From 91d7e16c81675ec1573196271c79cb67503f2ab5 Mon Sep 17 00:00:00 2001 From: Michael Kret <88898367+michael-radency@users.noreply.github.com> Date: Wed, 17 Aug 2022 18:50:24 +0300 Subject: [PATCH] n8n-3867-progressively-apply-prettier-to-all (#3873) * :hammer: formatting nodes with prettier --- .prettierignore | 192 +- packages/core/src/NodeExecuteFunctions.ts | 3 +- .../credentials/NocoDbApiToken.credentials.ts | 1 - .../nodes/GetResponse/ContactDescription.ts | 152 +- .../nodes/GetResponse/GenericFunctions.ts | 46 +- .../nodes/GetResponse/GetResponse.node.ts | 120 +- .../GetResponse/GetResponseTrigger.node.ts | 40 +- .../nodes/Ghost/GenericFunctions.ts | 43 +- packages/nodes-base/nodes/Ghost/Ghost.node.ts | 125 +- .../nodes-base/nodes/Ghost/PostDescription.ts | 308 +-- packages/nodes-base/nodes/Git/Git.node.ts | 96 +- .../Git/descriptions/AddConfigDescription.ts | 16 +- .../nodes/Git/descriptions/AddDescription.ts | 11 +- .../Git/descriptions/CloneDescription.ts | 8 +- .../Git/descriptions/CommitDescription.ts | 15 +- .../nodes/Git/descriptions/LogDescription.ts | 23 +- .../nodes/Git/descriptions/PushDescription.ts | 8 +- .../nodes/Git/descriptions/TagDescription.ts | 8 +- .../nodes/Github/GenericFunctions.ts | 56 +- .../nodes-base/nodes/Github/Github.node.ts | 41 +- .../nodes/Github/GithubTrigger.node.ts | 121 +- .../nodes/Gitlab/GenericFunctions.ts | 38 +- .../nodes-base/nodes/Gitlab/Gitlab.node.ts | 293 +-- .../nodes/Gitlab/GitlabTrigger.node.ts | 61 +- .../nodes/GoToWebinar/GenericFunctions.ts | 69 +- .../nodes/GoToWebinar/GoToWebinar.node.ts | 159 +- .../descriptions/AttendeeDescription.ts | 70 +- .../descriptions/CoorganizerDescription.ts | 157 +- .../descriptions/PanelistDescription.ts | 104 +- .../descriptions/RegistrantDescription.ts | 140 +- .../descriptions/SessionDescription.ts | 68 +- .../descriptions/WebinarDescription.ts | 126 +- .../nodes/Google/Ads/CampaignDescription.ts | 132 +- .../nodes/Google/Ads/GoogleAds.node.ts | 17 +- .../Google/Analytics/GenericFunctions.ts | 63 +- .../Google/Analytics/GoogleAnalytics.node.ts | 124 +- .../Google/Analytics/ReportDescription.ts | 79 +- .../Analytics/UserActivityDescription.ts | 55 +- .../nodes/Google/BigQuery/GenericFunctions.ts | 79 +- .../Google/BigQuery/GoogleBigQuery.node.ts | 57 +- .../Google/BigQuery/RecordDescription.ts | 153 +- .../nodes/Google/Books/GenericFunctions.ts | 82 +- .../nodes/Google/Books/GoogleBooks.node.ts | 194 +- .../Google/Calendar/CalendarDescription.ts | 42 +- .../nodes/Google/Calendar/EventDescription.ts | 238 +- .../nodes/Google/Calendar/EventInterface.ts | 10 +- .../nodes/Google/Calendar/GenericFunctions.ts | 45 +- .../Google/Calendar/GoogleCalendar.node.ts | 175 +- .../Calendar/GoogleCalendarTrigger.node.ts | 73 +- .../nodes/Google/Chat/GenericFunctions.ts | 111 +- .../nodes/Google/Chat/GoogleChat.node.ts | 171 +- .../descriptions/AttachmentDescription.ts | 21 +- .../IncomingWebhookDescription.ts | 89 +- .../Chat/descriptions/MediaDescription.ts | 26 +- .../Chat/descriptions/MemberDescription.ts | 33 +- .../Chat/descriptions/MessageDescription.ts | 149 +- .../Chat/descriptions/SpaceDescription.ts | 20 +- .../CloudNaturalLanguage/GenericFunctions.ts | 36 +- .../GoogleCloudNaturalLanguage.node.ts | 67 +- .../Google/CloudNaturalLanguage/Interface.ts | 2 +- .../Google/Contacts/ContactDescription.ts | 195 +- .../nodes/Google/Contacts/GenericFunctions.ts | 48 +- .../Google/Contacts/GoogleContacts.node.ts | 106 +- .../nodes/Google/Docs/DocumentDescription.ts | 478 ++-- .../nodes/Google/Docs/GenericFunctions.ts | 67 +- .../nodes/Google/Docs/GoogleDocs.node.ts | 207 +- .../nodes/Google/Docs/interfaces.d.ts | 4 +- .../nodes/Google/Drive/GenericFunctions.ts | 80 +- .../nodes/Google/Drive/GoogleDrive.node.ts | 788 +++--- .../Google/Drive/GoogleDriveTrigger.node.ts | 97 +- .../CloudFirestore/CollectionDescription.ts | 47 +- .../CloudFirestore/DocumentDescription.ts | 268 +- .../CloudFirestore/GenericFunctions.ts | 99 +- .../GoogleFirebaseCloudFirestore.node.ts | 207 +- .../RealtimeDatabase/GenericFunctions.ts | 69 +- .../GoogleFirebaseRealtimeDatabase.node.ts | 62 +- .../Google/GSuiteAdmin/GSuiteAdmin.node.ts | 79 +- .../Google/GSuiteAdmin/GenericFunctions.ts | 44 +- .../Google/GSuiteAdmin/GroupDescripion.ts | 118 +- .../Google/GSuiteAdmin/UserDescription.ts | 216 +- .../nodes/Google/Gmail/DraftDescription.ts | 148 +- .../nodes/Google/Gmail/GenericFunctions.ts | 115 +- .../nodes/Google/Gmail/Gmail.node.ts | 135 +- .../nodes/Google/Gmail/LabelDescription.ts | 64 +- .../nodes/Google/Gmail/MessageDescription.ts | 185 +- .../Google/Gmail/MessageLabelDescription.ts | 29 +- .../Google/Perspective/GenericFunctions.ts | 13 +- .../Perspective/GooglePerspective.node.ts | 73 +- .../nodes/Google/Perspective/types.d.ts | 2 +- .../nodes/Google/Sheet/GenericFunctions.ts | 96 +- .../nodes/Google/Sheet/GoogleSheet.ts | 265 +- .../nodes/Google/Sheet/GoogleSheets.node.ts | 428 ++-- .../nodes/Google/Slides/GenericFunctions.ts | 21 +- .../nodes/Google/Slides/GoogleSlides.node.ts | 202 +- .../nodes/Google/Task/GenericFunctions.ts | 39 +- .../nodes/Google/Task/GoogleTasks.node.ts | 38 +- .../nodes/Google/Task/TaskDescription.ts | 167 +- .../Google/Translate/GenericFunctions.ts | 77 +- .../Google/Translate/GoogleTranslate.node.ts | 57 +- .../Google/YouTube/ChannelDescription.ts | 165 +- .../nodes/Google/YouTube/CountryCodes.ts | 2158 ++++++++--------- .../nodes/Google/YouTube/GenericFunctions.ts | 43 +- .../Google/YouTube/PlaylistDescription.ts | 194 +- .../Google/YouTube/PlaylistItemDescription.ts | 154 +- .../YouTube/VideoCategoryDescription.ts | 40 +- .../nodes/Google/YouTube/VideoDescription.ts | 293 +-- .../nodes/Google/YouTube/YouTube.node.ts | 220 +- .../nodes/Gotify/GenericFunctions.ts | 45 +- .../nodes-base/nodes/Gotify/Gotify.node.ts | 87 +- .../nodes/Grafana/GenericFunctions.ts | 38 +- .../nodes-base/nodes/Grafana/Grafana.node.ts | 98 +- .../descriptions/DashboardDescription.ts | 90 +- .../Grafana/descriptions/TeamDescription.ts | 84 +- .../descriptions/TeamMemberDescription.ts | 83 +- .../Grafana/descriptions/UserDescription.ts | 52 +- packages/nodes-base/nodes/Grafana/types.d.ts | 36 +- .../nodes-base/nodes/GraphQL/GraphQL.node.ts | 116 +- .../nodes/Grist/GenericFunctions.ts | 42 +- packages/nodes-base/nodes/Grist/Grist.node.ts | 63 +- .../nodes/Grist/OperationDescription.ts | 83 +- packages/nodes-base/nodes/Grist/types.d.ts | 10 +- .../nodes/Gumroad/GenericFunctions.ts | 21 +- .../nodes/Gumroad/GumroadTrigger.node.ts | 37 +- .../nodes/HackerNews/GenericFunctions.ts | 38 +- .../nodes/HackerNews/HackerNews.node.ts | 108 +- .../nodes/HaloPSA/GenericFunctions.ts | 10 +- .../HaloPSA/descriptions/SiteDescription.ts | 3 +- .../HaloPSA/descriptions/TicketDescription.ts | 9 +- .../HaloPSA/descriptions/UserDescription.ts | 6 +- .../nodes/HaloPSA/descriptions/index.ts | 2 +- .../nodes/Harvest/ClientDescription.ts | 63 +- .../nodes/Harvest/CompanyDescription.ts | 9 +- .../nodes/Harvest/ContactDescription.ts | 55 +- .../nodes/Harvest/EstimateDescription.ts | 84 +- .../nodes/Harvest/ExpenseDescription.ts | 74 +- .../nodes/Harvest/GenericFunctions.ts | 40 +- .../nodes-base/nodes/Harvest/Harvest.node.ts | 342 ++- .../nodes/Harvest/InvoiceDescription.ts | 95 +- .../nodes/Harvest/ProjectDescription.ts | 97 +- .../nodes/Harvest/TaskDescription.ts | 71 +- .../nodes/Harvest/TimeEntryDescription.ts | 111 +- .../nodes/Harvest/UserDescription.ts | 83 +- .../HelpScout/ConversationDescription.ts | 158 +- .../nodes/HelpScout/CountriesCodes.ts | 2158 ++++++++--------- .../nodes/HelpScout/CustomerDescription.ts | 159 +- .../nodes/HelpScout/GenericFunctions.ts | 36 +- .../nodes/HelpScout/HelpScout.node.ts | 280 ++- .../nodes/HelpScout/HelpScoutTrigger.node.ts | 56 +- .../nodes/HelpScout/MailboxDescription.ts | 45 +- .../nodes/HelpScout/ThreadDescription.ts | 91 +- .../HomeAssistant/CameraProxyDescription.ts | 27 +- .../nodes/HomeAssistant/ConfigDescription.ts | 8 +- .../nodes/HomeAssistant/EventDescription.ts | 45 +- .../nodes/HomeAssistant/GenericFunctions.ts | 46 +- .../nodes/HomeAssistant/HistoryDescription.ts | 36 +- .../nodes/HomeAssistant/HomeAssistant.node.ts | 175 +- .../nodes/HomeAssistant/LogDescription.ts | 16 +- .../nodes/HomeAssistant/ServiceDescription.ts | 62 +- .../nodes/HomeAssistant/StateDescription.ts | 66 +- .../HomeAssistant/TemplateDescription.ts | 20 +- .../nodes/HtmlExtract/HtmlExtract.node.ts | 61 +- .../nodes/HttpRequest/GenericFunctions.ts | 2 +- .../nodes/HttpRequest/HttpRequest.node.ts | 428 ++-- .../nodes/Hubspot/CompanyDescription.ts | 281 +-- .../nodes/Hubspot/ContactDescription.ts | 293 +-- .../nodes/Hubspot/ContactListDescription.ts | 65 +- .../nodes/Hubspot/DealDescription.ts | 223 +- .../nodes-base/nodes/Hubspot/DealInterface.ts | 4 +- .../nodes/Hubspot/EngagementDescription.ts | 102 +- .../nodes/Hubspot/FormDescription.ts | 79 +- .../nodes-base/nodes/Hubspot/FormInterface.ts | 4 +- .../nodes/Hubspot/GenericFunctions.ts | 1857 +++++++------- .../nodes-base/nodes/Hubspot/Hubspot.node.ts | 401 ++- .../nodes/Hubspot/HubspotTrigger.node.ts | 123 +- .../nodes/Hubspot/TicketDescription.ts | 183 +- .../nodes/HumanticAI/GenericFunctions.ts | 20 +- .../nodes/HumanticAI/HumanticAi.node.ts | 49 +- .../nodes/HumanticAI/ProfileDescription.ts | 106 +- .../nodes/Hunter/GenericFunctions.ts | 28 +- .../nodes-base/nodes/Hunter/Hunter.node.ts | 98 +- .../nodes/ICalendar/ICalendar.node.ts | 76 +- packages/nodes-base/nodes/If/If.node.ts | 104 +- .../nodes/Intercom/CompanyDescription.ts | 149 +- .../nodes/Intercom/GenericFunctions.ts | 39 +- .../nodes/Intercom/Intercom.node.ts | 176 +- .../nodes/Intercom/LeadDescription.ts | 153 +- .../nodes/Intercom/UserDescription.ts | 178 +- .../nodes/Interval/Interval.node.ts | 15 +- .../nodes/InvoiceNinja/ClientDescription.ts | 118 +- .../nodes/InvoiceNinja/ExpenseDescription.ts | 81 +- .../nodes/InvoiceNinja/GenericFunctions.ts | 35 +- .../nodes/InvoiceNinja/ISOCountryCodes.ts | 2158 ++++++++--------- .../nodes/InvoiceNinja/InvoiceDescription.ts | 113 +- .../nodes/InvoiceNinja/InvoiceNinja.node.ts | 259 +- .../InvoiceNinja/InvoiceNinjaTrigger.node.ts | 21 +- .../nodes/InvoiceNinja/PaymentDescription.ts | 108 +- .../nodes/InvoiceNinja/QuoteDescription.ts | 113 +- .../nodes/InvoiceNinja/TaskDescription.ts | 103 +- .../nodes/ItemLists/ItemLists.node.ts | 615 ++--- .../nodes/Iterable/EventDescription.ts | 31 +- .../nodes/Iterable/GenericFunctions.ts | 47 +- .../nodes/Iterable/Iterable.node.ts | 47 +- .../nodes/Iterable/UserDescription.ts | 112 +- .../nodes/Iterable/UserListDescription.ts | 74 +- .../nodes/Jenkins/GenericFunctions.ts | 26 +- .../nodes-base/nodes/Jenkins/Jenkins.node.ts | 171 +- .../nodes-base/nodes/Jira/GenericFunctions.ts | 46 +- .../nodes/Jira/IssueAttachmentDescription.ts | 109 +- .../nodes/Jira/IssueCommentDescription.ts | 211 +- .../nodes-base/nodes/Jira/IssueDescription.ts | 382 ++- .../nodes-base/nodes/Jira/IssueInterface.ts | 4 +- packages/nodes-base/nodes/Jira/Jira.node.ts | 509 +++- .../nodes-base/nodes/Jira/JiraTrigger.node.ts | 58 +- .../nodes-base/nodes/Jira/UserDescription.ts | 71 +- .../nodes/JotForm/GenericFunctions.ts | 21 +- .../nodes/JotForm/JotFormTrigger.node.ts | 32 +- packages/nodes-base/nodes/Kafka/Kafka.node.ts | 72 +- .../nodes/Kafka/KafkaTrigger.node.ts | 57 +- .../nodes/Keap/CompanyDescription.ts | 92 +- .../nodes/Keap/ConctactInterface.ts | 4 +- .../nodes/Keap/ContactDescription.ts | 162 +- .../nodes/Keap/ContactNoteDescription.ts | 132 +- .../nodes/Keap/ContactNoteInterface.ts | 1 - .../nodes/Keap/ContactTagDescription.ts | 94 +- .../nodes/Keap/EcommerceOrderDescripion.ts | 142 +- .../nodes/Keap/EcommerceOrderInterface.ts | 26 +- .../nodes/Keap/EcommerceProductDescription.ts | 93 +- .../nodes/Keap/EcommerceProductInterface.ts | 1 - .../nodes-base/nodes/Keap/EmaiIInterface.ts | 1 - .../nodes-base/nodes/Keap/EmailDescription.ts | 138 +- .../nodes-base/nodes/Keap/FileDescription.ts | 137 +- .../nodes-base/nodes/Keap/FileInterface.ts | 1 - .../nodes-base/nodes/Keap/GenericFunctions.ts | 41 +- packages/nodes-base/nodes/Keap/Keap.node.ts | 250 +- .../nodes-base/nodes/Keap/KeapTrigger.node.ts | 33 +- .../nodes/Kitemaker/GenericFunctions.ts | 29 +- .../nodes/Kitemaker/Kitemaker.node.ts | 89 +- .../descriptions/OrganizationDescription.ts | 12 +- .../descriptions/SpaceDescription.ts | 30 +- .../Kitemaker/descriptions/UserDescription.ts | 30 +- .../descriptions/WorkItemDescription.ts | 110 +- .../nodes/KoBoToolbox/FormDescription.ts | 56 +- .../nodes/KoBoToolbox/GenericFunctions.ts | 104 +- .../nodes/KoBoToolbox/HookDescription.ts | 75 +- .../nodes/KoBoToolbox/KoBoToolbox.node.ts | 140 +- .../KoBoToolbox/KoBoToolboxTrigger.node.ts | 21 +- .../nodes-base/nodes/KoBoToolbox/Options.ts | 32 +- .../KoBoToolbox/SubmissionDescription.ts | 148 +- .../nodes/Lemlist/GenericFunctions.ts | 36 +- .../nodes-base/nodes/Lemlist/Lemlist.node.ts | 61 +- .../nodes/Lemlist/LemlistTrigger.node.ts | 23 +- .../descriptions/ActivityDescription.ts | 39 +- .../descriptions/CampaignDescription.ts | 28 +- .../Lemlist/descriptions/LeadDescription.ts | 84 +- .../Lemlist/descriptions/TeamDescription.ts | 9 +- .../descriptions/UnsubscribeDescription.ts | 44 +- .../nodes-base/nodes/Line/GenericFunctions.ts | 26 +- packages/nodes-base/nodes/Line/Line.node.ts | 50 +- .../nodes/Line/NotificationDescription.ts | 40 +- .../nodes/Linear/GenericFunctions.ts | 49 +- .../nodes/Linear/IssueDescription.ts | 96 +- .../nodes-base/nodes/Linear/Linear.node.ts | 22 +- .../nodes/Linear/LinearTrigger.node.ts | 49 +- .../nodes/LingvaNex/ActivityDescription.ts | 86 +- .../nodes/LingvaNex/GenericFunctions.ts | 21 +- .../nodes/LingvaNex/LingvaNex.node.ts | 35 +- .../nodes/LinkedIn/GenericFunctions.ts | 31 +- .../nodes/LinkedIn/LinkedIn.node.ts | 44 +- .../nodes/LinkedIn/PostDescription.ts | 91 +- .../LocalFileTrigger/LocalFileTrigger.node.ts | 42 +- packages/nodes-base/nodes/MQTT/Mqtt.node.ts | 45 +- .../nodes-base/nodes/MQTT/MqttTrigger.node.ts | 37 +- .../nodes/Magento/CustomerDescription.ts | 140 +- .../nodes/Magento/GenericFunctions.ts | 216 +- .../nodes/Magento/InvoiceDescription.ts | 17 +- .../nodes-base/nodes/Magento/Magento2.node.ts | 376 ++- .../nodes/Magento/OrderDescription.ts | 50 +- .../nodes/Magento/ProductDescription.ts | 107 +- packages/nodes-base/nodes/Magento/Types.d.ts | 20 +- .../nodes/Mailcheck/GenericFunctions.ts | 27 +- .../nodes/Mailcheck/Mailcheck.node.ts | 31 +- .../nodes/Mailchimp/GenericFunctions.ts | 58 +- .../nodes/Mailchimp/Mailchimp.node.ts | 786 +++--- .../nodes/Mailchimp/MailchimpTrigger.node.ts | 47 +- .../nodes/MailerLite/GenericFunctions.ts | 34 +- .../nodes/MailerLite/MailerLite.node.ts | 43 +- .../MailerLite/MailerLiteTrigger.node.ts | 26 +- .../nodes/MailerLite/SubscriberDescription.ts | 91 +- .../nodes-base/nodes/Mailgun/Mailgun.node.ts | 20 +- .../nodes/Mailjet/EmailDescription.ts | 148 +- .../nodes/Mailjet/GenericFunctions.ts | 60 +- .../nodes-base/nodes/Mailjet/Mailjet.node.ts | 57 +- .../nodes/Mailjet/MailjetTrigger.node.ts | 23 +- .../nodes/Mailjet/SmsDescription.ts | 41 +- .../nodes/Mandrill/GenericFunctions.ts | 43 +- .../nodes/Mandrill/Mandrill.node.ts | 227 +- .../nodes/Markdown/Markdown.node.ts | 45 +- .../nodes/Marketstack/GenericFunctions.ts | 25 +- .../nodes/Marketstack/Marketstack.node.ts | 40 +- .../descriptions/EndOfDayDataDescription.ts | 59 +- .../descriptions/ExchangeDescription.ts | 19 +- .../descriptions/TickerDescription.ts | 16 +- .../nodes/Matrix/AccountDescription.ts | 12 +- .../nodes/Matrix/EventDescription.ts | 26 +- .../nodes/Matrix/GenericFunctions.ts | 113 +- .../nodes-base/nodes/Matrix/Matrix.node.ts | 86 +- .../nodes/Matrix/MediaDescription.ts | 36 +- .../nodes/Matrix/MessageDescription.ts | 106 +- .../nodes/Matrix/RoomDescription.ts | 99 +- .../nodes/Matrix/RoomMemberDescription.ts | 36 +- .../nodes/Mattermost/Mattermost.node.ts | 5 +- .../nodes/Mattermost/v1/MattermostV1.node.ts | 11 +- .../nodes/Mattermost/v1/actions/Interfaces.ts | 6 +- .../v1/actions/channel/addUser/description.ts | 26 +- .../v1/actions/channel/addUser/execute.ts | 20 +- .../v1/actions/channel/addUser/index.ts | 5 +- .../v1/actions/channel/create/description.ts | 39 +- .../v1/actions/channel/create/execute.ts | 20 +- .../v1/actions/channel/create/index.ts | 5 +- .../v1/actions/channel/del/description.ts | 15 +- .../v1/actions/channel/del/execute.ts | 15 +- .../v1/actions/channel/del/index.ts | 5 +- .../Mattermost/v1/actions/channel/index.ts | 15 +- .../v1/actions/channel/members/description.ts | 62 +- .../v1/actions/channel/members/execute.ts | 23 +- .../v1/actions/channel/members/index.ts | 5 +- .../v1/actions/channel/restore/description.ts | 12 +- .../v1/actions/channel/restore/execute.ts | 22 +- .../v1/actions/channel/restore/index.ts | 5 +- .../v1/actions/channel/search/description.ts | 43 +- .../v1/actions/channel/search/execute.ts | 20 +- .../v1/actions/channel/search/index.ts | 5 +- .../actions/channel/statistics/description.ts | 16 +- .../v1/actions/channel/statistics/execute.ts | 20 +- .../v1/actions/channel/statistics/index.ts | 5 +- .../v1/actions/message/del/description.ts | 12 +- .../v1/actions/message/del/execute.ts | 15 +- .../v1/actions/message/del/index.ts | 5 +- .../Mattermost/v1/actions/message/index.ts | 10 +- .../v1/actions/message/post/description.ts | 55 +- .../v1/actions/message/post/execute.ts | 18 +- .../v1/actions/message/post/index.ts | 5 +- .../message/postEphemeral/description.ts | 34 +- .../actions/message/postEphemeral/execute.ts | 26 +- .../v1/actions/message/postEphemeral/index.ts | 5 +- .../v1/actions/reaction/create/description.ts | 34 +- .../v1/actions/reaction/create/execute.ts | 21 +- .../v1/actions/reaction/create/index.ts | 5 +- .../v1/actions/reaction/del/description.ts | 34 +- .../v1/actions/reaction/del/execute.ts | 15 +- .../v1/actions/reaction/del/index.ts | 5 +- .../v1/actions/reaction/getAll/description.ts | 32 +- .../v1/actions/reaction/getAll/execute.ts | 20 +- .../v1/actions/reaction/getAll/index.ts | 5 +- .../Mattermost/v1/actions/reaction/index.ts | 11 +- .../nodes/Mattermost/v1/actions/router.ts | 18 +- .../v1/actions/user/create/description.ts | 79 +- .../v1/actions/user/create/execute.ts | 22 +- .../v1/actions/user/create/index.ts | 5 +- .../v1/actions/user/deactive/description.ts | 12 +- .../v1/actions/user/deactive/execute.ts | 20 +- .../v1/actions/user/deactive/index.ts | 5 +- .../v1/actions/user/getAll/description.ts | 32 +- .../v1/actions/user/getAll/execute.ts | 79 +- .../v1/actions/user/getAll/index.ts | 5 +- .../v1/actions/user/getByEmail/description.ts | 14 +- .../v1/actions/user/getByEmail/execute.ts | 22 +- .../v1/actions/user/getByEmail/index.ts | 5 +- .../v1/actions/user/getById/description.ts | 25 +- .../v1/actions/user/getById/execute.ts | 20 +- .../v1/actions/user/getById/index.ts | 5 +- .../nodes/Mattermost/v1/actions/user/index.ts | 18 +- .../v1/actions/user/invite/description.ts | 25 +- .../v1/actions/user/invite/execute.ts | 23 +- .../v1/actions/user/invite/index.ts | 5 +- .../v1/actions/versionDescription.ts | 5 +- .../Mattermost/v1/methods/loadOptions.ts | 59 +- .../nodes/Mattermost/v1/transport/index.ts | 11 +- .../Mautic/CampaignContactDescription.ts | 32 +- .../nodes/Mautic/CompanyContactDescription.ts | 27 +- .../nodes/Mautic/CompanyDescription.ts | 140 +- .../nodes/Mautic/ContactDescription.ts | 421 +--- .../nodes/Mautic/ContactSegmentDescription.ts | 32 +- .../nodes/Mautic/GenericFunctions.ts | 39 +- .../nodes-base/nodes/Mautic/Mautic.node.ts | 305 ++- .../nodes/Mautic/MauticTrigger.node.ts | 28 +- .../nodes/Mautic/SegmentEmailDescription.ts | 20 +- .../nodes/Medium/GenericFunctions.ts | 25 +- .../nodes-base/nodes/Medium/Medium.node.ts | 145 +- packages/nodes-base/nodes/Merge/Merge.node.ts | 61 +- .../nodes/MessageBird/GenericFunctions.ts | 16 +- .../nodes/MessageBird/MessageBird.node.ts | 88 +- .../Microsoft/Dynamics/GenericFunctions.ts | 164 +- .../Dynamics/MicrosoftDynamicsCrm.node.ts | 92 +- .../descriptions/AccountDescription.ts | 112 +- .../Microsoft/Dynamics/descriptions/index.ts | 2 +- .../nodes/Microsoft/Excel/GenericFunctions.ts | 54 +- .../Microsoft/Excel/MicrosoftExcel.node.ts | 235 +- .../nodes/Microsoft/Excel/TableDescription.ts | 341 +-- .../Microsoft/Excel/WorkbookDescription.ts | 67 +- .../Microsoft/Excel/WorksheetDescription.ts | 158 +- .../GraphSecurity/GenericFunctions.ts | 21 +- .../MicrosoftGraphSecurity.node.ts | 64 +- .../SecureScoreControlProfileDescription.ts | 81 +- .../descriptions/SecureScoreDescription.ts | 47 +- .../Microsoft/OneDrive/FileDescription.ts | 256 +- .../Microsoft/OneDrive/FolderDescription.ts | 151 +- .../Microsoft/OneDrive/GenericFunctions.ts | 59 +- .../OneDrive/MicrosoftOneDrive.node.ts | 147 +- .../Microsoft/Outlook/DraftDescription.ts | 64 +- .../Outlook/DraftMessageSharedDescription.ts | 37 +- .../Microsoft/Outlook/FolderDescription.ts | 113 +- .../Outlook/FolderMessageDecription.ts | 47 +- .../Microsoft/Outlook/GenericFunctions.ts | 111 +- .../Outlook/MessageAttachmentDescription.ts | 80 +- .../Microsoft/Outlook/MessageDescription.ts | 140 +- .../Outlook/MicrosoftOutlook.node.ts | 272 ++- .../nodes/Microsoft/Sql/GenericFunctions.ts | 44 +- .../nodes/Microsoft/Sql/MicrosoftSql.node.ts | 97 +- .../Microsoft/Teams/ChannelDescription.ts | 157 +- .../Teams/ChannelMessageDescription.ts | 105 +- .../Microsoft/Teams/ChatMessageDescription.ts | 76 +- .../nodes/Microsoft/Teams/GenericFunctions.ts | 58 +- .../Microsoft/Teams/MicrosoftTeams.node.ts | 249 +- .../nodes/Microsoft/Teams/TaskDescription.ts | 254 +- .../nodes/Microsoft/ToDo/GenericFunctions.ts | 53 +- .../ToDo/LinkedResourceDescription.ts | 99 +- .../nodes/Microsoft/ToDo/ListDescription.ts | 52 +- .../Microsoft/ToDo/MicrosoftToDo.node.ts | 212 +- .../nodes/Microsoft/ToDo/TaskDescription.ts | 83 +- .../nodes/Mindee/GenericFunctions.ts | 7 +- .../nodes-base/nodes/Mindee/Mindee.node.ts | 8 +- .../nodes-base/nodes/Misp/GenericFunctions.ts | 48 +- packages/nodes-base/nodes/Misp/Misp.node.ts | 207 +- .../Misp/descriptions/AttributeDescription.ts | 100 +- .../Misp/descriptions/EventDescription.ts | 109 +- .../Misp/descriptions/EventTagDescription.ts | 46 +- .../Misp/descriptions/FeedDescription.ts | 100 +- .../Misp/descriptions/GalaxyDescription.ts | 44 +- .../descriptions/NoticelistDescription.ts | 36 +- .../descriptions/OrganisationDescription.ts | 76 +- .../nodes/Misp/descriptions/TagDescription.ts | 68 +- .../Misp/descriptions/UserDescription.ts | 96 +- .../descriptions/WarninglistDescription.ts | 36 +- packages/nodes-base/nodes/Misp/types.d.ts | 2 +- .../nodes/Mocean/GenericFunctions.ts | 20 +- .../nodes-base/nodes/Mocean/Mocean.node.ts | 79 +- .../nodes/MondayCom/BoardColumnDescription.ts | 68 +- .../nodes/MondayCom/BoardDescription.ts | 103 +- .../nodes/MondayCom/BoardGroupDescription.ts | 83 +- .../nodes/MondayCom/BoardItemDescription.ts | 306 +-- .../nodes/MondayCom/GenericFunctions.ts | 36 +- .../nodes/MondayCom/MondayCom.node.ts | 153 +- .../nodes-base/nodes/MongoDb/MongoDb.node.ts | 42 +- .../nodes/MongoDb/mongo.node.options.ts | 41 +- .../nodes/MongoDb/mongo.node.types.ts | 4 +- .../nodes/MongoDb/mongo.node.utils.ts | 28 +- .../nodes/MonicaCrm/GenericFunctions.ts | 29 +- .../nodes/MonicaCrm/MonicaCrm.node.ts | 216 +- .../descriptions/ActivityDescription.ts | 106 +- .../MonicaCrm/descriptions/CallDescription.ts | 84 +- .../descriptions/ContactDescription.ts | 98 +- .../descriptions/ContactFieldDescription.ts | 114 +- .../descriptions/ContactTagDescription.ts | 46 +- .../descriptions/ConversationDescription.ts | 78 +- .../ConversationMessageDescription.ts | 64 +- .../descriptions/JournalEntryDescription.ts | 76 +- .../MonicaCrm/descriptions/NoteDescription.ts | 84 +- .../descriptions/ReminderDescription.ts | 120 +- .../MonicaCrm/descriptions/TagDescription.ts | 68 +- .../MonicaCrm/descriptions/TaskDescription.ts | 84 +- .../nodes-base/nodes/MonicaCrm/types.d.ts | 4 +- .../MoveBinaryData/MoveBinaryData.node.ts | 157 +- .../nodes/Msg91/GenericFunctions.ts | 18 +- packages/nodes-base/nodes/Msg91/Msg91.node.ts | 47 +- .../nodes/MySql/GenericFunctions.ts | 7 +- packages/nodes-base/nodes/MySql/MySql.node.ts | 122 +- .../N8nTrainingCustomerDatastore.node.ts | 26 +- .../N8nTrainingCustomerMessenger.node.ts | 12 +- .../nodes/N8nTrigger/N8nTrigger.node.ts | 22 +- .../nodes-base/nodes/Nasa/GenericFunctions.ts | 41 +- packages/nodes-base/nodes/Nasa/Nasa.node.ts | 319 +-- .../nodes/Netlify/DeployDescription.ts | 64 +- .../nodes/Netlify/GenericFunctions.ts | 40 +- .../nodes-base/nodes/Netlify/Netlify.node.ts | 83 +- .../nodes/Netlify/NetlifyTrigger.node.ts | 47 +- .../nodes/Netlify/SiteDescription.ts | 37 +- .../nodes/NextCloud/GenericFunctions.ts | 34 +- .../nodes/NextCloud/NextCloud.node.ts | 492 ++-- packages/nodes-base/nodes/NoOp/NoOp.node.ts | 10 +- .../nodes/NocoDB/GenericFunctions.ts | 64 +- .../nodes-base/nodes/NocoDB/NocoDB.node.ts | 186 +- .../nodes/NocoDB/OperationDescription.ts | 130 +- .../nodes/Notion/BlockDescription.ts | 55 +- packages/nodes-base/nodes/Notion/Blocks.ts | 417 ++-- .../nodes/Notion/DatabaseDescription.ts | 109 +- .../nodes/Notion/DatabasePageDescription.ts | 498 ++-- packages/nodes-base/nodes/Notion/Filters.ts | 748 +++--- .../nodes/Notion/GenericFunctions.ts | 475 ++-- .../nodes-base/nodes/Notion/Notion.node.ts | 19 +- .../nodes/Notion/NotionTrigger.node.ts | 68 +- .../nodes/Notion/PageDescription.ts | 150 +- .../nodes/Notion/UserDescription.ts | 37 +- .../nodes/Notion/v1/NotionV1.node.ts | 237 +- .../nodes/Notion/v1/VersionDescription.ts | 241 +- .../nodes/Notion/v2/NotionV2.node.ts | 281 ++- .../nodes/Notion/v2/VersionDescription.ts | 31 +- .../nodes-base/nodes/Odoo/GenericFunctions.ts | 12 +- packages/nodes-base/nodes/Odoo/Odoo.node.ts | 66 +- .../Odoo/descriptions/ContactDescription.ts | 93 +- .../descriptions/CustomResourceDescription.ts | 105 +- .../Odoo/descriptions/NoteDescription.ts | 73 +- .../descriptions/OpportunityDescription.ts | 81 +- .../nodes/OneSimpleApi/GenericFunctions.ts | 28 +- .../nodes/OneSimpleApi/OneSimpleApi.node.ts | 268 +- .../nodes/Onfleet/GenericFunctions.ts | 53 +- .../nodes-base/nodes/Onfleet/Onfleet.node.ts | 62 +- packages/nodes-base/nodes/Onfleet/Onfleet.ts | 326 ++- .../nodes/Onfleet/OnfleetTrigger.node.ts | 45 +- .../nodes/Onfleet/WebhookMapping.ts | 4 +- .../descriptions/AdministratorDescription.ts | 86 +- .../descriptions/ContainerDescription.ts | 72 +- .../descriptions/DestinationDescription.ts | 152 +- .../Onfleet/descriptions/HubDescription.ts | 75 +- .../descriptions/OnfleetWebhookDescription.ts | 26 +- .../descriptions/OrganizationDescription.ts | 21 +- .../descriptions/RecipientDescription.ts | 113 +- .../Onfleet/descriptions/TaskDescription.ts | 115 +- .../Onfleet/descriptions/TeamDescription.ts | 134 +- .../descriptions/WebhookDescription.ts | 62 +- .../Onfleet/descriptions/WorkerDescription.ts | 213 +- .../nodes/OpenThesaurus/GenericFunctions.ts | 20 +- .../nodes/OpenThesaurus/OpenThesaurus.node.ts | 49 +- .../OpenWeatherMap/OpenWeatherMap.node.ts | 50 +- .../nodes/Orbit/ActivityDescription.ts | 86 +- .../nodes/Orbit/GenericFunctions.ts | 50 +- packages/nodes-base/nodes/Orbit/Interfaces.ts | 12 +- .../nodes/Orbit/MemberDescription.ts | 299 +-- .../nodes-base/nodes/Orbit/NoteDescription.ts | 118 +- packages/nodes-base/nodes/Orbit/Orbit.node.ts | 205 +- .../nodes-base/nodes/Orbit/PostDescription.ts | 113 +- .../nodes-base/nodes/Oura/GenericFunctions.ts | 11 +- packages/nodes-base/nodes/Oura/Oura.node.ts | 43 +- .../nodes/Oura/ProfileDescription.ts | 10 +- .../nodes/Oura/SummaryDescription.ts | 33 +- .../nodes/Paddle/CouponDescription.ts | 269 +- .../nodes/Paddle/GenericFunctions.ts | 42 +- .../nodes/Paddle/OrderDescription.ts | 17 +- .../nodes-base/nodes/Paddle/Paddle.node.ts | 115 +- .../nodes/Paddle/PaymentDescription.ts | 82 +- .../nodes/Paddle/PlanDescription.ts | 37 +- .../nodes/Paddle/ProductDescription.ts | 28 +- .../nodes/Paddle/UserDescription.ts | 63 +- .../nodes/PagerDuty/GenericFunctions.ts | 44 +- .../nodes/PagerDuty/IncidentDescription.ts | 201 +- .../nodes/PagerDuty/IncidentInterface.ts | 4 +- .../PagerDuty/IncidentNoteDescription.ts | 75 +- .../nodes/PagerDuty/LogEntryDescription.ts | 68 +- .../nodes/PagerDuty/PagerDuty.node.ts | 138 +- .../nodes/PagerDuty/UserDescription.ts | 22 +- .../nodes/PayPal/GenericFunctions.ts | 100 +- .../nodes-base/nodes/PayPal/PayPal.node.ts | 74 +- .../nodes/PayPal/PayPalTrigger.node.ts | 31 +- .../nodes/PayPal/PaymentDescription.ts | 128 +- .../nodes/Peekalink/GenericFunctions.ts | 20 +- .../nodes/Peekalink/Peekalink.node.ts | 15 +- .../nodes/Phantombuster/AgentDescription.ts | 149 +- .../nodes/Phantombuster/GenericFunctions.ts | 26 +- .../nodes/Phantombuster/Phantombuster.node.ts | 64 +- .../nodes/PhilipsHue/GenericFunctions.ts | 33 +- .../nodes/PhilipsHue/LightDescription.ts | 108 +- .../nodes/PhilipsHue/PhilipsHue.node.ts | 58 +- .../nodes/Pipedrive/GenericFunctions.ts | 177 +- .../nodes/Pipedrive/Pipedrive.node.ts | 1235 ++++------ .../nodes/Pipedrive/PipedriveTrigger.node.ts | 42 +- .../nodes-base/nodes/Plivo/CallDescription.ts | 43 +- .../nodes/Plivo/GenericFunctions.ts | 21 +- .../nodes-base/nodes/Plivo/MmsDescription.ts | 40 +- packages/nodes-base/nodes/Plivo/Plivo.node.ts | 44 +- .../nodes-base/nodes/Plivo/SmsDescription.ts | 32 +- .../nodes/PostBin/BinDescription.ts | 35 +- .../nodes/PostBin/GenericFunctions.ts | 58 +- .../nodes-base/nodes/PostBin/PostBin.node.ts | 15 +- .../nodes/PostBin/RequestDescription.ts | 55 +- .../nodes/PostHog/AliasDescription.ts | 37 +- .../nodes/PostHog/EventDescription.ts | 37 +- .../nodes/PostHog/GenericFunctions.ts | 26 +- .../nodes/PostHog/IdentityDescription.ts | 29 +- .../nodes-base/nodes/PostHog/PostHog.node.ts | 100 +- .../nodes/PostHog/TrackDescription.ts | 40 +- .../nodes/Postgres/Postgres.node.functions.ts | 157 +- .../nodes/Postgres/Postgres.node.ts | 60 +- .../nodes/Postmark/GenericFunctions.ts | 30 +- .../nodes/Postmark/PostmarkTrigger.node.ts | 48 +- .../nodes/ProfitWell/CompanyDescription.ts | 10 +- .../nodes/ProfitWell/GenericFunctions.ts | 32 +- .../nodes/ProfitWell/MetricDescription.ts | 101 +- .../nodes/ProfitWell/ProfitWell.node.ts | 23 +- .../nodes/Pushbullet/GenericFunctions.ts | 42 +- .../nodes/Pushbullet/Pushbullet.node.ts | 253 +- .../nodes/Pushcut/GenericFunctions.ts | 28 +- .../nodes-base/nodes/Pushcut/Pushcut.node.ts | 37 +- .../nodes/Pushcut/PushcutTrigger.node.ts | 27 +- .../nodes/Pushover/GenericFunctions.ts | 26 +- .../nodes/Pushover/Pushover.node.ts | 118 +- .../nodes-base/nodes/QuestDb/QuestDb.node.ts | 60 +- .../nodes/QuickBase/FieldDescription.ts | 44 +- .../nodes/QuickBase/FileDescription.ts | 52 +- .../nodes/QuickBase/GenericFunctions.ts | 45 +- .../nodes/QuickBase/QuickBase.node.ts | 101 +- .../nodes/QuickBase/RecordDescription.ts | 228 +- .../nodes/QuickBase/ReportDescription.ts | 60 +- .../nodes/QuickBooks/GenericFunctions.ts | 130 +- .../nodes/QuickBooks/QuickBooks.node.ts | 372 +-- .../Bill/BillAdditionalFieldsOptions.ts | 4 +- .../descriptions/Bill/BillDescription.ts | 111 +- .../CustomerAdditionalFieldsOptions.ts | 4 +- .../Customer/CustomerDescription.ts | 85 +- .../EmployeeAdditionalFieldsOptions.ts | 4 +- .../Employee/EmployeeDescription.ts | 93 +- .../EstimateAdditionalFieldsOptions.ts | 10 +- .../Estimate/EstimateDescription.ts | 162 +- .../Invoice/InvoiceAdditionalFieldsOptions.ts | 10 +- .../Invoice/InvoiceDescription.ts | 170 +- .../descriptions/Item/ItemDescription.ts | 49 +- .../Payment/PaymentAdditionalFieldsOptions.ts | 4 +- .../Payment/PaymentDescription.ts | 160 +- .../Purchase/PurchaseDescription.ts | 49 +- .../Transaction/TransactionDescription.ts | 47 +- .../Vendor/VendorAdditionalFieldsOptions.ts | 7 +- .../descriptions/Vendor/VendorDescription.ts | 85 +- .../nodes-base/nodes/QuickBooks/types.d.ts | 16 +- .../nodes/RabbitMQ/DefaultOptions.ts | 10 +- .../nodes/RabbitMQ/GenericFunctions.ts | 52 +- .../nodes/RabbitMQ/RabbitMQ.node.ts | 101 +- .../nodes/RabbitMQ/RabbitMQTrigger.node.ts | 71 +- .../nodes/Raindrop/GenericFunctions.ts | 16 +- .../nodes/Raindrop/Raindrop.node.ts | 97 +- .../descriptions/BookmarkDescription.ts | 107 +- .../descriptions/CollectionDescription.ts | 97 +- .../Raindrop/descriptions/TagDescription.ts | 61 +- .../Raindrop/descriptions/UserDescription.ts | 28 +- .../ReadBinaryFile/ReadBinaryFile.node.ts | 17 +- .../ReadBinaryFiles/ReadBinaryFiles.node.ts | 14 +- .../nodes-base/nodes/ReadPdf/ReadPDF.node.ts | 12 +- .../nodes/Reddit/GenericFunctions.ts | 32 +- .../nodes/Reddit/PostCommentDescription.ts | 96 +- .../nodes/Reddit/PostDescription.ts | 195 +- .../nodes/Reddit/ProfileDescription.ts | 45 +- .../nodes-base/nodes/Reddit/Reddit.node.ts | 90 +- .../nodes/Reddit/SubredditDescription.ts | 52 +- .../nodes/Reddit/UserDescription.ts | 58 +- packages/nodes-base/nodes/Redis/Redis.node.ts | 172 +- .../nodes/Redis/RedisTrigger.node.ts | 14 +- .../nodes/RenameKeys/RenameKeys.node.ts | 45 +- .../RespondToWebhook/RespondToWebhook.node.ts | 53 +- .../nodes/Rocketchat/GenericFunctions.ts | 23 +- .../nodes/Rocketchat/Rocketchat.node.ts | 118 +- .../nodes/RssFeedRead/RssFeedRead.node.ts | 18 +- .../nodes-base/nodes/Rundeck/Rundeck.node.ts | 46 +- .../nodes-base/nodes/Rundeck/RundeckApi.ts | 9 +- .../nodes-base/nodes/S3/GenericFunctions.ts | 130 +- packages/nodes-base/nodes/S3/S3.node.ts | 415 +++- .../nodes/Salesforce/AccountDescription.ts | 247 +- .../nodes/Salesforce/AttachmentDescription.ts | 127 +- .../Salesforce/CampaignMemberInterface.ts | 1 - .../nodes/Salesforce/CaseDescription.ts | 180 +- .../nodes/Salesforce/CaseInterface.ts | 1 - .../nodes/Salesforce/ContactDescription.ts | 232 +- .../Salesforce/CustomObjectDescription.ts | 219 +- .../nodes/Salesforce/DocumentDescription.ts | 39 +- .../nodes/Salesforce/FlowDescription.ts | 69 +- .../nodes/Salesforce/GenericFunctions.ts | 153 +- .../nodes/Salesforce/LeadDescription.ts | 232 +- .../nodes/Salesforce/LeadInterface.ts | 2 +- .../Salesforce/OpportunityDescription.ts | 217 +- .../nodes/Salesforce/Salesforce.node.ts | 717 ++++-- .../nodes/Salesforce/SearchDescription.ts | 20 +- .../nodes/Salesforce/TaskDescription.ts | 216 +- .../nodes/Salesforce/UserDescription.ts | 48 +- .../nodes/Salesmate/ActivityDescription.ts | 187 +- .../nodes/Salesmate/CompanyDescription.ts | 182 +- .../nodes/Salesmate/DealDescription.ts | 233 +- .../nodes/Salesmate/GenericFunctions.ts | 40 +- .../nodes/Salesmate/Salesmate.node.ts | 168 +- .../nodes/SeaTable/GenericFunctions.ts | 158 +- .../nodes-base/nodes/SeaTable/Interfaces.ts | 9 +- .../nodes/SeaTable/RowDescription.ts | 92 +- packages/nodes-base/nodes/SeaTable/Schema.ts | 86 +- .../nodes/SeaTable/SeaTable.node.ts | 161 +- .../nodes/SeaTable/SeaTableTrigger.node.ts | 56 +- packages/nodes-base/nodes/SeaTable/types.d.ts | 45 +- .../SecurityScorecard/GenericFunctions.ts | 26 +- .../SecurityScorecard.node.ts | 87 +- .../descriptions/CompanyDescription.ts | 85 +- .../descriptions/IndustryDescription.ts | 57 +- .../descriptions/InviteDescription.ts | 52 +- .../PortfolioCompanyDescription.ts | 59 +- .../descriptions/PortfolioDescription.ts | 65 +- .../descriptions/ReportDescription.ts | 124 +- .../nodes/Segment/GenericFunctions.ts | 23 +- .../nodes/Segment/GroupDescription.ts | 64 +- .../nodes/Segment/IdentifyDescription.ts | 53 +- .../nodes-base/nodes/Segment/Segment.node.ts | 78 +- .../nodes/Segment/TrackDescription.ts | 122 +- .../nodes/Segment/TrackInterface.ts | 6 +- .../nodes/SendGrid/ContactDescription.ts | 116 +- .../nodes/SendGrid/GenericFunctions.ts | 35 +- .../nodes/SendGrid/ListDescription.ts | 84 +- .../nodes/SendGrid/MailDescription.ts | 169 +- .../nodes/SendGrid/SendGrid.node.ts | 184 +- .../nodes/Sendy/CampaignDescription.ts | 114 +- .../nodes/Sendy/GenericFunctions.ts | 25 +- packages/nodes-base/nodes/Sendy/Sendy.node.ts | 78 +- .../nodes/Sendy/SubscriberDescription.ts | 150 +- .../nodes/SentryIo/EventDescription.ts | 98 +- .../nodes/SentryIo/GenericFunctions.ts | 50 +- .../nodes/SentryIo/IssueDescription.ts | 102 +- .../nodes/SentryIo/OrganizationDescription.ts | 96 +- .../nodes/SentryIo/ProjectDescription.ts | 149 +- .../nodes/SentryIo/ReleaseDescription.ts | 180 +- .../nodes/SentryIo/SentryIo.node.ts | 120 +- .../nodes/SentryIo/TeamDescription.ts | 155 +- .../nodes/ServiceNow/AttachmentDescription.ts | 114 +- .../ServiceNow/BusinessServiceDescription.ts | 43 +- .../ConfigurationItemsDescription.ts | 43 +- .../nodes/ServiceNow/DepartmentDescription.ts | 43 +- .../nodes/ServiceNow/DictionaryDescription.ts | 43 +- .../nodes/ServiceNow/GenericFunctions.ts | 87 +- .../nodes/ServiceNow/IncidentDescription.ts | 161 +- .../nodes/ServiceNow/ServiceNow.node.ts | 561 +++-- .../ServiceNow/TableRecordDescription.ts | 211 +- .../nodes/ServiceNow/UserDescription.ts | 143 +- .../nodes/ServiceNow/UserGroupDescription.ts | 43 +- .../nodes/ServiceNow/UserRoleDescription.ts | 43 +- packages/nodes-base/nodes/Set/Set.node.ts | 67 +- .../nodes/Shopify/GenericFunctions.ts | 48 +- .../nodes/Shopify/OrderDescription.ts | 140 +- .../nodes/Shopify/ProductDescription.ts | 171 +- .../nodes/Shopify/ProductInterface.ts | 4 +- .../nodes-base/nodes/Shopify/Shopify.node.ts | 162 +- .../nodes/Shopify/ShopifyTrigger.node.ts | 48 +- .../nodes/Signl4/GenericFunctions.ts | 23 +- .../nodes-base/nodes/Signl4/Signl4.node.ts | 73 +- .../nodes/Slack/ChannelDescription.ts | 377 +-- .../nodes-base/nodes/Slack/FileDescription.ts | 98 +- .../nodes/Slack/GenericFunctions.ts | 59 +- .../nodes/Slack/MessageDescription.ts | 423 ++-- .../nodes/Slack/MessageInterface.ts | 1 - .../nodes/Slack/ReactionDescription.ts | 36 +- packages/nodes-base/nodes/Slack/Slack.node.ts | 415 +++- .../nodes-base/nodes/Slack/StarDescription.ts | 47 +- .../nodes-base/nodes/Slack/UserDescription.ts | 27 +- .../nodes/Slack/UserGroupDescription.ts | 107 +- .../nodes/Slack/UserProfileDescription.ts | 41 +- .../nodes/Sms77/GenericFunctions.ts | 28 +- packages/nodes-base/nodes/Sms77/Sms77.node.ts | 76 +- .../nodes/Snowflake/GenericFunctions.ts | 5 +- .../nodes/Snowflake/Snowflake.node.ts | 74 +- .../SplitInBatches/SplitInBatches.node.ts | 14 +- .../nodes/Splunk/GenericFunctions.ts | 61 +- .../nodes-base/nodes/Splunk/Splunk.node.ts | 161 +- .../descriptions/FiredAlertDescription.ts | 8 +- .../SearchConfigurationDescription.ts | 55 +- .../descriptions/SearchJobDescription.ts | 89 +- .../descriptions/SearchResultDescription.ts | 55 +- .../Splunk/descriptions/UserDescription.ts | 100 +- packages/nodes-base/nodes/Splunk/types.d.ts | 6 +- .../nodes/Spontit/GenericFunctions.ts | 19 +- .../nodes/Spontit/PushDescription.ts | 54 +- .../nodes-base/nodes/Spontit/Spontit.node.ts | 20 +- .../nodes/Spotify/GenericFunctions.ts | 48 +- .../nodes/Spotify/IsoCountryCodes.ts | 6 +- .../nodes-base/nodes/Spotify/Spotify.node.ts | 342 +-- .../SpreadsheetFile/SpreadsheetFile.node.ts | 121 +- .../nodes/SseTrigger/SseTrigger.node.ts | 9 +- packages/nodes-base/nodes/Ssh/Ssh.node.ts | 130 +- .../nodes/Stackby/GenericFunction.ts | 46 +- .../nodes-base/nodes/Stackby/Stackby.node.ts | 98 +- packages/nodes-base/nodes/Start/Start.node.ts | 10 +- .../nodes/StickyNote/StickyNote.node.ts | 7 +- .../nodes/StopAndError/StopAndError.node.ts | 12 +- .../nodes/Storyblok/GenericFunctions.ts | 39 +- .../Storyblok/StoryContentDescription.ts | 65 +- .../Storyblok/StoryManagementDescription.ts | 191 +- .../nodes/Storyblok/Storyblok.node.ts | 118 +- .../nodes/Strapi/EntryDescription.ts | 131 +- .../nodes/Strapi/GenericFunctions.ts | 104 +- .../nodes-base/nodes/Strapi/Strapi.node.ts | 160 +- .../nodes/Strava/ActivityDescription.ts | 143 +- .../nodes/Strava/GenericFunctions.ts | 46 +- .../nodes-base/nodes/Strava/Strava.node.ts | 61 +- .../nodes/Strava/StravaTrigger.node.ts | 44 +- .../nodes-base/nodes/Stripe/Stripe.node.ts | 113 +- .../nodes/Stripe/StripeTrigger.node.ts | 941 +++---- .../Stripe/descriptions/BalanceDescription.ts | 8 +- .../Stripe/descriptions/ChargeDescription.ts | 107 +- .../Stripe/descriptions/CouponDescription.ts | 86 +- .../descriptions/CustomerCardDescription.ts | 56 +- .../descriptions/CustomerDescription.ts | 98 +- .../Stripe/descriptions/SourceDescription.ts | 81 +- .../Stripe/descriptions/TokenDescription.ts | 64 +- packages/nodes-base/nodes/Stripe/helpers.ts | 54 +- .../nodes/Supabase/GenericFunctions.ts | 79 +- .../nodes/Supabase/RowDescription.ts | 178 +- .../nodes/Supabase/Supabase.node.ts | 51 +- .../nodes/SurveyMonkey/GenericFunctions.ts | 40 +- .../nodes/SurveyMonkey/Interfaces.ts | 4 +- .../SurveyMonkey/SurveyMonkeyTrigger.node.ts | 191 +- .../nodes-base/nodes/Switch/Switch.node.ts | 166 +- .../nodes/SyncroMSP/SyncroMsp.node.ts | 5 +- .../nodes/SyncroMSP/v1/SyncroMspV1.node.ts | 10 +- .../nodes/SyncroMSP/v1/actions/Interfaces.ts | 14 +- .../v1/actions/contact/create/description.ts | 32 +- .../v1/actions/contact/create/execute.ts | 24 +- .../v1/actions/contact/create/index.ts | 5 +- .../v1/actions/contact/del/description.ts | 12 +- .../v1/actions/contact/del/execute.ts | 19 +- .../SyncroMSP/v1/actions/contact/del/index.ts | 5 +- .../v1/actions/contact/get/description.ts | 12 +- .../v1/actions/contact/get/execute.ts | 19 +- .../SyncroMSP/v1/actions/contact/get/index.ts | 5 +- .../v1/actions/contact/getAll/description.ts | 24 +- .../v1/actions/contact/getAll/execute.ts | 20 +- .../v1/actions/contact/getAll/index.ts | 5 +- .../SyncroMSP/v1/actions/contact/index.ts | 14 +- .../v1/actions/contact/update/description.ts | 24 +- .../v1/actions/contact/update/execute.ts | 24 +- .../v1/actions/contact/update/index.ts | 5 +- .../v1/actions/customer/create/description.ts | 31 +- .../v1/actions/customer/create/execute.ts | 34 +- .../v1/actions/customer/create/index.ts | 5 +- .../v1/actions/customer/del/description.ts | 12 +- .../v1/actions/customer/del/execute.ts | 19 +- .../v1/actions/customer/del/index.ts | 5 +- .../v1/actions/customer/get/description.ts | 12 +- .../v1/actions/customer/get/execute.ts | 19 +- .../v1/actions/customer/get/index.ts | 5 +- .../v1/actions/customer/getAll/description.ts | 32 +- .../v1/actions/customer/getAll/execute.ts | 19 +- .../v1/actions/customer/getAll/index.ts | 5 +- .../SyncroMSP/v1/actions/customer/index.ts | 15 +- .../v1/actions/customer/update/description.ts | 31 +- .../v1/actions/customer/update/execute.ts | 43 +- .../v1/actions/customer/update/index.ts | 5 +- .../v1/actions/rmm/create/description.ts | 36 +- .../v1/actions/rmm/create/execute.ts | 19 +- .../SyncroMSP/v1/actions/rmm/create/index.ts | 5 +- .../v1/actions/rmm/del/description.ts | 12 +- .../SyncroMSP/v1/actions/rmm/del/execute.ts | 19 +- .../SyncroMSP/v1/actions/rmm/del/index.ts | 5 +- .../v1/actions/rmm/get/description.ts | 12 +- .../SyncroMSP/v1/actions/rmm/get/execute.ts | 19 +- .../SyncroMSP/v1/actions/rmm/get/index.ts | 5 +- .../v1/actions/rmm/getAll/description.ts | 32 +- .../v1/actions/rmm/getAll/execute.ts | 18 +- .../SyncroMSP/v1/actions/rmm/getAll/index.ts | 5 +- .../nodes/SyncroMSP/v1/actions/rmm/index.ts | 14 +- .../v1/actions/rmm/mute/description.ts | 20 +- .../SyncroMSP/v1/actions/rmm/mute/execute.ts | 19 +- .../SyncroMSP/v1/actions/rmm/mute/index.ts | 5 +- .../nodes/SyncroMSP/v1/actions/router.ts | 16 +- .../v1/actions/ticket/create/description.ts | 29 +- .../v1/actions/ticket/create/execute.ts | 25 +- .../v1/actions/ticket/create/index.ts | 5 +- .../v1/actions/ticket/del/description.ts | 12 +- .../v1/actions/ticket/del/execute.ts | 19 +- .../SyncroMSP/v1/actions/ticket/del/index.ts | 5 +- .../v1/actions/ticket/get/description.ts | 12 +- .../v1/actions/ticket/get/execute.ts | 19 +- .../SyncroMSP/v1/actions/ticket/get/index.ts | 5 +- .../v1/actions/ticket/getAll/description.ts | 32 +- .../v1/actions/ticket/getAll/execute.ts | 19 +- .../v1/actions/ticket/getAll/index.ts | 5 +- .../SyncroMSP/v1/actions/ticket/index.ts | 13 +- .../v1/actions/ticket/update/description.ts | 20 +- .../v1/actions/ticket/update/execute.ts | 28 +- .../v1/actions/ticket/update/index.ts | 5 +- .../v1/actions/versionDescription.ts | 4 +- .../nodes/SyncroMSP/v1/methods/loadOptions.ts | 13 +- .../SyncroMSP/v1/methods/sharedFields.ts | 4 +- .../nodes/SyncroMSP/v1/transport/index.ts | 26 +- .../nodes/Taiga/GenericFunctions.ts | 59 +- packages/nodes-base/nodes/Taiga/Taiga.node.ts | 171 +- .../nodes/Taiga/TaigaTrigger.node.ts | 24 +- .../Taiga/descriptions/EpicDescription.ts | 152 +- .../Taiga/descriptions/IssueDescription.ts | 271 +-- .../Taiga/descriptions/TaskDescription.ts | 236 +- .../descriptions/UserStoryDescription.ts | 235 +- packages/nodes-base/nodes/Taiga/types.d.ts | 6 +- .../nodes/Tapfiliate/AffiliateDescription.ts | 90 +- .../AffiliateMetadataDescription.ts | 66 +- .../nodes/Tapfiliate/GenericFunctions.ts | 40 +- .../Tapfiliate/ProgramAffiliateDescription.ts | 131 +- .../nodes/Tapfiliate/Tapfiliate.node.ts | 110 +- .../nodes/Telegram/GenericFunctions.ts | 53 +- packages/nodes-base/nodes/Telegram/IEvent.ts | 3 +- .../nodes/Telegram/Telegram.node.ts | 571 ++--- .../nodes/Telegram/TelegramTrigger.node.ts | 90 +- .../nodes/TheHive/GenericFunctions.ts | 109 +- .../nodes/TheHive/QueryFunctions.ts | 87 +- .../nodes-base/nodes/TheHive/TheHive.node.ts | 696 +++--- .../nodes/TheHive/TheHiveTrigger.node.ts | 22 +- .../TheHive/descriptions/AlertDescription.ts | 262 +- .../TheHive/descriptions/CaseDescription.ts | 207 +- .../TheHive/descriptions/LogDescription.ts | 97 +- .../descriptions/ObservableDescription.ts | 222 +- .../TheHive/descriptions/TaskDescription.ts | 160 +- .../TheHive/interfaces/AlertInterface.ts | 4 +- .../nodes/TheHive/interfaces/CaseInterface.ts | 1 - .../TheHive/interfaces/ObservableInterface.ts | 4 +- .../nodes/TimescaleDb/TimescaleDb.node.ts | 90 +- .../nodes/Todoist/GenericFunctions.ts | 27 +- .../nodes/Todoist/OperationHandler.ts | 59 +- packages/nodes-base/nodes/Todoist/Service.ts | 30 +- .../nodes-base/nodes/Todoist/Todoist.node.ts | 227 +- .../nodes/Toggl/GenericFunctions.ts | 31 +- .../nodes/Toggl/TogglTrigger.node.ts | 1 - .../nodes/TravisCi/BuildDescription.ts | 93 +- .../nodes/TravisCi/GenericFunctions.ts | 44 +- .../nodes/TravisCi/TravisCi.node.ts | 54 +- .../nodes/Trello/AttachmentDescription.ts | 91 +- .../nodes/Trello/BoardDescription.ts | 88 +- .../nodes/Trello/BoardMemberDescription.ts | 111 +- .../nodes/Trello/CardCommentDescription.ts | 64 +- .../nodes/Trello/CardDescription.ts | 95 +- .../nodes/Trello/ChecklistDescription.ts | 199 +- .../nodes/Trello/GenericFunctions.ts | 41 +- .../nodes/Trello/LabelDescription.ts | 124 +- .../nodes/Trello/ListDescription.ts | 158 +- .../nodes-base/nodes/Trello/Trello.node.ts | 167 +- .../nodes/Trello/TrelloTrigger.node.ts | 17 +- .../nodes/Twake/GenericFunctions.ts | 25 +- packages/nodes-base/nodes/Twake/Twake.node.ts | 28 +- .../nodes/Twilio/GenericFunctions.ts | 26 +- .../nodes-base/nodes/Twilio/Twilio.node.ts | 92 +- .../nodes/Twist/ChannelDescription.ts | 108 +- .../nodes/Twist/CommentDescription.ts | 144 +- .../nodes/Twist/GenericFunctions.ts | 26 +- .../Twist/MessageConversationDescription.ts | 152 +- .../nodes/Twist/ThreadDescription.ts | 155 +- packages/nodes-base/nodes/Twist/Twist.node.ts | 299 ++- .../nodes/Twitter/DirectMessageDescription.ts | 38 +- .../nodes/Twitter/GenericFunctions.ts | 80 +- .../nodes/Twitter/TweetDescription.ts | 127 +- .../nodes-base/nodes/Twitter/Twitter.node.ts | 91 +- .../nodes/Typeform/GenericFunctions.ts | 47 +- .../nodes/Typeform/TypeformTrigger.node.ts | 58 +- .../nodes/UProc/GenericFunctions.ts | 19 +- .../nodes/UProc/GroupDescription.ts | 9 +- .../nodes-base/nodes/UProc/Json/Groups.ts | 16 +- .../nodes-base/nodes/UProc/ToolDescription.ts | 33 +- packages/nodes-base/nodes/UProc/UProc.node.ts | 45 +- .../UnleashedSoftware/GenericFunctions.ts | 54 +- .../SalesOrderDescription.ts | 46 +- .../StockOnHandDescription.ts | 54 +- .../UnleashedSoftware.node.ts | 44 +- .../nodes/Uplead/CompanyDesciption.ts | 27 +- .../nodes/Uplead/GenericFunctions.ts | 16 +- .../nodes/Uplead/PersonDescription.ts | 43 +- .../nodes-base/nodes/Uplead/Uplead.node.ts | 31 +- .../UptimeRobot/AlertContactDescription.ts | 88 +- .../nodes/UptimeRobot/GenericFunctions.ts | 24 +- .../MaintenanceWindowDescription.ts | 134 +- .../nodes/UptimeRobot/MonitorDescription.ts | 86 +- .../PublicStatusPageDescription.ts | 92 +- .../nodes/UptimeRobot/UptimeRobot.node.ts | 110 +- .../nodes/UrlScanIo/GenericFunctions.ts | 23 +- .../nodes/UrlScanIo/UrlScanIo.node.ts | 48 +- .../UrlScanIo/descriptions/ScanDescription.ts | 69 +- .../nodes-base/nodes/Vero/EventDescripion.ts | 97 +- .../nodes-base/nodes/Vero/GenericFunctions.ts | 25 +- .../nodes-base/nodes/Vero/UserDescription.ts | 169 +- packages/nodes-base/nodes/Vero/Vero.node.ts | 52 +- .../nodes/Vonage/GenericFunctions.ts | 26 +- .../nodes-base/nodes/Vonage/Vonage.node.ts | 65 +- packages/nodes-base/nodes/Wait/Wait.node.ts | 227 +- .../nodes/Webflow/GenericFunctions.ts | 16 +- .../nodes/Webflow/ItemDescription.ts | 197 +- .../nodes-base/nodes/Webflow/Webflow.node.ts | 107 +- .../nodes/Webflow/WebflowTrigger.node.ts | 31 +- .../nodes-base/nodes/Webhook/Webhook.node.ts | 159 +- .../nodes/Wekan/BoardDescription.ts | 84 +- .../nodes/Wekan/CardCommentDescription.ts | 236 +- .../nodes-base/nodes/Wekan/CardDescription.ts | 316 +-- .../nodes/Wekan/ChecklistDescription.ts | 245 +- .../nodes/Wekan/ChecklistItemDescription.ts | 235 +- .../nodes/Wekan/GenericFunctions.ts | 24 +- .../nodes-base/nodes/Wekan/ListDescription.ts | 104 +- packages/nodes-base/nodes/Wekan/Wekan.node.ts | 139 +- .../nodes-base/nodes/Wise/GenericFunctions.ts | 93 +- packages/nodes-base/nodes/Wise/Wise.node.ts | 170 +- .../nodes-base/nodes/Wise/WiseTrigger.node.ts | 54 +- .../Wise/descriptions/AccountDescription.ts | 95 +- .../descriptions/ExchangeRateDescription.ts | 32 +- .../Wise/descriptions/ProfileDescription.ts | 19 +- .../Wise/descriptions/QuoteDescription.ts | 70 +- .../Wise/descriptions/RecipientDescription.ts | 28 +- .../Wise/descriptions/TransferDescription.ts | 161 +- .../nodes/WooCommerce/GenericFunctions.ts | 83 +- .../nodes/WooCommerce/OrderDescription.ts | 218 +- .../nodes/WooCommerce/ProductDescription.ts | 185 +- .../nodes/WooCommerce/ProductInterface.ts | 10 +- .../nodes/WooCommerce/WooCommerce.node.ts | 164 +- .../WooCommerce/WooCommerceTrigger.node.ts | 51 +- .../descriptions/CustomerDescription.ts | 73 +- .../nodes/WooCommerce/descriptions/shared.ts | 28 +- .../nodes/Wordpress/GenericFunctions.ts | 41 +- .../nodes/Wordpress/PostDescription.ts | 168 +- .../nodes/Wordpress/PostInterface.ts | 1 - .../nodes/Wordpress/UserDescription.ts | 427 ++-- .../nodes/Wordpress/UserInterface.ts | 1 - .../nodes/Wordpress/Wordpress.node.ts | 55 +- .../nodes/Workable/GenericFunctions.ts | 28 +- .../nodes/Workable/WorkableTrigger.node.ts | 33 +- .../WorkflowTrigger/WorkflowTrigger.node.ts | 19 +- .../WriteBinaryFile/WriteBinaryFile.node.ts | 33 +- .../nodes/Wufoo/GenericFunctions.ts | 20 +- .../nodes/Wufoo/WufooTrigger.node.ts | 41 +- .../nodes/Xero/ContactDescription.ts | 142 +- .../nodes-base/nodes/Xero/GenericFunctions.ts | 44 +- .../nodes/Xero/IContactInterface.ts | 1 - .../nodes/Xero/InvoiceDescription.ts | 264 +- .../nodes-base/nodes/Xero/InvoiceInterface.ts | 6 +- packages/nodes-base/nodes/Xero/Xero.node.ts | 135 +- packages/nodes-base/nodes/Xml/Xml.node.ts | 60 +- .../nodes/Yourls/GenericFunctions.ts | 27 +- .../nodes-base/nodes/Yourls/UrlDescription.ts | 41 +- .../nodes-base/nodes/Yourls/Yourls.node.ts | 20 +- .../nodes/Zammad/GenericFunctions.ts | 47 +- .../nodes-base/nodes/Zammad/Zammad.node.ts | 206 +- .../Zammad/descriptions/GroupDescription.ts | 91 +- .../descriptions/OrganizationDescription.ts | 91 +- .../Zammad/descriptions/TicketDescription.ts | 99 +- .../Zammad/descriptions/UserDescription.ts | 132 +- packages/nodes-base/nodes/Zammad/types.d.ts | 18 +- .../nodes/Zendesk/ConditionDescription.ts | 92 +- .../nodes/Zendesk/GenericFunctions.ts | 48 +- .../nodes/Zendesk/OrganizationDescription.ts | 137 +- .../nodes/Zendesk/TicketDescription.ts | 225 +- .../nodes/Zendesk/TicketFieldDescription.ts | 49 +- .../nodes/Zendesk/TicketInterface.ts | 6 +- .../nodes/Zendesk/TriggerPlaceholders.ts | 72 +- .../nodes/Zendesk/UserDescription.ts | 255 +- .../nodes-base/nodes/Zendesk/Zendesk.node.ts | 268 +- .../nodes/Zendesk/ZendeskTrigger.node.ts | 130 +- .../nodes-base/nodes/Zoho/GenericFunctions.ts | 100 +- .../nodes-base/nodes/Zoho/ZohoCrm.node.ts | 183 +- .../Zoho/descriptions/AccountDescription.ts | 86 +- .../Zoho/descriptions/ContactDescription.ts | 75 +- .../Zoho/descriptions/DealDescription.ts | 95 +- .../Zoho/descriptions/InvoiceDescription.ts | 89 +- .../Zoho/descriptions/LeadDescription.ts | 91 +- .../Zoho/descriptions/ProductDescription.ts | 73 +- .../descriptions/PurchaseOrderDescription.ts | 101 +- .../Zoho/descriptions/QuoteDescription.ts | 83 +- .../descriptions/SalesOrderDescription.ts | 116 +- .../nodes/Zoho/descriptions/SharedFields.ts | 35 +- .../Zoho/descriptions/VendorDescription.ts | 68 +- packages/nodes-base/nodes/Zoho/types.d.ts | 58 +- .../nodes-base/nodes/Zoom/GenericFunctions.ts | 44 +- .../nodes/Zoom/MeetingDescription.ts | 130 +- .../Zoom/MeetingRegistrantDescription.ts | 108 +- .../nodes/Zoom/WebinarDescription.ts | 124 +- packages/nodes-base/nodes/Zoom/Zoom.node.ts | 87 +- .../nodes/Zulip/GenericFunctions.ts | 21 +- .../nodes/Zulip/MessageDescription.ts | 101 +- .../nodes/Zulip/StreamDescription.ts | 140 +- .../nodes-base/nodes/Zulip/UserDescription.ts | 85 +- packages/nodes-base/nodes/Zulip/Zulip.node.ts | 115 +- .../nodes-base/nodes/utils/allCurrencies.ts | 2 +- packages/nodes-base/nodes/utils/utilities.ts | 11 +- 1072 files changed, 42357 insertions(+), 59109 deletions(-) diff --git a/.prettierignore b/.prettierignore index 6fba26b4f0..ac6ea14896 100644 --- a/.prettierignore +++ b/.prettierignore @@ -7,194 +7,4 @@ packages/design-system !packages/nodes-base/test !packages/nodes-base/nodes -packages/nodes-base/nodes/GetResponse -packages/nodes-base/nodes/Ghost -packages/nodes-base/nodes/Git -packages/nodes-base/nodes/Github -packages/nodes-base/nodes/Gitlab -packages/nodes-base/nodes/Google -packages/nodes-base/nodes/Gotify -packages/nodes-base/nodes/GoToWebinar -packages/nodes-base/nodes/Grafana -packages/nodes-base/nodes/GraphQL -packages/nodes-base/nodes/Grist -packages/nodes-base/nodes/Gumroad -packages/nodes-base/nodes/HackerNews -packages/nodes-base/nodes/HaloPSA -packages/nodes-base/nodes/Harvest -packages/nodes-base/nodes/HelpScout -packages/nodes-base/nodes/HomeAssistant -packages/nodes-base/nodes/HtmlExtract -packages/nodes-base/nodes/HttpRequest -packages/nodes-base/nodes/Hubspot -packages/nodes-base/nodes/HumanticAI -packages/nodes-base/nodes/Hunter -packages/nodes-base/nodes/ICalendar -packages/nodes-base/nodes/If -packages/nodes-base/nodes/Intercom -packages/nodes-base/nodes/Interval -packages/nodes-base/nodes/InvoiceNinja -packages/nodes-base/nodes/ItemLists -packages/nodes-base/nodes/Iterable -packages/nodes-base/nodes/Jenkins -packages/nodes-base/nodes/Jira -packages/nodes-base/nodes/JotForm -packages/nodes-base/nodes/Kafka -packages/nodes-base/nodes/Keap -packages/nodes-base/nodes/Kitemaker -packages/nodes-base/nodes/KoBoToolbox -packages/nodes-base/nodes/Lemlist -packages/nodes-base/nodes/Line -packages/nodes-base/nodes/Linear -packages/nodes-base/nodes/LingvaNex -packages/nodes-base/nodes/LinkedIn -packages/nodes-base/nodes/LocalFileTrigger -packages/nodes-base/nodes/Magento -packages/nodes-base/nodes/Mailcheck -packages/nodes-base/nodes/Mailchimp -packages/nodes-base/nodes/MailerLite -packages/nodes-base/nodes/Mailgun -packages/nodes-base/nodes/Mailjet -packages/nodes-base/nodes/Mandrill -packages/nodes-base/nodes/Markdown -packages/nodes-base/nodes/Marketstack -packages/nodes-base/nodes/Matrix -packages/nodes-base/nodes/Mattermost -packages/nodes-base/nodes/Mautic -packages/nodes-base/nodes/Medium -packages/nodes-base/nodes/Merge -packages/nodes-base/nodes/MessageBird -packages/nodes-base/nodes/Microsoft -packages/nodes-base/nodes/Mindee -packages/nodes-base/nodes/Misp -packages/nodes-base/nodes/Mocean -packages/nodes-base/nodes/MondayCom -packages/nodes-base/nodes/MongoDb -packages/nodes-base/nodes/MonicaCrm -packages/nodes-base/nodes/MoveBinaryData -packages/nodes-base/nodes/MQTT -packages/nodes-base/nodes/Msg91 -packages/nodes-base/nodes/MySql -packages/nodes-base/nodes/N8nTrainingCustomerDatastore -packages/nodes-base/nodes/N8nTrainingCustomerMessenger -packages/nodes-base/nodes/N8nTrigger -packages/nodes-base/nodes/Nasa -packages/nodes-base/nodes/Netlify -packages/nodes-base/nodes/NextCloud -packages/nodes-base/nodes/NocoDB -packages/nodes-base/nodes/NoOp -packages/nodes-base/nodes/Notion -packages/nodes-base/nodes/Odoo -packages/nodes-base/nodes/OneSimpleApi -packages/nodes-base/nodes/Onfleet -packages/nodes-base/nodes/OpenThesaurus -packages/nodes-base/nodes/OpenWeatherMap -packages/nodes-base/nodes/Orbit -packages/nodes-base/nodes/Oura -packages/nodes-base/nodes/Paddle -packages/nodes-base/nodes/PagerDuty -packages/nodes-base/nodes/PayPal -packages/nodes-base/nodes/Peekalink -packages/nodes-base/nodes/Phantombuster -packages/nodes-base/nodes/PhilipsHue -packages/nodes-base/nodes/Pipedrive -packages/nodes-base/nodes/Plivo -packages/nodes-base/nodes/PostBin -packages/nodes-base/nodes/Postgres -packages/nodes-base/nodes/PostHog -packages/nodes-base/nodes/Postmark -packages/nodes-base/nodes/ProfitWell -packages/nodes-base/nodes/Pushbullet -packages/nodes-base/nodes/Pushcut -packages/nodes-base/nodes/Pushover -packages/nodes-base/nodes/QuestDb -packages/nodes-base/nodes/QuickBase -packages/nodes-base/nodes/QuickBooks -packages/nodes-base/nodes/RabbitMQ -packages/nodes-base/nodes/Raindrop -packages/nodes-base/nodes/ReadBinaryFile -packages/nodes-base/nodes/ReadBinaryFiles -packages/nodes-base/nodes/ReadPdf -packages/nodes-base/nodes/Reddit -packages/nodes-base/nodes/Redis -packages/nodes-base/nodes/RenameKeys -packages/nodes-base/nodes/RespondToWebhook -packages/nodes-base/nodes/Rocketchat -packages/nodes-base/nodes/RssFeedRead -packages/nodes-base/nodes/Rundeck -packages/nodes-base/nodes/S3 -packages/nodes-base/nodes/Salesforce -packages/nodes-base/nodes/Salesmate -packages/nodes-base/nodes/SeaTable -packages/nodes-base/nodes/SecurityScorecard -packages/nodes-base/nodes/Segment -packages/nodes-base/nodes/SendGrid -packages/nodes-base/nodes/Sendy -packages/nodes-base/nodes/SentryIo -packages/nodes-base/nodes/ServiceNow -packages/nodes-base/nodes/Set -packages/nodes-base/nodes/Shopify -packages/nodes-base/nodes/Signl4 -packages/nodes-base/nodes/Slack -packages/nodes-base/nodes/Sms77 -packages/nodes-base/nodes/Snowflake -packages/nodes-base/nodes/SplitInBatches -packages/nodes-base/nodes/Splunk -packages/nodes-base/nodes/Spontit -packages/nodes-base/nodes/Spotify -packages/nodes-base/nodes/SpreadsheetFile -packages/nodes-base/nodes/SseTrigger -packages/nodes-base/nodes/Ssh -packages/nodes-base/nodes/Stackby -packages/nodes-base/nodes/Start -packages/nodes-base/nodes/StickyNote -packages/nodes-base/nodes/StopAndError -packages/nodes-base/nodes/Storyblok -packages/nodes-base/nodes/Strapi -packages/nodes-base/nodes/Strava -packages/nodes-base/nodes/Stripe -packages/nodes-base/nodes/Supabase -packages/nodes-base/nodes/SurveyMonkey -packages/nodes-base/nodes/Switch -packages/nodes-base/nodes/SyncroMSP -packages/nodes-base/nodes/Taiga -packages/nodes-base/nodes/Tapfiliate -packages/nodes-base/nodes/Telegram -packages/nodes-base/nodes/TheHive -packages/nodes-base/nodes/TimescaleDb -packages/nodes-base/nodes/Todoist -packages/nodes-base/nodes/Toggl -packages/nodes-base/nodes/TravisCi -packages/nodes-base/nodes/Trello -packages/nodes-base/nodes/Twake -packages/nodes-base/nodes/Twilio -packages/nodes-base/nodes/Twist -packages/nodes-base/nodes/Twitter -packages/nodes-base/nodes/Typeform -packages/nodes-base/nodes/UnleashedSoftware -packages/nodes-base/nodes/Uplead -packages/nodes-base/nodes/UProc -packages/nodes-base/nodes/UptimeRobot -packages/nodes-base/nodes/UrlScanIo -packages/nodes-base/nodes/utils -packages/nodes-base/nodes/Vero -packages/nodes-base/nodes/Vonage -packages/nodes-base/nodes/Wait -packages/nodes-base/nodes/Webflow -packages/nodes-base/nodes/Webhook -packages/nodes-base/nodes/Wekan -packages/nodes-base/nodes/Wise -packages/nodes-base/nodes/WooCommerce -packages/nodes-base/nodes/Wordpress -packages/nodes-base/nodes/Workable -packages/nodes-base/nodes/WorkflowTrigger -packages/nodes-base/nodes/WriteBinaryFile -packages/nodes-base/nodes/Wufoo -packages/nodes-base/nodes/Xero -packages/nodes-base/nodes/Xml -packages/nodes-base/nodes/Yourls -packages/nodes-base/nodes/Zammad -packages/nodes-base/nodes/Zendesk -packages/nodes-base/nodes/Zoho -packages/nodes-base/nodes/Zoom -packages/nodes-base/nodes/Zulip +packages/nodes-base/nodes/UProc/Json/Tools.ts diff --git a/packages/core/src/NodeExecuteFunctions.ts b/packages/core/src/NodeExecuteFunctions.ts index 0171dd1849..3c029bd55c 100644 --- a/packages/core/src/NodeExecuteFunctions.ts +++ b/packages/core/src/NodeExecuteFunctions.ts @@ -537,9 +537,8 @@ function digestAuthAxiosConfig( async function proxyRequestToAxios( uriOrObject: string | IDataObject, options?: IDataObject, + // tslint:disable-next-line:no-any ): Promise { - // tslint:disable-line:no-any - // Check if there's a better way of getting this config here if (process.env.N8N_USE_DEPRECATED_REQUEST_LIB) { // @ts-ignore diff --git a/packages/nodes-base/credentials/NocoDbApiToken.credentials.ts b/packages/nodes-base/credentials/NocoDbApiToken.credentials.ts index 62455a9d5a..5661928e56 100644 --- a/packages/nodes-base/credentials/NocoDbApiToken.credentials.ts +++ b/packages/nodes-base/credentials/NocoDbApiToken.credentials.ts @@ -5,7 +5,6 @@ import { INodeProperties, } from 'n8n-workflow'; - export class NocoDbApiToken implements ICredentialType { name = 'nocoDbApiToken'; displayName = 'NocoDB API Token'; diff --git a/packages/nodes-base/nodes/GetResponse/ContactDescription.ts b/packages/nodes-base/nodes/GetResponse/ContactDescription.ts index 80051e255e..96fa793e43 100644 --- a/packages/nodes-base/nodes/GetResponse/ContactDescription.ts +++ b/packages/nodes-base/nodes/GetResponse/ContactDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const contactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contact', - ], + resource: ['contact'], }, }, options: [ @@ -62,12 +58,8 @@ export const contactFields: INodeProperties[] = [ placeholder: 'name@email.com', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, default: '', @@ -81,16 +73,13 @@ export const contactFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, default: '', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', }, { displayName: 'Additional Fields', @@ -100,12 +89,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, options: [ @@ -130,7 +115,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCustomFields', }, - description: 'The end user specified key of the user defined data. Choose from the list, or specify an ID using an expression.', + description: + 'The end user specified key of the user defined data. Choose from the list, or specify an ID using an expression.', default: '', }, { @@ -148,14 +134,15 @@ export const contactFields: INodeProperties[] = [ displayName: 'Day Of Cycle', name: 'dayOfCycle', type: 'string', - description: 'The day on which the contact is in the Autoresponder cycle. null indicates the contacts is not in the cycle.', + description: + 'The day on which the contact is in the Autoresponder cycle. null indicates the contacts is not in the cycle.', default: '', }, { displayName: 'IP Address', name: 'ipAddress', type: 'string', - description: 'The contact\'s IP address. IPv4 and IPv6 formats are accepted.', + description: "The contact's IP address. IPv4 and IPv6 formats are accepted.", default: '', }, { @@ -184,7 +171,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getTags', }, @@ -203,12 +191,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'delete', - ], + resource: ['contact'], + operation: ['delete'], }, }, default: '', @@ -222,12 +206,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'delete', - ], + resource: ['contact'], + operation: ['delete'], }, }, options: [ @@ -235,14 +215,16 @@ export const contactFields: INodeProperties[] = [ displayName: 'IP Address', name: 'ipAddress', type: 'string', - description: 'This makes it possible to pass the IP from which the contact unsubscribed. Used only if the messageId was send.', + description: + 'This makes it possible to pass the IP from which the contact unsubscribed. Used only if the messageId was send.', default: '', }, { displayName: 'Message ID', name: 'messageId', type: 'string', - description: 'The ID of a message (such as a newsletter, an autoresponder, or an RSS-newsletter). When passed, this method will simulate the unsubscribe process, as if the contact clicked the unsubscribe link in a given message.', + description: + 'The ID of a message (such as a newsletter, an autoresponder, or an RSS-newsletter). When passed, this method will simulate the unsubscribe process, as if the contact clicked the unsubscribe link in a given message.', default: '', }, ], @@ -258,12 +240,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], + resource: ['contact'], + operation: ['get'], }, }, default: '', @@ -277,12 +255,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], + resource: ['contact'], + operation: ['get'], }, }, options: [ @@ -290,7 +264,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Fields', name: 'fields', type: 'string', - description: 'List of fields that should be returned. ID is always returned. Fields should be separated by comma', + description: + 'List of fields that should be returned. ID is always returned. Fields should be separated by comma', default: '', }, ], @@ -305,12 +280,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, default: false, @@ -327,15 +298,9 @@ export const contactFields: INodeProperties[] = [ default: 20, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['contact'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -347,12 +312,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, options: [ @@ -396,13 +357,15 @@ export const contactFields: INodeProperties[] = [ name: 'exactMatch', type: 'boolean', default: false, - description: 'Whether to search for contacts with the exact value of the email and name provided in the query string. Without this flag, matching is done via a standard \'like\' comparison, which may sometimes be slow.', + description: + "Whether to search for contacts with the exact value of the email and name provided in the query string. Without this flag, matching is done via a standard 'like' comparison, which may sometimes be slow.", }, { displayName: 'Fields', name: 'fields', type: 'string', - description: 'List of fields that should be returned. ID is always returned. Fields should be separated by comma', + description: + 'List of fields that should be returned. ID is always returned. Fields should be separated by comma', default: '', }, { @@ -526,12 +489,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, default: '', @@ -545,12 +504,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, options: [ @@ -558,7 +513,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Campaign Name or ID', name: 'campaignId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCampaigns', }, @@ -585,7 +541,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCustomFields', }, - description: 'The end user specified key of the user defined data. Choose from the list, or specify an ID using an expression.', + description: + 'The end user specified key of the user defined data. Choose from the list, or specify an ID using an expression.', default: '', }, { @@ -603,7 +560,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Day Of Cycle', name: 'dayOfCycle', type: 'string', - description: 'The day on which the contact is in the Autoresponder cycle. null indicates the contacts is not in the cycle.', + description: + 'The day on which the contact is in the Autoresponder cycle. null indicates the contacts is not in the cycle.', default: '', }, { @@ -617,7 +575,7 @@ export const contactFields: INodeProperties[] = [ displayName: 'IP Address', name: 'ipAddress', type: 'string', - description: 'The contact\'s IP address. IPv4 and IPv6 formats are accepted.', + description: "The contact's IP address. IPv4 and IPv6 formats are accepted.", default: '', }, { @@ -646,7 +604,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getTags', }, @@ -654,5 +613,4 @@ export const contactFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts b/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts index 93199e89e3..17b1f12fb2 100644 --- a/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts +++ b/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,12 +7,19 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError -} from 'n8n-workflow'; - -export async function getresponseApiRequest(this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError } from 'n8n-workflow'; +export async function getresponseApiRequest( + this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const authentication = this.getNodeParameter('authentication', 0, 'apiKey') as string; let options: OptionsWithUri = { @@ -44,20 +49,33 @@ export async function getresponseApiRequest(this: IWebhookFunctions | IHookFunct } } -export async function getResponseApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function getResponseApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; query.page = 1; do { - responseData = await getresponseApiRequest.call(this, method, endpoint, body, query, undefined, { resolveWithFullResponse: true }); + responseData = await getresponseApiRequest.call( + this, + method, + endpoint, + body, + query, + undefined, + { resolveWithFullResponse: true }, + ); query.page++; returnData.push.apply(returnData, responseData.body); - } while ( - responseData.headers.TotalPages !== responseData.headers.CurrentPage - ); + } while (responseData.headers.TotalPages !== responseData.headers.CurrentPage); return returnData; } diff --git a/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts b/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts index 7883556a41..fbffe7ac2f 100644 --- a/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts +++ b/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,15 +9,9 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - getresponseApiRequest, - getResponseApiRequestAllItems, -} from './GenericFunctions'; +import { getresponseApiRequest, getResponseApiRequestAllItems } from './GenericFunctions'; -import { - contactFields, - contactOperations, -} from './ContactDescription'; +import { contactFields, contactOperations } from './ContactDescription'; import moment from 'moment-timezone'; @@ -44,9 +36,7 @@ export class GetResponse implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'apiKey', - ], + authentication: ['apiKey'], }, }, }, @@ -55,9 +45,7 @@ export class GetResponse implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -101,15 +89,9 @@ export class GetResponse implements INodeType { loadOptions: { // Get all the campaigns to display them to user so that he can // select them easily - async getCampaigns( - this: ILoadOptionsFunctions, - ): Promise { + async getCampaigns(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const campaigns = await getresponseApiRequest.call( - this, - 'GET', - `/campaigns`, - ); + const campaigns = await getresponseApiRequest.call(this, 'GET', `/campaigns`); for (const campaign of campaigns) { returnData.push({ name: campaign.name as string, @@ -120,15 +102,9 @@ export class GetResponse implements INodeType { }, // Get all the tagd to display them to user so that he can // select them easily - async getTags( - this: ILoadOptionsFunctions, - ): Promise { + async getTags(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const tags = await getresponseApiRequest.call( - this, - 'GET', - `/tags`, - ); + const tags = await getresponseApiRequest.call(this, 'GET', `/tags`); for (const tag of tags) { returnData.push({ name: tag.name as string, @@ -139,15 +115,9 @@ export class GetResponse implements INodeType { }, // Get all the custom fields to display them to user so that he can // select them easily - async getCustomFields( - this: ILoadOptionsFunctions, - ): Promise { + async getCustomFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const customFields = await getresponseApiRequest.call( - this, - 'GET', - `/custom-fields`, - ); + const customFields = await getresponseApiRequest.call(this, 'GET', `/custom-fields`); for (const customField of customFields) { returnData.push({ name: customField.name as string, @@ -188,7 +158,8 @@ export class GetResponse implements INodeType { Object.assign(body, additionalFields); if (additionalFields.customFieldsUi) { - const customFieldValues = (additionalFields.customFieldsUi as IDataObject).customFieldValues as IDataObject[]; + const customFieldValues = (additionalFields.customFieldsUi as IDataObject) + .customFieldValues as IDataObject[]; if (customFieldValues) { body.customFieldValues = customFieldValues; for (let i = 0; i < customFieldValues.length; i++) { @@ -212,7 +183,13 @@ export class GetResponse implements INodeType { Object.assign(qs, options); - responseData = await getresponseApiRequest.call(this, 'DELETE', `/contacts/${contactId}`, {}, qs); + responseData = await getresponseApiRequest.call( + this, + 'DELETE', + `/contacts/${contactId}`, + {}, + qs, + ); responseData = { success: true }; } @@ -224,7 +201,13 @@ export class GetResponse implements INodeType { Object.assign(qs, options); - responseData = await getresponseApiRequest.call(this, 'GET', `/contacts/${contactId}`, {}, qs); + responseData = await getresponseApiRequest.call( + this, + 'GET', + `/contacts/${contactId}`, + {}, + qs, + ); } //https://apireference.getresponse.com/?_ga=2.160836350.2102802044.1604719933-1897033509.1604598019#operation/getContactList if (operation === 'getAll') { @@ -236,32 +219,23 @@ export class GetResponse implements INodeType { Object.assign(qs, options); - const isNotQuery = [ - 'sortBy', - 'sortOrder', - 'additionalFlags', - 'fields', - 'exactMatch', - ]; + const isNotQuery = ['sortBy', 'sortOrder', 'additionalFlags', 'fields', 'exactMatch']; - const isDate = [ - 'createdOnFrom', - 'createdOnTo', - 'changeOnFrom', - 'changeOnTo', - ]; + const isDate = ['createdOnFrom', 'createdOnTo', 'changeOnFrom', 'changeOnTo']; - const dateMapToKey: { [key: string]: string; } = { - 'createdOnFrom': '[createdOn][from]', - 'createdOnTo': '[createdOn][to]', - 'changeOnFrom': '[changeOn][from]', - 'changeOnTo': '[changeOn][to]', + const dateMapToKey: { [key: string]: string } = { + createdOnFrom: '[createdOn][from]', + createdOnTo: '[createdOn][to]', + changeOnFrom: '[changeOn][from]', + changeOnTo: '[changeOn][to]', }; for (const key of Object.keys(qs)) { if (!isNotQuery.includes(key)) { if (isDate.includes(key)) { - qs[`query${dateMapToKey[key]}`] = moment.tz(qs[key], timezone).format('YYYY-MM-DDTHH:mm:ssZZ'); + qs[`query${dateMapToKey[key]}`] = moment + .tz(qs[key], timezone) + .format('YYYY-MM-DDTHH:mm:ssZZ'); } else { qs[`query[${key}]`] = qs[key]; } @@ -279,7 +253,13 @@ export class GetResponse implements INodeType { } if (returnAll) { - responseData = await getResponseApiRequestAllItems.call(this, 'GET', `/contacts`, {}, qs); + responseData = await getResponseApiRequestAllItems.call( + this, + 'GET', + `/contacts`, + {}, + qs, + ); } else { qs.perPage = this.getNodeParameter('limit', i) as number; responseData = await getresponseApiRequest.call(this, 'GET', `/contacts`, {}, qs); @@ -287,7 +267,6 @@ export class GetResponse implements INodeType { } //https://apireference.getresponse.com/?_ga=2.160836350.2102802044.1604719933-1897033509.1604598019#operation/updateContact if (operation === 'update') { - const contactId = this.getNodeParameter('contactId', i) as string; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; @@ -297,19 +276,24 @@ export class GetResponse implements INodeType { Object.assign(body, updateFields); if (updateFields.customFieldsUi) { - const customFieldValues = (updateFields.customFieldsUi as IDataObject).customFieldValues as IDataObject[]; + const customFieldValues = (updateFields.customFieldsUi as IDataObject) + .customFieldValues as IDataObject[]; if (customFieldValues) { body.customFieldValues = customFieldValues; delete body.customFieldsUi; } } - responseData = await getresponseApiRequest.call(this, 'POST', `/contacts/${contactId}`, body); + responseData = await getresponseApiRequest.call( + this, + 'POST', + `/contacts/${contactId}`, + body, + ); } } if (Array.isArray(responseData)) { returnData.push.apply(returnData, responseData as IDataObject[]); - } else if (responseData !== undefined) { returnData.push(responseData as IDataObject); } diff --git a/packages/nodes-base/nodes/GetResponse/GetResponseTrigger.node.ts b/packages/nodes-base/nodes/GetResponse/GetResponseTrigger.node.ts index 15e600a443..c257c728a1 100644 --- a/packages/nodes-base/nodes/GetResponse/GetResponseTrigger.node.ts +++ b/packages/nodes-base/nodes/GetResponse/GetResponseTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -14,10 +11,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - getresponseApiRequest, - getResponseApiRequestAllItems, -} from './GenericFunctions'; +import { getresponseApiRequest, getResponseApiRequestAllItems } from './GenericFunctions'; export class GetResponseTrigger implements INodeType { description: INodeTypeDescription = { @@ -39,9 +33,7 @@ export class GetResponseTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'apiKey', - ], + authentication: ['apiKey'], }, }, }, @@ -50,9 +42,7 @@ export class GetResponseTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -120,7 +110,8 @@ export class GetResponseTrigger implements INodeType { displayName: 'List Names or IDs', name: 'listIds', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getLists', }, @@ -176,7 +167,9 @@ export class GetResponseTrigger implements INodeType { if (data.url !== webhookUrl) { if (deleteCurrentSubscription === false) { - throw new NodeApiError(this.getNode(), data, { message: `The webhook (${data.url}) is active in the account. Delete it manually or set the parameter "Delete Current Subscription" to true, and the node will delete it for you.` }); + throw new NodeApiError(this.getNode(), data, { + message: `The webhook (${data.url}) is active in the account. Delete it manually or set the parameter "Delete Current Subscription" to true, and the node will delete it for you.`, + }); } } } catch (error) { @@ -195,10 +188,13 @@ export class GetResponseTrigger implements INodeType { const body = { url: webhookUrl, - actions: events.reduce((accumulator: { [key: string]: boolean }, currentValue: string) => { - accumulator[currentValue] = true; - return accumulator; - }, {}), + actions: events.reduce( + (accumulator: { [key: string]: boolean }, currentValue: string) => { + accumulator[currentValue] = true; + return accumulator; + }, + {}, + ), }; await getresponseApiRequest.call(this, 'POST', '/accounts/callbacks', body); @@ -226,9 +222,7 @@ export class GetResponseTrigger implements INodeType { } return { - workflowData: [ - this.helpers.returnJsonArray(query), - ], + workflowData: [this.helpers.returnJsonArray(query)], }; } } diff --git a/packages/nodes-base/nodes/Ghost/GenericFunctions.ts b/packages/nodes-base/nodes/Ghost/GenericFunctions.ts index e00b8a28b9..80bd8814ce 100644 --- a/packages/nodes-base/nodes/Ghost/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Ghost/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,14 +7,18 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, - JsonObject, - NodeApiError, -} from 'n8n-workflow'; - -export async function ghostApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise { // tslint:disable-line:no-any +import { IDataObject, JsonObject, NodeApiError } from 'n8n-workflow'; +export async function ghostApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { const source = this.getNodeParameter('source', 0) as string; let credentials; @@ -44,13 +46,21 @@ export async function ghostApiRequest(this: IHookFunctions | IExecuteFunctions | try { return await this.helpers.requestWithAuthentication.call(this, credentialType, options); - } catch(error) { + } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); } } -export async function ghostApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function ghostApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -62,13 +72,12 @@ export async function ghostApiRequestAllItems(this: IHookFunctions | IExecuteFun responseData = await ghostApiRequest.call(this, method, endpoint, body, query); query.page = responseData.meta.pagination.next; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - query.page !== null - ); + } while (query.page !== null); return returnData; } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); diff --git a/packages/nodes-base/nodes/Ghost/Ghost.node.ts b/packages/nodes-base/nodes/Ghost/Ghost.node.ts index 7a9222606b..aaf30b8157 100644 --- a/packages/nodes-base/nodes/Ghost/Ghost.node.ts +++ b/packages/nodes-base/nodes/Ghost/Ghost.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,16 +10,9 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - ghostApiRequest, - ghostApiRequestAllItems, - validateJSON, -} from './GenericFunctions'; +import { ghostApiRequest, ghostApiRequestAllItems, validateJSON } from './GenericFunctions'; -import { - postFields, - postOperations, -} from './PostDescription'; +import { postFields, postOperations } from './PostDescription'; import moment from 'moment-timezone'; @@ -45,9 +36,7 @@ export class Ghost implements INodeType { required: true, displayOptions: { show: { - source: [ - 'adminApi', - ], + source: ['adminApi'], }, }, }, @@ -56,9 +45,7 @@ export class Ghost implements INodeType { required: true, displayOptions: { show: { - source: [ - 'contentApi', - ], + source: ['contentApi'], }, }, }, @@ -99,21 +86,13 @@ export class Ghost implements INodeType { ], }; - methods = { loadOptions: { // Get all the authors to display them to user so that he can // select them easily - async getAuthors( - this: ILoadOptionsFunctions, - ): Promise { + async getAuthors(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const users = await ghostApiRequestAllItems.call( - this, - 'users', - 'GET', - `/admin/users`, - ); + const users = await ghostApiRequestAllItems.call(this, 'users', 'GET', `/admin/users`); for (const user of users) { returnData.push({ name: user.name, @@ -124,16 +103,9 @@ export class Ghost implements INodeType { }, // Get all the tags to display them to user so that he can // select them easily - async getTags( - this: ILoadOptionsFunctions, - ): Promise { + async getTags(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const tags = await ghostApiRequestAllItems.call( - this, - 'tags', - 'GET', - `/admin/tags`, - ); + const tags = await ghostApiRequestAllItems.call(this, 'tags', 'GET', `/admin/tags`); for (const tag of tags) { returnData.push({ name: tag.name, @@ -160,7 +132,6 @@ export class Ghost implements INodeType { if (source === 'contentApi') { if (resource === 'post') { if (operation === 'get') { - const by = this.getNodeParameter('by', i) as string; const identifier = this.getNodeParameter('identifier', i) as string; @@ -179,11 +150,9 @@ export class Ghost implements INodeType { responseData = await ghostApiRequest.call(this, 'GET', endpoint, {}, qs); returnData.push.apply(returnData, responseData.posts); - } if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', 0) as boolean; const options = this.getNodeParameter('options', i) as IDataObject; @@ -191,7 +160,14 @@ export class Ghost implements INodeType { Object.assign(qs, options); if (returnAll) { - responseData = await ghostApiRequestAllItems.call(this, 'posts', 'GET', '/content/posts', {} ,qs); + responseData = await ghostApiRequestAllItems.call( + this, + 'posts', + 'GET', + '/content/posts', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0); responseData = await ghostApiRequest.call(this, 'GET', '/content/posts', {}, qs); @@ -199,7 +175,6 @@ export class Ghost implements INodeType { } returnData.push.apply(returnData, responseData); - } } } @@ -207,7 +182,6 @@ export class Ghost implements INodeType { if (source === 'adminApi') { if (resource === 'post') { if (operation === 'create') { - const title = this.getNodeParameter('title', i) as string; const contentFormat = this.getNodeParameter('contentFormat', i) as string; @@ -226,7 +200,9 @@ export class Ghost implements INodeType { } else { const mobileDoc = validateJSON(content); if (mobileDoc === undefined) { - throw new NodeOperationError(this.getNode(), 'Content must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Content must be a valid JSON', { + itemIndex: i, + }); } post.mobiledoc = content; } @@ -240,27 +216,33 @@ export class Ghost implements INodeType { } if (post.status === 'scheduled' && post.published_at === undefined) { - throw new NodeOperationError(this.getNode(), 'Published at must be define when status is scheduled', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Published at must be define when status is scheduled', + { itemIndex: i }, + ); } - responseData = await ghostApiRequest.call(this, 'POST', '/admin/posts', { posts: [post] }, qs); + responseData = await ghostApiRequest.call( + this, + 'POST', + '/admin/posts', + { posts: [post] }, + qs, + ); returnData.push.apply(returnData, responseData.posts); - } if (operation === 'delete') { - const postId = this.getNodeParameter('postId', i) as string; responseData = await ghostApiRequest.call(this, 'DELETE', `/admin/posts/${postId}`); returnData.push({ success: true }); - } if (operation === 'get') { - const by = this.getNodeParameter('by', i) as string; const identifier = this.getNodeParameter('identifier', i) as string; @@ -279,12 +261,9 @@ export class Ghost implements INodeType { responseData = await ghostApiRequest.call(this, 'GET', endpoint, {}, qs); returnData.push.apply(returnData, responseData.posts); - } if (operation === 'getAll') { - - const returnAll = this.getNodeParameter('returnAll', 0) as boolean; const options = this.getNodeParameter('options', i) as IDataObject; @@ -292,7 +271,14 @@ export class Ghost implements INodeType { Object.assign(qs, options); if (returnAll) { - responseData = await ghostApiRequestAllItems.call(this, 'posts', 'GET', '/admin/posts', {} ,qs); + responseData = await ghostApiRequestAllItems.call( + this, + 'posts', + 'GET', + '/admin/posts', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0); responseData = await ghostApiRequest.call(this, 'GET', '/admin/posts', {}, qs); @@ -300,11 +286,9 @@ export class Ghost implements INodeType { } returnData.push.apply(returnData, responseData); - } if (operation === 'update') { - const postId = this.getNodeParameter('postId', i) as string; const contentFormat = this.getNodeParameter('contentFormat', i) as string; @@ -318,9 +302,11 @@ export class Ghost implements INodeType { qs.source = 'html'; delete updateFields.content; } else { - const mobileDoc = validateJSON(updateFields.contentJson as string || undefined); + const mobileDoc = validateJSON((updateFields.contentJson as string) || undefined); if (mobileDoc === undefined) { - throw new NodeOperationError(this.getNode(), 'Content must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Content must be a valid JSON', { + itemIndex: i, + }); } post.mobiledoc = updateFields.contentJson; delete updateFields.contentJson; @@ -328,22 +314,37 @@ export class Ghost implements INodeType { Object.assign(post, updateFields); - const { posts } = await ghostApiRequest.call(this, 'GET', `/admin/posts/${postId}`, {}, { fields: 'id, updated_at' }); + const { posts } = await ghostApiRequest.call( + this, + 'GET', + `/admin/posts/${postId}`, + {}, + { fields: 'id, updated_at' }, + ); if (post.published_at) { post.published_at = moment.tz(post.published_at, timezone).utc().format(); } if (post.status === 'scheduled' && post.published_at === undefined) { - throw new NodeOperationError(this.getNode(), 'Published at must be define when status is scheduled', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Published at must be define when status is scheduled', + { itemIndex: i }, + ); } post.updated_at = posts[0].updated_at; - responseData = await ghostApiRequest.call(this, 'PUT', `/admin/posts/${postId}`, { posts: [post] }, qs); + responseData = await ghostApiRequest.call( + this, + 'PUT', + `/admin/posts/${postId}`, + { posts: [post] }, + qs, + ); returnData.push.apply(returnData, responseData.posts); - } } } diff --git a/packages/nodes-base/nodes/Ghost/PostDescription.ts b/packages/nodes-base/nodes/Ghost/PostDescription.ts index fbb0be3416..b5932b510d 100644 --- a/packages/nodes-base/nodes/Ghost/PostDescription.ts +++ b/packages/nodes-base/nodes/Ghost/PostDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const postOperations: INodeProperties[] = [ { @@ -10,12 +8,8 @@ export const postOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - source: [ - 'contentApi', - ], - resource: [ - 'post', - ], + source: ['contentApi'], + resource: ['post'], }, }, options: [ @@ -41,12 +35,8 @@ export const postOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - source: [ - 'adminApi', - ], - resource: [ - 'post', - ], + source: ['adminApi'], + resource: ['post'], }, }, options: [ @@ -97,18 +87,12 @@ export const postFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'adminApi', - ], - resource: [ - 'post', - ], - operation: [ - 'create', - ], + source: ['adminApi'], + resource: ['post'], + operation: ['create'], }, }, - description: 'Post\'s title', + description: "Post's title", }, { displayName: 'Content Format', @@ -116,15 +100,9 @@ export const postFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - source: [ - 'adminApi', - ], - resource: [ - 'post', - ], - operation: [ - 'create', - ], + source: ['adminApi'], + resource: ['post'], + operation: ['create'], }, }, options: [ @@ -149,18 +127,10 @@ export const postFields: INodeProperties[] = [ }, displayOptions: { show: { - source: [ - 'adminApi', - ], - resource: [ - 'post', - ], - operation: [ - 'create', - ], - contentFormat: [ - 'html', - ], + source: ['adminApi'], + resource: ['post'], + operation: ['create'], + contentFormat: ['html'], }, }, default: '', @@ -172,23 +142,16 @@ export const postFields: INodeProperties[] = [ type: 'json', displayOptions: { show: { - source: [ - 'adminApi', - ], - resource: [ - 'post', - ], - operation: [ - 'create', - ], - contentFormat: [ - 'mobileDoc', - ], + source: ['adminApi'], + resource: ['post'], + operation: ['create'], + contentFormat: ['mobileDoc'], }, }, default: '', - description: 'Mobiledoc is the raw JSON format that Ghost uses to store post contents. Info.', + description: + 'Mobiledoc is the raw JSON format that Ghost uses to store post contents. Info.', }, { displayName: 'Additional Fields', @@ -198,15 +161,9 @@ export const postFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - source: [ - 'adminApi', - ], - resource: [ - 'post', - ], - operation: [ - 'create', - ], + source: ['adminApi'], + resource: ['post'], + operation: ['create'], }, }, options: [ @@ -214,7 +171,8 @@ export const postFields: INodeProperties[] = [ displayName: 'Author Names or IDs', name: 'authors', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getAuthors', }, @@ -270,7 +228,6 @@ export const postFields: INodeProperties[] = [ type: 'string', default: '', description: 'URL of the image', - }, { displayName: 'Open Graph Title', @@ -314,7 +271,8 @@ export const postFields: INodeProperties[] = [ displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getTags', }, @@ -353,15 +311,9 @@ export const postFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'adminApi', - ], - resource: [ - 'post', - ], - operation: [ - 'delete', - ], + source: ['adminApi'], + resource: ['post'], + operation: ['delete'], }, }, description: 'The ID of the post to delete', @@ -388,16 +340,9 @@ export const postFields: INodeProperties[] = [ ], displayOptions: { show: { - source: [ - 'contentApi', - 'adminApi', - ], - resource: [ - 'post', - ], - operation: [ - 'get', - ], + source: ['contentApi', 'adminApi'], + resource: ['post'], + operation: ['get'], }, }, description: 'Get the post either by slug or ID', @@ -410,16 +355,9 @@ export const postFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'contentApi', - 'adminApi', - ], - resource: [ - 'post', - ], - operation: [ - 'get', - ], + source: ['contentApi', 'adminApi'], + resource: ['post'], + operation: ['get'], }, }, description: 'The ID or slug of the post to get', @@ -432,15 +370,9 @@ export const postFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - source: [ - 'adminApi', - ], - resource: [ - 'post', - ], - operation: [ - 'get', - ], + source: ['adminApi'], + resource: ['post'], + operation: ['get'], }, }, options: [ @@ -450,7 +382,8 @@ export const postFields: INodeProperties[] = [ type: 'string', default: '', // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-url - description: 'Limit the fields returned in the response object. E.g. for posts fields=title,url.', + description: + 'Limit the fields returned in the response object. E.g. for posts fields=title,url.', }, { displayName: 'Formats', @@ -466,9 +399,7 @@ export const postFields: INodeProperties[] = [ value: 'mobiledoc', }, ], - default: [ - 'mobiledoc', - ], + default: ['mobiledoc'], }, ], }, @@ -480,15 +411,9 @@ export const postFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - source: [ - 'contentApi', - ], - resource: [ - 'post', - ], - operation: [ - 'get', - ], + source: ['contentApi'], + resource: ['post'], + operation: ['get'], }, }, options: [ @@ -498,7 +423,8 @@ export const postFields: INodeProperties[] = [ type: 'string', default: '', // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-url - description: 'Limit the fields returned in the response object. E.g. for posts fields=title,url.', + description: + 'Limit the fields returned in the response object. E.g. for posts fields=title,url.', }, { displayName: 'Formats', @@ -514,9 +440,7 @@ export const postFields: INodeProperties[] = [ value: 'plaintext', }, ], - default: [ - 'html', - ], + default: ['html'], }, ], }, @@ -530,16 +454,9 @@ export const postFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - source: [ - 'contentApi', - 'adminApi', - ], - resource: [ - 'post', - ], - operation: [ - 'getAll', - ], + source: ['contentApi', 'adminApi'], + resource: ['post'], + operation: ['getAll'], }, }, default: false, @@ -551,19 +468,10 @@ export const postFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - source: [ - 'adminApi', - 'contentApi', - ], - resource: [ - 'post', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + source: ['adminApi', 'contentApi'], + resource: ['post'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -581,15 +489,9 @@ export const postFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - source: [ - 'contentApi', - ], - resource: [ - 'post', - ], - operation: [ - 'getAll', - ], + source: ['contentApi'], + resource: ['post'], + operation: ['getAll'], }, }, options: [ @@ -608,7 +510,8 @@ export const postFields: INodeProperties[] = [ }, ], default: [], - description: 'Tells the API to return additional data related to the resource you have requested', + description: + 'Tells the API to return additional data related to the resource you have requested', }, { displayName: 'Fields', @@ -616,7 +519,8 @@ export const postFields: INodeProperties[] = [ type: 'string', default: '', // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-url - description: 'Limit the fields returned in the response object. E.g. for posts fields=title,url.', + description: + 'Limit the fields returned in the response object. E.g. for posts fields=title,url.', }, { displayName: 'Formats', @@ -632,10 +536,9 @@ export const postFields: INodeProperties[] = [ value: 'plaintext', }, ], - default: [ - 'html', - ], - description: 'By default, only html is returned, however each post and page in Ghost has 2 available formats: html and plaintext', + default: ['html'], + description: + 'By default, only html is returned, however each post and page in Ghost has 2 available formats: html and plaintext', }, ], }, @@ -647,15 +550,9 @@ export const postFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - source: [ - 'adminApi', - ], - resource: [ - 'post', - ], - operation: [ - 'getAll', - ], + source: ['adminApi'], + resource: ['post'], + operation: ['getAll'], }, }, options: [ @@ -674,7 +571,8 @@ export const postFields: INodeProperties[] = [ }, ], default: [], - description: 'Tells the API to return additional data related to the resource you have requested', + description: + 'Tells the API to return additional data related to the resource you have requested', }, { displayName: 'Fields', @@ -682,7 +580,8 @@ export const postFields: INodeProperties[] = [ type: 'string', default: '', // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-url - description: 'Limit the fields returned in the response object. E.g. for posts fields=title,url.', + description: + 'Limit the fields returned in the response object. E.g. for posts fields=title,url.', }, { displayName: 'Formats', @@ -698,9 +597,7 @@ export const postFields: INodeProperties[] = [ value: 'mobiledoc', }, ], - default: [ - 'mobiledoc', - ], + default: ['mobiledoc'], }, ], }, @@ -714,15 +611,9 @@ export const postFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - source: [ - 'adminApi', - ], - resource: [ - 'post', - ], - operation: [ - 'update', - ], + source: ['adminApi'], + resource: ['post'], + operation: ['update'], }, }, default: '', @@ -734,15 +625,9 @@ export const postFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - source: [ - 'adminApi', - ], - resource: [ - 'post', - ], - operation: [ - 'update', - ], + source: ['adminApi'], + resource: ['post'], + operation: ['update'], }, }, options: [ @@ -766,15 +651,9 @@ export const postFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - source: [ - 'adminApi', - ], - resource: [ - 'post', - ], - operation: [ - 'update', - ], + source: ['adminApi'], + resource: ['post'], + operation: ['update'], }, }, options: [ @@ -782,7 +661,8 @@ export const postFields: INodeProperties[] = [ displayName: 'Author Names or IDs', name: 'authors', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getAuthors', }, @@ -812,9 +692,7 @@ export const postFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/contentFormat': [ - 'html', - ], + '/contentFormat': ['html'], }, }, typeOptions: { @@ -828,13 +706,12 @@ export const postFields: INodeProperties[] = [ type: 'json', displayOptions: { show: { - '/contentFormat': [ - 'mobileDoc', - ], + '/contentFormat': ['mobileDoc'], }, }, default: '', - description: 'Mobiledoc is the raw JSON format that Ghost uses to store post contents. Info..', + description: + 'Mobiledoc is the raw JSON format that Ghost uses to store post contents. Info..', }, { displayName: 'Featured', @@ -909,7 +786,8 @@ export const postFields: INodeProperties[] = [ displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getTags', }, @@ -920,7 +798,7 @@ export const postFields: INodeProperties[] = [ name: 'title', type: 'string', default: '', - description: 'Post\'s title', + description: "Post's title", }, { displayName: 'Twitter Description', diff --git a/packages/nodes-base/nodes/Git/Git.node.ts b/packages/nodes-base/nodes/Git/Git.node.ts index 759a1028af..cc4d60516e 100644 --- a/packages/nodes-base/nodes/Git/Git.node.ts +++ b/packages/nodes-base/nodes/Git/Git.node.ts @@ -1,10 +1,5 @@ import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; import { addConfigFields, @@ -16,16 +11,9 @@ import { tagFields, } from './descriptions'; -import simpleGit, { - LogOptions, - SimpleGit, - SimpleGitOptions, -} from 'simple-git'; +import simpleGit, { LogOptions, SimpleGit, SimpleGitOptions } from 'simple-git'; -import { - access, - mkdir, -} from 'fs/promises'; +import { access, mkdir } from 'fs/promises'; import { URL } from 'url'; @@ -48,9 +36,7 @@ export class Git implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'gitPassword', - ], + authentication: ['gitPassword'], }, }, }, @@ -72,10 +58,7 @@ export class Git implements INodeType { ], displayOptions: { show: { - operation: [ - 'clone', - 'push', - ], + operation: ['clone', 'push'], }, }, default: 'none', @@ -175,9 +158,7 @@ export class Git implements INodeType { type: 'string', displayOptions: { hide: { - operation: [ - 'clone', - ], + operation: ['clone'], }, }, default: '', @@ -191,9 +172,7 @@ export class Git implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'clone', - ], + operation: ['clone'], }, }, default: '', @@ -213,11 +192,9 @@ export class Git implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); - const prepareRepository = async (repositoryPath: string): Promise => { const authentication = this.getNodeParameter('authentication', 0) as string; @@ -280,7 +257,6 @@ export class Git implements INodeType { item: itemIndex, }, }); - } else if (operation === 'addConfig') { // ---------------------------------- // addConfig @@ -303,7 +279,6 @@ export class Git implements INodeType { item: itemIndex, }, }); - } else if (operation === 'clone') { // ---------------------------------- // clone @@ -322,7 +297,6 @@ export class Git implements INodeType { item: itemIndex, }, }); - } else if (operation === 'commit') { // ---------------------------------- // commit @@ -345,7 +319,6 @@ export class Git implements INodeType { item: itemIndex, }, }); - } else if (operation === 'fetch') { // ---------------------------------- // fetch @@ -360,7 +333,6 @@ export class Git implements INodeType { item: itemIndex, }, }); - } else if (operation === 'log') { // ---------------------------------- // log @@ -378,14 +350,15 @@ export class Git implements INodeType { const log = await git.log(logOptions); - // @ts-ignore - returnItems.push(...this.helpers.returnJsonArray(log.all).map(item => { - return { - ...item, - pairedItem: { item: itemIndex }, - }; - })); - + returnItems.push( + // @ts-ignore + ...this.helpers.returnJsonArray(log.all).map((item) => { + return { + ...item, + pairedItem: { item: itemIndex }, + }; + }), + ); } else if (operation === 'pull') { // ---------------------------------- // pull @@ -400,7 +373,6 @@ export class Git implements INodeType { item: itemIndex, }, }); - } else if (operation === 'push') { // ---------------------------------- // push @@ -438,7 +410,6 @@ export class Git implements INodeType { item: itemIndex, }, }); - } else if (operation === 'pushTags') { // ---------------------------------- // pushTags @@ -453,7 +424,6 @@ export class Git implements INodeType { item: itemIndex, }, }); - } else if (operation === 'listConfig') { // ---------------------------------- // listConfig @@ -470,13 +440,14 @@ export class Git implements INodeType { } // @ts-ignore - returnItems.push(...this.helpers.returnJsonArray(data).map(item => { - return { - ...item, - pairedItem: { item: itemIndex }, - }; - })); - + returnItems.push( + ...this.helpers.returnJsonArray(data).map((item) => { + return { + ...item, + pairedItem: { item: itemIndex }, + }; + }), + ); } else if (operation === 'status') { // ---------------------------------- // status @@ -484,14 +455,15 @@ export class Git implements INodeType { const status = await git.status(); - // @ts-ignore - returnItems.push(...this.helpers.returnJsonArray([status]).map(item => { - return { - ...item, - pairedItem: { item: itemIndex }, - }; - })); - + returnItems.push( + // @ts-ignore + ...this.helpers.returnJsonArray([status]).map((item) => { + return { + ...item, + pairedItem: { item: itemIndex }, + }; + }), + ); } else if (operation === 'tag') { // ---------------------------------- // tag @@ -509,9 +481,7 @@ export class Git implements INodeType { }, }); } - } catch (error) { - if (this.continueOnFail()) { returnItems.push({ json: { diff --git a/packages/nodes-base/nodes/Git/descriptions/AddConfigDescription.ts b/packages/nodes-base/nodes/Git/descriptions/AddConfigDescription.ts index 2bad90699d..e5bfb19e6d 100644 --- a/packages/nodes-base/nodes/Git/descriptions/AddConfigDescription.ts +++ b/packages/nodes-base/nodes/Git/descriptions/AddConfigDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const addConfigFields: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const addConfigFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'addConfig', - ], + operation: ['addConfig'], }, }, default: '', @@ -25,9 +21,7 @@ export const addConfigFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'addConfig', - ], + operation: ['addConfig'], }, }, default: '', @@ -41,9 +35,7 @@ export const addConfigFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'addConfig', - ], + operation: ['addConfig'], }, }, placeholder: 'Add Option', diff --git a/packages/nodes-base/nodes/Git/descriptions/AddDescription.ts b/packages/nodes-base/nodes/Git/descriptions/AddDescription.ts index dd3e2f72ad..d3afc91456 100644 --- a/packages/nodes-base/nodes/Git/descriptions/AddDescription.ts +++ b/packages/nodes-base/nodes/Git/descriptions/AddDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const addFields: INodeProperties[] = [ { @@ -9,14 +7,13 @@ export const addFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'add', - ], + operation: ['add'], }, }, default: '', placeholder: 'README.md', - description: 'Comma-separated list of paths (absolute or relative to Repository Path) of files or folders to add', + description: + 'Comma-separated list of paths (absolute or relative to Repository Path) of files or folders to add', required: true, }, ]; diff --git a/packages/nodes-base/nodes/Git/descriptions/CloneDescription.ts b/packages/nodes-base/nodes/Git/descriptions/CloneDescription.ts index 833f80e26e..2fcab1d3c7 100644 --- a/packages/nodes-base/nodes/Git/descriptions/CloneDescription.ts +++ b/packages/nodes-base/nodes/Git/descriptions/CloneDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const cloneFields: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const cloneFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'clone', - ], + operation: ['clone'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Git/descriptions/CommitDescription.ts b/packages/nodes-base/nodes/Git/descriptions/CommitDescription.ts index ffb88afc01..289aa5106b 100644 --- a/packages/nodes-base/nodes/Git/descriptions/CommitDescription.ts +++ b/packages/nodes-base/nodes/Git/descriptions/CommitDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const commitFields: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const commitFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'commit', - ], + operation: ['commit'], }, }, default: '', @@ -23,9 +19,7 @@ export const commitFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'commit', - ], + operation: ['commit'], }, }, placeholder: 'Add Option', @@ -37,7 +31,8 @@ export const commitFields: INodeProperties[] = [ type: 'string', default: '', placeholder: '/data/file1.json', - description: 'Comma-separated list of paths (absolute or relative to Repository Path) of files or folders to commit. If not set will all "added" files and folders be committed.', + description: + 'Comma-separated list of paths (absolute or relative to Repository Path) of files or folders to commit. If not set will all "added" files and folders be committed.', }, ], }, diff --git a/packages/nodes-base/nodes/Git/descriptions/LogDescription.ts b/packages/nodes-base/nodes/Git/descriptions/LogDescription.ts index c5e6409179..6b75620a75 100644 --- a/packages/nodes-base/nodes/Git/descriptions/LogDescription.ts +++ b/packages/nodes-base/nodes/Git/descriptions/LogDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const logFields: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const logFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'log', - ], + operation: ['log'], }, }, default: false, @@ -23,12 +19,8 @@ export const logFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'log', - ], - returnAll: [ - false, - ], + operation: ['log'], + returnAll: [false], }, }, typeOptions: { @@ -44,9 +36,7 @@ export const logFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'log', - ], + operation: ['log'], }, }, placeholder: 'Add Option', @@ -57,7 +47,8 @@ export const logFields: INodeProperties[] = [ name: 'file', type: 'string', default: 'README.md', - description: 'The path (absolute or relative to Repository Path) of file or folder to get the history of', + description: + 'The path (absolute or relative to Repository Path) of file or folder to get the history of', }, ], }, diff --git a/packages/nodes-base/nodes/Git/descriptions/PushDescription.ts b/packages/nodes-base/nodes/Git/descriptions/PushDescription.ts index bd737cd176..5bbdb40195 100644 --- a/packages/nodes-base/nodes/Git/descriptions/PushDescription.ts +++ b/packages/nodes-base/nodes/Git/descriptions/PushDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const pushFields: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const pushFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'push', - ], + operation: ['push'], }, }, placeholder: 'Add Option', diff --git a/packages/nodes-base/nodes/Git/descriptions/TagDescription.ts b/packages/nodes-base/nodes/Git/descriptions/TagDescription.ts index f7ab403445..6fdbbaf5d9 100644 --- a/packages/nodes-base/nodes/Git/descriptions/TagDescription.ts +++ b/packages/nodes-base/nodes/Git/descriptions/TagDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const tagFields: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const tagFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'tag', - ], + operation: ['tag'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Github/GenericFunctions.ts b/packages/nodes-base/nodes/Github/GenericFunctions.ts index 3a9c534bd7..3f15825963 100644 --- a/packages/nodes-base/nodes/Github/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Github/GenericFunctions.ts @@ -1,13 +1,8 @@ import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; /** * Make an API request to Github @@ -18,8 +13,15 @@ import { * @param {object} body * @returns {Promise} */ -export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: object, query?: object, option: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function githubApiRequest( + this: IHookFunctions | IExecuteFunctions, + method: string, + endpoint: string, + body: object, + query?: object, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { method, headers: { @@ -36,7 +38,11 @@ export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions, } try { - const authenticationMethod = this.getNodeParameter('authentication', 0, 'accessToken') as string; + const authenticationMethod = this.getNodeParameter( + 'authentication', + 0, + 'accessToken', + ) as string; let credentialType = ''; if (authenticationMethod === 'accessToken') { @@ -59,8 +65,6 @@ export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions, } } - - /** * Returns the SHA of the given file * @@ -72,7 +76,14 @@ export async function githubApiRequest(this: IHookFunctions | IExecuteFunctions, * @param {string} [branch] * @returns {Promise} */ -export async function getFileSha(this: IHookFunctions | IExecuteFunctions, owner: string, repository: string, filePath: string, branch?: string): Promise { // tslint:disable-line:no-any +export async function getFileSha( + this: IHookFunctions | IExecuteFunctions, + owner: string, + repository: string, + filePath: string, + branch?: string, + // tslint:disable-next-line:no-any +): Promise { const getBody: IDataObject = {}; if (branch !== undefined) { getBody.branch = branch; @@ -86,8 +97,15 @@ export async function getFileSha(this: IHookFunctions | IExecuteFunctions, owner return responseData.sha; } -export async function githubApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function githubApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -96,11 +114,11 @@ export async function githubApiRequestAllItems(this: IHookFunctions | IExecuteFu query.page = 1; do { - responseData = await githubApiRequest.call(this, method, endpoint, body, query, { resolveWithFullResponse: true }); + responseData = await githubApiRequest.call(this, method, endpoint, body, query, { + resolveWithFullResponse: true, + }); query.page++; returnData.push.apply(returnData, responseData.body); - } while ( - responseData.headers.link && responseData.headers.link.includes('next') - ); + } while (responseData.headers.link && responseData.headers.link.includes('next')); return returnData; } diff --git a/packages/nodes-base/nodes/Github/Github.node.ts b/packages/nodes-base/nodes/Github/Github.node.ts index 527d347231..f567c7b088 100644 --- a/packages/nodes-base/nodes/Github/Github.node.ts +++ b/packages/nodes-base/nodes/Github/Github.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,15 +8,9 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - getFileSha, - githubApiRequest, - githubApiRequestAllItems, -} from './GenericFunctions'; +import { getFileSha, githubApiRequest, githubApiRequestAllItems } from './GenericFunctions'; -import { - snakeCase, -} from 'change-case'; +import { snakeCase } from 'change-case'; export class Github implements INodeType { description: INodeTypeDescription = { @@ -249,7 +241,8 @@ export class Github implements INodeType { { name: 'Get License', value: 'getLicense', - description: 'Returns the contents of the repository\'s license file, if one is detected', + description: + "Returns the contents of the repository's license file, if one is detected", action: 'Get the license of a repository', }, { @@ -290,7 +283,7 @@ export class Github implements INodeType { name: 'Get Repositories', value: 'getRepositories', description: 'Returns the repositories of a user', - action: 'Get a user\'s repositories', + action: "Get a user's repositories", }, { name: 'Invite', @@ -1026,8 +1019,7 @@ export class Github implements INodeType { name: 'prerelease', type: 'boolean', default: false, - description: - 'Whether to point out that the release is non-production ready', + description: 'Whether to point out that the release is non-production ready', }, { displayName: 'Target Commitish', @@ -1035,7 +1027,7 @@ export class Github implements INodeType { type: 'string', default: '', description: - 'Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository\'s default branch(usually master).', + "Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch(usually master).", }, ], }, @@ -1105,8 +1097,7 @@ export class Github implements INodeType { name: 'prerelease', type: 'boolean', default: false, - description: - 'Whether to point out that the release is non-production ready', + description: 'Whether to point out that the release is non-production ready', }, { displayName: 'Tag Name', @@ -1121,7 +1112,7 @@ export class Github implements INodeType { type: 'string', default: '', description: - 'Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository\'s default branch(usually master).', + "Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch(usually master).", }, ], }, @@ -1741,7 +1732,9 @@ export class Github implements INodeType { const item = items[i]; if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; @@ -2104,7 +2097,9 @@ export class Github implements INodeType { } } } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { + itemIndex: i, + }); } if (returnAll === true) { @@ -2124,7 +2119,9 @@ export class Github implements INodeType { if (asBinaryProperty === true) { if (Array.isArray(responseData)) { - throw new NodeOperationError(this.getNode(), 'File Path is a folder, not a file.', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'File Path is a folder, not a file.', { + itemIndex: i, + }); } // Add the returned data to the item as binary property const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; diff --git a/packages/nodes-base/nodes/Github/GithubTrigger.node.ts b/packages/nodes-base/nodes/Github/GithubTrigger.node.ts index d1b3f8501b..d9b105673e 100644 --- a/packages/nodes-base/nodes/Github/GithubTrigger.node.ts +++ b/packages/nodes-base/nodes/Github/GithubTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -12,10 +9,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - githubApiRequest, -} from './GenericFunctions'; - +import { githubApiRequest } from './GenericFunctions'; export class GithubTrigger implements INodeType { description: INodeTypeDescription = { @@ -24,7 +18,8 @@ export class GithubTrigger implements INodeType { icon: 'file:github.svg', group: ['trigger'], version: 1, - subtitle: '={{$parameter["owner"] + "/" + $parameter["repository"] + ": " + $parameter["events"].join(", ")}}', + subtitle: + '={{$parameter["owner"] + "/" + $parameter["repository"] + ": " + $parameter["events"].join(", ")}}', description: 'Starts the workflow when Github events occur', defaults: { name: 'Github Trigger', @@ -37,9 +32,7 @@ export class GithubTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -48,9 +41,7 @@ export class GithubTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -111,7 +102,8 @@ export class GithubTrigger implements INodeType { { name: 'Check Run', value: 'check_run', - description: 'Triggered when a check run is created, rerequested, completed, or has a requested_action', + description: + 'Triggered when a check run is created, rerequested, completed, or has a requested_action', }, { name: 'Check Suite', @@ -126,7 +118,8 @@ export class GithubTrigger implements INodeType { { name: 'Content Reference', value: 'content_reference', - description: 'Triggered when the body or comment of an issue or pull request includes a URL that matches a configured content reference domain. Only GitHub Apps can receive this event.', + description: + 'Triggered when the body or comment of an issue or pull request includes a URL that matches a configured content reference domain. Only GitHub Apps can receive this event.', }, { name: 'Create', @@ -171,7 +164,8 @@ export class GithubTrigger implements INodeType { { name: 'Installation', value: 'installation', - description: 'Triggered when someone installs (created), uninstalls (deleted), or accepts new permissions (new_permissions_accepted) for a GitHub App. When a GitHub App owner requests new permissions, the person who installed the GitHub App must accept the new permissions request.', + description: + 'Triggered when someone installs (created), uninstalls (deleted), or accepts new permissions (new_permissions_accepted) for a GitHub App. When a GitHub App owner requests new permissions, the person who installed the GitHub App must accept the new permissions request.', }, { name: 'Installation Repositories', @@ -186,27 +180,31 @@ export class GithubTrigger implements INodeType { { name: 'Issues', value: 'issues', - description: 'Triggered when an issue is opened, edited, deleted, transferred, pinned, unpinned, closed, reopened, assigned, unassigned, labeled, unlabeled, locked, unlocked, milestoned, or demilestoned', + description: + 'Triggered when an issue is opened, edited, deleted, transferred, pinned, unpinned, closed, reopened, assigned, unassigned, labeled, unlabeled, locked, unlocked, milestoned, or demilestoned', }, { name: 'Label', value: 'label', - description: 'Triggered when a repository\'s label is created, edited, or deleted', + description: "Triggered when a repository's label is created, edited, or deleted", }, { name: 'Marketplace Purchase', value: 'marketplace_purchase', - description: 'Triggered when someone purchases a GitHub Marketplace plan, cancels their plan, upgrades their plan (effective immediately), downgrades a plan that remains pending until the end of the billing cycle, or cancels a pending plan change', + description: + 'Triggered when someone purchases a GitHub Marketplace plan, cancels their plan, upgrades their plan (effective immediately), downgrades a plan that remains pending until the end of the billing cycle, or cancels a pending plan change', }, { name: 'Member', value: 'member', - description: 'Triggered when a user accepts an invitation or is removed as a collaborator to a repository, or has their permissions changed', + description: + 'Triggered when a user accepts an invitation or is removed as a collaborator to a repository, or has their permissions changed', }, { name: 'Membership', value: 'membership', - description: 'Triggered when a user is added or removed from a team. Organization hooks only.', + description: + 'Triggered when a user is added or removed from a team. Organization hooks only.', }, { name: 'Meta', @@ -216,32 +214,38 @@ export class GithubTrigger implements INodeType { { name: 'Milestone', value: 'milestone', - description: 'Triggered when a milestone is created, closed, opened, edited, or deleted', + description: + 'Triggered when a milestone is created, closed, opened, edited, or deleted', }, { name: 'Org Block', value: 'org_block', - description: 'Triggered when an organization blocks or unblocks a user. Organization hooks only.', + description: + 'Triggered when an organization blocks or unblocks a user. Organization hooks only.', }, { name: 'Organization', value: 'organization', - description: 'Triggered when an organization is deleted and renamed, and when a user is added, removed, or invited to an organization. Organization hooks only.', + description: + 'Triggered when an organization is deleted and renamed, and when a user is added, removed, or invited to an organization. Organization hooks only.', }, { name: 'Page Build', value: 'page_build', - description: 'Triggered on push to a GitHub Pages enabled branch (gh-pages for project pages, master for user and organization pages)', + description: + 'Triggered on push to a GitHub Pages enabled branch (gh-pages for project pages, master for user and organization pages)', }, { name: 'Project', value: 'project', - description: 'Triggered when a project is created, updated, closed, reopened, or deleted', + description: + 'Triggered when a project is created, updated, closed, reopened, or deleted', }, { name: 'Project Card', value: 'project_card', - description: 'Triggered when a project card is created, edited, moved, converted to an issue, or deleted', + description: + 'Triggered when a project card is created, edited, moved, converted to an issue, or deleted', }, { name: 'Project Column', @@ -256,37 +260,44 @@ export class GithubTrigger implements INodeType { { name: 'Pull Request', value: 'pull_request', - description: 'Triggered when a pull request is assigned, unassigned, labeled, unlabeled, opened, edited, closed, reopened, synchronize, ready_for_review, locked, unlocked, a pull request review is requested, or a review request is removed', + description: + 'Triggered when a pull request is assigned, unassigned, labeled, unlabeled, opened, edited, closed, reopened, synchronize, ready_for_review, locked, unlocked, a pull request review is requested, or a review request is removed', }, { name: 'Pull Request Review', value: 'pull_request_review', - description: 'Triggered when a pull request review is submitted into a non-pending state, the body is edited, or the review is dismissed', + description: + 'Triggered when a pull request review is submitted into a non-pending state, the body is edited, or the review is dismissed', }, { name: 'Pull Request Review Comment', value: 'pull_request_review_comment', - description: 'Triggered when a comment on a pull request\'s unified diff is created, edited, or deleted (in the Files Changed tab)', + description: + "Triggered when a comment on a pull request's unified diff is created, edited, or deleted (in the Files Changed tab)", }, { name: 'Push', value: 'push', - description: 'Triggered on a push to a repository branch. Branch pushes and repository tag pushes also trigger webhook push events. This is the default event.', + description: + 'Triggered on a push to a repository branch. Branch pushes and repository tag pushes also trigger webhook push events. This is the default event.', }, { name: 'Release', value: 'release', - description: 'Triggered when a release is published, unpublished, created, edited, deleted, or prereleased', + description: + 'Triggered when a release is published, unpublished, created, edited, deleted, or prereleased', }, { name: 'Repository', value: 'repository', - description: 'Triggered when a repository is created, archived, unarchived, renamed, edited, transferred, made public, or made private. Organization hooks are also triggered when a repository is deleted.', + description: + 'Triggered when a repository is created, archived, unarchived, renamed, edited, transferred, made public, or made private. Organization hooks are also triggered when a repository is deleted.', }, { name: 'Repository Import', value: 'repository_import', - description: 'Triggered when a successful, cancelled, or failed repository import finishes for a GitHub organization or a personal repository', + description: + 'Triggered when a successful, cancelled, or failed repository import finishes for a GitHub organization or a personal repository', }, { name: 'Repository Vulnerability Alert', @@ -296,7 +307,8 @@ export class GithubTrigger implements INodeType { { name: 'Security Advisory', value: 'security_advisory', - description: 'Triggered when a new security advisory is published, updated, or withdrawn', + description: + 'Triggered when a new security advisory is published, updated, or withdrawn', }, { name: 'Star', @@ -311,7 +323,8 @@ export class GithubTrigger implements INodeType { { name: 'Team', value: 'team', - description: 'Triggered when an organization\'s team is created, deleted, edited, added_to_repository, or removed_from_repository. Organization hooks only.', + description: + "Triggered when an organization's team is created, deleted, edited, added_to_repository, or removed_from_repository. Organization hooks only.", }, { name: 'Team Add', @@ -369,7 +382,10 @@ export class GithubTrigger implements INodeType { const webhookUrl = this.getNodeWebhookUrl('default') as string; if (webhookUrl.includes('//localhost')) { - throw new NodeOperationError(this.getNode(), 'The Webhook can not work on "localhost". Please, either setup n8n on a custom domain or start with "--tunnel"!'); + throw new NodeOperationError( + this.getNode(), + 'The Webhook can not work on "localhost". Please, either setup n8n on a custom domain or start with "--tunnel"!', + ); } const owner = this.getNodeParameter('owner') as string; @@ -415,7 +431,10 @@ export class GithubTrigger implements INodeType { } } - throw new NodeOperationError(this.getNode(), 'A webhook with the identical URL probably exists already. Please delete it manually on Github!'); + throw new NodeOperationError( + this.getNode(), + 'A webhook with the identical URL probably exists already. Please delete it manually on Github!', + ); } throw error; @@ -423,7 +442,9 @@ export class GithubTrigger implements INodeType { if (responseData.id === undefined || responseData.active !== true) { // Required data is missing so was not successful - throw new NodeApiError(this.getNode(), responseData, { message: 'Github webhook creation response did not contain the expected data.' }); + throw new NodeApiError(this.getNode(), responseData, { + message: 'Github webhook creation response did not contain the expected data.', + }); } webhookData.webhookId = responseData.id as string; @@ -457,8 +478,6 @@ export class GithubTrigger implements INodeType { }, }; - - async webhook(this: IWebhookFunctions): Promise { const bodyData = this.getBodyData(); @@ -477,18 +496,14 @@ export class GithubTrigger implements INodeType { // TODO: Add headers & requestPath const returnData: IDataObject[] = []; - returnData.push( - { - body: bodyData, - headers: this.getHeaderData(), - query: this.getQueryData(), - }, - ); + returnData.push({ + body: bodyData, + headers: this.getHeaderData(), + query: this.getQueryData(), + }); return { - workflowData: [ - this.helpers.returnJsonArray(returnData), - ], + workflowData: [this.helpers.returnJsonArray(returnData)], }; } } diff --git a/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts b/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts index 1434993bd1..18609b6733 100644 --- a/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts @@ -1,11 +1,6 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; import { OptionsWithUri } from 'request'; /** @@ -17,7 +12,15 @@ import { OptionsWithUri } from 'request'; * @param {object} body * @returns {Promise} */ -export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: object, query?: object, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function gitlabApiRequest( + this: IHookFunctions | IExecuteFunctions, + method: string, + endpoint: string, + body: object, + query?: object, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { method, headers: {}, @@ -53,8 +56,15 @@ export async function gitlabApiRequest(this: IHookFunctions | IExecuteFunctions, } } -export async function gitlabApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function gitlabApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -63,11 +73,11 @@ export async function gitlabApiRequestAllItems(this: IHookFunctions | IExecuteFu query.page = 1; do { - responseData = await gitlabApiRequest.call(this, method, endpoint, body, query, { resolveWithFullResponse: true }); + responseData = await gitlabApiRequest.call(this, method, endpoint, body, query, { + resolveWithFullResponse: true, + }); query.page++; returnData.push.apply(returnData, responseData.body); - } while ( - responseData.headers.link && responseData.headers.link.includes('next') - ); + } while (responseData.headers.link && responseData.headers.link.includes('next')); return returnData; } diff --git a/packages/nodes-base/nodes/Gitlab/Gitlab.node.ts b/packages/nodes-base/nodes/Gitlab/Gitlab.node.ts index f4fb6b4bcd..a63fbd9252 100644 --- a/packages/nodes-base/nodes/Gitlab/Gitlab.node.ts +++ b/packages/nodes-base/nodes/Gitlab/Gitlab.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,10 +8,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - gitlabApiRequest, - gitlabApiRequestAllItems, -} from './GenericFunctions'; +import { gitlabApiRequest, gitlabApiRequestAllItems } from './GenericFunctions'; export class Gitlab implements INodeType { description: INodeTypeDescription = { @@ -35,9 +30,7 @@ export class Gitlab implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -46,9 +39,7 @@ export class Gitlab implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -96,8 +87,6 @@ export class Gitlab implements INodeType { default: 'issue', }, - - // ---------------------------------- // operations // ---------------------------------- @@ -108,9 +97,7 @@ export class Gitlab implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'issue', - ], + resource: ['issue'], }, }, options: [ @@ -155,9 +142,7 @@ export class Gitlab implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'repository', - ], + resource: ['repository'], }, }, options: [ @@ -184,9 +169,7 @@ export class Gitlab implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -194,7 +177,7 @@ export class Gitlab implements INodeType { name: 'Get Repositories', value: 'getRepositories', description: 'Returns the repositories of a user', - action: 'Get a user\'s repositories', + action: "Get a user's repositories", }, ], default: 'getRepositories', @@ -207,9 +190,7 @@ export class Gitlab implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'release', - ], + resource: ['release'], }, }, options: [ @@ -247,8 +228,6 @@ export class Gitlab implements INodeType { default: 'create', }, - - // ---------------------------------- // shared // ---------------------------------- @@ -269,12 +248,8 @@ export class Gitlab implements INodeType { required: true, displayOptions: { hide: { - resource: [ - 'user', - ], - operation: [ - 'getRepositories', - ], + resource: ['user'], + operation: ['getRepositories'], }, }, placeholder: 'n8n', @@ -296,12 +271,8 @@ export class Gitlab implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'issue', - ], + operation: ['create'], + resource: ['issue'], }, }, description: 'The title of the issue', @@ -316,12 +287,8 @@ export class Gitlab implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'issue', - ], + operation: ['create'], + resource: ['issue'], }, }, description: 'The body of the issue', @@ -332,12 +299,8 @@ export class Gitlab implements INodeType { type: 'dateTime', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'issue', - ], + operation: ['create'], + resource: ['issue'], }, }, default: '', @@ -353,15 +316,11 @@ export class Gitlab implements INodeType { }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'issue', - ], + operation: ['create'], + resource: ['issue'], }, }, - default: { 'label': '' }, + default: { label: '' }, options: [ { displayName: 'Label', @@ -382,15 +341,11 @@ export class Gitlab implements INodeType { }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'issue', - ], + operation: ['create'], + resource: ['issue'], }, }, - default: { 'assignee': '' }, + default: { assignee: '' }, options: [ { displayName: 'Assignee', @@ -402,7 +357,6 @@ export class Gitlab implements INodeType { ], }, - // ---------------------------------- // issue:createComment // ---------------------------------- @@ -414,12 +368,8 @@ export class Gitlab implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'createComment', - ], - resource: [ - 'issue', - ], + operation: ['createComment'], + resource: ['issue'], }, }, description: 'The number of the issue on which to create the comment on', @@ -433,12 +383,8 @@ export class Gitlab implements INodeType { }, displayOptions: { show: { - operation: [ - 'createComment', - ], - resource: [ - 'issue', - ], + operation: ['createComment'], + resource: ['issue'], }, }, default: '', @@ -456,12 +402,8 @@ export class Gitlab implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'edit', - ], - resource: [ - 'issue', - ], + operation: ['edit'], + resource: ['issue'], }, }, description: 'The number of the issue edit', @@ -475,12 +417,8 @@ export class Gitlab implements INodeType { }, displayOptions: { show: { - operation: [ - 'edit', - ], - resource: [ - 'issue', - ], + operation: ['edit'], + resource: ['issue'], }, }, default: {}, @@ -529,7 +467,7 @@ export class Gitlab implements INodeType { multipleValues: true, multipleValueButtonText: 'Add Label', }, - default: { 'label': '' }, + default: { label: '' }, options: [ { displayName: 'Label', @@ -548,7 +486,7 @@ export class Gitlab implements INodeType { multipleValues: true, multipleValueButtonText: 'Add Assignee', }, - default: { 'assignee': '' }, + default: { assignee: '' }, options: [ { displayName: 'Assignees', @@ -580,12 +518,8 @@ export class Gitlab implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'issue', - ], + operation: ['get'], + resource: ['issue'], }, }, description: 'The number of the issue get data of', @@ -602,12 +536,8 @@ export class Gitlab implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'lock', - ], - resource: [ - 'issue', - ], + operation: ['lock'], + resource: ['issue'], }, }, description: 'The number of the issue to lock', @@ -618,12 +548,8 @@ export class Gitlab implements INodeType { type: 'options', displayOptions: { show: { - operation: [ - 'lock', - ], - resource: [ - 'issue', - ], + operation: ['lock'], + resource: ['issue'], }, }, options: [ @@ -652,8 +578,6 @@ export class Gitlab implements INodeType { description: 'The reason to lock the issue', }, - - // ---------------------------------- // release // ---------------------------------- @@ -669,12 +593,8 @@ export class Gitlab implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'release', - ], + operation: ['create'], + resource: ['release'], }, }, description: 'The tag of the release', @@ -688,12 +608,8 @@ export class Gitlab implements INodeType { }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'release', - ], + operation: ['create'], + resource: ['release'], }, }, default: {}, @@ -720,7 +636,8 @@ export class Gitlab implements INodeType { name: 'ref', type: 'string', default: '', - description: 'If Tag doesn’t exist, the release will be created from Ref. It can be a commit SHA, another tag name, or a branch name.', + description: + 'If Tag doesn’t exist, the release will be created from Ref. It can be a commit SHA, another tag name, or a branch name.', }, ], }, @@ -736,13 +653,8 @@ export class Gitlab implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'delete', - 'get', - ], - resource: [ - 'release', - ], + operation: ['delete', 'get'], + resource: ['release'], }, }, description: 'The ID or URL-encoded path of the project', @@ -755,13 +667,8 @@ export class Gitlab implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'delete', - 'get', - ], - resource: [ - 'release', - ], + operation: ['delete', 'get'], + resource: ['release'], }, }, description: 'The Git tag the release is associated with', @@ -778,12 +685,8 @@ export class Gitlab implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'release', - ], + operation: ['getAll'], + resource: ['release'], }, }, description: 'The ID or URL-encoded path of the project', @@ -794,12 +697,8 @@ export class Gitlab implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'getAll', - ], + resource: ['release'], + operation: ['getAll'], }, }, default: false, @@ -811,15 +710,9 @@ export class Gitlab implements INodeType { type: 'number', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['release'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -838,12 +731,8 @@ export class Gitlab implements INodeType { }, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'release', - ], + operation: ['getAll'], + resource: ['release'], }, }, default: {}, @@ -896,12 +785,8 @@ export class Gitlab implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'release', - ], + operation: ['update'], + resource: ['release'], }, }, description: 'The ID or URL-encoded path of the project', @@ -914,12 +799,8 @@ export class Gitlab implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'release', - ], + operation: ['update'], + resource: ['release'], }, }, description: 'The Git tag the release is associated with', @@ -933,12 +814,8 @@ export class Gitlab implements INodeType { }, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'release', - ], + operation: ['update'], + resource: ['release'], }, }, default: {}, @@ -962,7 +839,8 @@ export class Gitlab implements INodeType { name: 'milestones', type: 'string', default: '', - description: 'The title of each milestone to associate with the release (provide a titles list spearated with comma)', + description: + 'The title of each milestone to associate with the release (provide a titles list spearated with comma)', }, { displayName: 'Released At', @@ -989,12 +867,8 @@ export class Gitlab implements INodeType { }, displayOptions: { show: { - operation: [ - 'getIssues', - ], - resource: [ - 'repository', - ], + operation: ['getIssues'], + resource: ['repository'], }, }, default: {}, @@ -1018,7 +892,8 @@ export class Gitlab implements INodeType { name: 'labels', type: 'string', default: '', - description: 'Return only issues with the given labels. Multiple lables can be separated by comma.', + description: + 'Return only issues with the given labels. Multiple lables can be separated by comma.', }, { displayName: 'Updated After', @@ -1094,14 +969,11 @@ export class Gitlab implements INodeType { default: 'desc', description: 'The sort order', }, - ], }, - ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -1223,7 +1095,9 @@ export class Gitlab implements INodeType { body.labels = (body.labels as IDataObject[]).map((data) => data['label']).join(','); } if (body.assignee_ids !== undefined) { - body.assignee_ids = (body.assignee_ids as IDataObject[]).map((data) => data['assignee']); + body.assignee_ids = (body.assignee_ids as IDataObject[]).map( + (data) => data['assignee'], + ); } endpoint = `${baseEndpoint}/issues/${issueNumber}`; @@ -1321,7 +1195,7 @@ export class Gitlab implements INodeType { const tagName = this.getNodeParameter('tag_name', i) as string; body = this.getNodeParameter('additionalFields', i, {}) as IDataObject; - if(body.milestones){ + if (body.milestones) { body.milestones = (body.milestones as string).split(','); } @@ -1362,7 +1236,13 @@ export class Gitlab implements INodeType { } if (returnAll === true) { - responseData = await gitlabApiRequestAllItems.call(this, requestMethod, endpoint, body, qs); + responseData = await gitlabApiRequestAllItems.call( + this, + requestMethod, + endpoint, + body, + qs, + ); } else { responseData = await gitlabApiRequest.call(this, requestMethod, endpoint, body, qs); } @@ -1374,7 +1254,10 @@ export class Gitlab implements INodeType { } } catch (error) { if (this.continueOnFail()) { - if (overwriteDataOperations.includes(fullOperation) || overwriteDataOperationsArray.includes(fullOperation)) { + if ( + overwriteDataOperations.includes(fullOperation) || + overwriteDataOperationsArray.includes(fullOperation) + ) { returnData.push({ error: error.message }); } else { items[i].json = { error: error.message }; @@ -1385,13 +1268,15 @@ export class Gitlab implements INodeType { } } - if (overwriteDataOperations.includes(fullOperation) || overwriteDataOperationsArray.includes(fullOperation)) { + if ( + overwriteDataOperations.includes(fullOperation) || + overwriteDataOperationsArray.includes(fullOperation) + ) { // Return data gets replaced return [this.helpers.returnJsonArray(returnData)]; } else { // For all other ones simply return the unchanged items return this.prepareOutputData(items); } - } } diff --git a/packages/nodes-base/nodes/Gitlab/GitlabTrigger.node.ts b/packages/nodes-base/nodes/Gitlab/GitlabTrigger.node.ts index 7e2643aeeb..d376239b9f 100644 --- a/packages/nodes-base/nodes/Gitlab/GitlabTrigger.node.ts +++ b/packages/nodes-base/nodes/Gitlab/GitlabTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -12,20 +9,19 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - gitlabApiRequest, -} from './GenericFunctions'; +import { gitlabApiRequest } from './GenericFunctions'; const GITLAB_EVENTS = [ { name: 'Comment', value: 'note', - description: 'Triggered when a new comment is made on commits, merge requests, issues, and code snippets', + description: + 'Triggered when a new comment is made on commits, merge requests, issues, and code snippets', }, { name: 'Confidential Issues', value: 'confidential_issues', - description: 'Triggered on confidential issues\' events', + description: "Triggered on confidential issues' events", }, { name: 'Confidential Comments', @@ -40,7 +36,8 @@ const GITLAB_EVENTS = [ { name: 'Issue', value: 'issues', - description: 'Triggered when a new issue is created or an existing issue was updated/closed/reopened', + description: + 'Triggered when a new issue is created or an existing issue was updated/closed/reopened', }, { name: 'Job', @@ -50,7 +47,8 @@ const GITLAB_EVENTS = [ { name: 'Merge Request', value: 'merge_requests', - description: 'Triggered when a new merge request is created, an existing merge request was updated/merged/closed or a commit is added in the source branch', + description: + 'Triggered when a new merge request is created, an existing merge request was updated/merged/closed or a commit is added in the source branch', }, { name: 'Pipeline', @@ -86,7 +84,8 @@ export class GitlabTrigger implements INodeType { icon: 'file:gitlab.svg', group: ['trigger'], version: 1, - subtitle: '={{$parameter["owner"] + "/" + $parameter["repository"] + ": " + $parameter["events"].join(", ")}}', + subtitle: + '={{$parameter["owner"] + "/" + $parameter["repository"] + ": " + $parameter["events"].join(", ")}}', description: 'Starts the workflow when GitLab events occur', defaults: { name: 'Gitlab Trigger', @@ -99,9 +98,7 @@ export class GitlabTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -110,9 +107,7 @@ export class GitlabTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -194,7 +189,7 @@ export class GitlabTrigger implements INodeType { const owner = this.getNodeParameter('owner') as string; const repository = this.getNodeParameter('repository') as string; - const path = (`${owner}/${repository}`).replace(/\//g, '%2F'); + const path = `${owner}/${repository}`.replace(/\//g, '%2F'); const endpoint = `/projects/${path}/hooks/${webhookData.webhookId}`; @@ -228,7 +223,7 @@ export class GitlabTrigger implements INodeType { let eventsArray = this.getNodeParameter('events', []) as string[]; if (eventsArray.includes('*')) { - eventsArray = GITLAB_EVENTS.map(e => e.value); + eventsArray = GITLAB_EVENTS.map((e) => e.value); } const events: { [key: string]: boolean } = {}; @@ -242,7 +237,7 @@ export class GitlabTrigger implements INodeType { events['push_events'] = false; } - const path = (`${owner}/${repository}`).replace(/\//g, '%2F'); + const path = `${owner}/${repository}`.replace(/\//g, '%2F'); const endpoint = `/projects/${path}/hooks`; @@ -261,7 +256,9 @@ export class GitlabTrigger implements INodeType { if (responseData.id === undefined) { // Required data is missing so was not successful - throw new NodeApiError(this.getNode(), responseData, { message: 'GitLab webhook creation response did not contain the expected data.' }); + throw new NodeApiError(this.getNode(), responseData, { + message: 'GitLab webhook creation response did not contain the expected data.', + }); } const webhookData = this.getWorkflowStaticData('node'); @@ -277,7 +274,7 @@ export class GitlabTrigger implements INodeType { const owner = this.getNodeParameter('owner') as string; const repository = this.getNodeParameter('repository') as string; - const path = (`${owner}/${repository}`).replace(/\//g, '%2F'); + const path = `${owner}/${repository}`.replace(/\//g, '%2F'); const endpoint = `/projects/${path}/hooks/${webhookData.webhookId}`; const body = {}; @@ -299,25 +296,19 @@ export class GitlabTrigger implements INodeType { }, }; - - async webhook(this: IWebhookFunctions): Promise { const bodyData = this.getBodyData(); const returnData: IDataObject[] = []; - returnData.push( - { - body: bodyData, - headers: this.getHeaderData(), - query: this.getQueryData(), - }, - ); + returnData.push({ + body: bodyData, + headers: this.getHeaderData(), + query: this.getQueryData(), + }); return { - workflowData: [ - this.helpers.returnJsonArray(returnData), - ], + workflowData: [this.helpers.returnJsonArray(returnData)], }; } } diff --git a/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts b/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts index 8ad4380537..1341117589 100644 --- a/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts +++ b/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts @@ -1,7 +1,4 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; import { IDataObject, @@ -10,9 +7,7 @@ import { NodeApiError, } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import moment from 'moment'; @@ -29,14 +24,13 @@ export async function goToWebinarApiRequest( body: IDataObject | IDataObject[], option: IDataObject = {}, ) { - const operation = this.getNodeParameter('operation', 0) as string; const resource = this.getNodeParameter('resource', 0) as string; const options: OptionsWithUri = { headers: { 'user-agent': 'n8n', - 'Accept': 'application/json', + Accept: 'application/json', 'Content-Type': 'application/json', }, method, @@ -63,7 +57,9 @@ export async function goToWebinarApiRequest( } try { - const response = await this.helpers.requestOAuth2!.call(this, 'goToWebinarOAuth2Api', options, { tokenExpiredStatusCode: 403 }); + const response = await this.helpers.requestOAuth2!.call(this, 'goToWebinarOAuth2Api', options, { + tokenExpiredStatusCode: 403, + }); if (response === '') { return {}; @@ -87,7 +83,6 @@ export async function goToWebinarApiRequestAllItems( body: IDataObject, resource: string, ) { - const resourceToResponseKey: { [key: string]: string } = { session: 'sessionInfoResources', webinar: 'webinars', @@ -113,9 +108,9 @@ export async function goToWebinarApiRequestAllItems( returnData = returnData.splice(0, qs.limit as number); return returnData; } - } while ( - responseData.totalElements && parseInt(responseData.totalElements, 10) > returnData.length + responseData.totalElements && + parseInt(responseData.totalElements, 10) > returnData.length ); return returnData; @@ -126,7 +121,8 @@ export async function handleGetAll( endpoint: string, qs: IDataObject, body: IDataObject, - resource: string) { + resource: string, +) { const returnAll = this.getNodeParameter('returnAll', 0) as boolean; if (!returnAll) { @@ -137,8 +133,8 @@ export async function handleGetAll( } export async function loadWebinars(this: ILoadOptionsFunctions) { - const { oauthTokenData } = await this.getCredentials('goToWebinarOAuth2Api') as { - oauthTokenData: { account_key: string } + const { oauthTokenData } = (await this.getCredentials('goToWebinarOAuth2Api')) as { + oauthTokenData: { account_key: string }; }; const endpoint = `accounts/${oauthTokenData.account_key}/webinars`; @@ -148,7 +144,14 @@ export async function loadWebinars(this: ILoadOptionsFunctions) { toTime: moment().add(1, 'years').format(), }; - const resourceItems = await goToWebinarApiRequestAllItems.call(this, 'GET', endpoint, qs, {}, 'webinar'); + const resourceItems = await goToWebinarApiRequestAllItems.call( + this, + 'GET', + endpoint, + qs, + {}, + 'webinar', + ); const returnData: INodePropertyOptions[] = []; @@ -163,21 +166,30 @@ export async function loadWebinars(this: ILoadOptionsFunctions) { } export async function loadWebinarSessions(this: ILoadOptionsFunctions) { - const { oauthTokenData } = await this.getCredentials('goToWebinarOAuth2Api') as { - oauthTokenData: { organizer_key: string } + const { oauthTokenData } = (await this.getCredentials('goToWebinarOAuth2Api')) as { + oauthTokenData: { organizer_key: string }; }; const webinarKey = this.getCurrentNodeParameter('webinarKey') as string; const endpoint = `organizers/${oauthTokenData.organizer_key}/webinars/${webinarKey}/sessions`; - const resourceItems = await goToWebinarApiRequestAllItems.call(this, 'GET', endpoint, {}, {}, 'session'); + const resourceItems = await goToWebinarApiRequestAllItems.call( + this, + 'GET', + endpoint, + {}, + {}, + 'session', + ); const returnData: INodePropertyOptions[] = []; resourceItems.forEach((item) => { returnData.push({ - name: `Date: ${moment(item.startTime as string).format('MM-DD-YYYY')} | From: ${moment(item.startTime as string).format('LT')} - To: ${moment(item.endTime as string).format('LT')}`, + name: `Date: ${moment(item.startTime as string).format('MM-DD-YYYY')} | From: ${moment( + item.startTime as string, + ).format('LT')} - To: ${moment(item.endTime as string).format('LT')}`, value: item.sessionKey as string, }); }); @@ -186,8 +198,8 @@ export async function loadWebinarSessions(this: ILoadOptionsFunctions) { } export async function loadRegistranSimpleQuestions(this: ILoadOptionsFunctions) { - const { oauthTokenData } = await this.getCredentials('goToWebinarOAuth2Api') as { - oauthTokenData: { organizer_key: string } + const { oauthTokenData } = (await this.getCredentials('goToWebinarOAuth2Api')) as { + oauthTokenData: { organizer_key: string }; }; const webinarkey = this.getNodeParameter('webinarKey') as string; @@ -211,8 +223,8 @@ export async function loadRegistranSimpleQuestions(this: ILoadOptionsFunctions) } export async function loadAnswers(this: ILoadOptionsFunctions) { - const { oauthTokenData } = await this.getCredentials('goToWebinarOAuth2Api') as { - oauthTokenData: { organizer_key: string } + const { oauthTokenData } = (await this.getCredentials('goToWebinarOAuth2Api')) as { + oauthTokenData: { organizer_key: string }; }; const webinarKey = this.getCurrentNodeParameter('webinarKey') as string; @@ -240,8 +252,8 @@ export async function loadAnswers(this: ILoadOptionsFunctions) { } export async function loadRegistranMultiChoiceQuestions(this: ILoadOptionsFunctions) { - const { oauthTokenData } = await this.getCredentials('goToWebinarOAuth2Api') as { - oauthTokenData: { organizer_key: string } + const { oauthTokenData } = (await this.getCredentials('goToWebinarOAuth2Api')) as { + oauthTokenData: { organizer_key: string }; }; const webinarkey = this.getNodeParameter('webinarKey') as string; @@ -268,8 +280,7 @@ export async function loadRegistranMultiChoiceQuestions(this: ILoadOptionsFuncti function convertLosslessNumber(key: any, value: any) { if (value && value.isLosslessNumber) { return value.toString(); - } - else { + } else { return value; } } diff --git a/packages/nodes-base/nodes/GoToWebinar/GoToWebinar.node.ts b/packages/nodes-base/nodes/GoToWebinar/GoToWebinar.node.ts index 1194311264..bd23e91e27 100644 --- a/packages/nodes-base/nodes/GoToWebinar/GoToWebinar.node.ts +++ b/packages/nodes-base/nodes/GoToWebinar/GoToWebinar.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -38,10 +36,7 @@ import { loadWebinarSessions, } from './GenericFunctions'; -import { - isEmpty, - omit, -} from 'lodash'; +import { isEmpty, omit } from 'lodash'; import moment from 'moment-timezone'; @@ -139,10 +134,14 @@ export class GoToWebinar implements INodeType { } return returnData; }, - async getRegistranSimpleQuestions(this: ILoadOptionsFunctions): Promise { + async getRegistranSimpleQuestions( + this: ILoadOptionsFunctions, + ): Promise { return await loadRegistranSimpleQuestions.call(this); }, - async getRegistranMultiChoiceQuestions(this: ILoadOptionsFunctions): Promise { + async getRegistranMultiChoiceQuestions( + this: ILoadOptionsFunctions, + ): Promise { return await loadRegistranMultiChoiceQuestions.call(this); }, }, @@ -157,19 +156,16 @@ export class GoToWebinar implements INodeType { let responseData; const returnData: IDataObject[] = []; - const { oauthTokenData } = await this.getCredentials('goToWebinarOAuth2Api') as { - oauthTokenData: { account_key: string, organizer_key: string } + const { oauthTokenData } = (await this.getCredentials('goToWebinarOAuth2Api')) as { + oauthTokenData: { account_key: string; organizer_key: string }; }; const accountKey = oauthTokenData.account_key; const organizerKey = oauthTokenData.organizer_key; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'attendee') { - // ********************************************************************* // attendee // ********************************************************************* @@ -177,7 +173,6 @@ export class GoToWebinar implements INodeType { // https://developer.goto.com/GoToWebinarV2/#tag/Attendees if (operation === 'get') { - // ---------------------------------- // attendee: get // ---------------------------------- @@ -188,9 +183,7 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/sessions/${sessionKey}/attendees/${registrantKey}`; responseData = await goToWebinarApiRequest.call(this, 'GET', endpoint, {}, {}); - } else if (operation === 'getAll') { - // ---------------------------------- // attendee: getAll // ---------------------------------- @@ -200,9 +193,7 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/sessions/${sessionKey}/attendees`; responseData = await handleGetAll.call(this, endpoint, {}, {}, resource); - } else if (operation === 'getDetails') { - // ---------------------------------- // attendee: getDetails // ---------------------------------- @@ -214,11 +205,8 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/sessions/${sessionKey}/attendees/${registrantKey}/${details}`; responseData = await goToWebinarApiRequest.call(this, 'GET', endpoint, {}, {}); - } - } else if (resource === 'coorganizer') { - // ********************************************************************* // coorganizer // ********************************************************************* @@ -226,7 +214,6 @@ export class GoToWebinar implements INodeType { // https://developer.goto.com/GoToWebinarV2/#tag/Co-organizers if (operation === 'create') { - // ---------------------------------- // coorganizer: create // ---------------------------------- @@ -248,9 +235,7 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/coorganizers`; responseData = await goToWebinarApiRequest.call(this, 'POST', endpoint, {}, [body]); - } else if (operation === 'delete') { - // ---------------------------------- // coorganizer: delete // ---------------------------------- @@ -265,9 +250,7 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/coorganizers/${coorganizerKey}`; responseData = await goToWebinarApiRequest.call(this, 'DELETE', endpoint, qs, {}); responseData = { success: true }; - } else if (operation === 'getAll') { - // ---------------------------------- // coorganizer: getAll // ---------------------------------- @@ -276,9 +259,7 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/coorganizers`; responseData = await handleGetAll.call(this, endpoint, {}, {}, resource); - } else if (operation === 'reinvite') { - // ---------------------------------- // coorganizer: reinvite // ---------------------------------- @@ -294,11 +275,8 @@ export class GoToWebinar implements INodeType { responseData = await goToWebinarApiRequest.call(this, 'POST', endpoint, qs, {}); responseData = { success: true }; - } - } else if (resource === 'panelist') { - // ********************************************************************* // panelist // ********************************************************************* @@ -306,7 +284,6 @@ export class GoToWebinar implements INodeType { // https://developer.goto.com/GoToWebinarV2/#tag/Panelists if (operation === 'create') { - // ---------------------------------- // panelist: create // ---------------------------------- @@ -322,9 +299,7 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/panelists`; responseData = await goToWebinarApiRequest.call(this, 'POST', endpoint, {}, body); - } else if (operation === 'delete') { - // ---------------------------------- // panelist: delete // ---------------------------------- @@ -335,9 +310,7 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/panelists/${panelistKey}`; responseData = await goToWebinarApiRequest.call(this, 'DELETE', endpoint, {}, {}); responseData = { success: true }; - } else if (operation === 'getAll') { - // ---------------------------------- // panelist: getAll // ---------------------------------- @@ -346,9 +319,7 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/panelists`; responseData = await handleGetAll.call(this, endpoint, {}, {}, resource); - } else if (operation === 'reinvite') { - // ---------------------------------- // panelist: reinvite // ---------------------------------- @@ -359,11 +330,8 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/panelists/${panelistKey}/resendInvitation`; responseData = await goToWebinarApiRequest.call(this, 'POST', endpoint, {}, {}); responseData = { success: true }; - } - } else if (resource === 'registrant') { - // ********************************************************************* // registrant // ********************************************************************* @@ -371,7 +339,6 @@ export class GoToWebinar implements INodeType { // https://developer.goto.com/GoToWebinarV2/#tag/Registrants if (operation === 'create') { - // ---------------------------------- // registrant: create // ---------------------------------- @@ -387,16 +354,12 @@ export class GoToWebinar implements INodeType { } as IDataObject; let additionalFields = this.getNodeParameter('additionalFields', i) as Partial<{ - resendConfirmation: boolean, + resendConfirmation: boolean; fullAddress: { - details: { [key: string]: string } - } - simpleResponses: [ - { [key: string]: string } - ], - multiChoiceResponses: [ - { [key: string]: string } - ], + details: { [key: string]: string }; + }; + simpleResponses: [{ [key: string]: string }]; + multiChoiceResponses: [{ [key: string]: string }]; }>; if (additionalFields.resendConfirmation) { @@ -425,9 +388,7 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/registrants`; responseData = await goToWebinarApiRequest.call(this, 'POST', endpoint, qs, body); - } else if (operation === 'delete') { - // ---------------------------------- // registrant: delete // ---------------------------------- @@ -438,9 +399,7 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/registrants/${registrantKey}`; responseData = await goToWebinarApiRequest.call(this, 'DELETE', endpoint, {}, {}); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------- // registrant: get // ---------------------------------- @@ -450,9 +409,7 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/registrants/${registrantKey}`; responseData = await goToWebinarApiRequest.call(this, 'GET', endpoint, {}, {}); - } else if (operation === 'getAll') { - // ---------------------------------- // registrant: getAll // ---------------------------------- @@ -462,9 +419,7 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/registrants`; responseData = await handleGetAll.call(this, endpoint, {}, {}, resource); } - } else if (resource === 'session') { - // ********************************************************************* // session // ********************************************************************* @@ -472,7 +427,6 @@ export class GoToWebinar implements INodeType { // https://developer.goto.com/GoToWebinarV2/#tag/Sessions if (operation === 'get') { - // ---------------------------------- // session: get // ---------------------------------- @@ -482,9 +436,7 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/sessions/${sessionKey}`; responseData = await goToWebinarApiRequest.call(this, 'GET', endpoint, {}, {}); - } else if (operation === 'getAll') { - // ---------------------------------- // session: getAll // ---------------------------------- @@ -497,15 +449,12 @@ export class GoToWebinar implements INodeType { qs.limit = this.getNodeParameter('limit', 0) as number; } - const { - webinarKey, - times, - } = this.getNodeParameter('additionalFields', i) as { - filterByWebinar: boolean, - webinarKey: string, + const { webinarKey, times } = this.getNodeParameter('additionalFields', i) as { + filterByWebinar: boolean; + webinarKey: string; times: { - timesProperties: { [key: string]: string } - } + timesProperties: { [key: string]: string }; + }; }; if (times) { @@ -517,18 +466,27 @@ export class GoToWebinar implements INodeType { } if (webinarKey !== undefined) { - const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/sessions`; - responseData = await goToWebinarApiRequestAllItems.call(this, 'GET', endpoint, qs, {}, resource); - + responseData = await goToWebinarApiRequestAllItems.call( + this, + 'GET', + endpoint, + qs, + {}, + resource, + ); } else { - const endpoint = `organizers/${organizerKey}/sessions`; - responseData = await goToWebinarApiRequestAllItems.call(this, 'GET', endpoint, qs, {}, resource); + responseData = await goToWebinarApiRequestAllItems.call( + this, + 'GET', + endpoint, + qs, + {}, + resource, + ); } - } else if (operation === 'getDetails') { - // ---------------------------------- // session: getDetails // ---------------------------------- @@ -539,11 +497,8 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}/sessions/${sessionKey}/${details}`; responseData = await goToWebinarApiRequest.call(this, 'GET', endpoint, {}, {}); - } - } else if (resource === 'webinar') { - // ********************************************************************* // webinar // ********************************************************************* @@ -551,12 +506,15 @@ export class GoToWebinar implements INodeType { // https://developer.goto.com/GoToWebinarV2/#tag/Webinars if (operation === 'create') { - // ---------------------------------- // webinar: create // ---------------------------------- - const timesProperties = this.getNodeParameter('times.timesProperties', i, []) as IDataObject; + const timesProperties = this.getNodeParameter( + 'times.timesProperties', + i, + [], + ) as IDataObject; const body = { subject: this.getNodeParameter('subject', i) as string, @@ -568,16 +526,17 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars`; responseData = await goToWebinarApiRequest.call(this, 'POST', endpoint, {}, body); - } else if (operation === 'delete') { - // ---------------------------------- // webinar: delete // ---------------------------------- const webinarKey = this.getNodeParameter('webinarKey', i) as string; - const { sendCancellationEmails } = this.getNodeParameter('additionalFields', i) as IDataObject; + const { sendCancellationEmails } = this.getNodeParameter( + 'additionalFields', + i, + ) as IDataObject; const qs = {} as IDataObject; @@ -588,9 +547,7 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}`; await goToWebinarApiRequest.call(this, 'DELETE', endpoint, qs, {}); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------- // webinar: get // ---------------------------------- @@ -599,9 +556,7 @@ export class GoToWebinar implements INodeType { const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}`; responseData = await goToWebinarApiRequest.call(this, 'GET', endpoint, {}, {}); - } else if (operation === 'getAll') { - // ---------------------------------- // webinar: getAll // ---------------------------------- @@ -616,8 +571,8 @@ export class GoToWebinar implements INodeType { const { times } = this.getNodeParameter('additionalFields', i) as { times: { - timesProperties: { [key: string]: string } - } + timesProperties: { [key: string]: string }; + }; }; if (times) { @@ -629,10 +584,15 @@ export class GoToWebinar implements INodeType { } const endpoint = `accounts/${accountKey}/webinars`; - responseData = await goToWebinarApiRequestAllItems.call(this, 'GET', endpoint, qs, {}, resource); - + responseData = await goToWebinarApiRequestAllItems.call( + this, + 'GET', + endpoint, + qs, + {}, + resource, + ); } else if (operation === 'update') { - // ---------------------------------- // webinar: update // ---------------------------------- @@ -649,7 +609,7 @@ export class GoToWebinar implements INodeType { if (updateFields.times) { const { times } = updateFields as { - times: { timesProperties: Array<{ startTime: string, endTime: string }> } + times: { timesProperties: Array<{ startTime: string; endTime: string }> }; }; body = { @@ -662,7 +622,11 @@ export class GoToWebinar implements INodeType { Object.assign(body, updateFields); if (isEmpty(updateFields)) { - throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Please enter at least one field to update for the ${resource}.`, + { itemIndex: i }, + ); } const endpoint = `organizers/${organizerKey}/webinars/${webinarKey}`; @@ -670,7 +634,6 @@ export class GoToWebinar implements INodeType { responseData = { success: true }; } } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/GoToWebinar/descriptions/AttendeeDescription.ts b/packages/nodes-base/nodes/GoToWebinar/descriptions/AttendeeDescription.ts index 83bed5b331..f6c037f1f9 100644 --- a/packages/nodes-base/nodes/GoToWebinar/descriptions/AttendeeDescription.ts +++ b/packages/nodes-base/nodes/GoToWebinar/descriptions/AttendeeDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const attendeeOperations: INodeProperties[] = [ { @@ -28,9 +26,7 @@ export const attendeeOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'attendee', - ], + resource: ['attendee'], }, }, }, @@ -49,12 +45,11 @@ export const attendeeFields: INodeProperties[] = [ }, required: true, default: '', - description: 'Key of the webinar that the attendee attended. Choose from the list, or specify an ID using an expression.', + description: + 'Key of the webinar that the attendee attended. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'attendee', - ], + resource: ['attendee'], }, }, }, @@ -65,17 +60,14 @@ export const attendeeFields: INodeProperties[] = [ required: true, typeOptions: { loadOptionsMethod: 'getWebinarSessions', - loadOptionsDependsOn: [ - 'webinarKey', - ], + loadOptionsDependsOn: ['webinarKey'], }, default: '', - description: 'Key of the session that the attendee attended. Choose from the list, or specify an ID using an expression.', + description: + 'Key of the session that the attendee attended. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'attendee', - ], + resource: ['attendee'], }, }, }, @@ -92,12 +84,8 @@ export const attendeeFields: INodeProperties[] = [ description: 'Registrant key of the attendee at the webinar session', displayOptions: { show: { - resource: [ - 'attendee', - ], - operation: [ - 'get', - ], + resource: ['attendee'], + operation: ['get'], }, }, }, @@ -114,12 +102,8 @@ export const attendeeFields: INodeProperties[] = [ description: 'Registrant key of the attendee at the webinar session', displayOptions: { show: { - resource: [ - 'attendee', - ], - operation: [ - 'getDetails', - ], + resource: ['attendee'], + operation: ['getDetails'], }, }, }, @@ -149,12 +133,8 @@ export const attendeeFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'attendee', - ], - operation: [ - 'getDetails', - ], + resource: ['attendee'], + operation: ['getDetails'], }, }, }, @@ -170,12 +150,8 @@ export const attendeeFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'attendee', - ], - operation: [ - 'getAll', - ], + resource: ['attendee'], + operation: ['getAll'], }, }, }, @@ -191,15 +167,9 @@ export const attendeeFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'attendee', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['attendee'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/GoToWebinar/descriptions/CoorganizerDescription.ts b/packages/nodes-base/nodes/GoToWebinar/descriptions/CoorganizerDescription.ts index dccde4f29b..7ba68d1248 100644 --- a/packages/nodes-base/nodes/GoToWebinar/descriptions/CoorganizerDescription.ts +++ b/packages/nodes-base/nodes/GoToWebinar/descriptions/CoorganizerDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const coorganizerOperations: INodeProperties[] = [ { @@ -33,9 +31,7 @@ export const coorganizerOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'coorganizer', - ], + resource: ['coorganizer'], }, }, }, @@ -54,15 +50,12 @@ export const coorganizerFields: INodeProperties[] = [ }, required: true, default: [], - description: 'Key of the webinar that the co-organizer is hosting. Choose from the list, or specify an ID using an expression.', + description: + 'Key of the webinar that the co-organizer is hosting. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'coorganizer', - ], - operation: [ - 'create', - ], + resource: ['coorganizer'], + operation: ['create'], }, }, }, @@ -75,12 +68,8 @@ export const coorganizerFields: INodeProperties[] = [ description: 'Whether the co-organizer has no GoToWebinar account', displayOptions: { show: { - resource: [ - 'coorganizer', - ], - operation: [ - 'create', - ], + resource: ['coorganizer'], + operation: ['create'], }, }, }, @@ -89,18 +78,12 @@ export const coorganizerFields: INodeProperties[] = [ name: 'organizerKey', type: 'string', default: '', - description: 'The co-organizer\'s organizer key for the webinar', + description: "The co-organizer's organizer key for the webinar", displayOptions: { show: { - resource: [ - 'coorganizer', - ], - operation: [ - 'create', - ], - isExternal: [ - false, - ], + resource: ['coorganizer'], + operation: ['create'], + isExternal: [false], }, }, }, @@ -109,18 +92,12 @@ export const coorganizerFields: INodeProperties[] = [ name: 'givenName', type: 'string', default: '', - description: 'The co-organizer\'s given name', + description: "The co-organizer's given name", displayOptions: { show: { - resource: [ - 'coorganizer', - ], - operation: [ - 'create', - ], - isExternal: [ - true, - ], + resource: ['coorganizer'], + operation: ['create'], + isExternal: [true], }, }, }, @@ -130,18 +107,12 @@ export const coorganizerFields: INodeProperties[] = [ type: 'string', placeholder: 'name@email.com', default: '', - description: 'The co-organizer\'s email address', + description: "The co-organizer's email address", displayOptions: { show: { - resource: [ - 'coorganizer', - ], - operation: [ - 'create', - ], - isExternal: [ - true, - ], + resource: ['coorganizer'], + operation: ['create'], + isExternal: [true], }, }, }, @@ -158,15 +129,12 @@ export const coorganizerFields: INodeProperties[] = [ }, required: true, default: [], - description: 'Key of the webinar to delete. Choose from the list, or specify an ID using an expression.', + description: + 'Key of the webinar to delete. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'coorganizer', - ], - operation: [ - 'delete', - ], + resource: ['coorganizer'], + operation: ['delete'], }, }, }, @@ -178,12 +146,8 @@ export const coorganizerFields: INodeProperties[] = [ description: 'Key of the co-organizer to delete', displayOptions: { show: { - resource: [ - 'coorganizer', - ], - operation: [ - 'delete', - ], + resource: ['coorganizer'], + operation: ['delete'], }, }, }, @@ -195,16 +159,13 @@ export const coorganizerFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'coorganizer', - ], - operation: [ - 'delete', - ], + resource: ['coorganizer'], + operation: ['delete'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default only internal co-organizers (with a GoToWebinar account) can be deleted. If you want to use this call for external co-organizers you have to set this parameter to \'true\'.', + description: + "By default only internal co-organizers (with a GoToWebinar account) can be deleted. If you want to use this call for external co-organizers you have to set this parameter to 'true'.", }, // ---------------------------------- @@ -219,15 +180,12 @@ export const coorganizerFields: INodeProperties[] = [ }, required: true, default: [], - description: 'Key of the webinar to retrieve all co-organizers from. Choose from the list, or specify an ID using an expression.', + description: + 'Key of the webinar to retrieve all co-organizers from. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'coorganizer', - ], - operation: [ - 'getAll', - ], + resource: ['coorganizer'], + operation: ['getAll'], }, }, }, @@ -239,12 +197,8 @@ export const coorganizerFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'coorganizer', - ], - operation: [ - 'getAll', - ], + resource: ['coorganizer'], + operation: ['getAll'], }, }, }, @@ -260,15 +214,9 @@ export const coorganizerFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'coorganizer', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['coorganizer'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -282,15 +230,12 @@ export const coorganizerFields: INodeProperties[] = [ type: 'string', required: true, default: '', - description: 'By default only internal co-organizers (with a GoToWebinar account) can be deleted. If you want to use this call for external co-organizers you have to set this parameter to \'true\'.', + description: + "By default only internal co-organizers (with a GoToWebinar account) can be deleted. If you want to use this call for external co-organizers you have to set this parameter to 'true'.", displayOptions: { show: { - resource: [ - 'coorganizer', - ], - operation: [ - 'reinvite', - ], + resource: ['coorganizer'], + operation: ['reinvite'], }, }, }, @@ -302,12 +247,8 @@ export const coorganizerFields: INodeProperties[] = [ description: 'Key of the co-organizer to reinvite', displayOptions: { show: { - resource: [ - 'coorganizer', - ], - operation: [ - 'reinvite', - ], + resource: ['coorganizer'], + operation: ['reinvite'], }, }, }, @@ -320,12 +261,8 @@ export const coorganizerFields: INodeProperties[] = [ description: 'Whether the co-organizer has no GoToWebinar account', displayOptions: { show: { - resource: [ - 'coorganizer', - ], - operation: [ - 'reinvite', - ], + resource: ['coorganizer'], + operation: ['reinvite'], }, }, }, diff --git a/packages/nodes-base/nodes/GoToWebinar/descriptions/PanelistDescription.ts b/packages/nodes-base/nodes/GoToWebinar/descriptions/PanelistDescription.ts index 6f9e9f489a..6a2295574d 100644 --- a/packages/nodes-base/nodes/GoToWebinar/descriptions/PanelistDescription.ts +++ b/packages/nodes-base/nodes/GoToWebinar/descriptions/PanelistDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const panelistOperations: INodeProperties[] = [ { @@ -33,9 +31,7 @@ export const panelistOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'panelist', - ], + resource: ['panelist'], }, }, }, @@ -54,12 +50,8 @@ export const panelistFields: INodeProperties[] = [ description: 'Name of the panelist to create', displayOptions: { show: { - resource: [ - 'panelist', - ], - operation: [ - 'create', - ], + resource: ['panelist'], + operation: ['create'], }, }, }, @@ -73,12 +65,8 @@ export const panelistFields: INodeProperties[] = [ description: 'Email address of the panelist to create', displayOptions: { show: { - resource: [ - 'panelist', - ], - operation: [ - 'create', - ], + resource: ['panelist'], + operation: ['create'], }, }, }, @@ -91,15 +79,12 @@ export const panelistFields: INodeProperties[] = [ }, required: true, default: [], - description: 'Key of the webinar that the panelist will present at. Choose from the list, or specify an ID using an expression.', + description: + 'Key of the webinar that the panelist will present at. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'panelist', - ], - operation: [ - 'create', - ], + resource: ['panelist'], + operation: ['create'], }, }, }, @@ -116,15 +101,12 @@ export const panelistFields: INodeProperties[] = [ }, required: true, default: [], - description: 'Key of the webinar to retrieve all panelists from. Choose from the list, or specify an ID using an expression.', + description: + 'Key of the webinar to retrieve all panelists from. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'panelist', - ], - operation: [ - 'getAll', - ], + resource: ['panelist'], + operation: ['getAll'], }, }, }, @@ -136,12 +118,8 @@ export const panelistFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'panelist', - ], - operation: [ - 'getAll', - ], + resource: ['panelist'], + operation: ['getAll'], }, }, }, @@ -157,15 +135,9 @@ export const panelistFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'panelist', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['panelist'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -182,15 +154,12 @@ export const panelistFields: INodeProperties[] = [ }, required: true, default: [], - description: 'Key of the webinar to delete the panelist from. Choose from the list, or specify an ID using an expression.', + description: + 'Key of the webinar to delete the panelist from. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'panelist', - ], - operation: [ - 'delete', - ], + resource: ['panelist'], + operation: ['delete'], }, }, }, @@ -203,12 +172,8 @@ export const panelistFields: INodeProperties[] = [ description: 'Key of the panelist to delete', displayOptions: { show: { - resource: [ - 'panelist', - ], - operation: [ - 'delete', - ], + resource: ['panelist'], + operation: ['delete'], }, }, }, @@ -225,15 +190,12 @@ export const panelistFields: INodeProperties[] = [ }, required: true, default: [], - description: 'Key of the webinar to reinvite the panelist to. Choose from the list, or specify an ID using an expression.', + description: + 'Key of the webinar to reinvite the panelist to. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'panelist', - ], - operation: [ - 'reinvite', - ], + resource: ['panelist'], + operation: ['reinvite'], }, }, }, @@ -246,12 +208,8 @@ export const panelistFields: INodeProperties[] = [ description: 'Key of the panelist to reinvite', displayOptions: { show: { - resource: [ - 'panelist', - ], - operation: [ - 'reinvite', - ], + resource: ['panelist'], + operation: ['reinvite'], }, }, }, diff --git a/packages/nodes-base/nodes/GoToWebinar/descriptions/RegistrantDescription.ts b/packages/nodes-base/nodes/GoToWebinar/descriptions/RegistrantDescription.ts index 4ef17a9e42..f42198fbcf 100644 --- a/packages/nodes-base/nodes/GoToWebinar/descriptions/RegistrantDescription.ts +++ b/packages/nodes-base/nodes/GoToWebinar/descriptions/RegistrantDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const registrantOperations: INodeProperties[] = [ { @@ -33,9 +31,7 @@ export const registrantOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'registrant', - ], + resource: ['registrant'], }, }, }, @@ -54,15 +50,12 @@ export const registrantFields: INodeProperties[] = [ }, required: true, default: [], - description: 'Key of the webinar of the registrant to create. Choose from the list, or specify an ID using an expression.', + description: + 'Key of the webinar of the registrant to create. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'registrant', - ], - operation: [ - 'create', - ], + resource: ['registrant'], + operation: ['create'], }, }, }, @@ -74,12 +67,8 @@ export const registrantFields: INodeProperties[] = [ description: 'First name of the registrant to create', displayOptions: { show: { - resource: [ - 'registrant', - ], - operation: [ - 'create', - ], + resource: ['registrant'], + operation: ['create'], }, }, }, @@ -91,12 +80,8 @@ export const registrantFields: INodeProperties[] = [ description: 'Last name of the registrant to create', displayOptions: { show: { - resource: [ - 'registrant', - ], - operation: [ - 'create', - ], + resource: ['registrant'], + operation: ['create'], }, }, }, @@ -109,12 +94,8 @@ export const registrantFields: INodeProperties[] = [ description: 'Email address of the registrant to create', displayOptions: { show: { - resource: [ - 'registrant', - ], - operation: [ - 'create', - ], + resource: ['registrant'], + operation: ['create'], }, }, }, @@ -125,12 +106,8 @@ export const registrantFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'registrant', - ], - operation: [ - 'create', - ], + resource: ['registrant'], + operation: ['create'], }, }, default: {}, @@ -186,7 +163,7 @@ export const registrantFields: INodeProperties[] = [ name: 'industry', type: 'string', default: '', - description: 'The type of industry the registrant\'s organization belongs to', + description: "The type of industry the registrant's organization belongs to", }, { displayName: 'Job Title', @@ -213,12 +190,11 @@ export const registrantFields: INodeProperties[] = [ displayName: 'Question Key Name or ID', name: 'questionKey', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getRegistranMultiChoiceQuestions', - loadOptionsDependsOn: [ - 'webinarKey', - ], + loadOptionsDependsOn: ['webinarKey'], }, default: '', }, @@ -238,7 +214,7 @@ export const registrantFields: INodeProperties[] = [ name: 'numberOfEmployees', type: 'string', default: '', - description: 'The size in employees of the registrant\'s organization', + description: "The size in employees of the registrant's organization", }, { displayName: 'Organization', @@ -257,7 +233,7 @@ export const registrantFields: INodeProperties[] = [ name: 'purchasingRole', type: 'string', default: '', - description: 'Registrant\'s role in purchasing the product', + description: "Registrant's role in purchasing the product", }, { displayName: 'Purchasing Time Frame', @@ -298,12 +274,11 @@ export const registrantFields: INodeProperties[] = [ displayName: 'Question Key Name or ID', name: 'questionKey', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getRegistranSimpleQuestions', - loadOptionsDependsOn: [ - 'webinarKey', - ], + loadOptionsDependsOn: ['webinarKey'], }, default: '', }, @@ -340,15 +315,12 @@ export const registrantFields: INodeProperties[] = [ }, required: true, default: [], - description: 'The key of the webinar to retrieve registrants from. Choose from the list, or specify an ID using an expression.', + description: + 'The key of the webinar to retrieve registrants from. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'registrant', - ], - operation: [ - 'getAll', - ], + resource: ['registrant'], + operation: ['getAll'], }, }, }, @@ -360,12 +332,8 @@ export const registrantFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'registrant', - ], - operation: [ - 'getAll', - ], + resource: ['registrant'], + operation: ['getAll'], }, }, }, @@ -381,15 +349,9 @@ export const registrantFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'registrant', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['registrant'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -406,15 +368,12 @@ export const registrantFields: INodeProperties[] = [ }, required: true, default: [], - description: 'Key of the webinar of the registrant to delete. Choose from the list, or specify an ID using an expression.', + description: + 'Key of the webinar of the registrant to delete. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'registrant', - ], - operation: [ - 'delete', - ], + resource: ['registrant'], + operation: ['delete'], }, }, }, @@ -427,12 +386,8 @@ export const registrantFields: INodeProperties[] = [ description: 'Key of the registrant to delete', displayOptions: { show: { - resource: [ - 'registrant', - ], - operation: [ - 'delete', - ], + resource: ['registrant'], + operation: ['delete'], }, }, }, @@ -449,15 +404,12 @@ export const registrantFields: INodeProperties[] = [ }, required: true, default: [], - description: 'Key of the webinar of the registrant to retrieve. Choose from the list, or specify an ID using an expression.', + description: + 'Key of the webinar of the registrant to retrieve. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'registrant', - ], - operation: [ - 'get', - ], + resource: ['registrant'], + operation: ['get'], }, }, }, @@ -470,12 +422,8 @@ export const registrantFields: INodeProperties[] = [ description: 'Key of the registrant to retrieve', displayOptions: { show: { - resource: [ - 'registrant', - ], - operation: [ - 'get', - ], + resource: ['registrant'], + operation: ['get'], }, }, }, diff --git a/packages/nodes-base/nodes/GoToWebinar/descriptions/SessionDescription.ts b/packages/nodes-base/nodes/GoToWebinar/descriptions/SessionDescription.ts index 4481389f07..054c54f1ba 100644 --- a/packages/nodes-base/nodes/GoToWebinar/descriptions/SessionDescription.ts +++ b/packages/nodes-base/nodes/GoToWebinar/descriptions/SessionDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const sessionOperations: INodeProperties[] = [ { @@ -28,9 +26,7 @@ export const sessionOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'session', - ], + resource: ['session'], }, }, }, @@ -48,12 +44,8 @@ export const sessionFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'session', - ], - operation: [ - 'getAll', - ], + resource: ['session'], + operation: ['getAll'], }, }, }, @@ -69,15 +61,9 @@ export const sessionFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'session', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['session'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -88,12 +74,8 @@ export const sessionFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'session', - ], - operation: [ - 'getAll', - ], + resource: ['session'], + operation: ['getAll'], }, }, default: {}, @@ -136,7 +118,8 @@ export const sessionFields: INodeProperties[] = [ loadOptionsMethod: 'getWebinars', }, default: {}, - description: 'Webinar by which to filter the sessions to retrieve. Choose from the list, or specify an ID using an expression.', + description: + 'Webinar by which to filter the sessions to retrieve. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -153,16 +136,12 @@ export const sessionFields: INodeProperties[] = [ }, required: true, default: [], - description: 'Key of the webinar to which the session belongs. Choose from the list, or specify an ID using an expression.', + description: + 'Key of the webinar to which the session belongs. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'session', - ], - operation: [ - 'get', - 'getDetails', - ], + resource: ['session'], + operation: ['get', 'getDetails'], }, }, }, @@ -174,13 +153,8 @@ export const sessionFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'session', - ], - operation: [ - 'get', - 'getDetails', - ], + resource: ['session'], + operation: ['get', 'getDetails'], }, }, }, @@ -217,12 +191,8 @@ export const sessionFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'session', - ], - operation: [ - 'getDetails', - ], + resource: ['session'], + operation: ['getDetails'], }, }, }, diff --git a/packages/nodes-base/nodes/GoToWebinar/descriptions/WebinarDescription.ts b/packages/nodes-base/nodes/GoToWebinar/descriptions/WebinarDescription.ts index bb6a8b4e38..36e3e2a340 100644 --- a/packages/nodes-base/nodes/GoToWebinar/descriptions/WebinarDescription.ts +++ b/packages/nodes-base/nodes/GoToWebinar/descriptions/WebinarDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const webinarOperations: INodeProperties[] = [ { @@ -37,9 +35,7 @@ export const webinarOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'webinar', - ], + resource: ['webinar'], }, }, }, @@ -57,12 +53,8 @@ export const webinarFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'webinar', - ], - operation: [ - 'create', - ], + resource: ['webinar'], + operation: ['create'], }, }, }, @@ -78,12 +70,8 @@ export const webinarFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'webinar', - ], - operation: [ - 'create', - ], + resource: ['webinar'], + operation: ['create'], }, }, options: [ @@ -116,12 +104,8 @@ export const webinarFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'webinar', - ], - operation: [ - 'create', - ], + resource: ['webinar'], + operation: ['create'], }, }, default: {}, @@ -171,7 +155,8 @@ export const webinarFields: INodeProperties[] = [ displayName: 'Timezone Name or ID', name: 'timezone', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, default: '', placeholder: '2020-12-11T09:00:00Z', @@ -194,12 +179,14 @@ export const webinarFields: INodeProperties[] = [ { name: 'Series', value: 'series', - description: 'Webinar with multiple meetings times where attendees choose only one to attend', + description: + 'Webinar with multiple meetings times where attendees choose only one to attend', }, { name: 'Sequence', value: 'sequence', - description: 'Webinar with multiple meeting times where attendees are expected to be the same for all sessions', + description: + 'Webinar with multiple meeting times where attendees are expected to be the same for all sessions', }, ], }, @@ -218,12 +205,8 @@ export const webinarFields: INodeProperties[] = [ description: 'Key of the webinar to delete', displayOptions: { show: { - resource: [ - 'webinar', - ], - operation: [ - 'delete', - ], + resource: ['webinar'], + operation: ['delete'], }, }, }, @@ -234,12 +217,8 @@ export const webinarFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'webinar', - ], - operation: [ - 'delete', - ], + resource: ['webinar'], + operation: ['delete'], }, }, default: {}, @@ -265,12 +244,8 @@ export const webinarFields: INodeProperties[] = [ description: 'Key of the webinar to retrieve', displayOptions: { show: { - resource: [ - 'webinar', - ], - operation: [ - 'get', - ], + resource: ['webinar'], + operation: ['get'], }, }, }, @@ -286,12 +261,8 @@ export const webinarFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'webinar', - ], - operation: [ - 'getAll', - ], + resource: ['webinar'], + operation: ['getAll'], }, }, }, @@ -307,15 +278,9 @@ export const webinarFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'webinar', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['webinar'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -326,12 +291,8 @@ export const webinarFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'webinar', - ], - operation: [ - 'getAll', - ], + resource: ['webinar'], + operation: ['getAll'], }, }, default: {}, @@ -381,12 +342,8 @@ export const webinarFields: INodeProperties[] = [ description: 'Key of the webinar to update', displayOptions: { show: { - resource: [ - 'webinar', - ], - operation: [ - 'update', - ], + resource: ['webinar'], + operation: ['update'], }, }, }, @@ -398,12 +355,8 @@ export const webinarFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'webinar', - ], - operation: [ - 'update', - ], + resource: ['webinar'], + operation: ['update'], }, }, }, @@ -414,12 +367,8 @@ export const webinarFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'webinar', - ], - operation: [ - 'update', - ], + resource: ['webinar'], + operation: ['update'], }, }, default: {}, @@ -514,7 +463,8 @@ export const webinarFields: INodeProperties[] = [ type: 'options', default: '', placeholder: '2020-12-11T09:00:00Z', - description: 'Timezone where the webinar is to take place. Choose from the list, or specify an ID using an expression.', + description: + 'Timezone where the webinar is to take place. Choose from the list, or specify an ID using an expression.', typeOptions: { alwaysOpenEditWindow: true, loadOptionsMethod: 'getTimezones', @@ -534,12 +484,14 @@ export const webinarFields: INodeProperties[] = [ { name: 'Series', value: 'series', - description: 'Webinar with multiple meetings times where attendees choose only one to attend', + description: + 'Webinar with multiple meetings times where attendees choose only one to attend', }, { name: 'Sequence', value: 'sequence', - description: 'Webinar with multiple meeting times where attendees are expected to be the same for all sessions', + description: + 'Webinar with multiple meeting times where attendees are expected to be the same for all sessions', }, ], }, diff --git a/packages/nodes-base/nodes/Google/Ads/CampaignDescription.ts b/packages/nodes-base/nodes/Google/Ads/CampaignDescription.ts index 490707cb03..bbeb22b340 100644 --- a/packages/nodes-base/nodes/Google/Ads/CampaignDescription.ts +++ b/packages/nodes-base/nodes/Google/Ads/CampaignDescription.ts @@ -14,9 +14,7 @@ export const campaignOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'campaign', - ], + resource: ['campaign'], }, }, options: [ @@ -29,41 +27,41 @@ export const campaignOperations: INodeProperties[] = [ method: 'POST', url: '={{"/v9/customers/" + $parameter["clientCustomerId"].toString().replace(/-/g, "") + "/googleAds:search"}}', body: { - query: '={{ "' + - 'select ' + - 'campaign.id, ' + - 'campaign.name, ' + - 'campaign_budget.amount_micros, ' + - 'campaign_budget.period,' + - 'campaign.status,' + - 'campaign.optimization_score,' + - 'campaign.advertising_channel_type,' + - 'campaign.advertising_channel_sub_type,' + - 'metrics.impressions,' + - 'metrics.interactions,' + - 'metrics.interaction_rate,' + - 'metrics.average_cost,' + - 'metrics.cost_micros,' + - 'metrics.conversions,' + - 'metrics.cost_per_conversion,' + - 'metrics.conversions_from_interactions_rate,' + - 'metrics.video_views,' + - 'metrics.average_cpm,' + - 'metrics.ctr ' + - 'from campaign ' + - 'where campaign.id > 0 ' + // create a dummy where clause so we can append more conditions - '" + (["allTime", undefined, ""].includes($parameter.additionalOptions?.dateRange) ? "" : " and segments.date DURING " + $parameter.additionalOptions.dateRange) + " ' + - '" + (["all", undefined, ""].includes($parameter.additionalOptions?.campaignStatus) ? "" : " and campaign.status = \'" + $parameter.additionalOptions.campaignStatus + "\'") + "' + - '" }}', + query: + '={{ "' + + 'select ' + + 'campaign.id, ' + + 'campaign.name, ' + + 'campaign_budget.amount_micros, ' + + 'campaign_budget.period,' + + 'campaign.status,' + + 'campaign.optimization_score,' + + 'campaign.advertising_channel_type,' + + 'campaign.advertising_channel_sub_type,' + + 'metrics.impressions,' + + 'metrics.interactions,' + + 'metrics.interaction_rate,' + + 'metrics.average_cost,' + + 'metrics.cost_micros,' + + 'metrics.conversions,' + + 'metrics.cost_per_conversion,' + + 'metrics.conversions_from_interactions_rate,' + + 'metrics.video_views,' + + 'metrics.average_cpm,' + + 'metrics.ctr ' + + 'from campaign ' + + 'where campaign.id > 0 ' + // create a dummy where clause so we can append more conditions + '" + (["allTime", undefined, ""].includes($parameter.additionalOptions?.dateRange) ? "" : " and segments.date DURING " + $parameter.additionalOptions.dateRange) + " ' + + '" + (["all", undefined, ""].includes($parameter.additionalOptions?.campaignStatus) ? "" : " and campaign.status = \'" + $parameter.additionalOptions.campaignStatus + "\'") + "' + + '" }}', }, headers: { - 'login-customer-id': '={{$parameter["managerCustomerId"].toString().replace(/-/g, "")}}', + 'login-customer-id': + '={{$parameter["managerCustomerId"].toString().replace(/-/g, "")}}', }, }, output: { - postReceive: [ - processCampaignSearchResponse, - ], + postReceive: [processCampaignSearchResponse], }, }, action: 'Get all campaigns', @@ -105,14 +103,13 @@ export const campaignOperations: INodeProperties[] = [ '}}', }, headers: { - 'login-customer-id': '={{$parameter["managerCustomerId"].toString().replace(/-/g, "")}}', + 'login-customer-id': + '={{$parameter["managerCustomerId"].toString().replace(/-/g, "")}}', 'content-type': 'application/x-www-form-urlencoded', }, }, output: { - postReceive: [ - processCampaignSearchResponse, - ], + postReceive: [processCampaignSearchResponse], }, }, action: 'Get a campaign', @@ -131,9 +128,7 @@ export const campaignFields: INodeProperties[] = [ placeholder: '9998887777', displayOptions: { show: { - resource: [ - 'campaign', - ], + resource: ['campaign'], }, }, default: '', @@ -146,9 +141,7 @@ export const campaignFields: INodeProperties[] = [ placeholder: '6665554444', displayOptions: { show: { - resource: [ - 'campaign', - ], + resource: ['campaign'], }, }, default: '', @@ -160,12 +153,8 @@ export const campaignFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'campaign', - ], + operation: ['get'], + resource: ['campaign'], }, }, default: '', @@ -177,12 +166,8 @@ export const campaignFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'getAll', - ], + resource: ['campaign'], + operation: ['getAll'], }, }, default: {}, @@ -219,7 +204,8 @@ export const campaignFields: INodeProperties[] = [ { name: 'Last Business Week', value: 'LAST_BUSINESS_WEEK', - description: 'The 5 day business week, Monday through Friday, of the previous business week', + description: + 'The 5 day business week, Monday through Friday, of the previous business week', }, { name: 'This Month', @@ -277,24 +263,30 @@ export const campaignFields: INodeProperties[] = [ }, ]; -function processCampaignSearchResponse(this: IExecuteSingleFunctions, _inputData: INodeExecutionData[], responseData: IN8nHttpFullResponse): Promise { +function processCampaignSearchResponse( + this: IExecuteSingleFunctions, + _inputData: INodeExecutionData[], + responseData: IN8nHttpFullResponse, +): Promise { const results = (responseData.body as IDataObject).results as GoogleAdsCampaignElement; - return Promise.resolve(results.map((result) => { - return { - json: { - ...result.campaign, - ...result.metrics, - ...result.campaignBudget, - }, - }; - })); + return Promise.resolve( + results.map((result) => { + return { + json: { + ...result.campaign, + ...result.metrics, + ...result.campaignBudget, + }, + }; + }), + ); } type GoogleAdsCampaignElement = [ { - campaign: object, - metrics: object, - campaignBudget: object, - } + campaign: object; + metrics: object; + campaignBudget: object; + }, ]; diff --git a/packages/nodes-base/nodes/Google/Ads/GoogleAds.node.ts b/packages/nodes-base/nodes/Google/Ads/GoogleAds.node.ts index dab1d6591b..06211ea560 100644 --- a/packages/nodes-base/nodes/Google/Ads/GoogleAds.node.ts +++ b/packages/nodes-base/nodes/Google/Ads/GoogleAds.node.ts @@ -1,12 +1,6 @@ -import { - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - campaignFields, - campaignOperations, -} from './CampaignDescription'; +import { campaignFields, campaignOperations } from './CampaignDescription'; export class GoogleAds implements INodeType { description: INodeTypeDescription = { @@ -61,15 +55,14 @@ export class GoogleAds implements INodeType { //------------------------------- ...campaignOperations, { - displayName: 'Divide field names expressed with micros by 1,000,000 to get the actual value', + displayName: + 'Divide field names expressed with micros by 1,000,000 to get the actual value', name: 'campaigsNotice', type: 'notice', default: '', displayOptions: { show: { - resource: [ - 'campaign', - ], + resource: ['campaign'], }, }, }, diff --git a/packages/nodes-base/nodes/Google/Analytics/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Analytics/GenericFunctions.ts index 875057130c..4bc17573a9 100644 --- a/packages/nodes-base/nodes/Google/Analytics/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Analytics/GenericFunctions.ts @@ -1,22 +1,23 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, - endpoint: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function googleApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { let options: OptionsWithUri = { headers: { - 'Accept': 'application/json', + Accept: 'application/json', 'Content-Type': 'application/json', }, method, @@ -36,14 +37,22 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'googleAnalyticsOAuth2', options); - } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise { // tslint:disable-line:no-any - +export async function googleApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -57,8 +66,7 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp } returnData.push.apply(returnData, responseData[propertyName]); } while ( - (responseData['nextPageToken'] !== undefined && - responseData['nextPageToken'] !== '') || + (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== '') || (responseData[propertyName] && responseData[propertyName][0].nextPageToken && responseData[propertyName][0].nextPageToken !== undefined) @@ -67,9 +75,13 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp return returnData; } -export function simplify(responseData: any | [any]) { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function simplify(responseData: any | [any]) { const response = []; - for (const { columnHeader: { dimensions }, data: { rows } } of responseData) { + for (const { + columnHeader: { dimensions }, + data: { rows }, + } of responseData) { if (rows === undefined) { // Do not error if there is no data continue; @@ -90,13 +102,16 @@ export function simplify(responseData: any | [any]) { // tslint:disable-line:no- return response; } -export function merge(responseData: [any]) { // tslint:disable-line:no-any - const response: { columnHeader: IDataObject, data: { rows: [] } } = { +// tslint:disable-next-line:no-any +export function merge(responseData: [any]) { + const response: { columnHeader: IDataObject; data: { rows: [] } } = { columnHeader: responseData[0].columnHeader, data: responseData[0].data, }; const allRows = []; - for (const { data: { rows } } of responseData) { + for (const { + data: { rows }, + } of responseData) { allRows.push(...rows); } response.data.rows = allRows as []; diff --git a/packages/nodes-base/nodes/Google/Analytics/GoogleAnalytics.node.ts b/packages/nodes-base/nodes/Google/Analytics/GoogleAnalytics.node.ts index a3cc785070..d1ff27806c 100644 --- a/packages/nodes-base/nodes/Google/Analytics/GoogleAnalytics.node.ts +++ b/packages/nodes-base/nodes/Google/Analytics/GoogleAnalytics.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,28 +9,15 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - reportFields, - reportOperations, -} from './ReportDescription'; +import { reportFields, reportOperations } from './ReportDescription'; -import { - userActivityFields, - userActivityOperations, -} from './UserActivityDescription'; +import { userActivityFields, userActivityOperations } from './UserActivityDescription'; -import { - googleApiRequest, - googleApiRequestAllItems, - merge, - simplify, -} from './GenericFunctions'; +import { googleApiRequest, googleApiRequestAllItems, merge, simplify } from './GenericFunctions'; import moment from 'moment-timezone'; -import { - IData, -} from './Interfaces'; +import { IData } from './Interfaces'; export class GoogleAnalytics implements INodeType { description: INodeTypeDescription = { @@ -90,9 +75,7 @@ export class GoogleAnalytics implements INodeType { loadOptions: { // Get all the dimensions to display them to user so that he can // select them easily - async getDimensions( - this: ILoadOptionsFunctions, - ): Promise { + async getDimensions(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const { items: dimensions } = await googleApiRequest.call( this, @@ -104,7 +87,10 @@ export class GoogleAnalytics implements INodeType { ); for (const dimesion of dimensions) { - if (dimesion.attributes.type === 'DIMENSION' && dimesion.attributes.status !== 'DEPRECATED') { + if ( + dimesion.attributes.type === 'DIMENSION' && + dimesion.attributes.status !== 'DEPRECATED' + ) { returnData.push({ name: dimesion.attributes.uiName, value: dimesion.id, @@ -114,10 +100,14 @@ export class GoogleAnalytics implements INodeType { } returnData.sort((a, b) => { - const aName= a.name.toLowerCase(); - const bName= b.name.toLowerCase(); - if (aName < bName) { return -1; } - if (aName > bName) { return 1; } + const aName = a.name.toLowerCase(); + const bName = b.name.toLowerCase(); + if (aName < bName) { + return -1; + } + if (aName > bName) { + return 1; + } return 0; }); @@ -125,9 +115,7 @@ export class GoogleAnalytics implements INodeType { }, // Get all the views to display them to user so that he can // select them easily - async getViews( - this: ILoadOptionsFunctions, - ): Promise { + async getViews(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const { items } = await googleApiRequest.call( this, @@ -151,7 +139,6 @@ export class GoogleAnalytics implements INodeType { }; async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); const returnData: IDataObject[] = []; const resource = this.getNodeParameter('resource', 0) as string; @@ -163,17 +150,14 @@ export class GoogleAnalytics implements INodeType { let responseData; for (let i = 0; i < items.length; i++) { try { - if(resource === 'report') { - if(operation === 'get') { + if (resource === 'report') { + if (operation === 'get') { //https://developers.google.com/analytics/devguides/reporting/core/v4/rest/v4/reports/batchGet method = 'POST'; endpoint = '/v4/reports:batchGet'; const viewId = this.getNodeParameter('viewId', i) as string; const returnAll = this.getNodeParameter('returnAll', 0) as boolean; - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const simple = this.getNodeParameter('simple', i) as boolean; const body: IData = { @@ -184,39 +168,39 @@ export class GoogleAnalytics implements INodeType { qs.useResourceQuotas = additionalFields.useResourceQuotas; } if (additionalFields.dateRangesUi) { - const dateValues = (additionalFields.dateRangesUi as IDataObject).dateRanges as IDataObject; + const dateValues = (additionalFields.dateRangesUi as IDataObject) + .dateRanges as IDataObject; if (dateValues) { const start = dateValues.startDate as string; const end = dateValues.endDate as string; - Object.assign( - body, - { - dateRanges: - [ - { - startDate: moment(start).utc().format('YYYY-MM-DD'), - endDate: moment(end).utc().format('YYYY-MM-DD'), - }, - ], - }, - ); + Object.assign(body, { + dateRanges: [ + { + startDate: moment(start).utc().format('YYYY-MM-DD'), + endDate: moment(end).utc().format('YYYY-MM-DD'), + }, + ], + }); } } if (additionalFields.metricsUi) { - const metrics = (additionalFields.metricsUi as IDataObject).metricValues as IDataObject[]; + const metrics = (additionalFields.metricsUi as IDataObject) + .metricValues as IDataObject[]; body.metrics = metrics; } if (additionalFields.dimensionUi) { - const dimensions = (additionalFields.dimensionUi as IDataObject).dimensionValues as IDataObject[]; + const dimensions = (additionalFields.dimensionUi as IDataObject) + .dimensionValues as IDataObject[]; if (dimensions) { body.dimensions = dimensions; } } if (additionalFields.dimensionFiltersUi) { - const dimensionFilters = (additionalFields.dimensionFiltersUi as IDataObject).filterValues as IDataObject[]; + const dimensionFilters = (additionalFields.dimensionFiltersUi as IDataObject) + .filterValues as IDataObject[]; if (dimensionFilters) { - dimensionFilters.forEach(filter => filter.expressions = [filter.expressions]); + dimensionFilters.forEach((filter) => (filter.expressions = [filter.expressions])); body.dimensionFilterClauses = { filters: dimensionFilters }; } } @@ -232,9 +216,22 @@ export class GoogleAnalytics implements INodeType { } if (returnAll === true) { - responseData = await googleApiRequestAllItems.call(this, 'reports', method, endpoint, { reportRequests: [body] }, qs); + responseData = await googleApiRequestAllItems.call( + this, + 'reports', + method, + endpoint, + { reportRequests: [body] }, + qs, + ); } else { - responseData = await googleApiRequest.call(this, method, endpoint, { reportRequests: [body] }, qs); + responseData = await googleApiRequest.call( + this, + method, + endpoint, + { reportRequests: [body] }, + qs, + ); responseData = responseData.reports; } @@ -253,10 +250,7 @@ export class GoogleAnalytics implements INodeType { const viewId = this.getNodeParameter('viewId', i); const userId = this.getNodeParameter('userId', i); const returnAll = this.getNodeParameter('returnAll', 0) as boolean; - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body: IDataObject = { viewId, user: { @@ -268,7 +262,13 @@ export class GoogleAnalytics implements INodeType { } if (returnAll) { - responseData = await googleApiRequestAllItems.call(this, 'sessions', method, endpoint, body); + responseData = await googleApiRequestAllItems.call( + this, + 'sessions', + method, + endpoint, + body, + ); } else { body.pageSize = this.getNodeParameter('limit', 0) as number; responseData = await googleApiRequest.call(this, method, endpoint, body); diff --git a/packages/nodes-base/nodes/Google/Analytics/ReportDescription.ts b/packages/nodes-base/nodes/Google/Analytics/ReportDescription.ts index 9d2ed76b9f..fffb594abc 100644 --- a/packages/nodes-base/nodes/Google/Analytics/ReportDescription.ts +++ b/packages/nodes-base/nodes/Google/Analytics/ReportDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const reportOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const reportOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'report', - ], + resource: ['report'], }, }, options: [ @@ -39,16 +35,13 @@ export const reportFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'get', - ], + resource: ['report'], + operation: ['get'], }, }, placeholder: '123456', - description: 'The View ID of Google Analytics. Choose from the list, or specify an ID using an expression.', + description: + 'The View ID of Google Analytics. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -56,12 +49,8 @@ export const reportFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'report', - ], + operation: ['get'], + resource: ['report'], }, }, default: false, @@ -73,15 +62,9 @@ export const reportFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'report', - ], - returnAll: [ - false, - ], + operation: ['get'], + resource: ['report'], + returnAll: [false], }, }, typeOptions: { @@ -97,12 +80,8 @@ export const reportFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'report', - ], + operation: ['get'], + resource: ['report'], }, }, default: true, @@ -116,12 +95,8 @@ export const reportFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'get', - ], + resource: ['report'], + operation: ['get'], }, }, options: [ @@ -162,7 +137,8 @@ export const reportFields: INodeProperties[] = [ multipleValues: true, }, placeholder: 'Add Dimension', - description: 'Dimensions are attributes of your data. For example, the dimension ga:city indicates the city, for example, "Paris" or "New York", from which a session originates.', + description: + 'Dimensions are attributes of your data. For example, the dimension ga:city indicates the city, for example, "Paris" or "New York", from which a session originates.', options: [ { displayName: 'Dimension', @@ -176,7 +152,8 @@ export const reportFields: INodeProperties[] = [ loadOptionsMethod: 'getDimensions', }, default: '', - description: 'Name of the dimension to fetch, for example ga:browser. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the dimension to fetch, for example ga:browser. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -205,7 +182,8 @@ export const reportFields: INodeProperties[] = [ loadOptionsMethod: 'getDimensions', }, default: '', - description: 'Name of the dimension to filter by. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the dimension to filter by. Choose from the list, or specify an ID using an expression.', }, // https://developers.google.com/analytics/devguides/reporting/core/v4/rest/v4/reports/batchGet#Operator { @@ -255,7 +233,8 @@ export const reportFields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'ga:newUsers', - description: 'String or regular expression to match against', + description: + 'String or regular expression to match against', }, ], }, @@ -266,7 +245,8 @@ export const reportFields: INodeProperties[] = [ name: 'hideTotals', type: 'boolean', default: false, - description: 'Whether to hide the total of all metrics for all the matching rows, for every date range', + description: + 'Whether to hide the total of all metrics for all the matching rows, for every date range', }, { displayName: 'Hide Value Ranges', @@ -280,7 +260,8 @@ export const reportFields: INodeProperties[] = [ name: 'includeEmptyRows', type: 'boolean', default: false, - description: 'Whether the response exclude rows if all the retrieved metrics are equal to zero', + description: + 'Whether the response exclude rows if all the retrieved metrics are equal to zero', }, { displayName: 'Metrics', @@ -302,14 +283,16 @@ export const reportFields: INodeProperties[] = [ name: 'alias', type: 'string', default: '', - description: 'An alias for the metric expression is an alternate name for the expression. The alias can be used for filtering and sorting.', + description: + 'An alias for the metric expression is an alternate name for the expression. The alias can be used for filtering and sorting.', }, { displayName: 'Expression', name: 'expression', type: 'string', default: 'ga:newUsers', - description: '

A metric expression in the request. An expression is constructed from one or more metrics and numbers.

Accepted operators include: Plus (+), Minus (-), Negation (Unary -), Divided by (/), Multiplied by (*), Parenthesis, Positive cardinal numbers (0-9), can include decimals and is limited to 1024 characters.

Example ga:totalRefunds/ga:users, in most cases the metric expression is just a single metric name like ga:users.

Adding mixed MetricType (E.g., CURRENCY + PERCENTAGE) metrics will result in unexpected results.

.', + description: + '

A metric expression in the request. An expression is constructed from one or more metrics and numbers.

Accepted operators include: Plus (+), Minus (-), Negation (Unary -), Divided by (/), Multiplied by (*), Parenthesis, Positive cardinal numbers (0-9), can include decimals and is limited to 1024 characters.

Example ga:totalRefunds/ga:users, in most cases the metric expression is just a single metric name like ga:users.

Adding mixed MetricType (E.g., CURRENCY + PERCENTAGE) metrics will result in unexpected results.

.', }, { displayName: 'Formatting Type', diff --git a/packages/nodes-base/nodes/Google/Analytics/UserActivityDescription.ts b/packages/nodes-base/nodes/Google/Analytics/UserActivityDescription.ts index c9b3e6b796..40bf36ca54 100644 --- a/packages/nodes-base/nodes/Google/Analytics/UserActivityDescription.ts +++ b/packages/nodes-base/nodes/Google/Analytics/UserActivityDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userActivityOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userActivityOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'userActivity', - ], + resource: ['userActivity'], }, }, options: [ @@ -39,16 +35,13 @@ export const userActivityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'userActivity', - ], - operation: [ - 'search', - ], + resource: ['userActivity'], + operation: ['search'], }, }, placeholder: '123456', - description: 'The View ID of Google Analytics. Choose from the list, or specify an ID using an expression.', + description: + 'The View ID of Google Analytics. Choose from the list, or specify an ID using an expression.', }, { displayName: 'User ID', @@ -58,12 +51,8 @@ export const userActivityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'userActivity', - ], - operation: [ - 'search', - ], + resource: ['userActivity'], + operation: ['search'], }, }, placeholder: '123456', @@ -75,12 +64,8 @@ export const userActivityFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'userActivity', - ], + operation: ['search'], + resource: ['userActivity'], }, }, default: false, @@ -92,15 +77,9 @@ export const userActivityFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'userActivity', - ], - returnAll: [ - false, - ], + operation: ['search'], + resource: ['userActivity'], + returnAll: [false], }, }, typeOptions: { @@ -118,12 +97,8 @@ export const userActivityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'userActivity', - ], + operation: ['search'], + resource: ['userActivity'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts b/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts index 4761f74a07..5e0683bee7 100644 --- a/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts @@ -1,26 +1,29 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - JsonObject, - NodeApiError, - NodeOperationError -} from 'n8n-workflow'; +import { IDataObject, JsonObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; import moment from 'moment-timezone'; import * as jwt from 'jsonwebtoken'; -export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any - const authenticationMethod = this.getNodeParameter('authentication', 0, 'serviceAccount') as string; +export async function googleApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { + const authenticationMethod = this.getNodeParameter( + 'authentication', + 0, + 'serviceAccount', + ) as string; const options: OptionsWithUri = { headers: { @@ -64,8 +67,16 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function googleApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -75,41 +86,39 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData['pageToken']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['pageToken'] !== undefined && - responseData['pageToken'] !== '' - ); + } while (responseData['pageToken'] !== undefined && responseData['pageToken'] !== ''); return returnData; } -function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, credentials: IDataObject): Promise { +function getAccessToken( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + credentials: IDataObject, +): Promise { //https://developers.google.com/identity/protocols/oauth2/service-account#httprest const privateKey = (credentials.privateKey as string).replace(/\\n/g, '\n').trim(); - const scopes = [ - 'https://www.googleapis.com/auth/bigquery', - ]; + const scopes = ['https://www.googleapis.com/auth/bigquery']; const now = moment().unix(); const signature = jwt.sign( { - 'iss': credentials.email as string, - 'sub': credentials.delegatedEmail || credentials.email as string, - 'scope': scopes.join(' '), - 'aud': `https://oauth2.googleapis.com/token`, - 'iat': now, - 'exp': now + 3600, + iss: credentials.email as string, + sub: credentials.delegatedEmail || (credentials.email as string), + scope: scopes.join(' '), + aud: `https://oauth2.googleapis.com/token`, + iat: now, + exp: now + 3600, }, privateKey, { algorithm: 'RS256', header: { - 'kid': privateKey, - 'typ': 'JWT', - 'alg': 'RS256', + kid: privateKey, + typ: 'JWT', + alg: 'RS256', }, }, ); diff --git a/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts b/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts index 58034e0dc7..002e2f286e 100644 --- a/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts +++ b/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,16 +10,9 @@ import { NodeApiError, } from 'n8n-workflow'; -import { - googleApiRequest, - googleApiRequestAllItems, - simplify, -} from './GenericFunctions'; +import { googleApiRequest, googleApiRequestAllItems, simplify } from './GenericFunctions'; -import { - recordFields, - recordOperations, -} from './RecordDescription'; +import { recordFields, recordOperations } from './RecordDescription'; import { v4 as uuid } from 'uuid'; @@ -45,9 +36,7 @@ export class GoogleBigQuery implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'serviceAccount', - ], + authentication: ['serviceAccount'], }, }, }, @@ -56,9 +45,7 @@ export class GoogleBigQuery implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -101,15 +88,9 @@ export class GoogleBigQuery implements INodeType { methods = { loadOptions: { - async getProjects( - this: ILoadOptionsFunctions, - ): Promise { + async getProjects(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { projects } = await googleApiRequest.call( - this, - 'GET', - '/v2/projects', - ); + const { projects } = await googleApiRequest.call(this, 'GET', '/v2/projects'); for (const project of projects) { returnData.push({ name: project.friendlyName as string, @@ -118,9 +99,7 @@ export class GoogleBigQuery implements INodeType { } return returnData; }, - async getDatasets( - this: ILoadOptionsFunctions, - ): Promise { + async getDatasets(this: ILoadOptionsFunctions): Promise { const projectId = this.getCurrentNodeParameter('projectId'); const returnData: INodePropertyOptions[] = []; const { datasets } = await googleApiRequest.call( @@ -136,9 +115,7 @@ export class GoogleBigQuery implements INodeType { } return returnData; }, - async getTables( - this: ILoadOptionsFunctions, - ): Promise { + async getTables(this: ILoadOptionsFunctions): Promise { const projectId = this.getCurrentNodeParameter('projectId'); const datasetId = this.getCurrentNodeParameter('datasetId'); const returnData: INodePropertyOptions[] = []; @@ -168,13 +145,11 @@ export class GoogleBigQuery implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; if (resource === 'record') { - // ********************************************************************* // record // ********************************************************************* if (operation === 'create') { - // ---------------------------------- // record: create // ---------------------------------- @@ -188,14 +163,13 @@ export class GoogleBigQuery implements INodeType { const body: IDataObject = {}; for (let i = 0; i < length; i++) { - const options = this.getNodeParameter('options', i) as IDataObject; Object.assign(body, options); if (body.traceId === undefined) { body.traceId = uuid(); } const columns = this.getNodeParameter('columns', i) as string; - const columnList = columns.split(',').map(column => column.trim()); + const columnList = columns.split(',').map((column) => column.trim()); const record: IDataObject = {}; for (const key of Object.keys(items[i].json)) { @@ -224,7 +198,6 @@ export class GoogleBigQuery implements INodeType { } } } else if (operation === 'getAll') { - // ---------------------------------- // record: getAll // ---------------------------------- @@ -273,7 +246,10 @@ export class GoogleBigQuery implements INodeType { {}, qs, ); - returnData.push.apply(returnData, (simple) ? simplify(responseData, fields) : responseData); + returnData.push.apply( + returnData, + simple ? simplify(responseData, fields) : responseData, + ); } else { qs.maxResults = this.getNodeParameter('limit', i) as number; responseData = await googleApiRequest.call( @@ -283,7 +259,10 @@ export class GoogleBigQuery implements INodeType { {}, qs, ); - returnData.push.apply(returnData, (simple) ? simplify(responseData.rows, fields) : responseData.rows); + returnData.push.apply( + returnData, + simple ? simplify(responseData.rows, fields) : responseData.rows, + ); } } catch (error) { if (this.continueOnFail()) { diff --git a/packages/nodes-base/nodes/Google/BigQuery/RecordDescription.ts b/packages/nodes-base/nodes/Google/BigQuery/RecordDescription.ts index 1c37221722..1059cfb111 100644 --- a/packages/nodes-base/nodes/Google/BigQuery/RecordDescription.ts +++ b/packages/nodes-base/nodes/Google/BigQuery/RecordDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const recordOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const recordOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'record', - ], + resource: ['record'], }, }, options: [ @@ -47,16 +43,13 @@ export const recordFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'record', - ], + operation: ['create'], + resource: ['record'], }, }, default: '', - description: 'ID of the project to create the record in. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the project to create the record in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Dataset Name or ID', @@ -64,23 +57,18 @@ export const recordFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getDatasets', - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], }, required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'record', - ], + operation: ['create'], + resource: ['record'], }, }, default: '', - description: 'ID of the dataset to create the record in. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the dataset to create the record in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Table Name or ID', @@ -88,24 +76,18 @@ export const recordFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getTables', - loadOptionsDependsOn: [ - 'projectId', - 'datasetId', - ], + loadOptionsDependsOn: ['projectId', 'datasetId'], }, required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'record', - ], + operation: ['create'], + resource: ['record'], }, }, default: '', - description: 'ID of the table to create the record in. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the table to create the record in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Columns', @@ -113,12 +95,8 @@ export const recordFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'create', - ], + resource: ['record'], + operation: ['create'], }, }, default: '', @@ -134,12 +112,8 @@ export const recordFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'record', - ], + operation: ['create'], + resource: ['record'], }, }, options: [ @@ -162,14 +136,16 @@ export const recordFields: INodeProperties[] = [ name: 'templateSuffix', type: 'string', default: '', - description: 'Create a new table based on the destination table and insert rows into the new table. The new table will be named {destinationTable}{templateSuffix}', + description: + 'Create a new table based on the destination table and insert rows into the new table. The new table will be named {destinationTable}{templateSuffix}', }, { displayName: 'Trace ID', name: 'traceId', type: 'string', default: '', - description: 'Unique ID for the request, for debugging only. It is case-sensitive, limited to up to 36 ASCII characters. A UUID is recommended.', + description: + 'Unique ID for the request, for debugging only. It is case-sensitive, limited to up to 36 ASCII characters. A UUID is recommended.', }, ], }, @@ -187,16 +163,13 @@ export const recordFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'record', - ], + operation: ['getAll'], + resource: ['record'], }, }, default: '', - description: 'ID of the project to retrieve all rows from. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the project to retrieve all rows from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Dataset Name or ID', @@ -204,23 +177,18 @@ export const recordFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getDatasets', - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], }, required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'record', - ], + operation: ['getAll'], + resource: ['record'], }, }, default: '', - description: 'ID of the dataset to retrieve all rows from. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the dataset to retrieve all rows from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Table Name or ID', @@ -228,24 +196,18 @@ export const recordFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getTables', - loadOptionsDependsOn: [ - 'projectId', - 'datasetId', - ], + loadOptionsDependsOn: ['projectId', 'datasetId'], }, required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'record', - ], + operation: ['getAll'], + resource: ['record'], }, }, default: '', - description: 'ID of the table to retrieve all rows from. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the table to retrieve all rows from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -253,12 +215,8 @@ export const recordFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'record', - ], + operation: ['getAll'], + resource: ['record'], }, }, default: false, @@ -270,15 +228,9 @@ export const recordFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'record', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['record'], + returnAll: [false], }, }, typeOptions: { @@ -294,12 +246,8 @@ export const recordFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'getAll', - ], + resource: ['record'], + operation: ['getAll'], }, }, default: true, @@ -313,12 +261,8 @@ export const recordFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'record', - ], + operation: ['getAll'], + resource: ['record'], }, }, options: [ @@ -327,7 +271,8 @@ export const recordFields: INodeProperties[] = [ name: 'selectedFields', type: 'string', default: '', - description: 'Subset of fields to return, supports select into sub fields. Example: selectedFields = "a,e.d.f"', + description: + 'Subset of fields to return, supports select into sub fields. Example: selectedFields = "a,e.d.f"', }, // { // displayName: 'Use Int64 Timestamp', diff --git a/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts index fa6335afbb..760f2a7d9b 100644 --- a/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts @@ -1,16 +1,8 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; import moment from 'moment-timezone'; @@ -23,8 +15,22 @@ interface IGoogleAuthCredentials { privateKey: string; } -export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any - const authenticationMethod = this.getNodeParameter('authentication', 0, 'serviceAccount') as string; +export async function googleApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { + const authenticationMethod = this.getNodeParameter( + 'authentication', + 0, + 'serviceAccount', + ) as string; const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -44,12 +50,15 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } if (authenticationMethod === 'serviceAccount') { - const credentials = await this.getCredentials('googleApi') as { + const credentials = (await this.getCredentials('googleApi')) as { email: string; privateKey: string; }; - const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials); + const { access_token } = await getAccessToken.call( + this, + credentials as unknown as IGoogleAuthCredentials, + ); options.headers!.Authorization = `Bearer ${access_token}`; //@ts-ignore @@ -67,8 +76,16 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function googleApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -77,19 +94,18 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); returnData.push.apply(returnData, responseData[propertyName] || []); - } while ( - returnData.length < responseData.totalItems - ); + } while (returnData.length < responseData.totalItems); return returnData; } -function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, credentials: IGoogleAuthCredentials): Promise { +function getAccessToken( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + credentials: IGoogleAuthCredentials, +): Promise { //https://developers.google.com/identity/protocols/oauth2/service-account#httprest - const scopes = [ - 'https://www.googleapis.com/auth/books', - ]; + const scopes = ['https://www.googleapis.com/auth/books']; const now = moment().unix(); @@ -98,20 +114,20 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa const signature = jwt.sign( { - 'iss': credentials.email as string, - 'sub': credentials.delegatedEmail || credentials.email as string, - 'scope': scopes.join(' '), - 'aud': `https://oauth2.googleapis.com/token`, - 'iat': now, - 'exp': now + 3600, + iss: credentials.email as string, + sub: credentials.delegatedEmail || (credentials.email as string), + scope: scopes.join(' '), + aud: `https://oauth2.googleapis.com/token`, + iat: now, + exp: now + 3600, }, privateKey as string, { algorithm: 'RS256', header: { - 'kid': privateKey as string, - 'typ': 'JWT', - 'alg': 'RS256', + kid: privateKey as string, + typ: 'JWT', + alg: 'RS256', }, }, ); diff --git a/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts b/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts index 01b8f5ac3a..607fa99f45 100644 --- a/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts +++ b/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts @@ -1,19 +1,8 @@ +import { IExecuteFunctions } from 'n8n-core'; -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; - -import { - googleApiRequest, - googleApiRequestAllItems, -} from './GenericFunctions'; +import { googleApiRequest, googleApiRequestAllItems } from './GenericFunctions'; export interface IGoogleAuthCredentials { email: string; @@ -40,9 +29,7 @@ export class GoogleBooks implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'serviceAccount', - ], + authentication: ['serviceAccount'], }, }, }, @@ -51,9 +38,7 @@ export class GoogleBooks implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -76,9 +61,7 @@ export class GoogleBooks implements INodeType { default: 'serviceAccount', displayOptions: { show: { - '@version': [ - 1, - ], + '@version': [1], }, }, }, @@ -99,9 +82,7 @@ export class GoogleBooks implements INodeType { default: 'oAuth2', displayOptions: { show: { - '@version': [ - 2, - ], + '@version': [2], }, }, }, @@ -147,9 +128,7 @@ export class GoogleBooks implements INodeType { ], displayOptions: { show: { - resource: [ - 'bookshelf', - ], + resource: ['bookshelf'], }, }, default: 'get', @@ -193,9 +172,7 @@ export class GoogleBooks implements INodeType { ], displayOptions: { show: { - resource: [ - 'bookshelfVolume', - ], + resource: ['bookshelfVolume'], }, }, default: 'getAll', @@ -221,9 +198,7 @@ export class GoogleBooks implements INodeType { ], displayOptions: { show: { - resource: [ - 'volume', - ], + resource: ['volume'], }, }, default: 'get', @@ -236,14 +211,8 @@ export class GoogleBooks implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'get', - 'getAll', - ], - resource: [ - 'bookshelf', - 'bookshelfVolume', - ], + operation: ['get', 'getAll'], + resource: ['bookshelf', 'bookshelfVolume'], }, }, }, @@ -260,12 +229,8 @@ export class GoogleBooks implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'volume', - ], + operation: ['getAll'], + resource: ['volume'], }, }, }, @@ -278,19 +243,11 @@ export class GoogleBooks implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'get', - 'getAll', - ], - resource: [ - 'bookshelf', - 'bookshelfVolume', - ], + operation: ['get', 'getAll'], + resource: ['bookshelf', 'bookshelfVolume'], }, hide: { - myLibrary: [ - true, - ], + myLibrary: [true], }, }, }, @@ -303,17 +260,8 @@ export class GoogleBooks implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'get', - 'add', - 'clear', - 'move', - 'remove', - ], - resource: [ - 'bookshelf', - 'bookshelfVolume', - ], + operation: ['get', 'add', 'clear', 'move', 'remove'], + resource: ['bookshelf', 'bookshelfVolume'], }, }, }, @@ -326,12 +274,8 @@ export class GoogleBooks implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'bookshelfVolume', - ], + operation: ['getAll'], + resource: ['bookshelfVolume'], }, }, }, @@ -344,16 +288,8 @@ export class GoogleBooks implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'add', - 'move', - 'remove', - 'get', - ], - resource: [ - 'bookshelfVolume', - 'volume', - ], + operation: ['add', 'move', 'remove', 'get'], + resource: ['bookshelfVolume', 'volume'], }, }, }, @@ -361,17 +297,14 @@ export class GoogleBooks implements INodeType { displayName: 'Volume Position', name: 'volumePosition', type: 'string', - description: 'Position on shelf to move the item (0 puts the item before the current first item, 1 puts it between the first and the second and so on)', + description: + 'Position on shelf to move the item (0 puts the item before the current first item, 1 puts it between the first and the second and so on)', default: '', required: true, displayOptions: { show: { - operation: [ - 'move', - ], - resource: [ - 'bookshelfVolume', - ], + operation: ['move'], + resource: ['bookshelfVolume'], }, }, }, @@ -381,9 +314,7 @@ export class GoogleBooks implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: false, @@ -395,12 +326,8 @@ export class GoogleBooks implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -424,7 +351,6 @@ export class GoogleBooks implements INodeType { for (let i = 0; i < length; i++) { try { - if (resource === 'volume') { if (operation === 'get') { const volumeId = this.getNodeParameter('volumeId', i) as string; @@ -433,10 +359,22 @@ export class GoogleBooks implements INodeType { const searchQuery = this.getNodeParameter('searchQuery', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll) { - responseData = await googleApiRequestAllItems.call(this, 'items', 'GET', `v1/volumes?q=${searchQuery}`, {}); + responseData = await googleApiRequestAllItems.call( + this, + 'items', + 'GET', + `v1/volumes?q=${searchQuery}`, + {}, + ); } else { qs.maxResults = this.getNodeParameter('limit', i) as number; - responseData = await googleApiRequest.call(this, 'GET', `v1/volumes?q=${searchQuery}`, {}, qs); + responseData = await googleApiRequest.call( + this, + 'GET', + `v1/volumes?q=${searchQuery}`, + {}, + qs, + ); responseData = responseData.items || []; } } @@ -466,7 +404,13 @@ export class GoogleBooks implements INodeType { endpoint = `v1/mylibrary/bookshelves`; } if (returnAll) { - responseData = await googleApiRequestAllItems.call(this, 'items', 'GET', endpoint, {}); + responseData = await googleApiRequestAllItems.call( + this, + 'items', + 'GET', + endpoint, + {}, + ); } else { qs.maxResults = this.getNodeParameter('limit', i) as number; responseData = await googleApiRequest.call(this, 'GET', endpoint, {}, qs); @@ -482,12 +426,21 @@ export class GoogleBooks implements INodeType { const body: IDataObject = { volumeId, }; - responseData = await googleApiRequest.call(this, 'POST', `v1/mylibrary/bookshelves/${shelfId}/addVolume`, body); + responseData = await googleApiRequest.call( + this, + 'POST', + `v1/mylibrary/bookshelves/${shelfId}/addVolume`, + body, + ); } if (operation === 'clear') { const shelfId = this.getNodeParameter('shelfId', i) as string; - responseData = await googleApiRequest.call(this, 'POST', `v1/mylibrary/bookshelves/${shelfId}/clearVolumes`); + responseData = await googleApiRequest.call( + this, + 'POST', + `v1/mylibrary/bookshelves/${shelfId}/clearVolumes`, + ); } if (operation === 'getAll') { @@ -502,7 +455,13 @@ export class GoogleBooks implements INodeType { endpoint = `v1/mylibrary/bookshelves/${shelfId}/volumes`; } if (returnAll) { - responseData = await googleApiRequestAllItems.call(this, 'items', 'GET', endpoint, {}); + responseData = await googleApiRequestAllItems.call( + this, + 'items', + 'GET', + endpoint, + {}, + ); } else { qs.maxResults = this.getNodeParameter('limit', i) as number; responseData = await googleApiRequest.call(this, 'GET', endpoint, {}, qs); @@ -518,7 +477,12 @@ export class GoogleBooks implements INodeType { volumeId, volumePosition, }; - responseData = await googleApiRequest.call(this, 'POST', `v1/mylibrary/bookshelves/${shelfId}/moveVolume`, body); + responseData = await googleApiRequest.call( + this, + 'POST', + `v1/mylibrary/bookshelves/${shelfId}/moveVolume`, + body, + ); } if (operation === 'remove') { @@ -527,7 +491,12 @@ export class GoogleBooks implements INodeType { const body: IDataObject = { volumeId, }; - responseData = await googleApiRequest.call(this, 'POST', `v1/mylibrary/bookshelves/${shelfId}/removeVolume`, body); + responseData = await googleApiRequest.call( + this, + 'POST', + `v1/mylibrary/bookshelves/${shelfId}/removeVolume`, + body, + ); } } if (Array.isArray(responseData)) { @@ -535,7 +504,6 @@ export class GoogleBooks implements INodeType { } else { returnData.push(responseData as IDataObject); } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/Google/Calendar/CalendarDescription.ts b/packages/nodes-base/nodes/Google/Calendar/CalendarDescription.ts index 7964c60c45..d5940a2820 100644 --- a/packages/nodes-base/nodes/Google/Calendar/CalendarDescription.ts +++ b/packages/nodes-base/nodes/Google/Calendar/CalendarDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const calendarOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const calendarOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'calendar', - ], + resource: ['calendar'], }, }, options: [ @@ -35,16 +31,15 @@ export const calendarFields: INodeProperties[] = [ displayName: 'Calendar Name or ID', name: 'calendar', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCalendars', }, required: true, displayOptions: { show: { - resource: [ - 'calendar', - ], + resource: ['calendar'], }, }, default: '', @@ -56,12 +51,8 @@ export const calendarFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'availability', - ], - resource: [ - 'calendar', - ], + operation: ['availability'], + resource: ['calendar'], }, }, default: '', @@ -74,12 +65,8 @@ export const calendarFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'availability', - ], - resource: [ - 'calendar', - ], + operation: ['availability'], + resource: ['calendar'], }, }, default: '', @@ -92,12 +79,8 @@ export const calendarFields: INodeProperties[] = [ placeholder: 'Add Options', displayOptions: { show: { - operation: [ - 'availability', - ], - resource: [ - 'calendar', - ], + operation: ['availability'], + resource: ['calendar'], }, }, default: {}, @@ -134,7 +117,8 @@ export const calendarFields: INodeProperties[] = [ loadOptionsMethod: 'getTimezones', }, default: '', - description: 'Time zone used in the response. By default n8n timezone is used. Choose from the list, or specify an ID using an expression.', + description: + 'Time zone used in the response. By default n8n timezone is used. Choose from the list, or specify an ID using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/Google/Calendar/EventDescription.ts b/packages/nodes-base/nodes/Google/Calendar/EventDescription.ts index 4b62855f99..644760f4ce 100644 --- a/packages/nodes-base/nodes/Google/Calendar/EventDescription.ts +++ b/packages/nodes-base/nodes/Google/Calendar/EventDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const eventOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const eventOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'event', - ], + resource: ['event'], }, }, options: [ @@ -59,16 +55,15 @@ export const eventFields: INodeProperties[] = [ displayName: 'Calendar Name or ID', name: 'calendar', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCalendars', }, required: true, displayOptions: { show: { - resource: [ - 'event', - ], + resource: ['event'], }, }, default: '', @@ -84,12 +79,8 @@ export const eventFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'event', - ], + operation: ['create'], + resource: ['event'], }, }, default: '', @@ -102,12 +93,8 @@ export const eventFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'event', - ], + operation: ['create'], + resource: ['event'], }, }, default: '', @@ -119,12 +106,8 @@ export const eventFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'event', - ], + operation: ['create'], + resource: ['event'], }, }, default: true, @@ -137,12 +120,8 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'event', - ], + operation: ['create'], + resource: ['event'], }, }, options: [ @@ -182,7 +161,8 @@ export const eventFields: INodeProperties[] = [ loadOptionsMethod: 'getColors', }, default: '', - description: 'The color of the event. Choose from the list, or specify an ID using an expression.', + description: + 'The color of the event. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Conference Data', @@ -202,12 +182,11 @@ export const eventFields: INodeProperties[] = [ displayName: 'Type Name or ID', name: 'conferenceSolution', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getConferenceSolutations', - loadOptionsDependsOn: [ - 'calendar', - ], + loadOptionsDependsOn: ['calendar'], }, default: '', }, @@ -244,7 +223,8 @@ export const eventFields: INodeProperties[] = [ name: 'guestsCanSeeOtherGuests', type: 'boolean', default: true, - description: 'Whether attendees other than the organizer can see who the event\'s attendees are', + description: + "Whether attendees other than the organizer can see who the event's attendees are", }, { displayName: 'ID', @@ -265,7 +245,8 @@ export const eventFields: INodeProperties[] = [ name: 'maxAttendees', type: 'number', default: 0, - description: 'The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned.', + description: + 'The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned.', }, { displayName: 'Repeat Frequency', @@ -311,7 +292,8 @@ export const eventFields: INodeProperties[] = [ name: 'rrule', type: 'string', default: '', - description: 'Recurrence rule. When set, the parameters Repeat Frequency, Repeat How Many Times and Repeat Until are ignored.', + description: + 'Recurrence rule. When set, the parameters Repeat Frequency, Repeat How Many Times and Repeat Until are ignored.', }, { displayName: 'Send Updates', @@ -331,7 +313,8 @@ export const eventFields: INodeProperties[] = [ { name: 'None', value: 'none', - description: 'No notifications are sent. This value should only be used for migration use case.', + description: + 'No notifications are sent. This value should only be used for migration use case.', }, ], description: 'Whether to send notifications about the creation of the new event', @@ -386,7 +369,8 @@ export const eventFields: INodeProperties[] = [ { name: 'Public', value: 'public', - description: 'The event is public and event details are visible to all readers of the calendar', + description: + 'The event is public and event details are visible to all readers of the calendar', }, ], default: 'default', @@ -405,15 +389,9 @@ export const eventFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'create', - ], - useDefaultReminders: [ - false, - ], + resource: ['event'], + operation: ['create'], + useDefaultReminders: [false], }, }, options: [ @@ -450,7 +428,8 @@ export const eventFields: INodeProperties[] = [ ], }, ], - description: 'If the event doesn\'t use the default reminders, this lists the reminders specific to the event', + description: + "If the event doesn't use the default reminders, this lists the reminders specific to the event", }, /* -------------------------------------------------------------------------- */ @@ -463,12 +442,8 @@ export const eventFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'event', - ], + operation: ['delete'], + resource: ['event'], }, }, default: '', @@ -481,12 +456,8 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'event', - ], + operation: ['delete'], + resource: ['event'], }, }, options: [ @@ -508,7 +479,8 @@ export const eventFields: INodeProperties[] = [ { name: 'None', value: 'none', - description: 'No notifications are sent. This value should only be used for migration use case.', + description: + 'No notifications are sent. This value should only be used for migration use case.', }, ], description: 'Whether to send notifications about the creation of the new event', @@ -526,12 +498,8 @@ export const eventFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'event', - ], + operation: ['get'], + resource: ['event'], }, }, default: '', @@ -544,12 +512,8 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'event', - ], + operation: ['get'], + resource: ['event'], }, }, options: [ @@ -558,7 +522,8 @@ export const eventFields: INodeProperties[] = [ name: 'maxAttendees', type: 'number', default: 0, - description: 'The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned.', + description: + 'The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned.', }, { displayName: 'Timezone Name or ID', @@ -568,7 +533,8 @@ export const eventFields: INodeProperties[] = [ loadOptionsMethod: 'getTimezones', }, default: '', - description: 'Time zone used in the response. The default is the time zone of the calendar. Choose from the list, or specify an ID using an expression.', + description: + 'Time zone used in the response. The default is the time zone of the calendar. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -582,12 +548,8 @@ export const eventFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'event', - ], + operation: ['getAll'], + resource: ['event'], }, }, default: false, @@ -599,15 +561,9 @@ export const eventFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'event', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['event'], + returnAll: [false], }, }, typeOptions: { @@ -625,12 +581,8 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'event', - ], + operation: ['getAll'], + resource: ['event'], }, }, options: [ @@ -646,7 +598,8 @@ export const eventFields: INodeProperties[] = [ name: 'maxAttendees', type: 'number', default: 0, - description: 'The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned.', + description: + 'The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned.', }, { displayName: 'Order By', @@ -656,7 +609,8 @@ export const eventFields: INodeProperties[] = [ { name: 'Start Time', value: 'startTime', - description: 'Order by the start date/time (ascending). This is only available when querying single events (i.e. the parameter singleEvents is True).', + description: + 'Order by the start date/time (ascending). This is only available when querying single events (i.e. the parameter singleEvents is True).', }, { name: 'Updated', @@ -672,14 +626,16 @@ export const eventFields: INodeProperties[] = [ name: 'query', type: 'string', default: '', - description: 'Free text search terms to find events that match these terms in any field, except for extended properties', + description: + 'Free text search terms to find events that match these terms in any field, except for extended properties', }, { displayName: 'Show Deleted', name: 'showDeleted', type: 'boolean', default: false, - description: 'Whether to include deleted events (with status equals "cancelled") in the result', + description: + 'Whether to include deleted events (with status equals "cancelled") in the result', }, { displayName: 'Show Hidden Invitations', @@ -693,21 +649,22 @@ export const eventFields: INodeProperties[] = [ name: 'singleEvents', type: 'boolean', default: false, - description: 'Whether to expand recurring events into instances and only return single one-off events and instances of recurring events, but not the underlying recurring events themselves', + description: + 'Whether to expand recurring events into instances and only return single one-off events and instances of recurring events, but not the underlying recurring events themselves', }, { displayName: 'Start Time', name: 'timeMax', type: 'dateTime', default: '', - description: 'Upper bound (exclusive) for an event\'s start time to filter by', + description: "Upper bound (exclusive) for an event's start time to filter by", }, { displayName: 'End Time', name: 'timeMin', type: 'dateTime', default: '', - description: 'Lower bound (exclusive) for an event\'s end time to filter by', + description: "Lower bound (exclusive) for an event's end time to filter by", }, { displayName: 'Timezone Name or ID', @@ -717,14 +674,16 @@ export const eventFields: INodeProperties[] = [ loadOptionsMethod: 'getTimezones', }, default: '', - description: 'Time zone used in the response. The default is the time zone of the calendar. Choose from the list, or specify an ID using an expression.', + description: + 'Time zone used in the response. The default is the time zone of the calendar. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Updated Min', name: 'updatedMin', type: 'dateTime', default: '', - description: 'Lower bound for an event\'s last modification time (as a RFC3339 timestamp) to filter by. When specified, entries deleted since this time will always be included regardless of showDeleted.', + description: + "Lower bound for an event's last modification time (as a RFC3339 timestamp) to filter by. When specified, entries deleted since this time will always be included regardless of showDeleted.", }, ], }, @@ -739,12 +698,8 @@ export const eventFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'event', - ], + operation: ['update'], + resource: ['event'], }, }, default: '', @@ -755,12 +710,8 @@ export const eventFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'event', - ], + operation: ['update'], + resource: ['event'], }, }, default: true, @@ -773,12 +724,8 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'event', - ], + operation: ['update'], + resource: ['event'], }, }, options: [ @@ -818,7 +765,8 @@ export const eventFields: INodeProperties[] = [ loadOptionsMethod: 'getColors', }, default: '', - description: 'The color of the event. Choose from the list, or specify an ID using an expression.', + description: + 'The color of the event. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Description', @@ -855,7 +803,8 @@ export const eventFields: INodeProperties[] = [ name: 'guestsCanSeeOtherGuests', type: 'boolean', default: true, - description: 'Whether attendees other than the organizer can see who the event\'s attendees are', + description: + "Whether attendees other than the organizer can see who the event's attendees are", }, { displayName: 'ID', @@ -876,7 +825,8 @@ export const eventFields: INodeProperties[] = [ name: 'maxAttendees', type: 'number', default: 0, - description: 'The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned.', + description: + 'The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned.', }, { displayName: 'Repeat Frequency', @@ -922,7 +872,8 @@ export const eventFields: INodeProperties[] = [ name: 'rrule', type: 'string', default: '', - description: 'Recurrence rule. When set, the parameters Repeat Frequency, Repeat How Many Times and Repeat Until are ignored.', + description: + 'Recurrence rule. When set, the parameters Repeat Frequency, Repeat How Many Times and Repeat Until are ignored.', }, { displayName: 'Send Updates', @@ -942,7 +893,8 @@ export const eventFields: INodeProperties[] = [ { name: 'None', value: 'none', - description: 'No notifications are sent. This value should only be used for migration use case.', + description: + 'No notifications are sent. This value should only be used for migration use case.', }, ], description: 'Whether to send notifications about the creation of the new event', @@ -999,7 +951,8 @@ export const eventFields: INodeProperties[] = [ { name: 'Public', value: 'public', - description: 'The event is public and event details are visible to all readers of the calendar', + description: + 'The event is public and event details are visible to all readers of the calendar', }, { name: 'Private', @@ -1023,15 +976,9 @@ export const eventFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'update', - ], - useDefaultReminders: [ - false, - ], + resource: ['event'], + operation: ['update'], + useDefaultReminders: [false], }, }, options: [ @@ -1068,6 +1015,7 @@ export const eventFields: INodeProperties[] = [ ], }, ], - description: 'If the event doesn\'t use the default reminders, this lists the reminders specific to the event', + description: + "If the event doesn't use the default reminders, this lists the reminders specific to the event", }, ]; diff --git a/packages/nodes-base/nodes/Google/Calendar/EventInterface.ts b/packages/nodes-base/nodes/Google/Calendar/EventInterface.ts index 53471ca18f..fec1ca78fc 100644 --- a/packages/nodes-base/nodes/Google/Calendar/EventInterface.ts +++ b/packages/nodes-base/nodes/Google/Calendar/EventInterface.ts @@ -1,6 +1,4 @@ -import { - IDataObject, -} from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export interface IReminder { useDefault?: boolean; @@ -9,10 +7,10 @@ export interface IReminder { export interface IConferenceData { createRequest?: { - requestId: string, + requestId: string; conferenceSolution: { - type: string, - } + type: string; + }; }; } diff --git a/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts index 6ffd7404f5..1350acf78c 100644 --- a/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts @@ -1,20 +1,20 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - IPollFunctions, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, IPollFunctions, NodeApiError } from 'n8n-workflow'; -export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IPollFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function googleApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IPollFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -39,8 +39,16 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function googleApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -50,10 +58,7 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData['nextPageToken']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['nextPageToken'] !== undefined && - responseData['nextPageToken'] !== '' - ); + } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); return returnData; } diff --git a/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts b/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts index fe6cbb77e9..80d0aba7ba 100644 --- a/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts +++ b/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -14,24 +12,13 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - googleApiRequest, - googleApiRequestAllItems, -} from './GenericFunctions'; +import { googleApiRequest, googleApiRequestAllItems } from './GenericFunctions'; -import { - eventFields, - eventOperations, -} from './EventDescription'; +import { eventFields, eventOperations } from './EventDescription'; -import { - calendarFields, - calendarOperations, -} from './CalendarDescription'; +import { calendarFields, calendarOperations } from './CalendarDescription'; -import { - IEvent, -} from './EventInterface'; +import { IEvent } from './EventInterface'; import moment from 'moment-timezone'; @@ -86,17 +73,17 @@ export class GoogleCalendar implements INodeType { loadOptions: { // Get all the calendars to display them to user so that he can // select them easily - async getConferenceSolutations( - this: ILoadOptionsFunctions, - ): Promise { + async getConferenceSolutations(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const calendar = this.getCurrentNodeParameter('calendar') as string; const posibleSolutions: IDataObject = { - 'eventHangout': 'Google Hangout', - 'eventNamedHangout': 'Google Hangout Classic', - 'hangoutsMeet': 'Google Meet', + eventHangout: 'Google Hangout', + eventNamedHangout: 'Google Hangout Classic', + hangoutsMeet: 'Google Meet', }; - const { conferenceProperties: { allowedConferenceSolutionTypes } } = await googleApiRequest.call( + const { + conferenceProperties: { allowedConferenceSolutionTypes }, + } = await googleApiRequest.call( this, 'GET', `/calendar/v3/users/me/calendarList/${calendar}`, @@ -111,9 +98,7 @@ export class GoogleCalendar implements INodeType { }, // Get all the calendars to display them to user so that he can // select them easily - async getCalendars( - this: ILoadOptionsFunctions, - ): Promise { + async getCalendars(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const calendars = await googleApiRequestAllItems.call( this, @@ -133,15 +118,9 @@ export class GoogleCalendar implements INodeType { }, // Get all the colors to display them to user so that he can // select them easily - async getColors( - this: ILoadOptionsFunctions, - ): Promise { + async getColors(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { event } = await googleApiRequest.call( - this, - 'GET', - '/calendar/v3/colors', - ); + const { event } = await googleApiRequest.call(this, 'GET', '/calendar/v3/colors'); for (const key of Object.keys(event)) { const colorName = `Background: ${event[key].background} - Foreground: ${event[key].foreground}`; const colorId = key; @@ -154,9 +133,7 @@ export class GoogleCalendar implements INodeType { }, // Get all the timezones to display them to user so that he can // select them easily - async getTimezones( - this: ILoadOptionsFunctions, - ): Promise { + async getTimezones(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; for (const timezone of moment.tz.names()) { const timezoneName = timezone; @@ -218,7 +195,6 @@ export class GoogleCalendar implements INodeType { responseData = { available: !responseData.calendars[calendarId].busy.length, }; - } else if (outputFormat === 'bookedSlots') { responseData = responseData.calendars[calendarId].busy; } @@ -230,14 +206,8 @@ export class GoogleCalendar implements INodeType { const calendarId = this.getNodeParameter('calendar', i) as string; const start = this.getNodeParameter('start', i) as string; const end = this.getNodeParameter('end', i) as string; - const useDefaultReminders = this.getNodeParameter( - 'useDefaultReminders', - i, - ) as boolean; - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - ) as IDataObject; + const useDefaultReminders = this.getNodeParameter('useDefaultReminders', i) as boolean; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (additionalFields.maxAttendees) { qs.maxAttendees = additionalFields.maxAttendees as number; @@ -260,8 +230,14 @@ export class GoogleCalendar implements INodeType { }; if (additionalFields.attendees) { body.attendees = []; - (additionalFields.attendees as string[]).forEach(attendee => { - body.attendees!.push.apply(body.attendees, attendee.split(',').map(a => a.trim()).map(email => ({ email }))); + (additionalFields.attendees as string[]).forEach((attendee) => { + body.attendees!.push.apply( + body.attendees, + attendee + .split(',') + .map((a) => a.trim()) + .map((email) => ({ email })), + ); }); } if (additionalFields.color) { @@ -295,10 +271,8 @@ export class GoogleCalendar implements INodeType { body.visibility = additionalFields.visibility as string; } if (!useDefaultReminders) { - const reminders = (this.getNodeParameter( - 'remindersUi', - i, - ) as IDataObject).remindersValues as IDataObject[]; + const reminders = (this.getNodeParameter('remindersUi', i) as IDataObject) + .remindersValues as IDataObject[]; body.reminders = { useDefault: false, }; @@ -309,14 +283,14 @@ export class GoogleCalendar implements INodeType { if (additionalFields.allday) { body.start = { - date: timezone ? - moment.tz(start, timezone).utc(true).format('YYYY-MM-DD') : - moment.tz(start, moment.tz.guess()).utc(true).format('YYYY-MM-DD'), + date: timezone + ? moment.tz(start, timezone).utc(true).format('YYYY-MM-DD') + : moment.tz(start, moment.tz.guess()).utc(true).format('YYYY-MM-DD'), }; body.end = { - date: timezone ? - moment.tz(end, timezone).utc(true).format('YYYY-MM-DD') : - moment.tz(end, moment.tz.guess()).utc(true).format('YYYY-MM-DD'), + date: timezone + ? moment.tz(end, timezone).utc(true).format('YYYY-MM-DD') + : moment.tz(end, moment.tz.guess()).utc(true).format('YYYY-MM-DD'), }; } //exampel: RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=10;UNTIL=20110701T170000Z @@ -325,12 +299,11 @@ export class GoogleCalendar implements INodeType { if (additionalFields.rrule) { body.recurrence = [`RRULE:${additionalFields.rrule}`]; } else { - if ( - additionalFields.repeatHowManyTimes && - additionalFields.repeatUntil - ) { - throw new NodeOperationError(this.getNode(), - `You can set either 'Repeat How Many Times' or 'Repeat Until' but not both`, { itemIndex: i }, + if (additionalFields.repeatHowManyTimes && additionalFields.repeatUntil) { + throw new NodeOperationError( + this.getNode(), + `You can set either 'Repeat How Many Times' or 'Repeat Until' but not both`, + { itemIndex: i }, ); } if (additionalFields.repeatFrecuency) { @@ -339,17 +312,13 @@ export class GoogleCalendar implements INodeType { ); } if (additionalFields.repeatHowManyTimes) { - body.recurrence?.push( - `COUNT=${additionalFields.repeatHowManyTimes};`, - ); + body.recurrence?.push(`COUNT=${additionalFields.repeatHowManyTimes};`); } if (additionalFields.repeatUntil) { const repeatUntil = moment(additionalFields.repeatUntil as string) .utc() .format('YYYYMMDDTHHmmss'); - body.recurrence?.push( - `UNTIL=${repeatUntil}Z`, - ); + body.recurrence?.push(`UNTIL=${repeatUntil}Z`); } if (body.recurrence.length !== 0) { body.recurrence = [`RRULE:${body.recurrence.join('')}`]; @@ -357,9 +326,9 @@ export class GoogleCalendar implements INodeType { } if (additionalFields.conferenceDataUi) { - const conferenceData = (additionalFields.conferenceDataUi as IDataObject).conferenceDataValues as IDataObject; + const conferenceData = (additionalFields.conferenceDataUi as IDataObject) + .conferenceDataValues as IDataObject; if (conferenceData) { - qs.conferenceDataVersion = 1; body.conferenceData = { createRequest: { @@ -477,15 +446,9 @@ export class GoogleCalendar implements INodeType { if (operation === 'update') { const calendarId = this.getNodeParameter('calendar', i) as string; const eventId = this.getNodeParameter('eventId', i) as string; - const useDefaultReminders = this.getNodeParameter( - 'useDefaultReminders', - i, - ) as boolean; - const updateFields = this.getNodeParameter( - 'updateFields', - i, - ) as IDataObject; - const timezone = (updateFields.timezone as string); + const useDefaultReminders = this.getNodeParameter('useDefaultReminders', i) as boolean; + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; + const timezone = updateFields.timezone as string; if (updateFields.maxAttendees) { qs.maxAttendees = updateFields.maxAttendees as number; @@ -511,8 +474,14 @@ export class GoogleCalendar implements INodeType { } if (updateFields.attendees) { body.attendees = []; - (updateFields.attendees as string[]).forEach(attendee => { - body.attendees!.push.apply(body.attendees, attendee.split(',').map(a => a.trim()).map(email => ({ email }))); + (updateFields.attendees as string[]).forEach((attendee) => { + body.attendees!.push.apply( + body.attendees, + attendee + .split(',') + .map((a) => a.trim()) + .map((email) => ({ email })), + ); }); } if (updateFields.color) { @@ -546,10 +515,8 @@ export class GoogleCalendar implements INodeType { body.visibility = updateFields.visibility as string; } if (!useDefaultReminders) { - const reminders = (this.getNodeParameter( - 'remindersUi', - i, - ) as IDataObject).remindersValues as IDataObject[]; + const reminders = (this.getNodeParameter('remindersUi', i) as IDataObject) + .remindersValues as IDataObject[]; body.reminders = { useDefault: false, }; @@ -559,14 +526,14 @@ export class GoogleCalendar implements INodeType { } if (updateFields.allday && updateFields.start && updateFields.end) { body.start = { - date: timezone ? - moment.tz(updateFields.start, timezone).utc(true).format('YYYY-MM-DD') : - moment.tz(updateFields.start, moment.tz.guess()).utc(true).format('YYYY-MM-DD'), + date: timezone + ? moment.tz(updateFields.start, timezone).utc(true).format('YYYY-MM-DD') + : moment.tz(updateFields.start, moment.tz.guess()).utc(true).format('YYYY-MM-DD'), }; body.end = { - date: timezone ? - moment.tz(updateFields.end, timezone).utc(true).format('YYYY-MM-DD') : - moment.tz(updateFields.end, moment.tz.guess()).utc(true).format('YYYY-MM-DD'), + date: timezone + ? moment.tz(updateFields.end, timezone).utc(true).format('YYYY-MM-DD') + : moment.tz(updateFields.end, moment.tz.guess()).utc(true).format('YYYY-MM-DD'), }; } //exampel: RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=10;UNTIL=20110701T170000Z @@ -576,8 +543,10 @@ export class GoogleCalendar implements INodeType { body.recurrence = [`RRULE:${updateFields.rrule}`]; } else { if (updateFields.repeatHowManyTimes && updateFields.repeatUntil) { - throw new NodeOperationError(this.getNode(), - `You can set either 'Repeat How Many Times' or 'Repeat Until' but not both`, { itemIndex: i }, + throw new NodeOperationError( + this.getNode(), + `You can set either 'Repeat How Many Times' or 'Repeat Until' but not both`, + { itemIndex: i }, ); } if (updateFields.repeatFrecuency) { @@ -593,9 +562,7 @@ export class GoogleCalendar implements INodeType { .utc() .format('YYYYMMDDTHHmmss'); - body.recurrence?.push( - `UNTIL=${repeatUntil}Z`, - ); + body.recurrence?.push(`UNTIL=${repeatUntil}Z`); } if (body.recurrence.length !== 0) { body.recurrence = [`RRULE:${body.recurrence.join('')}`]; @@ -623,11 +590,9 @@ export class GoogleCalendar implements INodeType { throw error; } else { // Return the actual reason as error - returnData.push( - { - error: (error as JsonObject).message, - }, - ); + returnData.push({ + error: (error as JsonObject).message, + }); continue; } } diff --git a/packages/nodes-base/nodes/Google/Calendar/GoogleCalendarTrigger.node.ts b/packages/nodes-base/nodes/Google/Calendar/GoogleCalendarTrigger.node.ts index f28a8704a6..0cbc66deba 100644 --- a/packages/nodes-base/nodes/Google/Calendar/GoogleCalendarTrigger.node.ts +++ b/packages/nodes-base/nodes/Google/Calendar/GoogleCalendarTrigger.node.ts @@ -1,4 +1,3 @@ - import { IDataObject, ILoadOptionsFunctions, @@ -11,10 +10,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - googleApiRequest, - googleApiRequestAllItems, -} from './GenericFunctions'; +import { googleApiRequest, googleApiRequestAllItems } from './GenericFunctions'; import moment from 'moment'; @@ -44,7 +40,8 @@ export class GoogleCalendarTrigger implements INodeType { displayName: 'Calendar Name or ID', name: 'calendarId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getCalendars', @@ -88,7 +85,8 @@ export class GoogleCalendarTrigger implements INodeType { name: 'matchTerm', type: 'string', default: '', - description: 'Free text search terms to filter events that match these terms in any field, except for extended properties', + description: + 'Free text search terms to filter events that match these terms in any field, except for extended properties', }, ], }, @@ -99,9 +97,7 @@ export class GoogleCalendarTrigger implements INodeType { loadOptions: { // Get all the calendars to display them to user so that he can // select them easily - async getCalendars( - this: ILoadOptionsFunctions, - ): Promise { + async getCalendars(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const calendars = await googleApiRequestAllItems.call( this, @@ -128,29 +124,20 @@ export class GoogleCalendarTrigger implements INodeType { const matchTerm = this.getNodeParameter('options.matchTerm', '') as string; if (poolTimes.length === 0) { - throw new NodeOperationError( - this.getNode(), - 'Please set a poll time', - ); + throw new NodeOperationError(this.getNode(), 'Please set a poll time'); } if (triggerOn === '') { - throw new NodeOperationError( - this.getNode(), - 'Please select an event', - ); + throw new NodeOperationError(this.getNode(), 'Please select an event'); } if (calendarId === '') { - throw new NodeOperationError( - this.getNode(), - 'Please select a calendar', - ); + throw new NodeOperationError(this.getNode(), 'Please select a calendar'); } const now = moment().utc().format(); - const startDate = webhookData.lastTimeChecked as string || now; + const startDate = (webhookData.lastTimeChecked as string) || now; const endDate = now; @@ -184,18 +171,42 @@ export class GoogleCalendarTrigger implements INodeType { delete qs.timeMax; qs.maxResults = 1; - events = await googleApiRequest.call(this, 'GET', `/calendar/v3/calendars/${calendarId}/events`, {}, qs); + events = await googleApiRequest.call( + this, + 'GET', + `/calendar/v3/calendars/${calendarId}/events`, + {}, + qs, + ); events = events.items; } else { - events = await googleApiRequestAllItems.call(this, 'items', 'GET', `/calendar/v3/calendars/${calendarId}/events`, {}, qs); + events = await googleApiRequestAllItems.call( + this, + 'items', + 'GET', + `/calendar/v3/calendars/${calendarId}/events`, + {}, + qs, + ); if (triggerOn === 'eventCreated') { - events = events.filter((event: { created: string }) => moment(event.created).isBetween(startDate, endDate)); + events = events.filter((event: { created: string }) => + moment(event.created).isBetween(startDate, endDate), + ); } else if (triggerOn === 'eventUpdated') { - events = events.filter((event: { created: string, updated: string }) => !moment(moment(event.created).format('YYYY-MM-DDTHH:mm:ss')).isSame(moment(event.updated).format('YYYY-MM-DDTHH:mm:ss'))); + events = events.filter( + (event: { created: string; updated: string }) => + !moment(moment(event.created).format('YYYY-MM-DDTHH:mm:ss')).isSame( + moment(event.updated).format('YYYY-MM-DDTHH:mm:ss'), + ), + ); } else if (triggerOn === 'eventStarted') { - events = events.filter((event: { start: { dateTime: string } }) => moment(event.start.dateTime).isBetween(startDate, endDate, null, '[]')); + events = events.filter((event: { start: { dateTime: string } }) => + moment(event.start.dateTime).isBetween(startDate, endDate, null, '[]'), + ); } else if (triggerOn === 'eventEnded') { - events = events.filter((event: { end: { dateTime: string } }) => moment(event.end.dateTime).isBetween(startDate, endDate, null, '[]')); + events = events.filter((event: { end: { dateTime: string } }) => + moment(event.end.dateTime).isBetween(startDate, endDate, null, '[]'), + ); } } @@ -206,7 +217,9 @@ export class GoogleCalendarTrigger implements INodeType { } if (this.getMode() === 'manual') { - throw new NodeApiError(this.getNode(), { message: 'No data with the current filter could be found' }); + throw new NodeApiError(this.getNode(), { + message: 'No data with the current filter could be found', + }); } return null; diff --git a/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts index 47df5cbe6e..f7fc8b7643 100644 --- a/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts @@ -1,12 +1,6 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { // ICredentialDataDecryptedObject, @@ -28,8 +22,18 @@ interface IGoogleAuthCredentials { privateKey: string; } -export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, noCredentials = false, encoding?: null | undefined): Promise { // tslint:disable-line:no-any - +export async function googleApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + noCredentials = false, + encoding?: null | undefined, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -54,10 +58,13 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF if (noCredentials) { //@ts-ignore responseData = await this.helpers.request(options); - } else{ + } else { const credentials = await this.getCredentials('googleApi'); - const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials); + const { access_token } = await getAccessToken.call( + this, + credentials as unknown as IGoogleAuthCredentials, + ); options.headers!.Authorization = `Bearer ${access_token}`; //@ts-ignore responseData = await this.helpers.request(options); @@ -69,16 +76,23 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF throw new NodeApiError(this.getNode(), error); } - if(Object.keys(responseData as IDataObject).length !== 0) { + if (Object.keys(responseData as IDataObject).length !== 0) { return responseData; - } - else { - return { 'success': true }; + } else { + return { success: true }; } } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function googleApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -88,20 +102,22 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData['nextPageToken']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['nextPageToken'] !== undefined && - responseData['nextPageToken'] !== '' - ); + } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); return returnData; } -export function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | ICredentialTestFunctions, credentials: IGoogleAuthCredentials): Promise { +export function getAccessToken( + this: + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | ICredentialTestFunctions, + credentials: IGoogleAuthCredentials, +): Promise { //https://developers.google.com/identity/protocols/oauth2/service-account#httprest - const scopes = [ - 'https://www.googleapis.com/auth/chat.bot', - ]; + const scopes = ['https://www.googleapis.com/auth/chat.bot']; const now = moment().unix(); @@ -110,20 +126,20 @@ export function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions const signature = jwt.sign( { - 'iss': credentials.email as string, - 'sub': credentials.delegatedEmail || credentials.email as string, - 'scope': scopes.join(' '), - 'aud': `https://oauth2.googleapis.com/token`, - 'iat': now, - 'exp': now + 3600, + iss: credentials.email as string, + sub: credentials.delegatedEmail || (credentials.email as string), + scope: scopes.join(' '), + aud: `https://oauth2.googleapis.com/token`, + iat: now, + exp: now + 3600, }, privateKey, { algorithm: 'RS256', header: { - 'kid': privateKey, - 'typ': 'JWT', - 'alg': 'RS256', + kid: privateKey, + typ: 'JWT', + alg: 'RS256', }, }, ); @@ -145,7 +161,8 @@ export function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions return this.helpers.request(options); } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); @@ -156,19 +173,15 @@ export function validateJSON(json: string | undefined): any { // tslint:disable- } export function getPagingParameters(resource: string, operation = 'getAll') { - const pagingParameters: INodeProperties [] = [ + const pagingParameters: INodeProperties[] = [ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - resource, - ], - operation: [ - operation, - ], + resource: [resource], + operation: [operation], }, }, default: false, @@ -183,15 +196,9 @@ export function getPagingParameters(resource: string, operation = 'getAll') { }, displayOptions: { show: { - resource: [ - resource, - ], - operation: [ - operation, - ], - returnAll: [ - false, - ], + resource: [resource], + operation: [operation], + returnAll: [false], }, }, default: 100, diff --git a/packages/nodes-base/nodes/Google/Chat/GoogleChat.node.ts b/packages/nodes-base/nodes/Google/Chat/GoogleChat.node.ts index d716835b0f..41939f0596 100644 --- a/packages/nodes-base/nodes/Google/Chat/GoogleChat.node.ts +++ b/packages/nodes-base/nodes/Google/Chat/GoogleChat.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -15,14 +13,9 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - IMessage, - IMessageUi, -} from './MessageInterface'; +import { IMessage, IMessageUi } from './MessageInterface'; -import { - OptionsWithUri -} from 'request'; +import { OptionsWithUri } from 'request'; import { // attachmentFields, @@ -36,14 +29,10 @@ import { messageFields, messageOperations, spaceFields, - spaceOperations + spaceOperations, } from './descriptions'; -import { - googleApiRequest, - googleApiRequestAllItems, - validateJSON, -} from './GenericFunctions'; +import { googleApiRequest, googleApiRequestAllItems, validateJSON } from './GenericFunctions'; import moment from 'moment-timezone'; @@ -124,16 +113,9 @@ export class GoogleChat implements INodeType { loadOptions: { // Get all the spaces to display them to user so that he can // select them easily - async getSpaces( - this: ILoadOptionsFunctions, - ): Promise { + async getSpaces(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const spaces = await googleApiRequestAllItems.call( - this, - 'spaces', - 'GET', - `/v1/spaces`, - ); + const spaces = await googleApiRequestAllItems.call(this, 'spaces', 'GET', `/v1/spaces`); for (const space of spaces) { returnData.push({ name: space.displayName, @@ -144,11 +126,11 @@ export class GoogleChat implements INodeType { }, }, credentialTest: { - async testGoogleTokenAuth(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { - - const scopes = [ - 'https://www.googleapis.com/auth/chat.bot', - ]; + async testGoogleTokenAuth( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { + const scopes = ['https://www.googleapis.com/auth/chat.bot']; const now = moment().unix(); @@ -158,20 +140,20 @@ export class GoogleChat implements INodeType { try { const signature = jwt.sign( { - 'iss': email, - 'sub': credential.data!.delegatedEmail || email, - 'scope': scopes.join(' '), - 'aud': `https://oauth2.googleapis.com/token`, - 'iat': now, - 'exp': now, + iss: email, + sub: credential.data!.delegatedEmail || email, + scope: scopes.join(' '), + aud: `https://oauth2.googleapis.com/token`, + iat: now, + exp: now, }, privateKey, { algorithm: 'RS256', header: { - 'kid': privateKey, - 'typ': 'JWT', - 'alg': 'RS256', + kid: privateKey, + typ: 'JWT', + alg: 'RS256', }, }, ); @@ -264,13 +246,13 @@ export class GoogleChat implements INodeType { const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; - items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData(responseData, endpoint); - + items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData( + responseData, + endpoint, + ); } - } else if (resource === 'space') { if (operation === 'get') { - // ---------------------------------------- // space: get // ---------------------------------------- @@ -279,14 +261,8 @@ export class GoogleChat implements INodeType { const spaceId = this.getNodeParameter('spaceId', i) as string; - responseData = await googleApiRequest.call( - this, - 'GET', - `/v1/${spaceId}`, - ); - + responseData = await googleApiRequest.call(this, 'GET', `/v1/${spaceId}`); } else if (operation === 'getAll') { - // ---------------------------------------- // space: getAll // ---------------------------------------- @@ -305,19 +281,12 @@ export class GoogleChat implements INodeType { const limit = this.getNodeParameter('limit', i) as number; qs.pageSize = limit; - responseData = await googleApiRequest.call( - this, - 'GET', - `/v1/spaces`, - undefined, - qs, - ); + responseData = await googleApiRequest.call(this, 'GET', `/v1/spaces`, undefined, qs); responseData = responseData.spaces; } } } else if (resource === 'member') { if (operation === 'get') { - // ---------------------------------------- // member: get // ---------------------------------------- @@ -326,14 +295,8 @@ export class GoogleChat implements INodeType { const memberId = this.getNodeParameter('memberId', i) as string; - responseData = await googleApiRequest.call( - this, - 'GET', - `/v1/${memberId}`, - ); - + responseData = await googleApiRequest.call(this, 'GET', `/v1/${memberId}`); } else if (operation === 'getAll') { - // ---------------------------------------- // member: getAll // ---------------------------------------- @@ -352,7 +315,6 @@ export class GoogleChat implements INodeType { undefined, qs, ); - } else { const limit = this.getNodeParameter('limit', i) as number; qs.pageSize = limit; @@ -366,11 +328,9 @@ export class GoogleChat implements INodeType { ); responseData = responseData.memberships; } - } } else if (resource === 'message') { if (operation === 'create') { - // ---------------------------------------- // message: create // ---------------------------------------- @@ -401,16 +361,21 @@ export class GoogleChat implements INodeType { if (validateJSON(messageJson as string) !== undefined) { message = JSON.parse(messageJson as string) as IMessage; } else { - throw new NodeOperationError(this.getNode(), 'Message (JSON) must be a valid json', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Message (JSON) must be a valid json', + { itemIndex: i }, + ); } } - } else { const messageUi = this.getNodeParameter('messageUi', i) as IMessageUi; if (messageUi.text && messageUi.text !== '') { message.text = messageUi.text; } else { - throw new NodeOperationError(this.getNode(), 'Message Text must be provided.', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Message Text must be provided.', { + itemIndex: i, + }); } // // TODO: get cards from the UI // if (messageUi?.cards?.metadataValues && messageUi?.cards?.metadataValues.length !== 0) { @@ -429,9 +394,7 @@ export class GoogleChat implements INodeType { body, qs, ); - } else if (operation === 'delete') { - // ---------------------------------------- // message: delete // ---------------------------------------- @@ -440,14 +403,8 @@ export class GoogleChat implements INodeType { const messageId = this.getNodeParameter('messageId', i) as string; - responseData = await googleApiRequest.call( - this, - 'DELETE', - `/v1/${messageId}`, - ); - + responseData = await googleApiRequest.call(this, 'DELETE', `/v1/${messageId}`); } else if (operation === 'get') { - // ---------------------------------------- // message: get // ---------------------------------------- @@ -456,14 +413,8 @@ export class GoogleChat implements INodeType { const messageId = this.getNodeParameter('messageId', i) as string; - responseData = await googleApiRequest.call( - this, - 'GET', - `/v1/${messageId}`, - ); - + responseData = await googleApiRequest.call(this, 'GET', `/v1/${messageId}`); } else if (operation === 'update') { - // ---------------------------------------- // message: update // ---------------------------------------- @@ -485,10 +436,13 @@ export class GoogleChat implements INodeType { if (validateJSON(updateFieldsJson as string) !== undefined) { message = JSON.parse(updateFieldsJson as string) as IMessage; } else { - throw new NodeOperationError(this.getNode(), 'Update Fields (JSON) must be a valid json', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Update Fields (JSON) must be a valid json', + { itemIndex: i }, + ); } } - } else { const updateFieldsUi = this.getNodeParameter('updateFieldsUi', i) as IDataObject; if (updateFieldsUi.text) { @@ -514,17 +468,9 @@ export class GoogleChat implements INodeType { updateMask = updateMask.slice(0, -1); // remove trailing comma qs.updateMask = updateMask; - responseData = await googleApiRequest.call( - this, - 'PUT', - `/v1/${messageId}`, - body, - qs, - ); + responseData = await googleApiRequest.call(this, 'PUT', `/v1/${messageId}`, body, qs); } - } else if (resource === 'attachment') { - if (operation === 'get') { // ---------------------------------------- // attachment: get @@ -534,15 +480,10 @@ export class GoogleChat implements INodeType { const attachmentName = this.getNodeParameter('attachmentName', i) as string; - responseData = await googleApiRequest.call( - this, - 'GET', - `/v1/${attachmentName}`, - ); + responseData = await googleApiRequest.call(this, 'GET', `/v1/${attachmentName}`); } } else if (resource === 'incomingWebhook') { if (operation === 'create') { - // ---------------------------------------- // incomingWebhook: create // ---------------------------------------- @@ -570,33 +511,29 @@ export class GoogleChat implements INodeType { if (validateJSON(messageJson as string) !== undefined) { message = JSON.parse(messageJson as string) as IMessage; } else { - throw new NodeOperationError(this.getNode(), 'Message (JSON) must be a valid json', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Message (JSON) must be a valid json', + { itemIndex: i }, + ); } } - } else { const messageUi = this.getNodeParameter('messageUi', i) as IMessageUi; if (messageUi.text && messageUi.text !== '') { message.text = messageUi.text; } else { - throw new NodeOperationError(this.getNode(), 'Message Text must be provided.', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Message Text must be provided.', { + itemIndex: i, + }); } } const body: IDataObject = {}; Object.assign(body, message); - responseData = await googleApiRequest.call( - this, - 'POST', - '', - body, - qs, - uri, - true, - ); + responseData = await googleApiRequest.call(this, 'POST', '', body, qs, uri, true); } - } if (Array.isArray(responseData)) { returnData.push.apply(returnData, responseData as IDataObject[]); diff --git a/packages/nodes-base/nodes/Google/Chat/descriptions/AttachmentDescription.ts b/packages/nodes-base/nodes/Google/Chat/descriptions/AttachmentDescription.ts index 7cf318c709..ef3c5baa2c 100644 --- a/packages/nodes-base/nodes/Google/Chat/descriptions/AttachmentDescription.ts +++ b/packages/nodes-base/nodes/Google/Chat/descriptions/AttachmentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const attachmentOperations: INodeProperties[] = [ { @@ -10,16 +8,15 @@ export const attachmentOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'attachment', - ], + resource: ['attachment'], }, }, options: [ { name: 'Get', value: 'get', - description: 'Gets the metadata of a message attachment. The attachment data is fetched using the media API.', + description: + 'Gets the metadata of a message attachment. The attachment data is fetched using the media API.', action: 'Get an attachment', }, ], @@ -27,7 +24,7 @@ export const attachmentOperations: INodeProperties[] = [ }, ]; -export const attachmentFields: INodeProperties[] = [ +export const attachmentFields: INodeProperties[] = [ /* -------------------------------------------------------------------------- */ /* attachments:get */ /* -------------------------------------------------------------------------- */ @@ -38,12 +35,8 @@ export const attachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'get', - ], + resource: ['attachment'], + operation: ['get'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Google/Chat/descriptions/IncomingWebhookDescription.ts b/packages/nodes-base/nodes/Google/Chat/descriptions/IncomingWebhookDescription.ts index 8eaaa5dbc7..9f23c6559a 100644 --- a/packages/nodes-base/nodes/Google/Chat/descriptions/IncomingWebhookDescription.ts +++ b/packages/nodes-base/nodes/Google/Chat/descriptions/IncomingWebhookDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const incomingWebhookOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const incomingWebhookOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'incomingWebhook', - ], + resource: ['incomingWebhook'], }, }, options: [ @@ -27,24 +23,19 @@ export const incomingWebhookOperations: INodeProperties[] = [ }, ]; - export const incomingWebhookFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* incomingWebhook:create */ /* -------------------------------------------------------------------------- */ { - displayName: 'See Google Chat Guide To Webhooks', + displayName: + 'See Google Chat Guide To Webhooks', name: 'jsonNotice', type: 'notice', displayOptions: { show: { - resource: [ - 'incomingWebhook', - ], - operation: [ - 'create', - ], + resource: ['incomingWebhook'], + operation: ['create'], }, }, default: '', @@ -56,12 +47,8 @@ export const incomingWebhookFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'incomingWebhook', - ], - operation: [ - 'create', - ], + resource: ['incomingWebhook'], + operation: ['create'], }, }, default: '', @@ -73,12 +60,8 @@ export const incomingWebhookFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'incomingWebhook', - ], - operation: [ - 'create', - ], + resource: ['incomingWebhook'], + operation: ['create'], }, }, default: false, @@ -92,18 +75,12 @@ export const incomingWebhookFields: INodeProperties[] = [ placeholder: 'Add Options', displayOptions: { show: { - resource: [ - 'incomingWebhook', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['incomingWebhook'], + operation: ['create'], + jsonParameters: [false], }, }, - default: {'text': ''}, + default: { text: '' }, description: 'The message object', options: [ { @@ -116,20 +93,15 @@ export const incomingWebhookFields: INodeProperties[] = [ ], }, { - displayName: 'See Google Chat Guide To Creating Messages', + displayName: + 'See Google Chat Guide To Creating Messages', name: 'jsonNotice', type: 'notice', displayOptions: { show: { - resource: [ - 'incomingWebhook', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['incomingWebhook'], + operation: ['create'], + jsonParameters: [true], }, }, default: '', @@ -144,15 +116,9 @@ export const incomingWebhookFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'incomingWebhook', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['incomingWebhook'], + operation: ['create'], + jsonParameters: [true], }, }, default: '', @@ -166,12 +132,8 @@ export const incomingWebhookFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'incomingWebhook', - ], - operation: [ - 'create', - ], + resource: ['incomingWebhook'], + operation: ['create'], }, }, options: [ @@ -180,7 +142,8 @@ export const incomingWebhookFields: INodeProperties[] = [ name: 'threadKey', type: 'string', default: '', - description: 'Thread identifier which groups messages into a single thread. Has no effect if thread field, corresponding to an existing thread, is set in message. Example: spaces/AAAAMpdlehY/threads/MZ8fXhZXGkk.', + description: + 'Thread identifier which groups messages into a single thread. Has no effect if thread field, corresponding to an existing thread, is set in message. Example: spaces/AAAAMpdlehY/threads/MZ8fXhZXGkk.', }, ], }, diff --git a/packages/nodes-base/nodes/Google/Chat/descriptions/MediaDescription.ts b/packages/nodes-base/nodes/Google/Chat/descriptions/MediaDescription.ts index 278ef5f105..1a8a2f9853 100644 --- a/packages/nodes-base/nodes/Google/Chat/descriptions/MediaDescription.ts +++ b/packages/nodes-base/nodes/Google/Chat/descriptions/MediaDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const mediaOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const mediaOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'media', - ], + resource: ['media'], }, }, options: [ @@ -27,7 +23,7 @@ export const mediaOperations: INodeProperties[] = [ }, ]; -export const mediaFields: INodeProperties[] = [ +export const mediaFields: INodeProperties[] = [ /* -------------------------------------------------------------------------- */ /* media:download */ /* -------------------------------------------------------------------------- */ @@ -38,12 +34,8 @@ export const mediaFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'media', - ], - operation: [ - 'download', - ], + resource: ['media'], + operation: ['download'], }, }, default: '', @@ -57,12 +49,8 @@ export const mediaFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'media', - ], - operation: [ - 'download', - ], + resource: ['media'], + operation: ['download'], }, }, description: 'Name of the binary property to which to write the data of the read file', diff --git a/packages/nodes-base/nodes/Google/Chat/descriptions/MemberDescription.ts b/packages/nodes-base/nodes/Google/Chat/descriptions/MemberDescription.ts index 89400221ca..00b611289e 100644 --- a/packages/nodes-base/nodes/Google/Chat/descriptions/MemberDescription.ts +++ b/packages/nodes-base/nodes/Google/Chat/descriptions/MemberDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - getPagingParameters -} from '../GenericFunctions'; +import { getPagingParameters } from '../GenericFunctions'; export const memberOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const memberOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'member', - ], + resource: ['member'], }, }, options: [ @@ -37,7 +31,6 @@ export const memberOperations: INodeProperties[] = [ }, ]; - export const memberFields: INodeProperties[] = [ /* -------------------------------------------------------------------------- */ /* member:get */ @@ -49,12 +42,8 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'get', - ], + resource: ['member'], + operation: ['get'], }, }, default: '', @@ -74,18 +63,14 @@ export const memberFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'getAll', - ], + resource: ['member'], + operation: ['getAll'], }, }, default: [], - description: 'The name of the space for which to retrieve members, in the form "spaces/*". Choose from the list, or specify an ID using an expression.', + description: + 'The name of the space for which to retrieve members, in the form "spaces/*". Choose from the list, or specify an ID using an expression.', }, ...getPagingParameters('member'), ]; - diff --git a/packages/nodes-base/nodes/Google/Chat/descriptions/MessageDescription.ts b/packages/nodes-base/nodes/Google/Chat/descriptions/MessageDescription.ts index 92aa3e4cc2..cc87e84819 100644 --- a/packages/nodes-base/nodes/Google/Chat/descriptions/MessageDescription.ts +++ b/packages/nodes-base/nodes/Google/Chat/descriptions/MessageDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const messageOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const messageOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'message', - ], + resource: ['message'], }, }, options: [ @@ -46,7 +42,6 @@ export const messageOperations: INodeProperties[] = [ ]; export const messageFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* message:create */ /* -------------------------------------------------------------------------- */ @@ -60,16 +55,13 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], + resource: ['message'], + operation: ['create'], }, }, default: '', - description: 'Space resource name, in the form "spaces/*". Example: spaces/AAAAMpdlehY. Choose from the list, or specify an ID using an expression.', + description: + 'Space resource name, in the form "spaces/*". Example: spaces/AAAAMpdlehY. Choose from the list, or specify an ID using an expression.', }, { displayName: 'JSON Parameters', @@ -77,12 +69,8 @@ export const messageFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], + resource: ['message'], + operation: ['create'], }, }, default: false, @@ -96,15 +84,9 @@ export const messageFields: INodeProperties[] = [ placeholder: 'Add Message', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['message'], + operation: ['create'], + jsonParameters: [false], }, }, default: {}, @@ -165,20 +147,15 @@ export const messageFields: INodeProperties[] = [ ], }, { - displayName: 'See Google Chat Guide To Creating Messages', + displayName: + 'See Google Chat Guide To Creating Messages', name: 'jsonNotice', type: 'notice', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['message'], + operation: ['create'], + jsonParameters: [true], }, }, default: '', @@ -193,15 +170,9 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['message'], + operation: ['create'], + jsonParameters: [true], }, }, default: '', @@ -215,12 +186,8 @@ export const messageFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], + resource: ['message'], + operation: ['create'], }, }, options: [ @@ -236,7 +203,8 @@ export const messageFields: INodeProperties[] = [ name: 'requestId', type: 'string', default: '', - description: 'A unique request ID for this message. If a message has already been created in the space with this request ID, the subsequent request will return the existing message and no new message will be created.', + description: + 'A unique request ID for this message. If a message has already been created in the space with this request ID, the subsequent request will return the existing message and no new message will be created.', }, ], }, @@ -251,12 +219,8 @@ export const messageFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'delete', - ], + resource: ['message'], + operation: ['delete'], }, }, default: '', @@ -273,12 +237,8 @@ export const messageFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'get', - ], + resource: ['message'], + operation: ['get'], }, }, default: '', @@ -295,12 +255,8 @@ export const messageFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], + resource: ['message'], + operation: ['update'], }, }, default: '', @@ -312,12 +268,8 @@ export const messageFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], + resource: ['message'], + operation: ['update'], }, }, default: false, @@ -331,15 +283,9 @@ export const messageFields: INodeProperties[] = [ placeholder: 'Add Options', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], - jsonParameters: [ - false, - ], + resource: ['message'], + operation: ['update'], + jsonParameters: [false], }, }, default: {}, @@ -400,20 +346,15 @@ export const messageFields: INodeProperties[] = [ ], }, { - displayName: 'See Google Chat Guide To Creating Messages', + displayName: + 'See Google Chat Guide To Creating Messages', name: 'jsonNotice', type: 'notice', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['message'], + operation: ['update'], + jsonParameters: [true], }, }, default: '', @@ -428,15 +369,9 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['message'], + operation: ['update'], + jsonParameters: [true], }, }, default: '', diff --git a/packages/nodes-base/nodes/Google/Chat/descriptions/SpaceDescription.ts b/packages/nodes-base/nodes/Google/Chat/descriptions/SpaceDescription.ts index e2de821daf..db4463d320 100644 --- a/packages/nodes-base/nodes/Google/Chat/descriptions/SpaceDescription.ts +++ b/packages/nodes-base/nodes/Google/Chat/descriptions/SpaceDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - getPagingParameters -} from '../GenericFunctions'; +import { getPagingParameters } from '../GenericFunctions'; export const spaceOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const spaceOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'space', - ], + resource: ['space'], }, }, options: [ @@ -48,12 +42,8 @@ export const spaceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'space', - ], - operation: [ - 'get', - ], + resource: ['space'], + operation: ['get'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts b/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts index b053381e9e..5b61b6b86c 100644 --- a/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts @@ -1,22 +1,23 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, - endpoint: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function googleApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { let options: OptionsWithUri = { headers: { - 'Accept': 'application/json', + Accept: 'application/json', 'Content-Type': 'application/json', }, method, @@ -33,8 +34,11 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF delete options.body; } //@ts-ignore - return await this.helpers.requestOAuth2.call(this, 'googleCloudNaturalLanguageOAuth2Api', options); - + return await this.helpers.requestOAuth2.call( + this, + 'googleCloudNaturalLanguageOAuth2Api', + options, + ); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GoogleCloudNaturalLanguage.node.ts b/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GoogleCloudNaturalLanguage.node.ts index a2ebb33ee8..fe5ae886bc 100644 --- a/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GoogleCloudNaturalLanguage.node.ts +++ b/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GoogleCloudNaturalLanguage.node.ts @@ -1,22 +1,10 @@ +import { IExecuteFunctions } from 'n8n-core'; -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IData } from './Interface'; -import { - IData, -} from './Interface'; - -import { - googleApiRequest, -} from './GenericFunctions'; +import { googleApiRequest } from './GenericFunctions'; export class GoogleCloudNaturalLanguage implements INodeType { description: INodeTypeDescription = { @@ -60,9 +48,7 @@ export class GoogleCloudNaturalLanguage implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'document', - ], + resource: ['document'], }, }, options: [ @@ -92,13 +78,12 @@ export class GoogleCloudNaturalLanguage implements INodeType { }, ], default: 'content', - description: 'The source of the document: a string containing the content or a Google Cloud Storage URI', + description: + 'The source of the document: a string containing the content or a Google Cloud Storage URI', required: true, displayOptions: { show: { - operation: [ - 'analyzeSentiment', - ], + operation: ['analyzeSentiment'], }, }, }, @@ -107,16 +92,13 @@ export class GoogleCloudNaturalLanguage implements INodeType { name: 'content', type: 'string', default: '', - description: 'The content of the input in string format. Cloud audit logging exempt since it is based on user data.', + description: + 'The content of the input in string format. Cloud audit logging exempt since it is based on user data.', required: true, displayOptions: { show: { - operation: [ - 'analyzeSentiment', - ], - source: [ - 'content', - ], + operation: ['analyzeSentiment'], + source: ['content'], }, }, }, @@ -125,16 +107,13 @@ export class GoogleCloudNaturalLanguage implements INodeType { name: 'gcsContentUri', type: 'string', default: '', - description: 'The Google Cloud Storage URI where the file content is located. This URI must be of the form: gs://bucket_name/object_name. For more details, see reference.', + description: + 'The Google Cloud Storage URI where the file content is located. This URI must be of the form: gs://bucket_name/object_name. For more details, see reference.', required: true, displayOptions: { show: { - operation: [ - 'analyzeSentiment', - ], - source: [ - 'gcsContentUri', - ], + operation: ['analyzeSentiment'], + source: ['gcsContentUri'], }, }, }, @@ -144,9 +123,7 @@ export class GoogleCloudNaturalLanguage implements INodeType { type: 'collection', displayOptions: { show: { - operation: [ - 'analyzeSentiment', - ], + operation: ['analyzeSentiment'], }, }, default: {}, @@ -266,7 +243,8 @@ export class GoogleCloudNaturalLanguage implements INodeType { ], default: 'en', placeholder: '', - description: 'The language of the document (if not specified, the language is automatically detected). Both ISO and BCP-47 language codes are accepted.', + description: + 'The language of the document (if not specified, the language is automatically detected). Both ISO and BCP-47 language codes are accepted.', }, ], }, @@ -306,7 +284,12 @@ export class GoogleCloudNaturalLanguage implements INodeType { body.document.language = options.language as string; } - const response = await googleApiRequest.call(this, 'POST', `/v1/documents:analyzeSentiment`, body); + const response = await googleApiRequest.call( + this, + 'POST', + `/v1/documents:analyzeSentiment`, + body, + ); responseData.push(response); } } diff --git a/packages/nodes-base/nodes/Google/CloudNaturalLanguage/Interface.ts b/packages/nodes-base/nodes/Google/CloudNaturalLanguage/Interface.ts index bdbc494b2d..da2e7d5d0c 100644 --- a/packages/nodes-base/nodes/Google/CloudNaturalLanguage/Interface.ts +++ b/packages/nodes-base/nodes/Google/CloudNaturalLanguage/Interface.ts @@ -8,4 +8,4 @@ export interface IDocument { language?: string; content?: string; gcsContentUri?: string; -} \ No newline at end of file +} diff --git a/packages/nodes-base/nodes/Google/Contacts/ContactDescription.ts b/packages/nodes-base/nodes/Google/Contacts/ContactDescription.ts index 9ff8fbad1f..8b34d8e03b 100644 --- a/packages/nodes-base/nodes/Google/Contacts/ContactDescription.ts +++ b/packages/nodes-base/nodes/Google/Contacts/ContactDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const contactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contact', - ], + resource: ['contact'], }, }, options: [ @@ -61,12 +57,8 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], + operation: ['create'], + resource: ['contact'], }, }, default: '', @@ -77,12 +69,8 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], + operation: ['create'], + resource: ['contact'], }, }, default: '', @@ -95,12 +83,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], + operation: ['create'], + resource: ['contact'], }, }, options: [ @@ -282,7 +266,8 @@ export const contactFields: INodeProperties[] = [ }, ], default: '', - description: 'The type of the email address. The type can be custom or one of these predefined values.', + description: + 'The type of the email address. The type can be custom or one of these predefined values.', }, { displayName: 'Value', @@ -332,7 +317,8 @@ export const contactFields: INodeProperties[] = [ }, ], default: '', - description: 'The type of the event. The type can be custom or one of these predefined values.', + description: + 'The type of the event. The type can be custom or one of these predefined values.', }, ], }, @@ -349,7 +335,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Group Names or IDs', name: 'group', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getGroups', }, @@ -543,7 +530,8 @@ export const contactFields: INodeProperties[] = [ }, ], default: '', - description: 'The person\'s relation to the other person. The type can be custom or one of these predefined values.', + description: + "The person's relation to the other person. The type can be custom or one of these predefined values.", }, ], }, @@ -561,12 +549,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'contact', - ], + operation: ['delete'], + resource: ['contact'], }, }, default: '', @@ -581,12 +565,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], + operation: ['get'], + resource: ['contact'], }, }, default: '', @@ -699,16 +679,13 @@ export const contactFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], + operation: ['get'], + resource: ['contact'], }, }, default: [], - description: 'A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas.', + description: + 'A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas.', }, { displayName: 'RAW Data', @@ -716,12 +693,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], + operation: ['get'], + resource: ['contact'], }, }, default: false, @@ -736,12 +709,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], + operation: ['getAll'], + resource: ['contact'], }, }, default: false, @@ -753,15 +722,9 @@ export const contactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['contact'], + returnAll: [false], }, }, typeOptions: { @@ -879,16 +842,13 @@ export const contactFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], + operation: ['getAll'], + resource: ['contact'], }, }, default: [], - description: 'A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas.', + description: + 'A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas.', }, { displayName: 'Use Query', @@ -896,12 +856,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], + operation: ['getAll'], + resource: ['contact'], }, }, default: false, @@ -913,19 +869,14 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], - useQuery: [ - true, - ], + operation: ['getAll'], + resource: ['contact'], + useQuery: [true], }, }, default: '', - description: 'The plain-text query for the request. The query is used to match prefix phrases of the fields on a person. For example, a person with name "foo name" matches queries such as "f", "fo", "foo", "foo n", "nam", etc., but not "oo n".', + description: + 'The plain-text query for the request. The query is used to match prefix phrases of the fields on a person. For example, a person with name "foo name" matches queries such as "f", "fo", "foo", "foo n", "nam", etc., but not "oo n".', }, { displayName: 'RAW Data', @@ -933,12 +884,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], + operation: ['getAll'], + resource: ['contact'], }, }, default: false, @@ -952,15 +899,9 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], - useQuery: [ - false, - ], + operation: ['getAll'], + resource: ['contact'], + useQuery: [false], }, }, options: [ @@ -1005,12 +946,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'contact', - ], + operation: ['update'], + resource: ['contact'], }, }, default: '', @@ -1123,16 +1060,13 @@ export const contactFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'contact', - ], + operation: ['update'], + resource: ['contact'], }, }, default: [], - description: 'A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas.', + description: + 'A field mask to restrict which fields on each person are returned. Multiple fields can be specified by separating them with commas.', }, { displayName: 'Update Fields', @@ -1142,12 +1076,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'contact', - ], + operation: ['update'], + resource: ['contact'], }, }, options: [ @@ -1156,7 +1086,8 @@ export const contactFields: INodeProperties[] = [ name: 'etag', type: 'string', default: '', - description: 'The etag field in the person is nedded to make sure the contact has not changed since your last read', + description: + 'The etag field in the person is nedded to make sure the contact has not changed since your last read', }, { displayName: 'Family Name', @@ -1348,7 +1279,8 @@ export const contactFields: INodeProperties[] = [ }, ], default: '', - description: 'The type of the email address. The type can be custom or one of these predefined values.', + description: + 'The type of the email address. The type can be custom or one of these predefined values.', }, { displayName: 'Value', @@ -1398,7 +1330,8 @@ export const contactFields: INodeProperties[] = [ }, ], default: '', - description: 'The type of the event. The type can be custom or one of these predefined values.', + description: + 'The type of the event. The type can be custom or one of these predefined values.', }, ], }, @@ -1415,7 +1348,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Group Names or IDs', name: 'group', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getGroups', }, @@ -1609,7 +1543,8 @@ export const contactFields: INodeProperties[] = [ }, ], default: '', - description: 'The person\'s relation to the other person. The type can be custom or one of these predefined values.', + description: + "The person's relation to the other person. The type can be custom or one of these predefined values.", }, ], }, diff --git a/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts index a15861b1d6..df13bb3680 100644 --- a/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts @@ -1,18 +1,20 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function googleApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -38,8 +40,16 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function googleApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -49,10 +59,7 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData['nextPageToken']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['nextPageToken'] !== undefined && - responseData['nextPageToken'] !== '' - ); + } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); return returnData; } @@ -84,7 +91,8 @@ export const allFields = [ 'userDefined', ]; -export function cleanData(responseData: any) { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function cleanData(responseData: any) { const fields = ['emailAddresses', 'phoneNumbers', 'relations', 'events', 'addresses']; const newResponseData = []; if (!Array.isArray(responseData)) { @@ -97,7 +105,7 @@ export function cleanData(responseData: any) { // tslint:disable-line:no-any continue; } if (key === 'photos') { - responseData[y][key] = responseData[y][key].map(((photo: IDataObject) => photo.url)); + responseData[y][key] = responseData[y][key].map((photo: IDataObject) => photo.url); } if (key === 'names') { delete responseData[y][key][0].metadata; diff --git a/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts b/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts index 776cc66cdc..464a4bd744 100644 --- a/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts +++ b/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -18,10 +16,7 @@ import { googleApiRequestAllItems, } from './GenericFunctions'; -import { - contactFields, - contactOperations, -} from './ContactDescription'; +import { contactFields, contactOperations } from './ContactDescription'; import moment from 'moment'; import { IData } from '../Analytics/Interfaces'; @@ -70,9 +65,7 @@ export class GoogleContacts implements INodeType { loadOptions: { // Get all the calendars to display them to user so that he can // select them easily - async getGroups( - this: ILoadOptionsFunctions, - ): Promise { + async getGroups(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const groups = await googleApiRequestAllItems.call( this, @@ -136,29 +129,36 @@ export class GoogleContacts implements INodeType { } if (additionalFields.companyUi) { - const companyValues = (additionalFields.companyUi as IDataObject).companyValues as IDataObject[]; + const companyValues = (additionalFields.companyUi as IDataObject) + .companyValues as IDataObject[]; body.organizations = companyValues; } if (additionalFields.phoneUi) { - const phoneValues = (additionalFields.phoneUi as IDataObject).phoneValues as IDataObject[]; + const phoneValues = (additionalFields.phoneUi as IDataObject) + .phoneValues as IDataObject[]; body.phoneNumbers = phoneValues; } if (additionalFields.addressesUi) { - const addressesValues = (additionalFields.addressesUi as IDataObject).addressesValues as IDataObject[]; + const addressesValues = (additionalFields.addressesUi as IDataObject) + .addressesValues as IDataObject[]; body.addresses = addressesValues; } if (additionalFields.relationsUi) { - const relationsValues = (additionalFields.relationsUi as IDataObject).relationsValues as IDataObject[]; + const relationsValues = (additionalFields.relationsUi as IDataObject) + .relationsValues as IDataObject[]; body.relations = relationsValues; } if (additionalFields.eventsUi) { - const eventsValues = (additionalFields.eventsUi as IDataObject).eventsValues as IDataObject[]; + const eventsValues = (additionalFields.eventsUi as IDataObject) + .eventsValues as IDataObject[]; for (let i = 0; i < eventsValues.length; i++) { - const [month, day, year] = moment(eventsValues[i].date as string).format('MM/DD/YYYY').split('/'); + const [month, day, year] = moment(eventsValues[i].date as string) + .format('MM/DD/YYYY') + .split('/'); eventsValues[i] = { date: { day, @@ -172,7 +172,9 @@ export class GoogleContacts implements INodeType { } if (additionalFields.birthday) { - const [month, day, year] = moment(additionalFields.birthday as string).format('MM/DD/YYYY').split('/'); + const [month, day, year] = moment(additionalFields.birthday as string) + .format('MM/DD/YYYY') + .split('/'); body.birthdays = [ { @@ -186,7 +188,8 @@ export class GoogleContacts implements INodeType { } if (additionalFields.emailsUi) { - const emailsValues = (additionalFields.emailsUi as IDataObject).emailsValues as IDataObject[]; + const emailsValues = (additionalFields.emailsUi as IDataObject) + .emailsValues as IDataObject[]; body.emailAddresses = emailsValues; } @@ -200,7 +203,8 @@ export class GoogleContacts implements INodeType { } if (additionalFields.customFieldsUi) { - const customFieldsValues = (additionalFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFieldsValues = (additionalFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; body.userDefined = customFieldsValues; } @@ -225,7 +229,6 @@ export class GoogleContacts implements INodeType { ); responseData.contactId = responseData.resourceName.split('/')[1]; - } //https://developers.google.com/people/api/rest/v1/people/deleteContact if (operation === 'delete') { @@ -250,13 +253,7 @@ export class GoogleContacts implements INodeType { qs.personFields = (fields as string[]).join(','); } - responseData = await googleApiRequest.call( - this, - 'GET', - `/people/${contactId}`, - {}, - qs, - ); + responseData = await googleApiRequest.call(this, 'GET', `/people/${contactId}`, {}, qs); if (!rawData) { responseData = cleanData(responseData)[0]; @@ -273,7 +270,7 @@ export class GoogleContacts implements INodeType { const rawData = this.getNodeParameter('rawData', i) as boolean; const useQuery = this.getNodeParameter('useQuery', i) as boolean; - const endpoint = (useQuery) ? ':searchContacts' : '/me/connections'; + const endpoint = useQuery ? ':searchContacts' : '/me/connections'; if (useQuery) { qs.query = this.getNodeParameter('query', i) as string; @@ -297,7 +294,7 @@ export class GoogleContacts implements INodeType { if (returnAll) { responseData = await googleApiRequestAllItems.call( this, - (useQuery) ? 'results' : 'connections', + useQuery ? 'results' : 'connections', 'GET', `/people${endpoint}`, {}, @@ -307,18 +304,14 @@ export class GoogleContacts implements INodeType { if (useQuery) { responseData = responseData.map((result: IDataObject) => result.person); } - } else { qs.pageSize = this.getNodeParameter('limit', i) as number; - responseData = await googleApiRequest.call( - this, - 'GET', - `/people${endpoint}`, - {}, - qs, - ); + responseData = await googleApiRequest.call(this, 'GET', `/people${endpoint}`, {}, qs); - responseData = responseData.connections || responseData.results?.map((result: IDataObject) => result.person) || []; + responseData = + responseData.connections || + responseData.results?.map((result: IDataObject) => result.person) || + []; } if (!rawData) { @@ -342,11 +335,8 @@ export class GoogleContacts implements INodeType { let etag; if (updateFields.etag) { - etag = updateFields.etag as string; - } else { - const data = await googleApiRequest.call( this, 'GET', @@ -356,7 +346,6 @@ export class GoogleContacts implements INodeType { ); etag = data.etag; - } if (fields.includes('*')) { @@ -367,9 +356,7 @@ export class GoogleContacts implements INodeType { const body: IDataObject = { etag, - names: [ - {}, - ], + names: [{}], }; if (updateFields.givenName) { @@ -398,33 +385,40 @@ export class GoogleContacts implements INodeType { } if (updateFields.companyUi) { - const companyValues = (updateFields.companyUi as IDataObject).companyValues as IDataObject[]; + const companyValues = (updateFields.companyUi as IDataObject) + .companyValues as IDataObject[]; body.organizations = companyValues; updatePersonFields.push('organizations'); } if (updateFields.phoneUi) { - const phoneValues = (updateFields.phoneUi as IDataObject).phoneValues as IDataObject[]; + const phoneValues = (updateFields.phoneUi as IDataObject) + .phoneValues as IDataObject[]; body.phoneNumbers = phoneValues; updatePersonFields.push('phoneNumbers'); } if (updateFields.addressesUi) { - const addressesValues = (updateFields.addressesUi as IDataObject).addressesValues as IDataObject[]; + const addressesValues = (updateFields.addressesUi as IDataObject) + .addressesValues as IDataObject[]; body.addresses = addressesValues; updatePersonFields.push('addresses'); } if (updateFields.relationsUi) { - const relationsValues = (updateFields.relationsUi as IDataObject).relationsValues as IDataObject[]; + const relationsValues = (updateFields.relationsUi as IDataObject) + .relationsValues as IDataObject[]; body.relations = relationsValues; updatePersonFields.push('relations'); } if (updateFields.eventsUi) { - const eventsValues = (updateFields.eventsUi as IDataObject).eventsValues as IDataObject[]; + const eventsValues = (updateFields.eventsUi as IDataObject) + .eventsValues as IDataObject[]; for (let i = 0; i < eventsValues.length; i++) { - const [month, day, year] = moment(eventsValues[i].date as string).format('MM/DD/YYYY').split('/'); + const [month, day, year] = moment(eventsValues[i].date as string) + .format('MM/DD/YYYY') + .split('/'); eventsValues[i] = { date: { day, @@ -439,7 +433,9 @@ export class GoogleContacts implements INodeType { } if (updateFields.birthday) { - const [month, day, year] = moment(updateFields.birthday as string).format('MM/DD/YYYY').split('/'); + const [month, day, year] = moment(updateFields.birthday as string) + .format('MM/DD/YYYY') + .split('/'); body.birthdays = [ { @@ -455,7 +451,8 @@ export class GoogleContacts implements INodeType { } if (updateFields.emailsUi) { - const emailsValues = (updateFields.emailsUi as IDataObject).emailsValues as IDataObject[]; + const emailsValues = (updateFields.emailsUi as IDataObject) + .emailsValues as IDataObject[]; body.emailAddresses = emailsValues; updatePersonFields.push('emailAddresses'); } @@ -471,7 +468,8 @@ export class GoogleContacts implements INodeType { } if (updateFields.customFieldsUi) { - const customFieldsValues = (updateFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFieldsValues = (updateFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; body.userDefined = customFieldsValues; updatePersonFields.push('userDefined'); } diff --git a/packages/nodes-base/nodes/Google/Docs/DocumentDescription.ts b/packages/nodes-base/nodes/Google/Docs/DocumentDescription.ts index 14aab7e790..388abe1bc2 100644 --- a/packages/nodes-base/nodes/Google/Docs/DocumentDescription.ts +++ b/packages/nodes-base/nodes/Google/Docs/DocumentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const documentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const documentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'document', - ], + resource: ['document'], }, }, options: [ @@ -44,7 +40,8 @@ export const documentFields: INodeProperties[] = [ displayName: 'Drive Name or ID', name: 'driveId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getDrives', }, @@ -52,12 +49,8 @@ export const documentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'document', - ], + operation: ['create'], + resource: ['document'], }, }, }, @@ -65,23 +58,18 @@ export const documentFields: INodeProperties[] = [ displayName: 'Folder Name or ID', name: 'folderId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'driveId', - ], + loadOptionsDependsOn: ['driveId'], loadOptionsMethod: 'getFolders', }, default: '', required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'document', - ], + operation: ['create'], + resource: ['document'], }, }, }, @@ -93,12 +81,8 @@ export const documentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'document', - ], + operation: ['create'], + resource: ['document'], }, }, }, @@ -113,12 +97,8 @@ export const documentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'document', - ], + operation: ['get'], + resource: ['document'], }, }, default: '', @@ -130,12 +110,8 @@ export const documentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'document', - ], + operation: ['get'], + resource: ['document'], }, }, default: true, @@ -152,12 +128,8 @@ export const documentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'document', - ], + operation: ['update'], + resource: ['document'], }, }, default: '', @@ -169,12 +141,8 @@ export const documentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'document', - ], + operation: ['update'], + resource: ['document'], }, }, default: true, @@ -202,12 +170,8 @@ export const documentFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'document', - ], + operation: ['update'], + resource: ['document'], }, }, options: [ @@ -282,9 +246,7 @@ export const documentFields: INodeProperties[] = [ ], displayOptions: { show: { - object: [ - 'text', - ], + object: ['text'], }, }, description: 'The update action', @@ -306,12 +268,7 @@ export const documentFields: INodeProperties[] = [ ], displayOptions: { show: { - object: [ - 'footer', - 'header', - 'namedRange', - 'paragraphBullets', - ], + object: ['footer', 'header', 'namedRange', 'paragraphBullets'], }, }, description: 'The update action', @@ -333,10 +290,7 @@ export const documentFields: INodeProperties[] = [ ], displayOptions: { show: { - object: [ - 'tableColumn', - 'tableRow', - ], + object: ['tableColumn', 'tableRow'], }, }, description: 'The update action', @@ -354,10 +308,7 @@ export const documentFields: INodeProperties[] = [ ], displayOptions: { show: { - object: [ - 'pageBreak', - 'table', - ], + object: ['pageBreak', 'table'], }, }, description: 'The update action', @@ -375,9 +326,7 @@ export const documentFields: INodeProperties[] = [ ], displayOptions: { show: { - object: [ - 'positionedObject', - ], + object: ['positionedObject'], }, }, description: 'The update action', @@ -406,15 +355,8 @@ export const documentFields: INodeProperties[] = [ default: 'body', displayOptions: { show: { - object: [ - 'footer', - 'header', - 'paragraphBullets', - 'namedRange', - ], - action: [ - 'create', - ], + object: ['footer', 'header', 'paragraphBullets', 'namedRange'], + action: ['create'], }, }, }, @@ -422,24 +364,16 @@ export const documentFields: INodeProperties[] = [ displayName: 'Segment ID', name: 'segmentId', type: 'string', - description: 'The ID of the header, footer or footnote. The Document → Get operation lists all segment IDs (make sure you disable the simple toggle).', + description: + 'The ID of the header, footer or footnote. The Document → Get operation lists all segment IDs (make sure you disable the simple toggle).', default: '', displayOptions: { show: { - object: [ - 'footer', - 'header', - 'paragraphBullets', - 'namedRange', - ], - action: [ - 'create', - ], + object: ['footer', 'header', 'paragraphBullets', 'namedRange'], + action: ['create'], }, hide: { - insertSegment: [ - 'body', - ], + insertSegment: ['body'], }, }, }, @@ -454,13 +388,8 @@ export const documentFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - object: [ - 'footer', - 'header', - ], - action: [ - 'create', - ], + object: ['footer', 'header'], + action: ['create'], }, }, }, @@ -473,12 +402,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - object: [ - 'namedRange', - ], - action: [ - 'create', - ], + object: ['namedRange'], + action: ['create'], }, }, }, @@ -490,12 +415,8 @@ export const documentFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - object: [ - 'namedRange', - ], - action: [ - 'create', - ], + object: ['namedRange'], + action: ['create'], }, }, }, @@ -507,12 +428,8 @@ export const documentFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - object: [ - 'namedRange', - ], - action: [ - 'create', - ], + object: ['namedRange'], + action: ['create'], }, }, }, @@ -525,29 +442,28 @@ export const documentFields: INodeProperties[] = [ { name: 'Bullet List', value: 'BULLET_DISC_CIRCLE_SQUARE', - description: 'A bulleted list with a DISC, CIRCLE and SQUARE bullet glyph for the first 3 list nesting levels', + description: + 'A bulleted list with a DISC, CIRCLE and SQUARE bullet glyph for the first 3 list nesting levels', }, { name: 'Checkbox List', value: 'BULLET_CHECKBOX', - description: 'A bulleted list with CHECKBOX bullet glyphs for all list nesting levels', + description: + 'A bulleted list with CHECKBOX bullet glyphs for all list nesting levels', }, { name: 'Numbered List', value: 'NUMBERED_DECIMAL_NESTED', - description: 'A numbered list with DECIMAL numeric glyphs separated by periods, where each nesting level uses the previous nesting level\'s glyph as a prefix. For example: 1., 1.1., 2., 2.2 .', + description: + "A numbered list with DECIMAL numeric glyphs separated by periods, where each nesting level uses the previous nesting level's glyph as a prefix. For example: 1., 1.1., 2., 2.2 .", }, ], description: 'The Preset pattern of bullet glyphs for list', default: 'BULLET_DISC_CIRCLE_SQUARE', displayOptions: { show: { - object: [ - 'paragraphBullets', - ], - action: [ - 'create', - ], + object: ['paragraphBullets'], + action: ['create'], }, }, }, @@ -556,16 +472,13 @@ export const documentFields: INodeProperties[] = [ displayName: 'Footer ID', name: 'footerId', type: 'string', - description: 'The ID of the footer to delete. To retrieve it, use the get document where you can find under footers attribute.', + description: + 'The ID of the footer to delete. To retrieve it, use the get document where you can find under footers attribute.', default: '', displayOptions: { show: { - object: [ - 'footer', - ], - action: [ - 'delete', - ], + object: ['footer'], + action: ['delete'], }, }, }, @@ -574,16 +487,13 @@ export const documentFields: INodeProperties[] = [ displayName: 'Header ID', name: 'headerId', type: 'string', - description: 'The ID of the header to delete. To retrieve it, use the get document where you can find under headers attribute.', + description: + 'The ID of the header to delete. To retrieve it, use the get document where you can find under headers attribute.', default: '', displayOptions: { show: { - object: [ - 'header', - ], - action: [ - 'delete', - ], + object: ['header'], + action: ['delete'], }, }, }, @@ -606,12 +516,8 @@ export const documentFields: INodeProperties[] = [ default: 'namedRangeId', displayOptions: { show: { - object: [ - 'namedRange', - ], - action: [ - 'delete', - ], + object: ['namedRange'], + action: ['delete'], }, }, }, @@ -623,15 +529,9 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - object: [ - 'namedRange', - ], - action: [ - 'delete', - ], - namedRangeReference: [ - 'namedRangeId', - ], + object: ['namedRange'], + action: ['delete'], + namedRangeReference: ['namedRangeId'], }, }, }, @@ -643,15 +543,9 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - object: [ - 'namedRange', - ], - action: [ - 'delete', - ], - namedRangeReference: [ - 'name', - ], + object: ['namedRange'], + action: ['delete'], + namedRangeReference: ['name'], }, }, }, @@ -661,16 +555,13 @@ export const documentFields: INodeProperties[] = [ displayName: 'Object ID', name: 'objectId', type: 'string', - description: 'The ID of the positioned object to delete (An object that is tied to a paragraph and positioned relative to its beginning), See the Google documentation', + description: + 'The ID of the positioned object to delete (An object that is tied to a paragraph and positioned relative to its beginning), See the Google documentation', default: '', displayOptions: { show: { - object: [ - 'positionedObject', - ], - action: [ - 'delete', - ], + object: ['positionedObject'], + action: ['delete'], }, }, }, @@ -699,16 +590,8 @@ export const documentFields: INodeProperties[] = [ default: 'body', displayOptions: { show: { - object: [ - 'pageBreak', - 'table', - 'tableColumn', - 'tableRow', - 'text', - ], - action: [ - 'insert', - ], + object: ['pageBreak', 'table', 'tableColumn', 'tableRow', 'text'], + action: ['insert'], }, }, }, @@ -716,25 +599,16 @@ export const documentFields: INodeProperties[] = [ displayName: 'Segment ID', name: 'segmentId', type: 'string', - description: 'The ID of the header, footer or footnote. The Document → Get operation lists all segment IDs (make sure you disable the simple toggle).', + description: + 'The ID of the header, footer or footnote. The Document → Get operation lists all segment IDs (make sure you disable the simple toggle).', default: '', displayOptions: { show: { - object: [ - 'pageBreak', - 'table', - 'tableColumn', - 'tableRow', - 'text', - ], - action: [ - 'insert', - ], + object: ['pageBreak', 'table', 'tableColumn', 'tableRow', 'text'], + action: ['insert'], }, hide: { - insertSegment: [ - 'body', - ], + insertSegment: ['body'], }, }, }, @@ -747,7 +621,8 @@ export const documentFields: INodeProperties[] = [ { name: 'At End of Specific Position', value: 'endOfSegmentLocation', - description: 'Inserts the text at the end of a header, footer, footnote, or document body', + description: + 'Inserts the text at the end of a header, footer, footnote, or document body', }, { name: 'At Index', @@ -758,12 +633,8 @@ export const documentFields: INodeProperties[] = [ default: 'endOfSegmentLocation', displayOptions: { show: { - object: [ - 'pageBreak', - ], - action: [ - 'insert', - ], + object: ['pageBreak'], + action: ['insert'], }, }, }, @@ -774,15 +645,9 @@ export const documentFields: INodeProperties[] = [ description: 'The zero-based index, relative to the beginning of the specified segment', displayOptions: { show: { - locationChoice: [ - 'location', - ], - object: [ - 'pageBreak', - ], - action: [ - 'insert', - ], + locationChoice: ['location'], + object: ['pageBreak'], + action: ['insert'], }, }, typeOptions: { @@ -799,7 +664,8 @@ export const documentFields: INodeProperties[] = [ { name: 'At End of Specific Position', value: 'endOfSegmentLocation', - description: 'Inserts the text at the end of a header, footer, footnote, or document body', + description: + 'Inserts the text at the end of a header, footer, footnote, or document body', }, { name: 'At Index', @@ -810,12 +676,8 @@ export const documentFields: INodeProperties[] = [ default: 'endOfSegmentLocation', displayOptions: { show: { - object: [ - 'table', - ], - action: [ - 'insert', - ], + object: ['table'], + action: ['insert'], }, }, }, @@ -823,18 +685,13 @@ export const documentFields: INodeProperties[] = [ displayName: 'Index', name: 'index', type: 'number', - description: 'The zero-based index, relative to the beginning of the specified segment (use index + 1 to refer to a table)', + description: + 'The zero-based index, relative to the beginning of the specified segment (use index + 1 to refer to a table)', displayOptions: { show: { - locationChoice: [ - 'location', - ], - object: [ - 'table', - ], - action: [ - 'insert', - ], + locationChoice: ['location'], + object: ['table'], + action: ['insert'], }, }, default: 1, @@ -850,12 +707,8 @@ export const documentFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - object: [ - 'table', - ], - action: [ - 'insert', - ], + object: ['table'], + action: ['insert'], }, }, }, @@ -867,12 +720,8 @@ export const documentFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - object: [ - 'table', - ], - action: [ - 'insert', - ], + object: ['table'], + action: ['insert'], }, }, }, @@ -885,7 +734,8 @@ export const documentFields: INodeProperties[] = [ { name: 'At End of Specific Position', value: 'endOfSegmentLocation', - description: 'Inserts the text at the end of a header, footer, footnote, or document body', + description: + 'Inserts the text at the end of a header, footer, footnote, or document body', }, { name: 'At Index', @@ -896,12 +746,8 @@ export const documentFields: INodeProperties[] = [ default: 'endOfSegmentLocation', displayOptions: { show: { - object: [ - 'text', - ], - action: [ - 'insert', - ], + object: ['text'], + action: ['insert'], }, }, }, @@ -915,15 +761,9 @@ export const documentFields: INodeProperties[] = [ description: 'The zero-based index, relative to the beginning of the specified segment', displayOptions: { show: { - locationChoice: [ - 'location', - ], - object: [ - 'text', - ], - action: [ - 'insert', - ], + locationChoice: ['location'], + object: ['text'], + action: ['insert'], }, }, default: 1, @@ -936,12 +776,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - object: [ - 'text', - ], - action: [ - 'insert', - ], + object: ['text'], + action: ['insert'], }, }, }, @@ -954,12 +790,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - object: [ - 'text', - ], - action: [ - 'replaceAll', - ], + object: ['text'], + action: ['replaceAll'], }, }, }, @@ -971,12 +803,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - object: [ - 'text', - ], - action: [ - 'replaceAll', - ], + object: ['text'], + action: ['replaceAll'], }, }, }, @@ -988,12 +816,8 @@ export const documentFields: INodeProperties[] = [ default: false, displayOptions: { show: { - object: [ - 'text', - ], - action: [ - 'replaceAll', - ], + object: ['text'], + action: ['replaceAll'], }, }, }, @@ -1020,14 +844,8 @@ export const documentFields: INodeProperties[] = [ default: 'body', displayOptions: { show: { - object: [ - 'paragraphBullets', - 'tableColumn', - 'tableRow', - ], - action: [ - 'delete', - ], + object: ['paragraphBullets', 'tableColumn', 'tableRow'], + action: ['delete'], }, }, }, @@ -1035,23 +853,16 @@ export const documentFields: INodeProperties[] = [ displayName: 'Segment ID', name: 'segmentId', type: 'string', - description: 'The ID of the header, footer or footnote. The Document → Get operation lists all segment IDs (make sure you disable the simple toggle).', + description: + 'The ID of the header, footer or footnote. The Document → Get operation lists all segment IDs (make sure you disable the simple toggle).', default: '', displayOptions: { show: { - object: [ - 'paragraphBullets', - 'tableColumn', - 'tableRow', - ], - action: [ - 'delete', - ], + object: ['paragraphBullets', 'tableColumn', 'tableRow'], + action: ['delete'], }, hide: { - insertSegment: [ - 'body', - ], + insertSegment: ['body'], }, }, }, @@ -1064,9 +875,7 @@ export const documentFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - object: [ - 'paragraphBullets', - ], + object: ['paragraphBullets'], }, }, }, @@ -1078,9 +887,7 @@ export const documentFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - object: [ - 'paragraphBullets', - ], + object: ['paragraphBullets'], }, }, }, @@ -1102,13 +909,8 @@ export const documentFields: INodeProperties[] = [ default: true, displayOptions: { show: { - object: [ - 'tableColumn', - 'tableRow', - ], - action: [ - 'insert', - ], + object: ['tableColumn', 'tableRow'], + action: ['insert'], }, }, }, @@ -1116,17 +918,15 @@ export const documentFields: INodeProperties[] = [ displayName: 'Index', name: 'index', type: 'number', - description: 'The zero-based index, relative to the beginning of the specified segment (use index + 1 to refer to a table)', + description: + 'The zero-based index, relative to the beginning of the specified segment (use index + 1 to refer to a table)', default: 1, typeOptions: { minValue: 1, }, displayOptions: { show: { - object: [ - 'tableColumn', - 'tableRow', - ], + object: ['tableColumn', 'tableRow'], }, }, }, @@ -1138,10 +938,7 @@ export const documentFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - object: [ - 'tableColumn', - 'tableRow', - ], + object: ['tableColumn', 'tableRow'], }, }, }, @@ -1153,10 +950,7 @@ export const documentFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - object: [ - 'tableColumn', - 'tableRow', - ], + object: ['tableColumn', 'tableRow'], }, }, }, @@ -1172,12 +966,8 @@ export const documentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'document', - ], + operation: ['update'], + resource: ['document'], }, }, options: [ @@ -1193,12 +983,14 @@ export const documentFields: INodeProperties[] = [ { name: 'Target', value: 'targetRevisionId', - description: 'Apply changes to the latest revision. Otherwise changes will not be processed.', + description: + 'Apply changes to the latest revision. Otherwise changes will not be processed.', }, { name: 'Required', value: 'requiredRevisionId', - description: 'Apply changes to the provided revision while incorporating other collaborators\' changes. This mode is used for the recent revision, Otherwise changes will not be processed.', + description: + "Apply changes to the provided revision while incorporating other collaborators' changes. This mode is used for the recent revision, Otherwise changes will not be processed.", }, ], default: 'requiredRevisionId', diff --git a/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts index 667730fce6..ef09d6051b 100644 --- a/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts @@ -1,17 +1,8 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; import moment from 'moment-timezone'; @@ -32,7 +23,11 @@ export async function googleApiRequest( qs?: IDataObject, uri?: string, ) { - const authenticationMethod = this.getNodeParameter('authentication', 0, 'serviceAccount') as string; + const authenticationMethod = this.getNodeParameter( + 'authentication', + 0, + 'serviceAccount', + ) as string; const options: OptionsWithUri = { headers: { @@ -49,11 +44,13 @@ export async function googleApiRequest( delete options.body; } try { - if (authenticationMethod === 'serviceAccount') { const credentials = await this.getCredentials('googleApi'); - const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials); + const { access_token } = await getAccessToken.call( + this, + credentials as unknown as IGoogleAuthCredentials, + ); options.headers!.Authorization = `Bearer ${access_token}`; return await this.helpers.request!(options); @@ -66,8 +63,16 @@ export async function googleApiRequest( } } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: IDataObject = {}, qs?: IDataObject, uri?: string): Promise { // tslint:disable-line:no-any - +export async function googleApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + body: IDataObject = {}, + qs?: IDataObject, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -79,15 +84,15 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp responseData = await googleApiRequest.call(this, method, endpoint, body, query, uri); query.pageToken = responseData['nextPageToken']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['nextPageToken'] !== undefined && - responseData['nextPageToken'] !== '' - ); + } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); return returnData; } -function getAccessToken(this: IExecuteFunctions | ILoadOptionsFunctions, credentials: IGoogleAuthCredentials): Promise { +function getAccessToken( + this: IExecuteFunctions | ILoadOptionsFunctions, + credentials: IGoogleAuthCredentials, +): Promise { //https://developers.google.com/identity/protocols/oauth2/service-account#httprest const scopes = [ @@ -103,20 +108,20 @@ function getAccessToken(this: IExecuteFunctions | ILoadOptionsFunctions, credent const signature = jwt.sign( { - 'iss': credentials.email as string, - 'sub': credentials.delegatedEmail || credentials.email as string, - 'scope': scopes.join(' '), - 'aud': `https://oauth2.googleapis.com/token`, - 'iat': now, - 'exp': now + 3600, + iss: credentials.email as string, + sub: credentials.delegatedEmail || (credentials.email as string), + scope: scopes.join(' '), + aud: `https://oauth2.googleapis.com/token`, + iat: now, + exp: now + 3600, }, privateKey as string, { algorithm: 'RS256', header: { - 'kid': privateKey as string, - 'typ': 'JWT', - 'alg': 'RS256', + kid: privateKey as string, + typ: 'JWT', + alg: 'RS256', }, }, ); diff --git a/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts b/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts index d248c492b7..76900d120f 100644 --- a/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts +++ b/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts @@ -1,7 +1,4 @@ -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject, @@ -20,15 +17,9 @@ import { upperFirst, } from './GenericFunctions'; -import { - documentFields, - documentOperations, -} from './DocumentDescription'; +import { documentFields, documentOperations } from './DocumentDescription'; -import { - IUpdateBody, - IUpdateFields, -} from './interfaces'; +import { IUpdateBody, IUpdateFields } from './interfaces'; export class GoogleDocs implements INodeType { description: INodeTypeDescription = { @@ -50,9 +41,7 @@ export class GoogleDocs implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'serviceAccount', - ], + authentication: ['serviceAccount'], }, }, }, @@ -61,9 +50,7 @@ export class GoogleDocs implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -86,9 +73,7 @@ export class GoogleDocs implements INodeType { default: 'serviceAccount', displayOptions: { show: { - '@version': [ - 1, - ], + '@version': [1], }, }, }, @@ -109,9 +94,7 @@ export class GoogleDocs implements INodeType { default: 'oAuth2', displayOptions: { show: { - '@version': [ - 2, - ], + '@version': [2], }, }, }, @@ -149,7 +132,15 @@ export class GoogleDocs implements INodeType { ]; let drives; try { - drives = await googleApiRequestAllItems.call(this, 'drives', 'GET', '', {}, {}, 'https://www.googleapis.com/drive/v3/drives'); + drives = await googleApiRequestAllItems.call( + this, + 'drives', + 'GET', + '', + {}, + {}, + 'https://www.googleapis.com/drive/v3/drives', + ); } catch (error) { throw new NodeApiError(this.getNode(), error, { message: 'Error in loading Drives' }); } @@ -172,13 +163,23 @@ export class GoogleDocs implements INodeType { const driveId = this.getNodeParameter('driveId'); const qs = { - q: `mimeType = \'application/vnd.google-apps.folder\' ${driveId === 'sharedWithMe' ? 'and sharedWithMe = true' : ' and \'root\' in parents'}`, - ...(driveId && driveId !== 'myDrive' && driveId !== 'sharedWithMe') ? { driveId } : {}, + q: `mimeType = \'application/vnd.google-apps.folder\' ${ + driveId === 'sharedWithMe' ? 'and sharedWithMe = true' : " and 'root' in parents" + }`, + ...(driveId && driveId !== 'myDrive' && driveId !== 'sharedWithMe' ? { driveId } : {}), }; let folders; try { - folders = await googleApiRequestAllItems.call(this, 'files', 'GET', '', {}, qs, 'https://www.googleapis.com/drive/v3/files'); + folders = await googleApiRequestAllItems.call( + this, + 'files', + 'GET', + '', + {}, + qs, + 'https://www.googleapis.com/drive/v3/files', + ); } catch (error) { throw new NodeApiError(this.getNode(), error, { message: 'Error in loading Folders' }); } @@ -204,13 +205,9 @@ export class GoogleDocs implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < length; i++) { - try { - if (resource === 'document') { - if (operation === 'create') { - // https://developers.google.com/docs/api/reference/rest/v1/documents/create const folderId = this.getNodeParameter('folderId', i) as string; @@ -218,13 +215,18 @@ export class GoogleDocs implements INodeType { const body: IDataObject = { name: this.getNodeParameter('title', i) as string, mimeType: 'application/vnd.google-apps.document', - ...(folderId && folderId !== 'default') ? { parents: [folderId] } : {}, + ...(folderId && folderId !== 'default' ? { parents: [folderId] } : {}), }; - responseData = await googleApiRequest.call(this, 'POST', '', body, {}, 'https://www.googleapis.com/drive/v3/files'); - + responseData = await googleApiRequest.call( + this, + 'POST', + '', + body, + {}, + 'https://www.googleapis.com/drive/v3/files', + ); } else if (operation === 'get') { - // https://developers.google.com/docs/api/reference/rest/v1/documents/get const documentURL = this.getNodeParameter('documentURL', i) as string; @@ -236,16 +238,16 @@ export class GoogleDocs implements INodeType { } responseData = await googleApiRequest.call(this, 'GET', `/documents/${documentId}`); if (simple) { - const content = (responseData.body.content as IDataObject[]) .reduce((arr: string[], contentItem) => { if (contentItem && contentItem.paragraph) { - const texts = ((contentItem.paragraph as IDataObject).elements as IDataObject[]) - .map(element => { - if (element && element.textRun) { - return (element.textRun as IDataObject).content as string; - } - }) as string[]; + const texts = ( + (contentItem.paragraph as IDataObject).elements as IDataObject[] + ).map((element) => { + if (element && element.textRun) { + return (element.textRun as IDataObject).content as string; + } + }) as string[]; arr = [...arr, ...texts]; } return arr; @@ -256,20 +258,20 @@ export class GoogleDocs implements INodeType { documentId, content, }; - } - } else if (operation === 'update') { - // https://developers.google.com/docs/api/reference/rest/v1/documents/batchUpdate const documentURL = this.getNodeParameter('documentURL', i) as string; let documentId = extractID(documentURL); const simple = this.getNodeParameter('simple', i) as boolean; const actionsUi = this.getNodeParameter('actionsUi', i) as { - actionFields: IDataObject[] + actionFields: IDataObject[]; }; - const { writeControlObject } = this.getNodeParameter('updateFields', i) as IUpdateFields; + const { writeControlObject } = this.getNodeParameter( + 'updateFields', + i, + ) as IUpdateFields; if (!documentId) { documentId = documentURL; @@ -287,9 +289,8 @@ export class GoogleDocs implements INodeType { } if (actionsUi) { - let requestBody: IDataObject; - actionsUi.actionFields.forEach(actionField => { + actionsUi.actionFields.forEach((actionField) => { const { action, object } = actionField; if (object === 'positionedObject') { if (action === 'delete') { @@ -297,42 +298,37 @@ export class GoogleDocs implements INodeType { objectId: actionField.objectId, }; } - } else if (object === 'pageBreak') { - if (action === 'insert') { const { insertSegment, segmentId, locationChoice, index } = actionField; requestBody = { [locationChoice as string]: { - segmentId: (insertSegment !== 'body') ? segmentId : '', - ...(locationChoice === 'location') ? { index } : {}, + segmentId: insertSegment !== 'body' ? segmentId : '', + ...(locationChoice === 'location' ? { index } : {}), }, }; } - } else if (object === 'table') { - if (action === 'insert') { - const { rows, columns, insertSegment, locationChoice, segmentId, index } = actionField; + const { rows, columns, insertSegment, locationChoice, segmentId, index } = + actionField; requestBody = { rows, columns, [locationChoice as string]: { - segmentId: (insertSegment !== 'body') ? segmentId : '', - ...(locationChoice === 'location') ? { index } : {}, + segmentId: insertSegment !== 'body' ? segmentId : '', + ...(locationChoice === 'location' ? { index } : {}), }, }; } - } else if (object === 'footer') { - if (action === 'create') { const { insertSegment, locationChoice, segmentId, index } = actionField; requestBody = { type: 'DEFAULT', sectionBreakLocation: { - segmentId: (insertSegment !== 'body') ? segmentId : '', - ...(locationChoice === 'location') ? { index } : {}, + segmentId: insertSegment !== 'body' ? segmentId : '', + ...(locationChoice === 'location' ? { index } : {}), }, }; } else if (action === 'delete') { @@ -340,16 +336,14 @@ export class GoogleDocs implements INodeType { footerId: actionField.footerId, }; } - } else if (object === 'header') { - if (action === 'create') { const { insertSegment, locationChoice, segmentId, index } = actionField; requestBody = { type: 'DEFAULT', sectionBreakLocation: { - segmentId: (insertSegment !== 'body') ? segmentId : '', - ...(locationChoice === 'location') ? { index } : {}, + segmentId: insertSegment !== 'body' ? segmentId : '', + ...(locationChoice === 'location' ? { index } : {}), }, }; } else if (action === 'delete') { @@ -357,17 +351,25 @@ export class GoogleDocs implements INodeType { headerId: actionField.headerId, }; } - } else if (object === 'tableColumn') { - if (action === 'insert') { - const { insertPosition, rowIndex, columnIndex, insertSegment, segmentId, index } = actionField; + const { + insertPosition, + rowIndex, + columnIndex, + insertSegment, + segmentId, + index, + } = actionField; requestBody = { insertRight: insertPosition, tableCellLocation: { rowIndex, columnIndex, - tableStartLocation: { segmentId: (insertSegment !== 'body') ? segmentId : '', index, }, + tableStartLocation: { + segmentId: insertSegment !== 'body' ? segmentId : '', + index, + }, }, }; } else if (action === 'delete') { @@ -376,21 +378,32 @@ export class GoogleDocs implements INodeType { tableCellLocation: { rowIndex, columnIndex, - tableStartLocation: { segmentId: (insertSegment !== 'body') ? segmentId : '', index, }, + tableStartLocation: { + segmentId: insertSegment !== 'body' ? segmentId : '', + index, + }, }, }; } - } else if (object === 'tableRow') { - if (action === 'insert') { - const { insertPosition, rowIndex, columnIndex, insertSegment, segmentId, index } = actionField; + const { + insertPosition, + rowIndex, + columnIndex, + insertSegment, + segmentId, + index, + } = actionField; requestBody = { insertBelow: insertPosition, tableCellLocation: { rowIndex, columnIndex, - tableStartLocation: { segmentId: (insertSegment !== 'body') ? segmentId : '', index, }, + tableStartLocation: { + segmentId: insertSegment !== 'body' ? segmentId : '', + index, + }, }, }; } else if (action === 'delete') { @@ -399,20 +412,21 @@ export class GoogleDocs implements INodeType { tableCellLocation: { rowIndex, columnIndex, - tableStartLocation: { segmentId: (insertSegment !== 'body') ? segmentId : '', index, }, + tableStartLocation: { + segmentId: insertSegment !== 'body' ? segmentId : '', + index, + }, }, }; } - } else if (object === 'text') { - if (action === 'insert') { const { text, locationChoice, insertSegment, segmentId, index } = actionField; requestBody = { text, [locationChoice as string]: { - segmentId: (insertSegment !== 'body') ? segmentId : '', - ...(locationChoice === 'location') ? { index } : {}, + segmentId: insertSegment !== 'body' ? segmentId : '', + ...(locationChoice === 'location' ? { index } : {}), }, }; } else if (action === 'replaceAll') { @@ -422,18 +436,26 @@ export class GoogleDocs implements INodeType { containsText: { text, matchCase }, }; } - } else if (object === 'paragraphBullets') { if (action === 'create') { - const { bulletPreset, startIndex, insertSegment, segmentId, endIndex } = actionField; + const { bulletPreset, startIndex, insertSegment, segmentId, endIndex } = + actionField; requestBody = { bulletPreset, - range: { segmentId: (insertSegment !== 'body') ? segmentId : '', startIndex, endIndex }, + range: { + segmentId: insertSegment !== 'body' ? segmentId : '', + startIndex, + endIndex, + }, }; } else if (action === 'delete') { const { startIndex, insertSegment, segmentId, endIndex } = actionField; requestBody = { - range: { segmentId: (insertSegment !== 'body') ? segmentId : '', startIndex, endIndex }, + range: { + segmentId: insertSegment !== 'body' ? segmentId : '', + startIndex, + endIndex, + }, }; } } else if (object === 'namedRange') { @@ -441,7 +463,11 @@ export class GoogleDocs implements INodeType { const { name, insertSegment, segmentId, startIndex, endIndex } = actionField; requestBody = { name, - range: { segmentId: (insertSegment !== 'body') ? segmentId : '', startIndex, endIndex }, + range: { + segmentId: insertSegment !== 'body' ? segmentId : '', + startIndex, + endIndex, + }, }; } else if (action === 'delete') { const { namedRangeReference, value } = actionField; @@ -454,11 +480,15 @@ export class GoogleDocs implements INodeType { body.requests.push({ [`${action}${upperFirst(object as string)}`]: requestBody, }); - }); } - responseData = await googleApiRequest.call(this, 'POST', `/documents/${documentId}:batchUpdate`, body); + responseData = await googleApiRequest.call( + this, + 'POST', + `/documents/${documentId}:batchUpdate`, + body, + ); if (simple === true) { if (Object.keys(responseData.replies[0]).length !== 0) { @@ -471,7 +501,6 @@ export class GoogleDocs implements INodeType { responseData.documentId = documentId; } } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/Google/Docs/interfaces.d.ts b/packages/nodes-base/nodes/Google/Docs/interfaces.d.ts index e1a3616e00..a87d3c76d1 100644 --- a/packages/nodes-base/nodes/Google/Docs/interfaces.d.ts +++ b/packages/nodes-base/nodes/Google/Docs/interfaces.d.ts @@ -7,7 +7,7 @@ export interface IUpdateBody extends IDataObject { export interface IUpdateFields { writeControlObject: { - control: string, - value: string, + control: string; + value: string; }; } diff --git a/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts index 9f18b7436c..9e07bee5f9 100644 --- a/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts @@ -1,19 +1,8 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - IPollFunctions, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, IPollFunctions, NodeApiError, NodeOperationError } from 'n8n-workflow'; import moment from 'moment-timezone'; @@ -26,8 +15,22 @@ interface IGoogleAuthCredentials { privateKey: string; } -export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IPollFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any - const authenticationMethod = this.getNodeParameter('authentication', 0, 'serviceAccount') as string; +export async function googleApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IPollFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { + const authenticationMethod = this.getNodeParameter( + 'authentication', + 0, + 'serviceAccount', + ) as string; let options: OptionsWithUri = { headers: { @@ -50,7 +53,10 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF if (authenticationMethod === 'serviceAccount') { const credentials = await this.getCredentials('googleApi'); - const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials); + const { access_token } = await getAccessToken.call( + this, + credentials as unknown as IGoogleAuthCredentials, + ); options.headers!.Authorization = `Bearer ${access_token}`; return await this.helpers.request!(options); @@ -67,8 +73,16 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function googleApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -78,15 +92,15 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['nextPageToken'] !== undefined && - responseData['nextPageToken'] !== '' - ); + } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); return returnData; } -function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IPollFunctions, credentials: IGoogleAuthCredentials): Promise { +function getAccessToken( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IPollFunctions, + credentials: IGoogleAuthCredentials, +): Promise { //https://developers.google.com/identity/protocols/oauth2/service-account#httprest const scopes = [ @@ -102,20 +116,20 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa const signature = jwt.sign( { - 'iss': credentials.email as string, - 'sub': credentials.delegatedEmail || credentials.email as string, - 'scope': scopes.join(' '), - 'aud': `https://oauth2.googleapis.com/token`, - 'iat': now, - 'exp': now + 3600, + iss: credentials.email as string, + sub: credentials.delegatedEmail || (credentials.email as string), + scope: scopes.join(' '), + aud: `https://oauth2.googleapis.com/token`, + iat: now, + exp: now + 3600, }, privateKey as string, { algorithm: 'RS256', header: { - 'kid': privateKey as string, - 'typ': 'JWT', - 'alg': 'RS256', + kid: privateKey as string, + typ: 'JWT', + alg: 'RS256', }, }, ); diff --git a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts index 1b4619bc43..1aeef25646 100644 --- a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts +++ b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts @@ -8,10 +8,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - googleApiRequest, - googleApiRequestAllItems, -} from './GenericFunctions'; +import { googleApiRequest, googleApiRequestAllItems } from './GenericFunctions'; import { v4 as uuid } from 'uuid'; @@ -35,9 +32,7 @@ export class GoogleDrive implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'serviceAccount', - ], + authentication: ['serviceAccount'], }, }, }, @@ -46,9 +41,7 @@ export class GoogleDrive implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -71,9 +64,7 @@ export class GoogleDrive implements INodeType { default: 'serviceAccount', displayOptions: { show: { - '@version': [ - 1, - ], + '@version': [1], }, }, }, @@ -94,9 +85,7 @@ export class GoogleDrive implements INodeType { default: 'oAuth2', displayOptions: { show: { - '@version': [ - 2, - ], + '@version': [2], }, }, }, @@ -122,7 +111,6 @@ export class GoogleDrive implements INodeType { default: 'file', }, - // ---------------------------------- // operations // ---------------------------------- @@ -133,9 +121,7 @@ export class GoogleDrive implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'file', - ], + resource: ['file'], }, }, options: [ @@ -192,9 +178,7 @@ export class GoogleDrive implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'folder', - ], + resource: ['folder'], }, }, options: [ @@ -220,7 +204,6 @@ export class GoogleDrive implements INodeType { default: 'create', }, - // ---------------------------------- // file // ---------------------------------- @@ -236,12 +219,8 @@ export class GoogleDrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'copy', - ], - resource: [ - 'file', - ], + operation: ['copy'], + resource: ['file'], }, }, description: 'The ID of the file to copy', @@ -258,19 +237,13 @@ export class GoogleDrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'file', - 'folder', - ], + operation: ['delete'], + resource: ['file', 'folder'], }, }, description: 'The ID of the file/folder to delete', }, - // ---------------------------------- // file:download // ---------------------------------- @@ -282,12 +255,8 @@ export class GoogleDrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'file', - ], + operation: ['download'], + resource: ['file'], }, }, description: 'The ID of the file to download', @@ -300,12 +269,8 @@ export class GoogleDrive implements INodeType { default: 'data', displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'file', - ], + operation: ['download'], + resource: ['file'], }, }, description: 'Name of the binary property to which to write the data of the read file', @@ -318,12 +283,8 @@ export class GoogleDrive implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'file', - ], + operation: ['download'], + resource: ['file'], }, }, options: [ @@ -352,7 +313,8 @@ export class GoogleDrive implements INodeType { }, { name: 'To MS Word', - value: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + value: + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', }, { name: 'To OpenOffice Doc', @@ -367,7 +329,8 @@ export class GoogleDrive implements INodeType { value: 'application/rtf', }, ], - default: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + default: + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', description: 'Format used to export when downloading Google Docs files', }, { @@ -402,7 +365,8 @@ export class GoogleDrive implements INodeType { options: [ { name: 'To MS PowerPoint', - value: 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + value: + 'application/vnd.openxmlformats-officedocument.presentationml.presentation', }, { name: 'To PDF', @@ -417,7 +381,8 @@ export class GoogleDrive implements INodeType { value: 'text/plain', }, ], - default: 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + default: + 'application/vnd.openxmlformats-officedocument.presentationml.presentation', description: 'Format used to export when downloading Google Slides files', }, { @@ -455,7 +420,6 @@ export class GoogleDrive implements INodeType { ], }, - // ---------------------------------- // file:list // ---------------------------------- @@ -466,12 +430,8 @@ export class GoogleDrive implements INodeType { default: false, displayOptions: { show: { - operation: [ - 'list', - ], - resource: [ - 'file', - ], + operation: ['list'], + resource: ['file'], }, }, description: 'Whether a query string should be used to filter results', @@ -483,18 +443,12 @@ export class GoogleDrive implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'list', - ], - useQueryString: [ - true, - ], - resource: [ - 'file', - ], + operation: ['list'], + useQueryString: [true], + resource: ['file'], }, }, - placeholder: 'name contains \'invoice\'', + placeholder: "name contains 'invoice'", description: 'Query to use to return only specific files', }, { @@ -503,12 +457,8 @@ export class GoogleDrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'list', - ], - resource: [ - 'file', - ], + operation: ['list'], + resource: ['file'], }, }, typeOptions: { @@ -530,15 +480,9 @@ export class GoogleDrive implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'list', - ], - useQueryString: [ - false, - ], - resource: [ - 'file', - ], + operation: ['list'], + useQueryString: [false], + resource: ['file'], }, }, options: [ @@ -564,7 +508,6 @@ export class GoogleDrive implements INodeType { name: 'Is Not', value: 'isNot', }, - ], default: 'contains', }, @@ -665,9 +608,7 @@ export class GoogleDrive implements INodeType { default: '', displayOptions: { show: { - mimeType: [ - 'custom', - ], + mimeType: ['custom'], }, }, }, @@ -676,7 +617,6 @@ export class GoogleDrive implements INodeType { ], }, - // ---------------------------------- // file:share // ---------------------------------- @@ -688,13 +628,8 @@ export class GoogleDrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'file', - 'folder', - ], + operation: ['share'], + resource: ['file', 'folder'], }, }, description: 'The ID of the file or shared drive', @@ -710,13 +645,8 @@ export class GoogleDrive implements INodeType { }, displayOptions: { show: { - resource: [ - 'file', - 'folder', - ], - operation: [ - 'share', - ], + resource: ['file', 'folder'], + operation: ['share'], }, }, options: [ @@ -779,7 +709,8 @@ export class GoogleDrive implements INodeType { }, ], default: '', - description: 'Information about the different types can be found here', + description: + 'Information about the different types can be found here', }, { displayName: 'Email Address', @@ -787,14 +718,12 @@ export class GoogleDrive implements INodeType { type: 'string', displayOptions: { show: { - type: [ - 'user', - 'group', - ], + type: ['user', 'group'], }, }, default: '', - description: 'The email address of the user or group to which this permission refers', + description: + 'The email address of the user or group to which this permission refers', }, { displayName: 'Domain', @@ -802,9 +731,7 @@ export class GoogleDrive implements INodeType { type: 'string', displayOptions: { show: { - type: [ - 'domain', - ], + type: ['domain'], }, }, default: '', @@ -816,14 +743,12 @@ export class GoogleDrive implements INodeType { type: 'boolean', displayOptions: { show: { - type: [ - 'domain', - 'anyone', - ], + type: ['domain', 'anyone'], }, }, default: false, - description: 'Whether the permission allows the file to be discovered through search', + description: + 'Whether the permission allows the file to be discovered through search', }, ], }, @@ -837,12 +762,8 @@ export class GoogleDrive implements INodeType { default: false, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, description: 'Whether the data to upload should be taken from binary field', @@ -854,17 +775,10 @@ export class GoogleDrive implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], - binaryData: [ - false, - ], + operation: ['upload'], + resource: ['file'], + binaryData: [false], }, - }, placeholder: '', description: 'The text content of the file to upload', @@ -877,20 +791,14 @@ export class GoogleDrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], - binaryData: [ - true, - ], + operation: ['upload'], + resource: ['file'], + binaryData: [true], }, - }, placeholder: '', - description: 'Name of the binary property which contains the data for the file to be uploaded', + description: + 'Name of the binary property which contains the data for the file to be uploaded', }, // ---------------------------------- @@ -904,12 +812,8 @@ export class GoogleDrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'file', - ], + operation: ['update'], + resource: ['file'], }, }, description: 'The ID of the file to update', @@ -922,12 +826,8 @@ export class GoogleDrive implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'file', - ], + operation: ['update'], + resource: ['file'], }, }, options: [ @@ -943,7 +843,8 @@ export class GoogleDrive implements INodeType { name: 'keepRevisionForever', type: 'boolean', default: false, - description: 'Whether to set the \'keepForever\' field in the new head revision. This is only applicable to files with binary content in Google Drive. Only 200 revisions for the file can be kept forever. If the limit is reached, try deleting pinned revisions.', + description: + "Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Google Drive. Only 200 revisions for the file can be kept forever. If the limit is reached, try deleting pinned revisions.", }, { displayName: 'Move to Trash', @@ -983,12 +884,8 @@ export class GoogleDrive implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'file', - ], + operation: ['update'], + resource: ['file'], }, }, options: [ @@ -1083,12 +980,8 @@ export class GoogleDrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, placeholder: 'invoice_1.pdf', @@ -1102,16 +995,13 @@ export class GoogleDrive implements INodeType { default: false, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default the response only contain the ID of the file. If this option gets activated, it will resolve the data automatically.', + description: + 'By default the response only contain the ID of the file. If this option gets activated, it will resolve the data automatically.', }, { displayName: 'Parents', @@ -1123,12 +1013,8 @@ export class GoogleDrive implements INodeType { default: [], displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, description: 'The IDs of the parent folders which contain the file', @@ -1149,12 +1035,8 @@ export class GoogleDrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'folder', - ], + operation: ['create'], + resource: ['folder'], }, }, placeholder: 'invoices', @@ -1168,16 +1050,8 @@ export class GoogleDrive implements INodeType { default: {}, displayOptions: { show: { - '/operation': [ - 'copy', - 'list', - 'share', - 'create', - ], - '/resource': [ - 'file', - 'folder', - ], + '/operation': ['copy', 'list', 'share', 'create'], + '/resource': ['file', 'folder'], }, }, options: [ @@ -1187,13 +1061,8 @@ export class GoogleDrive implements INodeType { type: 'string', displayOptions: { show: { - '/operation': [ - 'share', - ], - '/resource': [ - 'file', - 'folder', - ], + '/operation': ['share'], + '/resource': ['file', 'folder'], }, }, default: '', @@ -1205,17 +1074,13 @@ export class GoogleDrive implements INodeType { type: 'boolean', displayOptions: { show: { - '/operation': [ - 'share', - ], - '/resource': [ - 'file', - 'folder', - ], + '/operation': ['share'], + '/resource': ['file', 'folder'], }, }, default: false, - description: 'Whether to opt in to API behavior that aims for all items to have exactly one parent. This parameter only takes effect if the item is not in a shared drive.', + description: + 'Whether to opt in to API behavior that aims for all items to have exactly one parent. This parameter only takes effect if the item is not in a shared drive.', }, { displayName: 'Fields', @@ -1223,10 +1088,7 @@ export class GoogleDrive implements INodeType { type: 'multiOptions', displayOptions: { show: { - '/operation': [ - 'list', - 'copy', - ], + '/operation': ['list', 'copy'], }, }, options: [ @@ -1309,18 +1171,14 @@ export class GoogleDrive implements INodeType { type: 'boolean', displayOptions: { show: { - '/operation': [ - 'share', - ], - '/resource': [ - 'file', - 'folder', - ], + '/operation': ['share'], + '/resource': ['file', 'folder'], }, }, default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: '

This parameter only takes effect if the item is not in a shared drive and the request is attempting to transfer the ownership of the item.

When set to true, the item is moved to the new owner\'s My Drive root folder and all prior parents removed.

', + description: + "

This parameter only takes effect if the item is not in a shared drive and the request is attempting to transfer the ownership of the item.

When set to true, the item is moved to the new owner's My Drive root folder and all prior parents removed.

", }, { displayName: 'Send Notification Email', @@ -1328,13 +1186,8 @@ export class GoogleDrive implements INodeType { type: 'boolean', displayOptions: { show: { - '/operation': [ - 'share', - ], - '/resource': [ - 'file', - 'folder', - ], + '/operation': ['share'], + '/resource': ['file', 'folder'], }, }, default: false, @@ -1346,17 +1199,13 @@ export class GoogleDrive implements INodeType { type: 'boolean', displayOptions: { show: { - '/operation': [ - 'share', - ], - '/resource': [ - 'file', - 'folder', - ], + '/operation': ['share'], + '/resource': ['file', 'folder'], }, }, default: false, - description: 'Whether the requesting application supports both My Drives and shared drives', + description: + 'Whether the requesting application supports both My Drives and shared drives', }, { displayName: 'Transfer Ownership', @@ -1364,17 +1213,13 @@ export class GoogleDrive implements INodeType { type: 'boolean', displayOptions: { show: { - '/operation': [ - 'share', - ], - '/resource': [ - 'file', - 'folder', - ], + '/operation': ['share'], + '/resource': ['file', 'folder'], }, }, default: false, - description: 'Whether to transfer ownership to the specified user and downgrade the current owner to a writer', + description: + 'Whether to transfer ownership to the specified user and downgrade the current owner to a writer', }, { displayName: 'Use Domain Admin Access', @@ -1382,17 +1227,13 @@ export class GoogleDrive implements INodeType { type: 'boolean', displayOptions: { show: { - '/operation': [ - 'share', - ], - '/resource': [ - 'file', - 'folder', - ], + '/operation': ['share'], + '/resource': ['file', 'folder'], }, }, default: false, - description: 'Whether to perform the operation as domain administrator, i.e. if you are an administrator of the domain to which the shared drive belongs, you will be granted access automatically.', + description: + 'Whether to perform the operation as domain administrator, i.e. if you are an administrator of the domain to which the shared drive belongs, you will be granted access automatically.', }, { @@ -1401,12 +1242,8 @@ export class GoogleDrive implements INodeType { type: 'string', displayOptions: { show: { - '/operation': [ - 'copy', - ], - '/resource': [ - 'file', - ], + '/operation': ['copy'], + '/resource': ['file'], }, }, default: '', @@ -1419,14 +1256,8 @@ export class GoogleDrive implements INodeType { type: 'string', displayOptions: { show: { - '/operation': [ - 'copy', - 'create', - ], - '/resource': [ - 'file', - 'folder', - ], + '/operation': ['copy', 'create'], + '/resource': ['file', 'folder'], }, }, typeOptions: { @@ -1441,12 +1272,8 @@ export class GoogleDrive implements INodeType { type: 'multiOptions', displayOptions: { show: { - '/operation': [ - 'list', - ], - '/resource': [ - 'file', - ], + '/operation': ['list'], + '/resource': ['file'], }, }, options: [ @@ -1477,12 +1304,8 @@ export class GoogleDrive implements INodeType { type: 'options', displayOptions: { show: { - '/operation': [ - 'list', - ], - '/resource': [ - 'file', - ], + '/operation': ['list'], + '/resource': ['file'], }, }, options: [ @@ -1494,7 +1317,7 @@ export class GoogleDrive implements INodeType { { name: 'Domain', value: 'domain', - description: 'All files shared to the user\'s domain that are searchable', + description: "All files shared to the user's domain that are searchable", }, { name: 'Drive', @@ -1517,18 +1340,13 @@ export class GoogleDrive implements INodeType { default: '', displayOptions: { show: { - '/operation': [ - 'list', - ], - '/resource': [ - 'file', - ], - corpora: [ - 'drive', - ], + '/operation': ['list'], + '/resource': ['file'], + corpora: ['drive'], }, }, - description: 'ID of the shared drive to search. The driveId parameter must be specified if and only if corpora is set to drive.', + description: + 'ID of the shared drive to search. The driveId parameter must be specified if and only if corpora is set to drive.', }, ], }, @@ -1542,9 +1360,7 @@ export class GoogleDrive implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'drive', - ], + resource: ['drive'], }, }, options: [ @@ -1591,12 +1407,8 @@ export class GoogleDrive implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'drive', - ], + operation: ['create'], + resource: ['drive'], }, }, description: 'The name of this shared drive', @@ -1609,12 +1421,8 @@ export class GoogleDrive implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'drive', - ], + operation: ['create'], + resource: ['drive'], }, }, options: [ @@ -1630,35 +1438,40 @@ export class GoogleDrive implements INodeType { name: 'canAddChildren', type: 'boolean', default: false, - description: 'Whether the current user can add children to folders in this shared drive', + description: + 'Whether the current user can add children to folders in this shared drive', }, { displayName: 'Can Change Copy Requires Writer Permission Restriction', name: 'canChangeCopyRequiresWriterPermissionRestriction', type: 'boolean', default: false, - description: 'Whether the current user can change the copyRequiresWriterPermission restriction of this shared drive', + description: + 'Whether the current user can change the copyRequiresWriterPermission restriction of this shared drive', }, { displayName: 'Can Change Domain Users Only Restriction', name: 'canChangeDomainUsersOnlyRestriction', type: 'boolean', default: false, - description: 'Whether the current user can change the domainUsersOnly restriction of this shared drive', + description: + 'Whether the current user can change the domainUsersOnly restriction of this shared drive', }, { displayName: 'Can Change Drive Background', name: 'canChangeDriveBackground', type: 'boolean', default: false, - description: 'Whether the current user can change the background of this shared drive', + description: + 'Whether the current user can change the background of this shared drive', }, { displayName: 'Can Change Drive Members Only Restriction', name: 'canChangeDriveMembersOnlyRestriction', type: 'boolean', default: false, - description: 'Whether the current user can change the driveMembersOnly restriction of this shared drive', + description: + 'Whether the current user can change the driveMembersOnly restriction of this shared drive', }, { displayName: 'Can Comment', @@ -1679,14 +1492,16 @@ export class GoogleDrive implements INodeType { name: 'canDeleteChildren', type: 'boolean', default: false, - description: 'Whether the current user can delete children from folders in this shared drive', + description: + 'Whether the current user can delete children from folders in this shared drive', }, { displayName: 'Can Delete Drive', name: 'canDeleteDrive', type: 'boolean', default: false, - description: 'Whether the current user can delete this shared drive. Attempting to delete the shared drive may still fail if there are untrashed items inside the shared drive.', + description: + 'Whether the current user can delete this shared drive. Attempting to delete the shared drive may still fail if there are untrashed items inside the shared drive.', }, { displayName: 'Can Download', @@ -1707,28 +1522,32 @@ export class GoogleDrive implements INodeType { name: 'canListChildren', type: 'boolean', default: false, - description: 'Whether the current user can list the children of folders in this shared drive', + description: + 'Whether the current user can list the children of folders in this shared drive', }, { displayName: 'Can Manage Members', name: 'canManageMembers', type: 'boolean', default: false, - description: 'Whether the current user can add members to this shared drive or remove them or change their role', + description: + 'Whether the current user can add members to this shared drive or remove them or change their role', }, { displayName: 'Can Read Revisions', name: 'canReadRevisions', type: 'boolean', default: false, - description: 'Whether the current user can read the revisions resource of files in this shared drive', + description: + 'Whether the current user can read the revisions resource of files in this shared drive', }, { displayName: 'Can Rename', name: 'canRename', type: 'boolean', default: false, - description: 'Whether the current user can rename files or folders in this shared drive', + description: + 'Whether the current user can rename files or folders in this shared drive', }, { displayName: 'Can Rename Drive', @@ -1749,7 +1568,8 @@ export class GoogleDrive implements INodeType { name: 'canTrashChildren', type: 'boolean', default: false, - description: 'Whether the current user can trash children from folders in this shared drive', + description: + 'Whether the current user can trash children from folders in this shared drive', }, ], }, @@ -1786,28 +1606,32 @@ export class GoogleDrive implements INodeType { name: 'adminManagedRestrictions', type: 'boolean', default: false, - description: 'Whether the options to copy, print, or download files inside this shared drive, should be disabled for readers and commenters. When this restriction is set to true, it will override the similarly named field to true for any file inside this shared drive.', + description: + 'Whether the options to copy, print, or download files inside this shared drive, should be disabled for readers and commenters. When this restriction is set to true, it will override the similarly named field to true for any file inside this shared drive.', }, { displayName: 'Copy Requires Writer Permission', name: 'copyRequiresWriterPermission', type: 'boolean', default: false, - description: 'Whether the options to copy, print, or download files inside this shared drive, should be disabled for readers and commenters. When this restriction is set to true, it will override the similarly named field to true for any file inside this shared drive.', + description: + 'Whether the options to copy, print, or download files inside this shared drive, should be disabled for readers and commenters. When this restriction is set to true, it will override the similarly named field to true for any file inside this shared drive.', }, { displayName: 'Domain Users Only', name: 'domainUsersOnly', type: 'boolean', default: false, - description: 'Whether access to this shared drive and items inside this shared drive is restricted to users of the domain to which this shared drive belongs. This restriction may be overridden by other sharing policies controlled outside of this shared drive.', + description: + 'Whether access to this shared drive and items inside this shared drive is restricted to users of the domain to which this shared drive belongs. This restriction may be overridden by other sharing policies controlled outside of this shared drive.', }, { displayName: 'Drive Members Only', name: 'driveMembersOnly', type: 'boolean', default: false, - description: 'Whether access to items inside this shared drive is restricted to its members', + description: + 'Whether access to items inside this shared drive is restricted to its members', }, ], }, @@ -1823,12 +1647,8 @@ export class GoogleDrive implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'drive', - ], + operation: ['delete'], + resource: ['drive'], }, }, description: 'The ID of the shared drive', @@ -1843,12 +1663,8 @@ export class GoogleDrive implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'drive', - ], + operation: ['get'], + resource: ['drive'], }, }, description: 'The ID of the shared drive', @@ -1861,12 +1677,8 @@ export class GoogleDrive implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'drive', - ], + operation: ['get'], + resource: ['drive'], }, }, options: [ @@ -1875,7 +1687,8 @@ export class GoogleDrive implements INodeType { name: 'useDomainAdminAccess', type: 'boolean', default: false, - description: 'Whether to issue the request as a domain administrator; if set to true, then the requester will be granted access if they are an administrator of the domain to which the shared drive belongs. (Default: false).', + description: + 'Whether to issue the request as a domain administrator; if set to true, then the requester will be granted access if they are an administrator of the domain to which the shared drive belongs. (Default: false).', }, ], }, @@ -1888,12 +1701,8 @@ export class GoogleDrive implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'list', - ], - resource: [ - 'drive', - ], + operation: ['list'], + resource: ['drive'], }, }, default: false, @@ -1905,15 +1714,9 @@ export class GoogleDrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'list', - ], - resource: [ - 'drive', - ], - returnAll: [ - false, - ], + operation: ['list'], + resource: ['drive'], + returnAll: [false], }, }, typeOptions: { @@ -1931,12 +1734,8 @@ export class GoogleDrive implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'list', - ], - resource: [ - 'drive', - ], + operation: ['list'], + resource: ['drive'], }, }, options: [ @@ -1945,14 +1744,16 @@ export class GoogleDrive implements INodeType { name: 'q', type: 'string', default: '', - description: 'Query string for searching shared drives. See the "Search for shared drives" guide for supported syntax.', + description: + 'Query string for searching shared drives. See the "Search for shared drives" guide for supported syntax.', }, { displayName: 'Use Domain Admin Access', name: 'useDomainAdminAccess', type: 'boolean', default: false, - description: 'Whether to issue the request as a domain administrator; if set to true, then the requester will be granted access if they are an administrator of the domain to which the shared drive belongs. (Default: false).', + description: + 'Whether to issue the request as a domain administrator; if set to true, then the requester will be granted access if they are an administrator of the domain to which the shared drive belongs. (Default: false).', }, ], }, @@ -1966,12 +1767,8 @@ export class GoogleDrive implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'drive', - ], + operation: ['update'], + resource: ['drive'], }, }, description: 'The ID of the shared drive', @@ -1984,12 +1781,8 @@ export class GoogleDrive implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'drive', - ], + operation: ['update'], + resource: ['drive'], }, }, options: [ @@ -2019,28 +1812,32 @@ export class GoogleDrive implements INodeType { name: 'adminManagedRestrictions', type: 'boolean', default: false, - description: 'Whether the options to copy, print, or download files inside this shared drive, should be disabled for readers and commenters. When this restriction is set to true, it will override the similarly named field to true for any file inside this shared drive.', + description: + 'Whether the options to copy, print, or download files inside this shared drive, should be disabled for readers and commenters. When this restriction is set to true, it will override the similarly named field to true for any file inside this shared drive.', }, { displayName: 'Copy Requires Writer Permission', name: 'copyRequiresWriterPermission', type: 'boolean', default: false, - description: 'Whether the options to copy, print, or download files inside this shared drive, should be disabled for readers and commenters. When this restriction is set to true, it will override the similarly named field to true for any file inside this shared drive.', + description: + 'Whether the options to copy, print, or download files inside this shared drive, should be disabled for readers and commenters. When this restriction is set to true, it will override the similarly named field to true for any file inside this shared drive.', }, { displayName: 'Domain Users Only', name: 'domainUsersOnly', type: 'boolean', default: false, - description: 'Whether access to this shared drive and items inside this shared drive is restricted to users of the domain to which this shared drive belongs. This restriction may be overridden by other sharing policies controlled outside of this shared drive.', + description: + 'Whether access to this shared drive and items inside this shared drive is restricted to users of the domain to which this shared drive belongs. This restriction may be overridden by other sharing policies controlled outside of this shared drive.', }, { displayName: 'Drive Members Only', name: 'driveMembersOnly', type: 'boolean', default: false, - description: 'Whether access to items inside this shared drive is restricted to its members', + description: + 'Whether access to items inside this shared drive is restricted to its members', }, ], }, @@ -2054,12 +1851,8 @@ export class GoogleDrive implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, options: [ @@ -2072,7 +1865,8 @@ export class GoogleDrive implements INodeType { typeOptions: { multipleValues: true, }, - description: 'A collection of arbitrary key-value pairs which are private to the requesting app', + description: + 'A collection of arbitrary key-value pairs which are private to the requesting app', options: [ { name: 'appPropertyValues', @@ -2134,7 +1928,6 @@ export class GoogleDrive implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -2170,7 +1963,9 @@ export class GoogleDrive implements INodeType { Object.assign(body, options); - const response = await googleApiRequest.call(this, 'POST', `/drive/v3/drives`, body, { requestId: uuid() }); + const response = await googleApiRequest.call(this, 'POST', `/drive/v3/drives`, body, { + requestId: uuid(), + }); returnData.push(response as IDataObject); } @@ -2196,7 +1991,13 @@ export class GoogleDrive implements INodeType { Object.assign(qs, options); - const response = await googleApiRequest.call(this, 'GET', `/drive/v3/drives/${driveId}`, {}, qs); + const response = await googleApiRequest.call( + this, + 'GET', + `/drive/v3/drives/${driveId}`, + {}, + qs, + ); returnData.push(response as IDataObject); } @@ -2213,7 +2014,14 @@ export class GoogleDrive implements INodeType { Object.assign(qs, options); if (returnAll === true) { - response = await googleApiRequestAllItems.call(this, 'drives', 'GET', `/drive/v3/drives`, {}, qs); + response = await googleApiRequestAllItems.call( + this, + 'drives', + 'GET', + `/drive/v3/drives`, + {}, + qs, + ); } else { qs.pageSize = this.getNodeParameter('limit', i) as number; const data = await googleApiRequest.call(this, 'GET', `/drive/v3/drives`, {}, qs); @@ -2233,11 +2041,15 @@ export class GoogleDrive implements INodeType { Object.assign(body, options); - const response = await googleApiRequest.call(this, 'PATCH', `/drive/v3/drives/${driveId}`, body); + const response = await googleApiRequest.call( + this, + 'PATCH', + `/drive/v3/drives/${driveId}`, + body, + ); returnData.push(response as IDataObject); } - } if (resource === 'file') { if (operation === 'copy') { @@ -2262,10 +2074,15 @@ export class GoogleDrive implements INodeType { supportsAllDrives: true, }; - const response = await googleApiRequest.call(this, 'POST', `/drive/v3/files/${fileId}/copy`, body, qs); + const response = await googleApiRequest.call( + this, + 'POST', + `/drive/v3/files/${fileId}/copy`, + body, + qs, + ); returnData.push(response as IDataObject); - } else if (operation === 'download') { // ---------------------------------- // download @@ -2280,7 +2097,13 @@ export class GoogleDrive implements INodeType { json: false, }; - const file = await googleApiRequest.call(this, 'GET', `/drive/v3/files/${fileId}`, {}, { fields: 'mimeType', supportsTeamDrives: true }); + const file = await googleApiRequest.call( + this, + 'GET', + `/drive/v3/files/${fileId}`, + {}, + { fields: 'mimeType', supportsTeamDrives: true }, + ); let response; if (file.mimeType.includes('vnd.google-apps')) { @@ -2288,17 +2111,49 @@ export class GoogleDrive implements INodeType { const type = file.mimeType.split('.')[2]; let mime; if (type === 'document') { - mime = this.getNodeParameter(`${parameterKey}.docsToFormat`, i, 'application/vnd.openxmlformats-officedocument.wordprocessingml.document') as string; + mime = this.getNodeParameter( + `${parameterKey}.docsToFormat`, + i, + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + ) as string; } else if (type === 'presentation') { - mime = this.getNodeParameter(`${parameterKey}.slidesToFormat`, i, 'application/vnd.openxmlformats-officedocument.presentationml.presentation') as string; + mime = this.getNodeParameter( + `${parameterKey}.slidesToFormat`, + i, + 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + ) as string; } else if (type === 'spreadsheet') { - mime = this.getNodeParameter(`${parameterKey}.sheetsToFormat`, i, 'application/x-vnd.oasis.opendocument.spreadsheet') as string; + mime = this.getNodeParameter( + `${parameterKey}.sheetsToFormat`, + i, + 'application/x-vnd.oasis.opendocument.spreadsheet', + ) as string; } else { - mime = this.getNodeParameter(`${parameterKey}.drawingsToFormat`, i, 'image/jpeg') as string; + mime = this.getNodeParameter( + `${parameterKey}.drawingsToFormat`, + i, + 'image/jpeg', + ) as string; } - response = await googleApiRequest.call(this, 'GET', `/drive/v3/files/${fileId}/export`, {}, { mimeType: mime }, undefined, requestOptions); + response = await googleApiRequest.call( + this, + 'GET', + `/drive/v3/files/${fileId}/export`, + {}, + { mimeType: mime }, + undefined, + requestOptions, + ); } else { - response = await googleApiRequest.call(this, 'GET', `/drive/v3/files/${fileId}`, {}, { alt: 'media' }, undefined, requestOptions); + response = await googleApiRequest.call( + this, + 'GET', + `/drive/v3/files/${fileId}`, + {}, + { alt: 'media' }, + undefined, + requestOptions, + ); } let mimeType: string | undefined; @@ -2326,12 +2181,18 @@ export class GoogleDrive implements INodeType { items[i] = newItem; - const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string; + const dataPropertyNameDownload = this.getNodeParameter( + 'binaryPropertyName', + i, + ) as string; const data = Buffer.from(response.body as string); - items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data as unknown as Buffer, fileName, mimeType); - + items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( + data as unknown as Buffer, + fileName, + mimeType, + ); } else if (operation === 'list') { // ---------------------------------- // list @@ -2369,7 +2230,7 @@ export class GoogleDrive implements INodeType { const queryFilterFields: string[] = []; if (queryFilters.name) { - (queryFilters.name as IDataObject[]).forEach(nameFilter => { + (queryFilters.name as IDataObject[]).forEach((nameFilter) => { let operation = nameFilter.operation; if (operation === 'is') { operation = '='; @@ -2384,7 +2245,7 @@ export class GoogleDrive implements INodeType { queryFilterFields.length = 0; if (queryFilters.mimeType) { - (queryFilters.mimeType as IDataObject[]).forEach(mimeTypeFilter => { + (queryFilters.mimeType as IDataObject[]).forEach((mimeTypeFilter) => { let mimeType = mimeTypeFilter.mimeType; if (mimeTypeFilter.mimeType === 'custom') { mimeType = mimeTypeFilter.customMimeType; @@ -2410,8 +2271,8 @@ export class GoogleDrive implements INodeType { fields: `nextPageToken, files(${queryFields})`, spaces: querySpaces, q: queryString, - includeItemsFromAllDrives: (queryCorpora !== '' || driveId !== ''), - supportsAllDrives: (queryCorpora !== '' || driveId !== ''), + includeItemsFromAllDrives: queryCorpora !== '' || driveId !== '', + supportsAllDrives: queryCorpora !== '' || driveId !== '', }; const response = await googleApiRequest.call(this, 'GET', `/drive/v3/files`, {}, qs); @@ -2425,7 +2286,6 @@ export class GoogleDrive implements INodeType { } else { returnData.push(...files); } - } else if (operation === 'upload') { // ---------------------------------- // upload @@ -2440,13 +2300,19 @@ export class GoogleDrive implements INodeType { const item = items[i]; if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string; if (item.binary[propertyNameUpload] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${propertyNameUpload}" does not exists on item!`, + { itemIndex: i }, + ); } if (item.binary[propertyNameUpload].mimeType) { @@ -2480,7 +2346,15 @@ export class GoogleDrive implements INodeType { json: false, }; - let response = await googleApiRequest.call(this, 'POST', `/upload/drive/v3/files`, body, qs, undefined, requestOptions); + let response = await googleApiRequest.call( + this, + 'POST', + `/upload/drive/v3/files`, + body, + qs, + undefined, + requestOptions, + ); body = { mimeType, @@ -2488,16 +2362,34 @@ export class GoogleDrive implements INodeType { originalFilename, }; - const properties = this.getNodeParameter('options.propertiesUi.propertyValues', i, []) as IDataObject[]; + const properties = this.getNodeParameter( + 'options.propertiesUi.propertyValues', + i, + [], + ) as IDataObject[]; if (properties.length) { - Object.assign(body, { properties: properties.reduce((obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), {}) }); + Object.assign(body, { + properties: properties.reduce( + (obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), + {}, + ), + }); } - const appProperties = this.getNodeParameter('options.appPropertiesUi.appPropertyValues', i, []) as IDataObject[]; + const appProperties = this.getNodeParameter( + 'options.appPropertiesUi.appPropertyValues', + i, + [], + ) as IDataObject[]; if (properties.length) { - Object.assign(body, { appProperties: appProperties.reduce((obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), {}) }); + Object.assign(body, { + appProperties: appProperties.reduce( + (obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), + {}, + ), + }); } qs = { @@ -2506,10 +2398,22 @@ export class GoogleDrive implements INodeType { supportsAllDrives: true, }; - response = await googleApiRequest.call(this, 'PATCH', `/drive/v3/files/${JSON.parse(response).id}`, body, qs); + response = await googleApiRequest.call( + this, + 'PATCH', + `/drive/v3/files/${JSON.parse(response).id}`, + body, + qs, + ); if (resolveData === true) { - response = await googleApiRequest.call(this, 'GET', `/drive/v3/files/${response.id}`, {}, { fields: '*' }); + response = await googleApiRequest.call( + this, + 'GET', + `/drive/v3/files/${response.id}`, + {}, + { fields: '*' }, + ); } returnData.push(response as IDataObject); @@ -2543,10 +2447,15 @@ export class GoogleDrive implements INodeType { qs.addParents = updateFields.parentId; } - const responseData = await googleApiRequest.call(this, 'PATCH', `/drive/v3/files/${id}`, body, qs); + const responseData = await googleApiRequest.call( + this, + 'PATCH', + `/drive/v3/files/${id}`, + body, + qs, + ); returnData.push(responseData as IDataObject); } - } if (resource === 'folder') { if (operation === 'create') { @@ -2580,7 +2489,13 @@ export class GoogleDrive implements INodeType { const fileId = this.getNodeParameter('fileId', i) as string; - await googleApiRequest.call(this, 'DELETE', `/drive/v3/files/${fileId}`, {}, { supportsTeamDrives: true }); + await googleApiRequest.call( + this, + 'DELETE', + `/drive/v3/files/${fileId}`, + {}, + { supportsTeamDrives: true }, + ); // If we are still here it did succeed returnData.push({ @@ -2589,7 +2504,6 @@ export class GoogleDrive implements INodeType { }); } if (operation === 'share') { - const fileId = this.getNodeParameter('fileId', i) as string; const permissions = this.getNodeParameter('permissionsUi', i) as IDataObject; @@ -2608,7 +2522,13 @@ export class GoogleDrive implements INodeType { Object.assign(qs, options); - const response = await googleApiRequest.call(this, 'POST', `/drive/v3/files/${fileId}/permissions`, body, qs); + const response = await googleApiRequest.call( + this, + 'POST', + `/drive/v3/files/${fileId}/permissions`, + body, + qs, + ); returnData.push(response as IDataObject); } diff --git a/packages/nodes-base/nodes/Google/Drive/GoogleDriveTrigger.node.ts b/packages/nodes-base/nodes/Google/Drive/GoogleDriveTrigger.node.ts index b1ce9a606d..76b6835fce 100644 --- a/packages/nodes-base/nodes/Google/Drive/GoogleDriveTrigger.node.ts +++ b/packages/nodes-base/nodes/Google/Drive/GoogleDriveTrigger.node.ts @@ -1,6 +1,4 @@ -import { - IPollFunctions, -} from 'n8n-core'; +import { IPollFunctions } from 'n8n-core'; import { IDataObject, @@ -12,11 +10,7 @@ import { NodeApiError, } from 'n8n-workflow'; -import { - extractId, - googleApiRequest, - googleApiRequestAllItems, -} from './GenericFunctions'; +import { extractId, googleApiRequest, googleApiRequestAllItems } from './GenericFunctions'; import moment from 'moment'; @@ -38,9 +32,7 @@ export class GoogleDriveTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'serviceAccount', - ], + authentication: ['serviceAccount'], }, }, }, @@ -49,9 +41,7 @@ export class GoogleDriveTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -103,13 +93,12 @@ export class GoogleDriveTrigger implements INodeType { type: 'string', displayOptions: { show: { - triggerOn: [ - 'specificFile', - ], + triggerOn: ['specificFile'], }, }, default: '', - description: 'The address of this file when you view it in your browser (or just the ID contained within the URL)', + description: + 'The address of this file when you view it in your browser (or just the ID contained within the URL)', required: true, }, { @@ -118,9 +107,7 @@ export class GoogleDriveTrigger implements INodeType { type: 'options', displayOptions: { show: { - triggerOn: [ - 'specificFile', - ], + triggerOn: ['specificFile'], }, }, required: true, @@ -139,13 +126,12 @@ export class GoogleDriveTrigger implements INodeType { type: 'string', displayOptions: { show: { - triggerOn: [ - 'specificFolder', - ], + triggerOn: ['specificFolder'], }, }, default: '', - description: 'The address of this folder when you view it in your browser (or just the ID contained within the URL)', + description: + 'The address of this folder when you view it in your browser (or just the ID contained within the URL)', required: true, }, { @@ -154,9 +140,7 @@ export class GoogleDriveTrigger implements INodeType { type: 'options', displayOptions: { show: { - triggerOn: [ - 'specificFolder', - ], + triggerOn: ['specificFolder'], }, }, required: true, @@ -190,19 +174,15 @@ export class GoogleDriveTrigger implements INodeType { ], }, { - displayName: 'Changes within subfolders won\'t trigger this node', + displayName: "Changes within subfolders won't trigger this node", name: 'asas', type: 'notice', displayOptions: { show: { - triggerOn: [ - 'specificFolder', - ], + triggerOn: ['specificFolder'], }, hide: { - event: [ - 'watchFolderUpdated', - ], + event: ['watchFolderUpdated'], }, }, default: '', @@ -214,9 +194,7 @@ export class GoogleDriveTrigger implements INodeType { type: 'options', displayOptions: { show: { - triggerOn: [ - 'anyFileFolder', - ], + triggerOn: ['anyFileFolder'], }, }, typeOptions: { @@ -224,7 +202,8 @@ export class GoogleDriveTrigger implements INodeType { }, default: 'root', required: true, - description: 'The drive to monitor. Choose from the list, or specify an ID using an expression.', + description: + 'The drive to monitor. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Watch For', @@ -232,9 +211,7 @@ export class GoogleDriveTrigger implements INodeType { type: 'options', displayOptions: { show: { - triggerOn: [ - 'anyFileFolder', - ], + triggerOn: ['anyFileFolder'], }, }, required: true, @@ -269,15 +246,10 @@ export class GoogleDriveTrigger implements INodeType { type: 'collection', displayOptions: { show: { - event: [ - 'fileCreated', - 'fileUpdated', - ], + event: ['fileCreated', 'fileUpdated'], }, hide: { - triggerOn: [ - 'specificFile', - ], + triggerOn: ['specificFile'], }, }, placeholder: 'Add Option', @@ -333,11 +305,14 @@ export class GoogleDriveTrigger implements INodeType { loadOptions: { // Get all the calendars to display them to user so that he can // select them easily - async getDrives( - this: ILoadOptionsFunctions, - ): Promise { + async getDrives(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const drives = await googleApiRequestAllItems.call(this, 'drives', 'GET', `/drive/v3/drives`); + const drives = await googleApiRequestAllItems.call( + this, + 'drives', + 'GET', + `/drive/v3/drives`, + ); returnData.push({ name: 'Root', value: 'root', @@ -362,13 +337,11 @@ export class GoogleDriveTrigger implements INodeType { const now = moment().utc().format(); - const startDate = webhookData.lastTimeChecked as string || now; + const startDate = (webhookData.lastTimeChecked as string) || now; const endDate = now; - const query = [ - 'trashed = false', - ]; + const query = ['trashed = false']; if (triggerOn === 'specificFolder' && event !== 'watchFolderUpdated') { const folderToWatch = extractId(this.getNodeParameter('folderToWatch') as string); @@ -417,7 +390,11 @@ export class GoogleDriveTrigger implements INodeType { files = files.filter((file: { id: string }) => file.id === fileToWatch); } - if (triggerOn === 'specificFolder' && event === 'watchFolderUpdated' && this.getMode() !== 'manual') { + if ( + triggerOn === 'specificFolder' && + event === 'watchFolderUpdated' && + this.getMode() !== 'manual' + ) { const folderToWatch = extractId(this.getNodeParameter('folderToWatch') as string); files = files.filter((file: { id: string }) => file.id === folderToWatch); } @@ -429,7 +406,9 @@ export class GoogleDriveTrigger implements INodeType { } if (this.getMode() === 'manual') { - throw new NodeApiError(this.getNode(), { message: 'No data with the current filter could be found' }); + throw new NodeApiError(this.getNode(), { + message: 'No data with the current filter could be found', + }); } return null; diff --git a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/CollectionDescription.ts b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/CollectionDescription.ts index 3f1dab669d..98e341df27 100644 --- a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/CollectionDescription.ts +++ b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/CollectionDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const collectionOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const collectionOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'collection', - ], + resource: ['collection'], }, }, options: [ @@ -41,15 +37,12 @@ export const collectionFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'getAll', - ], + resource: ['collection'], + operation: ['getAll'], }, }, - description: 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', + description: + 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', required: true, }, { @@ -59,12 +52,8 @@ export const collectionFields: INodeProperties[] = [ default: '(default)', displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'getAll', - ], + resource: ['collection'], + operation: ['getAll'], }, }, description: 'Usually the provided default value will work', @@ -77,12 +66,8 @@ export const collectionFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'getAll', - ], + resource: ['collection'], + operation: ['getAll'], }, }, description: 'Whether to return all results or only up to a given limit', @@ -94,15 +79,9 @@ export const collectionFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['collection'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/DocumentDescription.ts b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/DocumentDescription.ts index c63ce31074..8abbf90e4a 100644 --- a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/DocumentDescription.ts +++ b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/DocumentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const documentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const documentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'document', - ], + resource: ['document'], }, }, options: [ @@ -25,7 +21,8 @@ export const documentOperations: INodeProperties[] = [ { name: 'Create or Update', value: 'upsert', - description: 'Create a new document, or update the current one if it already exists (upsert)', + description: + 'Create a new document, or update the current one if it already exists (upsert)', action: 'Create or update a document', }, { @@ -76,15 +73,12 @@ export const documentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'create', - ], + resource: ['document'], + operation: ['create'], }, }, - description: 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', + description: + 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', required: true, }, { @@ -94,12 +88,8 @@ export const documentFields: INodeProperties[] = [ default: '(default)', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'create', - ], + resource: ['document'], + operation: ['create'], }, }, description: 'Usually the provided default value will work', @@ -112,12 +102,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'create', - ], + resource: ['document'], + operation: ['create'], }, }, description: 'Collection name', @@ -130,12 +116,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'create', - ], + resource: ['document'], + operation: ['create'], }, }, description: 'List of attributes to save', @@ -148,12 +130,8 @@ export const documentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'document', - ], + operation: ['create'], + resource: ['document'], }, }, default: true, @@ -173,15 +151,12 @@ export const documentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'get', - ], + resource: ['document'], + operation: ['get'], }, }, - description: 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', + description: + 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', required: true, }, { @@ -191,12 +166,8 @@ export const documentFields: INodeProperties[] = [ default: '(default)', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'get', - ], + resource: ['document'], + operation: ['get'], }, }, description: 'Usually the provided default value will work', @@ -209,12 +180,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'get', - ], + resource: ['document'], + operation: ['get'], }, }, description: 'Collection name', @@ -226,12 +193,8 @@ export const documentFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'document', - ], + operation: ['get'], + resource: ['document'], }, }, default: '', @@ -243,12 +206,8 @@ export const documentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'document', - ], + operation: ['get'], + resource: ['document'], }, }, default: true, @@ -268,15 +227,12 @@ export const documentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'getAll', - ], + resource: ['document'], + operation: ['getAll'], }, }, - description: 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', + description: + 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', required: true, }, { @@ -286,12 +242,8 @@ export const documentFields: INodeProperties[] = [ default: '(default)', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'getAll', - ], + resource: ['document'], + operation: ['getAll'], }, }, description: 'Usually the provided default value will work', @@ -304,12 +256,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'getAll', - ], + resource: ['document'], + operation: ['getAll'], }, }, description: 'Collection name', @@ -322,12 +270,8 @@ export const documentFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'getAll', - ], + resource: ['document'], + operation: ['getAll'], }, }, description: 'Whether to return all results or only up to a given limit', @@ -339,15 +283,9 @@ export const documentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['document'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -363,12 +301,8 @@ export const documentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'document', - ], + operation: ['getAll'], + resource: ['document'], }, }, default: true, @@ -388,15 +322,12 @@ export const documentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'delete', - ], + resource: ['document'], + operation: ['delete'], }, }, - description: 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', + description: + 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', required: true, }, { @@ -406,12 +337,8 @@ export const documentFields: INodeProperties[] = [ default: '(default)', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'delete', - ], + resource: ['document'], + operation: ['delete'], }, }, description: 'Usually the provided default value will work', @@ -424,12 +351,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'delete', - ], + resource: ['document'], + operation: ['delete'], }, }, description: 'Collection name', @@ -441,12 +364,8 @@ export const documentFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'document', - ], + operation: ['delete'], + resource: ['document'], }, }, default: '', @@ -580,15 +499,12 @@ export const documentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'upsert', - ], + resource: ['document'], + operation: ['upsert'], }, }, - description: 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', + description: + 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', required: true, }, { @@ -598,12 +514,8 @@ export const documentFields: INodeProperties[] = [ default: '(default)', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'upsert', - ], + resource: ['document'], + operation: ['upsert'], }, }, description: 'Usually the provided default value will work', @@ -616,12 +528,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'upsert', - ], + resource: ['document'], + operation: ['upsert'], }, }, description: 'Collection name', @@ -633,12 +541,8 @@ export const documentFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'upsert', - ], + resource: ['document'], + operation: ['upsert'], }, }, default: '', @@ -653,12 +557,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'upsert', - ], + resource: ['document'], + operation: ['upsert'], }, }, description: 'Columns to insert', @@ -678,15 +578,12 @@ export const documentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'query', - ], + resource: ['document'], + operation: ['query'], }, }, - description: 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', + description: + 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', required: true, }, { @@ -696,12 +593,8 @@ export const documentFields: INodeProperties[] = [ default: '(default)', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'query', - ], + resource: ['document'], + operation: ['query'], }, }, description: 'Usually the provided default value will work', @@ -714,12 +607,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'query', - ], + resource: ['document'], + operation: ['query'], }, }, description: 'JSON query to execute', @@ -727,7 +616,8 @@ export const documentFields: INodeProperties[] = [ typeOptions: { alwaysOpenEditWindow: true, }, - placeholder: '{"structuredQuery": {"where": {"fieldFilter": {"field": {"fieldPath": "age"},"op": "EQUAL", "value": {"integerValue": 28}}}, "from": [{"collectionId": "users-collection"}]}}', + placeholder: + '{"structuredQuery": {"where": {"fieldFilter": {"field": {"fieldPath": "age"},"op": "EQUAL", "value": {"integerValue": 28}}}, "from": [{"collectionId": "users-collection"}]}}', }, { displayName: 'Simplify', @@ -735,12 +625,8 @@ export const documentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'query', - ], - resource: [ - 'document', - ], + operation: ['query'], + resource: ['document'], }, }, default: true, diff --git a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts index 1af2cb7fa6..afc454bc63 100644 --- a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts @@ -1,21 +1,21 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; import moment from 'moment-timezone'; -export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri: string | null = null): Promise { // tslint:disable-line:no-any - +export async function googleApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri: string | null = null, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -35,14 +35,27 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } //@ts-ignore - return await this.helpers.requestOAuth2.call(this, 'googleFirebaseCloudFirestoreOAuth2Api', options); + return await this.helpers.requestOAuth2.call( + this, + 'googleFirebaseCloudFirestoreOAuth2Api', + options, + ); } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, uri: string | null = null): Promise { // tslint:disable-line:no-any - +export async function googleApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + uri: string | null = null, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -52,44 +65,42 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp responseData = await googleApiRequest.call(this, method, endpoint, body, query, uri); query.pageToken = responseData['nextPageToken']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['nextPageToken'] !== undefined && - responseData['nextPageToken'] !== '' - ); + } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); return returnData; } -const isValidDate = (str: string) => moment(str, ['YYYY-MM-DD HH:mm:ss Z', moment.ISO_8601], true).isValid(); +const isValidDate = (str: string) => + moment(str, ['YYYY-MM-DD HH:mm:ss Z', moment.ISO_8601], true).isValid(); // Both functions below were taken from Stack Overflow jsonToDocument was fixed as it was unable to handle null values correctly // https://stackoverflow.com/questions/62246410/how-to-convert-a-firestore-document-to-plain-json-and-vice-versa // Great thanks to https://stackoverflow.com/users/3915246/mahindar export function jsonToDocument(value: string | number | IDataObject | IDataObject[]): IDataObject { if (value === 'true' || value === 'false' || typeof value === 'boolean') { - return { 'booleanValue': value }; + return { booleanValue: value }; } else if (value === null) { - return { 'nullValue': null }; + return { nullValue: null }; } else if (!isNaN(value as number)) { if (value.toString().indexOf('.') !== -1) { - return { 'doubleValue': value }; + return { doubleValue: value }; } else { - return { 'integerValue': value }; + return { integerValue: value }; } } else if (isValidDate(value as string)) { const date = new Date(Date.parse(value as string)); - return { 'timestampValue': date.toISOString() }; + return { timestampValue: date.toISOString() }; } else if (typeof value === 'string') { - return { 'stringValue': value }; + return { stringValue: value }; } else if (value && value.constructor === Array) { - return { 'arrayValue': { values: value.map(v => jsonToDocument(v)) } }; + return { arrayValue: { values: value.map((v) => jsonToDocument(v)) } }; } else if (typeof value === 'object') { const obj = {}; for (const o of Object.keys(value)) { //@ts-ignore obj[o] = jsonToDocument(value[o]); } - return { 'mapValue': { fields: obj } }; + return { mapValue: { fields: obj } }; } return {}; @@ -109,17 +120,33 @@ export function fullDocumentToJson(data: IDataObject): IDataObject { }; } - export function documentToJson(fields: IDataObject): IDataObject { if (fields === undefined) return {}; const result = {}; for (const f of Object.keys(fields)) { - const key = f, value = fields[f], - isDocumentType = ['stringValue', 'booleanValue', 'doubleValue', - 'integerValue', 'timestampValue', 'mapValue', 'arrayValue', 'nullValue', 'geoPointValue'].find(t => t === key); + const key = f, + value = fields[f], + isDocumentType = [ + 'stringValue', + 'booleanValue', + 'doubleValue', + 'integerValue', + 'timestampValue', + 'mapValue', + 'arrayValue', + 'nullValue', + 'geoPointValue', + ].find((t) => t === key); if (isDocumentType) { - const item = ['stringValue', 'booleanValue', 'doubleValue', 'integerValue', 'timestampValue', 'nullValue', 'geoPointValue'] - .find(t => t === key); + const item = [ + 'stringValue', + 'booleanValue', + 'doubleValue', + 'integerValue', + 'timestampValue', + 'nullValue', + 'geoPointValue', + ].find((t) => t === key); if (item) { return value as IDataObject; } else if ('mapValue' === key) { @@ -129,7 +156,7 @@ export function documentToJson(fields: IDataObject): IDataObject { // @ts-ignore const list = value.values as IDataObject[]; // @ts-ignore - return !!list ? list.map(l => documentToJson(l)) : []; + return !!list ? list.map((l) => documentToJson(l)) : []; } } else { // @ts-ignore diff --git a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GoogleFirebaseCloudFirestore.node.ts b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GoogleFirebaseCloudFirestore.node.ts index dc75fb8218..4157cb3799 100644 --- a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GoogleFirebaseCloudFirestore.node.ts +++ b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GoogleFirebaseCloudFirestore.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -15,18 +13,12 @@ import { fullDocumentToJson, googleApiRequest, googleApiRequestAllItems, - jsonToDocument + jsonToDocument, } from './GenericFunctions'; -import { - collectionFields, - collectionOperations, -} from './CollectionDescription'; +import { collectionFields, collectionOperations } from './CollectionDescription'; -import { - documentFields, - documentOperations, -} from './DocumentDescription'; +import { documentFields, documentOperations } from './DocumentDescription'; export class GoogleFirebaseCloudFirestore implements INodeType { description: INodeTypeDescription = { @@ -76,9 +68,7 @@ export class GoogleFirebaseCloudFirestore implements INodeType { methods = { loadOptions: { - async getProjects( - this: ILoadOptionsFunctions, - ): Promise { + async getProjects(this: ILoadOptionsFunctions): Promise { const collections = await googleApiRequestAllItems.call( this, 'results', @@ -89,14 +79,16 @@ export class GoogleFirebaseCloudFirestore implements INodeType { 'https://firebase.googleapis.com/v1beta1/projects', ); // @ts-ignore - const returnData = collections.map(o => ({ name: o.projectId, value: o.projectId })) as INodePropertyOptions[]; + const returnData = collections.map((o) => ({ + name: o.projectId, + value: o.projectId, + })) as INodePropertyOptions[]; return returnData; }, }, }; async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); const returnData: IDataObject[] = []; let responseData; @@ -121,7 +113,7 @@ export class GoogleFirebaseCloudFirestore implements INodeType { { documents: documentList }, ); - responseData = responseData.map((element: { found: { id: string, name: string } }) => { + responseData = responseData.map((element: { found: { id: string; name: string } }) => { if (element.found) { element.found.id = (element.found.name as string).split('/').pop() as string; } @@ -131,39 +123,52 @@ export class GoogleFirebaseCloudFirestore implements INodeType { if (simple === false) { returnData.push.apply(returnData, responseData as IDataObject[]); } else { - returnData.push.apply(returnData, responseData.map((element: IDataObject) => { - return fullDocumentToJson(element.found as IDataObject); - }).filter((el: IDataObject) => !!el)); + returnData.push.apply( + returnData, + responseData + .map((element: IDataObject) => { + return fullDocumentToJson(element.found as IDataObject); + }) + .filter((el: IDataObject) => !!el), + ); } } else if (operation === 'create') { const projectId = this.getNodeParameter('projectId', 0) as string; const database = this.getNodeParameter('database', 0) as string; const simple = this.getNodeParameter('simple', 0) as boolean; - await Promise.all(items.map(async (item: IDataObject, i: number) => { - const collection = this.getNodeParameter('collection', i) as string; - const columns = this.getNodeParameter('columns', i) as string; - const columnList = columns.split(',').map(column => column.trim()); - const document = { fields: {} }; - columnList.map(column => { - // @ts-ignore - document.fields[column] = item['json'][column] ? jsonToDocument(item['json'][column]) : jsonToDocument(null); - }); - responseData = await googleApiRequest.call( - this, - 'POST', - `/${projectId}/databases/${database}/documents/${collection}`, - document, - ); + await Promise.all( + items.map(async (item: IDataObject, i: number) => { + const collection = this.getNodeParameter('collection', i) as string; + const columns = this.getNodeParameter('columns', i) as string; + const columnList = columns.split(',').map((column) => column.trim()); + const document = { fields: {} }; + columnList.map((column) => { + // @ts-ignore + if (item['json'][column]) { + // @ts-ignore + document.fields[column] = jsonToDocument(item['json'][column]); + } else { + // @ts-ignore + document.fields[column] = jsonToDocument(null); + } + }); + responseData = await googleApiRequest.call( + this, + 'POST', + `/${projectId}/databases/${database}/documents/${collection}`, + document, + ); - responseData.id = (responseData.name as string).split('/').pop(); + responseData.id = (responseData.name as string).split('/').pop(); - if (simple === false) { - returnData.push(responseData); - } else { - returnData.push(fullDocumentToJson(responseData as IDataObject)); - } - })); + if (simple === false) { + returnData.push(responseData); + } else { + returnData.push(fullDocumentToJson(responseData as IDataObject)); + } + }), + ); } else if (operation === 'getAll') { const projectId = this.getNodeParameter('projectId', 0) as string; const database = this.getNodeParameter('database', 0) as string; @@ -180,13 +185,13 @@ export class GoogleFirebaseCloudFirestore implements INodeType { ); } else { const limit = this.getNodeParameter('limit', 0) as string; - const getAllResponse = await googleApiRequest.call( + const getAllResponse = (await googleApiRequest.call( this, 'GET', `/${projectId}/databases/${database}/documents/${collection}`, {}, { pageSize: limit }, - ) as IDataObject; + )) as IDataObject; responseData = getAllResponse.documents; } responseData = responseData.map((element: IDataObject) => { @@ -196,29 +201,31 @@ export class GoogleFirebaseCloudFirestore implements INodeType { if (simple === false) { returnData.push.apply(returnData, responseData); } else { - returnData.push.apply(returnData, responseData.map((element: IDataObject) => fullDocumentToJson(element as IDataObject))); + returnData.push.apply( + returnData, + responseData.map((element: IDataObject) => fullDocumentToJson(element as IDataObject)), + ); } - } else if (operation === 'delete') { const responseData: IDataObject[] = []; - await Promise.all(items.map(async (item: IDataObject, i: number) => { - const projectId = this.getNodeParameter('projectId', i) as string; - const database = this.getNodeParameter('database', i) as string; - const collection = this.getNodeParameter('collection', i) as string; - const documentId = this.getNodeParameter('documentId', i) as string; + await Promise.all( + items.map(async (item: IDataObject, i: number) => { + const projectId = this.getNodeParameter('projectId', i) as string; + const database = this.getNodeParameter('database', i) as string; + const collection = this.getNodeParameter('collection', i) as string; + const documentId = this.getNodeParameter('documentId', i) as string; - await googleApiRequest.call( - this, - 'DELETE', - `/${projectId}/databases/${database}/documents/${collection}/${documentId}`, - ); + await googleApiRequest.call( + this, + 'DELETE', + `/${projectId}/databases/${database}/documents/${collection}/${documentId}`, + ); - responseData.push({ success: true }); - - })); + responseData.push({ success: true }); + }), + ); returnData.push.apply(returnData, responseData); - } else if (operation === 'upsert') { const projectId = this.getNodeParameter('projectId', 0) as string; const database = this.getNodeParameter('database', 0) as string; @@ -229,11 +236,17 @@ export class GoogleFirebaseCloudFirestore implements INodeType { // @ts-ignore const documentId = item['json'][updateKey] as string; const columns = this.getNodeParameter('columns', i) as string; - const columnList = columns.split(',').map(column => column.trim()) as string[]; + const columnList = columns.split(',').map((column) => column.trim()) as string[]; const document = {}; - columnList.map(column => { + columnList.map((column) => { // @ts-ignore - document[column] = item['json'].hasOwnProperty(column) ? jsonToDocument(item['json'][column]) : jsonToDocument(null); + if (item['json'].hasOwnProperty(column)) { + // @ts-ignore + document[column] = jsonToDocument(item['json'][column]); + } else { + // @ts-ignore + document[column] = jsonToDocument(null); + } }); return { @@ -245,7 +258,6 @@ export class GoogleFirebaseCloudFirestore implements INodeType { fieldPaths: columnList, }, }; - }); responseData = []; @@ -295,38 +307,47 @@ export class GoogleFirebaseCloudFirestore implements INodeType { // returnData.push(fullDocumentToJson(responseData as IDataObject)); // } // })); - } else if (operation === 'query') { const projectId = this.getNodeParameter('projectId', 0) as string; const database = this.getNodeParameter('database', 0) as string; const simple = this.getNodeParameter('simple', 0) as boolean; + await Promise.all( + items.map(async (item: IDataObject, i: number) => { + const query = this.getNodeParameter('query', i) as string; + responseData = await googleApiRequest.call( + this, + 'POST', + `/${projectId}/databases/${database}/documents:runQuery`, + JSON.parse(query), + ); - await Promise.all(items.map(async (item: IDataObject, i: number) => { - const query = this.getNodeParameter('query', i) as string; - responseData = await googleApiRequest.call( - this, - 'POST', - `/${projectId}/databases/${database}/documents:runQuery`, - JSON.parse(query), - ); + responseData = responseData.map( + (element: { document: { id: string; name: string } }) => { + if (element.document) { + element.document.id = (element.document.name as string) + .split('/') + .pop() as string; + } + return element; + }, + ); - responseData = responseData.map((element: { document: { id: string, name: string } }) => { - if (element.document) { - element.document.id = (element.document.name as string).split('/').pop() as string; + if (simple === false) { + returnData.push.apply(returnData, responseData); + } else { + //@ts-ignore + returnData.push.apply( + returnData, + responseData + .map((element: IDataObject) => { + return fullDocumentToJson(element.document as IDataObject); + }) + .filter((element: IDataObject) => !!element), + ); } - return element; - }); - - if (simple === false) { - returnData.push.apply(returnData, responseData); - } else { - //@ts-ignore - returnData.push.apply(returnData, responseData.map((element: IDataObject) => { - return fullDocumentToJson(element.document as IDataObject); - }).filter((element: IDataObject) => !!element)); - } - })); + }), + ); } } else if (resource === 'collection') { if (operation === 'getAll') { @@ -342,18 +363,18 @@ export class GoogleFirebaseCloudFirestore implements INodeType { `/${projectId}/databases/${database}/documents:listCollectionIds`, ); // @ts-ignore - responseData = getAllResponse.map(o => ({ name: o })); + responseData = getAllResponse.map((o) => ({ name: o })); } else { const limit = this.getNodeParameter('limit', 0) as string; - const getAllResponse = await googleApiRequest.call( + const getAllResponse = (await googleApiRequest.call( this, 'POST', `/${projectId}/databases/${database}/documents:listCollectionIds`, {}, { pageSize: limit }, - ) as IDataObject; + )) as IDataObject; // @ts-ignore - responseData = getAllResponse.collectionIds.map(o => ({ name: o })); + responseData = getAllResponse.collectionIds.map((o) => ({ name: o })); } returnData.push.apply(returnData, responseData); } diff --git a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts index 3a70524f24..26a5277b37 100644 --- a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts @@ -1,20 +1,24 @@ -import { - OptionsWithUrl, -} from 'request'; +import { OptionsWithUrl } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, JsonObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, JsonObject, NodeApiError } from 'n8n-workflow'; -export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, projectId: string, method: string, resource: string, body: any = {}, qs: IDataObject = {}, headers: IDataObject = {}, uri: string | null = null): Promise { // tslint:disable-line:no-any - - const { region } = await this.getCredentials('googleFirebaseRealtimeDatabaseOAuth2Api') as IDataObject; +export async function googleApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + projectId: string, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + headers: IDataObject = {}, + uri: string | null = null, + // tslint:disable-next-line:no-any +): Promise { + const { region } = (await this.getCredentials( + 'googleFirebaseRealtimeDatabaseOAuth2Api', + )) as IDataObject; const options: OptionsWithUrl = { headers: { @@ -35,28 +39,47 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF delete options.body; } - return await this.helpers.requestOAuth2!.call(this, 'googleFirebaseRealtimeDatabaseOAuth2Api', options); + return await this.helpers.requestOAuth2!.call( + this, + 'googleFirebaseRealtimeDatabaseOAuth2Api', + options, + ); } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); } } - -export async function googleApiRequestAllItems(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, projectId: string, method: string, resource: string, body: any = {}, qs: IDataObject = {}, headers: IDataObject = {}, uri: string | null = null): Promise { // tslint:disable-line:no-any - +export async function googleApiRequestAllItems( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + projectId: string, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + headers: IDataObject = {}, + uri: string | null = null, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; qs.pageSize = 100; do { - responseData = await googleApiRequest.call(this, projectId, method, resource, body, qs, {}, uri); + responseData = await googleApiRequest.call( + this, + projectId, + method, + resource, + body, + qs, + {}, + uri, + ); qs.pageToken = responseData['nextPageToken']; returnData.push.apply(returnData, responseData[resource]); - } while ( - responseData['nextPageToken'] !== undefined && - responseData['nextPageToken'] !== '' - ); + } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); return returnData; } diff --git a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GoogleFirebaseRealtimeDatabase.node.ts b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GoogleFirebaseRealtimeDatabase.node.ts index 33bb07dcaa..6eeddf81c6 100644 --- a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GoogleFirebaseRealtimeDatabase.node.ts +++ b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GoogleFirebaseRealtimeDatabase.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -14,10 +12,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - googleApiRequest, - googleApiRequestAllItems, -} from './GenericFunctions'; +import { googleApiRequest, googleApiRequestAllItems } from './GenericFunctions'; export class GoogleFirebaseRealtimeDatabase implements INodeType { description: INodeTypeDescription = { @@ -47,7 +42,8 @@ export class GoogleFirebaseRealtimeDatabase implements INodeType { typeOptions: { loadOptionsMethod: 'getProjects', }, - description: 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', + description: + 'As displayed in firebase console URL. Choose from the list, or specify an ID using an expression.', required: true, }, { @@ -101,7 +97,7 @@ export class GoogleFirebaseRealtimeDatabase implements INodeType { required: true, displayOptions: { hide: { - 'operation': [ 'get' ], + operation: ['get'], }, }, }, @@ -116,7 +112,7 @@ export class GoogleFirebaseRealtimeDatabase implements INodeType { hint: 'Leave blank to get a whole database object', displayOptions: { show: { - 'operation': [ 'get' ], + operation: ['get'], }, }, }, @@ -127,11 +123,7 @@ export class GoogleFirebaseRealtimeDatabase implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'create', - 'push', - 'update', - ], + operation: ['create', 'push', 'update'], }, }, description: 'Attributes to save', @@ -143,9 +135,7 @@ export class GoogleFirebaseRealtimeDatabase implements INodeType { methods = { loadOptions: { - async getProjects( - this: ILoadOptionsFunctions, - ): Promise { + async getProjects(this: ILoadOptionsFunctions): Promise { const projects = await googleApiRequestAllItems.call( this, '', @@ -158,14 +148,14 @@ export class GoogleFirebaseRealtimeDatabase implements INodeType { ); const returnData = projects - // select only realtime database projects - .filter((project: IDataObject) => (project.resources as IDataObject).realtimeDatabaseInstance ) - .map((project: IDataObject) => ( - { - name: project.projectId, - value: (project.resources as IDataObject).realtimeDatabaseInstance, - } - )) as INodePropertyOptions[]; + // select only realtime database projects + .filter( + (project: IDataObject) => (project.resources as IDataObject).realtimeDatabaseInstance, + ) + .map((project: IDataObject) => ({ + name: project.projectId, + value: (project.resources as IDataObject).realtimeDatabaseInstance, + })) as INodePropertyOptions[]; return returnData; }, @@ -180,8 +170,11 @@ export class GoogleFirebaseRealtimeDatabase implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; //https://firebase.google.com/docs/reference/rest/database - - if (['push', 'create', 'update'].includes(operation) && items.length === 1 && Object.keys(items[0].json).length === 0) { + if ( + ['push', 'create', 'update'].includes(operation) && + items.length === 1 && + Object.keys(items[0].json).length === 0 + ) { throw new NodeOperationError(this.getNode(), `The ${operation} operation needs input data`); } @@ -189,7 +182,8 @@ export class GoogleFirebaseRealtimeDatabase implements INodeType { try { const projectId = this.getNodeParameter('projectId', i) as string; - let method = 'GET', attributes = ''; + let method = 'GET', + attributes = ''; const document: IDataObject = {}; if (operation === 'create') { method = 'PUT'; @@ -207,7 +201,7 @@ export class GoogleFirebaseRealtimeDatabase implements INodeType { } if (attributes) { - const attributeList = attributes.split(',').map(el => el.trim()); + const attributeList = attributes.split(',').map((el) => el.trim()); attributeList.map((attribute: string) => { if (items[i].json.hasOwnProperty(attribute)) { document[attribute] = items[i].json[attribute]; @@ -225,7 +219,9 @@ export class GoogleFirebaseRealtimeDatabase implements INodeType { if (responseData === null) { if (operation === 'get') { - throw new NodeApiError(this.getNode(), responseData, { message: `Requested entity was not found.` }); + throw new NodeApiError(this.getNode(), responseData, { + message: `Requested entity was not found.`, + }); } else if (method === 'DELETE') { responseData = { success: true }; } @@ -240,7 +236,9 @@ export class GoogleFirebaseRealtimeDatabase implements INodeType { if (Array.isArray(responseData)) { returnData.push.apply(returnData, responseData as IDataObject[]); } else if (typeof responseData === 'string' || typeof responseData === 'number') { - returnData.push({ [this.getNodeParameter('path', i) as string]: responseData } as IDataObject); + returnData.push({ + [this.getNodeParameter('path', i) as string]: responseData, + } as IDataObject); } else { returnData.push(responseData as IDataObject); } diff --git a/packages/nodes-base/nodes/Google/GSuiteAdmin/GSuiteAdmin.node.ts b/packages/nodes-base/nodes/Google/GSuiteAdmin/GSuiteAdmin.node.ts index e33eedaee3..ae16722912 100644 --- a/packages/nodes-base/nodes/Google/GSuiteAdmin/GSuiteAdmin.node.ts +++ b/packages/nodes-base/nodes/Google/GSuiteAdmin/GSuiteAdmin.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,20 +10,11 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - googleApiRequest, - googleApiRequestAllItems, -} from './GenericFunctions'; +import { googleApiRequest, googleApiRequestAllItems } from './GenericFunctions'; -import { - userFields, - userOperations, -} from './UserDescription'; +import { userFields, userOperations } from './UserDescription'; -import { - groupFields, - groupOperations, -} from './GroupDescripion'; +import { groupFields, groupOperations } from './GroupDescripion'; export class GSuiteAdmin implements INodeType { description: INodeTypeDescription = { @@ -77,9 +66,7 @@ export class GSuiteAdmin implements INodeType { loadOptions: { // Get all the domains to display them to user so that he can // select them easily - async getDomains( - this: ILoadOptionsFunctions, - ): Promise { + async getDomains(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const domains = await googleApiRequestAllItems.call( this, @@ -99,9 +86,7 @@ export class GSuiteAdmin implements INodeType { }, // Get all the schemas to display them to user so that he can // select them easily - async getSchemas( - this: ILoadOptionsFunctions, - ): Promise { + async getSchemas(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const schemas = await googleApiRequestAllItems.call( this, @@ -144,12 +129,7 @@ export class GSuiteAdmin implements INodeType { Object.assign(body, additionalFields); - responseData = await googleApiRequest.call( - this, - 'POST', - `/directory/v1/groups`, - body, - ); + responseData = await googleApiRequest.call(this, 'POST', `/directory/v1/groups`, body); } //https://developers.google.com/admin-sdk/directory/v1/reference/groups/delete @@ -199,17 +179,10 @@ export class GSuiteAdmin implements INodeType { {}, qs, ); - } else { qs.maxResults = this.getNodeParameter('limit', i) as number; - responseData = await googleApiRequest.call( - this, - 'GET', - `/directory/v1/groups`, - {}, - qs, - ); + responseData = await googleApiRequest.call(this, 'GET', `/directory/v1/groups`, {}, qs); responseData = responseData.groups; } @@ -278,13 +251,7 @@ export class GSuiteAdmin implements INodeType { delete body.emailUi; } - responseData = await googleApiRequest.call( - this, - 'POST', - `/directory/v1/users`, - body, - qs, - ); + responseData = await googleApiRequest.call(this, 'POST', `/directory/v1/users`, body, qs); if (makeAdmin) { await googleApiRequest.call( @@ -329,7 +296,11 @@ export class GSuiteAdmin implements INodeType { } if (qs.projection === 'custom' && qs.customFieldMask === undefined) { - throw new NodeOperationError(this.getNode(), 'When projection is set to custom, the custom schemas field must be defined', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'When projection is set to custom, the custom schemas field must be defined', + { itemIndex: i }, + ); } responseData = await googleApiRequest.call( @@ -362,7 +333,11 @@ export class GSuiteAdmin implements INodeType { } if (qs.projection === 'custom' && qs.customFieldMask === undefined) { - throw new NodeOperationError(this.getNode(), 'When projection is set to custom, the custom schemas field must be defined', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'When projection is set to custom, the custom schemas field must be defined', + { itemIndex: i }, + ); } if (returnAll) { @@ -374,17 +349,10 @@ export class GSuiteAdmin implements INodeType { {}, qs, ); - } else { qs.maxResults = this.getNodeParameter('limit', i) as number; - responseData = await googleApiRequest.call( - this, - 'GET', - `/directory/v1/users`, - {}, - qs, - ); + responseData = await googleApiRequest.call(this, 'GET', `/directory/v1/users`, {}, qs); responseData = responseData.users; } @@ -396,7 +364,11 @@ export class GSuiteAdmin implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - const body: { name: { givenName?: string, familyName?: string }, emails?: IDataObject[], phones?: IDataObject[] } = { name: {} }; + const body: { + name: { givenName?: string; familyName?: string }; + emails?: IDataObject[]; + phones?: IDataObject[]; + } = { name: {} }; Object.assign(body, updateFields); @@ -451,7 +423,6 @@ export class GSuiteAdmin implements INodeType { if (Array.isArray(responseData)) { returnData.push.apply(returnData, responseData as IDataObject[]); - } else if (responseData !== undefined) { returnData.push(responseData as IDataObject); } diff --git a/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts b/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts index e95ecda637..051da41dde 100644 --- a/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts @@ -1,19 +1,20 @@ -import { - OptionsWithUri, - } from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function googleApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -38,8 +39,16 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function googleApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -49,10 +58,7 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData['nextPageToken']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['nextPageToken'] !== undefined && - responseData['nextPageToken'] !== '' - ); + } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); return returnData; } diff --git a/packages/nodes-base/nodes/Google/GSuiteAdmin/GroupDescripion.ts b/packages/nodes-base/nodes/Google/GSuiteAdmin/GroupDescripion.ts index 397e131f53..b1c63c109b 100644 --- a/packages/nodes-base/nodes/Google/GSuiteAdmin/GroupDescripion.ts +++ b/packages/nodes-base/nodes/Google/GSuiteAdmin/GroupDescripion.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const groupOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const groupOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'group', - ], + resource: ['group'], }, }, options: [ @@ -63,16 +59,13 @@ export const groupFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'group', - ], + operation: ['create'], + resource: ['group'], }, }, default: '', - description: 'The group\'s email address. If your account has multiple domains, select the appropriate domain for the email address. The email must be unique', + description: + "The group's email address. If your account has multiple domains, select the appropriate domain for the email address. The email must be unique", }, { displayName: 'Additional Fields', @@ -82,12 +75,8 @@ export const groupFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'group', - ], + operation: ['create'], + resource: ['group'], }, }, options: [ @@ -96,14 +85,15 @@ export const groupFields: INodeProperties[] = [ name: 'description', type: 'string', default: '', - description: 'An extended description to help users determine the purpose of a group. For example, you can include information about who should join the group, the types of messages to send to the group, links to FAQs about the group, or related groups.', + description: + 'An extended description to help users determine the purpose of a group. For example, you can include information about who should join the group, the types of messages to send to the group, links to FAQs about the group, or related groups.', }, { displayName: 'Name', name: 'name', type: 'string', default: '', - description: 'The group\'s display name', + description: "The group's display name", }, ], }, @@ -117,16 +107,13 @@ export const groupFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'group', - ], + operation: ['delete'], + resource: ['group'], }, }, default: '', - description: 'Identifies the group in the API request. The value can be the group\'s email address, group alias, or the unique group ID.', + description: + "Identifies the group in the API request. The value can be the group's email address, group alias, or the unique group ID.", }, /* -------------------------------------------------------------------------- */ /* group:get */ @@ -138,16 +125,13 @@ export const groupFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'group', - ], + operation: ['get'], + resource: ['group'], }, }, default: '', - description: 'Identifies the group in the API request. The value can be the group\'s email address, group alias, or the unique group ID.', + description: + "Identifies the group in the API request. The value can be the group's email address, group alias, or the unique group ID.", }, /* -------------------------------------------------------------------------- */ /* group:getAll */ @@ -158,12 +142,8 @@ export const groupFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'group', - ], + operation: ['getAll'], + resource: ['group'], }, }, default: false, @@ -175,15 +155,9 @@ export const groupFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'group', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['group'], + returnAll: [false], }, }, typeOptions: { @@ -201,12 +175,8 @@ export const groupFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'group', - ], + operation: ['getAll'], + resource: ['group'], }, }, options: [ @@ -215,7 +185,8 @@ export const groupFields: INodeProperties[] = [ name: 'customer', type: 'string', default: '', - description: 'The unique ID for the customer\'s G Suite account. In case of a multi-domain account, to fetch all groups for a customer, fill this field instead of domain.', + description: + "The unique ID for the customer's G Suite account. In case of a multi-domain account, to fetch all groups for a customer, fill this field instead of domain.", }, { displayName: 'Domain', @@ -242,7 +213,8 @@ export const groupFields: INodeProperties[] = [ name: 'query', type: 'string', default: '', - description: 'Query string search. Complete documentation is at.', + description: + 'Query string search. Complete documentation is at.', }, { displayName: 'Sort Order', @@ -266,7 +238,8 @@ export const groupFields: INodeProperties[] = [ name: 'userId', type: 'string', default: '', - description: 'Email or immutable ID of the user if only those groups are to be listed, the given user is a member of. If it\'s an ID, it should match with the ID of the user object.', + description: + "Email or immutable ID of the user if only those groups are to be listed, the given user is a member of. If it's an ID, it should match with the ID of the user object.", }, ], }, @@ -280,16 +253,13 @@ export const groupFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'group', - ], + operation: ['update'], + resource: ['group'], }, }, default: '', - description: 'Identifies the group in the API request. The value can be the group\'s email address, group alias, or the unique group ID.', + description: + "Identifies the group in the API request. The value can be the group's email address, group alias, or the unique group ID.", }, { displayName: 'Update Fields', @@ -299,12 +269,8 @@ export const groupFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'group', - ], + operation: ['update'], + resource: ['group'], }, }, options: [ @@ -313,7 +279,8 @@ export const groupFields: INodeProperties[] = [ name: 'description', type: 'string', default: '', - description: 'An extended description to help users determine the purpose of a group. For example, you can include information about who should join the group, the types of messages to send to the group, links to FAQs about the group, or related groups.', + description: + 'An extended description to help users determine the purpose of a group. For example, you can include information about who should join the group, the types of messages to send to the group, links to FAQs about the group, or related groups.', }, { displayName: 'Email', @@ -321,14 +288,15 @@ export const groupFields: INodeProperties[] = [ type: 'string', placeholder: 'name@email.com', default: '', - description: 'The group\'s email address. If your account has multiple domains, select the appropriate domain for the email address. The email must be unique.', + description: + "The group's email address. If your account has multiple domains, select the appropriate domain for the email address. The email must be unique.", }, { displayName: 'Name', name: 'name', type: 'string', default: '', - description: 'The group\'s display name', + description: "The group's display name", }, ], }, diff --git a/packages/nodes-base/nodes/Google/GSuiteAdmin/UserDescription.ts b/packages/nodes-base/nodes/Google/GSuiteAdmin/UserDescription.ts index 8ca337642a..d892f1fb6a 100644 --- a/packages/nodes-base/nodes/Google/GSuiteAdmin/UserDescription.ts +++ b/packages/nodes-base/nodes/Google/GSuiteAdmin/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -62,12 +58,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'user', - ], + operation: ['create'], + resource: ['user'], }, }, default: '', @@ -79,12 +71,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'user', - ], + operation: ['create'], + resource: ['user'], }, }, default: '', @@ -99,34 +87,28 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'user', - ], + operation: ['create'], + resource: ['user'], }, }, default: '', - description: 'Stores the password for the user account. A minimum of 8 characters is required. The maximum length is 100 characters.', + description: + 'Stores the password for the user account. A minimum of 8 characters is required. The maximum length is 100 characters.', }, { displayName: 'Domain Name or ID', name: 'domain', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getDomains', }, required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'user', - ], + operation: ['create'], + resource: ['user'], }, }, default: '', @@ -137,16 +119,13 @@ export const userFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'user', - ], + operation: ['create'], + resource: ['user'], }, }, default: '', - description: 'The username that will be set to the user. Example: If you domain is example.com and you set the username to jhon then the user\'s final email address will be jhon@example.com.', + description: + "The username that will be set to the user. Example: If you domain is example.com and you set the username to jhon then the user's final email address will be jhon@example.com.", }, { displayName: 'Make Admin', @@ -155,12 +134,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'user', - ], + operation: ['create'], + resource: ['user'], }, }, default: false, @@ -174,12 +149,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'user', - ], + operation: ['create'], + resource: ['user'], }, }, options: [ @@ -310,7 +281,8 @@ export const userFields: INodeProperties[] = [ name: 'primary', type: 'boolean', default: false, - description: 'Whether this is the user\'s primary phone number. A user may only have one primary phone number.', + description: + "Whether this is the user's primary phone number. A user may only have one primary phone number.", }, ], }, @@ -373,16 +345,13 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'user', - ], + operation: ['delete'], + resource: ['user'], }, }, default: '', - description: 'The value can be the user\'s primary email address, alias email address, or unique user ID', + description: + "The value can be the user's primary email address, alias email address, or unique user ID", }, /* -------------------------------------------------------------------------- */ /* user:get */ @@ -394,16 +363,13 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'user', - ], + operation: ['get'], + resource: ['user'], }, }, default: '', - description: 'The value can be the user\'s primary email address, alias email address, or unique user ID', + description: + "The value can be the user's primary email address, alias email address, or unique user ID", }, { displayName: 'Projection', @@ -429,12 +395,8 @@ export const userFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'user', - ], + operation: ['get'], + resource: ['user'], }, }, default: 'basic', @@ -448,12 +410,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'user', - ], + operation: ['get'], + resource: ['user'], }, }, options: [ @@ -463,16 +421,15 @@ export const userFields: INodeProperties[] = [ type: 'multiOptions', displayOptions: { show: { - '/projection': [ - 'custom', - ], + '/projection': ['custom'], }, }, typeOptions: { loadOptionsMethod: 'getSchemas', }, default: [], - description: 'A comma-separated list of schema names. All fields from these schemas are fetched. This should only be set when projection=custom. Choose from the list, or specify IDs using an expression.', + description: + 'A comma-separated list of schema names. All fields from these schemas are fetched. This should only be set when projection=custom. Choose from the list, or specify IDs using an expression.', }, { displayName: 'View Type', @@ -482,16 +439,19 @@ export const userFields: INodeProperties[] = [ { name: 'Admin View', value: 'admin_view', - description: 'Results include both administrator-only and domain-public fields for the user', + description: + 'Results include both administrator-only and domain-public fields for the user', }, { name: 'Descending', value: 'DESCENDING', - description: 'Results only include fields for the user that are publicly visible to other users in the domain', + description: + 'Results only include fields for the user that are publicly visible to other users in the domain', }, ], default: 'admin_view', - description: 'Whether to fetch the administrator-only or domain-wide public view of the user. For more information, see Retrieve a user as a non-administrator.', + description: + 'Whether to fetch the administrator-only or domain-wide public view of the user. For more information, see Retrieve a user as a non-administrator.', }, ], }, @@ -504,12 +464,8 @@ export const userFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'user', - ], + operation: ['getAll'], + resource: ['user'], }, }, default: false, @@ -521,15 +477,9 @@ export const userFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'user', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['user'], + returnAll: [false], }, }, typeOptions: { @@ -563,12 +513,8 @@ export const userFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'user', - ], + operation: ['getAll'], + resource: ['user'], }, }, default: 'basic', @@ -582,12 +528,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'user', - ], + operation: ['getAll'], + resource: ['user'], }, }, options: [ @@ -597,23 +539,23 @@ export const userFields: INodeProperties[] = [ type: 'multiOptions', displayOptions: { show: { - '/projection': [ - 'custom', - ], + '/projection': ['custom'], }, }, typeOptions: { loadOptionsMethod: 'getSchemas', }, default: [], - description: 'A comma-separated list of schema names. All fields from these schemas are fetched. This should only be set when projection=custom. Choose from the list, or specify IDs using an expression.', + description: + 'A comma-separated list of schema names. All fields from these schemas are fetched. This should only be set when projection=custom. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Customer', name: 'customer', type: 'string', default: '', - description: 'The unique ID for the customer\'s G Suite account. In case of a multi-domain account, to fetch all groups for a customer, fill this field instead of domain.', + description: + "The unique ID for the customer's G Suite account. In case of a multi-domain account, to fetch all groups for a customer, fill this field instead of domain.", }, { displayName: 'Domain', @@ -648,7 +590,8 @@ export const userFields: INodeProperties[] = [ name: 'query', type: 'string', default: '', - description: 'Free text search terms to find users that match these terms in any field, except for extended properties. For more information on constructing user queries, see Search for Users.', + description: + 'Free text search terms to find users that match these terms in any field, except for extended properties. For more information on constructing user queries, see Search for Users.', }, { displayName: 'Show Deleted', @@ -682,16 +625,19 @@ export const userFields: INodeProperties[] = [ { name: 'Admin View', value: 'admin_view', - description: 'Results include both administrator-only and domain-public fields for the user', + description: + 'Results include both administrator-only and domain-public fields for the user', }, { name: 'Descending', value: 'DESCENDING', - description: 'Results only include fields for the user that are publicly visible to other users in the domain', + description: + 'Results only include fields for the user that are publicly visible to other users in the domain', }, ], default: 'admin_view', - description: 'Whether to fetch the administrator-only or domain-wide public view of the user. For more information, see Retrieve a user as a non-administrator.', + description: + 'Whether to fetch the administrator-only or domain-wide public view of the user. For more information, see Retrieve a user as a non-administrator.', }, ], }, @@ -705,16 +651,13 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'user', - ], + operation: ['update'], + resource: ['user'], }, }, default: '', - description: 'The value can be the user\'s primary email address, alias email address, or unique user ID', + description: + "The value can be the user's primary email address, alias email address, or unique user ID", }, { displayName: 'Update Fields', @@ -724,12 +667,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'user', - ], + operation: ['update'], + resource: ['user'], }, }, options: [ @@ -764,7 +703,8 @@ export const userFields: INodeProperties[] = [ name: 'password', type: 'string', default: '', - description: 'Stores the password for the user account. A minimum of 8 characters is required. The maximum length is 100 characters.', + description: + 'Stores the password for the user account. A minimum of 8 characters is required. The maximum length is 100 characters.', }, { displayName: 'Phones', @@ -884,7 +824,8 @@ export const userFields: INodeProperties[] = [ name: 'primary', type: 'boolean', default: false, - description: 'Whether this is the user\'s primary phone number. A user may only have one primary phone number.', + description: + "Whether this is the user's primary phone number. A user may only have one primary phone number.", }, ], }, @@ -895,7 +836,8 @@ export const userFields: INodeProperties[] = [ name: 'primaryEmail', type: 'string', default: '', - description: 'The user\'s primary email address. This property is required in a request to create a user account. The primaryEmail must be unique and cannot be an alias of another user.', + description: + "The user's primary email address. This property is required in a request to create a user account. The primaryEmail must be unique and cannot be an alias of another user.", }, { displayName: 'Secondary Emails', diff --git a/packages/nodes-base/nodes/Google/Gmail/DraftDescription.ts b/packages/nodes-base/nodes/Google/Gmail/DraftDescription.ts index 63131cd18f..c23fa85b54 100644 --- a/packages/nodes-base/nodes/Google/Gmail/DraftDescription.ts +++ b/packages/nodes-base/nodes/Google/Gmail/DraftDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const draftOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const draftOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'draft', - ], + resource: ['draft'], }, }, options: [ @@ -54,13 +50,8 @@ export const draftFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'draft', - ], - operation: [ - 'delete', - 'get', - ], + resource: ['draft'], + operation: ['delete', 'get'], }, }, placeholder: 'r-3254521568507167962', @@ -74,12 +65,8 @@ export const draftFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'draft', - ], - operation: [ - 'create', - ], + resource: ['draft'], + operation: ['create'], }, }, placeholder: 'Hello World!', @@ -91,12 +78,8 @@ export const draftFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'draft', - ], - operation: [ - 'create', - ], + resource: ['draft'], + operation: ['create'], }, }, default: false, @@ -110,15 +93,9 @@ export const draftFields: INodeProperties[] = [ required: true, displayOptions: { show: { - includeHtml: [ - true, - ], - resource: [ - 'draft', - ], - operation: [ - 'create', - ], + includeHtml: [true], + resource: ['draft'], + operation: ['create'], }, }, description: 'The HTML message body', @@ -131,16 +108,13 @@ export const draftFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'draft', - ], - operation: [ - 'create', - ], + resource: ['draft'], + operation: ['create'], }, }, placeholder: 'Hello World!', - description: 'The message body. If HTML formatted, then you have to add and activate the option "HTML content" in the "Additional Options" section.', + description: + 'The message body. If HTML formatted, then you have to add and activate the option "HTML content" in the "Additional Options" section.', }, { displayName: 'Additional Fields', @@ -149,12 +123,8 @@ export const draftFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'draft', - ], - operation: [ - 'create', - ], + resource: ['draft'], + operation: ['create'], }, }, default: {}, @@ -213,7 +183,8 @@ export const draftFields: INodeProperties[] = [ name: 'property', type: 'string', default: '', - description: 'Name of the binary property containing the data to be added to the email as an attachment. Multiple properties can be set separated by comma.', + description: + 'Name of the binary property containing the data to be added to the email as an attachment. Multiple properties can be set separated by comma.', }, ], }, @@ -230,12 +201,8 @@ export const draftFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'draft', - ], - operation: [ - 'get', - ], + resource: ['draft'], + operation: ['get'], }, }, default: {}, @@ -247,15 +214,11 @@ export const draftFields: INodeProperties[] = [ default: 'attachment_', displayOptions: { hide: { - format: [ - 'full', - 'metadata', - 'minimal', - 'raw', - ], + format: ['full', 'metadata', 'minimal', 'raw'], }, }, - description: 'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"', + description: + 'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"', }, { displayName: 'Format', @@ -265,7 +228,8 @@ export const draftFields: INodeProperties[] = [ { name: 'Full', value: 'full', - description: 'Returns the full email message data with body content parsed in the payload field', + description: + 'Returns the full email message data with body content parsed in the payload field', }, { name: 'Metadata', @@ -275,17 +239,20 @@ export const draftFields: INodeProperties[] = [ { name: 'Minimal', value: 'minimal', - description: 'Returns only email message ID and labels; does not return the email headers, body, or payload', + description: + 'Returns only email message ID and labels; does not return the email headers, body, or payload', }, { name: 'RAW', value: 'raw', - description: 'Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used', + description: + 'Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used', }, { name: 'Resolved', value: 'resolved', - description: 'Returns the full email with all data resolved and attachments saved as binary data', + description: + 'Returns the full email with all data resolved and attachments saved as binary data', }, ], default: 'resolved', @@ -303,12 +270,8 @@ export const draftFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'draft', - ], + operation: ['getAll'], + resource: ['draft'], }, }, default: false, @@ -320,15 +283,9 @@ export const draftFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'draft', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['draft'], + returnAll: [false], }, }, typeOptions: { @@ -346,12 +303,8 @@ export const draftFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'draft', - ], + operation: ['getAll'], + resource: ['draft'], }, }, options: [ @@ -362,16 +315,11 @@ export const draftFields: INodeProperties[] = [ default: 'attachment_', displayOptions: { hide: { - format: [ - 'full', - 'ids', - 'metadata', - 'minimal', - 'raw', - ], + format: ['full', 'ids', 'metadata', 'minimal', 'raw'], }, }, - description: 'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"', + description: + 'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"', }, { displayName: 'Format', @@ -381,7 +329,8 @@ export const draftFields: INodeProperties[] = [ { name: 'Full', value: 'full', - description: 'Returns the full email message data with body content parsed in the payload field', + description: + 'Returns the full email message data with body content parsed in the payload field', }, { name: 'IDs', @@ -396,17 +345,20 @@ export const draftFields: INodeProperties[] = [ { name: 'Minimal', value: 'minimal', - description: 'Returns only email message ID and labels; does not return the email headers, body, or payload', + description: + 'Returns only email message ID and labels; does not return the email headers, body, or payload', }, { name: 'RAW', value: 'raw', - description: 'Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used', + description: + 'Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used', }, { name: 'Resolved', value: 'resolved', - description: 'Returns the full email with all data resolved and attachments saved as binary data', + description: + 'Returns the full email with all data resolved and attachments saved as binary data', }, ], default: 'resolved', diff --git a/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts index 3a392bc73f..1506661808 100644 --- a/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts @@ -1,16 +1,8 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - simpleParser, -} from 'mailparser'; +import { simpleParser } from 'mailparser'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IBinaryKeyData, @@ -20,9 +12,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - IEmail, -} from './Gmail.node'; +import { IEmail } from './Gmail.node'; import moment from 'moment-timezone'; @@ -37,12 +27,25 @@ interface IGoogleAuthCredentials { const mailComposer = require('nodemailer/lib/mail-composer'); -export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, - endpoint: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any - const authenticationMethod = this.getNodeParameter('authentication', 0, 'serviceAccount') as string; +export async function googleApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { + const authenticationMethod = this.getNodeParameter( + 'authentication', + 0, + 'serviceAccount', + ) as string; let options: OptionsWithUri = { headers: { - 'Accept': 'application/json', + Accept: 'application/json', 'Content-Type': 'application/json', }, method, @@ -65,7 +68,10 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF if (authenticationMethod === 'serviceAccount') { const credentials = await this.getCredentials('googleApi'); - const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials); + const { access_token } = await getAccessToken.call( + this, + credentials as unknown as IGoogleAuthCredentials, + ); options.headers!.Authorization = `Bearer ${access_token}`; //@ts-ignore @@ -74,7 +80,6 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'gmailOAuth2', options); } - } catch (error) { if (error.code === 'ERR_OSSL_PEM_NO_START_LINE') { error.statusCode = '401'; @@ -84,9 +89,12 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } } - -export async function parseRawEmail(this: IExecuteFunctions, messageData: any, dataPropertyNameDownload: string): Promise { // tslint:disable-line:no-any - +export async function parseRawEmail( + this: IExecuteFunctions, + // tslint:disable-next-line:no-any + messageData: any, + dataPropertyNameDownload: string, +): Promise { const messageEncoded = Buffer.from(messageData.raw, 'base64').toString('utf8'); let responseData = await simpleParser(messageEncoded); @@ -103,10 +111,13 @@ export async function parseRawEmail(this: IExecuteFunctions, messageData: any, d const binaryData: IBinaryKeyData = {}; if (responseData.attachments) { - for (let i = 0; i < responseData.attachments.length; i++) { const attachment = responseData.attachments[i]; - binaryData[`${dataPropertyNameDownload}${i}`] = await this.helpers.prepareBinaryData(attachment.content, attachment.filename, attachment.contentType); + binaryData[`${dataPropertyNameDownload}${i}`] = await this.helpers.prepareBinaryData( + attachment.content, + attachment.filename, + attachment.contentType, + ); } // @ts-ignore responseData.attachments = undefined; @@ -114,12 +125,7 @@ export async function parseRawEmail(this: IExecuteFunctions, messageData: any, d const mailBaseData: IDataObject = {}; - const resolvedModeAddProperties = [ - 'id', - 'threadId', - 'labelIds', - 'sizeEstimate', - ]; + const resolvedModeAddProperties = ['id', 'threadId', 'labelIds', 'sizeEstimate']; for (const key of resolvedModeAddProperties) { // @ts-ignore @@ -134,7 +140,6 @@ export async function parseRawEmail(this: IExecuteFunctions, messageData: any, d } as INodeExecutionData; } - //------------------------------------------------------------------------------------------------------------------------------------------ // This function converts an email object into a MIME encoded email and then converts that string into base64 encoding // for more info on MIME, https://docs.microsoft.com/en-us/previous-versions/office/developer/exchange-server-2010/aa494197(v%3Dexchg.140) @@ -158,7 +163,11 @@ export async function encodeEmail(email: IEmail) { mailOptions.html = email.htmlBody; } - if (email.attachments !== undefined && Array.isArray(email.attachments) && email.attachments.length > 0) { + if ( + email.attachments !== undefined && + Array.isArray(email.attachments) && + email.attachments.length > 0 + ) { const attachments = email.attachments.map((attachment) => ({ filename: attachment.name, content: attachment.content, @@ -182,8 +191,16 @@ export async function encodeEmail(email: IEmail) { return mailBody.toString('base64').replace(/\+/g, '-').replace(/\//g, '_'); } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function googleApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -193,10 +210,7 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData['nextPageToken']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['nextPageToken'] !== undefined && - responseData['nextPageToken'] !== '' - ); + } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); return returnData; } @@ -206,7 +220,10 @@ export function extractEmail(s: string) { return data.substring(0, data.length - 1); } -function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, credentials: IGoogleAuthCredentials): Promise { +function getAccessToken( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + credentials: IGoogleAuthCredentials, +): Promise { //https://developers.google.com/identity/protocols/oauth2/service-account#httprest const scopes = [ @@ -225,20 +242,20 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa const signature = jwt.sign( { - 'iss': credentials.email as string, - 'sub': credentials.delegatedEmail || credentials.email as string, - 'scope': scopes.join(' '), - 'aud': `https://oauth2.googleapis.com/token`, - 'iat': now, - 'exp': now + 3600, + iss: credentials.email as string, + sub: credentials.delegatedEmail || (credentials.email as string), + scope: scopes.join(' '), + aud: `https://oauth2.googleapis.com/token`, + iat: now, + exp: now + 3600, }, privateKey, { algorithm: 'RS256', header: { - 'kid': privateKey, - 'typ': 'JWT', - 'alg': 'RS256', + kid: privateKey, + typ: 'JWT', + alg: 'RS256', }, }, ); diff --git a/packages/nodes-base/nodes/Google/Gmail/Gmail.node.ts b/packages/nodes-base/nodes/Google/Gmail/Gmail.node.ts index 1d36209cfb..4b898b292d 100644 --- a/packages/nodes-base/nodes/Google/Gmail/Gmail.node.ts +++ b/packages/nodes-base/nodes/Google/Gmail/Gmail.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryKeyData, @@ -20,29 +18,15 @@ import { parseRawEmail, } from './GenericFunctions'; -import { - messageFields, - messageOperations, -} from './MessageDescription'; +import { messageFields, messageOperations } from './MessageDescription'; -import { - messageLabelFields, - messageLabelOperations, -} from './MessageLabelDescription'; +import { messageLabelFields, messageLabelOperations } from './MessageLabelDescription'; -import { - labelFields, - labelOperations, -} from './LabelDescription'; +import { labelFields, labelOperations } from './LabelDescription'; -import { - draftFields, - draftOperations, -} from './DraftDescription'; +import { draftFields, draftOperations } from './DraftDescription'; -import { - isEmpty, -} from 'lodash'; +import { isEmpty } from 'lodash'; export interface IEmail { from?: string; @@ -83,9 +67,7 @@ export class Gmail implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'serviceAccount', - ], + authentication: ['serviceAccount'], }, }, }, @@ -94,9 +76,7 @@ export class Gmail implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -170,9 +150,7 @@ export class Gmail implements INodeType { loadOptions: { // Get all the labels to display them to user so that he can // select them easily - async getLabels( - this: ILoadOptionsFunctions, - ): Promise { + async getLabels(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const labels = await googleApiRequestAllItems.call( this, @@ -212,7 +190,10 @@ export class Gmail implements INodeType { //https://developers.google.com/gmail/api/v1/reference/users/labels/create const labelName = this.getNodeParameter('name', i) as string; const labelListVisibility = this.getNodeParameter('labelListVisibility', i) as string; - const messageListVisibility = this.getNodeParameter('messageListVisibility', i) as string; + const messageListVisibility = this.getNodeParameter( + 'messageListVisibility', + i, + ) as string; method = 'POST'; endpoint = '/gmail/v1/users/me/labels'; @@ -233,7 +214,6 @@ export class Gmail implements INodeType { endpoint = `/gmail/v1/users/me/labels/${labelId}`; responseData = await googleApiRequest.call(this, method, endpoint, body, qs); responseData = { success: true }; - } if (operation === 'get') { // https://developers.google.com/gmail/api/v1/reference/users/labels/get @@ -328,15 +308,20 @@ export class Gmail implements INodeType { const attachmentsUi = additionalFields.attachmentsUi as IDataObject; const attachmentsBinary = []; if (!isEmpty(attachmentsUi)) { - if (attachmentsUi.hasOwnProperty('attachmentsBinary') - && !isEmpty(attachmentsUi.attachmentsBinary) - && items[i].binary) { + if ( + attachmentsUi.hasOwnProperty('attachmentsBinary') && + !isEmpty(attachmentsUi.attachmentsBinary) && + items[i].binary + ) { // @ts-ignore for (const { property } of attachmentsUi.attachmentsBinary as IDataObject[]) { for (const binaryProperty of (property as string).split(',')) { if (items[i].binary![binaryProperty] !== undefined) { const binaryData = items[i].binary![binaryProperty]; - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + i, + binaryProperty, + ); attachmentsBinary.push({ name: binaryData.fileName || 'unknown', content: binaryDataBuffer, @@ -356,7 +341,7 @@ export class Gmail implements INodeType { } const email: IEmail = { - from: additionalFields.senderName as string || '', + from: (additionalFields.senderName as string) || '', to: toStr, cc: ccStr, bcc: bccStr, @@ -365,7 +350,7 @@ export class Gmail implements INodeType { attachments: attachmentsList, }; - if (this.getNodeParameter('includeHtml', i, false) as boolean === true) { + if ((this.getNodeParameter('includeHtml', i, false) as boolean) === true) { email.htmlBody = this.getNodeParameter('htmlMessage', i) as string; } @@ -379,7 +364,6 @@ export class Gmail implements INodeType { responseData = await googleApiRequest.call(this, method, endpoint, body, qs); } if (operation === 'reply') { - const id = this.getNodeParameter('messageId', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; @@ -415,15 +399,20 @@ export class Gmail implements INodeType { const attachmentsUi = additionalFields.attachmentsUi as IDataObject; const attachmentsBinary = []; if (!isEmpty(attachmentsUi)) { - if (attachmentsUi.hasOwnProperty('attachmentsBinary') - && !isEmpty(attachmentsUi.attachmentsBinary) - && items[i].binary) { + if ( + attachmentsUi.hasOwnProperty('attachmentsBinary') && + !isEmpty(attachmentsUi.attachmentsBinary) && + items[i].binary + ) { // @ts-ignore for (const { property } of attachmentsUi.attachmentsBinary as IDataObject[]) { for (const binaryProperty of (property as string).split(',')) { if (items[i].binary![binaryProperty] !== undefined) { const binaryData = items[i].binary![binaryProperty]; - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + i, + binaryProperty, + ); attachmentsBinary.push({ name: binaryData.fileName || 'unknown', content: binaryDataBuffer, @@ -458,7 +447,7 @@ export class Gmail implements INodeType { } const email: IEmail = { - from: additionalFields.senderName as string || '', + from: (additionalFields.senderName as string) || '', to: toStr, cc: ccStr, bcc: bccStr, @@ -467,7 +456,7 @@ export class Gmail implements INodeType { attachments: attachmentsList, }; - if (this.getNodeParameter('includeHtml', i, false) as boolean === true) { + if ((this.getNodeParameter('includeHtml', i, false) as boolean) === true) { email.htmlBody = this.getNodeParameter('htmlMessage', i) as string; } @@ -505,9 +494,14 @@ export class Gmail implements INodeType { let nodeExecutionData: INodeExecutionData; if (format === 'resolved') { - const dataPropertyNameDownload = additionalFields.dataPropertyAttachmentsPrefixName as string || 'attachment_'; + const dataPropertyNameDownload = + (additionalFields.dataPropertyAttachmentsPrefixName as string) || 'attachment_'; - nodeExecutionData = await parseRawEmail.call(this, responseData, dataPropertyNameDownload); + nodeExecutionData = await parseRawEmail.call( + this, + responseData, + dataPropertyNameDownload, + ); } else { nodeExecutionData = { json: responseData, @@ -558,7 +552,6 @@ export class Gmail implements INodeType { const format = additionalFields.format || 'resolved'; if (format !== 'ids') { - if (format === 'resolved') { qs.format = 'raw'; } else { @@ -575,9 +568,14 @@ export class Gmail implements INodeType { ); if (format === 'resolved') { - const dataPropertyNameDownload = additionalFields.dataPropertyAttachmentsPrefixName as string || 'attachment_'; + const dataPropertyNameDownload = + (additionalFields.dataPropertyAttachmentsPrefixName as string) || 'attachment_'; - responseData[i] = await parseRawEmail.call(this, responseData[i], dataPropertyNameDownload); + responseData[i] = await parseRawEmail.call( + this, + responseData[i], + dataPropertyNameDownload, + ); } } } @@ -585,7 +583,6 @@ export class Gmail implements INodeType { if (format !== 'resolved') { responseData = this.helpers.returnJsonArray(responseData); } - } if (operation === 'delete') { // https://developers.google.com/gmail/api/v1/reference/users/messages/delete @@ -639,14 +636,19 @@ export class Gmail implements INodeType { const attachmentsBinary = []; if (!isEmpty(attachmentsUi)) { if (!isEmpty(attachmentsUi)) { - if (attachmentsUi.hasOwnProperty('attachmentsBinary') - && !isEmpty(attachmentsUi.attachmentsBinary) - && items[i].binary) { + if ( + attachmentsUi.hasOwnProperty('attachmentsBinary') && + !isEmpty(attachmentsUi.attachmentsBinary) && + items[i].binary + ) { for (const { property } of attachmentsUi.attachmentsBinary as IDataObject[]) { for (const binaryProperty of (property as string).split(',')) { if (items[i].binary![binaryProperty] !== undefined) { const binaryData = items[i].binary![binaryProperty]; - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + i, + binaryProperty, + ); attachmentsBinary.push({ name: binaryData.fileName || 'unknown', content: binaryDataBuffer, @@ -676,7 +678,7 @@ export class Gmail implements INodeType { attachments: attachmentsList, }; - if (this.getNodeParameter('includeHtml', i, false) as boolean === true) { + if ((this.getNodeParameter('includeHtml', i, false) as boolean) === true) { email.htmlBody = this.getNodeParameter('htmlMessage', i) as string; } @@ -713,9 +715,14 @@ export class Gmail implements INodeType { let nodeExecutionData: INodeExecutionData; if (format === 'resolved') { - const dataPropertyNameDownload = additionalFields.dataPropertyAttachmentsPrefixName as string || 'attachment_'; + const dataPropertyNameDownload = + (additionalFields.dataPropertyAttachmentsPrefixName as string) || 'attachment_'; - nodeExecutionData = await parseRawEmail.call(this, responseData.message, dataPropertyNameDownload); + nodeExecutionData = await parseRawEmail.call( + this, + responseData.message, + dataPropertyNameDownload, + ); // Add the draft-id nodeExecutionData.json.messageId = nodeExecutionData.json.id; @@ -780,7 +787,6 @@ export class Gmail implements INodeType { } for (let i = 0; i < responseData.length; i++) { - responseData[i] = await googleApiRequest.call( this, 'GET', @@ -790,9 +796,14 @@ export class Gmail implements INodeType { ); if (format === 'resolved') { - const dataPropertyNameDownload = additionalFields.dataPropertyAttachmentsPrefixName as string || 'attachment_'; + const dataPropertyNameDownload = + (additionalFields.dataPropertyAttachmentsPrefixName as string) || 'attachment_'; const id = responseData[i].id; - responseData[i] = await parseRawEmail.call(this, responseData[i].message, dataPropertyNameDownload); + responseData[i] = await parseRawEmail.call( + this, + responseData[i].message, + dataPropertyNameDownload, + ); // Add the draft-id responseData[i].json.messageId = responseData[i].json.id; diff --git a/packages/nodes-base/nodes/Google/Gmail/LabelDescription.ts b/packages/nodes-base/nodes/Google/Gmail/LabelDescription.ts index 990a308028..70a59ac216 100644 --- a/packages/nodes-base/nodes/Google/Gmail/LabelDescription.ts +++ b/packages/nodes-base/nodes/Google/Gmail/LabelDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const labelOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const labelOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'label', - ], + resource: ['label'], }, }, options: [ @@ -54,12 +50,8 @@ export const labelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'label', - ], - operation: [ - 'create', - ], + resource: ['label'], + operation: ['create'], }, }, placeholder: 'invoices', @@ -73,13 +65,8 @@ export const labelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'label', - ], - operation: [ - 'get', - 'delete', - ], + resource: ['label'], + operation: ['get', 'delete'], }, }, description: 'The ID of the label', @@ -106,12 +93,8 @@ export const labelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'label', - ], - operation: [ - 'create', - ], + resource: ['label'], + operation: ['create'], }, }, description: 'The visibility of the label in the label list in the Gmail web interface', @@ -134,15 +117,12 @@ export const labelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'label', - ], - operation: [ - 'create', - ], + resource: ['label'], + operation: ['create'], }, }, - description: 'The visibility of messages with this label in the message list in the Gmail web interface', + description: + 'The visibility of messages with this label in the message list in the Gmail web interface', }, /* -------------------------------------------------------------------------- */ /* label:getAll */ @@ -153,12 +133,8 @@ export const labelFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'label', - ], + operation: ['getAll'], + resource: ['label'], }, }, default: false, @@ -170,15 +146,9 @@ export const labelFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'label', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['label'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Google/Gmail/MessageDescription.ts b/packages/nodes-base/nodes/Google/Gmail/MessageDescription.ts index b6c2b83ee9..f657b765ec 100644 --- a/packages/nodes-base/nodes/Google/Gmail/MessageDescription.ts +++ b/packages/nodes-base/nodes/Google/Gmail/MessageDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const messageOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const messageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'message', - ], + resource: ['message'], }, }, options: [ @@ -60,13 +56,8 @@ export const messageFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'get', - 'delete', - ], + resource: ['message'], + operation: ['get', 'delete'], }, }, placeholder: '172ce2c4a72cc243', @@ -80,12 +71,8 @@ export const messageFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'reply', - ], + resource: ['message'], + operation: ['reply'], }, }, placeholder: '172ce2c4a72cc243', @@ -99,12 +86,8 @@ export const messageFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'reply', - ], + resource: ['message'], + operation: ['reply'], }, }, placeholder: 'CAHNQoFsC6JMMbOBJgtjsqN0eEc+gDg2a=SQj-tWUebQeHMDgqQ@mail.gmail.com', @@ -118,13 +101,8 @@ export const messageFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'reply', - 'send', - ], + resource: ['message'], + operation: ['reply', 'send'], }, }, placeholder: 'Hello World!', @@ -136,13 +114,8 @@ export const messageFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'send', - 'reply', - ], + resource: ['message'], + operation: ['send', 'reply'], }, }, default: false, @@ -156,16 +129,9 @@ export const messageFields: INodeProperties[] = [ required: true, displayOptions: { show: { - includeHtml: [ - true, - ], - resource: [ - 'message', - ], - operation: [ - 'reply', - 'send', - ], + includeHtml: [true], + resource: ['message'], + operation: ['reply', 'send'], }, }, description: 'The HTML message body', @@ -178,13 +144,8 @@ export const messageFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'reply', - 'send', - ], + resource: ['message'], + operation: ['reply', 'send'], }, }, description: 'Plain text message body', @@ -201,13 +162,8 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'reply', - 'send', - ], + resource: ['message'], + operation: ['reply', 'send'], }, }, placeholder: 'info@example.com', @@ -220,13 +176,8 @@ export const messageFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'send', - 'reply', - ], + resource: ['message'], + operation: ['send', 'reply'], }, }, default: {}, @@ -249,7 +200,8 @@ export const messageFields: INodeProperties[] = [ name: 'property', type: 'string', default: '', - description: 'Name of the binary property containing the data to be added to the email as an attachment. Multiple properties can be set separated by comma.', + description: + 'Name of the binary property containing the data to be added to the email as an attachment. Multiple properties can be set separated by comma.', }, ], }, @@ -287,7 +239,8 @@ export const messageFields: INodeProperties[] = [ type: 'string', placeholder: 'Name ', default: '', - description: 'The name displayed in your contacts inboxes. It has to be in the format: "Display-Name <name@gmail.com>". The email address has to match the email address of the logged in user for the API', + description: + 'The name displayed in your contacts inboxes. It has to be in the format: "Display-Name <name@gmail.com>". The email address has to match the email address of the logged in user for the API', }, ], }, @@ -298,12 +251,8 @@ export const messageFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'get', - ], + resource: ['message'], + operation: ['get'], }, }, default: {}, @@ -316,7 +265,8 @@ export const messageFields: INodeProperties[] = [ { name: 'Full', value: 'full', - description: 'Returns the full email message data with body content parsed in the payload field', + description: + 'Returns the full email message data with body content parsed in the payload field', }, { name: 'Metadata', @@ -326,17 +276,20 @@ export const messageFields: INodeProperties[] = [ { name: 'Minimal', value: 'minimal', - description: 'Returns only email message ID and labels; does not return the email headers, body, or payload', + description: + 'Returns only email message ID and labels; does not return the email headers, body, or payload', }, { name: 'RAW', value: 'raw', - description: 'Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used', + description: + 'Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used', }, { name: 'Resolved', value: 'resolved', - description: 'Returns the full email with all data resolved and attachments saved as binary data', + description: + 'Returns the full email with all data resolved and attachments saved as binary data', }, ], default: 'resolved', @@ -349,15 +302,11 @@ export const messageFields: INodeProperties[] = [ default: 'attachment_', displayOptions: { hide: { - format: [ - 'full', - 'metadata', - 'minimal', - 'raw', - ], + format: ['full', 'metadata', 'minimal', 'raw'], }, }, - description: 'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"', + description: + 'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"', }, ], }, @@ -371,12 +320,8 @@ export const messageFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'message', - ], + operation: ['getAll'], + resource: ['message'], }, }, default: false, @@ -388,15 +333,9 @@ export const messageFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'message', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['message'], + returnAll: [false], }, }, typeOptions: { @@ -414,12 +353,8 @@ export const messageFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'message', - ], + operation: ['getAll'], + resource: ['message'], }, }, options: [ @@ -430,16 +365,11 @@ export const messageFields: INodeProperties[] = [ default: 'attachment_', displayOptions: { hide: { - format: [ - 'full', - 'ids', - 'metadata', - 'minimal', - 'raw', - ], + format: ['full', 'ids', 'metadata', 'minimal', 'raw'], }, }, - description: 'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"', + description: + 'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"', }, { displayName: 'Format', @@ -449,7 +379,8 @@ export const messageFields: INodeProperties[] = [ { name: 'Full', value: 'full', - description: 'Returns the full email message data with body content parsed in the payload field', + description: + 'Returns the full email message data with body content parsed in the payload field', }, { name: 'IDs', @@ -464,17 +395,20 @@ export const messageFields: INodeProperties[] = [ { name: 'Minimal', value: 'minimal', - description: 'Returns only email message ID and labels; does not return the email headers, body, or payload', + description: + 'Returns only email message ID and labels; does not return the email headers, body, or payload', }, { name: 'RAW', value: 'raw', - description: 'Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used', + description: + 'Returns the full email message data with body content in the raw field as a base64url encoded string; the payload field is not used', }, { name: 'Resolved', value: 'resolved', - description: 'Returns the full email with all data resolved and attachments saved as binary data', + description: + 'Returns the full email with all data resolved and attachments saved as binary data', }, ], default: 'resolved', @@ -495,7 +429,8 @@ export const messageFields: INodeProperties[] = [ loadOptionsMethod: 'getLabels', }, default: [], - description: 'Only return messages with labels that match all of the specified label IDs. Choose from the list, or specify IDs using an expression.', + description: + 'Only return messages with labels that match all of the specified label IDs. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Query', @@ -505,9 +440,9 @@ export const messageFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'Only return messages matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid:<somemsgid@example.com> is:unread". Parameter cannot be used when accessing the api using the gmail.metadata scope.', + description: + 'Only return messages matching the specified query. Supports the same query format as the Gmail search box. For example, "from:someuser@example.com rfc822msgid:<somemsgid@example.com> is:unread". Parameter cannot be used when accessing the api using the gmail.metadata scope.', }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Google/Gmail/MessageLabelDescription.ts b/packages/nodes-base/nodes/Google/Gmail/MessageLabelDescription.ts index f821e2851d..b3a63f331b 100644 --- a/packages/nodes-base/nodes/Google/Gmail/MessageLabelDescription.ts +++ b/packages/nodes-base/nodes/Google/Gmail/MessageLabelDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const messageLabelOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const messageLabelOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'messageLabel', - ], + resource: ['messageLabel'], }, }, options: [ @@ -42,13 +38,8 @@ export const messageLabelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'messageLabel', - ], - operation: [ - 'add', - 'remove', - ], + resource: ['messageLabel'], + operation: ['add', 'remove'], }, }, placeholder: '172ce2c4a72cc243', @@ -65,15 +56,11 @@ export const messageLabelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'messageLabel', - ], - operation: [ - 'add', - 'remove', - ], + resource: ['messageLabel'], + operation: ['add', 'remove'], }, }, - description: 'The ID of the label. Choose from the list, or specify IDs using an expression.', + description: + 'The ID of the label. Choose from the list, or specify IDs using an expression.', }, ]; diff --git a/packages/nodes-base/nodes/Google/Perspective/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Perspective/GenericFunctions.ts index ad93b1a0ec..c6f7859720 100644 --- a/packages/nodes-base/nodes/Google/Perspective/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Perspective/GenericFunctions.ts @@ -1,15 +1,8 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( this: IExecuteFunctions, diff --git a/packages/nodes-base/nodes/Google/Perspective/GooglePerspective.node.ts b/packages/nodes-base/nodes/Google/Perspective/GooglePerspective.node.ts index ed6f00f34e..9883b70d30 100644 --- a/packages/nodes-base/nodes/Google/Perspective/GooglePerspective.node.ts +++ b/packages/nodes-base/nodes/Google/Perspective/GooglePerspective.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,16 +10,9 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - AttributesValuesUi, - CommentAnalyzeBody, - Language, - RequestedAttributes, -} from './types'; +import { AttributesValuesUi, CommentAnalyzeBody, Language, RequestedAttributes } from './types'; -import { - googleApiRequest, -} from './GenericFunctions'; +import { googleApiRequest } from './GenericFunctions'; const ISO6391 = require('iso-639-1'); @@ -30,21 +21,15 @@ export class GooglePerspective implements INodeType { displayName: 'Google Perspective', name: 'googlePerspective', icon: 'file:perspective.svg', - group: [ - 'transform', - ], + group: ['transform'], version: 1, description: 'Consume Google Perspective API', subtitle: '={{$parameter["operation"]}}', defaults: { name: 'Google Perspective', }, - inputs: [ - 'main', - ], - outputs: [ - 'main', - ], + inputs: ['main'], + outputs: ['main'], credentials: [ { name: 'googlePerspectiveOAuth2Api', @@ -73,9 +58,7 @@ export class GooglePerspective implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'analyzeComment', - ], + operation: ['analyzeComment'], }, }, }, @@ -91,9 +74,7 @@ export class GooglePerspective implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'analyzeComment', - ], + operation: ['analyzeComment'], }, }, options: [ @@ -139,7 +120,8 @@ export class GooglePerspective implements INodeType { value: 'toxicity', }, ], - description: 'Attribute to analyze in the text. Details here.', + description: + 'Attribute to analyze in the text. Details here.', default: 'flirtation', }, { @@ -151,7 +133,8 @@ export class GooglePerspective implements INodeType { minValue: 0, maxValue: 1, }, - description: 'Score above which to return results. At zero, all scores are returned.', + description: + 'Score above which to return results. At zero, all scores are returned.', default: 0, }, ], @@ -164,9 +147,7 @@ export class GooglePerspective implements INodeType { type: 'collection', displayOptions: { show: { - operation: [ - 'analyzeComment', - ], + operation: ['analyzeComment'], }, }, default: {}, @@ -180,7 +161,8 @@ export class GooglePerspective implements INodeType { loadOptionsMethod: 'getLanguages', }, default: '', - description: 'Languages of the text input. If unspecified, the API will auto-detect the comment language. Choose from the list, or specify an ID using an expression.', + description: + 'Languages of the text input. If unspecified, the API will auto-detect the comment language. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -203,7 +185,9 @@ export class GooglePerspective implements INodeType { 'Russian', ]; - const languages = ISO6391.getAllNames().filter((language: string) => supportedLanguages.includes(language)); + const languages = ISO6391.getAllNames().filter((language: string) => + supportedLanguages.includes(language), + ); for (const language of languages) { const languageName = language; const languageId = ISO6391.getCode(language); @@ -226,22 +210,21 @@ export class GooglePerspective implements INodeType { let responseData; for (let i = 0; i < items.length; i++) { - try { - - if (operation === 'analyzeComment') { - // https://developers.perspectiveapi.com/s/about-the-api-methods const attributes = this.getNodeParameter( - 'requestedAttributesUi.requestedAttributesValues', i, [], + 'requestedAttributesUi.requestedAttributesValues', + i, + [], ) as AttributesValuesUi[]; if (!attributes.length) { throw new NodeOperationError( this.getNode(), - 'Please enter at least one attribute to analyze.', { itemIndex: i }, + 'Please enter at least one attribute to analyze.', + { itemIndex: i }, ); } @@ -268,10 +251,13 @@ export class GooglePerspective implements INodeType { body.languages = languages; } - responseData = await googleApiRequest.call(this, 'POST', '/v1alpha1/comments:analyze', body); + responseData = await googleApiRequest.call( + this, + 'POST', + '/v1alpha1/comments:analyze', + body, + ); } - - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -283,7 +269,6 @@ export class GooglePerspective implements INodeType { Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } return [this.helpers.returnJsonArray(responseData)]; diff --git a/packages/nodes-base/nodes/Google/Perspective/types.d.ts b/packages/nodes-base/nodes/Google/Perspective/types.d.ts index bb4ade830b..03dde15812 100644 --- a/packages/nodes-base/nodes/Google/Perspective/types.d.ts +++ b/packages/nodes-base/nodes/Google/Perspective/types.d.ts @@ -15,7 +15,7 @@ export type RequestedAttributes = { [key: string]: { scoreType?: string; scoreThreshold?: { - value: number + value: number; }; }; }; diff --git a/packages/nodes-base/nodes/Google/Sheet/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Sheet/GenericFunctions.ts index 93c147a548..4d885db711 100644 --- a/packages/nodes-base/nodes/Google/Sheet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Sheet/GenericFunctions.ts @@ -1,16 +1,12 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { ICredentialTestFunctions, - IDataObject, NodeApiError, NodeOperationError, + IDataObject, + NodeApiError, + NodeOperationError, } from 'n8n-workflow'; import moment from 'moment-timezone'; @@ -24,8 +20,22 @@ export interface IGoogleAuthCredentials { privateKey: string; } -export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any - const authenticationMethod = this.getNodeParameter('authentication', 0, 'serviceAccount') as string; +export async function googleApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { + const authenticationMethod = this.getNodeParameter( + 'authentication', + 0, + 'serviceAccount', + ) as string; const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -47,7 +57,10 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF if (authenticationMethod === 'serviceAccount') { const credentials = await this.getCredentials('googleApi'); - const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials); + const { access_token } = await getAccessToken.call( + this, + credentials as unknown as IGoogleAuthCredentials, + ); options.headers!.Authorization = `Bearer ${access_token}`; //@ts-ignore @@ -65,8 +78,16 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function googleApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -76,15 +97,19 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData['nextPageToken']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['nextPageToken'] !== undefined && - responseData['nextPageToken'] !== '' - ); + } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); return returnData; } -export function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | ICredentialTestFunctions, credentials: IGoogleAuthCredentials): Promise { +export function getAccessToken( + this: + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | ICredentialTestFunctions, + credentials: IGoogleAuthCredentials, +): Promise { //https://developers.google.com/identity/protocols/oauth2/service-account#httprest const scopes = [ @@ -100,20 +125,20 @@ export function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions const signature = jwt.sign( { - 'iss': credentials.email as string, - 'sub': credentials.delegatedEmail || credentials.email as string, - 'scope': scopes.join(' '), - 'aud': `https://oauth2.googleapis.com/token`, - 'iat': now, - 'exp': now + 3600, + iss: credentials.email as string, + sub: credentials.delegatedEmail || (credentials.email as string), + scope: scopes.join(' '), + aud: `https://oauth2.googleapis.com/token`, + iat: now, + exp: now + 3600, }, privateKey, { algorithm: 'RS256', header: { - 'kid': privateKey, - 'typ': 'JWT', - 'alg': 'RS256', + kid: privateKey, + typ: 'JWT', + alg: 'RS256', }, }, ); @@ -144,9 +169,14 @@ export function hexToRgb(hex: string) { }); const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); - return result ? { - red: parseInt(result[1], 16), - green: parseInt(result[2], 16), - blue: parseInt(result[3], 16), - } : null; + + if (result) { + return { + red: parseInt(result[1], 16), + green: parseInt(result[2], 16), + blue: parseInt(result[3], 16), + }; + } + + return null; } diff --git a/packages/nodes-base/nodes/Google/Sheet/GoogleSheet.ts b/packages/nodes-base/nodes/Google/Sheet/GoogleSheet.ts index 2f82f2e6e9..37a2e72ebe 100644 --- a/packages/nodes-base/nodes/Google/Sheet/GoogleSheet.ts +++ b/packages/nodes-base/nodes/Google/Sheet/GoogleSheet.ts @@ -1,19 +1,10 @@ -import { - IDataObject, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeOperationError } from 'n8n-workflow'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - googleApiRequest, -} from './GenericFunctions'; +import { googleApiRequest } from './GenericFunctions'; -import { - utils as xlsxUtils, -} from 'xlsx'; +import { utils as xlsxUtils } from 'xlsx'; import { get } from 'lodash'; @@ -56,7 +47,11 @@ export class GoogleSheet { id: string; executeFunctions: IExecuteFunctions | ILoadOptionsFunctions; - constructor(spreadsheetId: string, executeFunctions: IExecuteFunctions | ILoadOptionsFunctions, options?: ISheetOptions | undefined) { + constructor( + spreadsheetId: string, + executeFunctions: IExecuteFunctions | ILoadOptionsFunctions, + options?: ISheetOptions | undefined, + ) { // options = options || {}; if (!options) { options = {} as ISheetOptions; @@ -66,7 +61,6 @@ export class GoogleSheet { this.id = spreadsheetId; } - /** * Encodes the range that also none latin character work * @@ -82,7 +76,6 @@ export class GoogleSheet { return range; } - /** * Clears values from a sheet * @@ -91,13 +84,17 @@ export class GoogleSheet { * @memberof GoogleSheet */ async clearData(range: string): Promise { - const body = { spreadsheetId: this.id, range, }; - const response = await googleApiRequest.call(this.executeFunctions, 'POST', `/v4/spreadsheets/${this.id}/values/${range}:clear`, body); + const response = await googleApiRequest.call( + this.executeFunctions, + 'POST', + `/v4/spreadsheets/${this.id}/values/${range}:clear`, + body, + ); return response; } @@ -105,85 +102,106 @@ export class GoogleSheet { /** * Returns the cell values */ - async getData(range: string, valueRenderMode: ValueRenderOption): Promise { - + async getData( + range: string, + valueRenderMode: ValueRenderOption, + ): Promise { const query = { valueRenderOption: valueRenderMode, }; - const response = await googleApiRequest.call(this.executeFunctions, 'GET', `/v4/spreadsheets/${this.id}/values/${range}`, {}, query); + const response = await googleApiRequest.call( + this.executeFunctions, + 'GET', + `/v4/spreadsheets/${this.id}/values/${range}`, + {}, + query, + ); return response.values as string[][] | undefined; } - /** * Returns the sheets in a Spreadsheet */ async spreadsheetGetSheets() { - const query = { fields: 'sheets.properties', }; - const response = await googleApiRequest.call(this.executeFunctions, 'GET', `/v4/spreadsheets/${this.id}`, {}, query); + const response = await googleApiRequest.call( + this.executeFunctions, + 'GET', + `/v4/spreadsheets/${this.id}`, + {}, + query, + ); return response; } - /** * Sets values in one or more ranges of a spreadsheet. */ - async spreadsheetBatchUpdate(requests: IDataObject[]) { // tslint:disable-line:no-any + async spreadsheetBatchUpdate(requests: IDataObject[]) { + // tslint:disable-line:no-any const body = { requests, }; - const response = await googleApiRequest.call(this.executeFunctions, 'POST', `/v4/spreadsheets/${this.id}:batchUpdate`, body); + const response = await googleApiRequest.call( + this.executeFunctions, + 'POST', + `/v4/spreadsheets/${this.id}:batchUpdate`, + body, + ); return response; } - /** * Sets the cell values */ async batchUpdate(updateData: ISheetUpdateData[], valueInputMode: ValueInputOption) { - const body = { data: updateData, valueInputOption: valueInputMode, }; - const response = await googleApiRequest.call(this.executeFunctions, 'POST', `/v4/spreadsheets/${this.id}/values:batchUpdate`, body); + const response = await googleApiRequest.call( + this.executeFunctions, + 'POST', + `/v4/spreadsheets/${this.id}/values:batchUpdate`, + body, + ); return response; } - /** * Sets the cell values */ async setData(range: string, data: string[][], valueInputMode: ValueInputOption) { - const body = { valueInputOption: valueInputMode, values: data, }; - const response = await googleApiRequest.call(this.executeFunctions, 'POST', `/v4/spreadsheets/${this.id}/values/${range}`, body); + const response = await googleApiRequest.call( + this.executeFunctions, + 'POST', + `/v4/spreadsheets/${this.id}/values/${range}`, + body, + ); return response; } - /** * Appends the cell values */ async appendData(range: string, data: string[][], valueInputMode: ValueInputOption) { - const body = { range: decodeURIComponent(range), values: data, @@ -193,7 +211,13 @@ export class GoogleSheet { valueInputOption: valueInputMode, }; - const response = await googleApiRequest.call(this.executeFunctions, 'POST', `/v4/spreadsheets/${this.id}/values/${range}:append`, body, query); + const response = await googleApiRequest.call( + this.executeFunctions, + 'POST', + `/v4/spreadsheets/${this.id}/values/${range}:append`, + body, + query, + ); return response; } @@ -201,7 +225,12 @@ export class GoogleSheet { /** * Returns the given sheet data in a structured way */ - structureData(inputData: string[][], startRow: number, keys: string[], addEmpty?: boolean): IDataObject[] { + structureData( + inputData: string[][], + startRow: number, + keys: string[], + addEmpty?: boolean, + ): IDataObject[] { const returnData = []; let tempEntry: IDataObject, rowIndex: number, columnIndex: number, key: string; @@ -224,13 +253,15 @@ export class GoogleSheet { return returnData; } - /** * Returns the given sheet data in a structured way using * the startRow as the one with the name of the key */ - structureArrayDataByColumn(inputData: string[][], keyRow: number, dataStartRow: number): IDataObject[] { - + structureArrayDataByColumn( + inputData: string[][], + keyRow: number, + dataStartRow: number, + ): IDataObject[] { const keys: string[] = []; if (keyRow < 0 || dataStartRow < keyRow || keyRow >= inputData.length) { @@ -246,19 +277,27 @@ export class GoogleSheet { return this.structureData(inputData, dataStartRow, keys); } - - async appendSheetData(inputData: IDataObject[], range: string, keyRowIndex: number, valueInputMode: ValueInputOption, usePathForKeyRow: boolean): Promise { - const data = await this.convertStructuredDataToArray(inputData, range, keyRowIndex, usePathForKeyRow); + async appendSheetData( + inputData: IDataObject[], + range: string, + keyRowIndex: number, + valueInputMode: ValueInputOption, + usePathForKeyRow: boolean, + ): Promise { + const data = await this.convertStructuredDataToArray( + inputData, + range, + keyRowIndex, + usePathForKeyRow, + ); return this.appendData(range, data, valueInputMode); } - getColumnWithOffset(startColumn: string, offset: number): string { const columnIndex = xlsxUtils.decode_col(startColumn) + offset; return xlsxUtils.encode_col(columnIndex); } - /** * Updates data in a sheet * @@ -271,15 +310,15 @@ export class GoogleSheet { * @memberof GoogleSheet */ async updateSheetData( - inputData: IDataObject[], - indexKey: string, - range: string, - keyRowIndex: number, - dataStartRowIndex: number, - valueInputMode: ValueInputOption, - valueRenderMode: ValueRenderOption, - upsert = false, - ): Promise { + inputData: IDataObject[], + indexKey: string, + range: string, + keyRowIndex: number, + dataStartRowIndex: number, + valueInputMode: ValueInputOption, + valueRenderMode: ValueRenderOption, + upsert = false, + ): Promise { // Get current data in Google Sheet let rangeStart: string, rangeEnd: string, rangeFull: string; let sheet: string | undefined = undefined; @@ -293,16 +332,29 @@ export class GoogleSheet { const rangeStartSplit = rangeStart.match(/([a-zA-Z]{1,10})([0-9]{0,10})/); const rangeEndSplit = rangeEnd.match(/([a-zA-Z]{1,10})([0-9]{0,10})/); - if (rangeStartSplit === null || rangeStartSplit.length !== 3 || rangeEndSplit === null || rangeEndSplit.length !== 3) { - throw new NodeOperationError(this.executeFunctions.getNode(), `The range "${range}" is not valid.`); + if ( + rangeStartSplit === null || + rangeStartSplit.length !== 3 || + rangeEndSplit === null || + rangeEndSplit.length !== 3 + ) { + throw new NodeOperationError( + this.executeFunctions.getNode(), + `The range "${range}" is not valid.`, + ); } - const keyRowRange = `${sheet ? sheet + '!' : ''}${rangeStartSplit[1]}${keyRowIndex + 1}:${rangeEndSplit[1]}${keyRowIndex + 1}`; + const keyRowRange = `${sheet ? sheet + '!' : ''}${rangeStartSplit[1]}${keyRowIndex + 1}:${ + rangeEndSplit[1] + }${keyRowIndex + 1}`; const sheetDatakeyRow = await this.getData(this.encodeRange(keyRowRange), valueRenderMode); if (sheetDatakeyRow === undefined) { - throw new NodeOperationError(this.executeFunctions.getNode(), 'Could not retrieve the key row!'); + throw new NodeOperationError( + this.executeFunctions.getNode(), + 'Could not retrieve the key row!', + ); } const keyColumnOrder = sheetDatakeyRow[0]; @@ -310,19 +362,30 @@ export class GoogleSheet { const keyIndex = keyColumnOrder.indexOf(indexKey); if (keyIndex === -1) { - throw new NodeOperationError(this.executeFunctions.getNode(), `Could not find column for key "${indexKey}"!`); + throw new NodeOperationError( + this.executeFunctions.getNode(), + `Could not find column for key "${indexKey}"!`, + ); } const startRowIndex = rangeStartSplit[2] || dataStartRowIndex; const endRowIndex = rangeEndSplit[2] || ''; const keyColumn = this.getColumnWithOffset(rangeStartSplit[1], keyIndex); - const keyColumnRange = `${sheet ? sheet + '!' : ''}${keyColumn}${startRowIndex}:${keyColumn}${endRowIndex}`; + const keyColumnRange = `${ + sheet ? sheet + '!' : '' + }${keyColumn}${startRowIndex}:${keyColumn}${endRowIndex}`; - const sheetDataKeyColumn = await this.getData(this.encodeRange(keyColumnRange), valueRenderMode); + const sheetDataKeyColumn = await this.getData( + this.encodeRange(keyColumnRange), + valueRenderMode, + ); if (sheetDataKeyColumn === undefined) { - throw new NodeOperationError(this.executeFunctions.getNode(), 'Could not retrieve the key column!'); + throw new NodeOperationError( + this.executeFunctions.getNode(), + 'Could not retrieve the key column!', + ); } // TODO: The data till here can be cached optionally. Maybe add an option which can @@ -346,7 +409,13 @@ export class GoogleSheet { if (itemKey === undefined || itemKey === null) { // Item does not have the indexKey so we can ignore it or append it if upsert true if (upsert) { - const data = await this.appendSheetData([inputItem], this.encodeRange(range), keyRowIndex, valueInputMode, false); + const data = await this.appendSheetData( + [inputItem], + this.encodeRange(range), + keyRowIndex, + valueInputMode, + false, + ); } continue; } @@ -356,7 +425,13 @@ export class GoogleSheet { if (itemKeyIndex === -1) { // Key does not exist in the Sheet so it can not be updated so skip it or append it if upsert true if (upsert) { - const data = await this.appendSheetData([inputItem], this.encodeRange(range), keyRowIndex, valueInputMode, false); + const data = await this.appendSheetData( + [inputItem], + this.encodeRange(range), + keyRowIndex, + valueInputMode, + false, + ); } continue; } @@ -380,24 +455,21 @@ export class GoogleSheet { // Property exists so add it to the data to update // Get the column name in which the property data can be found - updateColumnName = this.getColumnWithOffset(rangeStartSplit[1], keyColumnOrder.indexOf(propertyName)); + updateColumnName = this.getColumnWithOffset( + rangeStartSplit[1], + keyColumnOrder.indexOf(propertyName), + ); updateData.push({ range: `${sheet ? sheet + '!' : ''}${updateColumnName}${updateRowIndex}`, - values: [ - [ - inputItem[propertyName] as string, - ], - ], + values: [[inputItem[propertyName] as string]], }); - } } return this.batchUpdate(updateData, valueInputMode); } - /** * Looks for a specific value in a column and if it gets found it returns the whole row * @@ -409,7 +481,13 @@ export class GoogleSheet { * @returns {Promise} * @memberof GoogleSheet */ - async lookupValues(inputData: string[][], keyRowIndex: number, dataStartRowIndex: number, lookupValues: ILookupValues[], returnAllMatches?: boolean): Promise { + async lookupValues( + inputData: string[][], + keyRowIndex: number, + dataStartRowIndex: number, + lookupValues: ILookupValues[], + returnAllMatches?: boolean, + ): Promise { const keys: string[] = []; if (keyRowIndex < 0 || dataStartRowIndex < keyRowIndex || keyRowIndex >= inputData.length) { @@ -422,9 +500,7 @@ export class GoogleSheet { keys.push(inputData[keyRowIndex][columnIndex]); } - const returnData = [ - inputData[keyRowIndex], - ]; + const returnData = [inputData[keyRowIndex]]; // Standardise values array, if rows is [[]], map it to [['']] (Keep the columns into consideration) for (let rowIndex = 0; rowIndex < inputData?.length; rowIndex++) { @@ -444,17 +520,21 @@ export class GoogleSheet { let rowIndex: number; let returnColumnIndex: number; - lookupLoop: - for (const lookupValue of lookupValues) { + lookupLoop: for (const lookupValue of lookupValues) { returnColumnIndex = keys.indexOf(lookupValue.lookupColumn); if (returnColumnIndex === -1) { - throw new NodeOperationError(this.executeFunctions.getNode(), `The column "${lookupValue.lookupColumn}" could not be found!`); + throw new NodeOperationError( + this.executeFunctions.getNode(), + `The column "${lookupValue.lookupColumn}" could not be found!`, + ); } // Loop over all the items and find the one with the matching value for (rowIndex = dataStartRowIndex; rowIndex < inputData.length; rowIndex++) { - if (inputData[rowIndex][returnColumnIndex]?.toString() === lookupValue.lookupValue.toString()) { + if ( + inputData[rowIndex][returnColumnIndex]?.toString() === lookupValue.lookupValue.toString() + ) { returnData.push(inputData[rowIndex]); if (returnAllMatches !== true) { @@ -473,8 +553,12 @@ export class GoogleSheet { return this.structureData(returnData, 1, keys, true); } - - async convertStructuredDataToArray(inputData: IDataObject[], range: string, keyRowIndex: number, usePathForKeyRow: boolean): Promise { + async convertStructuredDataToArray( + inputData: IDataObject[], + range: string, + keyRowIndex: number, + usePathForKeyRow: boolean, + ): Promise { let startColumn, endColumn; let sheet: string | undefined = undefined; if (range.includes('!')) { @@ -482,7 +566,6 @@ export class GoogleSheet { } [startColumn, endColumn] = range.split(':'); - let getRange = `${startColumn}${keyRowIndex + 1}:${endColumn}${keyRowIndex + 1}`; if (sheet !== undefined) { @@ -492,7 +575,10 @@ export class GoogleSheet { const keyColumnData = await this.getData(getRange, 'UNFORMATTED_VALUE'); if (keyColumnData === undefined) { - throw new NodeOperationError(this.executeFunctions.getNode(), 'Could not retrieve the column data!'); + throw new NodeOperationError( + this.executeFunctions.getNode(), + 'Could not retrieve the column data!', + ); } const keyColumnOrder = keyColumnData[0]; @@ -504,9 +590,16 @@ export class GoogleSheet { rowData = []; keyColumnOrder.forEach((key) => { const value = get(item, key) as string; - if (usePathForKeyRow && value !== undefined && value !== null) { //match by key path + if (usePathForKeyRow && value !== undefined && value !== null) { + //match by key path rowData.push(value!.toString()); - } else if (!usePathForKeyRow && item.hasOwnProperty(key) && item[key] !== null && item[key] !== undefined) { //match by exact key name + } else if ( + !usePathForKeyRow && + item.hasOwnProperty(key) && + item[key] !== null && + item[key] !== undefined + ) { + //match by exact key name rowData.push(item[key]!.toString()); } else { rowData.push(''); diff --git a/packages/nodes-base/nodes/Google/Sheet/GoogleSheets.node.ts b/packages/nodes-base/nodes/Google/Sheet/GoogleSheets.node.ts index 6162566f86..d4dedc2024 100644 --- a/packages/nodes-base/nodes/Google/Sheet/GoogleSheets.node.ts +++ b/packages/nodes-base/nodes/Google/Sheet/GoogleSheets.node.ts @@ -1,7 +1,4 @@ - -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -52,9 +49,7 @@ export class GoogleSheets implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'serviceAccount', - ], + authentication: ['serviceAccount'], }, }, testedBy: 'googleApiCredentialTest', @@ -64,9 +59,7 @@ export class GoogleSheets implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -89,9 +82,7 @@ export class GoogleSheets implements INodeType { default: 'serviceAccount', displayOptions: { show: { - '@version': [ - 1, - ], + '@version': [1], }, }, }, @@ -112,9 +103,7 @@ export class GoogleSheets implements INodeType { default: 'oAuth2', displayOptions: { show: { - '@version': [ - 2, - ], + '@version': [2], }, }, }, @@ -132,7 +121,6 @@ export class GoogleSheets implements INodeType { name: 'Sheet', value: 'sheet', }, - ], default: 'sheet', }, @@ -143,9 +131,7 @@ export class GoogleSheets implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'sheet', - ], + resource: ['sheet'], }, }, options: [ @@ -170,7 +156,8 @@ export class GoogleSheets implements INodeType { { name: 'Create or Update', value: 'upsert', - description: 'Create a new record, or update the current one if it already exists (upsert)', + description: + 'Create a new record, or update the current one if it already exists (upsert)', action: 'Create or update a sheet', }, { @@ -216,14 +203,13 @@ export class GoogleSheets implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'sheet', - ], + resource: ['sheet'], }, }, default: '', required: true, - description: 'The ID of the Google Spreadsheet. Found as part of the sheet URL https://docs.google.com/spreadsheets/d/{ID}/.', + description: + 'The ID of the Google Spreadsheet. Found as part of the sheet URL https://docs.google.com/spreadsheets/d/{ID}/.', }, { displayName: 'Range', @@ -231,21 +217,16 @@ export class GoogleSheets implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'sheet', - ], + resource: ['sheet'], }, hide: { - operation: [ - 'create', - 'delete', - 'remove', - ], + operation: ['create', 'delete', 'remove'], }, }, default: 'A:F', required: true, - description: 'The table range to read from or to append data to. See the Google documentation for the details. If it contains multiple sheets it can also be added like this: "MySheet!A:F"', + description: + 'The table range to read from or to append data to. See the Google documentation for the details. If it contains multiple sheets it can also be added like this: "MySheet!A:F"', }, // ---------------------------------- @@ -262,12 +243,8 @@ export class GoogleSheets implements INodeType { }, displayOptions: { show: { - resource: [ - 'sheet', - ], - operation: [ - 'delete', - ], + resource: ['sheet'], + operation: ['delete'], }, }, default: {}, @@ -286,7 +263,8 @@ export class GoogleSheets implements INodeType { options: [], default: '', required: true, - description: 'The sheet to delete columns from. Choose from the list, or specify an ID using an expression.', + description: + 'The sheet to delete columns from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Start Index', @@ -324,7 +302,8 @@ export class GoogleSheets implements INodeType { options: [], default: '', required: true, - description: 'The sheet to delete columns from. Choose from the list, or specify an ID using an expression.', + description: + 'The sheet to delete columns from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Start Index', @@ -351,7 +330,6 @@ export class GoogleSheets implements INodeType { ], }, - // ---------------------------------- // Read // ---------------------------------- @@ -361,16 +339,13 @@ export class GoogleSheets implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'sheet', - ], - operation: [ - 'read', - ], + resource: ['sheet'], + operation: ['read'], }, }, default: false, - description: 'Whether the data should be returned RAW instead of parsed into keys according to their header', + description: + 'Whether the data should be returned RAW instead of parsed into keys according to their header', }, { displayName: 'Data Property', @@ -379,15 +354,9 @@ export class GoogleSheets implements INodeType { default: 'data', displayOptions: { show: { - resource: [ - 'sheet', - ], - operation: [ - 'read', - ], - rawData: [ - true, - ], + resource: ['sheet'], + operation: ['read'], + rawData: [true], }, }, description: 'The name of the property into which to write the RAW data', @@ -402,13 +371,8 @@ export class GoogleSheets implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'sheet', - ], - operation: [ - 'update', - 'upsert', - ], + resource: ['sheet'], + operation: ['update', 'upsert'], }, }, default: false, @@ -421,16 +385,9 @@ export class GoogleSheets implements INodeType { default: 'data', displayOptions: { show: { - resource: [ - 'sheet', - ], - operation: [ - 'update', - 'upsert', - ], - rawData: [ - true, - ], + resource: ['sheet'], + operation: ['update', 'upsert'], + rawData: [true], }, }, description: 'The name of the property from which to read the RAW data', @@ -449,24 +406,15 @@ export class GoogleSheets implements INodeType { default: 1, displayOptions: { show: { - resource: [ - 'sheet', - ], + resource: ['sheet'], }, hide: { - operation: [ - 'append', - 'create', - 'clear', - 'delete', - 'remove', - ], - rawData: [ - true, - ], + operation: ['append', 'create', 'clear', 'delete', 'remove'], + rawData: [true], }, }, - description: 'Index of the first row which contains the actual data and not the keys. Starts with 0.', + description: + 'Index of the first row which contains the actual data and not the keys. Starts with 0.', }, // ---------------------------------- @@ -481,27 +429,18 @@ export class GoogleSheets implements INodeType { }, displayOptions: { show: { - resource: [ - 'sheet', - ], + resource: ['sheet'], }, hide: { - operation: [ - 'clear', - 'create', - 'delete', - 'remove', - ], - rawData: [ - true, - ], + operation: ['clear', 'create', 'delete', 'remove'], + rawData: [true], }, }, default: 0, - description: 'Index of the row which contains the keys. Starts at 0. The incoming node data is matched to the keys for assignment. The matching is case sensitive.', + description: + 'Index of the row which contains the keys. Starts at 0. The incoming node data is matched to the keys for assignment. The matching is case sensitive.', }, - // ---------------------------------- // lookup // ---------------------------------- @@ -514,12 +453,8 @@ export class GoogleSheets implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'sheet', - ], - operation: [ - 'lookup', - ], + resource: ['sheet'], + operation: ['lookup'], }, }, description: 'The name of the column in which to look for value', @@ -532,12 +467,8 @@ export class GoogleSheets implements INodeType { placeholder: 'frank@example.com', displayOptions: { show: { - resource: [ - 'sheet', - ], - operation: [ - 'lookup', - ], + resource: ['sheet'], + operation: ['lookup'], }, }, description: 'The value to look for in column', @@ -553,16 +484,9 @@ export class GoogleSheets implements INodeType { default: 'id', displayOptions: { show: { - resource: [ - 'sheet', - ], - operation: [ - 'update', - 'upsert', - ], - rawData: [ - false, - ], + resource: ['sheet'], + operation: ['update', 'upsert'], + rawData: [false], }, }, description: 'The name of the key to identify which data should be updated in the sheet', @@ -576,16 +500,8 @@ export class GoogleSheets implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'sheet', - ], - operation: [ - 'append', - 'lookup', - 'read', - 'update', - 'upsert', - ], + resource: ['sheet'], + operation: ['append', 'lookup', 'read', 'update', 'upsert'], }, }, options: [ @@ -596,14 +512,12 @@ export class GoogleSheets implements INodeType { default: false, displayOptions: { show: { - '/operation': [ - 'lookup', - 'read', - ], + '/operation': ['lookup', 'read'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default, the workflow stops executing if the lookup/read does not return values', + description: + 'By default, the workflow stops executing if the lookup/read does not return values', }, { displayName: 'Return All Matches', @@ -612,13 +526,12 @@ export class GoogleSheets implements INodeType { default: false, displayOptions: { show: { - '/operation': [ - 'lookup', - ], + '/operation': ['lookup'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default only the first result gets returned. If options gets set all found matches get returned.', + description: + 'By default only the first result gets returned. If options gets set all found matches get returned.', }, { displayName: 'Use Header Names as JSON Paths', @@ -627,12 +540,11 @@ export class GoogleSheets implements INodeType { default: false, displayOptions: { show: { - '/operation': [ - 'append', - ], + '/operation': ['append'], }, }, - description: 'Whether you want to match the headers as path, for example, the row header "category.name" will match the "category" object and get the field "name" from it. By default "category.name" will match with the field with exact name, not nested object.', + description: + 'Whether you want to match the headers as path, for example, the row header "category.name" will match the "category" object and get the field "name" from it. By default "category.name" will match with the field with exact name, not nested object.', }, { displayName: 'Value Input Mode', @@ -640,11 +552,7 @@ export class GoogleSheets implements INodeType { type: 'options', displayOptions: { show: { - '/operation': [ - 'append', - 'update', - 'upsert', - ], + '/operation': ['append', 'update', 'upsert'], }, }, options: [ @@ -656,7 +564,8 @@ export class GoogleSheets implements INodeType { { name: 'User Entered', value: 'USER_ENTERED', - description: 'The values will be parsed as if the user typed them into the UI. Numbers will stay as numbers, but strings may be converted to numbers, dates, etc. following the same rules that are applied when entering text into a cell via the Google Sheets UI.', + description: + 'The values will be parsed as if the user typed them into the UI. Numbers will stay as numbers, but strings may be converted to numbers, dates, etc. following the same rules that are applied when entering text into a cell via the Google Sheets UI.', }, ], default: 'RAW', @@ -668,27 +577,27 @@ export class GoogleSheets implements INodeType { type: 'options', displayOptions: { show: { - '/operation': [ - 'lookup', - 'read', - ], + '/operation': ['lookup', 'read'], }, }, options: [ { name: 'Formatted Value', value: 'FORMATTED_VALUE', - description: 'Values will be calculated & formatted in the reply according to the cell\'s formatting.Formatting is based on the spreadsheet\'s locale, not the requesting user\'s locale.For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return "$1.23"', + description: + "Values will be calculated & formatted in the reply according to the cell's formatting.Formatting is based on the spreadsheet's locale, not the requesting user's locale.For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return \"$1.23\"", }, { name: 'Formula', value: 'FORMULA', - description: 'Values will not be calculated. The reply will include the formulas. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return "=A1".', + description: + 'Values will not be calculated. The reply will include the formulas. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return "=A1".', }, { name: 'Unformatted Value', value: 'UNFORMATTED_VALUE', - description: 'Values will be calculated, but not formatted in the reply. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return the number 1.23.', + description: + 'Values will be calculated, but not formatted in the reply. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return the number 1.23.', }, ], default: 'UNFORMATTED_VALUE', @@ -700,30 +609,28 @@ export class GoogleSheets implements INodeType { type: 'options', displayOptions: { show: { - '/operation': [ - 'update', - 'upsert', - ], - '/rawData': [ - false, - ], + '/operation': ['update', 'upsert'], + '/rawData': [false], }, }, options: [ { name: 'Formatted Value', value: 'FORMATTED_VALUE', - description: 'Values will be calculated & formatted in the reply according to the cell\'s formatting.Formatting is based on the spreadsheet\'s locale, not the requesting user\'s locale. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return "$1.23".', + description: + "Values will be calculated & formatted in the reply according to the cell's formatting.Formatting is based on the spreadsheet's locale, not the requesting user's locale. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return \"$1.23\".", }, { name: 'Formula', value: 'FORMULA', - description: 'Values will not be calculated. The reply will include the formulas. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return "=A1".', + description: + 'Values will not be calculated. The reply will include the formulas. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return "=A1".', }, { name: 'Unformatted Value', value: 'UNFORMATTED_VALUE', - description: 'Values will be calculated, but not formatted in the reply. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return the number 1.23.', + description: + 'Values will be calculated, but not formatted in the reply. For example, if A1 is 1.23 and A2 is =A1 and formatted as currency, then A2 would return the number 1.23.', }, ], default: 'UNFORMATTED_VALUE', @@ -739,9 +646,7 @@ export class GoogleSheets implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'spreadsheet', - ], + resource: ['spreadsheet'], }, }, options: [ @@ -764,12 +669,8 @@ export class GoogleSheets implements INodeType { default: '', displayOptions: { show: { - resource: [ - 'spreadsheet', - ], - operation: [ - 'create', - ], + resource: ['spreadsheet'], + operation: ['create'], }, }, description: 'The title of the spreadsheet', @@ -785,12 +686,8 @@ export class GoogleSheets implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'spreadsheet', - ], - operation: [ - 'create', - ], + resource: ['spreadsheet'], + operation: ['create'], }, }, options: [ @@ -833,12 +730,8 @@ export class GoogleSheets implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'spreadsheet', - ], - operation: [ - 'create', - ], + resource: ['spreadsheet'], + operation: ['create'], }, }, options: [ @@ -897,15 +790,12 @@ export class GoogleSheets implements INodeType { default: true, displayOptions: { show: { - resource: [ - 'sheet', - ], - operation: [ - 'create', - ], + resource: ['sheet'], + operation: ['create'], }, }, - description: 'Whether to return a simplified version of the response instead of the raw data', + description: + 'Whether to return a simplified version of the response instead of the raw data', }, { displayName: 'Options', @@ -915,12 +805,8 @@ export class GoogleSheets implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'sheet', - ], - operation: [ - 'create', - ], + resource: ['sheet'], + operation: ['create'], }, }, options: [ @@ -964,7 +850,7 @@ export class GoogleSheets implements INodeType { name: 'hideGridlines', type: 'boolean', default: false, - description: 'Whether the grid isn\'t showing gridlines in the UI', + description: "Whether the grid isn't showing gridlines in the UI", }, { displayName: 'Row Count', @@ -980,7 +866,6 @@ export class GoogleSheets implements INodeType { default: false, description: 'Whether the row grouping control toggle is shown after the group', }, - ], description: 'The type of the sheet', }, @@ -989,7 +874,7 @@ export class GoogleSheets implements INodeType { name: 'hidden', type: 'boolean', default: false, - description: 'Whether the sheet is hidden in the UI, false if it\'s visible', + description: "Whether the sheet is hidden in the UI, false if it's visible", }, { displayName: 'Right To Left', @@ -1003,7 +888,8 @@ export class GoogleSheets implements INodeType { name: 'sheetId', type: 'number', default: 0, - description: 'The ID of the sheet. Must be non-negative. This field cannot be changed once set.', + description: + 'The ID of the sheet. Must be non-negative. This field cannot be changed once set.', }, { displayName: 'Sheet Index', @@ -1040,12 +926,8 @@ export class GoogleSheets implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'sheet', - ], - operation: [ - 'remove', - ], + resource: ['sheet'], + operation: ['remove'], }, }, description: 'The ID of the sheet to delete', @@ -1053,7 +935,6 @@ export class GoogleSheets implements INodeType { ], }; - methods = { loadOptions: { // Get all the sheets in a Spreadsheet @@ -1083,16 +964,22 @@ export class GoogleSheets implements INodeType { }, }, credentialTest: { - async googleApiCredentialTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { + async googleApiCredentialTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { try { - const tokenRequest = await getAccessToken.call(this, credential.data! as unknown as IGoogleAuthCredentials); + const tokenRequest = await getAccessToken.call( + this, + credential.data! as unknown as IGoogleAuthCredentials, + ); if (!tokenRequest.access_token) { return { status: 'Error', message: 'Could not generate a token from your private key.', }; } - } catch(err) { + } catch (err) { return { status: 'Error', message: `Private key validation failed: ${err.message}`, @@ -1103,19 +990,15 @@ export class GoogleSheets implements INodeType { status: 'OK', message: 'Connection successful!', }; - }, }, }; - async execute(this: IExecuteFunctions): Promise { - const operation = this.getNodeParameter('operation', 0) as string; const resource = this.getNodeParameter('resource', 0) as string; if (resource === 'sheet') { - const spreadsheetId = this.getNodeParameter('sheetId', 0) as string; const sheet = new GoogleSheet(spreadsheetId, this); @@ -1147,7 +1030,13 @@ export class GoogleSheets implements INodeType { const usePathForKeyRow = (options.usePathForKeyRow || false) as boolean; // Convert data into array format - const data = await sheet.appendSheetData(setData, sheet.encodeRange(range), keyRow, valueInputMode, usePathForKeyRow); + const data = await sheet.appendSheetData( + setData, + sheet.encodeRange(range), + keyRow, + valueInputMode, + usePathForKeyRow, + ); // TODO: Should add this data somewhere // TODO: Should have something like add metadata which does not get passed through @@ -1155,7 +1044,7 @@ export class GoogleSheets implements INodeType { return this.prepareOutputData(items); } catch (error) { if (this.continueOnFail()) { - return this.prepareOutputData([{json:{ error: error.message }}]); + return this.prepareOutputData([{ json: { error: error.message } }]); } throw error; } @@ -1170,11 +1059,10 @@ export class GoogleSheets implements INodeType { return this.prepareOutputData(items); } catch (error) { if (this.continueOnFail()) { - return this.prepareOutputData([{json:{ error: error.message }}]); + return this.prepareOutputData([{ json: { error: error.message } }]); } throw error; } - } else if (operation === 'create') { const returnData: IDataObject[] = []; @@ -1191,13 +1079,20 @@ export class GoogleSheets implements INodeType { properties.tabColor = { red: red / 255, green: green / 255, blue: blue / 255 }; } - const requests = [{ - addSheet: { - properties, + const requests = [ + { + addSheet: { + properties, + }, }, - }]; + ]; - responseData = await googleApiRequest.call(this, 'POST', `/v4/spreadsheets/${spreadsheetId}:batchUpdate`, { requests }); + responseData = await googleApiRequest.call( + this, + 'POST', + `/v4/spreadsheets/${spreadsheetId}:batchUpdate`, + { requests }, + ); if (simple === true) { Object.assign(responseData, responseData.replies[0].addSheet.properties); @@ -1214,7 +1109,6 @@ export class GoogleSheets implements INodeType { } return [this.helpers.returnJsonArray(returnData)]; - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -1225,20 +1119,22 @@ export class GoogleSheets implements INodeType { const toDelete = this.getNodeParameter('toDelete', 0) as IToDelete; const deletePropertyToDimensions: IDataObject = { - 'columns': 'COLUMNS', - 'rows': 'ROWS', + columns: 'COLUMNS', + rows: 'ROWS', }; for (const propertyName of Object.keys(deletePropertyToDimensions)) { if (toDelete[propertyName] !== undefined) { - toDelete[propertyName]!.forEach(range => { + toDelete[propertyName]!.forEach((range) => { requests.push({ deleteDimension: { range: { sheetId: range.sheetId, dimension: deletePropertyToDimensions[propertyName] as string, startIndex: range.startIndex, - endIndex: parseInt(range.startIndex.toString(), 10) + parseInt(range.amount.toString(), 10), + endIndex: + parseInt(range.startIndex.toString(), 10) + + parseInt(range.amount.toString(), 10), }, }, }); @@ -1252,7 +1148,7 @@ export class GoogleSheets implements INodeType { return this.prepareOutputData(items); } catch (error) { if (this.continueOnFail()) { - return this.prepareOutputData([{json:{ error: error.message }}]); + return this.prepareOutputData([{ json: { error: error.message } }]); } throw error; } @@ -1280,11 +1176,22 @@ export class GoogleSheets implements INodeType { }); } - let returnData = await sheet.lookupValues(sheetData, keyRow, dataStartRow, lookupValues, options.returnAllMatches as boolean | undefined); + let returnData = await sheet.lookupValues( + sheetData, + keyRow, + dataStartRow, + lookupValues, + options.returnAllMatches as boolean | undefined, + ); if (returnData.length === 0 && options.continue && options.returnAllMatches) { returnData = [{}]; - } else if (returnData.length === 1 && Object.keys(returnData[0]).length === 0 && !options.continue && !options.returnAllMatches) { + } else if ( + returnData.length === 1 && + Object.keys(returnData[0]).length === 0 && + !options.continue && + !options.returnAllMatches + ) { returnData = []; } @@ -1332,7 +1239,6 @@ export class GoogleSheets implements INodeType { } throw error; } - } else if (operation === 'remove') { const returnData: IDataObject[] = []; @@ -1342,13 +1248,20 @@ export class GoogleSheets implements INodeType { const sheetId = this.getNodeParameter('id', i) as string; const spreadsheetId = this.getNodeParameter('sheetId', i) as string; - const requests = [{ - deleteSheet: { - sheetId, + const requests = [ + { + deleteSheet: { + sheetId, + }, }, - }]; + ]; - responseData = await googleApiRequest.call(this, 'POST', `/v4/spreadsheets/${spreadsheetId}:batchUpdate`, { requests }); + responseData = await googleApiRequest.call( + this, + 'POST', + `/v4/spreadsheets/${spreadsheetId}:batchUpdate`, + { requests }, + ); delete responseData.replies; returnData.push(responseData); } catch (error) { @@ -1393,25 +1306,31 @@ export class GoogleSheets implements INodeType { setData.push(item.json); }); - const data = await sheet.updateSheetData(setData, keyName, range, keyRow, dataStartRow, valueInputMode, valueRenderMode, upsert); + const data = await sheet.updateSheetData( + setData, + keyName, + range, + keyRow, + dataStartRow, + valueInputMode, + valueRenderMode, + upsert, + ); } // TODO: Should add this data somewhere // TODO: Should have something like add metadata which does not get passed through - return this.prepareOutputData(items); } catch (error) { if (this.continueOnFail()) { - return this.prepareOutputData([{json:{ error: error.message }}]); + return this.prepareOutputData([{ json: { error: error.message } }]); } throw error; } } - } if (resource === 'spreadsheet') { - const returnData: IDataObject[] = []; let responseData; @@ -1450,7 +1369,9 @@ export class GoogleSheets implements INodeType { body.sheets = data; } - body.properties!.autoRecalc = options.autoRecalc ? (options.autoRecalc as string) : undefined; + body.properties!.autoRecalc = options.autoRecalc + ? (options.autoRecalc as string) + : undefined; body.properties!.locale = options.locale ? (options.locale as string) : undefined; responseData = await googleApiRequest.call(this, 'POST', `/v4/spreadsheets`, body); @@ -1464,7 +1385,6 @@ export class GoogleSheets implements INodeType { throw error; } } - } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Google/Slides/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Slides/GenericFunctions.ts index 1baccd54e4..1472fdb40f 100644 --- a/packages/nodes-base/nodes/Google/Slides/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Slides/GenericFunctions.ts @@ -1,11 +1,6 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -32,7 +27,11 @@ export async function googleApiRequest( body: IDataObject = {}, qs: IDataObject = {}, ) { - const authenticationMethod = this.getNodeParameter('authentication', 0, 'serviceAccount') as string; + const authenticationMethod = this.getNodeParameter( + 'authentication', + 0, + 'serviceAccount', + ) as string; const options: OptionsWithUri & { headers: IDataObject } = { headers: { 'Content-Type': 'application/json', @@ -56,10 +55,12 @@ export async function googleApiRequest( if (authenticationMethod === 'serviceAccount') { const credentials = await this.getCredentials('googleApi'); - const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials); + const { access_token } = await getAccessToken.call( + this, + credentials as unknown as IGoogleAuthCredentials, + ); options.headers.Authorization = `Bearer ${access_token}`; return await this.helpers.request!(options); - } else { return await this.helpers.requestOAuth2!.call(this, 'googleSlidesOAuth2Api', options); } diff --git a/packages/nodes-base/nodes/Google/Slides/GoogleSlides.node.ts b/packages/nodes-base/nodes/Google/Slides/GoogleSlides.node.ts index 406fa19ada..86c30beadd 100644 --- a/packages/nodes-base/nodes/Google/Slides/GoogleSlides.node.ts +++ b/packages/nodes-base/nodes/Google/Slides/GoogleSlides.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,9 +9,7 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - googleApiRequest, -} from './GenericFunctions'; +import { googleApiRequest } from './GenericFunctions'; export class GoogleSlides implements INodeType { description: INodeTypeDescription = { @@ -35,9 +31,7 @@ export class GoogleSlides implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'serviceAccount', - ], + authentication: ['serviceAccount'], }, }, }, @@ -46,9 +40,7 @@ export class GoogleSlides implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -71,9 +63,7 @@ export class GoogleSlides implements INodeType { default: 'serviceAccount', displayOptions: { show: { - '@version': [ - 1, - ], + '@version': [1], }, }, }, @@ -94,9 +84,7 @@ export class GoogleSlides implements INodeType { default: 'oAuth2', displayOptions: { show: { - '@version': [ - 2, - ], + '@version': [2], }, }, }, @@ -150,9 +138,7 @@ export class GoogleSlides implements INodeType { ], displayOptions: { show: { - resource: [ - 'presentation', - ], + resource: ['presentation'], }, }, default: 'create', @@ -178,9 +164,7 @@ export class GoogleSlides implements INodeType { ], displayOptions: { show: { - resource: [ - 'page', - ], + resource: ['page'], }, }, default: 'get', @@ -194,35 +178,24 @@ export class GoogleSlides implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'presentation', - ], - operation: [ - 'create', - ], + resource: ['presentation'], + operation: ['create'], }, }, }, { displayName: 'Presentation ID', name: 'presentationId', - description: 'ID of the presentation to retrieve. Found in the presentation URL: https://docs.google.com/presentation/d/PRESENTATION_ID/edit', + description: + 'ID of the presentation to retrieve. Found in the presentation URL: https://docs.google.com/presentation/d/PRESENTATION_ID/edit', placeholder: '1wZtNFZ8MO-WKrxhYrOLMvyiqSgFwdSz5vn8_l_7eNqw', type: 'string', default: '', required: true, displayOptions: { show: { - resource: [ - 'presentation', - 'page', - ], - operation: [ - 'get', - 'getThumbnail', - 'getSlides', - 'replaceText', - ], + resource: ['presentation', 'page'], + operation: ['get', 'getThumbnail', 'getSlides', 'replaceText'], }, }, }, @@ -232,12 +205,8 @@ export class GoogleSlides implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'getSlides', - ], - resource: [ - 'presentation', - ], + operation: ['getSlides'], + resource: ['presentation'], }, }, default: false, @@ -249,15 +218,9 @@ export class GoogleSlides implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'getSlides', - ], - resource: [ - 'presentation', - ], - returnAll: [ - false, - ], + operation: ['getSlides'], + resource: ['presentation'], + returnAll: [false], }, }, typeOptions: { @@ -276,13 +239,8 @@ export class GoogleSlides implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'page', - ], - operation: [ - 'get', - 'getThumbnail', - ], + resource: ['page'], + operation: ['get', 'getThumbnail'], }, }, }, @@ -296,12 +254,8 @@ export class GoogleSlides implements INodeType { }, displayOptions: { show: { - resource: [ - 'presentation', - ], - operation: [ - 'replaceText', - ], + resource: ['presentation'], + operation: ['replaceText'], }, }, default: {}, @@ -315,7 +269,8 @@ export class GoogleSlides implements INodeType { name: 'matchCase', type: 'boolean', default: false, - description: 'Whether the search should respect case. True : the search is case sensitive. False : the search is case insensitive.', + description: + 'Whether the search should respect case. True : the search is case sensitive. False : the search is case insensitive.', }, { displayName: 'Page Names or IDs', @@ -324,11 +279,10 @@ export class GoogleSlides implements INodeType { default: [], typeOptions: { loadOptionsMethod: 'getPages', - loadOptionsDependsOn: [ - 'presentationId', - ], + loadOptionsDependsOn: ['presentationId'], }, - description: 'If non-empty, limits the matches to page elements only on the given pages. Choose from the list, or specify IDs using an expression.', + description: + 'If non-empty, limits the matches to page elements only on the given pages. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Replace Text', @@ -355,12 +309,8 @@ export class GoogleSlides implements INodeType { placeholder: 'Add Option', displayOptions: { show: { - operation: [ - 'replaceText', - ], - resource: [ - 'presentation', - ], + operation: ['replaceText'], + resource: ['presentation'], }, }, default: {}, @@ -370,7 +320,8 @@ export class GoogleSlides implements INodeType { name: 'revisionId', type: 'string', default: '', - description: 'The revision ID of the presentation required for the write request. If specified and the requiredRevisionId doesn\'t exactly match the presentation\'s current revisionId, the request will not be processed and will return a 400 bad request error.', + description: + "The revision ID of the presentation required for the write request. If specified and the requiredRevisionId doesn't exactly match the presentation's current revisionId, the request will not be processed and will return a 400 bad request error.", }, ], }, @@ -382,12 +333,8 @@ export class GoogleSlides implements INodeType { default: false, displayOptions: { show: { - resource: [ - 'page', - ], - operation: [ - 'getThumbnail', - ], + resource: ['page'], + operation: ['getThumbnail'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether @@ -402,15 +349,9 @@ export class GoogleSlides implements INodeType { description: 'Name of the binary property to which to write to', displayOptions: { show: { - resource: [ - 'page', - ], - operation: [ - 'getThumbnail', - ], - download: [ - true, - ], + resource: ['page'], + operation: ['getThumbnail'], + download: [true], }, }, }, @@ -421,12 +362,16 @@ export class GoogleSlides implements INodeType { loadOptions: { // Get all the pages to display them to user so that he can // select them easily - async getPages( - this: ILoadOptionsFunctions, - ): Promise { + async getPages(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const presentationId = this.getCurrentNodeParameter('presentationId') as string; - const { slides } = await googleApiRequest.call(this, 'GET', `/presentations/${presentationId}`, {}, { fields: 'slides' }); + const { slides } = await googleApiRequest.call( + this, + 'GET', + `/presentations/${presentationId}`, + {}, + { fields: 'slides' }, + ); for (const slide of slides) { returnData.push({ name: slide.objectId, @@ -438,7 +383,6 @@ export class GoogleSlides implements INodeType { }, }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); @@ -449,35 +393,37 @@ export class GoogleSlides implements INodeType { const returnData: INodeExecutionData[] = []; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'page') { - // ********************************************************************* // page // ********************************************************************* if (operation === 'get') { - // ---------------------------------- // page: get // ---------------------------------- const presentationId = this.getNodeParameter('presentationId', i) as string; const pageObjectId = this.getNodeParameter('pageObjectId', i) as string; - responseData = await googleApiRequest.call(this, 'GET', `/presentations/${presentationId}/pages/${pageObjectId}`); + responseData = await googleApiRequest.call( + this, + 'GET', + `/presentations/${presentationId}/pages/${pageObjectId}`, + ); returnData.push({ json: responseData }); - } else if (operation === 'getThumbnail') { - // ---------------------------------- // page: getThumbnail // ---------------------------------- const presentationId = this.getNodeParameter('presentationId', i) as string; const pageObjectId = this.getNodeParameter('pageObjectId', i) as string; - responseData = await googleApiRequest.call(this, 'GET', `/presentations/${presentationId}/pages/${pageObjectId}/thumbnail`); + responseData = await googleApiRequest.call( + this, + 'GET', + `/presentations/${presentationId}/pages/${pageObjectId}/thumbnail`, + ); const download = this.getNodeParameter('download', 0) as boolean; if (download === true) { @@ -502,15 +448,12 @@ export class GoogleSlides implements INodeType { returnData.push({ json: responseData }); } } - } else if (resource === 'presentation') { - // ********************************************************************* // presentation // ********************************************************************* if (operation === 'create') { - // ---------------------------------- // presentation: create // ---------------------------------- @@ -521,41 +464,45 @@ export class GoogleSlides implements INodeType { responseData = await googleApiRequest.call(this, 'POST', '/presentations', body); returnData.push({ json: responseData }); - } else if (operation === 'get') { - // ---------------------------------- // presentation: get // ---------------------------------- const presentationId = this.getNodeParameter('presentationId', i) as string; - responseData = await googleApiRequest.call(this, 'GET', `/presentations/${presentationId}`); + responseData = await googleApiRequest.call( + this, + 'GET', + `/presentations/${presentationId}`, + ); returnData.push({ json: responseData }); - } else if (operation === 'getSlides') { - // ---------------------------------- // presentation: getSlides // ---------------------------------- const returnAll = this.getNodeParameter('returnAll', 0) as boolean; const presentationId = this.getNodeParameter('presentationId', i) as string; - responseData = await googleApiRequest.call(this, 'GET', `/presentations/${presentationId}`, {}, { fields: 'slides' }); + responseData = await googleApiRequest.call( + this, + 'GET', + `/presentations/${presentationId}`, + {}, + { fields: 'slides' }, + ); responseData = responseData.slides; if (returnAll === false) { const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); } returnData.push(...this.helpers.returnJsonArray(responseData)); - } else if (operation === 'replaceText') { - // ---------------------------------- // presentation: replaceText // ---------------------------------- const presentationId = this.getNodeParameter('presentationId', i) as string; const texts = this.getNodeParameter('textUi.textValues', i, []) as IDataObject[]; const options = this.getNodeParameter('options', i) as IDataObject; - const requests = texts.map((text => { + const requests = texts.map((text) => { return { replaceAllText: { replaceText: text.replaceText, @@ -566,7 +513,7 @@ export class GoogleSlides implements INodeType { }, }, }; - })); + }); const body: IDataObject = { requests, @@ -578,15 +525,18 @@ export class GoogleSlides implements INodeType { }; } - responseData = await googleApiRequest.call(this, 'POST', `/presentations/${presentationId}:batchUpdate`, { requests }); + responseData = await googleApiRequest.call( + this, + 'POST', + `/presentations/${presentationId}:batchUpdate`, + { requests }, + ); returnData.push({ json: responseData }); - } } - } catch (error) { if (this.continueOnFail()) { - returnData.push({json:{ error: error.message }}); + returnData.push({ json: { error: error.message } }); continue; } throw error; diff --git a/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts index 737ba1be09..93a4c05cc1 100644 --- a/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Task/GenericFunctions.ts @@ -1,16 +1,8 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, @@ -20,7 +12,8 @@ export async function googleApiRequest( qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, -): Promise { // tslint:disable-line:no-any + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -40,11 +33,7 @@ export async function googleApiRequest( delete options.body; } //@ts-ignore - return await this.helpers.requestOAuth2.call( - this, - 'googleTasksOAuth2Api', - options, - ); + return await this.helpers.requestOAuth2.call(this, 'googleTasksOAuth2Api', options); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -57,26 +46,18 @@ export async function googleApiRequestAllItems( endpoint: string, body: IDataObject = {}, query: IDataObject = {}, -): Promise { // tslint:disable-line:no-any + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; query.maxResults = 100; do { - responseData = await googleApiRequest.call( - this, - method, - endpoint, - body, - query, - ); + responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData['nextPageToken']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['nextPageToken'] !== undefined && - responseData['nextPageToken'] !== '' - ); + } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); return returnData; } diff --git a/packages/nodes-base/nodes/Google/Task/GoogleTasks.node.ts b/packages/nodes-base/nodes/Google/Task/GoogleTasks.node.ts index c8cbc73be8..b7707cd14d 100644 --- a/packages/nodes-base/nodes/Google/Task/GoogleTasks.node.ts +++ b/packages/nodes-base/nodes/Google/Task/GoogleTasks.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,15 +9,9 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - googleApiRequest, - googleApiRequestAllItems, -} from './GenericFunctions'; +import { googleApiRequest, googleApiRequestAllItems } from './GenericFunctions'; -import { - taskFields, - taskOperations, -} from './TaskDescription'; +import { taskFields, taskOperations } from './TaskDescription'; export class GoogleTasks implements INodeType { description: INodeTypeDescription = { @@ -64,9 +56,7 @@ export class GoogleTasks implements INodeType { loadOptions: { // Get all the tasklists to display them to user so that he can select them easily - async getTasks( - this: ILoadOptionsFunctions, - ): Promise { + async getTasks(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const tasks = await googleApiRequestAllItems.call( this, @@ -104,10 +94,7 @@ export class GoogleTasks implements INodeType { //https://developers.google.com/tasks/v1/reference/tasks/insert const taskId = this.getNodeParameter('task', i) as string; body.title = this.getNodeParameter('title', i) as string; - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (additionalFields.parent) { qs.parent = additionalFields.parent as string; @@ -172,10 +159,12 @@ export class GoogleTasks implements INodeType { //https://developers.google.com/tasks/v1/reference/tasks/list const returnAll = this.getNodeParameter('returnAll', i) as boolean; const taskListId = this.getNodeParameter('task', i) as string; - const { showCompleted = true, showDeleted = false, showHidden = false, ...options } = this.getNodeParameter( - 'additionalFields', - i, - ) as IDataObject; + const { + showCompleted = true, + showDeleted = false, + showHidden = false, + ...options + } = this.getNodeParameter('additionalFields', i) as IDataObject; if (options.completedMax) { qs.completedMax = options.completedMax as string; } @@ -223,10 +212,7 @@ export class GoogleTasks implements INodeType { //https://developers.google.com/tasks/v1/reference/tasks/patch const taskListId = this.getNodeParameter('task', i) as string; const taskId = this.getNodeParameter('taskId', i) as string; - const updateFields = this.getNodeParameter( - 'updateFields', - i, - ) as IDataObject; + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; if (updateFields.previous) { qs.previous = updateFields.previous as string; diff --git a/packages/nodes-base/nodes/Google/Task/TaskDescription.ts b/packages/nodes-base/nodes/Google/Task/TaskDescription.ts index 737bab61c1..dea8735075 100644 --- a/packages/nodes-base/nodes/Google/Task/TaskDescription.ts +++ b/packages/nodes-base/nodes/Google/Task/TaskDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const taskOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const taskOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'task', - ], + resource: ['task'], }, }, options: [ @@ -59,19 +55,16 @@ export const taskFields: INodeProperties[] = [ displayName: 'TaskList Name or ID', name: 'task', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTasks', }, required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'task', - ], + operation: ['create'], + resource: ['task'], }, }, default: '', @@ -84,12 +77,8 @@ export const taskFields: INodeProperties[] = [ description: 'Title of the task', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'task', - ], + operation: ['create'], + resource: ['task'], }, }, }, @@ -101,12 +90,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'task', - ], + operation: ['create'], + resource: ['task'], }, }, options: [ @@ -115,7 +100,8 @@ export const taskFields: INodeProperties[] = [ name: 'completed', type: 'dateTime', default: '', - description: 'Completion date of the task (as a RFC 3339 timestamp). This field is omitted if the task has not been completed.', + description: + 'Completion date of the task (as a RFC 3339 timestamp). This field is omitted if the task has not been completed.', }, { displayName: 'Deleted', @@ -143,14 +129,16 @@ export const taskFields: INodeProperties[] = [ name: 'parent', type: 'string', default: '', - description: 'Parent task identifier. If the task is created at the top level, this parameter is omitted.', + description: + 'Parent task identifier. If the task is created at the top level, this parameter is omitted.', }, { displayName: 'Previous', name: 'previous', type: 'string', default: '', - description: 'Previous sibling task identifier. If the task is created at the first position among its siblings, this parameter is omitted.', + description: + 'Previous sibling task identifier. If the task is created at the first position among its siblings, this parameter is omitted.', }, { displayName: 'Status', @@ -169,7 +157,6 @@ export const taskFields: INodeProperties[] = [ default: '', description: 'Current status of the task', }, - ], }, /* -------------------------------------------------------------------------- */ @@ -179,19 +166,16 @@ export const taskFields: INodeProperties[] = [ displayName: 'TaskList Name or ID', name: 'task', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTasks', }, required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'task', - ], + operation: ['delete'], + resource: ['task'], }, }, default: '', @@ -203,12 +187,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'task', - ], + operation: ['delete'], + resource: ['task'], }, }, default: '', @@ -220,19 +200,16 @@ export const taskFields: INodeProperties[] = [ displayName: 'TaskList Name or ID', name: 'task', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTasks', }, required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'task', - ], + operation: ['get'], + resource: ['task'], }, }, default: '', @@ -244,12 +221,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'task', - ], + operation: ['get'], + resource: ['task'], }, }, default: '', @@ -261,19 +234,16 @@ export const taskFields: INodeProperties[] = [ displayName: 'TaskList Name or ID', name: 'task', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTasks', }, required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], + operation: ['getAll'], + resource: ['task'], }, }, default: '', @@ -284,12 +254,8 @@ export const taskFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], + operation: ['getAll'], + resource: ['task'], }, }, default: false, @@ -301,15 +267,9 @@ export const taskFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['task'], + returnAll: [false], }, }, typeOptions: { @@ -327,12 +287,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], + operation: ['getAll'], + resource: ['task'], }, }, options: [ @@ -341,14 +297,16 @@ export const taskFields: INodeProperties[] = [ name: 'completedMax', type: 'dateTime', default: '', - description: 'Upper bound for a task completion date (as a RFC 3339 timestamp) to filter by', + description: + 'Upper bound for a task completion date (as a RFC 3339 timestamp) to filter by', }, { displayName: 'Completed Min', name: 'completedMin', type: 'dateTime', default: '', - description: 'Lower bound for a task completion date (as a RFC 3339 timestamp) to filter by', + description: + 'Lower bound for a task completion date (as a RFC 3339 timestamp) to filter by', }, { displayName: 'Due Min', @@ -370,7 +328,8 @@ export const taskFields: INodeProperties[] = [ type: 'boolean', default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-unencoded-angle-brackets - description: 'Whether completed tasks are returned in the result. Show Hidden must also be True to show tasks completed in first party clients such as the web UI or Google\'s mobile apps.', + description: + "Whether completed tasks are returned in the result. Show Hidden must also be True to show tasks completed in first party clients such as the web UI or Google's mobile apps.", }, { displayName: 'Show Deleted', @@ -391,7 +350,8 @@ export const taskFields: INodeProperties[] = [ name: 'updatedMin', type: 'dateTime', default: '', - description: 'Lower bound for a task last modification time (as a RFC 3339 timestamp) to filter by', + description: + 'Lower bound for a task last modification time (as a RFC 3339 timestamp) to filter by', }, ], }, @@ -402,19 +362,16 @@ export const taskFields: INodeProperties[] = [ displayName: 'TaskList Name or ID', name: 'task', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTasks', }, required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'task', - ], + operation: ['update'], + resource: ['task'], }, }, default: '', @@ -426,12 +383,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'task', - ], + operation: ['update'], + resource: ['task'], }, }, default: '', @@ -444,12 +397,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'task', - ], + operation: ['update'], + resource: ['task'], }, }, options: [ @@ -458,7 +407,8 @@ export const taskFields: INodeProperties[] = [ name: 'completed', type: 'dateTime', default: '', - description: 'Completion date of the task (as a RFC 3339 timestamp). This field is omitted if the task has not been completed.', + description: + 'Completion date of the task (as a RFC 3339 timestamp). This field is omitted if the task has not been completed.', }, { @@ -490,7 +440,8 @@ export const taskFields: INodeProperties[] = [ name: 'previous', type: 'string', default: '', - description: 'Previous sibling task identifier. If the task is created at the first position among its siblings, this parameter is omitted.', + description: + 'Previous sibling task identifier. If the task is created at the first position among its siblings, this parameter is omitted.', }, { displayName: 'Status', diff --git a/packages/nodes-base/nodes/Google/Translate/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Translate/GenericFunctions.ts index 504931be4e..8d92cafea1 100644 --- a/packages/nodes-base/nodes/Google/Translate/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Translate/GenericFunctions.ts @@ -1,16 +1,8 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; import moment from 'moment-timezone'; @@ -23,8 +15,22 @@ interface IGoogleAuthCredentials { privateKey: string; } -export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any - const authenticationMethod = this.getNodeParameter('authentication', 0, 'serviceAccount') as string; +export async function googleApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { + const authenticationMethod = this.getNodeParameter( + 'authentication', + 0, + 'serviceAccount', + ) as string; const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -46,7 +52,10 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF if (authenticationMethod === 'serviceAccount') { const credentials = await this.getCredentials('googleApi'); - const { access_token } = await getAccessToken.call(this, credentials as unknown as IGoogleAuthCredentials); + const { access_token } = await getAccessToken.call( + this, + credentials as unknown as IGoogleAuthCredentials, + ); options.headers!.Authorization = `Bearer ${access_token}`; //@ts-ignore @@ -60,8 +69,16 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function googleApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -71,15 +88,15 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData['nextPageToken']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['nextPageToken'] !== undefined && - responseData['nextPageToken'] !== '' - ); + } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); return returnData; } -function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, credentials: IGoogleAuthCredentials): Promise { +function getAccessToken( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + credentials: IGoogleAuthCredentials, +): Promise { //https://developers.google.com/identity/protocols/oauth2/service-account#httprest const scopes = [ @@ -94,20 +111,20 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa const signature = jwt.sign( { - 'iss': credentials.email as string, - 'sub': credentials.email as string, - 'scope': scopes.join(' '), - 'aud': `https://oauth2.googleapis.com/token`, - 'iat': now, - 'exp': now + 3600, + iss: credentials.email as string, + sub: credentials.email as string, + scope: scopes.join(' '), + aud: `https://oauth2.googleapis.com/token`, + iat: now, + exp: now + 3600, }, privateKey as string, { algorithm: 'RS256', header: { - 'kid': privateKey as string, - 'typ': 'JWT', - 'alg': 'RS256', + kid: privateKey as string, + typ: 'JWT', + alg: 'RS256', }, }, ); diff --git a/packages/nodes-base/nodes/Google/Translate/GoogleTranslate.node.ts b/packages/nodes-base/nodes/Google/Translate/GoogleTranslate.node.ts index ed5364cf8a..e10cee012a 100644 --- a/packages/nodes-base/nodes/Google/Translate/GoogleTranslate.node.ts +++ b/packages/nodes-base/nodes/Google/Translate/GoogleTranslate.node.ts @@ -1,7 +1,4 @@ - -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ILoadOptionsFunctions, @@ -11,9 +8,7 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - googleApiRequest, -} from './GenericFunctions'; +import { googleApiRequest } from './GenericFunctions'; export interface IGoogleAuthCredentials { email: string; @@ -41,9 +36,7 @@ export class GoogleTranslate implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'serviceAccount', - ], + authentication: ['serviceAccount'], }, }, }, @@ -52,9 +45,7 @@ export class GoogleTranslate implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -77,9 +68,7 @@ export class GoogleTranslate implements INodeType { default: 'serviceAccount', displayOptions: { show: { - '@version': [ - 1, - ], + '@version': [1], }, }, }, @@ -100,9 +89,7 @@ export class GoogleTranslate implements INodeType { default: 'oAuth2', displayOptions: { show: { - '@version': [ - 2, - ], + '@version': [2], }, }, }, @@ -126,9 +113,7 @@ export class GoogleTranslate implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'language', - ], + resource: ['language'], }, }, options: [ @@ -153,9 +138,7 @@ export class GoogleTranslate implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'translate', - ], + operation: ['translate'], }, }, }, @@ -168,13 +151,12 @@ export class GoogleTranslate implements INodeType { loadOptionsMethod: 'getLanguages', }, default: '', - description: 'The language to use for translation of the input text, set to one of the language codes listed in Language Support. Choose from the list, or specify an ID using an expression.', + description: + 'The language to use for translation of the input text, set to one of the language codes listed in Language Support. Choose from the list, or specify an ID using an expression.', required: true, displayOptions: { show: { - operation: [ - 'translate', - ], + operation: ['translate'], }, }, }, @@ -183,15 +165,11 @@ export class GoogleTranslate implements INodeType { methods = { loadOptions: { - async getLanguages( - this: ILoadOptionsFunctions, - ): Promise { + async getLanguages(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { data: { languages } } = await googleApiRequest.call( - this, - 'GET', - '/language/translate/v2/languages', - ); + const { + data: { languages }, + } = await googleApiRequest.call(this, 'GET', '/language/translate/v2/languages'); for (const language of languages) { returnData.push({ name: language.language.toUpperCase(), @@ -216,7 +194,10 @@ export class GoogleTranslate implements INodeType { const text = this.getNodeParameter('text', i) as string; const translateTo = this.getNodeParameter('translateTo', i) as string; - const response = await googleApiRequest.call(this, 'POST', `/language/translate/v2`, { q: text, target: translateTo }); + const response = await googleApiRequest.call(this, 'POST', `/language/translate/v2`, { + q: text, + target: translateTo, + }); responseData.push(response.data.translations[0]); } } diff --git a/packages/nodes-base/nodes/Google/YouTube/ChannelDescription.ts b/packages/nodes-base/nodes/Google/YouTube/ChannelDescription.ts index e7bf8099a6..4c2d0bab4e 100644 --- a/packages/nodes-base/nodes/Google/YouTube/ChannelDescription.ts +++ b/packages/nodes-base/nodes/Google/YouTube/ChannelDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const channelOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const channelOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'channel', - ], + resource: ['channel'], }, }, options: [ @@ -98,15 +94,12 @@ export const channelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'channel', - ], + operation: ['getAll'], + resource: ['channel'], }, }, - description: 'The fields parameter specifies a comma-separated list of one or more channel resource properties that the API response will include', + description: + 'The fields parameter specifies a comma-separated list of one or more channel resource properties that the API response will include', default: ['*'], }, { @@ -115,12 +108,8 @@ export const channelFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'channel', - ], + operation: ['getAll'], + resource: ['channel'], }, }, default: false, @@ -132,15 +121,9 @@ export const channelFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'channel', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['channel'], + returnAll: [false], }, }, typeOptions: { @@ -158,12 +141,8 @@ export const channelFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'channel', - ], + operation: ['getAll'], + resource: ['channel'], }, }, options: [ @@ -172,28 +151,32 @@ export const channelFields: INodeProperties[] = [ name: 'categoryId', type: 'string', default: '', - description: 'The categoryId parameter specifies a YouTube guide category, thereby requesting YouTube channels associated with that category', + description: + 'The categoryId parameter specifies a YouTube guide category, thereby requesting YouTube channels associated with that category', }, { displayName: 'For Username', name: 'forUsername', type: 'string', default: '', - description: 'The forUsername parameter specifies a YouTube username, thereby requesting the channel associated with that username', + description: + 'The forUsername parameter specifies a YouTube username, thereby requesting the channel associated with that username', }, { displayName: 'ID', name: 'id', type: 'string', default: '', - description: 'The ID parameter specifies a comma-separated list of the YouTube channel ID(s) for the resource(s) that are being retrieved. In a channel resource, the ID property specifies the channel\'s YouTube channel ID.', + description: + "The ID parameter specifies a comma-separated list of the YouTube channel ID(s) for the resource(s) that are being retrieved. In a channel resource, the ID property specifies the channel's YouTube channel ID.", }, { displayName: 'Managed By Me', name: 'managedByMe', type: 'boolean', default: false, - description: 'Whether to instruct the API to only return channels managed by the content owner that the onBehalfOfContentOwner parameter specifies', + description: + 'Whether to instruct the API to only return channels managed by the content owner that the onBehalfOfContentOwner parameter specifies', }, ], }, @@ -205,12 +188,8 @@ export const channelFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'channel', - ], + operation: ['getAll'], + resource: ['channel'], }, }, options: [ @@ -223,14 +202,16 @@ export const channelFields: INodeProperties[] = [ loadOptionsMethod: 'getLanguages', }, default: '', - description: 'The hl parameter instructs the API to retrieve localized resource metadata for a specific application language that the YouTube website supports. Choose from the list, or specify an ID using an expression.', + description: + 'The hl parameter instructs the API to retrieve localized resource metadata for a specific application language that the YouTube website supports. Choose from the list, or specify an ID using an expression.', }, { displayName: 'On Behalf Of Content Owner', name: 'onBehalfOfContentOwner', type: 'string', default: '', - description: 'The onBehalfOfContentOwner parameter indicates that the request\'s authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value', + description: + "The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value", }, ], }, @@ -244,12 +225,8 @@ export const channelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'channel', - ], + operation: ['get'], + resource: ['channel'], }, }, description: 'ID of the video', @@ -304,15 +281,12 @@ export const channelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'channel', - ], + operation: ['get'], + resource: ['channel'], }, }, - description: 'The fields parameter specifies a comma-separated list of one or more channel resource properties that the API response will include', + description: + 'The fields parameter specifies a comma-separated list of one or more channel resource properties that the API response will include', default: ['*'], }, /* -------------------------------------------------------------------------- */ @@ -325,12 +299,8 @@ export const channelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'channel', - ], + operation: ['update'], + resource: ['channel'], }, }, default: '', @@ -343,12 +313,8 @@ export const channelFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'channel', - ], + operation: ['update'], + resource: ['channel'], }, }, options: [ @@ -382,34 +348,39 @@ export const channelFields: INodeProperties[] = [ name: 'country', type: 'string', default: '', - description: 'The country with which the channel is associated. Update this property to set the value of the snippet.country property.', + description: + 'The country with which the channel is associated. Update this property to set the value of the snippet.country property.', }, { displayName: 'Description', name: 'description', type: 'string', default: '', - description: 'The channel description, which appears in the channel information box on your channel page. The property\'s value has a maximum length of 1000 characters.', + description: + "The channel description, which appears in the channel information box on your channel page. The property's value has a maximum length of 1000 characters.", }, { displayName: 'Default Language', name: 'defaultLanguage', type: 'string', default: '', - description: 'The content tab that users should display by default when viewers arrive at your channel page', + description: + 'The content tab that users should display by default when viewers arrive at your channel page', }, { displayName: 'Default Tab', name: 'defaultTab', type: 'string', - default: 'The content tab that users should display by default when viewers arrive at your channel page.', + default: + 'The content tab that users should display by default when viewers arrive at your channel page.', }, { displayName: 'Featured Channels Title', name: 'featuredChannelsTitle', type: 'string', default: '', - description: 'The title that displays above the featured channels module. The title has a maximum length of 30 characters.', + description: + 'The title that displays above the featured channels module. The title has a maximum length of 30 characters.', }, { displayName: 'Featured Channels Urls', @@ -418,7 +389,8 @@ export const channelFields: INodeProperties[] = [ typeOptions: { multipleValues: true, }, - description: 'A list of up to 100 channels that you would like to link to from the featured channels module. The property value is a list of YouTube channel ID values, each of which uniquely identifies a channel.', + description: + 'A list of up to 100 channels that you would like to link to from the featured channels module. The property value is a list of YouTube channel ID values, each of which uniquely identifies a channel.', default: [], }, { @@ -429,14 +401,16 @@ export const channelFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, placeholder: 'tech,news', - description: 'Keywords associated with your channel. The value is a space-separated list of strings.', + description: + 'Keywords associated with your channel. The value is a space-separated list of strings.', default: '', }, { displayName: 'Moderate Comments', name: 'moderateComments', type: 'boolean', - description: 'Whether user-submitted comments left on the channel page need to be approved by the channel owner to be publicly visible', + description: + 'Whether user-submitted comments left on the channel page need to be approved by the channel owner to be publicly visible', default: false, }, { @@ -445,34 +419,38 @@ export const channelFields: INodeProperties[] = [ // eslint-disable-next-line n8n-nodes-base/node-param-color-type-unused type: 'string', default: '', - description: 'A prominent color that complements the channel\'s content', + description: "A prominent color that complements the channel's content", }, { displayName: 'Show Related Channels', name: 'showRelatedChannels', type: 'boolean', - description: 'Whether YouTube should show an algorithmically generated list of related channels on your channel page', + description: + 'Whether YouTube should show an algorithmically generated list of related channels on your channel page', default: false, }, { displayName: 'Show Browse View', name: 'showBrowseView', type: 'boolean', - description: 'Whether the channel page should display content in a browse or feed view', + description: + 'Whether the channel page should display content in a browse or feed view', default: false, }, { displayName: 'Tracking Analytics AccountId', name: 'trackingAnalyticsAccountId', type: 'string', - description: 'The ID for a Google Analytics account that you want to use to track and measure traffic to your channel', + description: + 'The ID for a Google Analytics account that you want to use to track and measure traffic to your channel', default: '', }, { displayName: 'Unsubscribed Trailer', name: 'unsubscribedTrailer', type: 'string', - description: 'The video that should play in the featured video module in the channel page\'s browse view for unsubscribed viewers', + description: + "The video that should play in the featured video module in the channel page's browse view for unsubscribed viewers", default: '', }, ], @@ -490,7 +468,8 @@ export const channelFields: INodeProperties[] = [ type: 'collection', default: {}, placeholder: 'Add Channel Settings', - description: 'The image object encapsulates information about images that display on the channel\'s channel page or video watch pages', + description: + "The image object encapsulates information about images that display on the channel's channel page or video watch pages", typeOptions: { multipleValues: false, }, @@ -561,12 +540,8 @@ export const channelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'uploadBanner', - ], - resource: [ - 'channel', - ], + operation: ['uploadBanner'], + resource: ['channel'], }, }, description: 'ID of the channel', @@ -579,12 +554,8 @@ export const channelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'uploadBanner', - ], - resource: [ - 'channel', - ], + operation: ['uploadBanner'], + resource: ['channel'], }, }, default: 'data', diff --git a/packages/nodes-base/nodes/Google/YouTube/CountryCodes.ts b/packages/nodes-base/nodes/Google/YouTube/CountryCodes.ts index 4c37abc6b3..b73da14ec9 100644 --- a/packages/nodes-base/nodes/Google/YouTube/CountryCodes.ts +++ b/packages/nodes-base/nodes/Google/YouTube/CountryCodes.ts @@ -1,1579 +1,1579 @@ export const countriesCodes = [ { - 'name': 'Afghanistan', - 'alpha2': 'AF', - 'alpha3': 'AFG', - 'numeric': '004', + name: 'Afghanistan', + alpha2: 'AF', + alpha3: 'AFG', + numeric: '004', }, { - 'name': 'Åland Islands', - 'alpha2': 'AX', - 'alpha3': 'ALA', - 'numeric': '248', - 'altName': 'Aland Islands', + name: 'Åland Islands', + alpha2: 'AX', + alpha3: 'ALA', + numeric: '248', + altName: 'Aland Islands', }, { - 'name': 'Albania', - 'alpha2': 'AL', - 'alpha3': 'ALB', - 'numeric': '008', + name: 'Albania', + alpha2: 'AL', + alpha3: 'ALB', + numeric: '008', }, { - 'name': 'Algeria', - 'alpha2': 'DZ', - 'alpha3': 'DZA', - 'numeric': '012', + name: 'Algeria', + alpha2: 'DZ', + alpha3: 'DZA', + numeric: '012', }, { - 'name': 'American Samoa', - 'alpha2': 'AS', - 'alpha3': 'ASM', - 'numeric': '016', + name: 'American Samoa', + alpha2: 'AS', + alpha3: 'ASM', + numeric: '016', }, { - 'name': 'Andorra', - 'alpha2': 'AD', - 'alpha3': 'AND', - 'numeric': '020', + name: 'Andorra', + alpha2: 'AD', + alpha3: 'AND', + numeric: '020', }, { - 'name': 'Angola', - 'alpha2': 'AO', - 'alpha3': 'AGO', - 'numeric': '024', + name: 'Angola', + alpha2: 'AO', + alpha3: 'AGO', + numeric: '024', }, { - 'name': 'Anguilla', - 'alpha2': 'AI', - 'alpha3': 'AIA', - 'numeric': '660', + name: 'Anguilla', + alpha2: 'AI', + alpha3: 'AIA', + numeric: '660', }, { - 'name': 'Antarctica', - 'alpha2': 'AQ', - 'alpha3': 'ATA', - 'numeric': '010', + name: 'Antarctica', + alpha2: 'AQ', + alpha3: 'ATA', + numeric: '010', }, { - 'name': 'Antigua and Barbuda', - 'alpha2': 'AG', - 'alpha3': 'ATG', - 'numeric': '028', + name: 'Antigua and Barbuda', + alpha2: 'AG', + alpha3: 'ATG', + numeric: '028', }, { - 'name': 'Argentina', - 'alpha2': 'AR', - 'alpha3': 'ARG', - 'numeric': '032', + name: 'Argentina', + alpha2: 'AR', + alpha3: 'ARG', + numeric: '032', }, { - 'name': 'Armenia', - 'alpha2': 'AM', - 'alpha3': 'ARM', - 'numeric': '051', + name: 'Armenia', + alpha2: 'AM', + alpha3: 'ARM', + numeric: '051', }, { - 'name': 'Aruba', - 'alpha2': 'AW', - 'alpha3': 'ABW', - 'numeric': '533', + name: 'Aruba', + alpha2: 'AW', + alpha3: 'ABW', + numeric: '533', }, { - 'name': 'Australia', - 'alpha2': 'AU', - 'alpha3': 'AUS', - 'numeric': '036', + name: 'Australia', + alpha2: 'AU', + alpha3: 'AUS', + numeric: '036', }, { - 'name': 'Austria', - 'alpha2': 'AT', - 'alpha3': 'AUT', - 'numeric': '040', + name: 'Austria', + alpha2: 'AT', + alpha3: 'AUT', + numeric: '040', }, { - 'name': 'Azerbaijan', - 'alpha2': 'AZ', - 'alpha3': 'AZE', - 'numeric': '031', + name: 'Azerbaijan', + alpha2: 'AZ', + alpha3: 'AZE', + numeric: '031', }, { - 'name': 'Bahamas (the)', - 'alpha2': 'BS', - 'alpha3': 'BHS', - 'numeric': '044', - 'altName': 'Bahamas', + name: 'Bahamas (the)', + alpha2: 'BS', + alpha3: 'BHS', + numeric: '044', + altName: 'Bahamas', }, { - 'name': 'Bahrain', - 'alpha2': 'BH', - 'alpha3': 'BHR', - 'numeric': '048', + name: 'Bahrain', + alpha2: 'BH', + alpha3: 'BHR', + numeric: '048', }, { - 'name': 'Bangladesh', - 'alpha2': 'BD', - 'alpha3': 'BGD', - 'numeric': '050', + name: 'Bangladesh', + alpha2: 'BD', + alpha3: 'BGD', + numeric: '050', }, { - 'name': 'Barbados', - 'alpha2': 'BB', - 'alpha3': 'BRB', - 'numeric': '052', + name: 'Barbados', + alpha2: 'BB', + alpha3: 'BRB', + numeric: '052', }, { - 'name': 'Belarus', - 'alpha2': 'BY', - 'alpha3': 'BLR', - 'numeric': '112', + name: 'Belarus', + alpha2: 'BY', + alpha3: 'BLR', + numeric: '112', }, { - 'name': 'Belgium', - 'alpha2': 'BE', - 'alpha3': 'BEL', - 'numeric': '056', + name: 'Belgium', + alpha2: 'BE', + alpha3: 'BEL', + numeric: '056', }, { - 'name': 'Belize', - 'alpha2': 'BZ', - 'alpha3': 'BLZ', - 'numeric': '084', + name: 'Belize', + alpha2: 'BZ', + alpha3: 'BLZ', + numeric: '084', }, { - 'name': 'Benin', - 'alpha2': 'BJ', - 'alpha3': 'BEN', - 'numeric': '204', + name: 'Benin', + alpha2: 'BJ', + alpha3: 'BEN', + numeric: '204', }, { - 'name': 'Bermuda', - 'alpha2': 'BM', - 'alpha3': 'BMU', - 'numeric': '060', + name: 'Bermuda', + alpha2: 'BM', + alpha3: 'BMU', + numeric: '060', }, { - 'name': 'Bhutan', - 'alpha2': 'BT', - 'alpha3': 'BTN', - 'numeric': '064', + name: 'Bhutan', + alpha2: 'BT', + alpha3: 'BTN', + numeric: '064', }, { - 'name': 'Bolivia (Plurinational State of)', - 'alpha2': 'BO', - 'alpha3': 'BOL', - 'numeric': '068', - 'altName': 'Bolivia', + name: 'Bolivia (Plurinational State of)', + alpha2: 'BO', + alpha3: 'BOL', + numeric: '068', + altName: 'Bolivia', }, { - 'name': 'Bonaire, Sint Eustatius and Saba', - 'alpha2': 'BQ', - 'alpha3': 'BES', - 'numeric': '535', + name: 'Bonaire, Sint Eustatius and Saba', + alpha2: 'BQ', + alpha3: 'BES', + numeric: '535', }, { - 'name': 'Bosnia and Herzegovina', - 'alpha2': 'BA', - 'alpha3': 'BIH', - 'numeric': '070', + name: 'Bosnia and Herzegovina', + alpha2: 'BA', + alpha3: 'BIH', + numeric: '070', }, { - 'name': 'Botswana', - 'alpha2': 'BW', - 'alpha3': 'BWA', - 'numeric': '072', + name: 'Botswana', + alpha2: 'BW', + alpha3: 'BWA', + numeric: '072', }, { - 'name': 'Bouvet Island', - 'alpha2': 'BV', - 'alpha3': 'BVT', - 'numeric': '074', + name: 'Bouvet Island', + alpha2: 'BV', + alpha3: 'BVT', + numeric: '074', }, { - 'name': 'Brazil', - 'alpha2': 'BR', - 'alpha3': 'BRA', - 'numeric': '076', + name: 'Brazil', + alpha2: 'BR', + alpha3: 'BRA', + numeric: '076', }, { - 'name': 'British Indian Ocean Territory (the)', - 'alpha2': 'IO', - 'alpha3': 'IOT', - 'numeric': '086', - 'altName': 'British Indian Ocean Territory', + name: 'British Indian Ocean Territory (the)', + alpha2: 'IO', + alpha3: 'IOT', + numeric: '086', + altName: 'British Indian Ocean Territory', }, { - 'name': 'Brunei Darussalam', - 'alpha2': 'BN', - 'alpha3': 'BRN', - 'numeric': '096', - 'shortName': 'Brunei', + name: 'Brunei Darussalam', + alpha2: 'BN', + alpha3: 'BRN', + numeric: '096', + shortName: 'Brunei', }, { - 'name': 'Bulgaria', - 'alpha2': 'BG', - 'alpha3': 'BGR', - 'numeric': '100', + name: 'Bulgaria', + alpha2: 'BG', + alpha3: 'BGR', + numeric: '100', }, { - 'name': 'Burkina Faso', - 'alpha2': 'BF', - 'alpha3': 'BFA', - 'numeric': '854', + name: 'Burkina Faso', + alpha2: 'BF', + alpha3: 'BFA', + numeric: '854', }, { - 'name': 'Burundi', - 'alpha2': 'BI', - 'alpha3': 'BDI', - 'numeric': '108', + name: 'Burundi', + alpha2: 'BI', + alpha3: 'BDI', + numeric: '108', }, { - 'name': 'Cabo Verde', - 'alpha2': 'CV', - 'alpha3': 'CPV', - 'numeric': '132', - 'altName': 'Cape Verde', + name: 'Cabo Verde', + alpha2: 'CV', + alpha3: 'CPV', + numeric: '132', + altName: 'Cape Verde', }, { - 'name': 'Cambodia', - 'alpha2': 'KH', - 'alpha3': 'KHM', - 'numeric': '116', + name: 'Cambodia', + alpha2: 'KH', + alpha3: 'KHM', + numeric: '116', }, { - 'name': 'Cameroon', - 'alpha2': 'CM', - 'alpha3': 'CMR', - 'numeric': '120', + name: 'Cameroon', + alpha2: 'CM', + alpha3: 'CMR', + numeric: '120', }, { - 'name': 'Canada', - 'alpha2': 'CA', - 'alpha3': 'CAN', - 'numeric': '124', + name: 'Canada', + alpha2: 'CA', + alpha3: 'CAN', + numeric: '124', }, { - 'name': 'Cayman Islands (the)', - 'alpha2': 'KY', - 'alpha3': 'CYM', - 'numeric': '136', - 'altName': 'Cayman Islands', + name: 'Cayman Islands (the)', + alpha2: 'KY', + alpha3: 'CYM', + numeric: '136', + altName: 'Cayman Islands', }, { - 'name': 'Central African Republic (the)', - 'alpha2': 'CF', - 'alpha3': 'CAF', - 'numeric': '140', - 'altName': 'Central African Republic', + name: 'Central African Republic (the)', + alpha2: 'CF', + alpha3: 'CAF', + numeric: '140', + altName: 'Central African Republic', }, { - 'name': 'Chad', - 'alpha2': 'TD', - 'alpha3': 'TCD', - 'numeric': '148', + name: 'Chad', + alpha2: 'TD', + alpha3: 'TCD', + numeric: '148', }, { - 'name': 'Chile', - 'alpha2': 'CL', - 'alpha3': 'CHL', - 'numeric': '152', + name: 'Chile', + alpha2: 'CL', + alpha3: 'CHL', + numeric: '152', }, { - 'name': 'China', - 'alpha2': 'CN', - 'alpha3': 'CHN', - 'numeric': '156', + name: 'China', + alpha2: 'CN', + alpha3: 'CHN', + numeric: '156', }, { - 'name': 'Christmas Island', - 'alpha2': 'CX', - 'alpha3': 'CXR', - 'numeric': '162', + name: 'Christmas Island', + alpha2: 'CX', + alpha3: 'CXR', + numeric: '162', }, { - 'name': 'Cocos (Keeling) Islands (the)', - 'alpha2': 'CC', - 'alpha3': 'CCK', - 'numeric': '166', - 'altName': 'Cocos (Keeling) Islands', - 'shortName': 'Cocos Islands', + name: 'Cocos (Keeling) Islands (the)', + alpha2: 'CC', + alpha3: 'CCK', + numeric: '166', + altName: 'Cocos (Keeling) Islands', + shortName: 'Cocos Islands', }, { - 'name': 'Colombia', - 'alpha2': 'CO', - 'alpha3': 'COL', - 'numeric': '170', + name: 'Colombia', + alpha2: 'CO', + alpha3: 'COL', + numeric: '170', }, { - 'name': 'Comoros (the)', - 'alpha2': 'KM', - 'alpha3': 'COM', - 'numeric': '174', - 'altName': 'Comoros', + name: 'Comoros (the)', + alpha2: 'KM', + alpha3: 'COM', + numeric: '174', + altName: 'Comoros', }, { - 'name': 'Congo (the Democratic Republic of the)', - 'alpha2': 'CD', - 'alpha3': 'COD', - 'numeric': '180', - 'altName': 'Congo, (Kinshasa)', - 'shortName': 'Democratic Republic of the Congo', + name: 'Congo (the Democratic Republic of the)', + alpha2: 'CD', + alpha3: 'COD', + numeric: '180', + altName: 'Congo, (Kinshasa)', + shortName: 'Democratic Republic of the Congo', }, { - 'name': 'Congo (the)', - 'alpha2': 'CG', - 'alpha3': 'COG', - 'numeric': '178', - 'altName': 'Congo (Brazzaville)', - 'shortName': 'Republic of the Congo', + name: 'Congo (the)', + alpha2: 'CG', + alpha3: 'COG', + numeric: '178', + altName: 'Congo (Brazzaville)', + shortName: 'Republic of the Congo', }, { - 'name': 'Cook Islands (the)', - 'alpha2': 'CK', - 'alpha3': 'COK', - 'numeric': '184', - 'altName': 'Cook Islands', + name: 'Cook Islands (the)', + alpha2: 'CK', + alpha3: 'COK', + numeric: '184', + altName: 'Cook Islands', }, { - 'name': 'Costa Rica', - 'alpha2': 'CR', - 'alpha3': 'CRI', - 'numeric': '188', + name: 'Costa Rica', + alpha2: 'CR', + alpha3: 'CRI', + numeric: '188', }, { - 'name': 'Côte d\'Ivoire', - 'alpha2': 'CI', - 'alpha3': 'CIV', - 'numeric': '384', - 'shortName': 'Ivory Coast', + name: "Côte d'Ivoire", + alpha2: 'CI', + alpha3: 'CIV', + numeric: '384', + shortName: 'Ivory Coast', }, { - 'name': 'Croatia', - 'alpha2': 'HR', - 'alpha3': 'HRV', - 'numeric': '191', + name: 'Croatia', + alpha2: 'HR', + alpha3: 'HRV', + numeric: '191', }, { - 'name': 'Cuba', - 'alpha2': 'CU', - 'alpha3': 'CUB', - 'numeric': '192', + name: 'Cuba', + alpha2: 'CU', + alpha3: 'CUB', + numeric: '192', }, { - 'name': 'Curaçao', - 'alpha2': 'CW', - 'alpha3': 'CUW', - 'numeric': '531', - 'shortName': 'Curacao', + name: 'Curaçao', + alpha2: 'CW', + alpha3: 'CUW', + numeric: '531', + shortName: 'Curacao', }, { - 'name': 'Cyprus', - 'alpha2': 'CY', - 'alpha3': 'CYP', - 'numeric': '196', + name: 'Cyprus', + alpha2: 'CY', + alpha3: 'CYP', + numeric: '196', }, { - 'name': 'Czechia', - 'alpha2': 'CZ', - 'alpha3': 'CZE', - 'numeric': '203', - 'altName': 'Czech Republic', + name: 'Czechia', + alpha2: 'CZ', + alpha3: 'CZE', + numeric: '203', + altName: 'Czech Republic', }, { - 'name': 'Denmark', - 'alpha2': 'DK', - 'alpha3': 'DNK', - 'numeric': '208', + name: 'Denmark', + alpha2: 'DK', + alpha3: 'DNK', + numeric: '208', }, { - 'name': 'Djibouti', - 'alpha2': 'DJ', - 'alpha3': 'DJI', - 'numeric': '262', + name: 'Djibouti', + alpha2: 'DJ', + alpha3: 'DJI', + numeric: '262', }, { - 'name': 'Dominica', - 'alpha2': 'DM', - 'alpha3': 'DMA', - 'numeric': '212', + name: 'Dominica', + alpha2: 'DM', + alpha3: 'DMA', + numeric: '212', }, { - 'name': 'Dominican Republic (the)', - 'alpha2': 'DO', - 'alpha3': 'DOM', - 'numeric': '214', - 'altName': 'Dominican Republic', + name: 'Dominican Republic (the)', + alpha2: 'DO', + alpha3: 'DOM', + numeric: '214', + altName: 'Dominican Republic', }, { - 'name': 'Ecuador', - 'alpha2': 'EC', - 'alpha3': 'ECU', - 'numeric': '218', + name: 'Ecuador', + alpha2: 'EC', + alpha3: 'ECU', + numeric: '218', }, { - 'name': 'Egypt', - 'alpha2': 'EG', - 'alpha3': 'EGY', - 'numeric': '818', + name: 'Egypt', + alpha2: 'EG', + alpha3: 'EGY', + numeric: '818', }, { - 'name': 'El Salvador', - 'alpha2': 'SV', - 'alpha3': 'SLV', - 'numeric': '222', + name: 'El Salvador', + alpha2: 'SV', + alpha3: 'SLV', + numeric: '222', }, { - 'name': 'Equatorial Guinea', - 'alpha2': 'GQ', - 'alpha3': 'GNQ', - 'numeric': '226', + name: 'Equatorial Guinea', + alpha2: 'GQ', + alpha3: 'GNQ', + numeric: '226', }, { - 'name': 'Eritrea', - 'alpha2': 'ER', - 'alpha3': 'ERI', - 'numeric': '232', + name: 'Eritrea', + alpha2: 'ER', + alpha3: 'ERI', + numeric: '232', }, { - 'name': 'Estonia', - 'alpha2': 'EE', - 'alpha3': 'EST', - 'numeric': '233', + name: 'Estonia', + alpha2: 'EE', + alpha3: 'EST', + numeric: '233', }, { - 'name': 'Ethiopia', - 'alpha2': 'ET', - 'alpha3': 'ETH', - 'numeric': '231', + name: 'Ethiopia', + alpha2: 'ET', + alpha3: 'ETH', + numeric: '231', }, { - 'name': 'Falkland Islands (the) [Malvinas]', - 'alpha2': 'FK', - 'alpha3': 'FLK', - 'numeric': '238', - 'altName': 'Falkland Islands (Malvinas)', - 'shortName': 'Falkland Islands', + name: 'Falkland Islands (the) [Malvinas]', + alpha2: 'FK', + alpha3: 'FLK', + numeric: '238', + altName: 'Falkland Islands (Malvinas)', + shortName: 'Falkland Islands', }, { - 'name': 'Faroe Islands (the)', - 'alpha2': 'FO', - 'alpha3': 'FRO', - 'numeric': '234', - 'altName': 'Faroe Islands', + name: 'Faroe Islands (the)', + alpha2: 'FO', + alpha3: 'FRO', + numeric: '234', + altName: 'Faroe Islands', }, { - 'name': 'Fiji', - 'alpha2': 'FJ', - 'alpha3': 'FJI', - 'numeric': '242', + name: 'Fiji', + alpha2: 'FJ', + alpha3: 'FJI', + numeric: '242', }, { - 'name': 'Finland', - 'alpha2': 'FI', - 'alpha3': 'FIN', - 'numeric': '246', + name: 'Finland', + alpha2: 'FI', + alpha3: 'FIN', + numeric: '246', }, { - 'name': 'France', - 'alpha2': 'FR', - 'alpha3': 'FRA', - 'numeric': '250', + name: 'France', + alpha2: 'FR', + alpha3: 'FRA', + numeric: '250', }, { - 'name': 'French Guiana', - 'alpha2': 'GF', - 'alpha3': 'GUF', - 'numeric': '254', + name: 'French Guiana', + alpha2: 'GF', + alpha3: 'GUF', + numeric: '254', }, { - 'name': 'French Polynesia', - 'alpha2': 'PF', - 'alpha3': 'PYF', - 'numeric': '258', + name: 'French Polynesia', + alpha2: 'PF', + alpha3: 'PYF', + numeric: '258', }, { - 'name': 'French Southern Territories (the)', - 'alpha2': 'TF', - 'alpha3': 'ATF', - 'numeric': '260', - 'altName': 'French Southern Territories', + name: 'French Southern Territories (the)', + alpha2: 'TF', + alpha3: 'ATF', + numeric: '260', + altName: 'French Southern Territories', }, { - 'name': 'Gabon', - 'alpha2': 'GA', - 'alpha3': 'GAB', - 'numeric': '266', + name: 'Gabon', + alpha2: 'GA', + alpha3: 'GAB', + numeric: '266', }, { - 'name': 'Gambia (the)', - 'alpha2': 'GM', - 'alpha3': 'GMB', - 'numeric': '270', - 'altName': 'Gambia', + name: 'Gambia (the)', + alpha2: 'GM', + alpha3: 'GMB', + numeric: '270', + altName: 'Gambia', }, { - 'name': 'Georgia', - 'alpha2': 'GE', - 'alpha3': 'GEO', - 'numeric': '268', + name: 'Georgia', + alpha2: 'GE', + alpha3: 'GEO', + numeric: '268', }, { - 'name': 'Germany', - 'alpha2': 'DE', - 'alpha3': 'DEU', - 'numeric': '276', + name: 'Germany', + alpha2: 'DE', + alpha3: 'DEU', + numeric: '276', }, { - 'name': 'Ghana', - 'alpha2': 'GH', - 'alpha3': 'GHA', - 'numeric': '288', + name: 'Ghana', + alpha2: 'GH', + alpha3: 'GHA', + numeric: '288', }, { - 'name': 'Gibraltar', - 'alpha2': 'GI', - 'alpha3': 'GIB', - 'numeric': '292', + name: 'Gibraltar', + alpha2: 'GI', + alpha3: 'GIB', + numeric: '292', }, { - 'name': 'Greece', - 'alpha2': 'GR', - 'alpha3': 'GRC', - 'numeric': '300', + name: 'Greece', + alpha2: 'GR', + alpha3: 'GRC', + numeric: '300', }, { - 'name': 'Greenland', - 'alpha2': 'GL', - 'alpha3': 'GRL', - 'numeric': '304', + name: 'Greenland', + alpha2: 'GL', + alpha3: 'GRL', + numeric: '304', }, { - 'name': 'Grenada', - 'alpha2': 'GD', - 'alpha3': 'GRD', - 'numeric': '308', + name: 'Grenada', + alpha2: 'GD', + alpha3: 'GRD', + numeric: '308', }, { - 'name': 'Guadeloupe', - 'alpha2': 'GP', - 'alpha3': 'GLP', - 'numeric': '312', + name: 'Guadeloupe', + alpha2: 'GP', + alpha3: 'GLP', + numeric: '312', }, { - 'name': 'Guam', - 'alpha2': 'GU', - 'alpha3': 'GUM', - 'numeric': '316', + name: 'Guam', + alpha2: 'GU', + alpha3: 'GUM', + numeric: '316', }, { - 'name': 'Guatemala', - 'alpha2': 'GT', - 'alpha3': 'GTM', - 'numeric': '320', + name: 'Guatemala', + alpha2: 'GT', + alpha3: 'GTM', + numeric: '320', }, { - 'name': 'Guernsey', - 'alpha2': 'GG', - 'alpha3': 'GGY', - 'numeric': '831', + name: 'Guernsey', + alpha2: 'GG', + alpha3: 'GGY', + numeric: '831', }, { - 'name': 'Guinea', - 'alpha2': 'GN', - 'alpha3': 'GIN', - 'numeric': '324', + name: 'Guinea', + alpha2: 'GN', + alpha3: 'GIN', + numeric: '324', }, { - 'name': 'Guinea-Bissau', - 'alpha2': 'GW', - 'alpha3': 'GNB', - 'numeric': '624', + name: 'Guinea-Bissau', + alpha2: 'GW', + alpha3: 'GNB', + numeric: '624', }, { - 'name': 'Guyana', - 'alpha2': 'GY', - 'alpha3': 'GUY', - 'numeric': '328', + name: 'Guyana', + alpha2: 'GY', + alpha3: 'GUY', + numeric: '328', }, { - 'name': 'Haiti', - 'alpha2': 'HT', - 'alpha3': 'HTI', - 'numeric': '332', + name: 'Haiti', + alpha2: 'HT', + alpha3: 'HTI', + numeric: '332', }, { - 'name': 'Heard Island and McDonald Islands', - 'alpha2': 'HM', - 'alpha3': 'HMD', - 'numeric': '334', - 'altName': 'Heard and Mcdonald Islands', + name: 'Heard Island and McDonald Islands', + alpha2: 'HM', + alpha3: 'HMD', + numeric: '334', + altName: 'Heard and Mcdonald Islands', }, { - 'name': 'Holy See (the)', - 'alpha2': 'VA', - 'alpha3': 'VAT', - 'numeric': '336', - 'altName': 'Holy See (Vatican City State)', - 'shortName': 'Vatican', + name: 'Holy See (the)', + alpha2: 'VA', + alpha3: 'VAT', + numeric: '336', + altName: 'Holy See (Vatican City State)', + shortName: 'Vatican', }, { - 'name': 'Honduras', - 'alpha2': 'HN', - 'alpha3': 'HND', - 'numeric': '340', + name: 'Honduras', + alpha2: 'HN', + alpha3: 'HND', + numeric: '340', }, { - 'name': 'Hong Kong', - 'alpha2': 'HK', - 'alpha3': 'HKG', - 'numeric': '344', - 'altName': 'Hong Kong, SAR China', + name: 'Hong Kong', + alpha2: 'HK', + alpha3: 'HKG', + numeric: '344', + altName: 'Hong Kong, SAR China', }, { - 'name': 'Hungary', - 'alpha2': 'HU', - 'alpha3': 'HUN', - 'numeric': '348', + name: 'Hungary', + alpha2: 'HU', + alpha3: 'HUN', + numeric: '348', }, { - 'name': 'Iceland', - 'alpha2': 'IS', - 'alpha3': 'ISL', - 'numeric': '352', + name: 'Iceland', + alpha2: 'IS', + alpha3: 'ISL', + numeric: '352', }, { - 'name': 'India', - 'alpha2': 'IN', - 'alpha3': 'IND', - 'numeric': '356', + name: 'India', + alpha2: 'IN', + alpha3: 'IND', + numeric: '356', }, { - 'name': 'Indonesia', - 'alpha2': 'ID', - 'alpha3': 'IDN', - 'numeric': '360', + name: 'Indonesia', + alpha2: 'ID', + alpha3: 'IDN', + numeric: '360', }, { - 'name': 'Iran (Islamic Republic of)', - 'alpha2': 'IR', - 'alpha3': 'IRN', - 'numeric': '364', - 'altName': 'Iran, Islamic Republic of', - 'shortName': 'Iran', + name: 'Iran (Islamic Republic of)', + alpha2: 'IR', + alpha3: 'IRN', + numeric: '364', + altName: 'Iran, Islamic Republic of', + shortName: 'Iran', }, { - 'name': 'Iraq', - 'alpha2': 'IQ', - 'alpha3': 'IRQ', - 'numeric': '368', + name: 'Iraq', + alpha2: 'IQ', + alpha3: 'IRQ', + numeric: '368', }, { - 'name': 'Ireland', - 'alpha2': 'IE', - 'alpha3': 'IRL', - 'numeric': '372', + name: 'Ireland', + alpha2: 'IE', + alpha3: 'IRL', + numeric: '372', }, { - 'name': 'Isle of Man', - 'alpha2': 'IM', - 'alpha3': 'IMN', - 'numeric': '833', + name: 'Isle of Man', + alpha2: 'IM', + alpha3: 'IMN', + numeric: '833', }, { - 'name': 'Israel', - 'alpha2': 'IL', - 'alpha3': 'ISR', - 'numeric': '376', + name: 'Israel', + alpha2: 'IL', + alpha3: 'ISR', + numeric: '376', }, { - 'name': 'Italy', - 'alpha2': 'IT', - 'alpha3': 'ITA', - 'numeric': '380', + name: 'Italy', + alpha2: 'IT', + alpha3: 'ITA', + numeric: '380', }, { - 'name': 'Jamaica', - 'alpha2': 'JM', - 'alpha3': 'JAM', - 'numeric': '388', + name: 'Jamaica', + alpha2: 'JM', + alpha3: 'JAM', + numeric: '388', }, { - 'name': 'Japan', - 'alpha2': 'JP', - 'alpha3': 'JPN', - 'numeric': '392', + name: 'Japan', + alpha2: 'JP', + alpha3: 'JPN', + numeric: '392', }, { - 'name': 'Jersey', - 'alpha2': 'JE', - 'alpha3': 'JEY', - 'numeric': '832', + name: 'Jersey', + alpha2: 'JE', + alpha3: 'JEY', + numeric: '832', }, { - 'name': 'Jordan', - 'alpha2': 'JO', - 'alpha3': 'JOR', - 'numeric': '400', + name: 'Jordan', + alpha2: 'JO', + alpha3: 'JOR', + numeric: '400', }, { - 'name': 'Kazakhstan', - 'alpha2': 'KZ', - 'alpha3': 'KAZ', - 'numeric': '398', + name: 'Kazakhstan', + alpha2: 'KZ', + alpha3: 'KAZ', + numeric: '398', }, { - 'name': 'Kenya', - 'alpha2': 'KE', - 'alpha3': 'KEN', - 'numeric': '404', + name: 'Kenya', + alpha2: 'KE', + alpha3: 'KEN', + numeric: '404', }, { - 'name': 'Kiribati', - 'alpha2': 'KI', - 'alpha3': 'KIR', - 'numeric': '296', + name: 'Kiribati', + alpha2: 'KI', + alpha3: 'KIR', + numeric: '296', }, { - 'name': 'Korea (the Democratic People\'s Republic of)', - 'alpha2': 'KP', - 'alpha3': 'PRK', - 'numeric': '408', - 'altName': 'Korea (North)', - 'shortName': 'North Korea', + name: "Korea (the Democratic People's Republic of)", + alpha2: 'KP', + alpha3: 'PRK', + numeric: '408', + altName: 'Korea (North)', + shortName: 'North Korea', }, { - 'name': 'Korea (the Republic of)', - 'alpha2': 'KR', - 'alpha3': 'KOR', - 'numeric': '410', - 'altName': 'Korea (South)', - 'shortName': 'South Korea', + name: 'Korea (the Republic of)', + alpha2: 'KR', + alpha3: 'KOR', + numeric: '410', + altName: 'Korea (South)', + shortName: 'South Korea', }, { - 'name': 'Kuwait', - 'alpha2': 'KW', - 'alpha3': 'KWT', - 'numeric': '414', + name: 'Kuwait', + alpha2: 'KW', + alpha3: 'KWT', + numeric: '414', }, { - 'name': 'Kyrgyzstan', - 'alpha2': 'KG', - 'alpha3': 'KGZ', - 'numeric': '417', + name: 'Kyrgyzstan', + alpha2: 'KG', + alpha3: 'KGZ', + numeric: '417', }, { - 'name': 'Lao People\'s Democratic Republic (the)', - 'alpha2': 'LA', - 'alpha3': 'LAO', - 'numeric': '418', - 'altName': 'Lao PDR', - 'shortName': 'Laos', + name: "Lao People's Democratic Republic (the)", + alpha2: 'LA', + alpha3: 'LAO', + numeric: '418', + altName: 'Lao PDR', + shortName: 'Laos', }, { - 'name': 'Latvia', - 'alpha2': 'LV', - 'alpha3': 'LVA', - 'numeric': '428', + name: 'Latvia', + alpha2: 'LV', + alpha3: 'LVA', + numeric: '428', }, { - 'name': 'Lebanon', - 'alpha2': 'LB', - 'alpha3': 'LBN', - 'numeric': '422', + name: 'Lebanon', + alpha2: 'LB', + alpha3: 'LBN', + numeric: '422', }, { - 'name': 'Lesotho', - 'alpha2': 'LS', - 'alpha3': 'LSO', - 'numeric': '426', + name: 'Lesotho', + alpha2: 'LS', + alpha3: 'LSO', + numeric: '426', }, { - 'name': 'Liberia', - 'alpha2': 'LR', - 'alpha3': 'LBR', - 'numeric': '430', + name: 'Liberia', + alpha2: 'LR', + alpha3: 'LBR', + numeric: '430', }, { - 'name': 'Libya', - 'alpha2': 'LY', - 'alpha3': 'LBY', - 'numeric': '434', + name: 'Libya', + alpha2: 'LY', + alpha3: 'LBY', + numeric: '434', }, { - 'name': 'Liechtenstein', - 'alpha2': 'LI', - 'alpha3': 'LIE', - 'numeric': '438', + name: 'Liechtenstein', + alpha2: 'LI', + alpha3: 'LIE', + numeric: '438', }, { - 'name': 'Lithuania', - 'alpha2': 'LT', - 'alpha3': 'LTU', - 'numeric': '440', + name: 'Lithuania', + alpha2: 'LT', + alpha3: 'LTU', + numeric: '440', }, { - 'name': 'Luxembourg', - 'alpha2': 'LU', - 'alpha3': 'LUX', - 'numeric': '442', + name: 'Luxembourg', + alpha2: 'LU', + alpha3: 'LUX', + numeric: '442', }, { - 'name': 'Macao', - 'alpha2': 'MO', - 'alpha3': 'MAC', - 'numeric': '446', - 'altName': 'Macao, SAR China', - 'shortName': 'Macau', + name: 'Macao', + alpha2: 'MO', + alpha3: 'MAC', + numeric: '446', + altName: 'Macao, SAR China', + shortName: 'Macau', }, { - 'name': 'Macedonia (the former Yugoslav Republic of)', - 'alpha2': 'MK', - 'alpha3': 'MKD', - 'numeric': '807', - 'altName': 'Macedonia, Republic of', - 'shortName': 'Macedonia', + name: 'Macedonia (the former Yugoslav Republic of)', + alpha2: 'MK', + alpha3: 'MKD', + numeric: '807', + altName: 'Macedonia, Republic of', + shortName: 'Macedonia', }, { - 'name': 'Madagascar', - 'alpha2': 'MG', - 'alpha3': 'MDG', - 'numeric': '450', + name: 'Madagascar', + alpha2: 'MG', + alpha3: 'MDG', + numeric: '450', }, { - 'name': 'Malawi', - 'alpha2': 'MW', - 'alpha3': 'MWI', - 'numeric': '454', + name: 'Malawi', + alpha2: 'MW', + alpha3: 'MWI', + numeric: '454', }, { - 'name': 'Malaysia', - 'alpha2': 'MY', - 'alpha3': 'MYS', - 'numeric': '458', + name: 'Malaysia', + alpha2: 'MY', + alpha3: 'MYS', + numeric: '458', }, { - 'name': 'Maldives', - 'alpha2': 'MV', - 'alpha3': 'MDV', - 'numeric': '462', + name: 'Maldives', + alpha2: 'MV', + alpha3: 'MDV', + numeric: '462', }, { - 'name': 'Mali', - 'alpha2': 'ML', - 'alpha3': 'MLI', - 'numeric': '466', + name: 'Mali', + alpha2: 'ML', + alpha3: 'MLI', + numeric: '466', }, { - 'name': 'Malta', - 'alpha2': 'MT', - 'alpha3': 'MLT', - 'numeric': '470', + name: 'Malta', + alpha2: 'MT', + alpha3: 'MLT', + numeric: '470', }, { - 'name': 'Marshall Islands (the)', - 'alpha2': 'MH', - 'alpha3': 'MHL', - 'numeric': '584', - 'altName': 'Marshall Islands', + name: 'Marshall Islands (the)', + alpha2: 'MH', + alpha3: 'MHL', + numeric: '584', + altName: 'Marshall Islands', }, { - 'name': 'Martinique', - 'alpha2': 'MQ', - 'alpha3': 'MTQ', - 'numeric': '474', + name: 'Martinique', + alpha2: 'MQ', + alpha3: 'MTQ', + numeric: '474', }, { - 'name': 'Mauritania', - 'alpha2': 'MR', - 'alpha3': 'MRT', - 'numeric': '478', + name: 'Mauritania', + alpha2: 'MR', + alpha3: 'MRT', + numeric: '478', }, { - 'name': 'Mauritius', - 'alpha2': 'MU', - 'alpha3': 'MUS', - 'numeric': '480', + name: 'Mauritius', + alpha2: 'MU', + alpha3: 'MUS', + numeric: '480', }, { - 'name': 'Mayotte', - 'alpha2': 'YT', - 'alpha3': 'MYT', - 'numeric': '175', + name: 'Mayotte', + alpha2: 'YT', + alpha3: 'MYT', + numeric: '175', }, { - 'name': 'Mexico', - 'alpha2': 'MX', - 'alpha3': 'MEX', - 'numeric': '484', + name: 'Mexico', + alpha2: 'MX', + alpha3: 'MEX', + numeric: '484', }, { - 'name': 'Micronesia (Federated States of)', - 'alpha2': 'FM', - 'alpha3': 'FSM', - 'numeric': '583', - 'altName': 'Micronesia, Federated States of', - 'shortName': 'Micronesia', + name: 'Micronesia (Federated States of)', + alpha2: 'FM', + alpha3: 'FSM', + numeric: '583', + altName: 'Micronesia, Federated States of', + shortName: 'Micronesia', }, { - 'name': 'Moldova (the Republic of)', - 'alpha2': 'MD', - 'alpha3': 'MDA', - 'numeric': '498', - 'altName': 'Moldova', + name: 'Moldova (the Republic of)', + alpha2: 'MD', + alpha3: 'MDA', + numeric: '498', + altName: 'Moldova', }, { - 'name': 'Monaco', - 'alpha2': 'MC', - 'alpha3': 'MCO', - 'numeric': '492', + name: 'Monaco', + alpha2: 'MC', + alpha3: 'MCO', + numeric: '492', }, { - 'name': 'Mongolia', - 'alpha2': 'MN', - 'alpha3': 'MNG', - 'numeric': '496', + name: 'Mongolia', + alpha2: 'MN', + alpha3: 'MNG', + numeric: '496', }, { - 'name': 'Montenegro', - 'alpha2': 'ME', - 'alpha3': 'MNE', - 'numeric': '499', + name: 'Montenegro', + alpha2: 'ME', + alpha3: 'MNE', + numeric: '499', }, { - 'name': 'Montserrat', - 'alpha2': 'MS', - 'alpha3': 'MSR', - 'numeric': '500', + name: 'Montserrat', + alpha2: 'MS', + alpha3: 'MSR', + numeric: '500', }, { - 'name': 'Morocco', - 'alpha2': 'MA', - 'alpha3': 'MAR', - 'numeric': '504', + name: 'Morocco', + alpha2: 'MA', + alpha3: 'MAR', + numeric: '504', }, { - 'name': 'Mozambique', - 'alpha2': 'MZ', - 'alpha3': 'MOZ', - 'numeric': '508', + name: 'Mozambique', + alpha2: 'MZ', + alpha3: 'MOZ', + numeric: '508', }, { - 'name': 'Myanmar', - 'alpha2': 'MM', - 'alpha3': 'MMR', - 'numeric': '104', + name: 'Myanmar', + alpha2: 'MM', + alpha3: 'MMR', + numeric: '104', }, { - 'name': 'Namibia', - 'alpha2': 'NA', - 'alpha3': 'NAM', - 'numeric': '516', + name: 'Namibia', + alpha2: 'NA', + alpha3: 'NAM', + numeric: '516', }, { - 'name': 'Nauru', - 'alpha2': 'NR', - 'alpha3': 'NRU', - 'numeric': '520', + name: 'Nauru', + alpha2: 'NR', + alpha3: 'NRU', + numeric: '520', }, { - 'name': 'Nepal', - 'alpha2': 'NP', - 'alpha3': 'NPL', - 'numeric': '524', + name: 'Nepal', + alpha2: 'NP', + alpha3: 'NPL', + numeric: '524', }, { - 'name': 'Netherlands (the)', - 'alpha2': 'NL', - 'alpha3': 'NLD', - 'numeric': '528', - 'altName': 'Netherlands', + name: 'Netherlands (the)', + alpha2: 'NL', + alpha3: 'NLD', + numeric: '528', + altName: 'Netherlands', }, { - 'name': 'New Caledonia', - 'alpha2': 'NC', - 'alpha3': 'NCL', - 'numeric': '540', + name: 'New Caledonia', + alpha2: 'NC', + alpha3: 'NCL', + numeric: '540', }, { - 'name': 'New Zealand', - 'alpha2': 'NZ', - 'alpha3': 'NZL', - 'numeric': '554', + name: 'New Zealand', + alpha2: 'NZ', + alpha3: 'NZL', + numeric: '554', }, { - 'name': 'Nicaragua', - 'alpha2': 'NI', - 'alpha3': 'NIC', - 'numeric': '558', + name: 'Nicaragua', + alpha2: 'NI', + alpha3: 'NIC', + numeric: '558', }, { - 'name': 'Niger (the)', - 'alpha2': 'NE', - 'alpha3': 'NER', - 'numeric': '562', - 'altName': 'Niger', + name: 'Niger (the)', + alpha2: 'NE', + alpha3: 'NER', + numeric: '562', + altName: 'Niger', }, { - 'name': 'Nigeria', - 'alpha2': 'NG', - 'alpha3': 'NGA', - 'numeric': '566', + name: 'Nigeria', + alpha2: 'NG', + alpha3: 'NGA', + numeric: '566', }, { - 'name': 'Niue', - 'alpha2': 'NU', - 'alpha3': 'NIU', - 'numeric': '570', + name: 'Niue', + alpha2: 'NU', + alpha3: 'NIU', + numeric: '570', }, { - 'name': 'Norfolk Island', - 'alpha2': 'NF', - 'alpha3': 'NFK', - 'numeric': '574', + name: 'Norfolk Island', + alpha2: 'NF', + alpha3: 'NFK', + numeric: '574', }, { - 'name': 'Northern Mariana Islands (the)', - 'alpha2': 'MP', - 'alpha3': 'MNP', - 'numeric': '580', - 'altName': 'Northern Mariana Islands', + name: 'Northern Mariana Islands (the)', + alpha2: 'MP', + alpha3: 'MNP', + numeric: '580', + altName: 'Northern Mariana Islands', }, { - 'name': 'Norway', - 'alpha2': 'NO', - 'alpha3': 'NOR', - 'numeric': '578', + name: 'Norway', + alpha2: 'NO', + alpha3: 'NOR', + numeric: '578', }, { - 'name': 'Oman', - 'alpha2': 'OM', - 'alpha3': 'OMN', - 'numeric': '512', + name: 'Oman', + alpha2: 'OM', + alpha3: 'OMN', + numeric: '512', }, { - 'name': 'Pakistan', - 'alpha2': 'PK', - 'alpha3': 'PAK', - 'numeric': '586', + name: 'Pakistan', + alpha2: 'PK', + alpha3: 'PAK', + numeric: '586', }, { - 'name': 'Palau', - 'alpha2': 'PW', - 'alpha3': 'PLW', - 'numeric': '585', + name: 'Palau', + alpha2: 'PW', + alpha3: 'PLW', + numeric: '585', }, { - 'name': 'Palestine, State of', - 'alpha2': 'PS', - 'alpha3': 'PSE', - 'numeric': '275', - 'altName': 'Palestinian Territory', - 'shortName': 'Palestine', + name: 'Palestine, State of', + alpha2: 'PS', + alpha3: 'PSE', + numeric: '275', + altName: 'Palestinian Territory', + shortName: 'Palestine', }, { - 'name': 'Panama', - 'alpha2': 'PA', - 'alpha3': 'PAN', - 'numeric': '591', + name: 'Panama', + alpha2: 'PA', + alpha3: 'PAN', + numeric: '591', }, { - 'name': 'Papua New Guinea', - 'alpha2': 'PG', - 'alpha3': 'PNG', - 'numeric': '598', + name: 'Papua New Guinea', + alpha2: 'PG', + alpha3: 'PNG', + numeric: '598', }, { - 'name': 'Paraguay', - 'alpha2': 'PY', - 'alpha3': 'PRY', - 'numeric': '600', + name: 'Paraguay', + alpha2: 'PY', + alpha3: 'PRY', + numeric: '600', }, { - 'name': 'Peru', - 'alpha2': 'PE', - 'alpha3': 'PER', - 'numeric': '604', + name: 'Peru', + alpha2: 'PE', + alpha3: 'PER', + numeric: '604', }, { - 'name': 'Philippines (the)', - 'alpha2': 'PH', - 'alpha3': 'PHL', - 'numeric': '608', - 'altName': 'Philippines', + name: 'Philippines (the)', + alpha2: 'PH', + alpha3: 'PHL', + numeric: '608', + altName: 'Philippines', }, { - 'name': 'Pitcairn', - 'alpha2': 'PN', - 'alpha3': 'PCN', - 'numeric': '612', + name: 'Pitcairn', + alpha2: 'PN', + alpha3: 'PCN', + numeric: '612', }, { - 'name': 'Poland', - 'alpha2': 'PL', - 'alpha3': 'POL', - 'numeric': '616', + name: 'Poland', + alpha2: 'PL', + alpha3: 'POL', + numeric: '616', }, { - 'name': 'Portugal', - 'alpha2': 'PT', - 'alpha3': 'PRT', - 'numeric': '620', + name: 'Portugal', + alpha2: 'PT', + alpha3: 'PRT', + numeric: '620', }, { - 'name': 'Puerto Rico', - 'alpha2': 'PR', - 'alpha3': 'PRI', - 'numeric': '630', + name: 'Puerto Rico', + alpha2: 'PR', + alpha3: 'PRI', + numeric: '630', }, { - 'name': 'Qatar', - 'alpha2': 'QA', - 'alpha3': 'QAT', - 'numeric': '634', + name: 'Qatar', + alpha2: 'QA', + alpha3: 'QAT', + numeric: '634', }, { - 'name': 'Réunion', - 'alpha2': 'RE', - 'alpha3': 'REU', - 'numeric': '638', - 'shortName': 'Reunion', + name: 'Réunion', + alpha2: 'RE', + alpha3: 'REU', + numeric: '638', + shortName: 'Reunion', }, { - 'name': 'Romania', - 'alpha2': 'RO', - 'alpha3': 'ROU', - 'numeric': '642', + name: 'Romania', + alpha2: 'RO', + alpha3: 'ROU', + numeric: '642', }, { - 'name': 'Russian Federation (the)', - 'alpha2': 'RU', - 'alpha3': 'RUS', - 'numeric': '643', - 'altName': 'Russian Federation', - 'shortName': 'Russia', + name: 'Russian Federation (the)', + alpha2: 'RU', + alpha3: 'RUS', + numeric: '643', + altName: 'Russian Federation', + shortName: 'Russia', }, { - 'name': 'Rwanda', - 'alpha2': 'RW', - 'alpha3': 'RWA', - 'numeric': '646', + name: 'Rwanda', + alpha2: 'RW', + alpha3: 'RWA', + numeric: '646', }, { - 'name': 'Saint Barthélemy', - 'alpha2': 'BL', - 'alpha3': 'BLM', - 'numeric': '652', - 'altName': 'Saint-Barthélemy', - 'shortName': 'Saint Barthelemy', + name: 'Saint Barthélemy', + alpha2: 'BL', + alpha3: 'BLM', + numeric: '652', + altName: 'Saint-Barthélemy', + shortName: 'Saint Barthelemy', }, { - 'name': 'Saint Helena, Ascension and Tristan da Cunha', - 'alpha2': 'SH', - 'alpha3': 'SHN', - 'numeric': '654', - 'altName': 'Saint Helena', + name: 'Saint Helena, Ascension and Tristan da Cunha', + alpha2: 'SH', + alpha3: 'SHN', + numeric: '654', + altName: 'Saint Helena', }, { - 'name': 'Saint Kitts and Nevis', - 'alpha2': 'KN', - 'alpha3': 'KNA', - 'numeric': '659', + name: 'Saint Kitts and Nevis', + alpha2: 'KN', + alpha3: 'KNA', + numeric: '659', }, { - 'name': 'Saint Lucia', - 'alpha2': 'LC', - 'alpha3': 'LCA', - 'numeric': '662', + name: 'Saint Lucia', + alpha2: 'LC', + alpha3: 'LCA', + numeric: '662', }, { - 'name': 'Saint Martin (French part)', - 'alpha2': 'MF', - 'alpha3': 'MAF', - 'numeric': '663', - 'altName': 'Saint-Martin (French part)', - 'shortName': 'Saint Martin', + name: 'Saint Martin (French part)', + alpha2: 'MF', + alpha3: 'MAF', + numeric: '663', + altName: 'Saint-Martin (French part)', + shortName: 'Saint Martin', }, { - 'name': 'Saint Pierre and Miquelon', - 'alpha2': 'PM', - 'alpha3': 'SPM', - 'numeric': '666', + name: 'Saint Pierre and Miquelon', + alpha2: 'PM', + alpha3: 'SPM', + numeric: '666', }, { - 'name': 'Saint Vincent and the Grenadines', - 'alpha2': 'VC', - 'alpha3': 'VCT', - 'numeric': '670', - 'altName': 'Saint Vincent and Grenadines', + name: 'Saint Vincent and the Grenadines', + alpha2: 'VC', + alpha3: 'VCT', + numeric: '670', + altName: 'Saint Vincent and Grenadines', }, { - 'name': 'Samoa', - 'alpha2': 'WS', - 'alpha3': 'WSM', - 'numeric': '882', + name: 'Samoa', + alpha2: 'WS', + alpha3: 'WSM', + numeric: '882', }, { - 'name': 'San Marino', - 'alpha2': 'SM', - 'alpha3': 'SMR', - 'numeric': '674', + name: 'San Marino', + alpha2: 'SM', + alpha3: 'SMR', + numeric: '674', }, { - 'name': 'Sao Tome and Principe', - 'alpha2': 'ST', - 'alpha3': 'STP', - 'numeric': '678', + name: 'Sao Tome and Principe', + alpha2: 'ST', + alpha3: 'STP', + numeric: '678', }, { - 'name': 'Saudi Arabia', - 'alpha2': 'SA', - 'alpha3': 'SAU', - 'numeric': '682', + name: 'Saudi Arabia', + alpha2: 'SA', + alpha3: 'SAU', + numeric: '682', }, { - 'name': 'Senegal', - 'alpha2': 'SN', - 'alpha3': 'SEN', - 'numeric': '686', + name: 'Senegal', + alpha2: 'SN', + alpha3: 'SEN', + numeric: '686', }, { - 'name': 'Serbia', - 'alpha2': 'RS', - 'alpha3': 'SRB', - 'numeric': '688', + name: 'Serbia', + alpha2: 'RS', + alpha3: 'SRB', + numeric: '688', }, { - 'name': 'Seychelles', - 'alpha2': 'SC', - 'alpha3': 'SYC', - 'numeric': '690', + name: 'Seychelles', + alpha2: 'SC', + alpha3: 'SYC', + numeric: '690', }, { - 'name': 'Sierra Leone', - 'alpha2': 'SL', - 'alpha3': 'SLE', - 'numeric': '694', + name: 'Sierra Leone', + alpha2: 'SL', + alpha3: 'SLE', + numeric: '694', }, { - 'name': 'Singapore', - 'alpha2': 'SG', - 'alpha3': 'SGP', - 'numeric': '702', + name: 'Singapore', + alpha2: 'SG', + alpha3: 'SGP', + numeric: '702', }, { - 'name': 'Sint Maarten (Dutch part)', - 'alpha2': 'SX', - 'alpha3': 'SXM', - 'numeric': '534', - 'shortName': 'Sint Maarten', + name: 'Sint Maarten (Dutch part)', + alpha2: 'SX', + alpha3: 'SXM', + numeric: '534', + shortName: 'Sint Maarten', }, { - 'name': 'Slovakia', - 'alpha2': 'SK', - 'alpha3': 'SVK', - 'numeric': '703', + name: 'Slovakia', + alpha2: 'SK', + alpha3: 'SVK', + numeric: '703', }, { - 'name': 'Slovenia', - 'alpha2': 'SI', - 'alpha3': 'SVN', - 'numeric': '705', + name: 'Slovenia', + alpha2: 'SI', + alpha3: 'SVN', + numeric: '705', }, { - 'name': 'Solomon Islands', - 'alpha2': 'SB', - 'alpha3': 'SLB', - 'numeric': '090', + name: 'Solomon Islands', + alpha2: 'SB', + alpha3: 'SLB', + numeric: '090', }, { - 'name': 'Somalia', - 'alpha2': 'SO', - 'alpha3': 'SOM', - 'numeric': '706', + name: 'Somalia', + alpha2: 'SO', + alpha3: 'SOM', + numeric: '706', }, { - 'name': 'South Africa', - 'alpha2': 'ZA', - 'alpha3': 'ZAF', - 'numeric': '710', + name: 'South Africa', + alpha2: 'ZA', + alpha3: 'ZAF', + numeric: '710', }, { - 'name': 'South Georgia and the South Sandwich Islands', - 'alpha2': 'GS', - 'alpha3': 'SGS', - 'numeric': '239', + name: 'South Georgia and the South Sandwich Islands', + alpha2: 'GS', + alpha3: 'SGS', + numeric: '239', }, { - 'name': 'South Sudan', - 'alpha2': 'SS', - 'alpha3': 'SSD', - 'numeric': '728', + name: 'South Sudan', + alpha2: 'SS', + alpha3: 'SSD', + numeric: '728', }, { - 'name': 'Spain', - 'alpha2': 'ES', - 'alpha3': 'ESP', - 'numeric': '724', + name: 'Spain', + alpha2: 'ES', + alpha3: 'ESP', + numeric: '724', }, { - 'name': 'Sri Lanka', - 'alpha2': 'LK', - 'alpha3': 'LKA', - 'numeric': '144', + name: 'Sri Lanka', + alpha2: 'LK', + alpha3: 'LKA', + numeric: '144', }, { - 'name': 'Sudan (the)', - 'alpha2': 'SD', - 'alpha3': 'SDN', - 'numeric': '729', - 'altName': 'Sudan', + name: 'Sudan (the)', + alpha2: 'SD', + alpha3: 'SDN', + numeric: '729', + altName: 'Sudan', }, { - 'name': 'Suriname', - 'alpha2': 'SR', - 'alpha3': 'SUR', - 'numeric': '740', + name: 'Suriname', + alpha2: 'SR', + alpha3: 'SUR', + numeric: '740', }, { - 'name': 'Svalbard and Jan Mayen', - 'alpha2': 'SJ', - 'alpha3': 'SJM', - 'numeric': '744', - 'altName': 'Svalbard and Jan Mayen Islands', + name: 'Svalbard and Jan Mayen', + alpha2: 'SJ', + alpha3: 'SJM', + numeric: '744', + altName: 'Svalbard and Jan Mayen Islands', }, { - 'name': 'Swaziland', - 'alpha2': 'SZ', - 'alpha3': 'SWZ', - 'numeric': '748', + name: 'Swaziland', + alpha2: 'SZ', + alpha3: 'SWZ', + numeric: '748', }, { - 'name': 'Sweden', - 'alpha2': 'SE', - 'alpha3': 'SWE', - 'numeric': '752', + name: 'Sweden', + alpha2: 'SE', + alpha3: 'SWE', + numeric: '752', }, { - 'name': 'Switzerland', - 'alpha2': 'CH', - 'alpha3': 'CHE', - 'numeric': '756', + name: 'Switzerland', + alpha2: 'CH', + alpha3: 'CHE', + numeric: '756', }, { - 'name': 'Syrian Arab Republic', - 'alpha2': 'SY', - 'alpha3': 'SYR', - 'numeric': '760', - 'altName': 'Syrian Arab Republic (Syria)', - 'shortName': 'Syria', + name: 'Syrian Arab Republic', + alpha2: 'SY', + alpha3: 'SYR', + numeric: '760', + altName: 'Syrian Arab Republic (Syria)', + shortName: 'Syria', }, { - 'name': 'Taiwan (Province of China)', - 'alpha2': 'TW', - 'alpha3': 'TWN', - 'numeric': '158', - 'altName': 'Taiwan, Republic of China', - 'shortName': 'Taiwan', + name: 'Taiwan (Province of China)', + alpha2: 'TW', + alpha3: 'TWN', + numeric: '158', + altName: 'Taiwan, Republic of China', + shortName: 'Taiwan', }, { - 'name': 'Tajikistan', - 'alpha2': 'TJ', - 'alpha3': 'TJK', - 'numeric': '762', + name: 'Tajikistan', + alpha2: 'TJ', + alpha3: 'TJK', + numeric: '762', }, { - 'name': 'Tanzania, United Republic of', - 'alpha2': 'TZ', - 'alpha3': 'TZA', - 'numeric': '834', - 'shortName': 'Tanzania', + name: 'Tanzania, United Republic of', + alpha2: 'TZ', + alpha3: 'TZA', + numeric: '834', + shortName: 'Tanzania', }, { - 'name': 'Thailand', - 'alpha2': 'TH', - 'alpha3': 'THA', - 'numeric': '764', + name: 'Thailand', + alpha2: 'TH', + alpha3: 'THA', + numeric: '764', }, { - 'name': 'Timor-Leste', - 'alpha2': 'TL', - 'alpha3': 'TLS', - 'numeric': '626', - 'shortName': 'East Timor', + name: 'Timor-Leste', + alpha2: 'TL', + alpha3: 'TLS', + numeric: '626', + shortName: 'East Timor', }, { - 'name': 'Togo', - 'alpha2': 'TG', - 'alpha3': 'TGO', - 'numeric': '768', + name: 'Togo', + alpha2: 'TG', + alpha3: 'TGO', + numeric: '768', }, { - 'name': 'Tokelau', - 'alpha2': 'TK', - 'alpha3': 'TKL', - 'numeric': '772', + name: 'Tokelau', + alpha2: 'TK', + alpha3: 'TKL', + numeric: '772', }, { - 'name': 'Tonga', - 'alpha2': 'TO', - 'alpha3': 'TON', - 'numeric': '776', + name: 'Tonga', + alpha2: 'TO', + alpha3: 'TON', + numeric: '776', }, { - 'name': 'Trinidad and Tobago', - 'alpha2': 'TT', - 'alpha3': 'TTO', - 'numeric': '780', + name: 'Trinidad and Tobago', + alpha2: 'TT', + alpha3: 'TTO', + numeric: '780', }, { - 'name': 'Tunisia', - 'alpha2': 'TN', - 'alpha3': 'TUN', - 'numeric': '788', + name: 'Tunisia', + alpha2: 'TN', + alpha3: 'TUN', + numeric: '788', }, { - 'name': 'Turkey', - 'alpha2': 'TR', - 'alpha3': 'TUR', - 'numeric': '792', + name: 'Turkey', + alpha2: 'TR', + alpha3: 'TUR', + numeric: '792', }, { - 'name': 'Turkmenistan', - 'alpha2': 'TM', - 'alpha3': 'TKM', - 'numeric': '795', + name: 'Turkmenistan', + alpha2: 'TM', + alpha3: 'TKM', + numeric: '795', }, { - 'name': 'Turks and Caicos Islands (the)', - 'alpha2': 'TC', - 'alpha3': 'TCA', - 'numeric': '796', - 'altName': 'Turks and Caicos Islands', + name: 'Turks and Caicos Islands (the)', + alpha2: 'TC', + alpha3: 'TCA', + numeric: '796', + altName: 'Turks and Caicos Islands', }, { - 'name': 'Tuvalu', - 'alpha2': 'TV', - 'alpha3': 'TUV', - 'numeric': '798', + name: 'Tuvalu', + alpha2: 'TV', + alpha3: 'TUV', + numeric: '798', }, { - 'name': 'Uganda', - 'alpha2': 'UG', - 'alpha3': 'UGA', - 'numeric': '800', + name: 'Uganda', + alpha2: 'UG', + alpha3: 'UGA', + numeric: '800', }, { - 'name': 'Ukraine', - 'alpha2': 'UA', - 'alpha3': 'UKR', - 'numeric': '804', + name: 'Ukraine', + alpha2: 'UA', + alpha3: 'UKR', + numeric: '804', }, { - 'name': 'United Arab Emirates (the)', - 'alpha2': 'AE', - 'alpha3': 'ARE', - 'numeric': '784', - 'altName': 'United Arab Emirates', + name: 'United Arab Emirates (the)', + alpha2: 'AE', + alpha3: 'ARE', + numeric: '784', + altName: 'United Arab Emirates', }, { - 'name': 'United Kingdom of Great Britain and Northern Ireland (the)', - 'alpha2': 'GB', - 'alpha3': 'GBR', - 'numeric': '826', - 'altName': 'United Kingdom', + name: 'United Kingdom of Great Britain and Northern Ireland (the)', + alpha2: 'GB', + alpha3: 'GBR', + numeric: '826', + altName: 'United Kingdom', }, { - 'name': 'United States Minor Outlying Islands (the)', - 'alpha2': 'UM', - 'alpha3': 'UMI', - 'numeric': '581', - 'altName': 'US Minor Outlying Islands', + name: 'United States Minor Outlying Islands (the)', + alpha2: 'UM', + alpha3: 'UMI', + numeric: '581', + altName: 'US Minor Outlying Islands', }, { - 'name': 'United States of America (the)', - 'alpha2': 'US', - 'alpha3': 'USA', - 'numeric': '840', - 'altName': 'United States of America', - 'shortName': 'United States', + name: 'United States of America (the)', + alpha2: 'US', + alpha3: 'USA', + numeric: '840', + altName: 'United States of America', + shortName: 'United States', }, { - 'name': 'Uruguay', - 'alpha2': 'UY', - 'alpha3': 'URY', - 'numeric': '858', + name: 'Uruguay', + alpha2: 'UY', + alpha3: 'URY', + numeric: '858', }, { - 'name': 'Uzbekistan', - 'alpha2': 'UZ', - 'alpha3': 'UZB', - 'numeric': '860', + name: 'Uzbekistan', + alpha2: 'UZ', + alpha3: 'UZB', + numeric: '860', }, { - 'name': 'Vanuatu', - 'alpha2': 'VU', - 'alpha3': 'VUT', - 'numeric': '548', + name: 'Vanuatu', + alpha2: 'VU', + alpha3: 'VUT', + numeric: '548', }, { - 'name': 'Venezuela (Bolivarian Republic of)', - 'alpha2': 'VE', - 'alpha3': 'VEN', - 'numeric': '862', - 'altName': 'Venezuela (Bolivarian Republic)', - 'shortName': 'Venezuela', + name: 'Venezuela (Bolivarian Republic of)', + alpha2: 'VE', + alpha3: 'VEN', + numeric: '862', + altName: 'Venezuela (Bolivarian Republic)', + shortName: 'Venezuela', }, { - 'name': 'Viet Nam', - 'alpha2': 'VN', - 'alpha3': 'VNM', - 'numeric': '704', - 'shortName': 'Vietnam', + name: 'Viet Nam', + alpha2: 'VN', + alpha3: 'VNM', + numeric: '704', + shortName: 'Vietnam', }, { - 'name': 'Virgin Islands (British)', - 'alpha2': 'VG', - 'alpha3': 'VGB', - 'numeric': '092', - 'altName': 'British Virgin Islands', + name: 'Virgin Islands (British)', + alpha2: 'VG', + alpha3: 'VGB', + numeric: '092', + altName: 'British Virgin Islands', }, { - 'name': 'Virgin Islands (U.S.)', - 'alpha2': 'VI', - 'alpha3': 'VIR', - 'numeric': '850', - 'altName': 'Virgin Islands, US', - 'shortName': 'U.S. Virgin Islands', + name: 'Virgin Islands (U.S.)', + alpha2: 'VI', + alpha3: 'VIR', + numeric: '850', + altName: 'Virgin Islands, US', + shortName: 'U.S. Virgin Islands', }, { - 'name': 'Wallis and Futuna', - 'alpha2': 'WF', - 'alpha3': 'WLF', - 'numeric': '876', - 'altName': 'Wallis and Futuna Islands', + name: 'Wallis and Futuna', + alpha2: 'WF', + alpha3: 'WLF', + numeric: '876', + altName: 'Wallis and Futuna Islands', }, { - 'name': 'Western Sahara*', - 'alpha2': 'EH', - 'alpha3': 'ESH', - 'numeric': '732', - 'altName': 'Western Sahara', + name: 'Western Sahara*', + alpha2: 'EH', + alpha3: 'ESH', + numeric: '732', + altName: 'Western Sahara', }, { - 'name': 'Yemen', - 'alpha2': 'YE', - 'alpha3': 'YEM', - 'numeric': '887', + name: 'Yemen', + alpha2: 'YE', + alpha3: 'YEM', + numeric: '887', }, { - 'name': 'Zambia', - 'alpha2': 'ZM', - 'alpha3': 'ZMB', - 'numeric': '894', + name: 'Zambia', + alpha2: 'ZM', + alpha3: 'ZMB', + numeric: '894', }, { - 'name': 'Zimbabwe', - 'alpha2': 'ZW', - 'alpha3': 'ZWE', - 'numeric': '716', + name: 'Zimbabwe', + alpha2: 'ZW', + alpha3: 'ZWE', + numeric: '716', }, ]; diff --git a/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts b/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts index 518f8b6254..982a094c2f 100644 --- a/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/YouTube/GenericFunctions.ts @@ -1,18 +1,20 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function googleApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { let options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -37,8 +39,16 @@ export async function googleApiRequest(this: IExecuteFunctions | IExecuteSingleF } } -export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function googleApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -48,10 +58,7 @@ export async function googleApiRequestAllItems(this: IExecuteFunctions | ILoadOp responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData['nextPageToken']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['nextPageToken'] !== undefined && - responseData['nextPageToken'] !== '' - ); + } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); return returnData; } diff --git a/packages/nodes-base/nodes/Google/YouTube/PlaylistDescription.ts b/packages/nodes-base/nodes/Google/YouTube/PlaylistDescription.ts index fc0de5a022..afcda28959 100644 --- a/packages/nodes-base/nodes/Google/YouTube/PlaylistDescription.ts +++ b/packages/nodes-base/nodes/Google/YouTube/PlaylistDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const playlistOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const playlistOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'playlist', - ], + resource: ['playlist'], }, }, options: [ @@ -62,16 +58,12 @@ export const playlistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'playlist', - ], + operation: ['create'], + resource: ['playlist'], }, }, default: '', - description: 'The playlist\'s title', + description: "The playlist's title", }, { displayName: 'Options', @@ -81,12 +73,8 @@ export const playlistFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'playlist', - ], + operation: ['create'], + resource: ['playlist'], }, }, options: [ @@ -95,7 +83,7 @@ export const playlistFields: INodeProperties[] = [ name: 'description', type: 'string', default: '', - description: 'The playlist\'s description', + description: "The playlist's description", }, { displayName: 'Privacy Status', @@ -116,14 +104,15 @@ export const playlistFields: INodeProperties[] = [ }, ], default: '', - description: 'The playlist\'s privacy status', + description: "The playlist's privacy status", }, { displayName: 'Tags', name: 'tags', type: 'string', default: '', - description: 'Keyword tags associated with the playlist. Mulplie can be defined separated by comma.', + description: + 'Keyword tags associated with the playlist. Mulplie can be defined separated by comma.', }, { displayName: 'Default Language Name or ID', @@ -133,21 +122,24 @@ export const playlistFields: INodeProperties[] = [ loadOptionsMethod: 'getLanguages', }, default: '', - description: 'The language of the text in the playlist resource\'s title and description properties. Choose from the list, or specify an ID using an expression.', + description: + 'The language of the text in the playlist resource\'s title and description properties. Choose from the list, or specify an ID using an expression.', }, { displayName: 'On Behalf Of Content Owner Channel', name: 'onBehalfOfContentOwnerChannel', type: 'string', default: '', - description: 'The onBehalfOfContentOwnerChannel parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter.', + description: + 'The onBehalfOfContentOwnerChannel parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter.', }, { displayName: 'On Behalf Of Content Owner', name: 'onBehalfOfContentOwner', type: 'string', default: '', - description: 'The onBehalfOfContentOwner parameter indicates that the request\'s authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value', + description: + "The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value", }, ], }, @@ -161,12 +153,8 @@ export const playlistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'playlist', - ], + operation: ['get'], + resource: ['playlist'], }, }, default: '', @@ -208,15 +196,12 @@ export const playlistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'playlist', - ], + operation: ['get'], + resource: ['playlist'], }, }, - description: 'The fields parameter specifies a comma-separated list of one or more playlist resource properties that the API response will include', + description: + 'The fields parameter specifies a comma-separated list of one or more playlist resource properties that the API response will include', default: ['*'], }, { @@ -227,12 +212,8 @@ export const playlistFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'playlist', - ], + operation: ['get'], + resource: ['playlist'], }, }, options: [ @@ -241,14 +222,16 @@ export const playlistFields: INodeProperties[] = [ name: 'onBehalfOfContentOwner', type: 'string', default: '', - description: 'The onBehalfOfContentOwner parameter indicates that the request\'s authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value', + description: + "The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value", }, { displayName: 'On Behalf Of Content Owner Channel', name: 'onBehalfOfContentOwnerChannel', type: 'string', default: '', - description: 'The onBehalfOfContentOwnerChannel parameter specifies the YouTube channel ID of the channel to which a video is being added', + description: + 'The onBehalfOfContentOwnerChannel parameter specifies the YouTube channel ID of the channel to which a video is being added', }, ], }, @@ -262,12 +245,8 @@ export const playlistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'playlist', - ], + operation: ['delete'], + resource: ['playlist'], }, }, default: '', @@ -280,12 +259,8 @@ export const playlistFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'playlist', - ], + operation: ['delete'], + resource: ['playlist'], }, }, options: [ @@ -294,7 +269,8 @@ export const playlistFields: INodeProperties[] = [ name: 'onBehalfOfContentOwner', type: 'string', default: '', - description: 'The onBehalfOfContentOwner parameter indicates that the request\'s authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value', + description: + "The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value", }, ], }, @@ -338,15 +314,12 @@ export const playlistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'playlist', - ], + operation: ['getAll'], + resource: ['playlist'], }, }, - description: 'The fields parameter specifies a comma-separated list of one or more playlist resource properties that the API response will include', + description: + 'The fields parameter specifies a comma-separated list of one or more playlist resource properties that the API response will include', default: ['*'], }, { @@ -355,12 +328,8 @@ export const playlistFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'playlist', - ], + operation: ['getAll'], + resource: ['playlist'], }, }, default: false, @@ -372,15 +341,9 @@ export const playlistFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'playlist', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['playlist'], + returnAll: [false], }, }, typeOptions: { @@ -398,12 +361,8 @@ export const playlistFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'playlist', - ], + operation: ['getAll'], + resource: ['playlist'], }, }, options: [ @@ -412,14 +371,16 @@ export const playlistFields: INodeProperties[] = [ name: 'channelId', type: 'string', default: '', - description: 'This value indicates that the API should only return the specified channel\'s playlists', + description: + "This value indicates that the API should only return the specified channel's playlists", }, { displayName: 'ID', name: 'id', type: 'string', default: '', - description: 'The ID parameter specifies a comma-separated list of the YouTube playlist ID(s) for the resource(s) that are being retrieved. In a playlist resource, the ID property specifies the playlist\'s YouTube playlist ID.', + description: + "The ID parameter specifies a comma-separated list of the YouTube playlist ID(s) for the resource(s) that are being retrieved. In a playlist resource, the ID property specifies the playlist's YouTube playlist ID.", }, ], }, @@ -431,12 +392,8 @@ export const playlistFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'playlist', - ], + operation: ['getAll'], + resource: ['playlist'], }, }, options: [ @@ -445,14 +402,16 @@ export const playlistFields: INodeProperties[] = [ name: 'onBehalfOfContentOwnerChannel', type: 'string', default: '', - description: 'The onBehalfOfContentOwnerChannel parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter.', + description: + 'The onBehalfOfContentOwnerChannel parameter specifies the YouTube channel ID of the channel to which a video is being added. This parameter is required when a request specifies a value for the onBehalfOfContentOwner parameter, and it can only be used in conjunction with that parameter.', }, { displayName: 'On Behalf Of Content Owner', name: 'onBehalfOfContentOwner', type: 'string', default: '', - description: 'The onBehalfOfContentOwner parameter indicates that the request\'s authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value', + description: + "The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value", }, ], }, @@ -466,16 +425,12 @@ export const playlistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'playlist', - ], + operation: ['update'], + resource: ['playlist'], }, }, default: '', - description: 'The playlist\'s title', + description: "The playlist's title", }, { displayName: 'Title', @@ -484,16 +439,12 @@ export const playlistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'playlist', - ], + operation: ['update'], + resource: ['playlist'], }, }, default: '', - description: 'The playlist\'s title', + description: "The playlist's title", }, { displayName: 'Update Fields', @@ -503,12 +454,8 @@ export const playlistFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'playlist', - ], + operation: ['update'], + resource: ['playlist'], }, }, options: [ @@ -520,21 +467,23 @@ export const playlistFields: INodeProperties[] = [ loadOptionsMethod: 'getLanguages', }, default: '', - description: 'The language of the text in the playlist resource\'s title and description properties. Choose from the list, or specify an ID using an expression.', + description: + 'The language of the text in the playlist resource\'s title and description properties. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Description', name: 'description', type: 'string', default: '', - description: 'The playlist\'s description', + description: "The playlist's description", }, { displayName: 'On Behalf Of Content Owner', name: 'onBehalfOfContentOwner', type: 'string', default: '', - description: 'The onBehalfOfContentOwner parameter indicates that the request\'s authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value', + description: + "The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value", }, { displayName: 'Privacy Status', @@ -555,14 +504,15 @@ export const playlistFields: INodeProperties[] = [ }, ], default: '', - description: 'The playlist\'s privacy status', + description: "The playlist's privacy status", }, { displayName: 'Tags', name: 'tags', type: 'string', default: '', - description: 'Keyword tags associated with the playlist. Mulplie can be defined separated by comma.', + description: + 'Keyword tags associated with the playlist. Mulplie can be defined separated by comma.', }, ], }, diff --git a/packages/nodes-base/nodes/Google/YouTube/PlaylistItemDescription.ts b/packages/nodes-base/nodes/Google/YouTube/PlaylistItemDescription.ts index 1c646b9429..a85c8cea37 100644 --- a/packages/nodes-base/nodes/Google/YouTube/PlaylistItemDescription.ts +++ b/packages/nodes-base/nodes/Google/YouTube/PlaylistItemDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const playlistItemOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const playlistItemOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'playlistItem', - ], + resource: ['playlistItem'], }, }, options: [ @@ -31,7 +27,7 @@ export const playlistItemOperations: INodeProperties[] = [ { name: 'Get', value: 'get', - description: 'Get a playlist\'s item', + description: "Get a playlist's item", action: 'Get a playlist item', }, { @@ -53,19 +49,16 @@ export const playlistItemFields: INodeProperties[] = [ displayName: 'Playlist Name or ID', name: 'playlistId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getPlaylists', }, required: true, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'playlistItem', - ], + operation: ['add'], + resource: ['playlistItem'], }, }, default: '', @@ -77,12 +70,8 @@ export const playlistItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'playlistItem', - ], + operation: ['add'], + resource: ['playlistItem'], }, }, default: '', @@ -95,12 +84,8 @@ export const playlistItemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'playlistItem', - ], + operation: ['add'], + resource: ['playlistItem'], }, }, options: [ @@ -109,21 +94,24 @@ export const playlistItemFields: INodeProperties[] = [ name: 'endAt', type: 'dateTime', default: '', - description: 'The time, measured in seconds from the start of the video, when the video should stop playing', + description: + 'The time, measured in seconds from the start of the video, when the video should stop playing', }, { displayName: 'Note', name: 'note', type: 'string', default: '', - description: 'A user-generated note for this item. The property value has a maximum length of 280 characters.', + description: + 'A user-generated note for this item. The property value has a maximum length of 280 characters.', }, { displayName: 'On Behalf Of Content Owner', name: 'onBehalfOfContentOwner', type: 'string', default: '', - description: 'The onBehalfOfContentOwner parameter indicates that the request\'s authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value', + description: + "The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value", }, { displayName: 'Position', @@ -133,14 +121,16 @@ export const playlistItemFields: INodeProperties[] = [ minValue: 0, }, default: '', - description: 'The order in which the item appears in the playlist. The value uses a zero-based index, so the first item has a position of 0, the second item has a position of 1, and so forth.', + description: + 'The order in which the item appears in the playlist. The value uses a zero-based index, so the first item has a position of 0, the second item has a position of 1, and so forth.', }, { displayName: 'Start At', name: 'startAt', type: 'dateTime', default: '', - description: 'The time, measured in seconds from the start of the video, when the video should start playing', + description: + 'The time, measured in seconds from the start of the video, when the video should start playing', }, ], }, @@ -154,12 +144,8 @@ export const playlistItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'playlistItem', - ], + operation: ['get'], + resource: ['playlistItem'], }, }, default: '', @@ -193,15 +179,12 @@ export const playlistItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'playlistItem', - ], + operation: ['get'], + resource: ['playlistItem'], }, }, - description: 'The fields parameter specifies a comma-separated list of one or more playlistItem resource properties that the API response will include', + description: + 'The fields parameter specifies a comma-separated list of one or more playlistItem resource properties that the API response will include', default: ['*'], }, { @@ -212,12 +195,8 @@ export const playlistItemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'playlistItem', - ], + operation: ['get'], + resource: ['playlistItem'], }, }, options: [ @@ -226,7 +205,8 @@ export const playlistItemFields: INodeProperties[] = [ name: 'onBehalfOfContentOwner', type: 'string', default: '', - description: 'The onBehalfOfContentOwner parameter indicates that the request\'s authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value', + description: + "The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value", }, ], }, @@ -240,12 +220,8 @@ export const playlistItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'playlistItem', - ], + operation: ['delete'], + resource: ['playlistItem'], }, }, default: '', @@ -258,12 +234,8 @@ export const playlistItemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'playlistItem', - ], + operation: ['delete'], + resource: ['playlistItem'], }, }, options: [ @@ -272,7 +244,8 @@ export const playlistItemFields: INodeProperties[] = [ name: 'onBehalfOfContentOwner', type: 'string', default: '', - description: 'The onBehalfOfContentOwner parameter indicates that the request\'s authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value', + description: + "The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value", }, ], }, @@ -283,19 +256,16 @@ export const playlistItemFields: INodeProperties[] = [ displayName: 'Playlist Name or ID', name: 'playlistId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getPlaylists', }, required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'playlistItem', - ], + operation: ['getAll'], + resource: ['playlistItem'], }, }, default: '', @@ -329,15 +299,12 @@ export const playlistItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'playlistItem', - ], + operation: ['getAll'], + resource: ['playlistItem'], }, }, - description: 'The fields parameter specifies a comma-separated list of one or more playlistItem resource properties that the API response will include', + description: + 'The fields parameter specifies a comma-separated list of one or more playlistItem resource properties that the API response will include', default: ['*'], }, { @@ -346,12 +313,8 @@ export const playlistItemFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'playlistItem', - ], + operation: ['getAll'], + resource: ['playlistItem'], }, }, default: false, @@ -363,15 +326,9 @@ export const playlistItemFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'playlistItem', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['playlistItem'], + returnAll: [false], }, }, typeOptions: { @@ -389,12 +346,8 @@ export const playlistItemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'playlistItem', - ], + operation: ['getAll'], + resource: ['playlistItem'], }, }, options: [ @@ -403,7 +356,8 @@ export const playlistItemFields: INodeProperties[] = [ name: 'onBehalfOfContentOwner', type: 'string', default: '', - description: 'The onBehalfOfContentOwner parameter indicates that the request\'s authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value', + description: + "The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value", }, ], }, diff --git a/packages/nodes-base/nodes/Google/YouTube/VideoCategoryDescription.ts b/packages/nodes-base/nodes/Google/YouTube/VideoCategoryDescription.ts index 0991184cd1..368e184997 100644 --- a/packages/nodes-base/nodes/Google/YouTube/VideoCategoryDescription.ts +++ b/packages/nodes-base/nodes/Google/YouTube/VideoCategoryDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const videoCategoryOperations: INodeProperties[] = [ { @@ -10,13 +8,10 @@ export const videoCategoryOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'videoCategory', - ], + resource: ['videoCategory'], }, }, options: [ - { name: 'Get All', value: 'getAll', @@ -37,16 +32,13 @@ export const videoCategoryFields: INodeProperties[] = [ displayName: 'Region Code', name: 'regionCode', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'videoCategory', - ], + operation: ['getAll'], + resource: ['videoCategory'], }, }, typeOptions: { @@ -60,12 +52,8 @@ export const videoCategoryFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'videoCategory', - ], + operation: ['getAll'], + resource: ['videoCategory'], }, }, default: false, @@ -77,15 +65,9 @@ export const videoCategoryFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'videoCategory', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['videoCategory'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Google/YouTube/VideoDescription.ts b/packages/nodes-base/nodes/Google/YouTube/VideoDescription.ts index 21a1ee2bb5..fcf3c7dc0d 100644 --- a/packages/nodes-base/nodes/Google/YouTube/VideoDescription.ts +++ b/packages/nodes-base/nodes/Google/YouTube/VideoDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const videoOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const videoOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'video', - ], + resource: ['video'], }, }, options: [ @@ -68,12 +64,8 @@ export const videoFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'video', - ], + operation: ['upload'], + resource: ['video'], }, }, default: '', @@ -83,18 +75,15 @@ export const videoFields: INodeProperties[] = [ displayName: 'Region Code', name: 'regionCode', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCountriesCodes', }, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'video', - ], + operation: ['upload'], + resource: ['video'], }, }, default: '', @@ -103,21 +92,16 @@ export const videoFields: INodeProperties[] = [ displayName: 'Category Name or ID', name: 'categoryId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getVideoCategories', - loadOptionsDependsOn: [ - 'regionCode', - ], + loadOptionsDependsOn: ['regionCode'], }, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'video', - ], + operation: ['upload'], + resource: ['video'], }, }, default: '', @@ -129,12 +113,8 @@ export const videoFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'video', - ], + operation: ['upload'], + resource: ['video'], }, }, default: 'data', @@ -147,12 +127,8 @@ export const videoFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'video', - ], + operation: ['upload'], + resource: ['video'], }, }, options: [ @@ -164,14 +140,15 @@ export const videoFields: INodeProperties[] = [ loadOptionsMethod: 'getLanguages', }, default: '', - description: 'The language of the text in the playlist resource\'s title and description properties. Choose from the list, or specify an ID using an expression.', + description: + 'The language of the text in the playlist resource\'s title and description properties. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Description', name: 'description', type: 'string', default: '', - description: 'The playlist\'s description', + description: "The playlist's description", }, { displayName: 'Embeddable', @@ -195,14 +172,15 @@ export const videoFields: INodeProperties[] = [ }, ], default: '', - description: 'The video\'s license', + description: "The video's license", }, { displayName: 'Notify Subscribers', name: 'notifySubscribers', type: 'boolean', default: false, - description: 'Whether YouTube should send a notification about the new video to users who subscribe to the video\'s channel', + description: + "Whether YouTube should send a notification about the new video to users who subscribe to the video's channel", }, { displayName: 'Privacy Status', @@ -223,21 +201,23 @@ export const videoFields: INodeProperties[] = [ }, ], default: '', - description: 'The playlist\'s privacy status', + description: "The playlist's privacy status", }, { displayName: 'Public Stats Viewable', name: 'publicStatsViewable', type: 'boolean', default: true, - description: 'Whether the extended video statistics on the video\'s watch page are publicly viewable', + description: + "Whether the extended video statistics on the video's watch page are publicly viewable", }, { displayName: 'Publish At', name: 'publishAt', type: 'dateTime', default: '', - description: 'If you set a value for this property, you must also set the status.privacyStatus property to private', + description: + 'If you set a value for this property, you must also set the status.privacyStatus property to private', }, { displayName: 'Recording Date', @@ -251,14 +231,16 @@ export const videoFields: INodeProperties[] = [ name: 'selfDeclaredMadeForKids', type: 'boolean', default: false, - description: 'Whether the video is designated as child-directed, and it contains the current "made for kids" status of the video', + description: + 'Whether the video is designated as child-directed, and it contains the current "made for kids" status of the video', }, { displayName: 'Tags', name: 'tags', type: 'string', default: '', - description: 'Keyword tags associated with the playlist. Mulplie can be defined separated by comma.', + description: + 'Keyword tags associated with the playlist. Mulplie can be defined separated by comma.', }, ], }, @@ -272,12 +254,8 @@ export const videoFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'video', - ], + operation: ['delete'], + resource: ['video'], }, }, description: 'ID of the video', @@ -291,12 +269,8 @@ export const videoFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'video', - ], + operation: ['delete'], + resource: ['video'], }, }, options: [ @@ -305,7 +279,8 @@ export const videoFields: INodeProperties[] = [ name: 'onBehalfOfContentOwner', type: 'string', default: '', - description: 'The onBehalfOfContentOwner parameter indicates that the request\'s authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value', + description: + "The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value", }, ], }, @@ -319,12 +294,8 @@ export const videoFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'video', - ], + operation: ['get'], + resource: ['video'], }, }, default: '', @@ -382,15 +353,12 @@ export const videoFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'video', - ], + operation: ['get'], + resource: ['video'], }, }, - description: 'The fields parameter specifies a comma-separated list of one or more video resource properties that the API response will include', + description: + 'The fields parameter specifies a comma-separated list of one or more video resource properties that the API response will include', default: ['*'], }, { @@ -401,12 +369,8 @@ export const videoFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'video', - ], + operation: ['get'], + resource: ['video'], }, }, options: [ @@ -415,7 +379,8 @@ export const videoFields: INodeProperties[] = [ name: 'onBehalfOfContentOwner', type: 'string', default: '', - description: 'The onBehalfOfContentOwner parameter indicates that the request\'s authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value', + description: + "The onBehalfOfContentOwner parameter indicates that the request's authorization credentials identify a YouTube CMS user who is acting on behalf of the content owner specified in the parameter value", }, ], }, @@ -428,12 +393,8 @@ export const videoFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'video', - ], + operation: ['getAll'], + resource: ['video'], }, }, default: false, @@ -445,15 +406,9 @@ export const videoFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'video', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['video'], + returnAll: [false], }, }, typeOptions: { @@ -471,12 +426,8 @@ export const videoFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'video', - ], + operation: ['getAll'], + resource: ['video'], }, }, options: [ @@ -485,28 +436,32 @@ export const videoFields: INodeProperties[] = [ name: 'channelId', type: 'string', default: '', - description: 'The channelId parameter indicates that the API response should only contain resources created by the channel', + description: + 'The channelId parameter indicates that the API response should only contain resources created by the channel', }, { displayName: 'For Developer', name: 'forDeveloper', type: 'boolean', default: false, - description: 'Whether to restrict the search to only retrieve videos uploaded via the developer\'s application or website', + description: + "Whether to restrict the search to only retrieve videos uploaded via the developer's application or website", }, { displayName: 'Published After', name: 'publishedAfter', type: 'dateTime', default: '', - description: 'The publishedAfter parameter indicates that the API response should only contain resources created at or after the specified time', + description: + 'The publishedAfter parameter indicates that the API response should only contain resources created at or after the specified time', }, { displayName: 'Published Before', name: 'publishedBefore', type: 'dateTime', default: '', - description: 'The publishedBefore parameter indicates that the API response should only contain resources created before or at the specified time', + description: + 'The publishedBefore parameter indicates that the API response should only contain resources created before or at the specified time', }, { displayName: 'Query', @@ -524,28 +479,32 @@ export const videoFields: INodeProperties[] = [ loadOptionsMethod: 'getCountriesCodes', }, default: '', - description: 'The regionCode parameter instructs the API to select a video chart available in the specified region. Choose from the list, or specify an ID using an expression.', + description: + 'The regionCode parameter instructs the API to select a video chart available in the specified region. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Related To Video ID', name: 'relatedToVideoId', type: 'string', default: '', - description: 'The relatedToVideoId parameter retrieves a list of videos that are related to the video that the parameter value identifies', + description: + 'The relatedToVideoId parameter retrieves a list of videos that are related to the video that the parameter value identifies', }, { displayName: 'Video Category ID', name: 'videoCategoryId', type: 'string', default: '', - description: 'The videoCategoryId parameter identifies the video category for which the chart should be retrieved', + description: + 'The videoCategoryId parameter identifies the video category for which the chart should be retrieved', }, { displayName: 'Video Syndicated', name: 'videoSyndicated', type: 'boolean', default: false, - description: 'Whether to restrict a search to only videos that can be played outside youtube.com', + description: + 'Whether to restrict a search to only videos that can be played outside youtube.com', }, { displayName: 'Video Type', @@ -566,7 +525,8 @@ export const videoFields: INodeProperties[] = [ }, ], default: '', - description: 'The videoType parameter lets you restrict a search to a particular type of videos', + description: + 'The videoType parameter lets you restrict a search to a particular type of videos', }, ], }, @@ -578,12 +538,8 @@ export const videoFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'video', - ], + operation: ['getAll'], + resource: ['video'], }, }, options: [ @@ -611,7 +567,8 @@ export const videoFields: INodeProperties[] = [ { name: 'Moderate', value: 'moderate', - description: 'YouTube will filter some content from search results and, at the least, will filter content that is restricted in your locale', + description: + 'YouTube will filter some content from search results and, at the least, will filter content that is restricted in your locale', }, { name: 'None', @@ -621,7 +578,8 @@ export const videoFields: INodeProperties[] = [ { name: 'Strict', value: 'strict', - description: 'YouTube will try to exclude all restricted content from the search result set', + description: + 'YouTube will try to exclude all restricted content from the search result set', }, ], default: '', @@ -638,12 +596,8 @@ export const videoFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'rate', - ], - resource: [ - 'video', - ], + operation: ['rate'], + resource: ['video'], }, }, default: '', @@ -654,12 +608,8 @@ export const videoFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - operation: [ - 'rate', - ], - resource: [ - 'video', - ], + operation: ['rate'], + resource: ['video'], }, }, options: [ @@ -676,7 +626,8 @@ export const videoFields: INodeProperties[] = [ { name: 'None', value: 'none', - description: 'Removes any rating that the authenticated user had previously set for the video', + description: + 'Removes any rating that the authenticated user had previously set for the video', }, ], default: '', @@ -691,12 +642,8 @@ export const videoFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'video', - ], + operation: ['update'], + resource: ['video'], }, }, default: '', @@ -708,12 +655,8 @@ export const videoFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'video', - ], + operation: ['update'], + resource: ['video'], }, }, default: '', @@ -723,18 +666,15 @@ export const videoFields: INodeProperties[] = [ displayName: 'Region Code', name: 'regionCode', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCountriesCodes', }, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'video', - ], + operation: ['update'], + resource: ['video'], }, }, default: '', @@ -743,21 +683,16 @@ export const videoFields: INodeProperties[] = [ displayName: 'Category Name or ID', name: 'categoryId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getVideoCategories', - loadOptionsDependsOn: [ - 'regionCode', - ], + loadOptionsDependsOn: ['regionCode'], }, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'video', - ], + operation: ['update'], + resource: ['video'], }, }, default: '', @@ -770,12 +705,8 @@ export const videoFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'video', - ], + operation: ['update'], + resource: ['video'], }, }, options: [ @@ -787,14 +718,15 @@ export const videoFields: INodeProperties[] = [ loadOptionsMethod: 'getLanguages', }, default: '', - description: 'The language of the text in the playlist resource\'s title and description properties. Choose from the list, or specify an ID using an expression.', + description: + 'The language of the text in the playlist resource\'s title and description properties. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Description', name: 'description', type: 'string', default: '', - description: 'The playlist\'s description', + description: "The playlist's description", }, { displayName: 'Embeddable', @@ -818,14 +750,15 @@ export const videoFields: INodeProperties[] = [ }, ], default: '', - description: 'The video\'s license', + description: "The video's license", }, { displayName: 'Notify Subscribers', name: 'notifySubscribers', type: 'boolean', default: false, - description: 'Whether YouTube should send a notification about the new video to users who subscribe to the video\'s channel', + description: + "Whether YouTube should send a notification about the new video to users who subscribe to the video's channel", }, { displayName: 'Privacy Status', @@ -846,21 +779,23 @@ export const videoFields: INodeProperties[] = [ }, ], default: '', - description: 'The playlist\'s privacy status', + description: "The playlist's privacy status", }, { displayName: 'Public Stats Viewable', name: 'publicStatsViewable', type: 'boolean', default: true, - description: 'Whether the extended video statistics on the video\'s watch page are publicly viewable', + description: + "Whether the extended video statistics on the video's watch page are publicly viewable", }, { displayName: 'Publish At', name: 'publishAt', type: 'dateTime', default: '', - description: 'If you set a value for this property, you must also set the status.privacyStatus property to private', + description: + 'If you set a value for this property, you must also set the status.privacyStatus property to private', }, { displayName: 'Recording Date', @@ -874,14 +809,16 @@ export const videoFields: INodeProperties[] = [ name: 'selfDeclaredMadeForKids', type: 'boolean', default: false, - description: 'Whether the video is designated as child-directed, and it contains the current "made for kids" status of the video', + description: + 'Whether the video is designated as child-directed, and it contains the current "made for kids" status of the video', }, { displayName: 'Tags', name: 'tags', type: 'string', default: '', - description: 'Keyword tags associated with the playlist. Mulplie can be defined separated by comma.', + description: + 'Keyword tags associated with the playlist. Mulplie can be defined separated by comma.', }, ], }, diff --git a/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts b/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts index 47a549814e..bc39c572a9 100644 --- a/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts +++ b/packages/nodes-base/nodes/Google/YouTube/YouTube.node.ts @@ -10,39 +10,19 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - googleApiRequest, - googleApiRequestAllItems, -} from './GenericFunctions'; +import { googleApiRequest, googleApiRequestAllItems } from './GenericFunctions'; -import { - channelFields, - channelOperations, -} from './ChannelDescription'; +import { channelFields, channelOperations } from './ChannelDescription'; -import { - playlistFields, - playlistOperations, -} from './PlaylistDescription'; +import { playlistFields, playlistOperations } from './PlaylistDescription'; -import { - playlistItemFields, - playlistItemOperations, -} from './PlaylistItemDescription'; +import { playlistItemFields, playlistItemOperations } from './PlaylistItemDescription'; -import { - videoFields, - videoOperations, -} from './VideoDescription'; +import { videoFields, videoOperations } from './VideoDescription'; -import { - videoCategoryFields, - videoCategoryOperations, -} from './VideoCategoryDescription'; +import { videoCategoryFields, videoCategoryOperations } from './VideoCategoryDescription'; -import { - countriesCodes, -} from './CountryCodes'; +import { countriesCodes } from './CountryCodes'; export class YouTube implements INodeType { description: INodeTypeDescription = { @@ -116,9 +96,7 @@ export class YouTube implements INodeType { loadOptions: { // Get all the languages to display them to user so that he can // select them easily - async getLanguages( - this: ILoadOptionsFunctions, - ): Promise { + async getLanguages(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const languages = await googleApiRequestAllItems.call( this, @@ -152,9 +130,7 @@ export class YouTube implements INodeType { }, // Get all the video categories to display them to user so that he can // select them easily - async getVideoCategories( - this: ILoadOptionsFunctions, - ): Promise { + async getVideoCategories(this: ILoadOptionsFunctions): Promise { const countryCode = this.getCurrentNodeParameter('regionCode') as string; const returnData: INodePropertyOptions[] = []; @@ -181,9 +157,7 @@ export class YouTube implements INodeType { }, // Get all the playlists to display them to user so that he can // select them easily - async getPlaylists( - this: ILoadOptionsFunctions, - ): Promise { + async getPlaylists(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const qs: IDataObject = {}; qs.part = 'snippet'; @@ -243,13 +217,7 @@ export class YouTube implements INodeType { qs.id = channelId; - responseData = await googleApiRequest.call( - this, - 'GET', - `/youtube/v3/channels`, - {}, - qs, - ); + responseData = await googleApiRequest.call(this, 'GET', `/youtube/v3/channels`, {}, qs); responseData = responseData.items; } @@ -325,7 +293,8 @@ export class YouTube implements INodeType { } if (updateFields.brandingSettingsUi) { - const channelSettingsValues = (updateFields.brandingSettingsUi as IDataObject).channelSettingsValues as IDataObject | undefined; + const channelSettingsValues = (updateFields.brandingSettingsUi as IDataObject) + .channelSettingsValues as IDataObject | undefined; const channelSettings: IDataObject = {}; if (channelSettingsValues?.channel) { const channelSettingsOptions = channelSettingsValues.channel as IDataObject; @@ -342,16 +311,19 @@ export class YouTube implements INodeType { channelSettings.defaultTab = channelSettingsOptions.defaultTab; } if (channelSettingsOptions.featuredChannelsTitle) { - channelSettings.featuredChannelsTitle = channelSettingsOptions.featuredChannelsTitle; + channelSettings.featuredChannelsTitle = + channelSettingsOptions.featuredChannelsTitle; } if (channelSettingsOptions.featuredChannelsUrls) { - channelSettings.featuredChannelsUrls = channelSettingsOptions.featuredChannelsUrls; + channelSettings.featuredChannelsUrls = + channelSettingsOptions.featuredChannelsUrls; } if (channelSettingsOptions.keywords) { channelSettings.keywords = channelSettingsOptions.keywords; } if (channelSettingsOptions.moderateComments) { - channelSettings.moderateComments = channelSettingsOptions.moderateComments as boolean; + channelSettings.moderateComments = + channelSettingsOptions.moderateComments as boolean; } if (channelSettingsOptions.profileColor) { channelSettings.profileColor = channelSettingsOptions.profileColor as string; @@ -360,31 +332,37 @@ export class YouTube implements INodeType { channelSettings.profileColor = channelSettingsOptions.profileColor as string; } if (channelSettingsOptions.showRelatedChannels) { - channelSettings.showRelatedChannels = channelSettingsOptions.showRelatedChannels as boolean; + channelSettings.showRelatedChannels = + channelSettingsOptions.showRelatedChannels as boolean; } if (channelSettingsOptions.showBrowseView) { channelSettings.showBrowseView = channelSettingsOptions.showBrowseView as boolean; } if (channelSettingsOptions.trackingAnalyticsAccountId) { - channelSettings.trackingAnalyticsAccountId = channelSettingsOptions.trackingAnalyticsAccountId as string; + channelSettings.trackingAnalyticsAccountId = + channelSettingsOptions.trackingAnalyticsAccountId as string; } if (channelSettingsOptions.unsubscribedTrailer) { - channelSettings.unsubscribedTrailer = channelSettingsOptions.unsubscribedTrailer as string; + channelSettings.unsubscribedTrailer = + channelSettingsOptions.unsubscribedTrailer as string; } } - const imageSettingsValues = (updateFields.brandingSettingsUi as IDataObject).imageSettingsValues as IDataObject | undefined; + const imageSettingsValues = (updateFields.brandingSettingsUi as IDataObject) + .imageSettingsValues as IDataObject | undefined; const imageSettings: IDataObject = {}; if (imageSettingsValues?.image) { const imageSettingsOptions = imageSettings.image as IDataObject; if (imageSettingsOptions.bannerExternalUrl) { - imageSettings.bannerExternalUrl = imageSettingsOptions.bannerExternalUrl as string; + imageSettings.bannerExternalUrl = + imageSettingsOptions.bannerExternalUrl as string; } if (imageSettingsOptions.trackingImageUrl) { imageSettings.trackingImageUrl = imageSettingsOptions.trackingImageUrl as string; } if (imageSettingsOptions.watchIconImageUrl) { - imageSettings.watchIconImageUrl = imageSettingsOptions.watchIconImageUrl as string; + imageSettings.watchIconImageUrl = + imageSettingsOptions.watchIconImageUrl as string; } } @@ -413,11 +391,17 @@ export class YouTube implements INodeType { const item = items[i]; if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } if (item.binary[binaryProperty] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryProperty}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryProperty}" does not exists on item!`, + { itemIndex: i }, + ); } if (item.binary[binaryProperty].mimeType) { @@ -433,7 +417,15 @@ export class YouTube implements INodeType { json: false, }; - const response = await googleApiRequest.call(this, 'POST', '/upload/youtube/v3/channelBanners/insert', body, qs, undefined, requestOptions); + const response = await googleApiRequest.call( + this, + 'POST', + '/upload/youtube/v3/channelBanners/insert', + body, + qs, + undefined, + requestOptions, + ); const { url } = JSON.parse(response); @@ -463,14 +455,7 @@ export class YouTube implements INodeType { const options = this.getNodeParameter('options', i) as IDataObject; if (part.includes('*')) { - part = [ - 'contentDetails', - 'id', - 'localizations', - 'player', - 'snippet', - 'status', - ]; + part = ['contentDetails', 'id', 'localizations', 'player', 'snippet', 'status']; } qs.part = part.join(','); @@ -497,14 +482,7 @@ export class YouTube implements INodeType { const filters = this.getNodeParameter('filters', i) as IDataObject; if (part.includes('*')) { - part = [ - 'contentDetails', - 'id', - 'localizations', - 'player', - 'snippet', - 'status', - ]; + part = ['contentDetails', 'id', 'localizations', 'player', 'snippet', 'status']; } qs.part = part.join(','); @@ -595,8 +573,7 @@ export class YouTube implements INodeType { snippet: { title, }, - status: { - }, + status: {}, }; if (updateFields.tags) { @@ -662,12 +639,7 @@ export class YouTube implements INodeType { const options = this.getNodeParameter('options', i) as IDataObject; if (part.includes('*')) { - part = [ - 'contentDetails', - 'id', - 'snippet', - 'status', - ]; + part = ['contentDetails', 'id', 'snippet', 'status']; } qs.part = part.join(','); @@ -695,12 +667,7 @@ export class YouTube implements INodeType { //const filters = this.getNodeParameter('filters', i) as IDataObject; if (part.includes('*')) { - part = [ - 'contentDetails', - 'id', - 'snippet', - 'status', - ]; + part = ['contentDetails', 'id', 'snippet', 'status']; } qs.playlistId = playlistId; @@ -746,9 +713,7 @@ export class YouTube implements INodeType { videoId, }, }, - contentDetails: { - }, - + contentDetails: {}, }; if (options.position) { @@ -826,7 +791,11 @@ export class YouTube implements INodeType { } if (qs.relatedToVideoId && qs.forDeveloper !== undefined) { - throw new NodeOperationError(this.getNode(), `When using the parameter 'related to video' the parameter 'for developer' cannot be set`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `When using the parameter 'related to video' the parameter 'for developer' cannot be set`, + { itemIndex: i }, + ); } if (returnAll) { @@ -840,13 +809,7 @@ export class YouTube implements INodeType { ); } else { qs.maxResults = this.getNodeParameter('limit', i) as number; - responseData = await googleApiRequest.call( - this, - 'GET', - `/youtube/v3/search`, - {}, - qs, - ); + responseData = await googleApiRequest.call(this, 'GET', `/youtube/v3/search`, {}, qs); responseData = responseData.items; } } @@ -877,13 +840,7 @@ export class YouTube implements INodeType { Object.assign(qs, options); - responseData = await googleApiRequest.call( - this, - 'GET', - `/youtube/v3/videos`, - {}, - qs, - ); + responseData = await googleApiRequest.call(this, 'GET', `/youtube/v3/videos`, {}, qs); responseData = responseData.items; } @@ -900,11 +857,17 @@ export class YouTube implements INodeType { const item = items[i]; if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } if (item.binary[binaryProperty] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryProperty}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryProperty}" does not exists on item!`, + { itemIndex: i }, + ); } if (item.binary[binaryProperty].mimeType) { @@ -920,7 +883,15 @@ export class YouTube implements INodeType { json: false, }; - const response = await googleApiRequest.call(this, 'POST', '/upload/youtube/v3/videos', body, qs, undefined, requestOptions); + const response = await googleApiRequest.call( + this, + 'POST', + '/upload/youtube/v3/videos', + body, + qs, + undefined, + requestOptions, + ); const { id } = JSON.parse(response); @@ -932,10 +903,8 @@ export class YouTube implements INodeType { title, categoryId, }, - status: { - }, - recordingDetails: { - }, + status: {}, + recordingDetails: {}, }; if (options.description) { @@ -993,13 +962,7 @@ export class YouTube implements INodeType { delete options.notifySubscribers; } - responseData = await googleApiRequest.call( - this, - 'PUT', - `/youtube/v3/videos`, - data, - qs, - ); + responseData = await googleApiRequest.call(this, 'PUT', `/youtube/v3/videos`, data, qs); } //https://developers.google.com/youtube/v3/docs/playlists/update if (operation === 'update') { @@ -1016,10 +979,8 @@ export class YouTube implements INodeType { title, categoryId, }, - status: { - }, - recordingDetails: { - }, + status: {}, + recordingDetails: {}, }; if (updateFields.description) { @@ -1072,13 +1033,7 @@ export class YouTube implements INodeType { body.snippet.defaultLanguage = updateFields.defaultLanguage as string; } - responseData = await googleApiRequest.call( - this, - 'PUT', - '/youtube/v3/videos', - body, - qs, - ); + responseData = await googleApiRequest.call(this, 'PUT', '/youtube/v3/videos', body, qs); } //https://developers.google.com/youtube/v3/docs/videos/delete?hl=en if (operation === 'delete') { @@ -1093,12 +1048,7 @@ export class YouTube implements INodeType { qs.onBehalfOfContentOwner = options.onBehalfOfContentOwner as string; } - responseData = await googleApiRequest.call( - this, - 'DELETE', - '/youtube/v3/videos', - body, - ); + responseData = await googleApiRequest.call(this, 'DELETE', '/youtube/v3/videos', body); responseData = { success: true }; } diff --git a/packages/nodes-base/nodes/Gotify/GenericFunctions.ts b/packages/nodes-base/nodes/Gotify/GenericFunctions.ts index e13bfcfd28..0325aea550 100644 --- a/packages/nodes-base/nodes/Gotify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Gotify/GenericFunctions.ts @@ -1,25 +1,26 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; - -export async function gotifyApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, uri?: string | undefined, option = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError } from 'n8n-workflow'; +export async function gotifyApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + path: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string | undefined, + option = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('gotifyApi'); const options: OptionsWithUri = { method, headers: { - 'X-Gotify-Key': (method === 'POST') ? credentials.appApiToken : credentials.clientApiToken, + 'X-Gotify-Key': method === 'POST' ? credentials.appApiToken : credentials.clientApiToken, accept: 'application/json', }, body, @@ -39,8 +40,16 @@ export async function gotifyApiRequest(this: IExecuteFunctions | IExecuteSingleF } } -export async function gotifyApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function gotifyApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -52,9 +61,7 @@ export async function gotifyApiRequestAllItems(this: IExecuteFunctions | ILoadOp uri = responseData.paging.next; } returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData.paging.next - ); + } while (responseData.paging.next); return returnData; } diff --git a/packages/nodes-base/nodes/Gotify/Gotify.node.ts b/packages/nodes-base/nodes/Gotify/Gotify.node.ts index 62324d0901..d8224dd451 100644 --- a/packages/nodes-base/nodes/Gotify/Gotify.node.ts +++ b/packages/nodes-base/nodes/Gotify/Gotify.node.ts @@ -1,18 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - gotifyApiRequest, - gotifyApiRequestAllItems, -} from './GenericFunctions'; +import { gotifyApiRequest, gotifyApiRequestAllItems } from './GenericFunctions'; export class Gotify implements INodeType { description: INodeTypeDescription = { @@ -56,9 +46,7 @@ export class Gotify implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'message', - ], + resource: ['message'], }, }, options: [ @@ -87,12 +75,8 @@ export class Gotify implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], + resource: ['message'], + operation: ['create'], }, }, default: '', @@ -105,12 +89,8 @@ export class Gotify implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], + resource: ['message'], + operation: ['create'], }, }, default: {}, @@ -138,12 +118,8 @@ export class Gotify implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'delete', - ], + resource: ['message'], + operation: ['delete'], }, }, default: '', @@ -154,12 +130,8 @@ export class Gotify implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'getAll', - ], + resource: ['message'], + operation: ['getAll'], }, }, default: false, @@ -176,15 +148,9 @@ export class Gotify implements INodeType { default: 20, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['message'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -203,7 +169,6 @@ export class Gotify implements INodeType { try { if (resource === 'message') { if (operation === 'create') { - const message = this.getNodeParameter('message', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; @@ -214,21 +179,12 @@ export class Gotify implements INodeType { Object.assign(body, additionalFields); - responseData = await gotifyApiRequest.call( - this, - 'POST', - `/message`, - body, - ); + responseData = await gotifyApiRequest.call(this, 'POST', `/message`, body); } if (operation === 'delete') { const messageId = this.getNodeParameter('messageId', i) as string; - responseData = await gotifyApiRequest.call( - this, - 'DELETE', - `/message/${messageId}`, - ); + responseData = await gotifyApiRequest.call(this, 'DELETE', `/message/${messageId}`); responseData = { success: true }; } @@ -244,16 +200,9 @@ export class Gotify implements INodeType { {}, qs, ); - } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await gotifyApiRequest.call( - this, - 'GET', - `/message`, - {}, - qs, - ); + responseData = await gotifyApiRequest.call(this, 'GET', `/message`, {}, qs); responseData = responseData.messages; } } diff --git a/packages/nodes-base/nodes/Grafana/GenericFunctions.ts b/packages/nodes-base/nodes/Grafana/GenericFunctions.ts index 599c2e33ac..464d2dab9b 100644 --- a/packages/nodes-base/nodes/Grafana/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Grafana/GenericFunctions.ts @@ -1,21 +1,10 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - ILoadOptionsFunctions, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, ILoadOptionsFunctions, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - GrafanaCredentials, -} from './types'; +import { GrafanaCredentials } from './types'; export async function grafanaApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, @@ -24,9 +13,7 @@ export async function grafanaApiRequest( body: IDataObject = {}, qs: IDataObject = {}, ) { - const { - baseUrl: rawBaseUrl, - } = await this.getCredentials('grafanaApi') as GrafanaCredentials; + const { baseUrl: rawBaseUrl } = (await this.getCredentials('grafanaApi')) as GrafanaCredentials; const baseUrl = tolerateTrailingSlash(rawBaseUrl); @@ -60,8 +47,12 @@ export async function grafanaApiRequest( error.response.data.message += ' with the provided ID'; } - if (error?.response?.data?.message === 'A dashboard with the same name in the folder already exists') { - error.response.data.message = 'A dashboard with the same name already exists in the selected folder'; + if ( + error?.response?.data?.message === + 'A dashboard with the same name in the folder already exists' + ) { + error.response.data.message = + 'A dashboard with the same name already exists in the selected folder'; } if (error?.response?.data?.message === 'Team name taken') { @@ -69,7 +60,8 @@ export async function grafanaApiRequest( } if (error?.code === 'ECONNREFUSED') { - error.message = 'Invalid credentials or error in establishing connection with given credentials'; + error.message = + 'Invalid credentials or error in establishing connection with given credentials'; } throw new NodeApiError(this.getNode(), error); @@ -90,9 +82,7 @@ export function throwOnEmptyUpdate( } export function tolerateTrailingSlash(baseUrl: string) { - return baseUrl.endsWith('/') - ? baseUrl.substr(0, baseUrl.length - 1) - : baseUrl; + return baseUrl.endsWith('/') ? baseUrl.substr(0, baseUrl.length - 1) : baseUrl; } export function deriveUid(this: IExecuteFunctions, uidOrUrl: string) { diff --git a/packages/nodes-base/nodes/Grafana/Grafana.node.ts b/packages/nodes-base/nodes/Grafana/Grafana.node.ts index c800b8cbf2..a7868e0847 100644 --- a/packages/nodes-base/nodes/Grafana/Grafana.node.ts +++ b/packages/nodes-base/nodes/Grafana/Grafana.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -15,11 +13,7 @@ import { NodeApiError, } from 'n8n-workflow'; -import { - deriveUid, - grafanaApiRequest, - throwOnEmptyUpdate, -} from './GenericFunctions'; +import { deriveUid, grafanaApiRequest, throwOnEmptyUpdate } from './GenericFunctions'; import { dashboardFields, @@ -101,24 +95,28 @@ export class Grafana implements INodeType { methods = { loadOptions: { async getDashboards(this: ILoadOptionsFunctions): Promise { - const dashboards = await grafanaApiRequest.call( - this, 'GET', '/search', {}, { qs: 'dash-db' }, - ) as LoadedDashboards; + const dashboards = (await grafanaApiRequest.call( + this, + 'GET', + '/search', + {}, + { qs: 'dash-db' }, + )) as LoadedDashboards; return dashboards.map(({ id, title }) => ({ value: id, name: title })); }, async getFolders(this: ILoadOptionsFunctions): Promise { - const folders = await grafanaApiRequest.call(this, 'GET', '/folders') as LoadedFolders; + const folders = (await grafanaApiRequest.call(this, 'GET', '/folders')) as LoadedFolders; return folders.map(({ id, title }) => ({ value: id, name: title })); }, async getTeams(this: ILoadOptionsFunctions): Promise { - const res = await grafanaApiRequest.call(this, 'GET', '/teams/search') as LoadedTeams; + const res = (await grafanaApiRequest.call(this, 'GET', '/teams/search')) as LoadedTeams; return res.teams.map(({ id, name }) => ({ value: id, name })); }, async getUsers(this: ILoadOptionsFunctions): Promise { - const users = await grafanaApiRequest.call(this, 'GET', '/org/users') as LoadedUsers; + const users = (await grafanaApiRequest.call(this, 'GET', '/org/users')) as LoadedUsers; return users.map(({ userId, email }) => ({ value: userId, name: email })); }, }, @@ -134,17 +132,13 @@ export class Grafana implements INodeType { let responseData; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'dashboard') { - // ********************************************************************** // dashboard // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // dashboard: create // ---------------------------------------- @@ -167,9 +161,7 @@ export class Grafana implements INodeType { } responseData = await grafanaApiRequest.call(this, 'POST', '/dashboards/db', body); - } else if (operation === 'delete') { - // ---------------------------------------- // dashboard: delete // ---------------------------------------- @@ -180,9 +172,7 @@ export class Grafana implements INodeType { const uid = deriveUid.call(this, uidOrUrl); const endpoint = `/dashboards/uid/${uid}`; responseData = await grafanaApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // dashboard: get // ---------------------------------------- @@ -193,9 +183,7 @@ export class Grafana implements INodeType { const uid = deriveUid.call(this, uidOrUrl); const endpoint = `/dashboards/uid/${uid}`; responseData = await grafanaApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // dashboard: getAll // ---------------------------------------- @@ -220,9 +208,7 @@ export class Grafana implements INodeType { } responseData = await grafanaApiRequest.call(this, 'GET', '/search', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // dashboard: update // ---------------------------------------- @@ -247,17 +233,22 @@ export class Grafana implements INodeType { const { title, ...rest } = updateFields; if (!title) { - const { dashboard } = await grafanaApiRequest.call(this, 'GET', `/dashboards/uid/${uid}`); + const { dashboard } = await grafanaApiRequest.call( + this, + 'GET', + `/dashboards/uid/${uid}`, + ); body.dashboard.title = dashboard.title; } else { - const dashboards = await grafanaApiRequest.call(this, 'GET', '/search') as Array<{ title: string }>; + const dashboards = (await grafanaApiRequest.call(this, 'GET', '/search')) as Array<{ + title: string; + }>; const titles = dashboards.map(({ title }) => title); if (titles.includes(title)) { - throw new NodeApiError( - this.getNode(), - { message: 'A dashboard with the same name already exists in the selected folder' }, - ); + throw new NodeApiError(this.getNode(), { + message: 'A dashboard with the same name already exists in the selected folder', + }); } body.dashboard.title = title; @@ -273,17 +264,13 @@ export class Grafana implements INodeType { } responseData = await grafanaApiRequest.call(this, 'POST', '/dashboards/db', body); - } - } else if (resource === 'team') { - // ********************************************************************** // team // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // team: create // ---------------------------------------- @@ -301,9 +288,7 @@ export class Grafana implements INodeType { } responseData = await grafanaApiRequest.call(this, 'POST', '/teams', body); - } else if (operation === 'delete') { - // ---------------------------------------- // team: delete // ---------------------------------------- @@ -312,9 +297,7 @@ export class Grafana implements INodeType { const teamId = this.getNodeParameter('teamId', i); responseData = await grafanaApiRequest.call(this, 'DELETE', `/teams/${teamId}`); - } else if (operation === 'get') { - // ---------------------------------------- // team: get // ---------------------------------------- @@ -323,9 +306,7 @@ export class Grafana implements INodeType { const teamId = this.getNodeParameter('teamId', i); responseData = await grafanaApiRequest.call(this, 'GET', `/teams/${teamId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // team: getAll // ---------------------------------------- @@ -349,9 +330,7 @@ export class Grafana implements INodeType { const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); } - } else if (operation === 'update') { - // ---------------------------------------- // team: update // ---------------------------------------- @@ -366,7 +345,7 @@ export class Grafana implements INodeType { const teamId = this.getNodeParameter('teamId', i); - // check if team exists, since API does not specify update failure reason + // check if team exists, since API does not specify update failure reason await grafanaApiRequest.call(this, 'GET', `/teams/${teamId}`); // prevent email from being overridden to empty @@ -380,17 +359,13 @@ export class Grafana implements INodeType { } responseData = await grafanaApiRequest.call(this, 'PUT', `/teams/${teamId}`, body); - } - } else if (resource === 'teamMember') { - // ********************************************************************** // teamMember // ********************************************************************** if (operation === 'add') { - // ---------------------------------------- // teamMember: add // ---------------------------------------- @@ -406,9 +381,7 @@ export class Grafana implements INodeType { const teamId = this.getNodeParameter('teamId', i); const endpoint = `/teams/${teamId}/members`; responseData = await grafanaApiRequest.call(this, 'POST', endpoint, body); - } else if (operation === 'remove') { - // ---------------------------------------- // teamMember: remove // ---------------------------------------- @@ -419,9 +392,7 @@ export class Grafana implements INodeType { const memberId = this.getNodeParameter('memberId', i); const endpoint = `/teams/${teamId}/members/${memberId}`; responseData = await grafanaApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // teamMember: getAll // ---------------------------------------- @@ -442,17 +413,13 @@ export class Grafana implements INodeType { const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); } - } - } else if (resource === 'user') { - // ********************************************************************** // user // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // user: create // ---------------------------------------- @@ -465,9 +432,7 @@ export class Grafana implements INodeType { }; responseData = await grafanaApiRequest.call(this, 'POST', '/org/users', body); - } else if (operation === 'delete') { - // ---------------------------------------- // user: delete // ---------------------------------------- @@ -476,9 +441,7 @@ export class Grafana implements INodeType { const userId = this.getNodeParameter('userId', i); responseData = await grafanaApiRequest.call(this, 'DELETE', `/org/users/${userId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // user: getAll // ---------------------------------------- @@ -493,9 +456,7 @@ export class Grafana implements INodeType { const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); } - } else if (operation === 'update') { - // ---------------------------------------- // user: update // ---------------------------------------- @@ -512,16 +473,18 @@ export class Grafana implements INodeType { } const userId = this.getNodeParameter('userId', i) as string; - responseData = await grafanaApiRequest.call(this, 'PATCH', `/org/users/${userId}`, body); - + responseData = await grafanaApiRequest.call( + this, + 'PATCH', + `/org/users/${userId}`, + body, + ); } - } Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -529,7 +492,6 @@ export class Grafana implements INodeType { } throw error; } - } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Grafana/descriptions/DashboardDescription.ts b/packages/nodes-base/nodes/Grafana/descriptions/DashboardDescription.ts index 5164ffcd2a..5f3e88f8ac 100644 --- a/packages/nodes-base/nodes/Grafana/descriptions/DashboardDescription.ts +++ b/packages/nodes-base/nodes/Grafana/descriptions/DashboardDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const dashboardOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const dashboardOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'dashboard', - ], + resource: ['dashboard'], }, }, options: [ @@ -61,12 +57,8 @@ export const dashboardFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'dashboard', - ], - operation: [ - 'create', - ], + resource: ['dashboard'], + operation: ['create'], }, }, }, @@ -78,12 +70,8 @@ export const dashboardFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'dashboard', - ], - operation: [ - 'create', - ], + resource: ['dashboard'], + operation: ['create'], }, }, options: [ @@ -92,7 +80,8 @@ export const dashboardFields: INodeProperties[] = [ name: 'folderId', type: 'options', default: '', - description: 'Folder to create the dashboard in - if the folder is unspecified, the dashboard will be saved to the General folder. Choose from the list, or specify an ID using an expression.', + description: + 'Folder to create the dashboard in - if the folder is unspecified, the dashboard will be saved to the General folder. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getFolders', }, @@ -112,12 +101,8 @@ export const dashboardFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'dashboard', - ], - operation: [ - 'delete', - ], + resource: ['dashboard'], + operation: ['delete'], }, }, }, @@ -135,12 +120,8 @@ export const dashboardFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'dashboard', - ], - operation: [ - 'get', - ], + resource: ['dashboard'], + operation: ['get'], }, }, }, @@ -156,12 +137,8 @@ export const dashboardFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'dashboard', - ], - operation: [ - 'getAll', - ], + resource: ['dashboard'], + operation: ['getAll'], }, }, }, @@ -177,15 +154,9 @@ export const dashboardFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'dashboard', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['dashboard'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -197,12 +168,8 @@ export const dashboardFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'dashboard', - ], - operation: [ - 'getAll', - ], + resource: ['dashboard'], + operation: ['getAll'], }, }, options: [ @@ -228,12 +195,8 @@ export const dashboardFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'dashboard', - ], - operation: [ - 'update', - ], + resource: ['dashboard'], + operation: ['update'], }, }, }, @@ -245,12 +208,8 @@ export const dashboardFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'dashboard', - ], - operation: [ - 'update', - ], + resource: ['dashboard'], + operation: ['update'], }, }, options: [ @@ -259,7 +218,8 @@ export const dashboardFields: INodeProperties[] = [ name: 'folderId', type: 'options', default: '', - description: 'Folder to move the dashboard into - if the folder is unspecified, the dashboard will be saved to the General folder. Choose from the list, or specify an ID using an expression.', + description: + 'Folder to move the dashboard into - if the folder is unspecified, the dashboard will be saved to the General folder. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getFolders', }, diff --git a/packages/nodes-base/nodes/Grafana/descriptions/TeamDescription.ts b/packages/nodes-base/nodes/Grafana/descriptions/TeamDescription.ts index eb71692cb3..75612cecde 100644 --- a/packages/nodes-base/nodes/Grafana/descriptions/TeamDescription.ts +++ b/packages/nodes-base/nodes/Grafana/descriptions/TeamDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const teamOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const teamOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'team', - ], + resource: ['team'], }, }, options: [ @@ -65,12 +61,8 @@ export const teamFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'create', - ], + resource: ['team'], + operation: ['create'], }, }, }, @@ -82,12 +74,8 @@ export const teamFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'create', - ], + resource: ['team'], + operation: ['create'], }, }, options: [ @@ -114,12 +102,8 @@ export const teamFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'delete', - ], + resource: ['team'], + operation: ['delete'], }, }, }, @@ -136,12 +120,8 @@ export const teamFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'get', - ], + resource: ['team'], + operation: ['get'], }, }, }, @@ -157,12 +137,8 @@ export const teamFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'getAll', - ], + resource: ['team'], + operation: ['getAll'], }, }, }, @@ -177,15 +153,9 @@ export const teamFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['team'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -197,12 +167,8 @@ export const teamFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'getAll', - ], + resource: ['team'], + operation: ['getAll'], }, }, options: [ @@ -228,12 +194,8 @@ export const teamFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'update', - ], + resource: ['team'], + operation: ['update'], }, }, }, @@ -245,12 +207,8 @@ export const teamFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'update', - ], + resource: ['team'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Grafana/descriptions/TeamMemberDescription.ts b/packages/nodes-base/nodes/Grafana/descriptions/TeamMemberDescription.ts index e216041dc4..26cefdfa46 100644 --- a/packages/nodes-base/nodes/Grafana/descriptions/TeamMemberDescription.ts +++ b/packages/nodes-base/nodes/Grafana/descriptions/TeamMemberDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const teamMemberOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const teamMemberOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'teamMember', - ], + resource: ['teamMember'], }, }, options: [ @@ -46,7 +42,8 @@ export const teamMemberFields: INodeProperties[] = [ { displayName: 'User Name or ID', name: 'userId', - description: 'User to add to a team. Choose from the list, or specify an ID using an expression.', + description: + 'User to add to a team. Choose from the list, or specify an ID using an expression.', type: 'options', required: true, default: '', @@ -55,19 +52,16 @@ export const teamMemberFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'teamMember', - ], - operation: [ - 'add', - ], + resource: ['teamMember'], + operation: ['add'], }, }, }, { displayName: 'Team Name or ID', name: 'teamId', - description: 'Team to add the user to. Choose from the list, or specify an ID using an expression.', + description: + 'Team to add the user to. Choose from the list, or specify an ID using an expression.', type: 'options', required: true, default: '', @@ -76,12 +70,8 @@ export const teamMemberFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'teamMember', - ], - operation: [ - 'add', - ], + resource: ['teamMember'], + operation: ['add'], }, }, }, @@ -92,7 +82,8 @@ export const teamMemberFields: INodeProperties[] = [ { displayName: 'User Name or ID', name: 'memberId', - description: 'User to remove from the team. Choose from the list, or specify an ID using an expression.', + description: + 'User to remove from the team. Choose from the list, or specify an ID using an expression.', type: 'options', required: true, default: '', @@ -101,19 +92,16 @@ export const teamMemberFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'teamMember', - ], - operation: [ - 'remove', - ], + resource: ['teamMember'], + operation: ['remove'], }, }, }, { displayName: 'Team Name or ID', name: 'teamId', - description: 'Team to remove the user from. Choose from the list, or specify an ID using an expression.', + description: + 'Team to remove the user from. Choose from the list, or specify an ID using an expression.', type: 'options', required: true, default: '', @@ -122,12 +110,8 @@ export const teamMemberFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'teamMember', - ], - operation: [ - 'remove', - ], + resource: ['teamMember'], + operation: ['remove'], }, }, }, @@ -138,7 +122,8 @@ export const teamMemberFields: INodeProperties[] = [ { displayName: 'Team Name or ID', name: 'teamId', - description: 'Team to retrieve all members from. Choose from the list, or specify an ID using an expression.', + description: + 'Team to retrieve all members from. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getTeams', }, @@ -147,12 +132,8 @@ export const teamMemberFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'teamMember', - ], - operation: [ - 'getAll', - ], + resource: ['teamMember'], + operation: ['getAll'], }, }, }, @@ -164,12 +145,8 @@ export const teamMemberFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'teamMember', - ], - operation: [ - 'getAll', - ], + resource: ['teamMember'], + operation: ['getAll'], }, }, }, @@ -184,15 +161,9 @@ export const teamMemberFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'teamMember', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['teamMember'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Grafana/descriptions/UserDescription.ts b/packages/nodes-base/nodes/Grafana/descriptions/UserDescription.ts index 81ab2e29be..74d0eac392 100644 --- a/packages/nodes-base/nodes/Grafana/descriptions/UserDescription.ts +++ b/packages/nodes-base/nodes/Grafana/descriptions/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -52,12 +48,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, }, @@ -69,12 +61,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, options: [ @@ -114,12 +102,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'delete', - ], + resource: ['user'], + operation: ['delete'], }, }, }, @@ -135,12 +119,8 @@ export const userFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, }, @@ -155,15 +135,9 @@ export const userFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['user'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Grafana/types.d.ts b/packages/nodes-base/nodes/Grafana/types.d.ts index d506d86f6e..02ea3c3e17 100644 --- a/packages/nodes-base/nodes/Grafana/types.d.ts +++ b/packages/nodes-base/nodes/Grafana/types.d.ts @@ -1,36 +1,36 @@ export type GrafanaCredentials = { - apiKey: string; - baseUrl: string; + apiKey: string; + baseUrl: string; }; export type DashboardUpdatePayload = { - overwrite: true, - dashboard: { - uid: string, - title?: string - } + overwrite: true; + dashboard: { + uid: string; + title?: string; + }; }; export type DashboardUpdateFields = { - title?: string; - folderId?: string; + title?: string; + folderId?: string; }; export type LoadedDashboards = Array<{ - id: number; - title: string; + id: number; + title: string; }>; export type LoadedFolders = LoadedDashboards; export type LoadedTeams = { - teams: Array<{ - id: number; - name: string; - }> + teams: Array<{ + id: number; + name: string; + }>; }; export type LoadedUsers = Array<{ - userId: number; - email: string; -}>; \ No newline at end of file + userId: number; + email: string; +}>; diff --git a/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts b/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts index 4b3fcd98ed..3648d0890f 100644 --- a/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts +++ b/packages/nodes-base/nodes/GraphQL/GraphQL.node.ts @@ -33,9 +33,7 @@ export class GraphQL implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'basicAuth', - ], + authentication: ['basicAuth'], }, }, }, @@ -44,9 +42,7 @@ export class GraphQL implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'digestAuth', - ], + authentication: ['digestAuth'], }, }, }, @@ -55,9 +51,7 @@ export class GraphQL implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'headerAuth', - ], + authentication: ['headerAuth'], }, }, }, @@ -66,9 +60,7 @@ export class GraphQL implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'queryAuth', - ], + authentication: ['queryAuth'], }, }, }, @@ -77,9 +69,7 @@ export class GraphQL implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth1', - ], + authentication: ['oAuth1'], }, }, }, @@ -88,9 +78,7 @@ export class GraphQL implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -165,7 +153,8 @@ export class GraphQL implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-ignore-ssl-issues - description: 'Whether to download the response even if SSL certificate validation is not possible', + description: + 'Whether to download the response even if SSL certificate validation is not possible', }, { displayName: 'Request Format', @@ -184,9 +173,7 @@ export class GraphQL implements INodeType { ], displayOptions: { show: { - requestMethod: [ - 'POST', - ], + requestMethod: ['POST'], }, }, default: 'graphql', @@ -208,12 +195,8 @@ export class GraphQL implements INodeType { description: 'Query variables', displayOptions: { show: { - requestFormat: [ - 'json', - ], - requestMethod: [ - 'POST', - ], + requestFormat: ['json'], + requestMethod: ['POST'], }, }, }, @@ -225,12 +208,8 @@ export class GraphQL implements INodeType { description: 'Name of operation to execute', displayOptions: { show: { - requestFormat: [ - 'json', - ], - requestMethod: [ - 'POST', - ], + requestFormat: ['json'], + requestMethod: ['POST'], }, }, }, @@ -259,9 +238,7 @@ export class GraphQL implements INodeType { required: true, displayOptions: { show: { - responseFormat: [ - 'string', - ], + responseFormat: ['string'], }, }, description: 'Name of the property to which to write the response data', @@ -304,9 +281,7 @@ export class GraphQL implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); let httpBasicAuth; let httpDigestAuth; @@ -317,36 +292,35 @@ export class GraphQL implements INodeType { try { httpBasicAuth = await this.getCredentials('httpBasicAuth'); - } catch(error) { + } catch (error) { // Do nothing } try { httpDigestAuth = await this.getCredentials('httpDigestAuth'); - } catch(error) { + } catch (error) { // Do nothing } try { httpHeaderAuth = await this.getCredentials('httpHeaderAuth'); - } catch(error) { + } catch (error) { // Do nothing } try { httpQueryAuth = await this.getCredentials('httpQueryAuth'); - } catch(error) { + } catch (error) { // Do nothing } try { oAuth1Api = await this.getCredentials('oAuth1Api'); - } catch(error) { + } catch (error) { // Do nothing } try { oAuth2Api = await this.getCredentials('oAuth2Api'); - } catch(error) { + } catch (error) { // Do nothing } - let requestOptions: OptionsWithUri & RequestPromiseOptions; const returnItems: INodeExecutionData[] = []; @@ -354,15 +328,22 @@ export class GraphQL implements INodeType { try { const requestMethod = this.getNodeParameter('requestMethod', itemIndex, 'POST') as string; const endpoint = this.getNodeParameter('endpoint', itemIndex, '') as string; - const requestFormat = this.getNodeParameter('requestFormat', itemIndex, 'graphql') as string; + const requestFormat = this.getNodeParameter( + 'requestFormat', + itemIndex, + 'graphql', + ) as string; const responseFormat = this.getNodeParameter('responseFormat', 0) as string; - const { parameter }: { parameter?: Array<{ name: string, value: string }> } = this - .getNodeParameter('headerParametersUi', itemIndex, {}) as IDataObject; - const headerParameters = (parameter || []).reduce((result, item) => ({ - ...result, - [item.name]: item.value, - }), {}); + const { parameter }: { parameter?: Array<{ name: string; value: string }> } = + this.getNodeParameter('headerParametersUi', itemIndex, {}) as IDataObject; + const headerParameters = (parameter || []).reduce( + (result, item) => ({ + ...result, + [item.name]: item.value, + }), + {}, + ); requestOptions = { headers: { @@ -372,7 +353,11 @@ export class GraphQL implements INodeType { method: requestMethod, uri: endpoint, simple: false, - rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false) as boolean, + rejectUnauthorized: !this.getNodeParameter( + 'allowUnauthorizedCerts', + itemIndex, + false, + ) as boolean, }; // Add credentials if any are set @@ -416,7 +401,14 @@ export class GraphQL implements INodeType { try { requestOptions.body.variables = JSON.parse(requestOptions.body.variables || '{}'); } catch (error) { - throw new NodeOperationError(this.getNode(), 'Using variables failed:\n' + requestOptions.body.variables + '\n\nWith error message:\n' + error, { itemIndex }); + throw new NodeOperationError( + this.getNode(), + 'Using variables failed:\n' + + requestOptions.body.variables + + '\n\nWith error message:\n' + + error, + { itemIndex }, + ); } } if (requestOptions.body.operationName === '') { @@ -433,7 +425,9 @@ export class GraphQL implements INodeType { if (oAuth1Api !== undefined) { response = await this.helpers.requestOAuth1.call(this, 'oAuth1Api', requestOptions); } else if (oAuth2Api !== undefined) { - response = await this.helpers.requestOAuth2.call(this, 'oAuth2Api', requestOptions, { tokenType: 'Bearer' }); + response = await this.helpers.requestOAuth2.call(this, 'oAuth2Api', requestOptions, { + tokenType: 'Bearer', + }); } else { response = await this.helpers.request(requestOptions); } @@ -450,12 +444,18 @@ export class GraphQL implements INodeType { try { response = JSON.parse(response); } catch (error) { - throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"', { itemIndex }); + throw new NodeOperationError( + this.getNode(), + 'Response body is not valid JSON. Change "Response Format" to "String"', + { itemIndex }, + ); } } if (response.errors) { - const message = response.errors?.map((error: IDataObject) => error.message).join(', ') || 'Unexpected error'; + const message = + response.errors?.map((error: IDataObject) => error.message).join(', ') || + 'Unexpected error'; throw new NodeApiError(this.getNode(), response.errors, { message }); } diff --git a/packages/nodes-base/nodes/Grist/GenericFunctions.ts b/packages/nodes-base/nodes/Grist/GenericFunctions.ts index 45aafc4df8..2abb3e0738 100644 --- a/packages/nodes-base/nodes/Grist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Grist/GenericFunctions.ts @@ -1,17 +1,8 @@ -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IDataObject, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; import { GristCredentials, @@ -27,16 +18,16 @@ export async function gristApiRequest( body: IDataObject | number[] = {}, qs: IDataObject = {}, ) { - const { - apiKey, - planType, - customSubdomain, - selfHostedUrl, - } = await this.getCredentials('gristApi') as GristCredentials; + const { apiKey, planType, customSubdomain, selfHostedUrl } = (await this.getCredentials( + 'gristApi', + )) as GristCredentials; - const gristapiurl = (planType === 'free') ? `https://docs.getgrist.com/api${endpoint}` : - (planType === 'paid') ? `https://${customSubdomain}.getgrist.com/api${endpoint}` : - `${selfHostedUrl}/api${endpoint}`; + const gristapiurl = + planType === 'free' + ? `https://docs.getgrist.com/api${endpoint}` + : planType === 'paid' + ? `https://${customSubdomain}.getgrist.com/api${endpoint}` + : `${selfHostedUrl}/api${endpoint}`; const options: OptionsWithUri = { headers: { @@ -74,7 +65,7 @@ export function parseSortProperties(sortProperties: GristSortProperties) { } export function parseFilterProperties(filterProperties: GristFilterProperties) { - return filterProperties.reduce<{ [key: string]: Array; }>((acc, cur) => { + return filterProperties.reduce<{ [key: string]: Array }>((acc, cur) => { acc[cur.field] = acc[cur.field] ?? []; const values = isNaN(Number(cur.values)) ? cur.values : Number(cur.values); acc[cur.field].push(values); @@ -83,7 +74,7 @@ export function parseFilterProperties(filterProperties: GristFilterProperties) { } export function parseDefinedFields(fieldsToSendProperties: GristDefinedFields) { - return fieldsToSendProperties.reduce<{ [key: string]: string; }>((acc, cur) => { + return fieldsToSendProperties.reduce<{ [key: string]: string }>((acc, cur) => { acc[cur.fieldId] = cur.fieldValue; return acc; }, {}); @@ -94,7 +85,8 @@ export function parseAutoMappedInputs( inputsToIgnore: string[], item: any, // tslint:disable-line:no-any ) { - return incomingKeys.reduce<{ [key: string]: any; }>((acc, curKey) => { // tslint:disable-line:no-any + // tslint:disable-next-line:no-any + return incomingKeys.reduce<{ [key: string]: any }>((acc, curKey) => { if (inputsToIgnore.includes(curKey)) return acc; acc = { ...acc, [curKey]: item[curKey] }; return acc; @@ -105,7 +97,7 @@ export function throwOnZeroDefinedFields(this: IExecuteFunctions, fields: GristD if (!fields?.length) { throw new NodeOperationError( this.getNode(), - 'No defined data found. Please specify the data to send in \'Fields to Send\'.', + "No defined data found. Please specify the data to send in 'Fields to Send'.", ); } } diff --git a/packages/nodes-base/nodes/Grist/Grist.node.ts b/packages/nodes-base/nodes/Grist/Grist.node.ts index d71427abab..91f30911d5 100644 --- a/packages/nodes-base/nodes/Grist/Grist.node.ts +++ b/packages/nodes-base/nodes/Grist/Grist.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -13,9 +11,7 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { gristApiRequest, @@ -26,9 +22,7 @@ import { throwOnZeroDefinedFields, } from './GenericFunctions'; -import { - operationFields, -} from './OperationDescription'; +import { operationFields } from './OperationDescription'; import { FieldsToSend, @@ -71,7 +65,7 @@ export class Grist implements INodeType { const tableId = this.getNodeParameter('tableId', 0) as string; const endpoint = `/docs/${docId}/tables/${tableId}/columns`; - const { columns } = await gristApiRequest.call(this, 'GET', endpoint) as GristColumns; + const { columns } = (await gristApiRequest.call(this, 'GET', endpoint)) as GristColumns; return columns.map(({ id }) => ({ name: id, value: id })); }, }, @@ -81,18 +75,17 @@ export class Grist implements INodeType { this: ICredentialTestFunctions, credential: ICredentialsDecrypted, ): Promise { - const { - apiKey, - planType, - customSubdomain, - selfHostedUrl, - } = credential.data as GristCredentials; + const { apiKey, planType, customSubdomain, selfHostedUrl } = + credential.data as GristCredentials; const endpoint = '/orgs'; - const gristapiurl = (planType === 'free') ? `https://docs.getgrist.com/api${endpoint}` : - (planType === 'paid') ? `https://${customSubdomain}.getgrist.com/api${endpoint}` : - `${selfHostedUrl}/api${endpoint}`; + const gristapiurl = + planType === 'free' + ? `https://docs.getgrist.com/api${endpoint}` + : planType === 'paid' + ? `https://${customSubdomain}.getgrist.com/api${endpoint}` + : `${selfHostedUrl}/api${endpoint}`; const options: OptionsWithUri = { headers: { @@ -128,11 +121,8 @@ export class Grist implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < items.length; i++) { - try { - if (operation === 'create') { - // ---------------------------------- // create // ---------------------------------- @@ -144,19 +134,15 @@ export class Grist implements INodeType { const dataToSend = this.getNodeParameter('dataToSend', 0) as SendingOptions; if (dataToSend === 'autoMapInputs') { - const incomingKeys = Object.keys(items[i].json); const rawInputsToIgnore = this.getNodeParameter('inputsToIgnore', i) as string; - const inputsToIgnore = rawInputsToIgnore.split(',').map(c => c.trim()); + const inputsToIgnore = rawInputsToIgnore.split(',').map((c) => c.trim()); const fields = parseAutoMappedInputs(incomingKeys, inputsToIgnore, items[i].json); body.records.push({ fields }); - } else if (dataToSend === 'defineInNode') { - const { properties } = this.getNodeParameter('fieldsToSend', i, []) as FieldsToSend; throwOnZeroDefinedFields.call(this, properties); body.records.push({ fields: parseDefinedFields(properties) }); - } const docId = this.getNodeParameter('docId', 0) as string; @@ -168,9 +154,7 @@ export class Grist implements INodeType { id: responseData.records[0].id, ...body.records[0].fields, }; - } else if (operation === 'delete') { - // ---------------------------------- // delete // ---------------------------------- @@ -182,13 +166,14 @@ export class Grist implements INodeType { const endpoint = `/docs/${docId}/tables/${tableId}/data/delete`; const rawRowIds = (this.getNodeParameter('rowId', i) as string).toString(); - const body = rawRowIds.split(',').map(c => c.trim()).map(Number); + const body = rawRowIds + .split(',') + .map((c) => c.trim()) + .map(Number); await gristApiRequest.call(this, 'POST', endpoint, body); responseData = { success: true }; - } else if (operation === 'update') { - // ---------------------------------- // update // ---------------------------------- @@ -201,20 +186,16 @@ export class Grist implements INodeType { const dataToSend = this.getNodeParameter('dataToSend', 0) as SendingOptions; if (dataToSend === 'autoMapInputs') { - const incomingKeys = Object.keys(items[i].json); const rawInputsToIgnore = this.getNodeParameter('inputsToIgnore', i) as string; - const inputsToIgnore = rawInputsToIgnore.split(',').map(c => c.trim()); + const inputsToIgnore = rawInputsToIgnore.split(',').map((c) => c.trim()); const fields = parseAutoMappedInputs(incomingKeys, inputsToIgnore, items[i].json); body.records.push({ id: Number(rowId), fields }); - } else if (dataToSend === 'defineInNode') { - const { properties } = this.getNodeParameter('fieldsToSend', i, []) as FieldsToSend; throwOnZeroDefinedFields.call(this, properties); const fields = parseDefinedFields(properties); body.records.push({ id: Number(rowId), fields }); - } const docId = this.getNodeParameter('docId', 0) as string; @@ -226,9 +207,7 @@ export class Grist implements INodeType { id: rowId, ...body.records[0].fields, }; - } else if (operation === 'getAll') { - // ---------------------------------- // getAll // ---------------------------------- @@ -247,7 +226,10 @@ export class Grist implements INodeType { qs.limit = this.getNodeParameter('limit', i) as number; } - const { sort, filter } = this.getNodeParameter('additionalOptions', i) as GristGetAllOptions; + const { sort, filter } = this.getNodeParameter( + 'additionalOptions', + i, + ) as GristGetAllOptions; if (sort?.sortProperties.length) { qs.sort = parseSortProperties(sort.sortProperties); @@ -263,7 +245,6 @@ export class Grist implements INodeType { return { id: data.id, ...(data.fields as object) }; }); } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/Grist/OperationDescription.ts b/packages/nodes-base/nodes/Grist/OperationDescription.ts index 82a435734e..749d8db867 100644 --- a/packages/nodes-base/nodes/Grist/OperationDescription.ts +++ b/packages/nodes-base/nodes/Grist/OperationDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const operationFields: INodeProperties[] = [ { @@ -47,7 +45,8 @@ export const operationFields: INodeProperties[] = [ type: 'string', default: '', required: true, - description: 'In your document, click your profile icon, then Document Settings, then copy the value under "This document\'s ID"', + description: + 'In your document, click your profile icon, then Document Settings, then copy the value under "This document\'s ID"', }, { displayName: 'Table ID', @@ -67,9 +66,7 @@ export const operationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], }, }, default: '', @@ -88,9 +85,7 @@ export const operationFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, }, @@ -105,12 +100,8 @@ export const operationFields: INodeProperties[] = [ description: 'Max number of results to return', displayOptions: { show: { - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -120,9 +111,7 @@ export const operationFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: {}, @@ -132,7 +121,8 @@ export const operationFields: INodeProperties[] = [ displayName: 'Filter', name: 'filter', placeholder: 'Add Filter', - description: 'Only return rows matching all of the given filters. For complex filters, create a formula column and filter for the value "true".', + description: + 'Only return rows matching all of the given filters. For complex filters, create a formula column and filter for the value "true".', type: 'fixedCollection', typeOptions: { multipleValues: true, @@ -148,14 +138,12 @@ export const operationFields: INodeProperties[] = [ name: 'field', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'docId', - 'tableId', - ], + loadOptionsDependsOn: ['docId', 'tableId'], loadOptionsMethod: 'getTableColumns', }, default: '', - description: 'Column to apply the filter in. Choose from the list, or specify an ID using an expression.', + description: + 'Column to apply the filter in. Choose from the list, or specify an ID using an expression.', required: true, }, { @@ -188,15 +176,13 @@ export const operationFields: INodeProperties[] = [ name: 'field', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'docId', - 'tableId', - ], + loadOptionsDependsOn: ['docId', 'tableId'], loadOptionsMethod: 'getTableColumns', }, default: '', required: true, - description: 'Column to sort on. Choose from the list, or specify an ID using an expression.', + description: + 'Column to sort on. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Direction', @@ -231,9 +217,7 @@ export const operationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: '', @@ -262,10 +246,7 @@ export const operationFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'create', - 'update', - ], + operation: ['create', 'update'], }, }, default: 'defineInNode', @@ -277,17 +258,13 @@ export const operationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - 'update', - ], - dataToSend: [ - 'autoMapInputs', - ], + operation: ['create', 'update'], + dataToSend: ['autoMapInputs'], }, }, default: '', - description: 'List of input properties to avoid sending, separated by commas. Leave empty to send all properties.', + description: + 'List of input properties to avoid sending, separated by commas. Leave empty to send all properties.', placeholder: 'Enter properties...', }, { @@ -301,13 +278,8 @@ export const operationFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - 'update', - ], - dataToSend: [ - 'defineInNode', - ], + operation: ['create', 'update'], + dataToSend: ['defineInNode'], }, }, default: {}, @@ -319,12 +291,11 @@ export const operationFields: INodeProperties[] = [ { displayName: 'Column Name or ID', name: 'fieldId', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'tableId', - ], + loadOptionsDependsOn: ['tableId'], loadOptionsMethod: 'getTableColumns', }, default: '', diff --git a/packages/nodes-base/nodes/Grist/types.d.ts b/packages/nodes-base/nodes/Grist/types.d.ts index c8fec6c93f..2ff8c2406c 100644 --- a/packages/nodes-base/nodes/Grist/types.d.ts +++ b/packages/nodes-base/nodes/Grist/types.d.ts @@ -3,7 +3,7 @@ export type GristCredentials = { planType: 'free' | 'paid' | 'selfHosted'; customSubdomain?: string; selfHostedUrl?: string; -} +}; export type GristColumns = { columns: Array<{ id: string }>; @@ -32,16 +32,16 @@ export type GristDefinedFields = Array<{ export type GristCreateRowPayload = { records: Array<{ fields: { [key: string]: any }; - }> + }>; }; export type GristUpdateRowPayload = { records: Array<{ id: number; fields: { [key: string]: any }; - }> -} + }>; +}; export type SendingOptions = 'defineInNode' | 'autoMapInputs'; -export type FieldsToSend = { properties: GristDefinedFields; }; +export type FieldsToSend = { properties: GristDefinedFields }; diff --git a/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts b/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts index 1cc6df1f64..135dd80329 100644 --- a/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts @@ -6,9 +6,24 @@ import { ILoadOptionsFunctions, IWebhookFunctions, } from 'n8n-core'; -import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function gumroadApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function gumroadApiRequest( + this: + | IHookFunctions + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IWebhookFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('gumroadApi'); body = Object.assign({ access_token: credentials.accessToken }, body); @@ -16,7 +31,7 @@ export async function gumroadApiRequest(this: IHookFunctions | IExecuteFunctions method, qs, body, - uri: uri ||`https://api.gumroad.com/v2${resource}`, + uri: uri || `https://api.gumroad.com/v2${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Gumroad/GumroadTrigger.node.ts b/packages/nodes-base/nodes/Gumroad/GumroadTrigger.node.ts index 3cc65d25bd..c597cecf5c 100644 --- a/packages/nodes-base/nodes/Gumroad/GumroadTrigger.node.ts +++ b/packages/nodes-base/nodes/Gumroad/GumroadTrigger.node.ts @@ -1,18 +1,8 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import { - IDataObject, - INodeType, - INodeTypeDescription, - IWebhookResponseData, -} from 'n8n-workflow'; +import { IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; -import { - gumroadApiRequest, -} from './GenericFunctions'; +import { gumroadApiRequest } from './GenericFunctions'; export class GumroadTrigger implements INodeType { // eslint-disable-next-line n8n-nodes-base/node-class-description-missing-subtitle @@ -55,27 +45,32 @@ export class GumroadTrigger implements INodeType { { name: 'Cancellation', value: 'cancellation', - description: 'When subscribed to this resource, you will be notified of cancellations of the user\'s subscribers', + description: + "When subscribed to this resource, you will be notified of cancellations of the user's subscribers", }, { name: 'Dispute', value: 'dispute', - description: 'When subscribed to this resource, you will be notified of the disputes raised against user\'s sales', + description: + "When subscribed to this resource, you will be notified of the disputes raised against user's sales", }, { name: 'Dispute Won', value: 'dispute_won', - description: 'When subscribed to this resource, you will be notified of the sale disputes won', + description: + 'When subscribed to this resource, you will be notified of the sale disputes won', }, { name: 'Refund', value: 'refund', - description: 'When subscribed to this resource, you will be notified of refunds to the user\'s sales', + description: + "When subscribed to this resource, you will be notified of refunds to the user's sales", }, { name: 'Sale', value: 'sale', - description: 'When subscribed to this resource, you will be notified of the user\'s sales', + description: + "When subscribed to this resource, you will be notified of the user's sales", }, ], description: 'The resource is gonna fire the event', @@ -120,7 +115,7 @@ export class GumroadTrigger implements INodeType { const endpoint = `/resource_subscriptions/${webhookData.webhookId}`; try { responseData = await gumroadApiRequest.call(this, 'DELETE', endpoint); - } catch(error) { + } catch (error) { return false; } if (!responseData.success) { @@ -135,9 +130,7 @@ export class GumroadTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts b/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts index c94df5757d..ad7f40e0a2 100644 --- a/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts @@ -1,17 +1,8 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - IDataObject, - ILoadOptionsFunctions, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, ILoadOptionsFunctions, NodeApiError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; /** * Make an API request to HackerNews @@ -22,7 +13,13 @@ import { * @param {IDataObject} qs * @returns {Promise} */ -export async function hackerNewsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, qs: IDataObject): Promise { // tslint:disable-line:no-any +export async function hackerNewsApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + qs: IDataObject, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { method, qs, @@ -37,7 +34,6 @@ export async function hackerNewsApiRequest(this: IHookFunctions | IExecuteFuncti } } - /** * Make an API request to HackerNews * and return all results @@ -49,8 +45,13 @@ export async function hackerNewsApiRequest(this: IHookFunctions | IExecuteFuncti * @param {IDataObject} qs * @returns {Promise} */ -export async function hackerNewsApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, qs: IDataObject): Promise { // tslint:disable-line:no-any - +export async function hackerNewsApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + qs: IDataObject, + // tslint:disable-next-line:no-any +): Promise { qs.hitsPerPage = 100; const returnData: IDataObject[] = []; @@ -65,10 +66,7 @@ export async function hackerNewsApiRequestAllItems(this: IHookFunctions | IExecu if (returnData !== undefined) { itemsReceived += returnData.length; } - - } while ( - responseData.nbHits > itemsReceived - ); + } while (responseData.nbHits > itemsReceived); return returnData; } diff --git a/packages/nodes-base/nodes/HackerNews/HackerNews.node.ts b/packages/nodes-base/nodes/HackerNews/HackerNews.node.ts index f9b4b96ec1..4f38854175 100644 --- a/packages/nodes-base/nodes/HackerNews/HackerNews.node.ts +++ b/packages/nodes-base/nodes/HackerNews/HackerNews.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,10 +8,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - hackerNewsApiRequest, - hackerNewsApiRequestAllItems, -} from './GenericFunctions'; +import { hackerNewsApiRequest, hackerNewsApiRequestAllItems } from './GenericFunctions'; export class HackerNews implements INodeType { description: INodeTypeDescription = { @@ -56,7 +51,6 @@ export class HackerNews implements INodeType { default: 'article', }, - // ---------------------------------- // Operations // ---------------------------------- @@ -67,9 +61,7 @@ export class HackerNews implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'all', - ], + resource: ['all'], }, }, options: [ @@ -89,9 +81,7 @@ export class HackerNews implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'article', - ], + resource: ['article'], }, }, options: [ @@ -111,9 +101,7 @@ export class HackerNews implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -138,12 +126,8 @@ export class HackerNews implements INodeType { description: 'The ID of the Hacker News article to be returned', displayOptions: { show: { - resource: [ - 'article', - ], - operation: [ - 'get', - ], + resource: ['article'], + operation: ['get'], }, }, }, @@ -156,12 +140,8 @@ export class HackerNews implements INodeType { description: 'The Hacker News user to be returned', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, }, @@ -173,12 +153,8 @@ export class HackerNews implements INodeType { description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'all', - ], - operation: [ - 'getAll', - ], + resource: ['all'], + operation: ['getAll'], }, }, }, @@ -193,15 +169,9 @@ export class HackerNews implements INodeType { description: 'Max number of results to return', displayOptions: { show: { - resource: [ - 'all', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['all'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -213,12 +183,8 @@ export class HackerNews implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'article', - ], - operation: [ - 'get', - ], + resource: ['article'], + operation: ['get'], }, }, options: [ @@ -239,12 +205,8 @@ export class HackerNews implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'all', - ], - operation: [ - 'getAll', - ], + resource: ['all'], + operation: ['getAll'], }, }, options: [ @@ -299,7 +261,6 @@ export class HackerNews implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -316,7 +277,6 @@ export class HackerNews implements INodeType { if (resource === 'all') { if (operation === 'getAll') { - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const keyword = additionalFields.keyword as string; const tags = additionalFields.tags as string[]; @@ -333,36 +293,41 @@ export class HackerNews implements INodeType { } endpoint = 'search?'; - } else { - throw new NodeOperationError(this.getNode(), `The operation '${operation}' is unknown!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation '${operation}' is unknown!`, + { itemIndex: i }, + ); } } else if (resource === 'article') { - if (operation === 'get') { - endpoint = `items/${this.getNodeParameter('articleId', i)}`; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; includeComments = additionalFields.includeComments as boolean; - } else { - throw new NodeOperationError(this.getNode(), `The operation '${operation}' is unknown!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation '${operation}' is unknown!`, + { itemIndex: i }, + ); } - } else if (resource === 'user') { - if (operation === 'get') { endpoint = `users/${this.getNodeParameter('username', i)}`; - } else { - throw new NodeOperationError(this.getNode(), `The operation '${operation}' is unknown!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation '${operation}' is unknown!`, + { itemIndex: i }, + ); } - } else { - throw new NodeOperationError(this.getNode(), `The resource '${resource}' is unknown!`, { itemIndex: i }); + throw new NodeOperationError(this.getNode(), `The resource '${resource}' is unknown!`, { + itemIndex: i, + }); } - let responseData; if (returnAll === true) { responseData = await hackerNewsApiRequestAllItems.call(this, 'GET', endpoint, qs); @@ -392,6 +357,5 @@ export class HackerNews implements INodeType { } return [this.helpers.returnJsonArray(returnData)]; - } } diff --git a/packages/nodes-base/nodes/HaloPSA/GenericFunctions.ts b/packages/nodes-base/nodes/HaloPSA/GenericFunctions.ts index e412c5e33f..d46735dabe 100644 --- a/packages/nodes-base/nodes/HaloPSA/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HaloPSA/GenericFunctions.ts @@ -66,9 +66,9 @@ export async function haloPSAApiRequest( body: IDataObject | IDataObject[] = {}, qs: IDataObject = {}, option: IDataObject = {}, -): Promise { // tslint:disable-line:no-any - const resourceApiUrl = (await this.getCredentials('haloPSAApi')) - .resourceApiUrl as string; + // tslint:disable-next-line:no-any +): Promise { + const resourceApiUrl = (await this.getCredentials('haloPSAApi')).resourceApiUrl as string; try { let options: OptionsWithUri = { @@ -159,8 +159,8 @@ export async function haloPSAApiRequestAllItems( accessToken: string, body = {}, query: IDataObject = {}, -): Promise { // tslint:disable-line:no-any - + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData: IDataObject; diff --git a/packages/nodes-base/nodes/HaloPSA/descriptions/SiteDescription.ts b/packages/nodes-base/nodes/HaloPSA/descriptions/SiteDescription.ts index c7013f5750..ccc343dc63 100644 --- a/packages/nodes-base/nodes/HaloPSA/descriptions/SiteDescription.ts +++ b/packages/nodes-base/nodes/HaloPSA/descriptions/SiteDescription.ts @@ -96,7 +96,8 @@ export const siteFields: INodeProperties[] = [ displayName: 'Client Name or ID', name: 'clientId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', required: true, typeOptions: { diff --git a/packages/nodes-base/nodes/HaloPSA/descriptions/TicketDescription.ts b/packages/nodes-base/nodes/HaloPSA/descriptions/TicketDescription.ts index dab1de1ab3..017a6b596c 100644 --- a/packages/nodes-base/nodes/HaloPSA/descriptions/TicketDescription.ts +++ b/packages/nodes-base/nodes/HaloPSA/descriptions/TicketDescription.ts @@ -55,7 +55,8 @@ export const ticketFields: INodeProperties[] = [ displayName: 'Ticket Type Name or ID', name: 'ticketType', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', required: true, typeOptions: { @@ -113,7 +114,8 @@ export const ticketFields: INodeProperties[] = [ displayName: 'Assigned Agent Name or ID', name: 'agent_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getHaloPSAAgents', @@ -274,7 +276,8 @@ export const ticketFields: INodeProperties[] = [ displayName: 'Assigned Agent Name or ID', name: 'agent_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getHaloPSAAgents', diff --git a/packages/nodes-base/nodes/HaloPSA/descriptions/UserDescription.ts b/packages/nodes-base/nodes/HaloPSA/descriptions/UserDescription.ts index 04f46ae183..dce6e25362 100644 --- a/packages/nodes-base/nodes/HaloPSA/descriptions/UserDescription.ts +++ b/packages/nodes-base/nodes/HaloPSA/descriptions/UserDescription.ts @@ -69,7 +69,8 @@ export const userFields: INodeProperties[] = [ displayName: 'Site Name or ID', name: 'siteId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', required: true, typeOptions: { @@ -305,7 +306,8 @@ export const userFields: INodeProperties[] = [ displayName: 'Site Name or ID', name: 'site_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getHaloPSASites', diff --git a/packages/nodes-base/nodes/HaloPSA/descriptions/index.ts b/packages/nodes-base/nodes/HaloPSA/descriptions/index.ts index aa9fd75548..262f4bc7b5 100644 --- a/packages/nodes-base/nodes/HaloPSA/descriptions/index.ts +++ b/packages/nodes-base/nodes/HaloPSA/descriptions/index.ts @@ -11,5 +11,5 @@ export { ticketFields, ticketOperations, userFields, - userOperations + userOperations, }; diff --git a/packages/nodes-base/nodes/Harvest/ClientDescription.ts b/packages/nodes-base/nodes/Harvest/ClientDescription.ts index bf6cf53ef9..35d46cfdf2 100644 --- a/packages/nodes-base/nodes/Harvest/ClientDescription.ts +++ b/packages/nodes-base/nodes/Harvest/ClientDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -const resource = [ - 'client', -]; +const resource = ['client']; export const clientOperations: INodeProperties[] = [ { @@ -52,11 +48,9 @@ export const clientOperations: INodeProperties[] = [ ], default: 'getAll', }, - ]; export const clientFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* client:getAll */ /* -------------------------------------------------------------------------- */ @@ -68,9 +62,7 @@ export const clientFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: false, @@ -83,12 +75,8 @@ export const clientFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -107,9 +95,7 @@ export const clientFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, options: [ @@ -141,9 +127,7 @@ export const clientFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], resource, }, }, @@ -161,9 +145,7 @@ export const clientFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], resource, }, }, @@ -179,9 +161,7 @@ export const clientFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -196,9 +176,7 @@ export const clientFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -209,14 +187,16 @@ export const clientFields: INodeProperties[] = [ name: 'address', type: 'string', default: '', - description: 'A textual representation of the client’s physical address. May include new line characters.', + description: + 'A textual representation of the client’s physical address. May include new line characters.', }, { displayName: 'Currency', name: 'currency', type: 'string', default: '', - description: 'The currency used by the estimate. If not provided, the client’s currency will be used. See a list of supported currencies', + description: + 'The currency used by the estimate. If not provided, the client’s currency will be used. See a list of supported currencies', }, { displayName: 'Is Active', @@ -239,9 +219,7 @@ export const clientFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -254,9 +232,7 @@ export const clientFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -267,14 +243,16 @@ export const clientFields: INodeProperties[] = [ name: 'address', type: 'string', default: '', - description: 'A textual representation of the client’s physical address. May include new line characters.', + description: + 'A textual representation of the client’s physical address. May include new line characters.', }, { displayName: 'Currency', name: 'currency', type: 'string', default: '', - description: 'The currency used by the estimate. If not provided, the client’s currency will be used. See a list of supported currencies', + description: + 'The currency used by the estimate. If not provided, the client’s currency will be used. See a list of supported currencies', }, { displayName: 'Is Active', @@ -292,5 +270,4 @@ export const clientFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Harvest/CompanyDescription.ts b/packages/nodes-base/nodes/Harvest/CompanyDescription.ts index dcd6d758bf..265938d5cf 100644 --- a/packages/nodes-base/nodes/Harvest/CompanyDescription.ts +++ b/packages/nodes-base/nodes/Harvest/CompanyDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -const resource = [ - 'company', -]; +const resource = ['company']; export const companyOperations: INodeProperties[] = [ { @@ -27,5 +23,4 @@ export const companyOperations: INodeProperties[] = [ ], default: 'get', }, - ]; diff --git a/packages/nodes-base/nodes/Harvest/ContactDescription.ts b/packages/nodes-base/nodes/Harvest/ContactDescription.ts index e5014fa29d..7997627df9 100644 --- a/packages/nodes-base/nodes/Harvest/ContactDescription.ts +++ b/packages/nodes-base/nodes/Harvest/ContactDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -const resource = [ - 'contact', -]; +const resource = ['contact']; export const contactOperations: INodeProperties[] = [ { @@ -51,11 +47,9 @@ export const contactOperations: INodeProperties[] = [ ], default: 'getAll', }, - ]; export const contactFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* contact:getAll */ /* -------------------------------------------------------------------------- */ @@ -67,9 +61,7 @@ export const contactFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: false, @@ -82,12 +74,8 @@ export const contactFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -106,9 +94,7 @@ export const contactFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, options: [ @@ -140,9 +126,7 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], resource, }, }, @@ -160,9 +144,7 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], resource, }, }, @@ -178,9 +160,7 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -194,9 +174,7 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -211,9 +189,7 @@ export const contactFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -277,9 +253,7 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -292,9 +266,7 @@ export const contactFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -359,5 +331,4 @@ export const contactFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Harvest/EstimateDescription.ts b/packages/nodes-base/nodes/Harvest/EstimateDescription.ts index 2b1613d766..118303b0ab 100644 --- a/packages/nodes-base/nodes/Harvest/EstimateDescription.ts +++ b/packages/nodes-base/nodes/Harvest/EstimateDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -const resource = [ - 'estimate', -]; +const resource = ['estimate']; export const estimateOperations: INodeProperties[] = [ { @@ -51,11 +47,9 @@ export const estimateOperations: INodeProperties[] = [ ], default: 'getAll', }, - ]; export const estimateFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* estimate:getAll */ /* -------------------------------------------------------------------------- */ @@ -67,9 +61,7 @@ export const estimateFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: false, @@ -82,12 +74,8 @@ export const estimateFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -106,9 +94,7 @@ export const estimateFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, options: [ @@ -131,7 +117,8 @@ export const estimateFields: INodeProperties[] = [ name: 'state', type: 'string', default: '', - description: 'Only return estimates with a state matching the value provided. Options: draft, sent, accepted, or declined.', + description: + 'Only return estimates with a state matching the value provided. Options: draft, sent, accepted, or declined.', }, { displayName: 'To', @@ -145,7 +132,8 @@ export const estimateFields: INodeProperties[] = [ name: 'updated_since', type: 'dateTime', default: '', - description: 'Only return time entries that have been updated since the given date and time', + description: + 'Only return time entries that have been updated since the given date and time', }, { displayName: 'Page', @@ -155,7 +143,8 @@ export const estimateFields: INodeProperties[] = [ minValue: 1, }, default: 1, - description: 'The page number to use in pagination. For instance, if you make a list request and receive 100 records, your subsequent call can include page=2 to retrieve the next page of the list. (Default: 1)', + description: + 'The page number to use in pagination. For instance, if you make a list request and receive 100 records, your subsequent call can include page=2 to retrieve the next page of the list. (Default: 1)', }, ], }, @@ -171,9 +160,7 @@ export const estimateFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], resource, }, }, @@ -191,9 +178,7 @@ export const estimateFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], resource, }, }, @@ -209,9 +194,7 @@ export const estimateFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -226,9 +209,7 @@ export const estimateFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -239,14 +220,16 @@ export const estimateFields: INodeProperties[] = [ name: 'currency', type: 'string', default: '', - description: 'The currency used by the estimate. If not provided, the client’s currency will be used. See a list of supported currencies', + description: + 'The currency used by the estimate. If not provided, the client’s currency will be used. See a list of supported currencies', }, { displayName: 'Discount', name: 'over_budget_notification_percentage', type: 'string', default: '', - description: 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.', + description: + 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.', }, { displayName: 'Issue Date', @@ -288,14 +271,16 @@ export const estimateFields: INodeProperties[] = [ name: 'tax', type: 'string', default: '', - description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', + description: + 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', }, { displayName: 'Tax2', name: 'tax2', type: 'string', default: '', - description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', + description: + 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', }, ], }, @@ -311,9 +296,7 @@ export const estimateFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -326,9 +309,7 @@ export const estimateFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -346,14 +327,16 @@ export const estimateFields: INodeProperties[] = [ name: 'currency', type: 'string', default: '', - description: 'The currency used by the estimate. If not provided, the client’s currency will be used. See a list of supported currencies', + description: + 'The currency used by the estimate. If not provided, the client’s currency will be used. See a list of supported currencies', }, { displayName: 'Discount', name: 'over_budget_notification_percentage', type: 'string', default: '', - description: 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.', + description: + 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.', }, { displayName: 'Issue Date', @@ -395,16 +378,17 @@ export const estimateFields: INodeProperties[] = [ name: 'tax', type: 'string', default: '', - description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', + description: + 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', }, { displayName: 'Tax2', name: 'tax2', type: 'string', default: '', - description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', + description: + 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Harvest/ExpenseDescription.ts b/packages/nodes-base/nodes/Harvest/ExpenseDescription.ts index b5c51fcd5a..2d34788906 100644 --- a/packages/nodes-base/nodes/Harvest/ExpenseDescription.ts +++ b/packages/nodes-base/nodes/Harvest/ExpenseDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -const resource = [ - 'expense', -]; +const resource = ['expense']; export const expenseOperations: INodeProperties[] = [ { @@ -51,11 +47,9 @@ export const expenseOperations: INodeProperties[] = [ ], default: 'getAll', }, - ]; export const expenseFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* expense:getAll */ /* -------------------------------------------------------------------------- */ @@ -67,9 +61,7 @@ export const expenseFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: false, @@ -82,12 +74,8 @@ export const expenseFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -106,9 +94,7 @@ export const expenseFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, options: [ @@ -131,7 +117,8 @@ export const expenseFields: INodeProperties[] = [ name: 'is_billed', type: 'boolean', default: false, - description: 'Whether to only return time entries that have been invoiced and false to return time entries that have not been invoiced', + description: + 'Whether to only return time entries that have been invoiced and false to return time entries that have not been invoiced', }, { displayName: 'Page', @@ -141,7 +128,8 @@ export const expenseFields: INodeProperties[] = [ minValue: 1, }, default: 1, - description: 'The page number to use in pagination. For instance, if you make a list request and receive 100 records, your subsequent call can include page=2 to retrieve the next page of the list. (Default: 1)', + description: + 'The page number to use in pagination. For instance, if you make a list request and receive 100 records, your subsequent call can include page=2 to retrieve the next page of the list. (Default: 1)', }, { displayName: 'Project ID', @@ -162,7 +150,8 @@ export const expenseFields: INodeProperties[] = [ name: 'updated_since', type: 'dateTime', default: '', - description: 'Only return time entries that have been updated since the given date and time', + description: + 'Only return time entries that have been updated since the given date and time', }, { displayName: 'User ID', @@ -185,9 +174,7 @@ export const expenseFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], resource, }, }, @@ -205,9 +192,7 @@ export const expenseFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], resource, }, }, @@ -223,9 +208,7 @@ export const expenseFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -239,9 +222,7 @@ export const expenseFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -255,9 +236,7 @@ export const expenseFields: INodeProperties[] = [ type: 'dateTime', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -272,9 +251,7 @@ export const expenseFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -314,7 +291,8 @@ export const expenseFields: INodeProperties[] = [ type: 'boolean', default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'The ID of the user associated with this expense. Defaults to the ID of the currently authenticated user.', + description: + 'The ID of the user associated with this expense. Defaults to the ID of the currently authenticated user.', }, ], }, @@ -330,9 +308,7 @@ export const expenseFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -345,9 +321,7 @@ export const expenseFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -408,9 +382,9 @@ export const expenseFields: INodeProperties[] = [ type: 'boolean', default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'The ID of the user associated with this expense. Defaults to the ID of the currently authenticated user.', + description: + 'The ID of the user associated with this expense. Defaults to the ID of the currently authenticated user.', }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Harvest/GenericFunctions.ts b/packages/nodes-base/nodes/Harvest/GenericFunctions.ts index 276c9dfe25..61e842cb72 100644 --- a/packages/nodes-base/nodes/Harvest/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Harvest/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,16 +7,23 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function harvestApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, qs: IDataObject = {}, path: string, body: IDataObject = {}, option: IDataObject = {}, uri?: string): Promise { // tslint:disable-line:no-any +export async function harvestApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + qs: IDataObject = {}, + path: string, + body: IDataObject = {}, + option: IDataObject = {}, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { let options: OptionsWithUri = { headers: { 'Harvest-Account-Id': `${this.getNodeParameter('accountId', 0)}`, 'User-Agent': 'Harvest App', - 'Authorization': '', + Authorization: '', }, method, body, @@ -61,8 +66,8 @@ export async function harvestApiRequestAllItems( resource: string, body: IDataObject = {}, option: IDataObject = {}, -): Promise { // tslint:disable-line:no-any - + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -79,7 +84,11 @@ export async function harvestApiRequestAllItems( /** * fetch All resource using paginated calls */ -export async function getAllResource(this: IExecuteFunctions | ILoadOptionsFunctions, resource: string, i: number) { +export async function getAllResource( + this: IExecuteFunctions | ILoadOptionsFunctions, + resource: string, + i: number, +) { const endpoint = resource; const qs: IDataObject = {}; const requestMethod = 'GET'; @@ -93,7 +102,13 @@ export async function getAllResource(this: IExecuteFunctions | ILoadOptionsFunct let responseData: IDataObject = {}; if (returnAll) { - responseData[resource] = await harvestApiRequestAllItems.call(this, requestMethod, qs, endpoint, resource); + responseData[resource] = await harvestApiRequestAllItems.call( + this, + requestMethod, + qs, + endpoint, + resource, + ); } else { const limit = this.getNodeParameter('limit', i) as string; qs.per_page = limit; @@ -101,4 +116,3 @@ export async function getAllResource(this: IExecuteFunctions | ILoadOptionsFunct } return responseData[resource] as IDataObject[]; } - diff --git a/packages/nodes-base/nodes/Harvest/Harvest.node.ts b/packages/nodes-base/nodes/Harvest/Harvest.node.ts index 1348758211..7e6923db91 100644 --- a/packages/nodes-base/nodes/Harvest/Harvest.node.ts +++ b/packages/nodes-base/nodes/Harvest/Harvest.node.ts @@ -1,7 +1,4 @@ -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject, @@ -12,59 +9,27 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - clientFields, - clientOperations, -} from './ClientDescription'; +import { clientFields, clientOperations } from './ClientDescription'; -import { - contactFields, - contactOperations, -} from './ContactDescription'; +import { contactFields, contactOperations } from './ContactDescription'; -import { - companyOperations, -} from './CompanyDescription'; +import { companyOperations } from './CompanyDescription'; -import { - estimateFields, - estimateOperations, -} from './EstimateDescription'; +import { estimateFields, estimateOperations } from './EstimateDescription'; -import { - expenseFields, - expenseOperations, -} from './ExpenseDescription'; +import { expenseFields, expenseOperations } from './ExpenseDescription'; -import { - getAllResource, - harvestApiRequest, -} from './GenericFunctions'; +import { getAllResource, harvestApiRequest } from './GenericFunctions'; -import { - invoiceFields, - invoiceOperations, -} from './InvoiceDescription'; +import { invoiceFields, invoiceOperations } from './InvoiceDescription'; -import { - projectFields, - projectOperations, -} from './ProjectDescription'; +import { projectFields, projectOperations } from './ProjectDescription'; -import { - taskFields, - taskOperations, -} from './TaskDescription'; +import { taskFields, taskOperations } from './TaskDescription'; -import { - timeEntryFields, - timeEntryOperations, -} from './TimeEntryDescription'; +import { timeEntryFields, timeEntryOperations } from './TimeEntryDescription'; -import { - userFields, - userOperations, -} from './UserDescription'; +import { userFields, userOperations } from './UserDescription'; export class Harvest implements INodeType { description: INodeTypeDescription = { @@ -87,9 +52,7 @@ export class Harvest implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -98,9 +61,7 @@ export class Harvest implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -123,14 +84,12 @@ export class Harvest implements INodeType { default: 'accessToken', }, - { displayName: 'Resource', name: 'resource', type: 'options', noDataExpression: true, options: [ - { name: 'Client', value: 'client', @@ -191,7 +150,8 @@ export class Harvest implements INodeType { displayName: 'Account Name or ID', name: 'accountId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getAccounts', @@ -218,7 +178,15 @@ export class Harvest implements INodeType { // select them easily async getAccounts(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { accounts } = await harvestApiRequest.call(this, 'GET', {}, '', {}, {}, 'https://id.getharvest.com/api/v2/accounts'); + const { accounts } = await harvestApiRequest.call( + this, + 'GET', + {}, + '', + {}, + {}, + 'https://id.getharvest.com/api/v2/accounts', + ); for (const account of accounts) { const accountName = account.name; const accountId = account.id; @@ -262,14 +230,12 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); - } else if (operation === 'getAll') { // ---------------------------------- // getAll // ---------------------------------- const responseData: IDataObject[] = await getAllResource.call(this, 'time_entries', i); returnData.push.apply(returnData, responseData); - } else if (operation === 'createByStartEnd') { // ---------------------------------- // createByStartEnd @@ -285,9 +251,14 @@ export class Harvest implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'createByDuration') { // ---------------------------------- // createByDuration @@ -303,9 +274,14 @@ export class Harvest implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -328,7 +304,6 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); - } else if (operation === 'restartTime') { // ---------------------------------- // restartTime @@ -340,7 +315,6 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); - } else if (operation === 'stopTime') { // ---------------------------------- // stopTime @@ -352,7 +326,6 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); - } else if (operation === 'update') { // ---------------------------------- // update @@ -365,13 +338,21 @@ export class Harvest implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; Object.assign(body, updateFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } - } else if (resource === 'client') { if (operation === 'get') { // ---------------------------------- @@ -385,7 +366,6 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -393,7 +373,6 @@ export class Harvest implements INodeType { const responseData: IDataObject[] = await getAllResource.call(this, 'clients', i); returnData.push.apply(returnData, responseData); - } else if (operation === 'create') { // ---------------------------------- // create @@ -407,9 +386,14 @@ export class Harvest implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'update') { // ---------------------------------- // update @@ -422,9 +406,14 @@ export class Harvest implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; Object.assign(qs, updateFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -437,7 +426,11 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The resource "${resource}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'project') { if (operation === 'get') { @@ -452,7 +445,6 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -460,7 +452,6 @@ export class Harvest implements INodeType { const responseData: IDataObject[] = await getAllResource.call(this, 'projects', i); returnData.push.apply(returnData, responseData); - } else if (operation === 'create') { // ---------------------------------- // create @@ -478,9 +469,14 @@ export class Harvest implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'update') { // ---------------------------------- // update @@ -493,9 +489,14 @@ export class Harvest implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; Object.assign(body, updateFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -508,7 +509,11 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The resource "${resource}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'user') { if (operation === 'get') { @@ -523,7 +528,6 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -531,7 +535,6 @@ export class Harvest implements INodeType { const responseData: IDataObject[] = await getAllResource.call(this, 'users', i); returnData.push.apply(returnData, responseData); - } else if (operation === 'me') { // ---------------------------------- // me @@ -543,7 +546,6 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); - } else if (operation === 'create') { // ---------------------------------- // create @@ -559,9 +561,14 @@ export class Harvest implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'update') { // ---------------------------------- // update @@ -574,9 +581,14 @@ export class Harvest implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; Object.assign(qs, updateFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -589,7 +601,11 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The resource "${resource}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'contact') { if (operation === 'get') { @@ -604,7 +620,6 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -612,7 +627,6 @@ export class Harvest implements INodeType { const responseData: IDataObject[] = await getAllResource.call(this, 'contacts', i); returnData.push.apply(returnData, responseData); - } else if (operation === 'create') { // ---------------------------------- // create @@ -627,9 +641,14 @@ export class Harvest implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'update') { // ---------------------------------- // update @@ -642,9 +661,14 @@ export class Harvest implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; Object.assign(qs, updateFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -657,7 +681,11 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The resource "${resource}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'company') { if (operation === 'get') { @@ -670,9 +698,12 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); - } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The resource "${resource}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'task') { if (operation === 'get') { @@ -687,7 +718,6 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -695,7 +725,6 @@ export class Harvest implements INodeType { const responseData: IDataObject[] = await getAllResource.call(this, 'tasks', i); returnData.push.apply(returnData, responseData); - } else if (operation === 'create') { // ---------------------------------- // create @@ -709,9 +738,14 @@ export class Harvest implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'update') { // ---------------------------------- // update @@ -724,9 +758,14 @@ export class Harvest implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; Object.assign(qs, updateFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -739,7 +778,11 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The resource "${resource}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'invoice') { if (operation === 'get') { @@ -754,7 +797,6 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -762,7 +804,6 @@ export class Harvest implements INodeType { const responseData: IDataObject[] = await getAllResource.call(this, 'invoices', i); returnData.push.apply(returnData, responseData); - } else if (operation === 'create') { // ---------------------------------- // create @@ -776,9 +817,14 @@ export class Harvest implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'update') { // ---------------------------------- // update @@ -791,9 +837,14 @@ export class Harvest implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; Object.assign(qs, updateFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -806,7 +857,11 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The resource "${resource}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'expense') { if (operation === 'get') { @@ -821,7 +876,6 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -829,7 +883,6 @@ export class Harvest implements INodeType { const responseData: IDataObject[] = await getAllResource.call(this, 'expenses', i); returnData.push.apply(returnData, responseData); - } else if (operation === 'create') { // ---------------------------------- // create @@ -845,9 +898,14 @@ export class Harvest implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'update') { // ---------------------------------- // update @@ -860,9 +918,14 @@ export class Harvest implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; Object.assign(qs, updateFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -875,7 +938,11 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The resource "${resource}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'estimate') { if (operation === 'get') { @@ -890,7 +957,6 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -898,7 +964,6 @@ export class Harvest implements INodeType { const responseData: IDataObject[] = await getAllResource.call(this, 'estimates', i); returnData.push.apply(returnData, responseData); - } else if (operation === 'create') { // ---------------------------------- // create @@ -912,9 +977,14 @@ export class Harvest implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'update') { // ---------------------------------- // update @@ -927,9 +997,14 @@ export class Harvest implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; Object.assign(qs, updateFields); - const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint, body); + const responseData = await harvestApiRequest.call( + this, + requestMethod, + qs, + endpoint, + body, + ); returnData.push(responseData); - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -942,10 +1017,16 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); returnData.push(responseData); } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The resource "${resource}" is not known!`, + { itemIndex: i }, + ); } } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { + itemIndex: i, + }); } } catch (error) { if (this.continueOnFail()) { @@ -958,5 +1039,4 @@ export class Harvest implements INodeType { return [this.helpers.returnJsonArray(returnData)]; } - } diff --git a/packages/nodes-base/nodes/Harvest/InvoiceDescription.ts b/packages/nodes-base/nodes/Harvest/InvoiceDescription.ts index 52d5fb1c4e..687c66c1b5 100644 --- a/packages/nodes-base/nodes/Harvest/InvoiceDescription.ts +++ b/packages/nodes-base/nodes/Harvest/InvoiceDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -const resource = [ - 'invoice', -]; +const resource = ['invoice']; export const invoiceOperations: INodeProperties[] = [ { @@ -51,11 +47,9 @@ export const invoiceOperations: INodeProperties[] = [ ], default: 'getAll', }, - ]; export const invoiceFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* invoice:getAll */ /* -------------------------------------------------------------------------- */ @@ -67,9 +61,7 @@ export const invoiceFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: false, @@ -82,12 +74,8 @@ export const invoiceFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -106,9 +94,7 @@ export const invoiceFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, options: [ @@ -134,7 +120,8 @@ export const invoiceFields: INodeProperties[] = [ minValue: 1, }, default: 1, - description: 'The page number to use in pagination. For instance, if you make a list request and receive 100 records, your subsequent call can include page=2 to retrieve the next page of the list. (Default: 1)', + description: + 'The page number to use in pagination. For instance, if you make a list request and receive 100 records, your subsequent call can include page=2 to retrieve the next page of the list. (Default: 1)', }, { displayName: 'Project ID', @@ -166,7 +153,8 @@ export const invoiceFields: INodeProperties[] = [ }, ], default: [], - description: 'Only return invoices with a state matching the value provided. Options: draft, open, paid, or closed.', + description: + 'Only return invoices with a state matching the value provided. Options: draft, open, paid, or closed.', }, { displayName: 'To', @@ -181,7 +169,8 @@ export const invoiceFields: INodeProperties[] = [ name: 'updated_since', type: 'dateTime', default: '', - description: 'Only return time entries that have been updated since the given date and time', + description: + 'Only return time entries that have been updated since the given date and time', }, ], }, @@ -197,9 +186,7 @@ export const invoiceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], resource, }, }, @@ -217,9 +204,7 @@ export const invoiceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], resource, }, }, @@ -235,9 +220,7 @@ export const invoiceFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -252,9 +235,7 @@ export const invoiceFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -265,21 +246,24 @@ export const invoiceFields: INodeProperties[] = [ name: 'currency', type: 'string', default: '', - description: 'The currency used by the invoice. If not provided, the client’s currency will be used. See a list of supported currencies', + description: + 'The currency used by the invoice. If not provided, the client’s currency will be used. See a list of supported currencies', }, { displayName: 'Discount', name: 'over_budget_notification_percentage', type: 'string', default: '', - description: 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.', + description: + 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.', }, { displayName: 'Due Date', name: 'ends_on', type: 'dateTime', default: '', - description: 'Date the invoice is due. Defaults to the issue_date if no payment_term is specified.', + description: + 'Date the invoice is due. Defaults to the issue_date if no payment_term is specified.', }, { displayName: 'Estimate ID', @@ -314,7 +298,8 @@ export const invoiceFields: INodeProperties[] = [ name: 'payment_term', type: 'string', default: '', - description: 'The timeframe in which the invoice should be paid. Defaults to custom. Options: upon receipt, net 15, net 30, net 45, or net 60.', + description: + 'The timeframe in which the invoice should be paid. Defaults to custom. Options: upon receipt, net 15, net 30, net 45, or net 60.', }, { displayName: 'Purchase Order', @@ -343,14 +328,16 @@ export const invoiceFields: INodeProperties[] = [ name: 'tax', type: 'string', default: '', - description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', + description: + 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', }, { displayName: 'Tax2', name: 'tax2', type: 'string', default: '', - description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', + description: + 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', }, ], }, @@ -366,9 +353,7 @@ export const invoiceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -381,9 +366,7 @@ export const invoiceFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -401,21 +384,24 @@ export const invoiceFields: INodeProperties[] = [ name: 'currency', type: 'string', default: '', - description: 'The currency used by the invoice. If not provided, the client’s currency will be used. See a list of supported currencies', + description: + 'The currency used by the invoice. If not provided, the client’s currency will be used. See a list of supported currencies', }, { displayName: 'Discount', name: 'over_budget_notification_percentage', type: 'string', default: '', - description: 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.', + description: + 'This percentage is subtracted from the subtotal. Example: use 10.0 for 10.0%.', }, { displayName: 'Due Date', name: 'ends_on', type: 'dateTime', default: '', - description: 'Date the invoice is due. Defaults to the issue_date if no payment_term is specified.', + description: + 'Date the invoice is due. Defaults to the issue_date if no payment_term is specified.', }, { displayName: 'Estimate ID', @@ -450,7 +436,8 @@ export const invoiceFields: INodeProperties[] = [ name: 'payment_term', type: 'string', default: '', - description: 'The timeframe in which the invoice should be paid. Defaults to custom. Options: upon receipt, net 15, net 30, net 45, or net 60.', + description: + 'The timeframe in which the invoice should be paid. Defaults to custom. Options: upon receipt, net 15, net 30, net 45, or net 60.', }, { displayName: 'Purchase Order', @@ -479,14 +466,16 @@ export const invoiceFields: INodeProperties[] = [ name: 'tax', type: 'string', default: '', - description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', + description: + 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', }, { displayName: 'Tax2', name: 'tax2', type: 'string', default: '', - description: 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', + description: + 'This percentage is applied to the subtotal, including line items and discounts. Example: use 10.0 for 10.0%.', }, ], }, diff --git a/packages/nodes-base/nodes/Harvest/ProjectDescription.ts b/packages/nodes-base/nodes/Harvest/ProjectDescription.ts index 5085fd7fd4..6e9a0b7e83 100644 --- a/packages/nodes-base/nodes/Harvest/ProjectDescription.ts +++ b/packages/nodes-base/nodes/Harvest/ProjectDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -const resource = [ - 'project', -]; +const resource = ['project']; export const projectOperations: INodeProperties[] = [ { @@ -51,11 +47,9 @@ export const projectOperations: INodeProperties[] = [ ], default: 'getAll', }, - ]; export const projectFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* projects:getAll */ /* -------------------------------------------------------------------------- */ @@ -67,9 +61,7 @@ export const projectFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: false, @@ -82,12 +74,8 @@ export const projectFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -106,9 +94,7 @@ export const projectFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, options: [ @@ -157,9 +143,7 @@ export const projectFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], resource, }, }, @@ -177,9 +161,7 @@ export const projectFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], resource, }, }, @@ -195,9 +177,7 @@ export const projectFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -211,9 +191,7 @@ export const projectFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -227,9 +205,7 @@ export const projectFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -243,9 +219,7 @@ export const projectFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -277,9 +251,7 @@ export const projectFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -295,9 +267,7 @@ export const projectFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -333,7 +303,8 @@ export const projectFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Option for budget of Total Project Fees projects to include tracked expenses. Defaults to false.', + description: + 'Option for budget of Total Project Fees projects to include tracked expenses. Defaults to false.', }, { displayName: 'Ends On', @@ -347,7 +318,8 @@ export const projectFields: INodeProperties[] = [ name: 'fee', type: 'string', default: '', - description: 'The amount you plan to invoice for the project. Only used by fixed-fee projects.', + description: + 'The amount you plan to invoice for the project. Only used by fixed-fee projects.', }, { displayName: 'Hourly Rate', @@ -382,21 +354,24 @@ export const projectFields: INodeProperties[] = [ name: 'notify_when_over_budget', type: 'boolean', default: false, - description: 'Whether project managers should be notified when the project goes over budget. Defaults to false.', + description: + 'Whether project managers should be notified when the project goes over budget. Defaults to false.', }, { displayName: 'Over Budget Notification Percentage', name: 'over_budget_notification_percentage', type: 'string', default: '', - description: 'Percentage value used to trigger over budget email alerts. Example: use 10.0 for 10.0%.', + description: + 'Percentage value used to trigger over budget email alerts. Example: use 10.0 for 10.0%.', }, { displayName: 'Show Budget To All', name: 'show_budget_to_all', type: 'boolean', default: false, - description: 'Whether to show project budget to all employees. Does not apply to Total Project Fee projects. Defaults to false.', + description: + 'Whether to show project budget to all employees. Does not apply to Total Project Fee projects. Defaults to false.', }, { displayName: 'Starts On', @@ -419,9 +394,7 @@ export const projectFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -434,9 +407,7 @@ export const projectFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -508,7 +479,8 @@ export const projectFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Option for budget of Total Project Fees projects to include tracked expenses. Defaults to false.', + description: + 'Option for budget of Total Project Fees projects to include tracked expenses. Defaults to false.', }, { displayName: 'Ends On', @@ -522,7 +494,8 @@ export const projectFields: INodeProperties[] = [ name: 'fee', type: 'string', default: '', - description: 'The amount you plan to invoice for the project. Only used by fixed-fee projects.', + description: + 'The amount you plan to invoice for the project. Only used by fixed-fee projects.', }, { displayName: 'Hourly Rate', @@ -571,21 +544,24 @@ export const projectFields: INodeProperties[] = [ name: 'notify_when_over_budget', type: 'boolean', default: false, - description: 'Whether project managers should be notified when the project goes over budget. Defaults to false.', + description: + 'Whether project managers should be notified when the project goes over budget. Defaults to false.', }, { displayName: 'Over Budget Notification Percentage', name: 'over_budget_notification_percentage', type: 'string', default: '', - description: 'Percentage value used to trigger over budget email alerts. Example: use 10.0 for 10.0%.', + description: + 'Percentage value used to trigger over budget email alerts. Example: use 10.0 for 10.0%.', }, { displayName: 'Show Budget To All', name: 'show_budget_to_all', type: 'boolean', default: false, - description: 'Whether to show project budget to all employees. Does not apply to Total Project Fee projects. Defaults to false.', + description: + 'Whether to show project budget to all employees. Does not apply to Total Project Fee projects. Defaults to false.', }, { displayName: 'Starts On', @@ -596,5 +572,4 @@ export const projectFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Harvest/TaskDescription.ts b/packages/nodes-base/nodes/Harvest/TaskDescription.ts index 9b869bca5d..3f5c042c8d 100644 --- a/packages/nodes-base/nodes/Harvest/TaskDescription.ts +++ b/packages/nodes-base/nodes/Harvest/TaskDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -const resource = [ - 'task', -]; +const resource = ['task']; export const taskOperations: INodeProperties[] = [ { @@ -51,11 +47,9 @@ export const taskOperations: INodeProperties[] = [ ], default: 'getAll', }, - ]; export const taskFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* task:getAll */ /* -------------------------------------------------------------------------- */ @@ -66,9 +60,7 @@ export const taskFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: false, @@ -81,12 +73,8 @@ export const taskFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -105,9 +93,7 @@ export const taskFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, options: [ @@ -149,9 +135,7 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], resource, }, }, @@ -169,9 +153,7 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], resource, }, }, @@ -187,9 +169,7 @@ export const taskFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -204,9 +184,7 @@ export const taskFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -217,14 +195,16 @@ export const taskFields: INodeProperties[] = [ name: 'billable_by_default', type: 'boolean', default: true, - description: 'Whether default tasks should be marked billable when creating a new project. Defaults to true.', + description: + 'Whether default tasks should be marked billable when creating a new project. Defaults to true.', }, { displayName: 'Default Hourly Rate', name: 'default_hourly_rate', type: 'number', default: 0, - description: 'The default hourly rate to use for this task when it is added to a project. Defaults to 0.', + description: + 'The default hourly rate to use for this task when it is added to a project. Defaults to 0.', }, { displayName: 'Is Active', @@ -238,7 +218,8 @@ export const taskFields: INodeProperties[] = [ name: 'is_default', type: 'boolean', default: false, - description: 'Whether this task should be automatically added to future projects. Defaults to false.', + description: + 'Whether this task should be automatically added to future projects. Defaults to false.', }, ], }, @@ -254,9 +235,7 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -269,28 +248,27 @@ export const taskFields: INodeProperties[] = [ placeholder: 'Update Field', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, default: {}, options: [ - { displayName: 'Billable By Default', name: 'billable_by_default', type: 'boolean', default: false, - description: 'Whether default tasks should be marked billable when creating a new project. Defaults to true.', + description: + 'Whether default tasks should be marked billable when creating a new project. Defaults to true.', }, { displayName: 'Default Hourly Rate', name: 'default_hourly_rate', type: 'number', default: 0, - description: 'The default hourly rate to use for this task when it is added to a project. Defaults to 0.', + description: + 'The default hourly rate to use for this task when it is added to a project. Defaults to 0.', }, { displayName: 'Is Active', @@ -304,7 +282,8 @@ export const taskFields: INodeProperties[] = [ name: 'is_default', type: 'boolean', default: false, - description: 'Whether this task should be automatically added to future projects. Defaults to false.', + description: + 'Whether this task should be automatically added to future projects. Defaults to false.', }, { displayName: 'Name', @@ -315,6 +294,4 @@ export const taskFields: INodeProperties[] = [ }, ], }, - - ]; diff --git a/packages/nodes-base/nodes/Harvest/TimeEntryDescription.ts b/packages/nodes-base/nodes/Harvest/TimeEntryDescription.ts index 009290c3ca..5ce9dca120 100644 --- a/packages/nodes-base/nodes/Harvest/TimeEntryDescription.ts +++ b/packages/nodes-base/nodes/Harvest/TimeEntryDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -export const resource = [ - 'timeEntry', -]; +export const resource = ['timeEntry']; export const timeEntryOperations: INodeProperties[] = [ { @@ -89,9 +85,7 @@ export const timeEntryFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: false, @@ -104,12 +98,8 @@ export const timeEntryFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -128,9 +118,7 @@ export const timeEntryFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, options: [ @@ -153,14 +141,16 @@ export const timeEntryFields: INodeProperties[] = [ name: 'is_billed', type: 'boolean', default: true, - description: 'Whether to only return time entries that have been invoiced and false to return time entries that have not been invoiced', + description: + 'Whether to only return time entries that have been invoiced and false to return time entries that have not been invoiced', }, { displayName: 'Is Running', name: 'is_running', type: 'boolean', default: true, - description: 'Whether to only return running time entries and false to return non-running time entries', + description: + 'Whether to only return running time entries and false to return non-running time entries', }, { displayName: 'Page', @@ -170,7 +160,8 @@ export const timeEntryFields: INodeProperties[] = [ minValue: 1, }, default: 1, - description: 'The page number to use in pagination. For instance, if you make a list request and receive 100 records, your subsequent call can include page=2 to retrieve the next page of the list. (Default: 1)', + description: + 'The page number to use in pagination. For instance, if you make a list request and receive 100 records, your subsequent call can include page=2 to retrieve the next page of the list. (Default: 1)', }, { displayName: 'To', @@ -184,7 +175,8 @@ export const timeEntryFields: INodeProperties[] = [ name: 'updated_since', type: 'dateTime', default: '', - description: 'Only return time entries that have been updated since the given date and time', + description: + 'Only return time entries that have been updated since the given date and time', }, { displayName: 'User ID', @@ -207,9 +199,7 @@ export const timeEntryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], resource, }, }, @@ -227,9 +217,7 @@ export const timeEntryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], resource, }, }, @@ -247,9 +235,7 @@ export const timeEntryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'deleteExternal', - ], + operation: ['deleteExternal'], resource, }, }, @@ -267,13 +253,12 @@ export const timeEntryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'stopTime', - ], + operation: ['stopTime'], resource, }, }, - description: 'Stop a running time entry. Stopping a time entry is only possible if it’s currently running.', + description: + 'Stop a running time entry. Stopping a time entry is only possible if it’s currently running.', }, /* -------------------------------------------------------------------------- */ @@ -287,13 +272,12 @@ export const timeEntryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'restartTime', - ], + operation: ['restartTime'], resource, }, }, - description: 'Restart a stopped time entry. Restarting a time entry is only possible if it isn’t currently running.', + description: + 'Restart a stopped time entry. Restarting a time entry is only possible if it isn’t currently running.', }, /* -------------------------------------------------------------------------- */ @@ -307,9 +291,7 @@ export const timeEntryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -322,9 +304,7 @@ export const timeEntryFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -375,9 +355,7 @@ export const timeEntryFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'createByDuration', - ], + operation: ['createByDuration'], resource, }, }, @@ -391,9 +369,7 @@ export const timeEntryFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'createByDuration', - ], + operation: ['createByDuration'], resource, }, }, @@ -407,9 +383,7 @@ export const timeEntryFields: INodeProperties[] = [ type: 'dateTime', displayOptions: { show: { - operation: [ - 'createByDuration', - ], + operation: ['createByDuration'], resource, }, }, @@ -424,9 +398,7 @@ export const timeEntryFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'createByDuration', - ], + operation: ['createByDuration'], resource, }, }, @@ -454,7 +426,8 @@ export const timeEntryFields: INodeProperties[] = [ name: 'user_id', type: 'string', default: '', - description: 'The ID of the user to associate with the time entry. Defaults to the currently authenticated user’s ID.', + description: + 'The ID of the user to associate with the time entry. Defaults to the currently authenticated user’s ID.', }, ], }, @@ -468,9 +441,7 @@ export const timeEntryFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'createByStartEnd', - ], + operation: ['createByStartEnd'], resource, }, }, @@ -484,9 +455,7 @@ export const timeEntryFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'createByStartEnd', - ], + operation: ['createByStartEnd'], resource, }, }, @@ -500,9 +469,7 @@ export const timeEntryFields: INodeProperties[] = [ type: 'dateTime', displayOptions: { show: { - operation: [ - 'createByStartEnd', - ], + operation: ['createByStartEnd'], resource, }, }, @@ -517,9 +484,7 @@ export const timeEntryFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'createByStartEnd', - ], + operation: ['createByStartEnd'], resource, }, }, @@ -553,11 +518,9 @@ export const timeEntryFields: INodeProperties[] = [ name: 'user_id', type: 'string', default: '', - description: 'The ID of the user to associate with the time entry. Defaults to the currently authenticated user’s ID.', + description: + 'The ID of the user to associate with the time entry. Defaults to the currently authenticated user’s ID.', }, ], }, - - - ]; diff --git a/packages/nodes-base/nodes/Harvest/UserDescription.ts b/packages/nodes-base/nodes/Harvest/UserDescription.ts index 25d34d4117..3b4493d1b9 100644 --- a/packages/nodes-base/nodes/Harvest/UserDescription.ts +++ b/packages/nodes-base/nodes/Harvest/UserDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -const resource = [ - 'user', -]; +const resource = ['user']; export const userOperations: INodeProperties[] = [ { @@ -58,11 +54,9 @@ export const userOperations: INodeProperties[] = [ ], default: 'me', }, - ]; export const userFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* user:getAll */ /* -------------------------------------------------------------------------- */ @@ -74,9 +68,7 @@ export const userFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: false, @@ -89,12 +81,8 @@ export const userFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -113,9 +101,7 @@ export const userFields: INodeProperties[] = [ displayOptions: { show: { resource, - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, options: [ @@ -157,9 +143,7 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], resource, }, }, @@ -177,9 +161,7 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], resource, }, }, @@ -195,9 +177,7 @@ export const userFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -211,9 +191,7 @@ export const userFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -228,9 +206,7 @@ export const userFields: INodeProperties[] = [ placeholder: 'name@email.com', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -245,9 +221,7 @@ export const userFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], resource, }, }, @@ -272,7 +246,8 @@ export const userFields: INodeProperties[] = [ name: 'can_see_rates', type: 'boolean', default: false, - description: 'Whether the user can see billable rates on projects. Only applicable to Project Managers.', + description: + 'Whether the user can see billable rates on projects. Only applicable to Project Managers.', }, { displayName: 'Cost Rate', @@ -282,7 +257,8 @@ export const userFields: INodeProperties[] = [ minValue: 0, }, default: 0, - description: 'The cost rate to use for this user when calculating a project’s costs vs billable amount', + description: + 'The cost rate to use for this user when calculating a project’s costs vs billable amount', }, { displayName: 'Default Hourly Rate', @@ -339,7 +315,8 @@ export const userFields: INodeProperties[] = [ type: 'string', default: '', // eslint-disable-next-line n8n-nodes-base/node-param-description-url-missing-protocol - description: 'The user’s timezone. Defaults to the company’s timezone. See a list of supported time zones.', + description: + 'The user’s timezone. Defaults to the company’s timezone. See a list of supported time zones.', }, { displayName: 'Weekly Capacity', @@ -349,7 +326,8 @@ export const userFields: INodeProperties[] = [ minValue: 0, }, default: 126000, - description: 'The number of hours per week this person is available to work in seconds. Defaults to 126000 seconds (35 hours).', + description: + 'The number of hours per week this person is available to work in seconds. Defaults to 126000 seconds (35 hours).', }, ], }, @@ -365,9 +343,7 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -380,9 +356,7 @@ export const userFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], resource, }, }, @@ -407,7 +381,8 @@ export const userFields: INodeProperties[] = [ name: 'can_see_rates', type: 'boolean', default: false, - description: 'Whether the user can see billable rates on projects. Only applicable to Project Managers.', + description: + 'Whether the user can see billable rates on projects. Only applicable to Project Managers.', }, { displayName: 'Cost Rate', @@ -417,7 +392,8 @@ export const userFields: INodeProperties[] = [ minValue: 0, }, default: 0, - description: 'The cost rate to use for this user when calculating a project’s costs vs billable amount', + description: + 'The cost rate to use for this user when calculating a project’s costs vs billable amount', }, { displayName: 'Default Hourly Rate', @@ -496,7 +472,8 @@ export const userFields: INodeProperties[] = [ type: 'string', default: '', // eslint-disable-next-line n8n-nodes-base/node-param-description-url-missing-protocol - description: 'The user’s timezone. Defaults to the company’s timezone. See a list of supported time zones.', + description: + 'The user’s timezone. Defaults to the company’s timezone. See a list of supported time zones.', }, { displayName: 'Weekly Capacity', @@ -506,9 +483,9 @@ export const userFields: INodeProperties[] = [ minValue: 0, }, default: 126000, - description: 'The number of hours per week this person is available to work in seconds. Defaults to 126000 seconds (35 hours).', + description: + 'The number of hours per week this person is available to work in seconds. Defaults to 126000 seconds (35 hours).', }, ], }, - ]; diff --git a/packages/nodes-base/nodes/HelpScout/ConversationDescription.ts b/packages/nodes-base/nodes/HelpScout/ConversationDescription.ts index 81ee5415e2..856e33345e 100644 --- a/packages/nodes-base/nodes/HelpScout/ConversationDescription.ts +++ b/packages/nodes-base/nodes/HelpScout/ConversationDescription.ts @@ -8,9 +8,7 @@ export const conversationOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'conversation', - ], + resource: ['conversation'], }, }, options: [ @@ -44,9 +42,9 @@ export const conversationOperations: INodeProperties[] = [ ]; export const conversationFields: INodeProperties[] = [ -/* -------------------------------------------------------------------------- */ -/* conversation:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* conversation:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Mailbox Name or ID', name: 'mailboxId', @@ -57,16 +55,13 @@ export const conversationFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'conversation', - ], + operation: ['create'], + resource: ['conversation'], }, }, default: '', - description: 'ID of a mailbox where the conversation is being created. Choose from the list, or specify an ID using an expression.', + description: + 'ID of a mailbox where the conversation is being created. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Status', @@ -89,12 +84,8 @@ export const conversationFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'conversation', - ], + operation: ['create'], + resource: ['conversation'], }, }, default: '', @@ -110,12 +101,8 @@ export const conversationFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'conversation', - ], + operation: ['create'], + resource: ['conversation'], }, }, default: '', @@ -142,12 +129,8 @@ export const conversationFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'conversation', - ], + operation: ['create'], + resource: ['conversation'], }, }, default: '', @@ -160,16 +143,13 @@ export const conversationFields: INodeProperties[] = [ default: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'conversation', - ], + operation: ['create'], + resource: ['conversation'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default the response only contain the ID to resource. If this option gets activated, it will resolve the data automatically.', + description: + 'By default the response only contain the ID to resource. If this option gets activated, it will resolve the data automatically.', }, { displayName: 'Additional Fields', @@ -179,12 +159,8 @@ export const conversationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'conversation', - ], + operation: ['create'], + resource: ['conversation'], }, }, options: [ @@ -200,7 +176,8 @@ export const conversationFields: INodeProperties[] = [ name: 'autoReply', type: 'boolean', default: false, - description: 'Whether set to true, an auto reply will be sent as long as there is at least one customer thread in the conversation', + description: + 'Whether set to true, an auto reply will be sent as long as there is at least one customer thread in the conversation', }, { displayName: 'Closed At', @@ -243,7 +220,8 @@ export const conversationFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'List of tags to be added to the conversation. Choose from the list, or specify IDs using an expression.', + description: + 'List of tags to be added to the conversation. Choose from the list, or specify IDs using an expression.', }, { displayName: 'User ID', @@ -264,12 +242,8 @@ export const conversationFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'conversation', - ], + operation: ['create'], + resource: ['conversation'], }, }, default: {}, @@ -321,9 +295,7 @@ export const conversationFields: INodeProperties[] = [ name: 'bcc', displayOptions: { show: { - type: [ - 'customer', - ], + type: ['customer'], }, }, type: 'string', @@ -339,9 +311,7 @@ export const conversationFields: INodeProperties[] = [ name: 'cc', displayOptions: { show: { - type: [ - 'customer', - ], + type: ['customer'], }, }, type: 'string', @@ -357,9 +327,7 @@ export const conversationFields: INodeProperties[] = [ name: 'draft', displayOptions: { show: { - type: [ - 'reply', - ], + type: ['reply'], }, }, type: 'boolean', @@ -370,9 +338,9 @@ export const conversationFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* conversation:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* conversation:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Conversation ID', name: 'conversationId', @@ -381,18 +349,14 @@ export const conversationFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'conversation', - ], - operation: [ - 'get', - ], + resource: ['conversation'], + operation: ['get'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* conversation:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* conversation:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Conversation ID', name: 'conversationId', @@ -401,30 +365,22 @@ export const conversationFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'conversation', - ], - operation: [ - 'delete', - ], + resource: ['conversation'], + operation: ['delete'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* conversation:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* conversation:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'conversation', - ], + operation: ['getAll'], + resource: ['conversation'], }, }, default: false, @@ -436,15 +392,9 @@ export const conversationFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'conversation', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['conversation'], + returnAll: [false], }, }, typeOptions: { @@ -461,12 +411,8 @@ export const conversationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'conversation', - ], - operation: [ - 'getAll', - ], + resource: ['conversation'], + operation: ['getAll'], }, }, options: [ @@ -529,7 +475,8 @@ export const conversationFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'Advanced search Examples', + description: + 'Advanced search Examples', }, { displayName: 'Sort Field', @@ -633,7 +580,8 @@ export const conversationFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'Filter conversation by tags. Choose from the list, or specify IDs using an expression.', + description: + 'Filter conversation by tags. Choose from the list, or specify IDs using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/HelpScout/CountriesCodes.ts b/packages/nodes-base/nodes/HelpScout/CountriesCodes.ts index 4c37abc6b3..b73da14ec9 100644 --- a/packages/nodes-base/nodes/HelpScout/CountriesCodes.ts +++ b/packages/nodes-base/nodes/HelpScout/CountriesCodes.ts @@ -1,1579 +1,1579 @@ export const countriesCodes = [ { - 'name': 'Afghanistan', - 'alpha2': 'AF', - 'alpha3': 'AFG', - 'numeric': '004', + name: 'Afghanistan', + alpha2: 'AF', + alpha3: 'AFG', + numeric: '004', }, { - 'name': 'Åland Islands', - 'alpha2': 'AX', - 'alpha3': 'ALA', - 'numeric': '248', - 'altName': 'Aland Islands', + name: 'Åland Islands', + alpha2: 'AX', + alpha3: 'ALA', + numeric: '248', + altName: 'Aland Islands', }, { - 'name': 'Albania', - 'alpha2': 'AL', - 'alpha3': 'ALB', - 'numeric': '008', + name: 'Albania', + alpha2: 'AL', + alpha3: 'ALB', + numeric: '008', }, { - 'name': 'Algeria', - 'alpha2': 'DZ', - 'alpha3': 'DZA', - 'numeric': '012', + name: 'Algeria', + alpha2: 'DZ', + alpha3: 'DZA', + numeric: '012', }, { - 'name': 'American Samoa', - 'alpha2': 'AS', - 'alpha3': 'ASM', - 'numeric': '016', + name: 'American Samoa', + alpha2: 'AS', + alpha3: 'ASM', + numeric: '016', }, { - 'name': 'Andorra', - 'alpha2': 'AD', - 'alpha3': 'AND', - 'numeric': '020', + name: 'Andorra', + alpha2: 'AD', + alpha3: 'AND', + numeric: '020', }, { - 'name': 'Angola', - 'alpha2': 'AO', - 'alpha3': 'AGO', - 'numeric': '024', + name: 'Angola', + alpha2: 'AO', + alpha3: 'AGO', + numeric: '024', }, { - 'name': 'Anguilla', - 'alpha2': 'AI', - 'alpha3': 'AIA', - 'numeric': '660', + name: 'Anguilla', + alpha2: 'AI', + alpha3: 'AIA', + numeric: '660', }, { - 'name': 'Antarctica', - 'alpha2': 'AQ', - 'alpha3': 'ATA', - 'numeric': '010', + name: 'Antarctica', + alpha2: 'AQ', + alpha3: 'ATA', + numeric: '010', }, { - 'name': 'Antigua and Barbuda', - 'alpha2': 'AG', - 'alpha3': 'ATG', - 'numeric': '028', + name: 'Antigua and Barbuda', + alpha2: 'AG', + alpha3: 'ATG', + numeric: '028', }, { - 'name': 'Argentina', - 'alpha2': 'AR', - 'alpha3': 'ARG', - 'numeric': '032', + name: 'Argentina', + alpha2: 'AR', + alpha3: 'ARG', + numeric: '032', }, { - 'name': 'Armenia', - 'alpha2': 'AM', - 'alpha3': 'ARM', - 'numeric': '051', + name: 'Armenia', + alpha2: 'AM', + alpha3: 'ARM', + numeric: '051', }, { - 'name': 'Aruba', - 'alpha2': 'AW', - 'alpha3': 'ABW', - 'numeric': '533', + name: 'Aruba', + alpha2: 'AW', + alpha3: 'ABW', + numeric: '533', }, { - 'name': 'Australia', - 'alpha2': 'AU', - 'alpha3': 'AUS', - 'numeric': '036', + name: 'Australia', + alpha2: 'AU', + alpha3: 'AUS', + numeric: '036', }, { - 'name': 'Austria', - 'alpha2': 'AT', - 'alpha3': 'AUT', - 'numeric': '040', + name: 'Austria', + alpha2: 'AT', + alpha3: 'AUT', + numeric: '040', }, { - 'name': 'Azerbaijan', - 'alpha2': 'AZ', - 'alpha3': 'AZE', - 'numeric': '031', + name: 'Azerbaijan', + alpha2: 'AZ', + alpha3: 'AZE', + numeric: '031', }, { - 'name': 'Bahamas (the)', - 'alpha2': 'BS', - 'alpha3': 'BHS', - 'numeric': '044', - 'altName': 'Bahamas', + name: 'Bahamas (the)', + alpha2: 'BS', + alpha3: 'BHS', + numeric: '044', + altName: 'Bahamas', }, { - 'name': 'Bahrain', - 'alpha2': 'BH', - 'alpha3': 'BHR', - 'numeric': '048', + name: 'Bahrain', + alpha2: 'BH', + alpha3: 'BHR', + numeric: '048', }, { - 'name': 'Bangladesh', - 'alpha2': 'BD', - 'alpha3': 'BGD', - 'numeric': '050', + name: 'Bangladesh', + alpha2: 'BD', + alpha3: 'BGD', + numeric: '050', }, { - 'name': 'Barbados', - 'alpha2': 'BB', - 'alpha3': 'BRB', - 'numeric': '052', + name: 'Barbados', + alpha2: 'BB', + alpha3: 'BRB', + numeric: '052', }, { - 'name': 'Belarus', - 'alpha2': 'BY', - 'alpha3': 'BLR', - 'numeric': '112', + name: 'Belarus', + alpha2: 'BY', + alpha3: 'BLR', + numeric: '112', }, { - 'name': 'Belgium', - 'alpha2': 'BE', - 'alpha3': 'BEL', - 'numeric': '056', + name: 'Belgium', + alpha2: 'BE', + alpha3: 'BEL', + numeric: '056', }, { - 'name': 'Belize', - 'alpha2': 'BZ', - 'alpha3': 'BLZ', - 'numeric': '084', + name: 'Belize', + alpha2: 'BZ', + alpha3: 'BLZ', + numeric: '084', }, { - 'name': 'Benin', - 'alpha2': 'BJ', - 'alpha3': 'BEN', - 'numeric': '204', + name: 'Benin', + alpha2: 'BJ', + alpha3: 'BEN', + numeric: '204', }, { - 'name': 'Bermuda', - 'alpha2': 'BM', - 'alpha3': 'BMU', - 'numeric': '060', + name: 'Bermuda', + alpha2: 'BM', + alpha3: 'BMU', + numeric: '060', }, { - 'name': 'Bhutan', - 'alpha2': 'BT', - 'alpha3': 'BTN', - 'numeric': '064', + name: 'Bhutan', + alpha2: 'BT', + alpha3: 'BTN', + numeric: '064', }, { - 'name': 'Bolivia (Plurinational State of)', - 'alpha2': 'BO', - 'alpha3': 'BOL', - 'numeric': '068', - 'altName': 'Bolivia', + name: 'Bolivia (Plurinational State of)', + alpha2: 'BO', + alpha3: 'BOL', + numeric: '068', + altName: 'Bolivia', }, { - 'name': 'Bonaire, Sint Eustatius and Saba', - 'alpha2': 'BQ', - 'alpha3': 'BES', - 'numeric': '535', + name: 'Bonaire, Sint Eustatius and Saba', + alpha2: 'BQ', + alpha3: 'BES', + numeric: '535', }, { - 'name': 'Bosnia and Herzegovina', - 'alpha2': 'BA', - 'alpha3': 'BIH', - 'numeric': '070', + name: 'Bosnia and Herzegovina', + alpha2: 'BA', + alpha3: 'BIH', + numeric: '070', }, { - 'name': 'Botswana', - 'alpha2': 'BW', - 'alpha3': 'BWA', - 'numeric': '072', + name: 'Botswana', + alpha2: 'BW', + alpha3: 'BWA', + numeric: '072', }, { - 'name': 'Bouvet Island', - 'alpha2': 'BV', - 'alpha3': 'BVT', - 'numeric': '074', + name: 'Bouvet Island', + alpha2: 'BV', + alpha3: 'BVT', + numeric: '074', }, { - 'name': 'Brazil', - 'alpha2': 'BR', - 'alpha3': 'BRA', - 'numeric': '076', + name: 'Brazil', + alpha2: 'BR', + alpha3: 'BRA', + numeric: '076', }, { - 'name': 'British Indian Ocean Territory (the)', - 'alpha2': 'IO', - 'alpha3': 'IOT', - 'numeric': '086', - 'altName': 'British Indian Ocean Territory', + name: 'British Indian Ocean Territory (the)', + alpha2: 'IO', + alpha3: 'IOT', + numeric: '086', + altName: 'British Indian Ocean Territory', }, { - 'name': 'Brunei Darussalam', - 'alpha2': 'BN', - 'alpha3': 'BRN', - 'numeric': '096', - 'shortName': 'Brunei', + name: 'Brunei Darussalam', + alpha2: 'BN', + alpha3: 'BRN', + numeric: '096', + shortName: 'Brunei', }, { - 'name': 'Bulgaria', - 'alpha2': 'BG', - 'alpha3': 'BGR', - 'numeric': '100', + name: 'Bulgaria', + alpha2: 'BG', + alpha3: 'BGR', + numeric: '100', }, { - 'name': 'Burkina Faso', - 'alpha2': 'BF', - 'alpha3': 'BFA', - 'numeric': '854', + name: 'Burkina Faso', + alpha2: 'BF', + alpha3: 'BFA', + numeric: '854', }, { - 'name': 'Burundi', - 'alpha2': 'BI', - 'alpha3': 'BDI', - 'numeric': '108', + name: 'Burundi', + alpha2: 'BI', + alpha3: 'BDI', + numeric: '108', }, { - 'name': 'Cabo Verde', - 'alpha2': 'CV', - 'alpha3': 'CPV', - 'numeric': '132', - 'altName': 'Cape Verde', + name: 'Cabo Verde', + alpha2: 'CV', + alpha3: 'CPV', + numeric: '132', + altName: 'Cape Verde', }, { - 'name': 'Cambodia', - 'alpha2': 'KH', - 'alpha3': 'KHM', - 'numeric': '116', + name: 'Cambodia', + alpha2: 'KH', + alpha3: 'KHM', + numeric: '116', }, { - 'name': 'Cameroon', - 'alpha2': 'CM', - 'alpha3': 'CMR', - 'numeric': '120', + name: 'Cameroon', + alpha2: 'CM', + alpha3: 'CMR', + numeric: '120', }, { - 'name': 'Canada', - 'alpha2': 'CA', - 'alpha3': 'CAN', - 'numeric': '124', + name: 'Canada', + alpha2: 'CA', + alpha3: 'CAN', + numeric: '124', }, { - 'name': 'Cayman Islands (the)', - 'alpha2': 'KY', - 'alpha3': 'CYM', - 'numeric': '136', - 'altName': 'Cayman Islands', + name: 'Cayman Islands (the)', + alpha2: 'KY', + alpha3: 'CYM', + numeric: '136', + altName: 'Cayman Islands', }, { - 'name': 'Central African Republic (the)', - 'alpha2': 'CF', - 'alpha3': 'CAF', - 'numeric': '140', - 'altName': 'Central African Republic', + name: 'Central African Republic (the)', + alpha2: 'CF', + alpha3: 'CAF', + numeric: '140', + altName: 'Central African Republic', }, { - 'name': 'Chad', - 'alpha2': 'TD', - 'alpha3': 'TCD', - 'numeric': '148', + name: 'Chad', + alpha2: 'TD', + alpha3: 'TCD', + numeric: '148', }, { - 'name': 'Chile', - 'alpha2': 'CL', - 'alpha3': 'CHL', - 'numeric': '152', + name: 'Chile', + alpha2: 'CL', + alpha3: 'CHL', + numeric: '152', }, { - 'name': 'China', - 'alpha2': 'CN', - 'alpha3': 'CHN', - 'numeric': '156', + name: 'China', + alpha2: 'CN', + alpha3: 'CHN', + numeric: '156', }, { - 'name': 'Christmas Island', - 'alpha2': 'CX', - 'alpha3': 'CXR', - 'numeric': '162', + name: 'Christmas Island', + alpha2: 'CX', + alpha3: 'CXR', + numeric: '162', }, { - 'name': 'Cocos (Keeling) Islands (the)', - 'alpha2': 'CC', - 'alpha3': 'CCK', - 'numeric': '166', - 'altName': 'Cocos (Keeling) Islands', - 'shortName': 'Cocos Islands', + name: 'Cocos (Keeling) Islands (the)', + alpha2: 'CC', + alpha3: 'CCK', + numeric: '166', + altName: 'Cocos (Keeling) Islands', + shortName: 'Cocos Islands', }, { - 'name': 'Colombia', - 'alpha2': 'CO', - 'alpha3': 'COL', - 'numeric': '170', + name: 'Colombia', + alpha2: 'CO', + alpha3: 'COL', + numeric: '170', }, { - 'name': 'Comoros (the)', - 'alpha2': 'KM', - 'alpha3': 'COM', - 'numeric': '174', - 'altName': 'Comoros', + name: 'Comoros (the)', + alpha2: 'KM', + alpha3: 'COM', + numeric: '174', + altName: 'Comoros', }, { - 'name': 'Congo (the Democratic Republic of the)', - 'alpha2': 'CD', - 'alpha3': 'COD', - 'numeric': '180', - 'altName': 'Congo, (Kinshasa)', - 'shortName': 'Democratic Republic of the Congo', + name: 'Congo (the Democratic Republic of the)', + alpha2: 'CD', + alpha3: 'COD', + numeric: '180', + altName: 'Congo, (Kinshasa)', + shortName: 'Democratic Republic of the Congo', }, { - 'name': 'Congo (the)', - 'alpha2': 'CG', - 'alpha3': 'COG', - 'numeric': '178', - 'altName': 'Congo (Brazzaville)', - 'shortName': 'Republic of the Congo', + name: 'Congo (the)', + alpha2: 'CG', + alpha3: 'COG', + numeric: '178', + altName: 'Congo (Brazzaville)', + shortName: 'Republic of the Congo', }, { - 'name': 'Cook Islands (the)', - 'alpha2': 'CK', - 'alpha3': 'COK', - 'numeric': '184', - 'altName': 'Cook Islands', + name: 'Cook Islands (the)', + alpha2: 'CK', + alpha3: 'COK', + numeric: '184', + altName: 'Cook Islands', }, { - 'name': 'Costa Rica', - 'alpha2': 'CR', - 'alpha3': 'CRI', - 'numeric': '188', + name: 'Costa Rica', + alpha2: 'CR', + alpha3: 'CRI', + numeric: '188', }, { - 'name': 'Côte d\'Ivoire', - 'alpha2': 'CI', - 'alpha3': 'CIV', - 'numeric': '384', - 'shortName': 'Ivory Coast', + name: "Côte d'Ivoire", + alpha2: 'CI', + alpha3: 'CIV', + numeric: '384', + shortName: 'Ivory Coast', }, { - 'name': 'Croatia', - 'alpha2': 'HR', - 'alpha3': 'HRV', - 'numeric': '191', + name: 'Croatia', + alpha2: 'HR', + alpha3: 'HRV', + numeric: '191', }, { - 'name': 'Cuba', - 'alpha2': 'CU', - 'alpha3': 'CUB', - 'numeric': '192', + name: 'Cuba', + alpha2: 'CU', + alpha3: 'CUB', + numeric: '192', }, { - 'name': 'Curaçao', - 'alpha2': 'CW', - 'alpha3': 'CUW', - 'numeric': '531', - 'shortName': 'Curacao', + name: 'Curaçao', + alpha2: 'CW', + alpha3: 'CUW', + numeric: '531', + shortName: 'Curacao', }, { - 'name': 'Cyprus', - 'alpha2': 'CY', - 'alpha3': 'CYP', - 'numeric': '196', + name: 'Cyprus', + alpha2: 'CY', + alpha3: 'CYP', + numeric: '196', }, { - 'name': 'Czechia', - 'alpha2': 'CZ', - 'alpha3': 'CZE', - 'numeric': '203', - 'altName': 'Czech Republic', + name: 'Czechia', + alpha2: 'CZ', + alpha3: 'CZE', + numeric: '203', + altName: 'Czech Republic', }, { - 'name': 'Denmark', - 'alpha2': 'DK', - 'alpha3': 'DNK', - 'numeric': '208', + name: 'Denmark', + alpha2: 'DK', + alpha3: 'DNK', + numeric: '208', }, { - 'name': 'Djibouti', - 'alpha2': 'DJ', - 'alpha3': 'DJI', - 'numeric': '262', + name: 'Djibouti', + alpha2: 'DJ', + alpha3: 'DJI', + numeric: '262', }, { - 'name': 'Dominica', - 'alpha2': 'DM', - 'alpha3': 'DMA', - 'numeric': '212', + name: 'Dominica', + alpha2: 'DM', + alpha3: 'DMA', + numeric: '212', }, { - 'name': 'Dominican Republic (the)', - 'alpha2': 'DO', - 'alpha3': 'DOM', - 'numeric': '214', - 'altName': 'Dominican Republic', + name: 'Dominican Republic (the)', + alpha2: 'DO', + alpha3: 'DOM', + numeric: '214', + altName: 'Dominican Republic', }, { - 'name': 'Ecuador', - 'alpha2': 'EC', - 'alpha3': 'ECU', - 'numeric': '218', + name: 'Ecuador', + alpha2: 'EC', + alpha3: 'ECU', + numeric: '218', }, { - 'name': 'Egypt', - 'alpha2': 'EG', - 'alpha3': 'EGY', - 'numeric': '818', + name: 'Egypt', + alpha2: 'EG', + alpha3: 'EGY', + numeric: '818', }, { - 'name': 'El Salvador', - 'alpha2': 'SV', - 'alpha3': 'SLV', - 'numeric': '222', + name: 'El Salvador', + alpha2: 'SV', + alpha3: 'SLV', + numeric: '222', }, { - 'name': 'Equatorial Guinea', - 'alpha2': 'GQ', - 'alpha3': 'GNQ', - 'numeric': '226', + name: 'Equatorial Guinea', + alpha2: 'GQ', + alpha3: 'GNQ', + numeric: '226', }, { - 'name': 'Eritrea', - 'alpha2': 'ER', - 'alpha3': 'ERI', - 'numeric': '232', + name: 'Eritrea', + alpha2: 'ER', + alpha3: 'ERI', + numeric: '232', }, { - 'name': 'Estonia', - 'alpha2': 'EE', - 'alpha3': 'EST', - 'numeric': '233', + name: 'Estonia', + alpha2: 'EE', + alpha3: 'EST', + numeric: '233', }, { - 'name': 'Ethiopia', - 'alpha2': 'ET', - 'alpha3': 'ETH', - 'numeric': '231', + name: 'Ethiopia', + alpha2: 'ET', + alpha3: 'ETH', + numeric: '231', }, { - 'name': 'Falkland Islands (the) [Malvinas]', - 'alpha2': 'FK', - 'alpha3': 'FLK', - 'numeric': '238', - 'altName': 'Falkland Islands (Malvinas)', - 'shortName': 'Falkland Islands', + name: 'Falkland Islands (the) [Malvinas]', + alpha2: 'FK', + alpha3: 'FLK', + numeric: '238', + altName: 'Falkland Islands (Malvinas)', + shortName: 'Falkland Islands', }, { - 'name': 'Faroe Islands (the)', - 'alpha2': 'FO', - 'alpha3': 'FRO', - 'numeric': '234', - 'altName': 'Faroe Islands', + name: 'Faroe Islands (the)', + alpha2: 'FO', + alpha3: 'FRO', + numeric: '234', + altName: 'Faroe Islands', }, { - 'name': 'Fiji', - 'alpha2': 'FJ', - 'alpha3': 'FJI', - 'numeric': '242', + name: 'Fiji', + alpha2: 'FJ', + alpha3: 'FJI', + numeric: '242', }, { - 'name': 'Finland', - 'alpha2': 'FI', - 'alpha3': 'FIN', - 'numeric': '246', + name: 'Finland', + alpha2: 'FI', + alpha3: 'FIN', + numeric: '246', }, { - 'name': 'France', - 'alpha2': 'FR', - 'alpha3': 'FRA', - 'numeric': '250', + name: 'France', + alpha2: 'FR', + alpha3: 'FRA', + numeric: '250', }, { - 'name': 'French Guiana', - 'alpha2': 'GF', - 'alpha3': 'GUF', - 'numeric': '254', + name: 'French Guiana', + alpha2: 'GF', + alpha3: 'GUF', + numeric: '254', }, { - 'name': 'French Polynesia', - 'alpha2': 'PF', - 'alpha3': 'PYF', - 'numeric': '258', + name: 'French Polynesia', + alpha2: 'PF', + alpha3: 'PYF', + numeric: '258', }, { - 'name': 'French Southern Territories (the)', - 'alpha2': 'TF', - 'alpha3': 'ATF', - 'numeric': '260', - 'altName': 'French Southern Territories', + name: 'French Southern Territories (the)', + alpha2: 'TF', + alpha3: 'ATF', + numeric: '260', + altName: 'French Southern Territories', }, { - 'name': 'Gabon', - 'alpha2': 'GA', - 'alpha3': 'GAB', - 'numeric': '266', + name: 'Gabon', + alpha2: 'GA', + alpha3: 'GAB', + numeric: '266', }, { - 'name': 'Gambia (the)', - 'alpha2': 'GM', - 'alpha3': 'GMB', - 'numeric': '270', - 'altName': 'Gambia', + name: 'Gambia (the)', + alpha2: 'GM', + alpha3: 'GMB', + numeric: '270', + altName: 'Gambia', }, { - 'name': 'Georgia', - 'alpha2': 'GE', - 'alpha3': 'GEO', - 'numeric': '268', + name: 'Georgia', + alpha2: 'GE', + alpha3: 'GEO', + numeric: '268', }, { - 'name': 'Germany', - 'alpha2': 'DE', - 'alpha3': 'DEU', - 'numeric': '276', + name: 'Germany', + alpha2: 'DE', + alpha3: 'DEU', + numeric: '276', }, { - 'name': 'Ghana', - 'alpha2': 'GH', - 'alpha3': 'GHA', - 'numeric': '288', + name: 'Ghana', + alpha2: 'GH', + alpha3: 'GHA', + numeric: '288', }, { - 'name': 'Gibraltar', - 'alpha2': 'GI', - 'alpha3': 'GIB', - 'numeric': '292', + name: 'Gibraltar', + alpha2: 'GI', + alpha3: 'GIB', + numeric: '292', }, { - 'name': 'Greece', - 'alpha2': 'GR', - 'alpha3': 'GRC', - 'numeric': '300', + name: 'Greece', + alpha2: 'GR', + alpha3: 'GRC', + numeric: '300', }, { - 'name': 'Greenland', - 'alpha2': 'GL', - 'alpha3': 'GRL', - 'numeric': '304', + name: 'Greenland', + alpha2: 'GL', + alpha3: 'GRL', + numeric: '304', }, { - 'name': 'Grenada', - 'alpha2': 'GD', - 'alpha3': 'GRD', - 'numeric': '308', + name: 'Grenada', + alpha2: 'GD', + alpha3: 'GRD', + numeric: '308', }, { - 'name': 'Guadeloupe', - 'alpha2': 'GP', - 'alpha3': 'GLP', - 'numeric': '312', + name: 'Guadeloupe', + alpha2: 'GP', + alpha3: 'GLP', + numeric: '312', }, { - 'name': 'Guam', - 'alpha2': 'GU', - 'alpha3': 'GUM', - 'numeric': '316', + name: 'Guam', + alpha2: 'GU', + alpha3: 'GUM', + numeric: '316', }, { - 'name': 'Guatemala', - 'alpha2': 'GT', - 'alpha3': 'GTM', - 'numeric': '320', + name: 'Guatemala', + alpha2: 'GT', + alpha3: 'GTM', + numeric: '320', }, { - 'name': 'Guernsey', - 'alpha2': 'GG', - 'alpha3': 'GGY', - 'numeric': '831', + name: 'Guernsey', + alpha2: 'GG', + alpha3: 'GGY', + numeric: '831', }, { - 'name': 'Guinea', - 'alpha2': 'GN', - 'alpha3': 'GIN', - 'numeric': '324', + name: 'Guinea', + alpha2: 'GN', + alpha3: 'GIN', + numeric: '324', }, { - 'name': 'Guinea-Bissau', - 'alpha2': 'GW', - 'alpha3': 'GNB', - 'numeric': '624', + name: 'Guinea-Bissau', + alpha2: 'GW', + alpha3: 'GNB', + numeric: '624', }, { - 'name': 'Guyana', - 'alpha2': 'GY', - 'alpha3': 'GUY', - 'numeric': '328', + name: 'Guyana', + alpha2: 'GY', + alpha3: 'GUY', + numeric: '328', }, { - 'name': 'Haiti', - 'alpha2': 'HT', - 'alpha3': 'HTI', - 'numeric': '332', + name: 'Haiti', + alpha2: 'HT', + alpha3: 'HTI', + numeric: '332', }, { - 'name': 'Heard Island and McDonald Islands', - 'alpha2': 'HM', - 'alpha3': 'HMD', - 'numeric': '334', - 'altName': 'Heard and Mcdonald Islands', + name: 'Heard Island and McDonald Islands', + alpha2: 'HM', + alpha3: 'HMD', + numeric: '334', + altName: 'Heard and Mcdonald Islands', }, { - 'name': 'Holy See (the)', - 'alpha2': 'VA', - 'alpha3': 'VAT', - 'numeric': '336', - 'altName': 'Holy See (Vatican City State)', - 'shortName': 'Vatican', + name: 'Holy See (the)', + alpha2: 'VA', + alpha3: 'VAT', + numeric: '336', + altName: 'Holy See (Vatican City State)', + shortName: 'Vatican', }, { - 'name': 'Honduras', - 'alpha2': 'HN', - 'alpha3': 'HND', - 'numeric': '340', + name: 'Honduras', + alpha2: 'HN', + alpha3: 'HND', + numeric: '340', }, { - 'name': 'Hong Kong', - 'alpha2': 'HK', - 'alpha3': 'HKG', - 'numeric': '344', - 'altName': 'Hong Kong, SAR China', + name: 'Hong Kong', + alpha2: 'HK', + alpha3: 'HKG', + numeric: '344', + altName: 'Hong Kong, SAR China', }, { - 'name': 'Hungary', - 'alpha2': 'HU', - 'alpha3': 'HUN', - 'numeric': '348', + name: 'Hungary', + alpha2: 'HU', + alpha3: 'HUN', + numeric: '348', }, { - 'name': 'Iceland', - 'alpha2': 'IS', - 'alpha3': 'ISL', - 'numeric': '352', + name: 'Iceland', + alpha2: 'IS', + alpha3: 'ISL', + numeric: '352', }, { - 'name': 'India', - 'alpha2': 'IN', - 'alpha3': 'IND', - 'numeric': '356', + name: 'India', + alpha2: 'IN', + alpha3: 'IND', + numeric: '356', }, { - 'name': 'Indonesia', - 'alpha2': 'ID', - 'alpha3': 'IDN', - 'numeric': '360', + name: 'Indonesia', + alpha2: 'ID', + alpha3: 'IDN', + numeric: '360', }, { - 'name': 'Iran (Islamic Republic of)', - 'alpha2': 'IR', - 'alpha3': 'IRN', - 'numeric': '364', - 'altName': 'Iran, Islamic Republic of', - 'shortName': 'Iran', + name: 'Iran (Islamic Republic of)', + alpha2: 'IR', + alpha3: 'IRN', + numeric: '364', + altName: 'Iran, Islamic Republic of', + shortName: 'Iran', }, { - 'name': 'Iraq', - 'alpha2': 'IQ', - 'alpha3': 'IRQ', - 'numeric': '368', + name: 'Iraq', + alpha2: 'IQ', + alpha3: 'IRQ', + numeric: '368', }, { - 'name': 'Ireland', - 'alpha2': 'IE', - 'alpha3': 'IRL', - 'numeric': '372', + name: 'Ireland', + alpha2: 'IE', + alpha3: 'IRL', + numeric: '372', }, { - 'name': 'Isle of Man', - 'alpha2': 'IM', - 'alpha3': 'IMN', - 'numeric': '833', + name: 'Isle of Man', + alpha2: 'IM', + alpha3: 'IMN', + numeric: '833', }, { - 'name': 'Israel', - 'alpha2': 'IL', - 'alpha3': 'ISR', - 'numeric': '376', + name: 'Israel', + alpha2: 'IL', + alpha3: 'ISR', + numeric: '376', }, { - 'name': 'Italy', - 'alpha2': 'IT', - 'alpha3': 'ITA', - 'numeric': '380', + name: 'Italy', + alpha2: 'IT', + alpha3: 'ITA', + numeric: '380', }, { - 'name': 'Jamaica', - 'alpha2': 'JM', - 'alpha3': 'JAM', - 'numeric': '388', + name: 'Jamaica', + alpha2: 'JM', + alpha3: 'JAM', + numeric: '388', }, { - 'name': 'Japan', - 'alpha2': 'JP', - 'alpha3': 'JPN', - 'numeric': '392', + name: 'Japan', + alpha2: 'JP', + alpha3: 'JPN', + numeric: '392', }, { - 'name': 'Jersey', - 'alpha2': 'JE', - 'alpha3': 'JEY', - 'numeric': '832', + name: 'Jersey', + alpha2: 'JE', + alpha3: 'JEY', + numeric: '832', }, { - 'name': 'Jordan', - 'alpha2': 'JO', - 'alpha3': 'JOR', - 'numeric': '400', + name: 'Jordan', + alpha2: 'JO', + alpha3: 'JOR', + numeric: '400', }, { - 'name': 'Kazakhstan', - 'alpha2': 'KZ', - 'alpha3': 'KAZ', - 'numeric': '398', + name: 'Kazakhstan', + alpha2: 'KZ', + alpha3: 'KAZ', + numeric: '398', }, { - 'name': 'Kenya', - 'alpha2': 'KE', - 'alpha3': 'KEN', - 'numeric': '404', + name: 'Kenya', + alpha2: 'KE', + alpha3: 'KEN', + numeric: '404', }, { - 'name': 'Kiribati', - 'alpha2': 'KI', - 'alpha3': 'KIR', - 'numeric': '296', + name: 'Kiribati', + alpha2: 'KI', + alpha3: 'KIR', + numeric: '296', }, { - 'name': 'Korea (the Democratic People\'s Republic of)', - 'alpha2': 'KP', - 'alpha3': 'PRK', - 'numeric': '408', - 'altName': 'Korea (North)', - 'shortName': 'North Korea', + name: "Korea (the Democratic People's Republic of)", + alpha2: 'KP', + alpha3: 'PRK', + numeric: '408', + altName: 'Korea (North)', + shortName: 'North Korea', }, { - 'name': 'Korea (the Republic of)', - 'alpha2': 'KR', - 'alpha3': 'KOR', - 'numeric': '410', - 'altName': 'Korea (South)', - 'shortName': 'South Korea', + name: 'Korea (the Republic of)', + alpha2: 'KR', + alpha3: 'KOR', + numeric: '410', + altName: 'Korea (South)', + shortName: 'South Korea', }, { - 'name': 'Kuwait', - 'alpha2': 'KW', - 'alpha3': 'KWT', - 'numeric': '414', + name: 'Kuwait', + alpha2: 'KW', + alpha3: 'KWT', + numeric: '414', }, { - 'name': 'Kyrgyzstan', - 'alpha2': 'KG', - 'alpha3': 'KGZ', - 'numeric': '417', + name: 'Kyrgyzstan', + alpha2: 'KG', + alpha3: 'KGZ', + numeric: '417', }, { - 'name': 'Lao People\'s Democratic Republic (the)', - 'alpha2': 'LA', - 'alpha3': 'LAO', - 'numeric': '418', - 'altName': 'Lao PDR', - 'shortName': 'Laos', + name: "Lao People's Democratic Republic (the)", + alpha2: 'LA', + alpha3: 'LAO', + numeric: '418', + altName: 'Lao PDR', + shortName: 'Laos', }, { - 'name': 'Latvia', - 'alpha2': 'LV', - 'alpha3': 'LVA', - 'numeric': '428', + name: 'Latvia', + alpha2: 'LV', + alpha3: 'LVA', + numeric: '428', }, { - 'name': 'Lebanon', - 'alpha2': 'LB', - 'alpha3': 'LBN', - 'numeric': '422', + name: 'Lebanon', + alpha2: 'LB', + alpha3: 'LBN', + numeric: '422', }, { - 'name': 'Lesotho', - 'alpha2': 'LS', - 'alpha3': 'LSO', - 'numeric': '426', + name: 'Lesotho', + alpha2: 'LS', + alpha3: 'LSO', + numeric: '426', }, { - 'name': 'Liberia', - 'alpha2': 'LR', - 'alpha3': 'LBR', - 'numeric': '430', + name: 'Liberia', + alpha2: 'LR', + alpha3: 'LBR', + numeric: '430', }, { - 'name': 'Libya', - 'alpha2': 'LY', - 'alpha3': 'LBY', - 'numeric': '434', + name: 'Libya', + alpha2: 'LY', + alpha3: 'LBY', + numeric: '434', }, { - 'name': 'Liechtenstein', - 'alpha2': 'LI', - 'alpha3': 'LIE', - 'numeric': '438', + name: 'Liechtenstein', + alpha2: 'LI', + alpha3: 'LIE', + numeric: '438', }, { - 'name': 'Lithuania', - 'alpha2': 'LT', - 'alpha3': 'LTU', - 'numeric': '440', + name: 'Lithuania', + alpha2: 'LT', + alpha3: 'LTU', + numeric: '440', }, { - 'name': 'Luxembourg', - 'alpha2': 'LU', - 'alpha3': 'LUX', - 'numeric': '442', + name: 'Luxembourg', + alpha2: 'LU', + alpha3: 'LUX', + numeric: '442', }, { - 'name': 'Macao', - 'alpha2': 'MO', - 'alpha3': 'MAC', - 'numeric': '446', - 'altName': 'Macao, SAR China', - 'shortName': 'Macau', + name: 'Macao', + alpha2: 'MO', + alpha3: 'MAC', + numeric: '446', + altName: 'Macao, SAR China', + shortName: 'Macau', }, { - 'name': 'Macedonia (the former Yugoslav Republic of)', - 'alpha2': 'MK', - 'alpha3': 'MKD', - 'numeric': '807', - 'altName': 'Macedonia, Republic of', - 'shortName': 'Macedonia', + name: 'Macedonia (the former Yugoslav Republic of)', + alpha2: 'MK', + alpha3: 'MKD', + numeric: '807', + altName: 'Macedonia, Republic of', + shortName: 'Macedonia', }, { - 'name': 'Madagascar', - 'alpha2': 'MG', - 'alpha3': 'MDG', - 'numeric': '450', + name: 'Madagascar', + alpha2: 'MG', + alpha3: 'MDG', + numeric: '450', }, { - 'name': 'Malawi', - 'alpha2': 'MW', - 'alpha3': 'MWI', - 'numeric': '454', + name: 'Malawi', + alpha2: 'MW', + alpha3: 'MWI', + numeric: '454', }, { - 'name': 'Malaysia', - 'alpha2': 'MY', - 'alpha3': 'MYS', - 'numeric': '458', + name: 'Malaysia', + alpha2: 'MY', + alpha3: 'MYS', + numeric: '458', }, { - 'name': 'Maldives', - 'alpha2': 'MV', - 'alpha3': 'MDV', - 'numeric': '462', + name: 'Maldives', + alpha2: 'MV', + alpha3: 'MDV', + numeric: '462', }, { - 'name': 'Mali', - 'alpha2': 'ML', - 'alpha3': 'MLI', - 'numeric': '466', + name: 'Mali', + alpha2: 'ML', + alpha3: 'MLI', + numeric: '466', }, { - 'name': 'Malta', - 'alpha2': 'MT', - 'alpha3': 'MLT', - 'numeric': '470', + name: 'Malta', + alpha2: 'MT', + alpha3: 'MLT', + numeric: '470', }, { - 'name': 'Marshall Islands (the)', - 'alpha2': 'MH', - 'alpha3': 'MHL', - 'numeric': '584', - 'altName': 'Marshall Islands', + name: 'Marshall Islands (the)', + alpha2: 'MH', + alpha3: 'MHL', + numeric: '584', + altName: 'Marshall Islands', }, { - 'name': 'Martinique', - 'alpha2': 'MQ', - 'alpha3': 'MTQ', - 'numeric': '474', + name: 'Martinique', + alpha2: 'MQ', + alpha3: 'MTQ', + numeric: '474', }, { - 'name': 'Mauritania', - 'alpha2': 'MR', - 'alpha3': 'MRT', - 'numeric': '478', + name: 'Mauritania', + alpha2: 'MR', + alpha3: 'MRT', + numeric: '478', }, { - 'name': 'Mauritius', - 'alpha2': 'MU', - 'alpha3': 'MUS', - 'numeric': '480', + name: 'Mauritius', + alpha2: 'MU', + alpha3: 'MUS', + numeric: '480', }, { - 'name': 'Mayotte', - 'alpha2': 'YT', - 'alpha3': 'MYT', - 'numeric': '175', + name: 'Mayotte', + alpha2: 'YT', + alpha3: 'MYT', + numeric: '175', }, { - 'name': 'Mexico', - 'alpha2': 'MX', - 'alpha3': 'MEX', - 'numeric': '484', + name: 'Mexico', + alpha2: 'MX', + alpha3: 'MEX', + numeric: '484', }, { - 'name': 'Micronesia (Federated States of)', - 'alpha2': 'FM', - 'alpha3': 'FSM', - 'numeric': '583', - 'altName': 'Micronesia, Federated States of', - 'shortName': 'Micronesia', + name: 'Micronesia (Federated States of)', + alpha2: 'FM', + alpha3: 'FSM', + numeric: '583', + altName: 'Micronesia, Federated States of', + shortName: 'Micronesia', }, { - 'name': 'Moldova (the Republic of)', - 'alpha2': 'MD', - 'alpha3': 'MDA', - 'numeric': '498', - 'altName': 'Moldova', + name: 'Moldova (the Republic of)', + alpha2: 'MD', + alpha3: 'MDA', + numeric: '498', + altName: 'Moldova', }, { - 'name': 'Monaco', - 'alpha2': 'MC', - 'alpha3': 'MCO', - 'numeric': '492', + name: 'Monaco', + alpha2: 'MC', + alpha3: 'MCO', + numeric: '492', }, { - 'name': 'Mongolia', - 'alpha2': 'MN', - 'alpha3': 'MNG', - 'numeric': '496', + name: 'Mongolia', + alpha2: 'MN', + alpha3: 'MNG', + numeric: '496', }, { - 'name': 'Montenegro', - 'alpha2': 'ME', - 'alpha3': 'MNE', - 'numeric': '499', + name: 'Montenegro', + alpha2: 'ME', + alpha3: 'MNE', + numeric: '499', }, { - 'name': 'Montserrat', - 'alpha2': 'MS', - 'alpha3': 'MSR', - 'numeric': '500', + name: 'Montserrat', + alpha2: 'MS', + alpha3: 'MSR', + numeric: '500', }, { - 'name': 'Morocco', - 'alpha2': 'MA', - 'alpha3': 'MAR', - 'numeric': '504', + name: 'Morocco', + alpha2: 'MA', + alpha3: 'MAR', + numeric: '504', }, { - 'name': 'Mozambique', - 'alpha2': 'MZ', - 'alpha3': 'MOZ', - 'numeric': '508', + name: 'Mozambique', + alpha2: 'MZ', + alpha3: 'MOZ', + numeric: '508', }, { - 'name': 'Myanmar', - 'alpha2': 'MM', - 'alpha3': 'MMR', - 'numeric': '104', + name: 'Myanmar', + alpha2: 'MM', + alpha3: 'MMR', + numeric: '104', }, { - 'name': 'Namibia', - 'alpha2': 'NA', - 'alpha3': 'NAM', - 'numeric': '516', + name: 'Namibia', + alpha2: 'NA', + alpha3: 'NAM', + numeric: '516', }, { - 'name': 'Nauru', - 'alpha2': 'NR', - 'alpha3': 'NRU', - 'numeric': '520', + name: 'Nauru', + alpha2: 'NR', + alpha3: 'NRU', + numeric: '520', }, { - 'name': 'Nepal', - 'alpha2': 'NP', - 'alpha3': 'NPL', - 'numeric': '524', + name: 'Nepal', + alpha2: 'NP', + alpha3: 'NPL', + numeric: '524', }, { - 'name': 'Netherlands (the)', - 'alpha2': 'NL', - 'alpha3': 'NLD', - 'numeric': '528', - 'altName': 'Netherlands', + name: 'Netherlands (the)', + alpha2: 'NL', + alpha3: 'NLD', + numeric: '528', + altName: 'Netherlands', }, { - 'name': 'New Caledonia', - 'alpha2': 'NC', - 'alpha3': 'NCL', - 'numeric': '540', + name: 'New Caledonia', + alpha2: 'NC', + alpha3: 'NCL', + numeric: '540', }, { - 'name': 'New Zealand', - 'alpha2': 'NZ', - 'alpha3': 'NZL', - 'numeric': '554', + name: 'New Zealand', + alpha2: 'NZ', + alpha3: 'NZL', + numeric: '554', }, { - 'name': 'Nicaragua', - 'alpha2': 'NI', - 'alpha3': 'NIC', - 'numeric': '558', + name: 'Nicaragua', + alpha2: 'NI', + alpha3: 'NIC', + numeric: '558', }, { - 'name': 'Niger (the)', - 'alpha2': 'NE', - 'alpha3': 'NER', - 'numeric': '562', - 'altName': 'Niger', + name: 'Niger (the)', + alpha2: 'NE', + alpha3: 'NER', + numeric: '562', + altName: 'Niger', }, { - 'name': 'Nigeria', - 'alpha2': 'NG', - 'alpha3': 'NGA', - 'numeric': '566', + name: 'Nigeria', + alpha2: 'NG', + alpha3: 'NGA', + numeric: '566', }, { - 'name': 'Niue', - 'alpha2': 'NU', - 'alpha3': 'NIU', - 'numeric': '570', + name: 'Niue', + alpha2: 'NU', + alpha3: 'NIU', + numeric: '570', }, { - 'name': 'Norfolk Island', - 'alpha2': 'NF', - 'alpha3': 'NFK', - 'numeric': '574', + name: 'Norfolk Island', + alpha2: 'NF', + alpha3: 'NFK', + numeric: '574', }, { - 'name': 'Northern Mariana Islands (the)', - 'alpha2': 'MP', - 'alpha3': 'MNP', - 'numeric': '580', - 'altName': 'Northern Mariana Islands', + name: 'Northern Mariana Islands (the)', + alpha2: 'MP', + alpha3: 'MNP', + numeric: '580', + altName: 'Northern Mariana Islands', }, { - 'name': 'Norway', - 'alpha2': 'NO', - 'alpha3': 'NOR', - 'numeric': '578', + name: 'Norway', + alpha2: 'NO', + alpha3: 'NOR', + numeric: '578', }, { - 'name': 'Oman', - 'alpha2': 'OM', - 'alpha3': 'OMN', - 'numeric': '512', + name: 'Oman', + alpha2: 'OM', + alpha3: 'OMN', + numeric: '512', }, { - 'name': 'Pakistan', - 'alpha2': 'PK', - 'alpha3': 'PAK', - 'numeric': '586', + name: 'Pakistan', + alpha2: 'PK', + alpha3: 'PAK', + numeric: '586', }, { - 'name': 'Palau', - 'alpha2': 'PW', - 'alpha3': 'PLW', - 'numeric': '585', + name: 'Palau', + alpha2: 'PW', + alpha3: 'PLW', + numeric: '585', }, { - 'name': 'Palestine, State of', - 'alpha2': 'PS', - 'alpha3': 'PSE', - 'numeric': '275', - 'altName': 'Palestinian Territory', - 'shortName': 'Palestine', + name: 'Palestine, State of', + alpha2: 'PS', + alpha3: 'PSE', + numeric: '275', + altName: 'Palestinian Territory', + shortName: 'Palestine', }, { - 'name': 'Panama', - 'alpha2': 'PA', - 'alpha3': 'PAN', - 'numeric': '591', + name: 'Panama', + alpha2: 'PA', + alpha3: 'PAN', + numeric: '591', }, { - 'name': 'Papua New Guinea', - 'alpha2': 'PG', - 'alpha3': 'PNG', - 'numeric': '598', + name: 'Papua New Guinea', + alpha2: 'PG', + alpha3: 'PNG', + numeric: '598', }, { - 'name': 'Paraguay', - 'alpha2': 'PY', - 'alpha3': 'PRY', - 'numeric': '600', + name: 'Paraguay', + alpha2: 'PY', + alpha3: 'PRY', + numeric: '600', }, { - 'name': 'Peru', - 'alpha2': 'PE', - 'alpha3': 'PER', - 'numeric': '604', + name: 'Peru', + alpha2: 'PE', + alpha3: 'PER', + numeric: '604', }, { - 'name': 'Philippines (the)', - 'alpha2': 'PH', - 'alpha3': 'PHL', - 'numeric': '608', - 'altName': 'Philippines', + name: 'Philippines (the)', + alpha2: 'PH', + alpha3: 'PHL', + numeric: '608', + altName: 'Philippines', }, { - 'name': 'Pitcairn', - 'alpha2': 'PN', - 'alpha3': 'PCN', - 'numeric': '612', + name: 'Pitcairn', + alpha2: 'PN', + alpha3: 'PCN', + numeric: '612', }, { - 'name': 'Poland', - 'alpha2': 'PL', - 'alpha3': 'POL', - 'numeric': '616', + name: 'Poland', + alpha2: 'PL', + alpha3: 'POL', + numeric: '616', }, { - 'name': 'Portugal', - 'alpha2': 'PT', - 'alpha3': 'PRT', - 'numeric': '620', + name: 'Portugal', + alpha2: 'PT', + alpha3: 'PRT', + numeric: '620', }, { - 'name': 'Puerto Rico', - 'alpha2': 'PR', - 'alpha3': 'PRI', - 'numeric': '630', + name: 'Puerto Rico', + alpha2: 'PR', + alpha3: 'PRI', + numeric: '630', }, { - 'name': 'Qatar', - 'alpha2': 'QA', - 'alpha3': 'QAT', - 'numeric': '634', + name: 'Qatar', + alpha2: 'QA', + alpha3: 'QAT', + numeric: '634', }, { - 'name': 'Réunion', - 'alpha2': 'RE', - 'alpha3': 'REU', - 'numeric': '638', - 'shortName': 'Reunion', + name: 'Réunion', + alpha2: 'RE', + alpha3: 'REU', + numeric: '638', + shortName: 'Reunion', }, { - 'name': 'Romania', - 'alpha2': 'RO', - 'alpha3': 'ROU', - 'numeric': '642', + name: 'Romania', + alpha2: 'RO', + alpha3: 'ROU', + numeric: '642', }, { - 'name': 'Russian Federation (the)', - 'alpha2': 'RU', - 'alpha3': 'RUS', - 'numeric': '643', - 'altName': 'Russian Federation', - 'shortName': 'Russia', + name: 'Russian Federation (the)', + alpha2: 'RU', + alpha3: 'RUS', + numeric: '643', + altName: 'Russian Federation', + shortName: 'Russia', }, { - 'name': 'Rwanda', - 'alpha2': 'RW', - 'alpha3': 'RWA', - 'numeric': '646', + name: 'Rwanda', + alpha2: 'RW', + alpha3: 'RWA', + numeric: '646', }, { - 'name': 'Saint Barthélemy', - 'alpha2': 'BL', - 'alpha3': 'BLM', - 'numeric': '652', - 'altName': 'Saint-Barthélemy', - 'shortName': 'Saint Barthelemy', + name: 'Saint Barthélemy', + alpha2: 'BL', + alpha3: 'BLM', + numeric: '652', + altName: 'Saint-Barthélemy', + shortName: 'Saint Barthelemy', }, { - 'name': 'Saint Helena, Ascension and Tristan da Cunha', - 'alpha2': 'SH', - 'alpha3': 'SHN', - 'numeric': '654', - 'altName': 'Saint Helena', + name: 'Saint Helena, Ascension and Tristan da Cunha', + alpha2: 'SH', + alpha3: 'SHN', + numeric: '654', + altName: 'Saint Helena', }, { - 'name': 'Saint Kitts and Nevis', - 'alpha2': 'KN', - 'alpha3': 'KNA', - 'numeric': '659', + name: 'Saint Kitts and Nevis', + alpha2: 'KN', + alpha3: 'KNA', + numeric: '659', }, { - 'name': 'Saint Lucia', - 'alpha2': 'LC', - 'alpha3': 'LCA', - 'numeric': '662', + name: 'Saint Lucia', + alpha2: 'LC', + alpha3: 'LCA', + numeric: '662', }, { - 'name': 'Saint Martin (French part)', - 'alpha2': 'MF', - 'alpha3': 'MAF', - 'numeric': '663', - 'altName': 'Saint-Martin (French part)', - 'shortName': 'Saint Martin', + name: 'Saint Martin (French part)', + alpha2: 'MF', + alpha3: 'MAF', + numeric: '663', + altName: 'Saint-Martin (French part)', + shortName: 'Saint Martin', }, { - 'name': 'Saint Pierre and Miquelon', - 'alpha2': 'PM', - 'alpha3': 'SPM', - 'numeric': '666', + name: 'Saint Pierre and Miquelon', + alpha2: 'PM', + alpha3: 'SPM', + numeric: '666', }, { - 'name': 'Saint Vincent and the Grenadines', - 'alpha2': 'VC', - 'alpha3': 'VCT', - 'numeric': '670', - 'altName': 'Saint Vincent and Grenadines', + name: 'Saint Vincent and the Grenadines', + alpha2: 'VC', + alpha3: 'VCT', + numeric: '670', + altName: 'Saint Vincent and Grenadines', }, { - 'name': 'Samoa', - 'alpha2': 'WS', - 'alpha3': 'WSM', - 'numeric': '882', + name: 'Samoa', + alpha2: 'WS', + alpha3: 'WSM', + numeric: '882', }, { - 'name': 'San Marino', - 'alpha2': 'SM', - 'alpha3': 'SMR', - 'numeric': '674', + name: 'San Marino', + alpha2: 'SM', + alpha3: 'SMR', + numeric: '674', }, { - 'name': 'Sao Tome and Principe', - 'alpha2': 'ST', - 'alpha3': 'STP', - 'numeric': '678', + name: 'Sao Tome and Principe', + alpha2: 'ST', + alpha3: 'STP', + numeric: '678', }, { - 'name': 'Saudi Arabia', - 'alpha2': 'SA', - 'alpha3': 'SAU', - 'numeric': '682', + name: 'Saudi Arabia', + alpha2: 'SA', + alpha3: 'SAU', + numeric: '682', }, { - 'name': 'Senegal', - 'alpha2': 'SN', - 'alpha3': 'SEN', - 'numeric': '686', + name: 'Senegal', + alpha2: 'SN', + alpha3: 'SEN', + numeric: '686', }, { - 'name': 'Serbia', - 'alpha2': 'RS', - 'alpha3': 'SRB', - 'numeric': '688', + name: 'Serbia', + alpha2: 'RS', + alpha3: 'SRB', + numeric: '688', }, { - 'name': 'Seychelles', - 'alpha2': 'SC', - 'alpha3': 'SYC', - 'numeric': '690', + name: 'Seychelles', + alpha2: 'SC', + alpha3: 'SYC', + numeric: '690', }, { - 'name': 'Sierra Leone', - 'alpha2': 'SL', - 'alpha3': 'SLE', - 'numeric': '694', + name: 'Sierra Leone', + alpha2: 'SL', + alpha3: 'SLE', + numeric: '694', }, { - 'name': 'Singapore', - 'alpha2': 'SG', - 'alpha3': 'SGP', - 'numeric': '702', + name: 'Singapore', + alpha2: 'SG', + alpha3: 'SGP', + numeric: '702', }, { - 'name': 'Sint Maarten (Dutch part)', - 'alpha2': 'SX', - 'alpha3': 'SXM', - 'numeric': '534', - 'shortName': 'Sint Maarten', + name: 'Sint Maarten (Dutch part)', + alpha2: 'SX', + alpha3: 'SXM', + numeric: '534', + shortName: 'Sint Maarten', }, { - 'name': 'Slovakia', - 'alpha2': 'SK', - 'alpha3': 'SVK', - 'numeric': '703', + name: 'Slovakia', + alpha2: 'SK', + alpha3: 'SVK', + numeric: '703', }, { - 'name': 'Slovenia', - 'alpha2': 'SI', - 'alpha3': 'SVN', - 'numeric': '705', + name: 'Slovenia', + alpha2: 'SI', + alpha3: 'SVN', + numeric: '705', }, { - 'name': 'Solomon Islands', - 'alpha2': 'SB', - 'alpha3': 'SLB', - 'numeric': '090', + name: 'Solomon Islands', + alpha2: 'SB', + alpha3: 'SLB', + numeric: '090', }, { - 'name': 'Somalia', - 'alpha2': 'SO', - 'alpha3': 'SOM', - 'numeric': '706', + name: 'Somalia', + alpha2: 'SO', + alpha3: 'SOM', + numeric: '706', }, { - 'name': 'South Africa', - 'alpha2': 'ZA', - 'alpha3': 'ZAF', - 'numeric': '710', + name: 'South Africa', + alpha2: 'ZA', + alpha3: 'ZAF', + numeric: '710', }, { - 'name': 'South Georgia and the South Sandwich Islands', - 'alpha2': 'GS', - 'alpha3': 'SGS', - 'numeric': '239', + name: 'South Georgia and the South Sandwich Islands', + alpha2: 'GS', + alpha3: 'SGS', + numeric: '239', }, { - 'name': 'South Sudan', - 'alpha2': 'SS', - 'alpha3': 'SSD', - 'numeric': '728', + name: 'South Sudan', + alpha2: 'SS', + alpha3: 'SSD', + numeric: '728', }, { - 'name': 'Spain', - 'alpha2': 'ES', - 'alpha3': 'ESP', - 'numeric': '724', + name: 'Spain', + alpha2: 'ES', + alpha3: 'ESP', + numeric: '724', }, { - 'name': 'Sri Lanka', - 'alpha2': 'LK', - 'alpha3': 'LKA', - 'numeric': '144', + name: 'Sri Lanka', + alpha2: 'LK', + alpha3: 'LKA', + numeric: '144', }, { - 'name': 'Sudan (the)', - 'alpha2': 'SD', - 'alpha3': 'SDN', - 'numeric': '729', - 'altName': 'Sudan', + name: 'Sudan (the)', + alpha2: 'SD', + alpha3: 'SDN', + numeric: '729', + altName: 'Sudan', }, { - 'name': 'Suriname', - 'alpha2': 'SR', - 'alpha3': 'SUR', - 'numeric': '740', + name: 'Suriname', + alpha2: 'SR', + alpha3: 'SUR', + numeric: '740', }, { - 'name': 'Svalbard and Jan Mayen', - 'alpha2': 'SJ', - 'alpha3': 'SJM', - 'numeric': '744', - 'altName': 'Svalbard and Jan Mayen Islands', + name: 'Svalbard and Jan Mayen', + alpha2: 'SJ', + alpha3: 'SJM', + numeric: '744', + altName: 'Svalbard and Jan Mayen Islands', }, { - 'name': 'Swaziland', - 'alpha2': 'SZ', - 'alpha3': 'SWZ', - 'numeric': '748', + name: 'Swaziland', + alpha2: 'SZ', + alpha3: 'SWZ', + numeric: '748', }, { - 'name': 'Sweden', - 'alpha2': 'SE', - 'alpha3': 'SWE', - 'numeric': '752', + name: 'Sweden', + alpha2: 'SE', + alpha3: 'SWE', + numeric: '752', }, { - 'name': 'Switzerland', - 'alpha2': 'CH', - 'alpha3': 'CHE', - 'numeric': '756', + name: 'Switzerland', + alpha2: 'CH', + alpha3: 'CHE', + numeric: '756', }, { - 'name': 'Syrian Arab Republic', - 'alpha2': 'SY', - 'alpha3': 'SYR', - 'numeric': '760', - 'altName': 'Syrian Arab Republic (Syria)', - 'shortName': 'Syria', + name: 'Syrian Arab Republic', + alpha2: 'SY', + alpha3: 'SYR', + numeric: '760', + altName: 'Syrian Arab Republic (Syria)', + shortName: 'Syria', }, { - 'name': 'Taiwan (Province of China)', - 'alpha2': 'TW', - 'alpha3': 'TWN', - 'numeric': '158', - 'altName': 'Taiwan, Republic of China', - 'shortName': 'Taiwan', + name: 'Taiwan (Province of China)', + alpha2: 'TW', + alpha3: 'TWN', + numeric: '158', + altName: 'Taiwan, Republic of China', + shortName: 'Taiwan', }, { - 'name': 'Tajikistan', - 'alpha2': 'TJ', - 'alpha3': 'TJK', - 'numeric': '762', + name: 'Tajikistan', + alpha2: 'TJ', + alpha3: 'TJK', + numeric: '762', }, { - 'name': 'Tanzania, United Republic of', - 'alpha2': 'TZ', - 'alpha3': 'TZA', - 'numeric': '834', - 'shortName': 'Tanzania', + name: 'Tanzania, United Republic of', + alpha2: 'TZ', + alpha3: 'TZA', + numeric: '834', + shortName: 'Tanzania', }, { - 'name': 'Thailand', - 'alpha2': 'TH', - 'alpha3': 'THA', - 'numeric': '764', + name: 'Thailand', + alpha2: 'TH', + alpha3: 'THA', + numeric: '764', }, { - 'name': 'Timor-Leste', - 'alpha2': 'TL', - 'alpha3': 'TLS', - 'numeric': '626', - 'shortName': 'East Timor', + name: 'Timor-Leste', + alpha2: 'TL', + alpha3: 'TLS', + numeric: '626', + shortName: 'East Timor', }, { - 'name': 'Togo', - 'alpha2': 'TG', - 'alpha3': 'TGO', - 'numeric': '768', + name: 'Togo', + alpha2: 'TG', + alpha3: 'TGO', + numeric: '768', }, { - 'name': 'Tokelau', - 'alpha2': 'TK', - 'alpha3': 'TKL', - 'numeric': '772', + name: 'Tokelau', + alpha2: 'TK', + alpha3: 'TKL', + numeric: '772', }, { - 'name': 'Tonga', - 'alpha2': 'TO', - 'alpha3': 'TON', - 'numeric': '776', + name: 'Tonga', + alpha2: 'TO', + alpha3: 'TON', + numeric: '776', }, { - 'name': 'Trinidad and Tobago', - 'alpha2': 'TT', - 'alpha3': 'TTO', - 'numeric': '780', + name: 'Trinidad and Tobago', + alpha2: 'TT', + alpha3: 'TTO', + numeric: '780', }, { - 'name': 'Tunisia', - 'alpha2': 'TN', - 'alpha3': 'TUN', - 'numeric': '788', + name: 'Tunisia', + alpha2: 'TN', + alpha3: 'TUN', + numeric: '788', }, { - 'name': 'Turkey', - 'alpha2': 'TR', - 'alpha3': 'TUR', - 'numeric': '792', + name: 'Turkey', + alpha2: 'TR', + alpha3: 'TUR', + numeric: '792', }, { - 'name': 'Turkmenistan', - 'alpha2': 'TM', - 'alpha3': 'TKM', - 'numeric': '795', + name: 'Turkmenistan', + alpha2: 'TM', + alpha3: 'TKM', + numeric: '795', }, { - 'name': 'Turks and Caicos Islands (the)', - 'alpha2': 'TC', - 'alpha3': 'TCA', - 'numeric': '796', - 'altName': 'Turks and Caicos Islands', + name: 'Turks and Caicos Islands (the)', + alpha2: 'TC', + alpha3: 'TCA', + numeric: '796', + altName: 'Turks and Caicos Islands', }, { - 'name': 'Tuvalu', - 'alpha2': 'TV', - 'alpha3': 'TUV', - 'numeric': '798', + name: 'Tuvalu', + alpha2: 'TV', + alpha3: 'TUV', + numeric: '798', }, { - 'name': 'Uganda', - 'alpha2': 'UG', - 'alpha3': 'UGA', - 'numeric': '800', + name: 'Uganda', + alpha2: 'UG', + alpha3: 'UGA', + numeric: '800', }, { - 'name': 'Ukraine', - 'alpha2': 'UA', - 'alpha3': 'UKR', - 'numeric': '804', + name: 'Ukraine', + alpha2: 'UA', + alpha3: 'UKR', + numeric: '804', }, { - 'name': 'United Arab Emirates (the)', - 'alpha2': 'AE', - 'alpha3': 'ARE', - 'numeric': '784', - 'altName': 'United Arab Emirates', + name: 'United Arab Emirates (the)', + alpha2: 'AE', + alpha3: 'ARE', + numeric: '784', + altName: 'United Arab Emirates', }, { - 'name': 'United Kingdom of Great Britain and Northern Ireland (the)', - 'alpha2': 'GB', - 'alpha3': 'GBR', - 'numeric': '826', - 'altName': 'United Kingdom', + name: 'United Kingdom of Great Britain and Northern Ireland (the)', + alpha2: 'GB', + alpha3: 'GBR', + numeric: '826', + altName: 'United Kingdom', }, { - 'name': 'United States Minor Outlying Islands (the)', - 'alpha2': 'UM', - 'alpha3': 'UMI', - 'numeric': '581', - 'altName': 'US Minor Outlying Islands', + name: 'United States Minor Outlying Islands (the)', + alpha2: 'UM', + alpha3: 'UMI', + numeric: '581', + altName: 'US Minor Outlying Islands', }, { - 'name': 'United States of America (the)', - 'alpha2': 'US', - 'alpha3': 'USA', - 'numeric': '840', - 'altName': 'United States of America', - 'shortName': 'United States', + name: 'United States of America (the)', + alpha2: 'US', + alpha3: 'USA', + numeric: '840', + altName: 'United States of America', + shortName: 'United States', }, { - 'name': 'Uruguay', - 'alpha2': 'UY', - 'alpha3': 'URY', - 'numeric': '858', + name: 'Uruguay', + alpha2: 'UY', + alpha3: 'URY', + numeric: '858', }, { - 'name': 'Uzbekistan', - 'alpha2': 'UZ', - 'alpha3': 'UZB', - 'numeric': '860', + name: 'Uzbekistan', + alpha2: 'UZ', + alpha3: 'UZB', + numeric: '860', }, { - 'name': 'Vanuatu', - 'alpha2': 'VU', - 'alpha3': 'VUT', - 'numeric': '548', + name: 'Vanuatu', + alpha2: 'VU', + alpha3: 'VUT', + numeric: '548', }, { - 'name': 'Venezuela (Bolivarian Republic of)', - 'alpha2': 'VE', - 'alpha3': 'VEN', - 'numeric': '862', - 'altName': 'Venezuela (Bolivarian Republic)', - 'shortName': 'Venezuela', + name: 'Venezuela (Bolivarian Republic of)', + alpha2: 'VE', + alpha3: 'VEN', + numeric: '862', + altName: 'Venezuela (Bolivarian Republic)', + shortName: 'Venezuela', }, { - 'name': 'Viet Nam', - 'alpha2': 'VN', - 'alpha3': 'VNM', - 'numeric': '704', - 'shortName': 'Vietnam', + name: 'Viet Nam', + alpha2: 'VN', + alpha3: 'VNM', + numeric: '704', + shortName: 'Vietnam', }, { - 'name': 'Virgin Islands (British)', - 'alpha2': 'VG', - 'alpha3': 'VGB', - 'numeric': '092', - 'altName': 'British Virgin Islands', + name: 'Virgin Islands (British)', + alpha2: 'VG', + alpha3: 'VGB', + numeric: '092', + altName: 'British Virgin Islands', }, { - 'name': 'Virgin Islands (U.S.)', - 'alpha2': 'VI', - 'alpha3': 'VIR', - 'numeric': '850', - 'altName': 'Virgin Islands, US', - 'shortName': 'U.S. Virgin Islands', + name: 'Virgin Islands (U.S.)', + alpha2: 'VI', + alpha3: 'VIR', + numeric: '850', + altName: 'Virgin Islands, US', + shortName: 'U.S. Virgin Islands', }, { - 'name': 'Wallis and Futuna', - 'alpha2': 'WF', - 'alpha3': 'WLF', - 'numeric': '876', - 'altName': 'Wallis and Futuna Islands', + name: 'Wallis and Futuna', + alpha2: 'WF', + alpha3: 'WLF', + numeric: '876', + altName: 'Wallis and Futuna Islands', }, { - 'name': 'Western Sahara*', - 'alpha2': 'EH', - 'alpha3': 'ESH', - 'numeric': '732', - 'altName': 'Western Sahara', + name: 'Western Sahara*', + alpha2: 'EH', + alpha3: 'ESH', + numeric: '732', + altName: 'Western Sahara', }, { - 'name': 'Yemen', - 'alpha2': 'YE', - 'alpha3': 'YEM', - 'numeric': '887', + name: 'Yemen', + alpha2: 'YE', + alpha3: 'YEM', + numeric: '887', }, { - 'name': 'Zambia', - 'alpha2': 'ZM', - 'alpha3': 'ZMB', - 'numeric': '894', + name: 'Zambia', + alpha2: 'ZM', + alpha3: 'ZMB', + numeric: '894', }, { - 'name': 'Zimbabwe', - 'alpha2': 'ZW', - 'alpha3': 'ZWE', - 'numeric': '716', + name: 'Zimbabwe', + alpha2: 'ZW', + alpha3: 'ZWE', + numeric: '716', }, ]; diff --git a/packages/nodes-base/nodes/HelpScout/CustomerDescription.ts b/packages/nodes-base/nodes/HelpScout/CustomerDescription.ts index 6d1a3ba31b..76eec5737d 100644 --- a/packages/nodes-base/nodes/HelpScout/CustomerDescription.ts +++ b/packages/nodes-base/nodes/HelpScout/CustomerDescription.ts @@ -8,9 +8,7 @@ export const customerOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'customer', - ], + resource: ['customer'], }, }, options: [ @@ -50,9 +48,9 @@ export const customerOperations: INodeProperties[] = [ ]; export const customerFields: INodeProperties[] = [ -/* -------------------------------------------------------------------------- */ -/* customer:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* customer:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Resolve Data', name: 'resolveData', @@ -60,16 +58,13 @@ export const customerFields: INodeProperties[] = [ default: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'customer', - ], + operation: ['create'], + resource: ['customer'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default the response only contain the ID to resource. If this option gets activated, it will resolve the data automatically.', + description: + 'By default the response only contain the ID to resource. If this option gets activated, it will resolve the data automatically.', }, { displayName: 'Additional Fields', @@ -79,12 +74,8 @@ export const customerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'customer', - ], + operation: ['create'], + resource: ['customer'], }, }, options: [ @@ -103,7 +94,8 @@ export const customerFields: INodeProperties[] = [ name: 'firstName', type: 'string', default: '', - description: 'First name of the customer. When defined it must be between 1 and 40 characters.', + description: + 'First name of the customer. When defined it must be between 1 and 40 characters.', }, { displayName: 'Gender', @@ -178,12 +170,8 @@ export const customerFields: INodeProperties[] = [ type: 'fixedCollection', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'customer', - ], + operation: ['create'], + resource: ['customer'], }, }, default: {}, @@ -220,7 +208,8 @@ export const customerFields: INodeProperties[] = [ displayName: 'Country Name or ID', name: 'country', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCountriesCodes', }, @@ -246,12 +235,8 @@ export const customerFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'customer', - ], + operation: ['create'], + resource: ['customer'], }, }, default: {}, @@ -326,12 +311,8 @@ export const customerFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'customer', - ], + operation: ['create'], + resource: ['customer'], }, }, default: {}, @@ -382,12 +363,8 @@ export const customerFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'customer', - ], + operation: ['create'], + resource: ['customer'], }, }, default: {}, @@ -446,12 +423,8 @@ export const customerFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'customer', - ], + operation: ['create'], + resource: ['customer'], }, }, default: {}, @@ -538,12 +511,8 @@ export const customerFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'customer', - ], + operation: ['create'], + resource: ['customer'], }, }, default: {}, @@ -563,21 +532,17 @@ export const customerFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* customer:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* customer:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'customer', - ], + operation: ['getAll'], + resource: ['customer'], }, }, default: false, @@ -589,15 +554,9 @@ export const customerFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'customer', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['customer'], + returnAll: [false], }, }, typeOptions: { @@ -614,12 +573,8 @@ export const customerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'getAll', - ], + resource: ['customer'], + operation: ['getAll'], }, }, options: [ @@ -700,13 +655,14 @@ export const customerFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'Advanced search Examples', + description: + 'Advanced search Examples', }, ], }, -/* -------------------------------------------------------------------------- */ -/* customer:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* customer:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Customer ID', name: 'customerId', @@ -715,18 +671,14 @@ export const customerFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'get', - ], + resource: ['customer'], + operation: ['get'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* customer:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* customer:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'Customer ID', name: 'customerId', @@ -734,12 +686,8 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'customer', - ], + operation: ['update'], + resource: ['customer'], }, }, }, @@ -751,12 +699,8 @@ export const customerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'customer', - ], + operation: ['update'], + resource: ['customer'], }, }, options: [ @@ -775,7 +719,8 @@ export const customerFields: INodeProperties[] = [ name: 'firstName', type: 'string', default: '', - description: 'First name of the customer. When defined it must be between 1 and 40 characters.', + description: + 'First name of the customer. When defined it must be between 1 and 40 characters.', }, { displayName: 'Gender', diff --git a/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts b/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts index c48ea971c1..775907e85a 100644 --- a/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,15 +7,21 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -import { - get, -} from 'lodash'; +import { get } from 'lodash'; -export async function helpscoutApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function helpscoutApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { let options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -42,8 +46,16 @@ export async function helpscoutApiRequest(this: IExecuteFunctions | IExecuteSing } } -export async function helpscoutApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function helpscoutApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; diff --git a/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts b/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts index a7f04b2359..d19a076671 100644 --- a/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts +++ b/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryKeyData, @@ -13,48 +11,23 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - countriesCodes -} from './CountriesCodes'; +import { countriesCodes } from './CountriesCodes'; -import { - conversationFields, - conversationOperations, -} from './ConversationDescription'; +import { conversationFields, conversationOperations } from './ConversationDescription'; -import { - customerFields, - customerOperations, -} from './CustomerDescription'; +import { customerFields, customerOperations } from './CustomerDescription'; -import { - ICustomer, -} from './CustomerInterface'; +import { ICustomer } from './CustomerInterface'; -import { - IConversation, -} from './ConversationInterface'; +import { IConversation } from './ConversationInterface'; -import { - helpscoutApiRequest, - helpscoutApiRequestAllItems, -} from './GenericFunctions'; +import { helpscoutApiRequest, helpscoutApiRequestAllItems } from './GenericFunctions'; -import { - mailboxFields, - mailboxOperations, -} from './MailboxDescription'; +import { mailboxFields, mailboxOperations } from './MailboxDescription'; -import { - threadFields, - threadOperations, -} from './ThreadDescription'; - -import { - IAttachment, - IThread, -} from './ThreadInterface'; +import { threadFields, threadOperations } from './ThreadDescription'; +import { IAttachment, IThread } from './ThreadInterface'; export class HelpScout implements INodeType { description: INodeTypeDescription = { @@ -133,7 +106,12 @@ export class HelpScout implements INodeType { // select them easily async getTags(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const tags = await helpscoutApiRequestAllItems.call(this, '_embedded.tags', 'GET', '/v2/tags'); + const tags = await helpscoutApiRequestAllItems.call( + this, + '_embedded.tags', + 'GET', + '/v2/tags', + ); for (const tag of tags) { const tagName = tag.name; const tagId = tag.id; @@ -148,7 +126,12 @@ export class HelpScout implements INodeType { // select them easily async getMailboxes(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const mailboxes = await helpscoutApiRequestAllItems.call(this, '_embedded.mailboxes', 'GET', '/v2/mailboxes'); + const mailboxes = await helpscoutApiRequestAllItems.call( + this, + '_embedded.mailboxes', + 'GET', + '/v2/mailboxes', + ); for (const mailbox of mailboxes) { const mailboxName = mailbox.name; const mailboxId = mailbox.id; @@ -181,7 +164,8 @@ export class HelpScout implements INodeType { const type = this.getNodeParameter('type', i) as string; const resolveData = this.getNodeParameter('resolveData', i) as boolean; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - const threads = (this.getNodeParameter('threadsUi', i) as IDataObject).threadsValues as IDataObject[]; + const threads = (this.getNodeParameter('threadsUi', i) as IDataObject) + .threadsValues as IDataObject[]; const body: IConversation = { mailboxId, status, @@ -204,7 +188,11 @@ export class HelpScout implements INodeType { delete body.customerEmail; } if (body.customer === undefined) { - throw new NodeOperationError(this.getNode(), 'Either customer email or customer ID must be set', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Either customer email or customer ID must be set', + { itemIndex: i }, + ); } if (threads) { for (let i = 0; i < threads.length; i++) { @@ -217,7 +205,15 @@ export class HelpScout implements INodeType { } body.threads = threads; } - responseData = await helpscoutApiRequest.call(this, 'POST', '/v2/conversations', body, qs, undefined, { resolveWithFullResponse: true }); + responseData = await helpscoutApiRequest.call( + this, + 'POST', + '/v2/conversations', + body, + qs, + undefined, + { resolveWithFullResponse: true }, + ); const id = responseData.headers['resource-id']; const uri = responseData.headers.location; if (resolveData) { @@ -232,13 +228,21 @@ export class HelpScout implements INodeType { //https://developer.helpscout.com/mailbox-api/endpoints/conversations/delete if (operation === 'delete') { const conversationId = this.getNodeParameter('conversationId', i) as string; - responseData = await helpscoutApiRequest.call(this, 'DELETE', `/v2/conversations/${conversationId}`); + responseData = await helpscoutApiRequest.call( + this, + 'DELETE', + `/v2/conversations/${conversationId}`, + ); responseData = { success: true }; } //https://developer.helpscout.com/mailbox-api/endpoints/conversations/get if (operation === 'get') { const conversationId = this.getNodeParameter('conversationId', i) as string; - responseData = await helpscoutApiRequest.call(this, 'GET', `/v2/conversations/${conversationId}`); + responseData = await helpscoutApiRequest.call( + this, + 'GET', + `/v2/conversations/${conversationId}`, + ); } //https://developer.helpscout.com/mailbox-api/endpoints/conversations/list if (operation === 'getAll') { @@ -246,10 +250,24 @@ export class HelpScout implements INodeType { const options = this.getNodeParameter('options', i) as IDataObject; Object.assign(qs, options); if (returnAll) { - responseData = await helpscoutApiRequestAllItems.call(this, '_embedded.conversations', 'GET', '/v2/conversations', {}, qs); + responseData = await helpscoutApiRequestAllItems.call( + this, + '_embedded.conversations', + 'GET', + '/v2/conversations', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await helpscoutApiRequestAllItems.call(this, '_embedded.conversations', 'GET', '/v2/conversations', {}, qs); + responseData = await helpscoutApiRequestAllItems.call( + this, + '_embedded.conversations', + 'GET', + '/v2/conversations', + {}, + qs, + ); responseData = responseData.splice(0, qs.limit); } } @@ -259,12 +277,18 @@ export class HelpScout implements INodeType { if (operation === 'create') { const resolveData = this.getNodeParameter('resolveData', i) as boolean; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - const chats = (this.getNodeParameter('chatsUi', i) as IDataObject).chatsValues as IDataObject[]; - const address = (this.getNodeParameter('addressUi', i) as IDataObject).addressValue as IDataObject; - const emails = (this.getNodeParameter('emailsUi', i) as IDataObject).emailsValues as IDataObject[]; - const phones = (this.getNodeParameter('phonesUi', i) as IDataObject).phonesValues as IDataObject[]; - const socialProfiles = (this.getNodeParameter('socialProfilesUi', i) as IDataObject).socialProfilesValues as IDataObject[]; - const websites = (this.getNodeParameter('websitesUi', i) as IDataObject).websitesValues as IDataObject[]; + const chats = (this.getNodeParameter('chatsUi', i) as IDataObject) + .chatsValues as IDataObject[]; + const address = (this.getNodeParameter('addressUi', i) as IDataObject) + .addressValue as IDataObject; + const emails = (this.getNodeParameter('emailsUi', i) as IDataObject) + .emailsValues as IDataObject[]; + const phones = (this.getNodeParameter('phonesUi', i) as IDataObject) + .phonesValues as IDataObject[]; + const socialProfiles = (this.getNodeParameter('socialProfilesUi', i) as IDataObject) + .socialProfilesValues as IDataObject[]; + const websites = (this.getNodeParameter('websitesUi', i) as IDataObject) + .websitesValues as IDataObject[]; let body: ICustomer = {}; body = Object.assign({}, additionalFields); if (body.age) { @@ -290,9 +314,19 @@ export class HelpScout implements INodeType { body.websites = websites; } if (Object.keys(body).length === 0) { - throw new NodeOperationError(this.getNode(), 'You have to set at least one field', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'You have to set at least one field', { + itemIndex: i, + }); } - responseData = await helpscoutApiRequest.call(this, 'POST', '/v2/customers', body, qs, undefined, { resolveWithFullResponse: true }); + responseData = await helpscoutApiRequest.call( + this, + 'POST', + '/v2/customers', + body, + qs, + undefined, + { resolveWithFullResponse: true }, + ); const id = responseData.headers['resource-id']; const uri = responseData.headers.location; if (resolveData) { @@ -306,12 +340,23 @@ export class HelpScout implements INodeType { } //https://developer.helpscout.com/mailbox-api/endpoints/customer_properties/list if (operation === 'properties') { - responseData = await helpscoutApiRequestAllItems.call(this, '_embedded.customer-properties', 'GET', '/v2/customer-properties', {}, qs); + responseData = await helpscoutApiRequestAllItems.call( + this, + '_embedded.customer-properties', + 'GET', + '/v2/customer-properties', + {}, + qs, + ); } //https://developer.helpscout.com/mailbox-api/endpoints/customers/get if (operation === 'get') { const customerId = this.getNodeParameter('customerId', i) as string; - responseData = await helpscoutApiRequest.call(this, 'GET', `/v2/customers/${customerId}`); + responseData = await helpscoutApiRequest.call( + this, + 'GET', + `/v2/customers/${customerId}`, + ); } //https://developer.helpscout.com/mailbox-api/endpoints/customers/list if (operation === 'getAll') { @@ -319,10 +364,24 @@ export class HelpScout implements INodeType { const options = this.getNodeParameter('options', i) as IDataObject; Object.assign(qs, options); if (returnAll) { - responseData = await helpscoutApiRequestAllItems.call(this, '_embedded.customers', 'GET', '/v2/customers', {}, qs); + responseData = await helpscoutApiRequestAllItems.call( + this, + '_embedded.customers', + 'GET', + '/v2/customers', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await helpscoutApiRequestAllItems.call(this, '_embedded.customers', 'GET', '/v2/customers', {}, qs); + responseData = await helpscoutApiRequestAllItems.call( + this, + '_embedded.customers', + 'GET', + '/v2/customers', + {}, + qs, + ); responseData = responseData.splice(0, qs.limit); } } @@ -336,9 +395,19 @@ export class HelpScout implements INodeType { body.age = body.age.toString(); } if (Object.keys(body).length === 0) { - throw new NodeOperationError(this.getNode(), 'You have to set at least one field', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'You have to set at least one field', { + itemIndex: i, + }); } - responseData = await helpscoutApiRequest.call(this, 'PUT', `/v2/customers/${customerId}`, body, qs, undefined, { resolveWithFullResponse: true }); + responseData = await helpscoutApiRequest.call( + this, + 'PUT', + `/v2/customers/${customerId}`, + body, + qs, + undefined, + { resolveWithFullResponse: true }, + ); responseData = { success: true }; } } @@ -346,16 +415,36 @@ export class HelpScout implements INodeType { //https://developer.helpscout.com/mailbox-api/endpoints/mailboxes/get if (operation === 'get') { const mailboxId = this.getNodeParameter('mailboxId', i) as string; - responseData = await helpscoutApiRequest.call(this, 'GET', `/v2/mailboxes/${mailboxId}`, {}, qs); + responseData = await helpscoutApiRequest.call( + this, + 'GET', + `/v2/mailboxes/${mailboxId}`, + {}, + qs, + ); } //https://developer.helpscout.com/mailbox-api/endpoints/mailboxes/list if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll) { - responseData = await helpscoutApiRequestAllItems.call(this, '_embedded.mailboxes', 'GET', '/v2/mailboxes', {}, qs); + responseData = await helpscoutApiRequestAllItems.call( + this, + '_embedded.mailboxes', + 'GET', + '/v2/mailboxes', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await helpscoutApiRequestAllItems.call(this, '_embedded.mailboxes', 'GET', '/v2/mailboxes', {}, qs); + responseData = await helpscoutApiRequestAllItems.call( + this, + '_embedded.mailboxes', + 'GET', + '/v2/mailboxes', + {}, + qs, + ); responseData = responseData.splice(0, qs.limit); } } @@ -388,18 +477,31 @@ export class HelpScout implements INodeType { delete body.customerEmail; } if (body.customer === undefined) { - throw new NodeOperationError(this.getNode(), 'Either customer email or customer ID must be set', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Either customer email or customer ID must be set', + { itemIndex: i }, + ); } if (attachments) { - if (attachments.attachmentsValues - && (attachments.attachmentsValues as IDataObject[]).length !== 0) { - body.attachments?.push.apply(body.attachments, attachments.attachmentsValues as IAttachment[]); + if ( + attachments.attachmentsValues && + (attachments.attachmentsValues as IDataObject[]).length !== 0 + ) { + body.attachments?.push.apply( + body.attachments, + attachments.attachmentsValues as IAttachment[], + ); } - if (attachments.attachmentsBinary - && (attachments.attachmentsBinary as IDataObject[]).length !== 0 - && items[i].binary) { + if ( + attachments.attachmentsBinary && + (attachments.attachmentsBinary as IDataObject[]).length !== 0 && + items[i].binary + ) { const mapFunction = (value: IDataObject): IAttachment => { - const binaryProperty = (items[i].binary as IBinaryKeyData)[value.property as string]; + const binaryProperty = (items[i].binary as IBinaryKeyData)[ + value.property as string + ]; if (binaryProperty) { return { fileName: binaryProperty.fileName || 'unknown', @@ -407,13 +509,27 @@ export class HelpScout implements INodeType { mimeType: binaryProperty.mimeType, }; } else { - throw new NodeOperationError(this.getNode(), `Binary property ${value.property} does not exist on input`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Binary property ${value.property} does not exist on input`, + { itemIndex: i }, + ); } }; - body.attachments?.push.apply(body.attachments, (attachments.attachmentsBinary as IDataObject[]).map(mapFunction) as IAttachment[]); + body.attachments?.push.apply( + body.attachments, + (attachments.attachmentsBinary as IDataObject[]).map( + mapFunction, + ) as IAttachment[], + ); } } - responseData = await helpscoutApiRequest.call(this, 'POST', `/v2/conversations/${conversationId}/chats`, body); + responseData = await helpscoutApiRequest.call( + this, + 'POST', + `/v2/conversations/${conversationId}/chats`, + body, + ); responseData = { success: true }; } //https://developer.helpscout.com/mailbox-api/endpoints/conversations/threads/list @@ -421,10 +537,22 @@ export class HelpScout implements INodeType { const returnAll = this.getNodeParameter('returnAll', i) as boolean; const conversationId = this.getNodeParameter('conversationId', i) as string; if (returnAll) { - responseData = await helpscoutApiRequestAllItems.call(this, '_embedded.threads', 'GET', `/v2/conversations/${conversationId}/threads`); + responseData = await helpscoutApiRequestAllItems.call( + this, + '_embedded.threads', + 'GET', + `/v2/conversations/${conversationId}/threads`, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await helpscoutApiRequestAllItems.call(this, '_embedded.threads', 'GET', `/v2/conversations/${conversationId}/threads`, {}, qs); + responseData = await helpscoutApiRequestAllItems.call( + this, + '_embedded.threads', + 'GET', + `/v2/conversations/${conversationId}/threads`, + {}, + qs, + ); responseData = responseData.splice(0, qs.limit); } } diff --git a/packages/nodes-base/nodes/HelpScout/HelpScoutTrigger.node.ts b/packages/nodes-base/nodes/HelpScout/HelpScoutTrigger.node.ts index 472922b4cb..4417634f14 100644 --- a/packages/nodes-base/nodes/HelpScout/HelpScoutTrigger.node.ts +++ b/packages/nodes-base/nodes/HelpScout/HelpScoutTrigger.node.ts @@ -1,23 +1,10 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import { - IDataObject, - INodeType, - INodeTypeDescription, - IWebhookResponseData, -} from 'n8n-workflow'; +import { IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; -import { - helpscoutApiRequest, - helpscoutApiRequestAllItems, -} from './GenericFunctions'; +import { helpscoutApiRequest, helpscoutApiRequestAllItems } from './GenericFunctions'; -import { - createHmac, -} from 'crypto'; +import { createHmac } from 'crypto'; export class HelpScoutTrigger implements INodeType { description: INodeTypeDescription = { @@ -52,7 +39,6 @@ export class HelpScoutTrigger implements INodeType { name: 'events', type: 'multiOptions', options: [ - { name: 'Conversation - Assigned', value: 'convo.assigned', @@ -106,7 +92,6 @@ export class HelpScoutTrigger implements INodeType { required: true, }, ], - }; // @ts-ignore (because of request) @@ -120,13 +105,18 @@ export class HelpScoutTrigger implements INodeType { // Check all the webhooks which exist already if it is identical to the // one that is supposed to get created. const endpoint = '/v2/webhooks'; - const data = await helpscoutApiRequestAllItems.call(this, '_embedded.webhooks', 'GET', endpoint, {}); + const data = await helpscoutApiRequestAllItems.call( + this, + '_embedded.webhooks', + 'GET', + endpoint, + {}, + ); for (const webhook of data) { if (webhook.url === webhookUrl) { for (const event of events) { - if (!webhook.events.includes(event) - && webhook.state === 'enabled') { + if (!webhook.events.includes(event) && webhook.state === 'enabled') { return false; } } @@ -150,7 +140,15 @@ export class HelpScoutTrigger implements INodeType { secret: Math.random().toString(36).substring(2, 15), }; - const responseData = await helpscoutApiRequest.call(this, 'POST', endpoint, body, {}, undefined, { resolveWithFullResponse: true }); + const responseData = await helpscoutApiRequest.call( + this, + 'POST', + endpoint, + body, + {}, + undefined, + { resolveWithFullResponse: true }, + ); if (responseData.headers['resource-id'] === undefined) { // Required data is missing so was not successful @@ -164,7 +162,6 @@ export class HelpScoutTrigger implements INodeType { async delete(this: IHookFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); if (webhookData.webhookId !== undefined) { - const endpoint = `/v2/webhooks/${webhookData.webhookId}`; try { await helpscoutApiRequest.call(this, 'DELETE', endpoint); @@ -190,15 +187,16 @@ export class HelpScoutTrigger implements INodeType { if (headerData['x-helpscout-signature'] === undefined) { return {}; } - //@ts-ignore - const computedSignature = createHmac('sha1', webhookData.secret as string).update(req.rawBody).digest('base64'); + + const computedSignature = createHmac('sha1', webhookData.secret as string) + //@ts-ignore + .update(req.rawBody) + .digest('base64'); if (headerData['x-helpscout-signature'] !== computedSignature) { return {}; } return { - workflowData: [ - this.helpers.returnJsonArray(bodyData), - ], + workflowData: [this.helpers.returnJsonArray(bodyData)], }; } } diff --git a/packages/nodes-base/nodes/HelpScout/MailboxDescription.ts b/packages/nodes-base/nodes/HelpScout/MailboxDescription.ts index 7bbde2292b..14d5f0a9bd 100644 --- a/packages/nodes-base/nodes/HelpScout/MailboxDescription.ts +++ b/packages/nodes-base/nodes/HelpScout/MailboxDescription.ts @@ -8,9 +8,7 @@ export const mailboxOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'mailbox', - ], + resource: ['mailbox'], }, }, options: [ @@ -32,10 +30,9 @@ export const mailboxOperations: INodeProperties[] = [ ]; export const mailboxFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* mailbox:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* mailbox:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Mailbox ID', name: 'mailboxId', @@ -44,30 +41,22 @@ export const mailboxFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'mailbox', - ], - operation: [ - 'get', - ], + resource: ['mailbox'], + operation: ['get'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* mailbox:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* mailbox:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'mailbox', - ], + operation: ['getAll'], + resource: ['mailbox'], }, }, default: false, @@ -79,15 +68,9 @@ export const mailboxFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'mailbox', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['mailbox'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/HelpScout/ThreadDescription.ts b/packages/nodes-base/nodes/HelpScout/ThreadDescription.ts index be8888bfce..51fb379ea0 100644 --- a/packages/nodes-base/nodes/HelpScout/ThreadDescription.ts +++ b/packages/nodes-base/nodes/HelpScout/ThreadDescription.ts @@ -8,9 +8,7 @@ export const threadOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'thread', - ], + resource: ['thread'], }, }, options: [ @@ -32,9 +30,9 @@ export const threadOperations: INodeProperties[] = [ ]; export const threadFields: INodeProperties[] = [ -/* -------------------------------------------------------------------------- */ -/* thread:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* thread:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Conversation ID', name: 'conversationId', @@ -43,12 +41,8 @@ export const threadFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'thread', - ], - operation: [ - 'create', - ], + resource: ['thread'], + operation: ['create'], }, }, }, @@ -59,12 +53,8 @@ export const threadFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'thread', - ], - operation: [ - 'create', - ], + resource: ['thread'], + operation: ['create'], }, }, options: [ @@ -102,12 +92,8 @@ export const threadFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'thread', - ], - operation: [ - 'create', - ], + resource: ['thread'], + operation: ['create'], }, }, description: 'The chat text', @@ -120,12 +106,8 @@ export const threadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'thread', - ], + operation: ['create'], + resource: ['thread'], }, }, options: [ @@ -154,9 +136,7 @@ export const threadFields: INodeProperties[] = [ default: false, displayOptions: { show: { - '/type': [ - 'note', - ], + '/type': ['note'], }, }, description: 'Whether a draft reply is created', @@ -180,12 +160,8 @@ export const threadFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'thread', - ], + operation: ['create'], + resource: ['thread'], }, }, options: [ @@ -226,7 +202,8 @@ export const threadFields: INodeProperties[] = [ name: 'property', type: 'string', default: 'data', - description: 'Name of the binary properties which contain data which should be added to email as attachment', + description: + 'Name of the binary properties which contain data which should be added to email as attachment', }, ], }, @@ -234,9 +211,9 @@ export const threadFields: INodeProperties[] = [ default: {}, description: 'Array of supported attachments to add to the message', }, -/* -------------------------------------------------------------------------- */ -/* thread:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* thread:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Conversation ID', name: 'conversationId', @@ -245,12 +222,8 @@ export const threadFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'thread', - ], - operation: [ - 'getAll', - ], + resource: ['thread'], + operation: ['getAll'], }, }, }, @@ -260,12 +233,8 @@ export const threadFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'thread', - ], + operation: ['getAll'], + resource: ['thread'], }, }, default: false, @@ -277,15 +246,9 @@ export const threadFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'thread', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['thread'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/HomeAssistant/CameraProxyDescription.ts b/packages/nodes-base/nodes/HomeAssistant/CameraProxyDescription.ts index 49197dec5b..c612a118e2 100644 --- a/packages/nodes-base/nodes/HomeAssistant/CameraProxyDescription.ts +++ b/packages/nodes-base/nodes/HomeAssistant/CameraProxyDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const cameraProxyOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const cameraProxyOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'cameraProxy', - ], + resource: ['cameraProxy'], }, }, options: [ @@ -35,7 +31,8 @@ export const cameraProxyFields: INodeProperties[] = [ displayName: 'Camera Entity Name or ID', name: 'cameraEntityId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCameraEntities', }, @@ -43,12 +40,8 @@ export const cameraProxyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getScreenshot', - ], - resource: [ - 'cameraProxy', - ], + operation: ['getScreenshot'], + resource: ['cameraProxy'], }, }, }, @@ -60,12 +53,8 @@ export const cameraProxyFields: INodeProperties[] = [ default: 'data', displayOptions: { show: { - operation: [ - 'getScreenshot', - ], - resource: [ - 'cameraProxy', - ], + operation: ['getScreenshot'], + resource: ['cameraProxy'], }, }, description: 'Name of the binary property to which to write the data of the read file', diff --git a/packages/nodes-base/nodes/HomeAssistant/ConfigDescription.ts b/packages/nodes-base/nodes/HomeAssistant/ConfigDescription.ts index 6e70fbe4b2..a306ab9240 100644 --- a/packages/nodes-base/nodes/HomeAssistant/ConfigDescription.ts +++ b/packages/nodes-base/nodes/HomeAssistant/ConfigDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const configOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const configOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'config', - ], + resource: ['config'], }, }, options: [ diff --git a/packages/nodes-base/nodes/HomeAssistant/EventDescription.ts b/packages/nodes-base/nodes/HomeAssistant/EventDescription.ts index 0807a79d8f..4aa2ea7700 100644 --- a/packages/nodes-base/nodes/HomeAssistant/EventDescription.ts +++ b/packages/nodes-base/nodes/HomeAssistant/EventDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const eventOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const eventOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'event', - ], + resource: ['event'], }, }, options: [ @@ -34,7 +30,6 @@ export const eventOperations: INodeProperties[] = [ ]; export const eventFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* event:getAll */ /* -------------------------------------------------------------------------- */ @@ -44,12 +39,8 @@ export const eventFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'event', - ], + operation: ['getAll'], + resource: ['event'], }, }, default: false, @@ -61,15 +52,9 @@ export const eventFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'event', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['event'], + returnAll: [false], }, }, typeOptions: { @@ -89,12 +74,8 @@ export const eventFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'event', - ], + operation: ['create'], + resource: ['event'], }, }, required: true, @@ -112,12 +93,8 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'create', - ], + resource: ['event'], + operation: ['create'], }, }, options: [ diff --git a/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts b/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts index 6fcef17943..6efb65e990 100644 --- a/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts @@ -1,20 +1,18 @@ -import { - OptionsWithUri -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - INodePropertyOptions, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, INodePropertyOptions, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function homeAssistantApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: IDataObject = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}) { +export async function homeAssistantApiRequest( + this: IExecuteFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + body: IDataObject = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, +) { const credentials = await this.getCredentials('homeAssistantApi'); let options: OptionsWithUri = { @@ -24,7 +22,11 @@ export async function homeAssistantApiRequest(this: IExecuteFunctions | ILoadOpt method, qs, body, - uri: uri ?? `${credentials.ssl === true ? 'https' : 'http'}://${credentials.host}:${credentials.port}/api${resource}`, + uri: + uri ?? + `${credentials.ssl === true ? 'https' : 'http'}://${credentials.host}:${ + credentials.port + }/api${resource}`, json: true, }; @@ -41,13 +43,16 @@ export async function homeAssistantApiRequest(this: IExecuteFunctions | ILoadOpt } } -export async function getHomeAssistantEntities(this: IExecuteFunctions | ILoadOptionsFunctions, domain = '') { +export async function getHomeAssistantEntities( + this: IExecuteFunctions | ILoadOptionsFunctions, + domain = '', +) { const returnData: INodePropertyOptions[] = []; const entities = await homeAssistantApiRequest.call(this, 'GET', '/states'); for (const entity of entities) { const entityId = entity.entity_id as string; - if (domain === '' || domain && entityId.startsWith(domain)) { - const entityName = entity.attributes.friendly_name as string || entityId; + if (domain === '' || (domain && entityId.startsWith(domain))) { + const entityName = (entity.attributes.friendly_name as string) || entityId; returnData.push({ name: entityName, value: entityId, @@ -57,7 +62,10 @@ export async function getHomeAssistantEntities(this: IExecuteFunctions | ILoadOp return returnData; } -export async function getHomeAssistantServices(this: IExecuteFunctions | ILoadOptionsFunctions, domain = '') { +export async function getHomeAssistantServices( + this: IExecuteFunctions | ILoadOptionsFunctions, + domain = '', +) { const returnData: INodePropertyOptions[] = []; const services = await homeAssistantApiRequest.call(this, 'GET', '/services'); if (domain === '') { diff --git a/packages/nodes-base/nodes/HomeAssistant/HistoryDescription.ts b/packages/nodes-base/nodes/HomeAssistant/HistoryDescription.ts index f6db6a0012..43efdbf85d 100644 --- a/packages/nodes-base/nodes/HomeAssistant/HistoryDescription.ts +++ b/packages/nodes-base/nodes/HomeAssistant/HistoryDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const historyOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const historyOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'history', - ], + resource: ['history'], }, }, options: [ @@ -37,12 +33,8 @@ export const historyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'history', - ], + operation: ['getAll'], + resource: ['history'], }, }, default: false, @@ -54,15 +46,9 @@ export const historyFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'history', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['history'], + returnAll: [false], }, }, typeOptions: { @@ -80,12 +66,8 @@ export const historyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'history', - ], - operation: [ - 'getAll', - ], + resource: ['history'], + operation: ['getAll'], }, }, options: [ diff --git a/packages/nodes-base/nodes/HomeAssistant/HomeAssistant.node.ts b/packages/nodes-base/nodes/HomeAssistant/HomeAssistant.node.ts index fd133ac185..217f78fecc 100644 --- a/packages/nodes-base/nodes/HomeAssistant/HomeAssistant.node.ts +++ b/packages/nodes-base/nodes/HomeAssistant/HomeAssistant.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -14,44 +12,21 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - configOperations, -} from './ConfigDescription'; +import { configOperations } from './ConfigDescription'; -import { - serviceFields, - serviceOperations, -} from './ServiceDescription'; +import { serviceFields, serviceOperations } from './ServiceDescription'; -import { - stateFields, - stateOperations, -} from './StateDescription'; +import { stateFields, stateOperations } from './StateDescription'; -import { - eventFields, - eventOperations, -} from './EventDescription'; +import { eventFields, eventOperations } from './EventDescription'; -import { - logFields, - logOperations, -} from './LogDescription'; +import { logFields, logOperations } from './LogDescription'; -import { - templateFields, - templateOperations, -} from './TemplateDescription'; +import { templateFields, templateOperations } from './TemplateDescription'; -import { - historyFields, - historyOperations, -} from './HistoryDescription'; +import { historyFields, historyOperations } from './HistoryDescription'; -import { - cameraProxyFields, - cameraProxyOperations, -} from './CameraProxyDescription'; +import { cameraProxyFields, cameraProxyOperations } from './CameraProxyDescription'; import { getHomeAssistantEntities, @@ -142,14 +117,19 @@ export class HomeAssistant implements INodeType { methods = { credentialTest: { - async homeAssistantApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { + async homeAssistantApiTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { const credentials = credential.data; const options = { method: 'GET', headers: { Authorization: `Bearer ${credentials!.accessToken}`, }, - uri: `${credentials!.ssl === true ? 'https' : 'http'}://${credentials!.host}:${ credentials!.port || '8123' }/api/`, + uri: `${credentials!.ssl === true ? 'https' : 'http'}://${credentials!.host}:${ + credentials!.port || '8123' + }/api/`, json: true, timeout: 5000, }; @@ -164,7 +144,9 @@ export class HomeAssistant implements INodeType { } catch (error) { return { status: 'Error', - message: `${error.statusCode === 401 ? 'Token is' : 'Settings are'} not valid: ${error}`, + message: `${ + error.statusCode === 401 ? 'Token is' : 'Settings are' + } not valid: ${error}`, }; } @@ -194,7 +176,6 @@ export class HomeAssistant implements INodeType { } }, }, - }; async execute(this: IExecuteFunctions): Promise { @@ -211,12 +192,20 @@ export class HomeAssistant implements INodeType { if (operation === 'get') { responseData = await homeAssistantApiRequest.call(this, 'GET', '/config'); } else if (operation === 'check') { - responseData = await homeAssistantApiRequest.call(this, 'POST', '/config/core/check_config'); + responseData = await homeAssistantApiRequest.call( + this, + 'POST', + '/config/core/check_config', + ); } } else if (resource === 'service') { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; - responseData = await homeAssistantApiRequest.call(this, 'GET', '/services') as IDataObject[]; + responseData = (await homeAssistantApiRequest.call( + this, + 'GET', + '/services', + )) as IDataObject[]; if (!returnAll) { const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); @@ -225,23 +214,26 @@ export class HomeAssistant implements INodeType { const domain = this.getNodeParameter('domain', i) as string; const service = this.getNodeParameter('service', i) as string; const serviceAttributes = this.getNodeParameter('serviceAttributes', i) as { - attributes: IDataObject[], + attributes: IDataObject[]; }; const body: IDataObject = {}; if (Object.entries(serviceAttributes).length) { if (serviceAttributes.attributes !== undefined) { - serviceAttributes.attributes.map( - attribute => { - // @ts-ignore - body[attribute.name as string] = attribute.value; - }, - ); + serviceAttributes.attributes.map((attribute) => { + // @ts-ignore + body[attribute.name as string] = attribute.value; + }); } } - responseData = await homeAssistantApiRequest.call(this, 'POST', `/services/${domain}/${service}`, body); + responseData = await homeAssistantApiRequest.call( + this, + 'POST', + `/services/${domain}/${service}`, + body, + ); if (Array.isArray(responseData) && responseData.length === 0) { responseData = {}; } @@ -249,7 +241,11 @@ export class HomeAssistant implements INodeType { } else if (resource === 'state') { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; - responseData = await homeAssistantApiRequest.call(this, 'GET', '/states') as IDataObject[]; + responseData = (await homeAssistantApiRequest.call( + this, + 'GET', + '/states', + )) as IDataObject[]; if (!returnAll) { const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); @@ -261,7 +257,7 @@ export class HomeAssistant implements INodeType { const entityId = this.getNodeParameter('entityId', i) as string; const state = this.getNodeParameter('state', i) as string; const stateAttributes = this.getNodeParameter('stateAttributes', i) as { - attributes: IDataObject[], + attributes: IDataObject[]; }; const body = { @@ -271,21 +267,28 @@ export class HomeAssistant implements INodeType { if (Object.entries(stateAttributes).length) { if (stateAttributes.attributes !== undefined) { - stateAttributes.attributes.map( - attribute => { - // @ts-ignore - body.attributes[attribute.name as string] = attribute.value; - }, - ); + stateAttributes.attributes.map((attribute) => { + // @ts-ignore + body.attributes[attribute.name as string] = attribute.value; + }); } } - responseData = await homeAssistantApiRequest.call(this, 'POST', `/states/${entityId}`, body); + responseData = await homeAssistantApiRequest.call( + this, + 'POST', + `/states/${entityId}`, + body, + ); } } else if (resource === 'event') { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; - responseData = await homeAssistantApiRequest.call(this, 'GET', '/events') as IDataObject[]; + responseData = (await homeAssistantApiRequest.call( + this, + 'GET', + '/events', + )) as IDataObject[]; if (!returnAll) { const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); @@ -293,24 +296,26 @@ export class HomeAssistant implements INodeType { } else if (operation === 'create') { const eventType = this.getNodeParameter('eventType', i) as string; const eventAttributes = this.getNodeParameter('eventAttributes', i) as { - attributes: IDataObject[], + attributes: IDataObject[]; }; const body = {}; if (Object.entries(eventAttributes).length) { if (eventAttributes.attributes !== undefined) { - eventAttributes.attributes.map( - attribute => { - // @ts-ignore - body[attribute.name as string] = attribute.value; - }, - ); + eventAttributes.attributes.map((attribute) => { + // @ts-ignore + body[attribute.name as string] = attribute.value; + }); } } - responseData = await homeAssistantApiRequest.call(this, 'POST', `/events/${eventType}`, body); - + responseData = await homeAssistantApiRequest.call( + this, + 'POST', + `/events/${eventType}`, + body, + ); } } else if (resource === 'log') { if (operation === 'getErroLogs') { @@ -337,7 +342,6 @@ export class HomeAssistant implements INodeType { } responseData = await homeAssistantApiRequest.call(this, 'GET', endpoint, {}, qs); - } } else if (resource === 'template') { if (operation === 'create') { @@ -373,7 +377,13 @@ export class HomeAssistant implements INodeType { } } - responseData = await homeAssistantApiRequest.call(this, 'GET', endpoint, {}, qs) as IDataObject[]; + responseData = (await homeAssistantApiRequest.call( + this, + 'GET', + endpoint, + {}, + qs, + )) as IDataObject[]; if (!returnAll) { const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); @@ -382,15 +392,26 @@ export class HomeAssistant implements INodeType { } else if (resource === 'cameraProxy') { if (operation === 'getScreenshot') { const cameraEntityId = this.getNodeParameter('cameraEntityId', i) as string; - const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string; + const dataPropertyNameDownload = this.getNodeParameter( + 'binaryPropertyName', + i, + ) as string; const endpoint = `/camera_proxy/${cameraEntityId}`; let mimeType: string | undefined; - responseData = await homeAssistantApiRequest.call(this, 'GET', endpoint, {}, {}, undefined, { - encoding: null, - resolveWithFullResponse: true, - }); + responseData = await homeAssistantApiRequest.call( + this, + 'GET', + endpoint, + {}, + {}, + undefined, + { + encoding: null, + resolveWithFullResponse: true, + }, + ); const newItem: INodeExecutionData = { json: items[i].json, @@ -412,7 +433,11 @@ export class HomeAssistant implements INodeType { const data = Buffer.from(responseData.body as string); - items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data, 'screenshot.jpg', mimeType); + items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( + data, + 'screenshot.jpg', + mimeType, + ); } } } catch (error) { diff --git a/packages/nodes-base/nodes/HomeAssistant/LogDescription.ts b/packages/nodes-base/nodes/HomeAssistant/LogDescription.ts index 8976645ae2..caa00ff1a4 100644 --- a/packages/nodes-base/nodes/HomeAssistant/LogDescription.ts +++ b/packages/nodes-base/nodes/HomeAssistant/LogDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const logOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const logOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'log', - ], + resource: ['log'], }, }, options: [ @@ -45,12 +41,8 @@ export const logFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'log', - ], - operation: [ - 'getLogbookEntries', - ], + resource: ['log'], + operation: ['getLogbookEntries'], }, }, options: [ diff --git a/packages/nodes-base/nodes/HomeAssistant/ServiceDescription.ts b/packages/nodes-base/nodes/HomeAssistant/ServiceDescription.ts index d279fbd2b1..91700fce50 100644 --- a/packages/nodes-base/nodes/HomeAssistant/ServiceDescription.ts +++ b/packages/nodes-base/nodes/HomeAssistant/ServiceDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const serviceOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const serviceOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'service', - ], + resource: ['service'], }, }, options: [ @@ -43,12 +39,8 @@ export const serviceFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'service', - ], + operation: ['getAll'], + resource: ['service'], }, }, default: false, @@ -60,15 +52,9 @@ export const serviceFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'service', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['service'], + returnAll: [false], }, }, typeOptions: { @@ -86,7 +72,8 @@ export const serviceFields: INodeProperties[] = [ displayName: 'Domain Name or ID', name: 'domain', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getDomains', }, @@ -94,12 +81,8 @@ export const serviceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'service', - ], - operation: [ - 'call', - ], + resource: ['service'], + operation: ['call'], }, }, }, @@ -107,23 +90,18 @@ export const serviceFields: INodeProperties[] = [ displayName: 'Service Name or ID', name: 'service', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'domain', - ], + loadOptionsDependsOn: ['domain'], loadOptionsMethod: 'getDomainServices', }, default: '', required: true, displayOptions: { show: { - resource: [ - 'service', - ], - operation: [ - 'call', - ], + resource: ['service'], + operation: ['call'], }, }, }, @@ -138,12 +116,8 @@ export const serviceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'service', - ], - operation: [ - 'call', - ], + resource: ['service'], + operation: ['call'], }, }, options: [ diff --git a/packages/nodes-base/nodes/HomeAssistant/StateDescription.ts b/packages/nodes-base/nodes/HomeAssistant/StateDescription.ts index 65cb2b62b9..53efd98bea 100644 --- a/packages/nodes-base/nodes/HomeAssistant/StateDescription.ts +++ b/packages/nodes-base/nodes/HomeAssistant/StateDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const stateOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const stateOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'state', - ], + resource: ['state'], }, }, options: [ @@ -47,18 +43,15 @@ export const stateFields: INodeProperties[] = [ displayName: 'Entity Name or ID', name: 'entityId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getAllEntities', }, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'state', - ], + operation: ['get'], + resource: ['state'], }, }, required: true, @@ -74,12 +67,8 @@ export const stateFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'state', - ], + operation: ['getAll'], + resource: ['state'], }, }, default: false, @@ -91,15 +80,9 @@ export const stateFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'state', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['state'], + returnAll: [false], }, }, typeOptions: { @@ -122,17 +105,14 @@ export const stateFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'upsert', - ], - resource: [ - 'state', - ], + operation: ['upsert'], + resource: ['state'], }, }, required: true, default: '', - description: 'The entity ID for which a state will be created. Choose from the list, or specify an ID using an expression.', + description: + 'The entity ID for which a state will be created. Choose from the list, or specify an ID using an expression.', }, { displayName: 'State', @@ -142,12 +122,8 @@ export const stateFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'state', - ], - operation: [ - 'upsert', - ], + resource: ['state'], + operation: ['upsert'], }, }, }, @@ -162,12 +138,8 @@ export const stateFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'state', - ], - operation: [ - 'upsert', - ], + resource: ['state'], + operation: ['upsert'], }, }, options: [ diff --git a/packages/nodes-base/nodes/HomeAssistant/TemplateDescription.ts b/packages/nodes-base/nodes/HomeAssistant/TemplateDescription.ts index 4a016c9c94..5d2fcceb4a 100644 --- a/packages/nodes-base/nodes/HomeAssistant/TemplateDescription.ts +++ b/packages/nodes-base/nodes/HomeAssistant/TemplateDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const templateOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const templateOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'template', - ], + resource: ['template'], }, }, options: [ @@ -28,7 +24,6 @@ export const templateOperations: INodeProperties[] = [ ]; export const templateFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* template:create */ /* -------------------------------------------------------------------------- */ @@ -38,16 +33,13 @@ export const templateFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'template', - ], - operation: [ - 'create', - ], + resource: ['template'], + operation: ['create'], }, }, required: true, default: '', - description: 'Render a Home Assistant template. See template docs for more information..', + description: + 'Render a Home Assistant template. See template docs for more information..', }, ]; diff --git a/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts b/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts index b6c1d1e601..56a2c3235f 100644 --- a/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts +++ b/packages/nodes-base/nodes/HtmlExtract/HtmlExtract.node.ts @@ -18,18 +18,17 @@ interface IValueData { returnArray: boolean; } - // The extraction functions const extractFunctions: { [key: string]: ($: Cheerio, valueData: IValueData) => string | undefined; } = { - attribute: ($: Cheerio, valueData: IValueData): string | undefined => $.attr(valueData.attribute!), + attribute: ($: Cheerio, valueData: IValueData): string | undefined => + $.attr(valueData.attribute!), html: ($: Cheerio, valueData: IValueData): string | undefined => $.html() || undefined, text: ($: Cheerio, valueData: IValueData): string | undefined => $.text(), value: ($: Cheerio, valueData: IValueData): string | undefined => $.val(), }; - /** * Simple helper function which applies options */ @@ -42,7 +41,6 @@ function getValue($: Cheerio, valueData: IValueData, options: IDataObject) { return value.trim(); } - export class HtmlExtract implements INodeType { description: INodeTypeDescription = { displayName: 'HTML Extract', @@ -82,14 +80,13 @@ export class HtmlExtract implements INodeType { type: 'string', displayOptions: { show: { - sourceData: [ - 'binary', - ], + sourceData: ['binary'], }, }, default: 'data', required: true, - description: 'Name of the binary property in which the HTML to extract the data from can be found', + description: + 'Name of the binary property in which the HTML to extract the data from can be found', }, { displayName: 'JSON Property', @@ -97,14 +94,13 @@ export class HtmlExtract implements INodeType { type: 'string', displayOptions: { show: { - sourceData: [ - 'json', - ], + sourceData: ['json'], }, }, default: 'data', required: true, - description: 'Name of the JSON property in which the HTML to extract the data from can be found. The property can either contain a string or an array of strings.', + description: + 'Name of the JSON property in which the HTML to extract the data from can be found. The property can either contain a string or an array of strings.', }, { displayName: 'Extraction Values', @@ -170,9 +166,7 @@ export class HtmlExtract implements INodeType { type: 'string', displayOptions: { show: { - returnValue: [ - 'attribute', - ], + returnValue: ['attribute'], }, }, default: '', @@ -184,7 +178,8 @@ export class HtmlExtract implements INodeType { name: 'returnArray', type: 'boolean', default: false, - description: 'Whether to return the values as an array so if multiple ones get found they also get returned separately. If not set all will be returned as a single string.', + description: + 'Whether to return the values as an array so if multiple ones get found they also get returned separately. If not set all will be returned as a single string.', }, ], }, @@ -203,14 +198,14 @@ export class HtmlExtract implements INodeType { name: 'trimValues', type: 'boolean', default: true, - description: 'Whether to remove automatically all spaces and newlines from the beginning and end of the values', + description: + 'Whether to remove automatically all spaces and newlines from the beginning and end of the values', }, ], }, ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); @@ -220,7 +215,10 @@ export class HtmlExtract implements INodeType { for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { try { const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex) as string; - const extractionValues = this.getNodeParameter('extractionValues', itemIndex) as IDataObject; + const extractionValues = this.getNodeParameter( + 'extractionValues', + itemIndex, + ) as IDataObject; const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; const sourceData = this.getNodeParameter('sourceData', itemIndex) as string; @@ -229,18 +227,31 @@ export class HtmlExtract implements INodeType { let htmlArray: string[] | string = []; if (sourceData === 'json') { if (item.json[dataPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No property named "${dataPropertyName}" exists!`, { itemIndex }); + throw new NodeOperationError( + this.getNode(), + `No property named "${dataPropertyName}" exists!`, + { itemIndex }, + ); } htmlArray = item.json[dataPropertyName] as string; } else { if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), `No item does not contain binary data!`, { itemIndex }); + throw new NodeOperationError(this.getNode(), `No item does not contain binary data!`, { + itemIndex, + }); } if (item.binary[dataPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No property named "${dataPropertyName}" exists!`, { itemIndex }); + throw new NodeOperationError( + this.getNode(), + `No property named "${dataPropertyName}" exists!`, + { itemIndex }, + ); } - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, dataPropertyName); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + itemIndex, + dataPropertyName, + ); htmlArray = binaryDataBuffer.toString('utf-8'); } @@ -269,7 +280,9 @@ export class HtmlExtract implements INodeType { // value at a time newItem.json[valueData.key as string] = []; htmlElement.each((i, el) => { - (newItem.json[valueData.key as string] as Array).push(getValue($(el), valueData, options)); + (newItem.json[valueData.key as string] as Array).push( + getValue($(el), valueData, options), + ); }); } else { // One single value should be returned diff --git a/packages/nodes-base/nodes/HttpRequest/GenericFunctions.ts b/packages/nodes-base/nodes/HttpRequest/GenericFunctions.ts index 2f4793c75f..067ce5da35 100644 --- a/packages/nodes-base/nodes/HttpRequest/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HttpRequest/GenericFunctions.ts @@ -2,7 +2,7 @@ import { INodeExecutionData } from 'n8n-workflow'; export const replaceNullValues = (item: INodeExecutionData) => { if (item.json === null) { - item.json = {}; + item.json = {}; } return item; }; diff --git a/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts b/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts index 8e8ea150fc..6f655154d5 100644 --- a/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/HttpRequest.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryData, IDataObject, @@ -24,7 +22,6 @@ interface OptionDataParamters { [key: string]: OptionData; } - export class HttpRequest implements INodeType { description: INodeTypeDescription = { displayName: 'HTTP Request', @@ -49,12 +46,8 @@ export class HttpRequest implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'httpBasicAuth', - ], - '@version': [ - 2, - ], + authentication: ['httpBasicAuth'], + '@version': [2], }, }, }, @@ -63,12 +56,8 @@ export class HttpRequest implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'httpDigestAuth', - ], - '@version': [ - 2, - ], + authentication: ['httpDigestAuth'], + '@version': [2], }, }, }, @@ -77,12 +66,8 @@ export class HttpRequest implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'httpHeaderAuth', - ], - '@version': [ - 2, - ], + authentication: ['httpHeaderAuth'], + '@version': [2], }, }, }, @@ -91,12 +76,8 @@ export class HttpRequest implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'httpQueryAuth', - ], - '@version': [ - 2, - ], + authentication: ['httpQueryAuth'], + '@version': [2], }, }, }, @@ -105,12 +86,8 @@ export class HttpRequest implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth1Api', - ], - '@version': [ - 2, - ], + authentication: ['oAuth1Api'], + '@version': [2], }, }, }, @@ -119,12 +96,8 @@ export class HttpRequest implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2Api', - ], - '@version': [ - 2, - ], + authentication: ['oAuth2Api'], + '@version': [2], }, }, }, @@ -137,12 +110,8 @@ export class HttpRequest implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'basicAuth', - ], - '@version': [ - 1, - ], + authentication: ['basicAuth'], + '@version': [1], }, }, }, @@ -151,12 +120,8 @@ export class HttpRequest implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'digestAuth', - ], - '@version': [ - 1, - ], + authentication: ['digestAuth'], + '@version': [1], }, }, }, @@ -165,12 +130,8 @@ export class HttpRequest implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'headerAuth', - ], - '@version': [ - 1, - ], + authentication: ['headerAuth'], + '@version': [1], }, }, }, @@ -179,12 +140,8 @@ export class HttpRequest implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'queryAuth', - ], - '@version': [ - 1, - ], + authentication: ['queryAuth'], + '@version': [1], }, }, }, @@ -193,12 +150,8 @@ export class HttpRequest implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth1', - ], - '@version': [ - 1, - ], + authentication: ['oAuth1'], + '@version': [1], }, }, }, @@ -207,9 +160,7 @@ export class HttpRequest implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -232,7 +183,8 @@ export class HttpRequest implements INodeType { { name: 'Predefined Credential Type', value: 'predefinedCredentialType', - description: 'We\'ve already implemented auth for many services so that you don\'t have to set it up manually', + description: + "We've already implemented auth for many services so that you don't have to set it up manually", }, { name: 'Generic Credential Type', @@ -243,9 +195,7 @@ export class HttpRequest implements INodeType { default: 'none', displayOptions: { show: { - '@version': [ - 2, - ], + '@version': [2], }, }, }, @@ -256,19 +206,11 @@ export class HttpRequest implements INodeType { noDataExpression: true, required: true, default: '', - credentialTypes: [ - 'extends:oAuth2Api', - 'extends:oAuth1Api', - 'has:authenticate', - ], + credentialTypes: ['extends:oAuth2Api', 'extends:oAuth1Api', 'has:authenticate'], displayOptions: { show: { - authentication: [ - 'predefinedCredentialType', - ], - '@version': [ - 2, - ], + authentication: ['predefinedCredentialType'], + '@version': [2], }, }, }, @@ -278,17 +220,11 @@ export class HttpRequest implements INodeType { type: 'credentialsSelect', required: true, default: '', - credentialTypes: [ - 'has:genericAuth', - ], + credentialTypes: ['has:genericAuth'], displayOptions: { show: { - authentication: [ - 'genericCredentialType', - ], - '@version': [ - 2, - ], + authentication: ['genericCredentialType'], + '@version': [2], }, }, }, @@ -334,9 +270,7 @@ export class HttpRequest implements INodeType { description: 'The way to authenticate', displayOptions: { show: { - '@version': [ - 1, - ], + '@version': [1], }, }, }, @@ -396,7 +330,8 @@ export class HttpRequest implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-ignore-ssl-issues - description: 'Whether to download the response even if SSL certificate validation is not possible', + description: + 'Whether to download the response even if SSL certificate validation is not possible', }, { displayName: 'Response Format', @@ -427,9 +362,7 @@ export class HttpRequest implements INodeType { required: true, displayOptions: { show: { - responseFormat: [ - 'string', - ], + responseFormat: ['string'], }, }, description: 'Name of the property to which to write the response data', @@ -442,9 +375,7 @@ export class HttpRequest implements INodeType { required: true, displayOptions: { show: { - responseFormat: [ - 'file', - ], + responseFormat: ['file'], }, }, description: 'Name of the binary property to which to write the data of the read file', @@ -455,7 +386,8 @@ export class HttpRequest implements INodeType { name: 'jsonParameters', type: 'boolean', default: false, - description: 'Whether the query and/or body parameter should be set via the value-key pair UI or JSON/RAW', + description: + 'Whether the query and/or body parameter should be set via the value-key pair UI or JSON/RAW', }, { @@ -483,7 +415,8 @@ export class HttpRequest implements INodeType { minValue: -1, }, default: 50, - description: 'Input will be split in batches to throttle requests. -1 for disabled. 0 will be treated as 1.', + description: + 'Input will be split in batches to throttle requests. -1 for disabled. 0 will be treated as 1.', }, { displayName: 'Body Content Type', @@ -491,11 +424,7 @@ export class HttpRequest implements INodeType { type: 'options', displayOptions: { show: { - '/requestMethod': [ - 'PATCH', - 'POST', - 'PUT', - ], + '/requestMethod': ['PATCH', 'POST', 'PUT'], }, }, options: [ @@ -556,11 +485,7 @@ export class HttpRequest implements INodeType { description: 'Specify the mime type for raw/custom body type', displayOptions: { show: { - '/requestMethod': [ - 'PATCH', - 'POST', - 'PUT', - ], + '/requestMethod': ['PATCH', 'POST', 'PUT'], }, }, }, @@ -580,9 +505,7 @@ export class HttpRequest implements INodeType { description: 'Whether to output each element of an array as own item', displayOptions: { show: { - '/responseFormat': [ - 'json', - ], + '/responseFormat': ['json'], }, }, }, @@ -594,19 +517,20 @@ export class HttpRequest implements INodeType { minValue: 1, }, default: 10000, - description: 'Time in ms to wait for the server to send response headers (and start the response body) before aborting the request', + description: + 'Time in ms to wait for the server to send response headers (and start the response body) before aborting the request', }, { displayName: 'Use Querystring', name: 'useQueryString', type: 'boolean', default: false, - description: 'Whether you need arrays to be serialized as foo=bar&foo=baz instead of the default foo[0]=bar&foo[1]=baz', + description: + 'Whether you need arrays to be serialized as foo=bar&foo=baz instead of the default foo[0]=bar&foo[1]=baz', }, ], }, - // Body Parameter { displayName: 'Send Binary Data', @@ -618,14 +542,8 @@ export class HttpRequest implements INodeType { // 'options.bodyContentType': [ // 'raw', // ], - jsonParameters: [ - true, - ], - requestMethod: [ - 'PATCH', - 'POST', - 'PUT', - ], + jsonParameters: [true], + requestMethod: ['PATCH', 'POST', 'PUT'], }, }, default: false, @@ -639,22 +557,15 @@ export class HttpRequest implements INodeType { default: 'data', displayOptions: { hide: { - sendBinaryData: [ - false, - ], + sendBinaryData: [false], }, show: { - jsonParameters: [ - true, - ], - requestMethod: [ - 'PATCH', - 'POST', - 'PUT', - ], + jsonParameters: [true], + requestMethod: ['PATCH', 'POST', 'PUT'], }, }, - description: 'Name of the binary property which contains the data for the file to be uploaded. For Form-Data Multipart, they can be provided in the format: "sendKey1:binaryProperty1,sendKey2:binaryProperty2', + description: + 'Name of the binary property which contains the data for the file to be uploaded. For Form-Data Multipart, they can be provided in the format: "sendKey1:binaryProperty1,sendKey2:binaryProperty2', }, { displayName: 'Body Parameters', @@ -662,20 +573,11 @@ export class HttpRequest implements INodeType { type: 'json', displayOptions: { hide: { - sendBinaryData: [ - true, - ], + sendBinaryData: [true], }, show: { - jsonParameters: [ - true, - ], - requestMethod: [ - 'PATCH', - 'POST', - 'PUT', - 'DELETE', - ], + jsonParameters: [true], + requestMethod: ['PATCH', 'POST', 'PUT', 'DELETE'], }, }, default: '', @@ -691,15 +593,8 @@ export class HttpRequest implements INodeType { }, displayOptions: { show: { - jsonParameters: [ - false, - ], - requestMethod: [ - 'PATCH', - 'POST', - 'PUT', - 'DELETE', - ], + jsonParameters: [false], + requestMethod: ['PATCH', 'POST', 'PUT', 'DELETE'], }, }, description: 'The body parameter to send', @@ -735,9 +630,7 @@ export class HttpRequest implements INodeType { type: 'json', displayOptions: { show: { - jsonParameters: [ - true, - ], + jsonParameters: [true], }, }, default: '', @@ -753,9 +646,7 @@ export class HttpRequest implements INodeType { }, displayOptions: { show: { - jsonParameters: [ - false, - ], + jsonParameters: [false], }, }, description: 'The headers to send', @@ -791,9 +682,7 @@ export class HttpRequest implements INodeType { type: 'json', displayOptions: { show: { - jsonParameters: [ - true, - ], + jsonParameters: [true], }, }, default: '', @@ -809,9 +698,7 @@ export class HttpRequest implements INodeType { }, displayOptions: { show: { - jsonParameters: [ - false, - ], + jsonParameters: [false], }, }, description: 'The query parameter to send', @@ -845,12 +732,7 @@ export class HttpRequest implements INodeType { async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); - const fullReponseProperties = [ - 'body', - 'headers', - 'statusCode', - 'statusMessage', - ]; + const fullReponseProperties = ['body', 'headers', 'statusCode', 'statusMessage']; let authentication; const nodeVersion = this.getNode().typeVersion; @@ -858,7 +740,10 @@ export class HttpRequest implements INodeType { const responseFormat = this.getNodeParameter('responseFormat', 0) as string; try { - authentication = this.getNodeParameter('authentication', 0) as 'predefinedCredentialType' | 'genericCredentialType' | 'none'; + authentication = this.getNodeParameter('authentication', 0) as + | 'predefinedCredentialType' + | 'genericCredentialType' + | 'none'; } catch (_) {} let httpBasicAuth; @@ -926,11 +811,16 @@ export class HttpRequest implements INodeType { const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; const url = this.getNodeParameter('url', itemIndex) as string; - if (itemIndex > 0 && options.batchSize as number >= 0 && options.batchInterval as number > 0) { + if ( + itemIndex > 0 && + (options.batchSize as number) >= 0 && + (options.batchInterval as number) > 0 + ) { // defaults batch size to 1 of it's set to 0 - const batchSize: number = options.batchSize as number > 0 ? options.batchSize as number : 1; + const batchSize: number = + (options.batchSize as number) > 0 ? (options.batchSize as number) : 1; if (itemIndex % batchSize === 0) { - await new Promise(resolve => setTimeout(resolve, options.batchInterval as number)); + await new Promise((resolve) => setTimeout(resolve, options.batchInterval as number)); } } @@ -941,7 +831,11 @@ export class HttpRequest implements INodeType { method: requestMethod, uri: url, gzip: true, - rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false) as boolean, + rejectUnauthorized: !this.getNodeParameter( + 'allowUnauthorizedCerts', + itemIndex, + false, + ) as boolean, }; if (fullResponse === true) { @@ -980,40 +874,61 @@ export class HttpRequest implements INodeType { for (const parameterName of Object.keys(jsonParameters)) { optionData = jsonParameters[parameterName] as OptionData; const tempValue = this.getNodeParameter(parameterName, itemIndex, '') as string | object; - const sendBinaryData = this.getNodeParameter('sendBinaryData', itemIndex, false) as boolean; + const sendBinaryData = this.getNodeParameter( + 'sendBinaryData', + itemIndex, + false, + ) as boolean; if (optionData.name === 'body' && parametersAreJson === true) { if (sendBinaryData === true) { - - const contentTypesAllowed = [ - 'raw', - 'multipart-form-data', - ]; + const contentTypesAllowed = ['raw', 'multipart-form-data']; if (!contentTypesAllowed.includes(options.bodyContentType as string)) { // As n8n-workflow.NodeHelpers.getParamterResolveOrder can not be changed // easily to handle parameters in dot.notation simply error for now. - throw new NodeOperationError(this.getNode(), 'Sending binary data is only supported when option "Body Content Type" is set to "RAW/CUSTOM" or "FORM-DATA/MULTIPART"!', { itemIndex }); + throw new NodeOperationError( + this.getNode(), + 'Sending binary data is only supported when option "Body Content Type" is set to "RAW/CUSTOM" or "FORM-DATA/MULTIPART"!', + { itemIndex }, + ); } const item = items[itemIndex]; if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex, + }); } if (options.bodyContentType === 'raw') { - const binaryPropertyName = this.getNodeParameter('binaryPropertyName', itemIndex) as string; + const binaryPropertyName = this.getNodeParameter( + 'binaryPropertyName', + itemIndex, + ) as string; if (item.binary[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + { itemIndex }, + ); } - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + itemIndex, + binaryPropertyName, + ); requestOptions.body = binaryDataBuffer; } else if (options.bodyContentType === 'multipart-form-data') { requestOptions.body = {}; - const binaryPropertyNameFull = this.getNodeParameter('binaryPropertyName', itemIndex) as string; - const binaryPropertyNames = binaryPropertyNameFull.split(',').map(key => key.trim()); + const binaryPropertyNameFull = this.getNodeParameter( + 'binaryPropertyName', + itemIndex, + ) as string; + const binaryPropertyNames = binaryPropertyNameFull + .split(',') + .map((key) => key.trim()); for (const propertyData of binaryPropertyNames) { let propertyName = 'file'; @@ -1023,15 +938,25 @@ export class HttpRequest implements INodeType { propertyName = propertyDataParts[0]; binaryPropertyName = propertyDataParts[1]; } else if (binaryPropertyNames.length > 1) { - throw new NodeOperationError(this.getNode(), 'If more than one property should be send it is needed to define the in the format:"sendKey1:binaryProperty1,sendKey2:binaryProperty2"', { itemIndex }); + throw new NodeOperationError( + this.getNode(), + 'If more than one property should be send it is needed to define the in the format:"sendKey1:binaryProperty1,sendKey2:binaryProperty2"', + { itemIndex }, + ); } if (item.binary[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + ); } const binaryProperty = item.binary[binaryPropertyName] as IBinaryData; - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + itemIndex, + binaryPropertyName, + ); requestOptions.body[propertyName] = { value: binaryDataBuffer, @@ -1054,14 +979,21 @@ export class HttpRequest implements INodeType { // @ts-ignore requestOptions[optionData.name] = tempValue; - // @ts-ignore - if (typeof requestOptions[optionData.name] !== 'object' && options.bodyContentType !== 'raw') { + if ( + // @ts-ignore + typeof requestOptions[optionData.name] !== 'object' && + options.bodyContentType !== 'raw' + ) { // If it is not an object && bodyContentType is not 'raw' it must be JSON so parse it try { // @ts-ignore requestOptions[optionData.name] = JSON.parse(requestOptions[optionData.name]); } catch (error) { - throw new NodeOperationError(this.getNode(), `The data in "${optionData.displayName}" is no valid JSON. Set Body Content Type to "RAW/Custom" for XML or other types of payloads`, { itemIndex }); + throw new NodeOperationError( + this.getNode(), + `The data in "${optionData.displayName}" is no valid JSON. Set Body Content Type to "RAW/Custom" for XML or other types of payloads`, + { itemIndex }, + ); } } } @@ -1087,7 +1019,9 @@ export class HttpRequest implements INodeType { return newValue; } }; - requestOptions[optionName][parameterDataName] = computeNewValue(requestOptions[optionName][parameterDataName]); + requestOptions[optionName][parameterDataName] = computeNewValue( + requestOptions[optionName][parameterDataName], + ); } else if (optionName === 'headers') { // @ts-ignore requestOptions[optionName][parameterDataName.toString().toLowerCase()] = newValue; @@ -1165,9 +1099,11 @@ export class HttpRequest implements INodeType { if (responseFormat === 'json') { requestOptions.headers!['accept'] = 'application/json,text/*;q=0.99'; } else if (responseFormat === 'string') { - requestOptions.headers!['accept'] = 'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, */*;q=0.1'; + requestOptions.headers!['accept'] = + 'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, */*;q=0.1'; } else { - requestOptions.headers!['accept'] = 'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7'; + requestOptions.headers!['accept'] = + 'application/json,text/html,application/xhtml+xml,application/xml,text/*;q=0.9, image/*;q=0.8, */*;q=0.7'; } } @@ -1181,7 +1117,7 @@ export class HttpRequest implements INodeType { }; } this.sendMessageToUI(sendRequest); - } catch (e) { } + } catch (e) {} if ( authentication === 'genericCredentialType' || @@ -1189,21 +1125,18 @@ export class HttpRequest implements INodeType { nodeVersion === 1 ) { if (oAuth1Api) { - requestPromises.push( - this.helpers.requestOAuth1.call(this, 'oAuth1Api', requestOptions), - ); + requestPromises.push(this.helpers.requestOAuth1.call(this, 'oAuth1Api', requestOptions)); } else if (oAuth2Api) { requestPromises.push( - this.helpers.requestOAuth2.call(this, 'oAuth2Api', requestOptions, { tokenType: 'Bearer' }), + this.helpers.requestOAuth2.call(this, 'oAuth2Api', requestOptions, { + tokenType: 'Bearer', + }), ); } else { // bearerAuth, queryAuth, headerAuth, digestAuth, none - requestPromises.push( - this.helpers.request(requestOptions), - ); + requestPromises.push(this.helpers.request(requestOptions)); } } else if (authentication === 'predefinedCredentialType' && nodeCredentialType) { - const oAuth2Options: { [credentialType: string]: IOAuth2Options } = { clickUpOAuth2Api: { keepBearer: false, @@ -1250,16 +1183,14 @@ export class HttpRequest implements INodeType { throw new NodeApiError(this.getNode(), response); } else { // Return the actual reason as error - returnItems.push( - { - json: { - error: response.reason, - }, - pairedItem: { - item: itemIndex, - }, + returnItems.push({ + json: { + error: response.reason, }, - ); + pairedItem: { + item: itemIndex, + }, + }); continue; } } @@ -1290,8 +1221,7 @@ export class HttpRequest implements INodeType { Object.assign(newItem.binary, items[itemIndex].binary); } - - const fileName = (url).split('/').pop(); + const fileName = url.split('/').pop(); if (fullResponse === true) { const returnItem: IDataObject = {}; @@ -1304,11 +1234,17 @@ export class HttpRequest implements INodeType { newItem.json = returnItem; - newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData(response!.body, fileName); + newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData( + response!.body, + fileName, + ); } else { newItem.json = items[itemIndex].json; - newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData(response!, fileName); + newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData( + response!, + fileName, + ); } returnItems.push(newItem); @@ -1353,7 +1289,11 @@ export class HttpRequest implements INodeType { try { returnItem.body = JSON.parse(returnItem.body); } catch (error) { - throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"', { itemIndex }); + throw new NodeOperationError( + this.getNode(), + 'Response body is not valid JSON. Change "Response Format" to "String"', + { itemIndex }, + ); } } @@ -1368,17 +1308,23 @@ export class HttpRequest implements INodeType { try { response = JSON.parse(response); } catch (error) { - throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"', { itemIndex }); + throw new NodeOperationError( + this.getNode(), + 'Response body is not valid JSON. Change "Response Format" to "String"', + { itemIndex }, + ); } } if (options.splitIntoItems === true && Array.isArray(response)) { - response.forEach(item => returnItems.push({ - json: item, - pairedItem: { - item: itemIndex, - }, - })); + response.forEach((item) => + returnItems.push({ + json: item, + pairedItem: { + item: itemIndex, + }, + }), + ); } else { returnItems.push({ json: response, diff --git a/packages/nodes-base/nodes/Hubspot/CompanyDescription.ts b/packages/nodes-base/nodes/Hubspot/CompanyDescription.ts index 72d1a62849..d2857f8001 100644 --- a/packages/nodes-base/nodes/Hubspot/CompanyDescription.ts +++ b/packages/nodes-base/nodes/Hubspot/CompanyDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const companyOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const companyOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'company', - ], + resource: ['company'], }, }, options: [ @@ -70,7 +66,6 @@ export const companyOperations: INodeProperties[] = [ ]; export const companyFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* company:create */ /* -------------------------------------------------------------------------- */ @@ -81,12 +76,8 @@ export const companyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], + resource: ['company'], + operation: ['create'], }, }, default: '', @@ -99,12 +90,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], + resource: ['company'], + operation: ['create'], }, }, options: [ @@ -156,7 +143,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getOwners', }, default: '', - description: 'The owner of the company. Choose from the list, or specify an ID using an expression.', + description: + 'The owner of the company. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Country/Region', @@ -187,7 +175,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyCustomProperties', }, default: '', - description: 'Name of the property. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the property. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -205,7 +194,7 @@ export const companyFields: INodeProperties[] = [ name: 'description', type: 'string', default: '', - description: 'A short statement about the company\'s mission and goals', + description: "A short statement about the company's mission and goals", }, { displayName: 'Facebook Fans', @@ -232,7 +221,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyIndustries', }, default: '', - description: 'The type of business the company performs. Choose from the list, or specify an ID using an expression.', + description: + 'The type of business the company performs. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Is Public', @@ -249,7 +239,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyleadStatuses', }, default: '', - description: 'The company\'s sales, prospecting or outreach status. Choose from the list, or specify an ID using an expression.', + description: + 'The company\'s sales, prospecting or outreach status. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Lifecycle Stage Name or ID', @@ -259,7 +250,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanylifecycleStages', }, default: '', - description: 'The most advanced lifecycle stage across all contacts associated with this company or organization. Choose from the list, or specify an ID using an expression.', + description: + 'The most advanced lifecycle stage across all contacts associated with this company or organization. Choose from the list, or specify an ID using an expression.', }, { displayName: 'LinkedIn Bio', @@ -293,42 +285,47 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanySourceTypes', }, default: '', - description: 'Original source for the contact with the earliest activity for this company or organization. Choose from the list, or specify an ID using an expression.', + description: + 'Original source for the contact with the earliest activity for this company or organization. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Phone Number', name: 'phoneNumber', type: 'string', default: '', - description: 'A company\'s primary phone number. Powered by HubSpot Insights.', + description: "A company's primary phone number. Powered by HubSpot Insights.", }, { displayName: 'Postal Code', name: 'postalCode', type: 'string', default: '', - description: 'The postal or zip code of the company or organization. Powered by HubSpot Insights.', + description: + 'The postal or zip code of the company or organization. Powered by HubSpot Insights.', }, { displayName: 'State/Region', name: 'stateRegion', type: 'string', default: '', - description: 'The state or region in which the company or organization is located. Powered by HubSpot Insights.', + description: + 'The state or region in which the company or organization is located. Powered by HubSpot Insights.', }, { displayName: 'Street Address', name: 'streetAddress', type: 'string', default: '', - description: 'The street address of the company or organization, including unit number. Powered by HubSpot Insights.', + description: + 'The street address of the company or organization, including unit number. Powered by HubSpot Insights.', }, { displayName: 'Street Address 2', name: 'streetAddress2', type: 'string', default: '', - description: 'The additional address of the company or organization. Powered by HubSpot Insights.', + description: + 'The additional address of the company or organization. Powered by HubSpot Insights.', }, { @@ -339,14 +336,16 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyTargetAccounts', }, default: '', - description: 'The Target Account property is a means to flag high priority companies if you are following an account based strategy. Choose from the list, or specify an ID using an expression.', + description: + 'The Target Account property is a means to flag high priority companies if you are following an account based strategy. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Timezone', name: 'timezone', type: 'string', default: '', - description: 'The time zone where the company or organization is located. Powered by HubSpot Insights.', + description: + 'The time zone where the company or organization is located. Powered by HubSpot Insights.', }, { displayName: 'Total Money Raised', @@ -356,7 +355,8 @@ export const companyFields: INodeProperties[] = [ minValue: 0, }, default: 0, - description: 'The total amount of money raised by the company. Powered by HubSpot Insights.', + description: + 'The total amount of money raised by the company. Powered by HubSpot Insights.', }, { displayName: 'Twitter Bio', @@ -393,7 +393,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyTypes', }, default: '', - description: 'The optional classification of this company record - prospect, partner, etc. Choose from the list, or specify an ID using an expression.', + description: + 'The optional classification of this company record - prospect, partner, etc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Web Technologies Name or ID', @@ -403,14 +404,16 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyWebTechnologies', }, default: '', - description: 'The web technologies used by the company or organization. Powered by HubSpot Insights. Choose from the list, or specify an ID using an expression.', + description: + 'The web technologies used by the company or organization. Powered by HubSpot Insights. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Website URL', name: 'websiteUrl', type: 'string', default: '', - description: 'The main website of the company or organization. This property is used to identify unique companies. Powered by HubSpot Insights.', + description: + 'The main website of the company or organization. This property is used to identify unique companies. Powered by HubSpot Insights.', }, { displayName: 'Year Founded', @@ -432,12 +435,8 @@ export const companyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'update', - ], + resource: ['company'], + operation: ['update'], }, }, default: '', @@ -451,12 +450,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'update', - ], + resource: ['company'], + operation: ['update'], }, }, options: [ @@ -508,7 +503,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getOwners', }, default: '', - description: 'The owner of the company. Choose from the list, or specify an ID using an expression.', + description: + 'The owner of the company. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Country/Region', @@ -539,7 +535,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyCustomProperties', }, default: '', - description: 'Name of the property. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the property. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -557,7 +554,7 @@ export const companyFields: INodeProperties[] = [ name: 'description', type: 'string', default: '', - description: 'A short statement about the company\'s mission and goals', + description: "A short statement about the company's mission and goals", }, { displayName: 'Facebook Fans', @@ -584,7 +581,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyIndustries', }, default: '', - description: 'The type of business the company performs. Choose from the list, or specify an ID using an expression.', + description: + 'The type of business the company performs. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Is Public', @@ -601,7 +599,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyleadStatuses', }, default: '', - description: 'The company\'s sales, prospecting or outreach status. Choose from the list, or specify an ID using an expression.', + description: + 'The company\'s sales, prospecting or outreach status. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Lifecycle Stage Name or ID', @@ -611,7 +610,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanylifecycleStages', }, default: '', - description: 'The most advanced lifecycle stage across all contacts associated with this company or organization. Choose from the list, or specify an ID using an expression.', + description: + 'The most advanced lifecycle stage across all contacts associated with this company or organization. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Linkedin Bio', @@ -651,42 +651,47 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanySourceTypes', }, default: '', - description: 'Original source for the contact with the earliest activity for this company or organization. Choose from the list, or specify an ID using an expression.', + description: + 'Original source for the contact with the earliest activity for this company or organization. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Phone Number', name: 'phoneNumber', type: 'string', default: '', - description: 'A company\'s primary phone number. Powered by HubSpot Insights.', + description: "A company's primary phone number. Powered by HubSpot Insights.", }, { displayName: 'Postal Code', name: 'postalCode', type: 'string', default: '', - description: 'The postal or zip code of the company or organization. Powered by HubSpot Insights.', + description: + 'The postal or zip code of the company or organization. Powered by HubSpot Insights.', }, { displayName: 'State/Region', name: 'stateRegion', type: 'string', default: '', - description: 'The state or region in which the company or organization is located. Powered by HubSpot Insights.', + description: + 'The state or region in which the company or organization is located. Powered by HubSpot Insights.', }, { displayName: 'Street Address', name: 'streetAddress', type: 'string', default: '', - description: 'The street address of the company or organization, including unit number. Powered by HubSpot Insights.', + description: + 'The street address of the company or organization, including unit number. Powered by HubSpot Insights.', }, { displayName: 'Street Address 2', name: 'streetAddress2', type: 'string', default: '', - description: 'The additional address of the company or organization. Powered by HubSpot Insights.', + description: + 'The additional address of the company or organization. Powered by HubSpot Insights.', }, { @@ -697,14 +702,16 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyTargetAccounts', }, default: '', - description: 'The Target Account property is a means to flag high priority companies if you are following an account based strategy. Choose from the list, or specify an ID using an expression.', + description: + 'The Target Account property is a means to flag high priority companies if you are following an account based strategy. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Timezone', name: 'timezone', type: 'string', default: '', - description: 'The time zone where the company or organization is located. Powered by HubSpot Insights.', + description: + 'The time zone where the company or organization is located. Powered by HubSpot Insights.', }, { displayName: 'Total Money Raised', @@ -714,7 +721,8 @@ export const companyFields: INodeProperties[] = [ minValue: 0, }, default: 0, - description: 'The total amount of money raised by the company. Powered by HubSpot Insights.', + description: + 'The total amount of money raised by the company. Powered by HubSpot Insights.', }, { displayName: 'Twitter Bio', @@ -751,7 +759,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyTypes', }, default: '', - description: 'The optional classification of this company record - prospect, partner, etc. Choose from the list, or specify an ID using an expression.', + description: + 'The optional classification of this company record - prospect, partner, etc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Web Technologies Name or ID', @@ -761,14 +770,16 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyWebTechnologies', }, default: '', - description: 'The web technologies used by the company or organization. Powered by HubSpot Insights. Choose from the list, or specify an ID using an expression.', + description: + 'The web technologies used by the company or organization. Powered by HubSpot Insights. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Website URL', name: 'websiteUrl', type: 'string', default: '', - description: 'The main website of the company or organization. This property is used to identify unique companies. Powered by HubSpot Insights.', + description: + 'The main website of the company or organization. This property is used to identify unique companies. Powered by HubSpot Insights.', }, { displayName: 'Year Founded', @@ -790,12 +801,8 @@ export const companyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'get', - ], + resource: ['company'], + operation: ['get'], }, }, default: '', @@ -809,12 +816,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'get', - ], + resource: ['company'], + operation: ['get'], }, }, options: [ @@ -823,7 +826,8 @@ export const companyFields: INodeProperties[] = [ name: 'includeMergeAudits', type: 'boolean', default: false, - description: 'Whether to return any merge history if the company has been previously merged with another company record. Defaults to false.', + description: + 'Whether to return any merge history if the company has been previously merged with another company record. Defaults to false.', }, ], }, @@ -837,12 +841,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], + resource: ['company'], + operation: ['getAll'], }, }, default: false, @@ -854,15 +854,9 @@ export const companyFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['company'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -880,12 +874,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], + resource: ['company'], + operation: ['getAll'], }, }, options: [ @@ -894,7 +884,8 @@ export const companyFields: INodeProperties[] = [ name: 'includeMergeAudits', type: 'boolean', default: false, - description: 'Whether to return any merge history if a company has been previously merged with another company record. Defaults to false.', + description: + 'Whether to return any merge history if a company has been previously merged with another company record. Defaults to false.', }, { displayName: 'Property Names or IDs', @@ -904,14 +895,16 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyProperties', }, default: [], - description: '

Used to include specific company properties in the results. By default, the results will only include company ID and will not include the values for any properties for your companies.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', + description: + '

Used to include specific company properties in the results. By default, the results will only include company ID and will not include the values for any properties for your companies.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Properties With History', name: 'propertiesWithHistory', type: 'string', default: '', - description: 'Works similarly to properties=, but this parameter will include the history for the specified property, instead of just including the current value. Use this parameter when you need the full history of changes to a property\'s value.', + description: + "Works similarly to properties=, but this parameter will include the history for the specified property, instead of just including the current value. Use this parameter when you need the full history of changes to a property's value.", }, ], }, @@ -926,12 +919,8 @@ export const companyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'delete', - ], + resource: ['company'], + operation: ['delete'], }, }, default: '', @@ -947,13 +936,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getRecentlyCreated', - 'getRecentlyModified', - ], + resource: ['company'], + operation: ['getRecentlyCreated', 'getRecentlyModified'], }, }, default: false, @@ -965,16 +949,9 @@ export const companyFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getRecentlyCreated', - 'getRecentlyModified', - ], - returnAll: [ - false, - ], + resource: ['company'], + operation: ['getRecentlyCreated', 'getRecentlyModified'], + returnAll: [false], }, }, typeOptions: { @@ -992,12 +969,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getRecentlyModified', - ], + resource: ['company'], + operation: ['getRecentlyModified'], }, }, options: [ @@ -1014,7 +987,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default, you will only get data for the most recent version of a property in the "versions" data. If you include this parameter, you will get data for all previous versions.', + description: + 'By default, you will only get data for the most recent version of a property in the "versions" data. If you include this parameter, you will get data for all previous versions.', }, ], }, @@ -1028,12 +1002,8 @@ export const companyFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'searchByDomain', - ], + resource: ['company'], + operation: ['searchByDomain'], }, }, required: true, @@ -1045,12 +1015,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'searchByDomain', - ], + resource: ['company'], + operation: ['searchByDomain'], }, }, default: false, @@ -1062,15 +1028,9 @@ export const companyFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'searchByDomain', - ], - returnAll: [ - false, - ], + resource: ['company'], + operation: ['searchByDomain'], + returnAll: [false], }, }, typeOptions: { @@ -1088,12 +1048,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'searchByDomain', - ], + resource: ['company'], + operation: ['searchByDomain'], }, }, options: [ @@ -1105,7 +1061,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyProperties', }, default: [], - description: '

Used to include specific company properties in the results. By default, the results will only include company ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', + description: + '

Used to include specific company properties in the results. By default, the results will only include company ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/Hubspot/ContactDescription.ts b/packages/nodes-base/nodes/Hubspot/ContactDescription.ts index 91f3e2c85e..24ff372fd4 100644 --- a/packages/nodes-base/nodes/Hubspot/ContactDescription.ts +++ b/packages/nodes-base/nodes/Hubspot/ContactDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactOperations: INodeProperties[] = [ { @@ -10,16 +8,15 @@ export const contactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contact', - ], + resource: ['contact'], }, }, options: [ { name: 'Create or Update', value: 'upsert', - description: 'Create a new contact, or update the current one if it already exists (upsert)', + description: + 'Create a new contact, or update the current one if it already exists (upsert)', action: 'Create or update a contact', }, { @@ -58,7 +55,6 @@ export const contactOperations: INodeProperties[] = [ ]; export const contactFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* contact:upsert */ /* -------------------------------------------------------------------------- */ @@ -70,12 +66,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'upsert', - ], + resource: ['contact'], + operation: ['upsert'], }, }, default: '', @@ -86,17 +78,14 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'upsert', - ], + resource: ['contact'], + operation: ['upsert'], }, }, default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default the response only includes the ID. If this option gets activated, it will resolve the data automatically.', + description: + 'By default the response only includes the ID. If this option gets activated, it will resolve the data automatically.', }, { displayName: 'Additional Fields', @@ -106,12 +95,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'upsert', - ], + resource: ['contact'], + operation: ['upsert'], }, }, options: [ @@ -132,7 +117,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanies', }, default: '', - description: 'Companies associated with the ticket. Choose from the list, or specify an ID using an expression.', + description: + 'Companies associated with the ticket. Choose from the list, or specify an ID using an expression.', }, { displayName: 'City', @@ -168,7 +154,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Contact Owner Name or ID', name: 'contactOwner', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getOwners', }, @@ -202,7 +189,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactCustomProperties', }, default: '', - description: 'Name of the property. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the property. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -244,14 +232,15 @@ export const contactFields: INodeProperties[] = [ name: 'fieldOfStudy', type: 'string', default: '', - description: 'A contact\'s field of study. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool', + description: + "A contact's field of study. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool", }, { displayName: 'First Name', name: 'firstName', type: 'string', default: '', - description: 'A contact\'s first name', + description: "A contact's first name", }, { displayName: 'Gender', @@ -270,7 +259,8 @@ export const contactFields: INodeProperties[] = [ name: 'graduationDate', type: 'dateTime', default: '', - description: 'A contact\'s graduation date. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool', + description: + "A contact's graduation date. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool", }, { displayName: 'Industry', @@ -284,21 +274,22 @@ export const contactFields: INodeProperties[] = [ name: 'jobFunction', type: 'string', default: '', - description: 'A contact\'s job function. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool', + description: + "A contact's job function. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool", }, { displayName: 'Job Title', name: 'jobTitle', type: 'string', default: '', - description: 'A contact\'s job title', + description: "A contact's job title", }, { displayName: 'Last Name', name: 'lastName', type: 'string', default: '', - description: 'A contact\'s last name', + description: "A contact's last name", }, { displayName: 'Lead Status Name or ID', @@ -308,7 +299,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactLeadStatuses', }, default: '', - description: 'The contact\'s sales, prospecting or outreach status. Choose from the list, or specify an ID using an expression.', + description: + 'The contact\'s sales, prospecting or outreach status. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Legal Basic For Processing Contact Data Name or ID', @@ -318,7 +310,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactLealBasics', }, default: '', - description: 'Legal basis for processing contact\'s data; \'Not applicable\' will exempt the contact from GDPR protections. Choose from the list, or specify an ID using an expression.', + description: + "Legal basis for processing contact's data; 'Not applicable' will exempt the contact from GDPR protections. Choose from the list, or specify an ID using an expression.", }, { displayName: 'Lifecycle Stage Name or ID', @@ -328,14 +321,16 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactLifeCycleStages', }, default: '', - description: 'The qualification of contacts to sales readiness. It can be set through imports, forms, workflows, and manually on a per contact basis. Choose from the list, or specify an ID using an expression.', + description: + 'The qualification of contacts to sales readiness. It can be set through imports, forms, workflows, and manually on a per contact basis. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Marital Status', name: 'maritalStatus', type: 'string', default: '', - description: 'A contact\'s marital status. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool', + description: + "A contact's marital status. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool", }, { displayName: 'Membership Note', @@ -345,7 +340,7 @@ export const contactFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'The notes relating to the contact\'s content membership', + description: "The notes relating to the contact's content membership", }, { displayName: 'Message', @@ -355,14 +350,15 @@ export const contactFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'A default property to be used for any message or comments a contact may want to leave on a form', + description: + 'A default property to be used for any message or comments a contact may want to leave on a form', }, { displayName: 'Mobile Phone Number', name: 'mobilePhoneNumber', type: 'string', default: '', - description: 'A contact\'s mobile phone number', + description: "A contact's mobile phone number", }, { // eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-dynamic-options @@ -373,7 +369,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactNumberOfEmployees', }, default: '', - description: 'The number of company employees. Choose from the list, or specify an ID using an expression.', + description: + 'The number of company employees. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Original Source Name or ID', @@ -383,14 +380,15 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactOriginalSources', }, default: '', - description: 'The first known source through which a contact found your website. Source is automatically set by HubSpot, but may be updated manually. Choose from the list, or specify an ID using an expression.', + description: + 'The first known source through which a contact found your website. Source is automatically set by HubSpot, but may be updated manually. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Phone Number', name: 'phoneNumber', type: 'string', default: '', - description: 'A contact\'s primary phone number', + description: "A contact's primary phone number", }, { displayName: 'Property Names or IDs', @@ -401,20 +399,19 @@ export const contactFields: INodeProperties[] = [ }, displayOptions: { show: { - '/resolveData': [ - true, - ], + '/resolveData': [true], }, }, default: [], - description: '

Used to include specific company properties in the results. By default, the results will only include company ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', + description: + '

Used to include specific company properties in the results. By default, the results will only include company ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Postal Code', name: 'postalCode', type: 'string', default: '', - description: 'The contact\'s zip code. This might be set via import, form, or integration.', + description: "The contact's zip code. This might be set via import, form, or integration.", }, { displayName: 'Preffered Language Name or ID', @@ -424,14 +421,16 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactPrefferedLanguages', }, default: '', - description: 'Set your contact\'s preferred language for communications. This property can be changed from an import, form, or integration. Choose from the list, or specify an ID using an expression.', + description: + 'Set your contact\'s preferred language for communications. This property can be changed from an import, form, or integration. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Relationship Status', name: 'relationshipStatus', type: 'string', default: '', - description: 'A contact\'s relationship status. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool', + description: + "A contact's relationship status. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool", }, { displayName: 'Salutation', @@ -445,28 +444,32 @@ export const contactFields: INodeProperties[] = [ name: 'school', type: 'string', default: '', - description: 'A contact\'s school. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool', + description: + "A contact's school. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool", }, { displayName: 'Seniority', name: 'seniority', type: 'string', default: '', - description: 'A contact\'s seniority. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool', + description: + "A contact's seniority. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool", }, { displayName: 'Start Date', name: 'startDate', type: 'dateTime', default: '', - description: 'A contact\'s start date. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool', + description: + "A contact's start date. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool", }, { displayName: 'State/Region', name: 'stateRegion', type: 'string', default: '', - description: 'The contact\'s state of residence. This might be set via import, form, or integration.', + description: + "The contact's state of residence. This might be set via import, form, or integration.", }, { displayName: 'Status Name or ID', @@ -476,35 +479,38 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactStatuses', }, default: '', - description: 'The status of the contact\'s content membership. Choose from the list, or specify an ID using an expression.', + description: + 'The status of the contact\'s content membership. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Street Address', name: 'streetAddress', type: 'string', default: '', - description: 'A contact\'s street address, including apartment or unit #', + description: "A contact's street address, including apartment or unit #", }, { displayName: 'Twitter Username', name: 'twitterUsername', type: 'string', default: '', - description: 'The contact\'s Twitter handle. This is set by HubSpot using the contact\'s email address.', + description: + "The contact's Twitter handle. This is set by HubSpot using the contact's email address.", }, { displayName: 'Website URL', name: 'websiteUrl', type: 'string', default: '', - description: 'The contact\'s company website', + description: "The contact's company website", }, { displayName: 'Work Email', name: 'workEmail', type: 'string', default: '', - description: 'A contact\'s work email. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool', + description: + "A contact's work email. This property is required for the Facebook Ads Integration. This property will be automatically synced via the Lead Ads tool", }, ], }, @@ -519,12 +525,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], + resource: ['contact'], + operation: ['get'], }, }, default: '', @@ -538,12 +540,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], + resource: ['contact'], + operation: ['get'], }, }, options: [ @@ -587,7 +585,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactProperties', }, default: [], - description: '

Used to include specific company properties in the results. By default, the results will only include company ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', + description: + '

Used to include specific company properties in the results. By default, the results will only include company ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Property Mode', @@ -604,7 +603,8 @@ export const contactFields: INodeProperties[] = [ }, ], default: 'valueAndHistory', - description: 'Specify if the current value for a property should be fetched, or the value and all the historical values for that property', + description: + 'Specify if the current value for a property should be fetched, or the value and all the historical values for that property', }, ], }, @@ -618,12 +618,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, default: false, @@ -635,15 +631,9 @@ export const contactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['contact'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -661,12 +651,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, options: [ @@ -710,7 +696,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactProperties', }, default: [], - description: '

Used to include specific company properties in the results. By default, the results will only include company ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', + description: + '

Used to include specific company properties in the results. By default, the results will only include company ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Property Mode', @@ -727,7 +714,8 @@ export const contactFields: INodeProperties[] = [ }, ], default: 'valueAndHistory', - description: 'Specify if the current value for a property should be fetched, or the value and all the historical values for that property', + description: + 'Specify if the current value for a property should be fetched, or the value and all the historical values for that property', }, ], }, @@ -742,12 +730,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'delete', - ], + resource: ['contact'], + operation: ['delete'], }, }, default: '', @@ -763,12 +747,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getRecentlyCreatedUpdated', - ], + resource: ['contact'], + operation: ['getRecentlyCreatedUpdated'], }, }, default: false, @@ -780,15 +760,9 @@ export const contactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getRecentlyCreatedUpdated', - ], - returnAll: [ - false, - ], + resource: ['contact'], + operation: ['getRecentlyCreatedUpdated'], + returnAll: [false], }, }, typeOptions: { @@ -806,12 +780,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getRecentlyCreatedUpdated', - ], + resource: ['contact'], + operation: ['getRecentlyCreatedUpdated'], }, }, options: [ @@ -855,7 +825,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactProperties', }, default: [], - description: '

Used to include specific company properties in the results. By default, the results will only include company ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', + description: + '

Used to include specific company properties in the results. By default, the results will only include company ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Property Mode', @@ -872,7 +843,8 @@ export const contactFields: INodeProperties[] = [ }, ], default: 'valueAndHistory', - description: 'Specify if the current value for a property should be fetched, or the value and all the historical values for that property', + description: + 'Specify if the current value for a property should be fetched, or the value and all the historical values for that property', }, ], }, @@ -886,12 +858,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'search', - ], + resource: ['contact'], + operation: ['search'], }, }, default: false, @@ -903,15 +871,9 @@ export const contactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'search', - ], - returnAll: [ - false, - ], + resource: ['contact'], + operation: ['search'], + returnAll: [false], }, }, typeOptions: { @@ -932,12 +894,8 @@ export const contactFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'search', - ], + resource: ['contact'], + operation: ['search'], }, }, options: [ @@ -963,7 +921,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Property Name or ID', name: 'propertyName', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getContactProperties', }, @@ -1018,10 +977,7 @@ export const contactFields: INodeProperties[] = [ name: 'value', displayOptions: { hide: { - operator: [ - 'HAS_PROPERTY', - 'NOT_HAS_PROPERTY', - ], + operator: ['HAS_PROPERTY', 'NOT_HAS_PROPERTY'], }, }, type: 'string', @@ -1030,12 +986,14 @@ export const contactFields: INodeProperties[] = [ ], }, ], - description: 'Use filters to limit the results to only CRM objects with matching property values. More info here.', + description: + 'Use filters to limit the results to only CRM objects with matching property values. More info here.', }, ], }, ], - description: 'When multiple filters are provided within a filterGroup, they will be combined using a logical AND operator. When multiple filterGroups are provided, they will be combined using a logical OR operator. The system supports a maximum of three filterGroups with up to three filters each. More info here', + description: + 'When multiple filters are provided within a filterGroup, they will be combined using a logical AND operator. When multiple filterGroups are provided, they will be combined using a logical OR operator. The system supports a maximum of three filterGroups with up to three filters each. More info here', }, { displayName: 'Additional Fields', @@ -1045,12 +1003,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'search', - ], + resource: ['contact'], + operation: ['search'], }, }, options: [ @@ -1069,7 +1023,8 @@ export const contactFields: INodeProperties[] = [ }, ], default: 'DESCENDING', - description: 'Defines the direction in which search results are ordered. Default value is DESC.', + description: + 'Defines the direction in which search results are ordered. Default value is DESC.', }, { displayName: 'Field Names or IDs', @@ -1078,12 +1033,9 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getContactProperties', }, - default: [ - 'firstname', - 'lastname', - 'email', - ], - description: '

Used to include specific company properties in the results. By default, the results will only include company ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', + default: ['firstname', 'lastname', 'email'], + description: + '

Used to include specific company properties in the results. By default, the results will only include company ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Query', @@ -1097,7 +1049,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Sort By', name: 'sortBy', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getContactProperties', }, diff --git a/packages/nodes-base/nodes/Hubspot/ContactListDescription.ts b/packages/nodes-base/nodes/Hubspot/ContactListDescription.ts index 33880a5afb..7a0ca4746f 100644 --- a/packages/nodes-base/nodes/Hubspot/ContactListDescription.ts +++ b/packages/nodes-base/nodes/Hubspot/ContactListDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactListOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const contactListOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contactList', - ], + resource: ['contactList'], }, }, options: [ @@ -34,7 +30,6 @@ export const contactListOperations: INodeProperties[] = [ ]; export const contactListFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* contactList:add */ /* -------------------------------------------------------------------------- */ @@ -55,12 +50,8 @@ export const contactListFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contactList', - ], - operation: [ - 'add', - ], + resource: ['contactList'], + operation: ['add'], }, }, default: 'email', @@ -73,15 +64,9 @@ export const contactListFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contactList', - ], - operation: [ - 'add', - ], - by: [ - 'email', - ], + resource: ['contactList'], + operation: ['add'], + by: ['email'], }, }, default: '', @@ -93,15 +78,9 @@ export const contactListFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contactList', - ], - operation: [ - 'add', - ], - by: [ - 'id', - ], + resource: ['contactList'], + operation: ['add'], + by: ['id'], }, }, default: '', @@ -113,12 +92,8 @@ export const contactListFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contactList', - ], - operation: [ - 'add', - ], + resource: ['contactList'], + operation: ['add'], }, }, default: '', @@ -134,12 +109,8 @@ export const contactListFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contactList', - ], - operation: [ - 'remove', - ], + resource: ['contactList'], + operation: ['remove'], }, }, default: '', @@ -151,12 +122,8 @@ export const contactListFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contactList', - ], - operation: [ - 'remove', - ], + resource: ['contactList'], + operation: ['remove'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Hubspot/DealDescription.ts b/packages/nodes-base/nodes/Hubspot/DealDescription.ts index 7674fd525e..b049c874fe 100644 --- a/packages/nodes-base/nodes/Hubspot/DealDescription.ts +++ b/packages/nodes-base/nodes/Hubspot/DealDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const dealOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const dealOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'deal', - ], + resource: ['deal'], }, }, options: [ @@ -70,7 +66,6 @@ export const dealOperations: INodeProperties[] = [ ]; export const dealFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* deal:create */ /* -------------------------------------------------------------------------- */ @@ -84,17 +79,14 @@ export const dealFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, default: '', options: [], - description: 'The dealstage is required when creating a deal. See the CRM Pipelines API for details on managing pipelines and stages. Choose from the list, or specify an ID using an expression.', + description: + 'The dealstage is required when creating a deal. See the CRM Pipelines API for details on managing pipelines and stages. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Additional Fields', @@ -104,12 +96,8 @@ export const dealFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, options: [ @@ -123,7 +111,8 @@ export const dealFields: INodeProperties[] = [ displayName: 'Associated Company Names or IDs', name: 'associatedCompany', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getCompanies', }, @@ -133,7 +122,8 @@ export const dealFields: INodeProperties[] = [ displayName: 'Associated Vid Names or IDs', name: 'associatedVids', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getContacts', }, @@ -167,7 +157,8 @@ export const dealFields: INodeProperties[] = [ loadOptionsMethod: 'getDealCustomProperties', }, default: '', - description: 'Name of the property. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the property. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -196,7 +187,8 @@ export const dealFields: INodeProperties[] = [ displayName: 'Deal Type Name or ID', name: 'dealType', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getDealTypes', }, @@ -221,12 +213,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], + resource: ['deal'], + operation: ['update'], }, }, default: '', @@ -240,12 +228,8 @@ export const dealFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], + resource: ['deal'], + operation: ['update'], }, }, options: [ @@ -283,7 +267,8 @@ export const dealFields: INodeProperties[] = [ loadOptionsMethod: 'getDealCustomProperties', }, default: '', - description: 'Name of the property. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the property. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -316,13 +301,15 @@ export const dealFields: INodeProperties[] = [ loadOptionsMethod: 'getDealStages', }, default: '', - description: 'The dealstage is required when creating a deal. See the CRM Pipelines API for details on managing pipelines and stages. Choose from the list, or specify an ID using an expression.', + description: + 'The dealstage is required when creating a deal. See the CRM Pipelines API for details on managing pipelines and stages. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Deal Type Name or ID', name: 'dealType', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getDealTypes', }, @@ -347,12 +334,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'get', - ], + resource: ['deal'], + operation: ['get'], }, }, default: '', @@ -366,12 +349,8 @@ export const dealFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'get', - ], + resource: ['deal'], + operation: ['get'], }, }, options: [ @@ -381,7 +360,8 @@ export const dealFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default, you will only get data for the most recent version of a property in the "versions" data. If you include this parameter, you will get data for all previous versions.', + description: + 'By default, you will only get data for the most recent version of a property in the "versions" data. If you include this parameter, you will get data for all previous versions.', }, ], }, @@ -395,12 +375,8 @@ export const dealFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'getAll', - ], + resource: ['deal'], + operation: ['getAll'], }, }, default: false, @@ -412,15 +388,9 @@ export const dealFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['deal'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -438,12 +408,8 @@ export const dealFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'getAll', - ], + resource: ['deal'], + operation: ['getAll'], }, }, options: [ @@ -452,7 +418,8 @@ export const dealFields: INodeProperties[] = [ name: 'includeAssociations', type: 'boolean', default: false, - description: 'Whether to include the IDs of the associated contacts and companies in the results. This will also automatically include the num_associated_contacts property.', + description: + 'Whether to include the IDs of the associated contacts and companies in the results. This will also automatically include the num_associated_contacts property.', }, { displayName: 'Property Names or IDs', @@ -462,7 +429,8 @@ export const dealFields: INodeProperties[] = [ loadOptionsMethod: 'getDealProperties', }, default: [], - description: '

Used to include specific deal properties in the results. By default, the results will only include Deal ID and will not include the values for any properties for your Deals.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', + description: + '

Used to include specific deal properties in the results. By default, the results will only include Deal ID and will not include the values for any properties for your Deals.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', }, { // eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-dynamic-multi-options @@ -473,9 +441,9 @@ export const dealFields: INodeProperties[] = [ loadOptionsMethod: 'getDealProperties', }, default: [], - description: 'Works similarly to properties=, but this parameter will include the history for the specified property, instead of just including the current value. Use this parameter when you need the full history of changes to a property\'s value. Choose from the list, or specify IDs using an expression.', + description: + 'Works similarly to properties=, but this parameter will include the history for the specified property, instead of just including the current value. Use this parameter when you need the full history of changes to a property\'s value. Choose from the list, or specify IDs using an expression.', }, - ], }, @@ -489,12 +457,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'delete', - ], + resource: ['deal'], + operation: ['delete'], }, }, default: '', @@ -510,13 +474,8 @@ export const dealFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'getRecentlyCreated', - 'getRecentlyModified', - ], + resource: ['deal'], + operation: ['getRecentlyCreated', 'getRecentlyModified'], }, }, default: false, @@ -528,16 +487,9 @@ export const dealFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'getRecentlyCreated', - 'getRecentlyModified', - ], - returnAll: [ - false, - ], + resource: ['deal'], + operation: ['getRecentlyCreated', 'getRecentlyModified'], + returnAll: [false], }, }, typeOptions: { @@ -555,13 +507,8 @@ export const dealFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'getRecentlyCreated', - 'getRecentlyModified', - ], + resource: ['deal'], + operation: ['getRecentlyCreated', 'getRecentlyModified'], }, }, options: [ @@ -578,7 +525,8 @@ export const dealFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default, you will only get data for the most recent version of a property in the "versions" data. If you include this parameter, you will get data for all previous versions.', + description: + 'By default, you will only get data for the most recent version of a property in the "versions" data. If you include this parameter, you will get data for all previous versions.', }, ], }, @@ -592,12 +540,8 @@ export const dealFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'search', - ], + resource: ['deal'], + operation: ['search'], }, }, default: false, @@ -609,15 +553,9 @@ export const dealFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'search', - ], - returnAll: [ - false, - ], + resource: ['deal'], + operation: ['search'], + returnAll: [false], }, }, typeOptions: { @@ -638,12 +576,8 @@ export const dealFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'search', - ], + resource: ['deal'], + operation: ['search'], }, }, options: [ @@ -669,7 +603,8 @@ export const dealFields: INodeProperties[] = [ displayName: 'Property Name or ID', name: 'propertyName', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getDealProperties', }, @@ -724,10 +659,7 @@ export const dealFields: INodeProperties[] = [ name: 'value', displayOptions: { hide: { - operator: [ - 'HAS_PROPERTY', - 'NOT_HAS_PROPERTY', - ], + operator: ['HAS_PROPERTY', 'NOT_HAS_PROPERTY'], }, }, type: 'string', @@ -736,12 +668,14 @@ export const dealFields: INodeProperties[] = [ ], }, ], - description: 'Use filters to limit the results to only CRM objects with matching property values. More info here.', + description: + 'Use filters to limit the results to only CRM objects with matching property values. More info here.', }, ], }, ], - description: 'When multiple filters are provided within a filterGroup, they will be combined using a logical AND operator. When multiple filterGroups are provided, they will be combined using a logical OR operator. The system supports a maximum of three filterGroups with up to three filters each. More info here', + description: + 'When multiple filters are provided within a filterGroup, they will be combined using a logical AND operator. When multiple filterGroups are provided, they will be combined using a logical OR operator. The system supports a maximum of three filterGroups with up to three filters each. More info here', }, { displayName: 'Additional Fields', @@ -751,12 +685,8 @@ export const dealFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'search', - ], + resource: ['deal'], + operation: ['search'], }, }, options: [ @@ -775,7 +705,8 @@ export const dealFields: INodeProperties[] = [ }, ], default: 'DESCENDING', - description: 'Defines the direction in which search results are ordered. Default value is DESC.', + description: + 'Defines the direction in which search results are ordered. Default value is DESC.', }, { displayName: 'Field Names or IDs', @@ -785,7 +716,8 @@ export const dealFields: INodeProperties[] = [ loadOptionsMethod: 'getDealProperties', }, default: [], - description: '

Used to include specific deal properties in the results. By default, the results will only include Deal ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', + description: + '

Used to include specific deal properties in the results. By default, the results will only include Deal ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Query', @@ -799,7 +731,8 @@ export const dealFields: INodeProperties[] = [ displayName: 'Sort By', name: 'sortBy', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getDealProperties', }, diff --git a/packages/nodes-base/nodes/Hubspot/DealInterface.ts b/packages/nodes-base/nodes/Hubspot/DealInterface.ts index 2bd20ddb1b..7602eaefc2 100644 --- a/packages/nodes-base/nodes/Hubspot/DealInterface.ts +++ b/packages/nodes-base/nodes/Hubspot/DealInterface.ts @@ -1,6 +1,4 @@ -import { - IDataObject, -} from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export interface IAssociation { associatedCompanyIds?: number[]; diff --git a/packages/nodes-base/nodes/Hubspot/EngagementDescription.ts b/packages/nodes-base/nodes/Hubspot/EngagementDescription.ts index d73b22754e..ae8eebbfe9 100644 --- a/packages/nodes-base/nodes/Hubspot/EngagementDescription.ts +++ b/packages/nodes-base/nodes/Hubspot/EngagementDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const engagementOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const engagementOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'engagement', - ], + resource: ['engagement'], }, }, options: [ @@ -46,7 +42,6 @@ export const engagementOperations: INodeProperties[] = [ ]; export const engagementFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* engagement:create */ /* -------------------------------------------------------------------------- */ @@ -75,12 +70,8 @@ export const engagementFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'engagement', - ], - operation: [ - 'create', - ], + resource: ['engagement'], + operation: ['create'], }, }, default: '', @@ -93,15 +84,9 @@ export const engagementFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'engagement', - ], - operation: [ - 'create', - ], - type: [ - 'task', - ], + resource: ['engagement'], + operation: ['create'], + type: ['task'], }, }, options: [ @@ -171,15 +156,9 @@ export const engagementFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'engagement', - ], - operation: [ - 'create', - ], - type: [ - 'email', - ], + resource: ['engagement'], + operation: ['create'], + type: ['email'], }, }, options: [ @@ -253,15 +232,9 @@ export const engagementFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'engagement', - ], - operation: [ - 'create', - ], - type: [ - 'meeting', - ], + resource: ['engagement'], + operation: ['create'], + type: ['meeting'], }, }, options: [ @@ -305,15 +278,9 @@ export const engagementFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'engagement', - ], - operation: [ - 'create', - ], - type: [ - 'call', - ], + resource: ['engagement'], + operation: ['create'], + type: ['call'], }, }, options: [ @@ -405,12 +372,8 @@ export const engagementFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'engagement', - ], - operation: [ - 'create', - ], + resource: ['engagement'], + operation: ['create'], }, }, options: [ @@ -466,13 +429,8 @@ export const engagementFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'engagement', - ], - operation: [ - 'get', - 'delete', - ], + resource: ['engagement'], + operation: ['get', 'delete'], }, }, default: '', @@ -487,12 +445,8 @@ export const engagementFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'engagement', - ], - operation: [ - 'getAll', - ], + resource: ['engagement'], + operation: ['getAll'], }, }, default: false, @@ -504,15 +458,9 @@ export const engagementFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'engagement', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['engagement'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Hubspot/FormDescription.ts b/packages/nodes-base/nodes/Hubspot/FormDescription.ts index da330d7f5d..103e548c16 100644 --- a/packages/nodes-base/nodes/Hubspot/FormDescription.ts +++ b/packages/nodes-base/nodes/Hubspot/FormDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const formOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const formOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'form', - ], + resource: ['form'], }, }, options: [ @@ -34,7 +30,6 @@ export const formOperations: INodeProperties[] = [ ]; export const formFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* form:submit */ /* -------------------------------------------------------------------------- */ @@ -48,16 +43,13 @@ export const formFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'form', - ], - operation: [ - 'submit', - ], + resource: ['form'], + operation: ['submit'], }, }, default: '', - description: 'The ID of the form you\'re sending data to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the form you\'re sending data to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Additional Fields', @@ -67,12 +59,8 @@ export const formFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'form', - ], - operation: [ - 'submit', - ], + resource: ['form'], + operation: ['submit'], }, }, options: [ @@ -102,12 +90,8 @@ export const formFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'form', - ], - operation: [ - 'submit', - ], + resource: ['form'], + operation: ['submit'], }, }, default: {}, @@ -121,7 +105,8 @@ export const formFields: INodeProperties[] = [ name: 'hutk', type: 'string', default: '', - description: 'Include this parameter and set it to the hubspotutk cookie value to enable cookie tracking on your submission', + description: + 'Include this parameter and set it to the hubspotutk cookie value to enable cookie tracking on your submission', }, { displayName: 'IP Address', @@ -156,14 +141,16 @@ export const formFields: INodeProperties[] = [ name: 'sfdcCampaignId', type: 'string', default: '', - description: 'If the form is for an account using the HubSpot Salesforce Integration, you can include the ID of a Salesforce campaign to add the contact to the specified campaign', + description: + 'If the form is for an account using the HubSpot Salesforce Integration, you can include the ID of a Salesforce campaign to add the contact to the specified campaign', }, { displayName: 'Go to Webinar Webinar ID', name: 'goToWebinarWebinarKey', type: 'string', default: '', - description: 'If the form is for an account using the HubSpot GoToWebinar Integration, you can include the ID of a webinar to enroll the contact in that webinar when they submit the form', + description: + 'If the form is for an account using the HubSpot GoToWebinar Integration, you can include the ID of a webinar to enroll the contact in that webinar when they submit the form', }, ], }, @@ -179,12 +166,8 @@ export const formFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'form', - ], - operation: [ - 'submit', - ], + resource: ['form'], + operation: ['submit'], }, }, default: {}, @@ -229,21 +212,24 @@ export const formFields: INodeProperties[] = [ loadOptionsMethod: 'getSubscriptionTypes', }, default: '', - description: 'The ID of the specific subscription type. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the specific subscription type. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', name: 'value', type: 'boolean', default: false, - description: 'Whether or not the visitor checked the checkbox for this subscription type', + description: + 'Whether or not the visitor checked the checkbox for this subscription type', }, { displayName: 'Text', name: 'text', type: 'string', default: '', - description: 'The text displayed to the visitor for this specific subscription checkbox', + description: + 'The text displayed to the visitor for this specific subscription checkbox', }, ], }, @@ -263,7 +249,8 @@ export const formFields: INodeProperties[] = [ loadOptionsMethod: 'getSubscriptionTypes', }, default: '', - description: 'The ID of the specific subscription type that this forms indicates interest to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the specific subscription type that this forms indicates interest to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -271,7 +258,8 @@ export const formFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'This must be true when using the \'legitimateInterest\' option, as it reflects the consent indicated by the visitor when submitting the form', + description: + "This must be true when using the 'legitimateInterest' option, as it reflects the consent indicated by the visitor when submitting the form", }, { displayName: 'Legal Basis', @@ -315,15 +303,12 @@ export const formFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'form', - ], - operation: [ - 'getFields', - ], + resource: ['form'], + operation: ['getFields'], }, }, default: '', - description: 'The ID of the form. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the form. Choose from the list, or specify an ID using an expression.', }, ]; diff --git a/packages/nodes-base/nodes/Hubspot/FormInterface.ts b/packages/nodes-base/nodes/Hubspot/FormInterface.ts index f6dd2e9e3d..f61e06c8b5 100644 --- a/packages/nodes-base/nodes/Hubspot/FormInterface.ts +++ b/packages/nodes-base/nodes/Hubspot/FormInterface.ts @@ -1,6 +1,4 @@ -import { - IDataObject, -} from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export interface IContext { goToWebinarWebinarKey?: string; diff --git a/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts b/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts index fdade2001b..27b0a8075d 100644 --- a/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -19,8 +17,16 @@ import { import moment from 'moment'; -export async function hubspotApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise { // tslint:disable-line:no-any - +export async function hubspotApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { let authenticationMethod = this.getNodeParameter('authentication', 0); if (this.getNode().type.includes('Trigger')) { @@ -50,16 +56,20 @@ export async function hubspotApiRequest(this: IHookFunctions | IExecuteFunctions return await this.helpers.request!(options); } else if (authenticationMethod === 'developerApi') { if (endpoint.includes('webhooks')) { - const credentials = await this.getCredentials('hubspotDeveloperApi'); options.qs.hapikey = credentials.apiKey as string; return await this.helpers.request!(options); - } else { - return await this.helpers.requestOAuth2!.call(this, 'hubspotDeveloperApi', options, { tokenType: 'Bearer', includeCredentialsOnRefreshOnBody: true }); + return await this.helpers.requestOAuth2!.call(this, 'hubspotDeveloperApi', options, { + tokenType: 'Bearer', + includeCredentialsOnRefreshOnBody: true, + }); } } else { - return await this.helpers.requestOAuth2!.call(this, 'hubspotOAuth2Api', options, { tokenType: 'Bearer', includeCredentialsOnRefreshOnBody: true }); + return await this.helpers.requestOAuth2!.call(this, 'hubspotOAuth2Api', options, { + tokenType: 'Bearer', + includeCredentialsOnRefreshOnBody: true, + }); } } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); @@ -70,8 +80,16 @@ export async function hubspotApiRequest(this: IHookFunctions | IExecuteFunctions * Make an API request to paginated hubspot endpoint * and return all results */ -export async function hubspotApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function hubspotApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -93,13 +111,12 @@ export async function hubspotApiRequestAllItems(this: IHookFunctions | IExecuteF if (query.limit && query.limit <= returnData.length && endpoint.includes('/tickets/paged')) { return returnData; } - } while ( - responseData['hasMore'] || responseData['has-more'] || responseData['paging'] - ); + } while (responseData['hasMore'] || responseData['has-more'] || responseData['paging']); return returnData; } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); @@ -109,7 +126,6 @@ export function validateJSON(json: string | undefined): any { // tslint:disable- return result; } - // tslint:disable-next-line: no-any export function clean(obj: any) { for (const propName in obj) { @@ -128,1791 +144,1793 @@ export const propertyEvents = [ export const contactFields = [ { - 'id': 'company_size', - 'label': 'testingricardo', + id: 'company_size', + label: 'testingricardo', }, { - 'id': 'date', - 'label': 'Date', + id: 'date', + label: 'Date', }, { - 'id': 'date_of_birth', - 'label': 'Date of birth', + id: 'date_of_birth', + label: 'Date of birth', }, { - 'id': 'days_to_close', - 'label': 'Days To Close', + id: 'days_to_close', + label: 'Days To Close', }, { - 'id': 'degree', - 'label': 'Degree', + id: 'degree', + label: 'Degree', }, { - 'id': 'field_of_study', - 'label': 'Field of study', + id: 'field_of_study', + label: 'Field of study', }, { - 'id': 'first_conversion_date', - 'label': 'First Conversion Date', + id: 'first_conversion_date', + label: 'First Conversion Date', }, { - 'id': 'first_conversion_event_name', - 'label': 'First Conversion', + id: 'first_conversion_event_name', + label: 'First Conversion', }, { - 'id': 'first_deal_created_date', - 'label': 'First Deal Created Date', + id: 'first_deal_created_date', + label: 'First Deal Created Date', }, { - 'id': 'gender', - 'label': 'Gender', + id: 'gender', + label: 'Gender', }, { - 'id': 'graduation_date', - 'label': 'Graduation date', + id: 'graduation_date', + label: 'Graduation date', }, { - 'id': 'hs_additional_emails', - 'label': 'Additional email addresses', + id: 'hs_additional_emails', + label: 'Additional email addresses', }, { - 'id': 'hs_all_contact_vids', - 'label': 'All vids for a contact', + id: 'hs_all_contact_vids', + label: 'All vids for a contact', }, { - 'id': 'hs_analytics_first_touch_converting_campaign', - 'label': 'First Touch Converting Campaign', + id: 'hs_analytics_first_touch_converting_campaign', + label: 'First Touch Converting Campaign', }, { - 'id': 'hs_analytics_last_touch_converting_campaign', - 'label': 'Last Touch Converting Campaign', + id: 'hs_analytics_last_touch_converting_campaign', + label: 'Last Touch Converting Campaign', }, { - 'id': 'hs_avatar_filemanager_key', - 'label': 'Avatar FileManager key', + id: 'hs_avatar_filemanager_key', + label: 'Avatar FileManager key', }, { - 'id': 'hs_buying_role', - 'label': 'Buying Role', + id: 'hs_buying_role', + label: 'Buying Role', }, { - 'id': 'hs_calculated_form_submissions', - 'label': 'All form submissions for a contact', + id: 'hs_calculated_form_submissions', + label: 'All form submissions for a contact', }, { - 'id': 'hs_calculated_merged_vids', - 'label': 'Merged vids with timestamps of a contact', + id: 'hs_calculated_merged_vids', + label: 'Merged vids with timestamps of a contact', }, { - 'id': 'hs_calculated_mobile_number', - 'label': 'Calculated Mobile Number in International Format', + id: 'hs_calculated_mobile_number', + label: 'Calculated Mobile Number in International Format', }, { - 'id': 'hs_calculated_phone_number', - 'label': 'Calculated Phone Number in International Format', + id: 'hs_calculated_phone_number', + label: 'Calculated Phone Number in International Format', }, { - 'id': 'hs_calculated_phone_number_area_code', - 'label': 'Calculated Phone Number Area Code', + id: 'hs_calculated_phone_number_area_code', + label: 'Calculated Phone Number Area Code', }, { - 'id': 'hs_calculated_phone_number_country_code', - 'label': 'Calculated Phone Number Country Code', + id: 'hs_calculated_phone_number_country_code', + label: 'Calculated Phone Number Country Code', }, { - 'id': 'hs_calculated_phone_number_region_code', - 'label': 'Calculated Phone Number Region', + id: 'hs_calculated_phone_number_region_code', + label: 'Calculated Phone Number Region', }, { - 'id': 'hs_content_membership_email_confirmed', - 'label': 'Email Confirmed', + id: 'hs_content_membership_email_confirmed', + label: 'Email Confirmed', }, { - 'id': 'hs_content_membership_notes', - 'label': 'Membership Notes', + id: 'hs_content_membership_notes', + label: 'Membership Notes', }, { - 'id': 'hs_content_membership_registered_at', - 'label': 'Registered At', + id: 'hs_content_membership_registered_at', + label: 'Registered At', }, { - 'id': 'hs_content_membership_registration_domain_sent_to', - 'label': 'Domain to which registration email was sent', + id: 'hs_content_membership_registration_domain_sent_to', + label: 'Domain to which registration email was sent', }, { - 'id': 'hs_content_membership_registration_email_sent_at', - 'label': 'Time registration email was sent', + id: 'hs_content_membership_registration_email_sent_at', + label: 'Time registration email was sent', }, { - 'id': 'hs_content_membership_status', - 'label': 'Status', + id: 'hs_content_membership_status', + label: 'Status', }, { - 'id': 'hs_conversations_visitor_email', - 'label': 'Conversations visitor email', + id: 'hs_conversations_visitor_email', + label: 'Conversations visitor email', }, { - 'id': 'hs_count_is_unworked', - 'label': 'Count of unengaged contacts', + id: 'hs_count_is_unworked', + label: 'Count of unengaged contacts', }, { - 'id': 'hs_count_is_worked', - 'label': 'Count of engaged contacts', + id: 'hs_count_is_worked', + label: 'Count of engaged contacts', }, { - 'id': 'hs_created_by_conversations', - 'label': 'Created By Conversations', + id: 'hs_created_by_conversations', + label: 'Created By Conversations', }, { - 'id': 'hs_created_by_user_id', - 'label': 'Created by user ID', + id: 'hs_created_by_user_id', + label: 'Created by user ID', }, { - 'id': 'hs_createdate', - 'label': 'Object create date/time', + id: 'hs_createdate', + label: 'Object create date/time', }, { - 'id': 'hs_document_last_revisited', - 'label': 'Recent Document Revisit Date', + id: 'hs_document_last_revisited', + label: 'Recent Document Revisit Date', }, { - 'id': 'hs_email_bad_address', - 'label': 'Invalid email address', + id: 'hs_email_bad_address', + label: 'Invalid email address', }, { - 'id': 'hs_email_customer_quarantined_reason', - 'label': 'Email address quarantine reason', + id: 'hs_email_customer_quarantined_reason', + label: 'Email address quarantine reason', }, { - 'id': 'hs_email_domain', - 'label': 'Email Domain', + id: 'hs_email_domain', + label: 'Email Domain', }, { - 'id': 'hs_email_hard_bounce_reason', - 'label': 'Email hard bounce reason', + id: 'hs_email_hard_bounce_reason', + label: 'Email hard bounce reason', }, { - 'id': 'hs_email_hard_bounce_reason_enum', - 'label': 'Email hard bounce reason', + id: 'hs_email_hard_bounce_reason_enum', + label: 'Email hard bounce reason', }, { - 'id': 'hs_email_quarantined', - 'label': 'Email Address Quarantined', + id: 'hs_email_quarantined', + label: 'Email Address Quarantined', }, { - 'id': 'hs_email_quarantined_reason', - 'label': 'Email address internal quarantine reason', + id: 'hs_email_quarantined_reason', + label: 'Email address internal quarantine reason', }, { - 'id': 'hs_email_recipient_fatigue_recovery_time', - 'label': 'Email Address Recipient Fatigue Next Available Sending Time', + id: 'hs_email_recipient_fatigue_recovery_time', + label: 'Email Address Recipient Fatigue Next Available Sending Time', }, { - 'id': 'hs_email_sends_since_last_engagement', - 'label': 'Sends Since Last Engagement', + id: 'hs_email_sends_since_last_engagement', + label: 'Sends Since Last Engagement', }, { - 'id': 'hs_emailconfirmationstatus', - 'label': 'Marketing email confirmation status', + id: 'hs_emailconfirmationstatus', + label: 'Marketing email confirmation status', }, { - 'id': 'hs_facebook_ad_clicked', - 'label': 'Clicked Facebook ad', + id: 'hs_facebook_ad_clicked', + label: 'Clicked Facebook ad', }, { - 'id': 'hs_facebook_click_id', - 'label': 'Facebook click id', + id: 'hs_facebook_click_id', + label: 'Facebook click id', }, { - 'id': 'hs_facebookid', - 'label': 'Facebook ID', + id: 'hs_facebookid', + label: 'Facebook ID', }, { - 'id': 'hs_feedback_last_nps_follow_up', - 'label': 'Last NPS survey comment', + id: 'hs_feedback_last_nps_follow_up', + label: 'Last NPS survey comment', }, { - 'id': 'hs_feedback_last_nps_rating', - 'label': 'Last NPS survey rating', + id: 'hs_feedback_last_nps_rating', + label: 'Last NPS survey rating', }, { - 'id': 'hs_feedback_last_survey_date', - 'label': 'Last NPS survey date', + id: 'hs_feedback_last_survey_date', + label: 'Last NPS survey date', }, { - 'id': 'hs_feedback_show_nps_web_survey', - 'label': 'Should be shown an NPS web survey', + id: 'hs_feedback_show_nps_web_survey', + label: 'Should be shown an NPS web survey', }, { - 'id': 'hs_first_engagement_object_id', - 'label': 'ID of first engagement', + id: 'hs_first_engagement_object_id', + label: 'ID of first engagement', }, { - 'id': 'hs_google_click_id', - 'label': 'Google ad click id', + id: 'hs_google_click_id', + label: 'Google ad click id', }, { - 'id': 'hs_googleplusid', - 'label': 'googleplus ID', + id: 'hs_googleplusid', + label: 'googleplus ID', }, { - 'id': 'hs_ip_timezone', - 'label': 'IP Timezone', + id: 'hs_ip_timezone', + label: 'IP Timezone', }, { - 'id': 'hs_is_contact', - 'label': 'Is a contact', + id: 'hs_is_contact', + label: 'Is a contact', }, { - 'id': 'hs_is_unworked', - 'label': 'Contact unworked', + id: 'hs_is_unworked', + label: 'Contact unworked', }, { - 'id': 'hs_last_sales_activity_date', - 'label': 'last sales activity date old', + id: 'hs_last_sales_activity_date', + label: 'last sales activity date old', }, { - 'id': 'hs_last_sales_activity_timestamp', - 'label': 'Last Engagement Date', + id: 'hs_last_sales_activity_timestamp', + label: 'Last Engagement Date', }, { - 'id': 'hs_lastmodifieddate', - 'label': 'Object last modified date/time', + id: 'hs_lastmodifieddate', + label: 'Object last modified date/time', }, { - 'id': 'hs_lead_status', - 'label': 'Lead Status', + id: 'hs_lead_status', + label: 'Lead Status', }, { - 'id': 'hs_legal_basis', - 'label': 'Legal basis for processing contact\'s data', + id: 'hs_legal_basis', + label: "Legal basis for processing contact's data", }, { - 'id': 'hs_linkedinid', - 'label': 'Linkedin ID', + id: 'hs_linkedinid', + label: 'Linkedin ID', }, { - 'id': 'hs_marketable_reason_id', - 'label': 'Marketing contact status source name', + id: 'hs_marketable_reason_id', + label: 'Marketing contact status source name', }, { - 'id': 'hs_marketable_reason_type', - 'label': 'Marketing contact status source type', + id: 'hs_marketable_reason_type', + label: 'Marketing contact status source type', }, { - 'id': 'hs_marketable_status', - 'label': 'Marketing contact status', + id: 'hs_marketable_status', + label: 'Marketing contact status', }, { - 'id': 'hs_marketable_until_renewal', - 'label': 'Marketing contact until next update', + id: 'hs_marketable_until_renewal', + label: 'Marketing contact until next update', }, { - 'id': 'hs_merged_object_ids', - 'label': 'Merged object IDs', + id: 'hs_merged_object_ids', + label: 'Merged object IDs', }, { - 'id': 'hs_object_id', - 'label': 'Contact ID', + id: 'hs_object_id', + label: 'Contact ID', }, { - 'id': 'hs_predictivecontactscore_v2', - 'label': 'Likelihood to close', + id: 'hs_predictivecontactscore_v2', + label: 'Likelihood to close', }, { - 'id': 'hs_predictivescoringtier', - 'label': 'Contact priority', + id: 'hs_predictivescoringtier', + label: 'Contact priority', }, { - 'id': 'hs_sa_first_engagement_date', - 'label': 'Date of first engagement', + id: 'hs_sa_first_engagement_date', + label: 'Date of first engagement', }, { - 'id': 'hs_sa_first_engagement_descr', - 'label': 'Description of first engagement', + id: 'hs_sa_first_engagement_descr', + label: 'Description of first engagement', }, { - 'id': 'hs_sa_first_engagement_object_type', - 'label': 'Type of first engagement', + id: 'hs_sa_first_engagement_object_type', + label: 'Type of first engagement', }, { - 'id': 'hs_sales_email_last_clicked', - 'label': 'Recent Sales Email Clicked Date', + id: 'hs_sales_email_last_clicked', + label: 'Recent Sales Email Clicked Date', }, { - 'id': 'hs_sales_email_last_opened', - 'label': 'Recent Sales Email Opened Date', + id: 'hs_sales_email_last_opened', + label: 'Recent Sales Email Opened Date', }, { - 'id': 'hs_searchable_calculated_international_mobile_number', - 'label': 'Calculated Mobile Number with country code', + id: 'hs_searchable_calculated_international_mobile_number', + label: 'Calculated Mobile Number with country code', }, { - 'id': 'hs_searchable_calculated_international_phone_number', - 'label': 'Calculated Phone Number with country code', + id: 'hs_searchable_calculated_international_phone_number', + label: 'Calculated Phone Number with country code', }, { - 'id': 'hs_searchable_calculated_mobile_number', - 'label': 'Calculated Mobile Number without country code', + id: 'hs_searchable_calculated_mobile_number', + label: 'Calculated Mobile Number without country code', }, { - 'id': 'hs_searchable_calculated_phone_number', - 'label': 'Calculated Phone Number without country code', + id: 'hs_searchable_calculated_phone_number', + label: 'Calculated Phone Number without country code', }, { - 'id': 'hs_sequences_is_enrolled', - 'label': 'Currently in Sequence', + id: 'hs_sequences_is_enrolled', + label: 'Currently in Sequence', }, { - 'id': 'hs_testpurge', - 'label': 'testpurge', + id: 'hs_testpurge', + label: 'testpurge', }, { - 'id': 'hs_testrollback', - 'label': 'testrollback', + id: 'hs_testrollback', + label: 'testrollback', }, { - 'id': 'hs_time_between_contact_creation_and_deal_close', - 'label': 'Time between contact creation and deal close', + id: 'hs_time_between_contact_creation_and_deal_close', + label: 'Time between contact creation and deal close', }, { - 'id': 'hs_time_between_contact_creation_and_deal_creation', - 'label': 'Time between contact creation and deal creation', + id: 'hs_time_between_contact_creation_and_deal_creation', + label: 'Time between contact creation and deal creation', }, { - 'id': 'hs_time_to_first_engagement', - 'label': 'Lead response time', + id: 'hs_time_to_first_engagement', + label: 'Lead response time', }, { - 'id': 'hs_time_to_move_from_lead_to_customer', - 'label': 'Time to move from lead to customer', + id: 'hs_time_to_move_from_lead_to_customer', + label: 'Time to move from lead to customer', }, { - 'id': 'hs_time_to_move_from_marketingqualifiedlead_to_customer', - 'label': 'Time to move from marketing qualified lead to customer', + id: 'hs_time_to_move_from_marketingqualifiedlead_to_customer', + label: 'Time to move from marketing qualified lead to customer', }, { - 'id': 'hs_time_to_move_from_opportunity_to_customer', - 'label': 'Time to move from opportunity to customer', + id: 'hs_time_to_move_from_opportunity_to_customer', + label: 'Time to move from opportunity to customer', }, { - 'id': 'hs_time_to_move_from_salesqualifiedlead_to_customer', - 'label': 'Time to move from sales qualified lead to customer', + id: 'hs_time_to_move_from_salesqualifiedlead_to_customer', + label: 'Time to move from sales qualified lead to customer', }, { - 'id': 'hs_time_to_move_from_subscriber_to_customer', - 'label': 'Time to move from subscriber to customer', + id: 'hs_time_to_move_from_subscriber_to_customer', + label: 'Time to move from subscriber to customer', }, { - 'id': 'hs_twitterid', - 'label': 'Twitter ID', + id: 'hs_twitterid', + label: 'Twitter ID', }, { - 'id': 'hs_updated_by_user_id', - 'label': 'Updated by user ID', + id: 'hs_updated_by_user_id', + label: 'Updated by user ID', }, { - 'id': 'hs_user_ids_of_all_owners', - 'label': 'User IDs of all owners', + id: 'hs_user_ids_of_all_owners', + label: 'User IDs of all owners', }, { - 'id': 'hubspot_owner_assigneddate', - 'label': 'Owner Assigned Date', + id: 'hubspot_owner_assigneddate', + label: 'Owner Assigned Date', }, { - 'id': 'ip_city', - 'label': 'IP City', + id: 'ip_city', + label: 'IP City', }, { - 'id': 'ip_country', - 'label': 'IP Country', + id: 'ip_country', + label: 'IP Country', }, { - 'id': 'ip_country_code', - 'label': 'IP Country Code', + id: 'ip_country_code', + label: 'IP Country Code', }, { - 'id': 'ip_latlon', - 'label': 'IP Latitude & Longitude', + id: 'ip_latlon', + label: 'IP Latitude & Longitude', }, { - 'id': 'ip_state', - 'label': 'IP State/Region', + id: 'ip_state', + label: 'IP State/Region', }, { - 'id': 'ip_state_code', - 'label': 'IP State Code/Region Code', + id: 'ip_state_code', + label: 'IP State Code/Region Code', }, { - 'id': 'ip_zipcode', - 'label': 'IP Zipcode', + id: 'ip_zipcode', + label: 'IP Zipcode', }, { - 'id': 'job_function', - 'label': 'Job function', + id: 'job_function', + label: 'Job function', }, { - 'id': 'lastmodifieddate', - 'label': 'Last Modified Date', + id: 'lastmodifieddate', + label: 'Last Modified Date', }, { - 'id': 'marital_status', - 'label': 'Marital Status', + id: 'marital_status', + label: 'Marital Status', }, { - 'id': 'military_status', - 'label': 'Military status', + id: 'military_status', + label: 'Military status', }, { - 'id': 'num_associated_deals', - 'label': 'Associated Deals', + id: 'num_associated_deals', + label: 'Associated Deals', }, { - 'id': 'num_conversion_events', - 'label': 'Number of Form Submissions', + id: 'num_conversion_events', + label: 'Number of Form Submissions', }, { - 'id': 'num_unique_conversion_events', - 'label': 'Number of Unique Forms Submitted', + id: 'num_unique_conversion_events', + label: 'Number of Unique Forms Submitted', }, { - 'id': 'recent_conversion_date', - 'label': 'Recent Conversion Date', + id: 'recent_conversion_date', + label: 'Recent Conversion Date', }, { - 'id': 'recent_conversion_event_name', - 'label': 'Recent Conversion', + id: 'recent_conversion_event_name', + label: 'Recent Conversion', }, { - 'id': 'recent_deal_amount', - 'label': 'Recent Deal Amount', + id: 'recent_deal_amount', + label: 'Recent Deal Amount', }, { - 'id': 'recent_deal_close_date', - 'label': 'Recent Deal Close Date', + id: 'recent_deal_close_date', + label: 'Recent Deal Close Date', }, { - 'id': 'relationship_status', - 'label': 'Relationship Status', + id: 'relationship_status', + label: 'Relationship Status', }, { - 'id': 'school', - 'label': 'School', + id: 'school', + label: 'School', }, { - 'id': 'seniority', - 'label': 'Seniority', + id: 'seniority', + label: 'Seniority', }, { - 'id': 'start_date', - 'label': 'Start date', + id: 'start_date', + label: 'Start date', }, { - 'id': 'testing', - 'label': 'testing', + id: 'testing', + label: 'testing', }, { - 'id': 'total_revenue', - 'label': 'Total Revenue', + id: 'total_revenue', + label: 'Total Revenue', }, { - 'id': 'work_email', - 'label': 'Work email', + id: 'work_email', + label: 'Work email', }, { - 'id': 'firstname', - 'label': 'First Name', + id: 'firstname', + label: 'First Name', }, { - 'id': 'hs_analytics_first_url', - 'label': 'First Page Seen', + id: 'hs_analytics_first_url', + label: 'First Page Seen', }, { - 'id': 'hs_email_delivered', - 'label': 'Marketing emails delivered', + id: 'hs_email_delivered', + label: 'Marketing emails delivered', }, { - 'id': 'hs_email_optout_6871816', - 'label': 'Opted out of email: Marketing Information', + id: 'hs_email_optout_6871816', + label: 'Opted out of email: Marketing Information', }, { - 'id': 'hs_email_optout_8363428', - 'label': 'Opted out of email: One to One', + id: 'hs_email_optout_8363428', + label: 'Opted out of email: One to One', }, { - 'id': 'twitterhandle', - 'label': 'Twitter Username', + id: 'twitterhandle', + label: 'Twitter Username', }, { - 'id': 'currentlyinworkflow', - 'label': 'Currently in workflow', + id: 'currentlyinworkflow', + label: 'Currently in workflow', }, { - 'id': 'followercount', - 'label': 'Follower Count', + id: 'followercount', + label: 'Follower Count', }, { - 'id': 'hs_analytics_last_url', - 'label': 'Last Page Seen', + id: 'hs_analytics_last_url', + label: 'Last Page Seen', }, { - 'id': 'hs_email_open', - 'label': 'Marketing emails opened', + id: 'hs_email_open', + label: 'Marketing emails opened', }, { - 'id': 'lastname', - 'label': 'Last Name', + id: 'lastname', + label: 'Last Name', }, { - 'id': 'hs_analytics_num_page_views', - 'label': 'Number of Pageviews', + id: 'hs_analytics_num_page_views', + label: 'Number of Pageviews', }, { - 'id': 'hs_email_click', - 'label': 'Marketing emails clicked', + id: 'hs_email_click', + label: 'Marketing emails clicked', }, { - 'id': 'salutation', - 'label': 'Salutation', + id: 'salutation', + label: 'Salutation', }, { - 'id': 'twitterprofilephoto', - 'label': 'Twitter Profile Photo', + id: 'twitterprofilephoto', + label: 'Twitter Profile Photo', }, { - 'id': 'email', - 'label': 'Email', + id: 'email', + label: 'Email', }, { - 'id': 'hs_analytics_num_visits', - 'label': 'Number of Sessions', + id: 'hs_analytics_num_visits', + label: 'Number of Sessions', }, { - 'id': 'hs_email_bounce', - 'label': 'Marketing emails bounced', + id: 'hs_email_bounce', + label: 'Marketing emails bounced', }, { - 'id': 'hs_persona', - 'label': 'Persona', + id: 'hs_persona', + label: 'Persona', }, { - 'id': 'hs_social_last_engagement', - 'label': 'Most Recent Social Click', + id: 'hs_social_last_engagement', + label: 'Most Recent Social Click', }, { - 'id': 'hs_analytics_num_event_completions', - 'label': 'Number of event completions', + id: 'hs_analytics_num_event_completions', + label: 'Number of event completions', }, { - 'id': 'hs_email_optout', - 'label': 'Unsubscribed from all email', + id: 'hs_email_optout', + label: 'Unsubscribed from all email', }, { - 'id': 'hs_social_twitter_clicks', - 'label': 'Twitter Clicks', + id: 'hs_social_twitter_clicks', + label: 'Twitter Clicks', }, { - 'id': 'mobilephone', - 'label': 'Mobile Phone Number', + id: 'mobilephone', + label: 'Mobile Phone Number', }, { - 'id': 'phone', - 'label': 'Phone Number', + id: 'phone', + label: 'Phone Number', }, { - 'id': 'fax', - 'label': 'Fax Number', + id: 'fax', + label: 'Fax Number', }, { - 'id': 'hs_analytics_first_timestamp', - 'label': 'Time First Seen', + id: 'hs_analytics_first_timestamp', + label: 'Time First Seen', }, { - 'id': 'hs_email_last_email_name', - 'label': 'Last marketing email name', + id: 'hs_email_last_email_name', + label: 'Last marketing email name', }, { - 'id': 'hs_email_last_send_date', - 'label': 'Last marketing email send date', + id: 'hs_email_last_send_date', + label: 'Last marketing email send date', }, { - 'id': 'hs_social_facebook_clicks', - 'label': 'Facebook Clicks', + id: 'hs_social_facebook_clicks', + label: 'Facebook Clicks', }, { - 'id': 'address', - 'label': 'Street Address', + id: 'address', + label: 'Street Address', }, { - 'id': 'engagements_last_meeting_booked', - 'label': 'Date of last meeting booked in meetings tool', + id: 'engagements_last_meeting_booked', + label: 'Date of last meeting booked in meetings tool', }, { - 'id': 'engagements_last_meeting_booked_campaign', - 'label': 'Campaign of last booking in meetings tool', + id: 'engagements_last_meeting_booked_campaign', + label: 'Campaign of last booking in meetings tool', }, { - 'id': 'engagements_last_meeting_booked_medium', - 'label': 'Medium of last booking in meetings tool', + id: 'engagements_last_meeting_booked_medium', + label: 'Medium of last booking in meetings tool', }, { - 'id': 'engagements_last_meeting_booked_source', - 'label': 'Source of last booking in meetings tool', + id: 'engagements_last_meeting_booked_source', + label: 'Source of last booking in meetings tool', }, { - 'id': 'hs_analytics_first_visit_timestamp', - 'label': 'Time of First Session', + id: 'hs_analytics_first_visit_timestamp', + label: 'Time of First Session', }, { - 'id': 'hs_email_last_open_date', - 'label': 'Last marketing email open date', + id: 'hs_email_last_open_date', + label: 'Last marketing email open date', }, { - 'id': 'hs_latest_meeting_activity', - 'label': 'Latest meeting activity', + id: 'hs_latest_meeting_activity', + label: 'Latest meeting activity', }, { - 'id': 'hs_sales_email_last_replied', - 'label': 'Recent Sales Email Replied Date', + id: 'hs_sales_email_last_replied', + label: 'Recent Sales Email Replied Date', }, { - 'id': 'hs_social_linkedin_clicks', - 'label': 'LinkedIn Clicks', + id: 'hs_social_linkedin_clicks', + label: 'LinkedIn Clicks', }, { - 'id': 'hubspot_owner_id', - 'label': 'Contact owner', + id: 'hubspot_owner_id', + label: 'Contact owner', }, { - 'id': 'notes_last_contacted', - 'label': 'Last Contacted', + id: 'notes_last_contacted', + label: 'Last Contacted', }, { - 'id': 'notes_last_updated', - 'label': 'Last Activity Date', + id: 'notes_last_updated', + label: 'Last Activity Date', }, { - 'id': 'notes_next_activity_date', - 'label': 'Next Activity Date', + id: 'notes_next_activity_date', + label: 'Next Activity Date', }, { - 'id': 'num_contacted_notes', - 'label': 'Number of times contacted', + id: 'num_contacted_notes', + label: 'Number of times contacted', }, { - 'id': 'num_notes', - 'label': 'Number of Sales Activities', + id: 'num_notes', + label: 'Number of Sales Activities', }, { - 'id': 'owneremail', - 'label': 'HubSpot Owner Email (legacy)', + id: 'owneremail', + label: 'HubSpot Owner Email (legacy)', }, { - 'id': 'ownername', - 'label': 'HubSpot Owner Name (legacy)', + id: 'ownername', + label: 'HubSpot Owner Name (legacy)', }, { - 'id': 'surveymonkeyeventlastupdated', - 'label': 'SurveyMonkey Event Last Updated', + id: 'surveymonkeyeventlastupdated', + label: 'SurveyMonkey Event Last Updated', }, { - 'id': 'webinareventlastupdated', - 'label': 'Webinar Event Last Updated', + id: 'webinareventlastupdated', + label: 'Webinar Event Last Updated', }, { - 'id': 'city', - 'label': 'City', + id: 'city', + label: 'City', }, { - 'id': 'hs_analytics_last_timestamp', - 'label': 'Time Last Seen', + id: 'hs_analytics_last_timestamp', + label: 'Time Last Seen', }, { - 'id': 'hs_email_last_click_date', - 'label': 'Last marketing email click date', + id: 'hs_email_last_click_date', + label: 'Last marketing email click date', }, { - 'id': 'hs_social_google_plus_clicks', - 'label': 'Google Plus Clicks', + id: 'hs_social_google_plus_clicks', + label: 'Google Plus Clicks', }, { - 'id': 'hubspot_team_id', - 'label': 'HubSpot Team', + id: 'hubspot_team_id', + label: 'HubSpot Team', }, { - 'id': 'linkedinbio', - 'label': 'LinkedIn Bio', + id: 'linkedinbio', + label: 'LinkedIn Bio', }, { - 'id': 'twitterbio', - 'label': 'Twitter Bio', + id: 'twitterbio', + label: 'Twitter Bio', }, { - 'id': 'hs_all_owner_ids', - 'label': 'All owner ids', + id: 'hs_all_owner_ids', + label: 'All owner ids', }, { - 'id': 'hs_analytics_last_visit_timestamp', - 'label': 'Time of Last Session', + id: 'hs_analytics_last_visit_timestamp', + label: 'Time of Last Session', }, { - 'id': 'hs_email_first_send_date', - 'label': 'First marketing email send date', + id: 'hs_email_first_send_date', + label: 'First marketing email send date', }, { - 'id': 'hs_social_num_broadcast_clicks', - 'label': 'Broadcast Clicks', + id: 'hs_social_num_broadcast_clicks', + label: 'Broadcast Clicks', }, { - 'id': 'state', - 'label': 'State/Region', + id: 'state', + label: 'State/Region', }, { - 'id': 'hs_all_team_ids', - 'label': 'All team ids', + id: 'hs_all_team_ids', + label: 'All team ids', }, { - 'id': 'hs_analytics_source', - 'label': 'Original Source', + id: 'hs_analytics_source', + label: 'Original Source', }, { - 'id': 'hs_email_first_open_date', - 'label': 'First marketing email open date', + id: 'hs_email_first_open_date', + label: 'First marketing email open date', }, { - 'id': 'zip', - 'label': 'Postal Code', + id: 'zip', + label: 'Postal Code', }, { - 'id': 'country', - 'label': 'Country/Region', + id: 'country', + label: 'Country/Region', }, { - 'id': 'hs_all_accessible_team_ids', - 'label': 'All accessible team ids', + id: 'hs_all_accessible_team_ids', + label: 'All accessible team ids', }, { - 'id': 'hs_analytics_source_data_1', - 'label': 'Original Source Drill-Down 1', + id: 'hs_analytics_source_data_1', + label: 'Original Source Drill-Down 1', }, { - 'id': 'hs_email_first_click_date', - 'label': 'First marketing email click date', + id: 'hs_email_first_click_date', + label: 'First marketing email click date', }, { - 'id': 'linkedinconnections', - 'label': 'LinkedIn Connections', + id: 'linkedinconnections', + label: 'LinkedIn Connections', }, { - 'id': 'hs_analytics_source_data_2', - 'label': 'Original Source Drill-Down 2', + id: 'hs_analytics_source_data_2', + label: 'Original Source Drill-Down 2', }, { - 'id': 'hs_email_is_ineligible', - 'label': 'Is globally ineligible', + id: 'hs_email_is_ineligible', + label: 'Is globally ineligible', }, { - 'id': 'hs_language', - 'label': 'Preferred language', + id: 'hs_language', + label: 'Preferred language', }, { - 'id': 'kloutscoregeneral', - 'label': 'Klout Score', + id: 'kloutscoregeneral', + label: 'Klout Score', }, { - 'id': 'hs_analytics_first_referrer', - 'label': 'First Referring Site', + id: 'hs_analytics_first_referrer', + label: 'First Referring Site', }, { - 'id': 'hs_email_first_reply_date', - 'label': 'First marketing email reply date', + id: 'hs_email_first_reply_date', + label: 'First marketing email reply date', }, { - 'id': 'jobtitle', - 'label': 'Job Title', + id: 'jobtitle', + label: 'Job Title', }, { - 'id': 'photo', - 'label': 'Photo', + id: 'photo', + label: 'Photo', }, { - 'id': 'hs_analytics_last_referrer', - 'label': 'Last Referring Site', + id: 'hs_analytics_last_referrer', + label: 'Last Referring Site', }, { - 'id': 'hs_email_last_reply_date', - 'label': 'Last marketing email reply date', + id: 'hs_email_last_reply_date', + label: 'Last marketing email reply date', }, { - 'id': 'message', - 'label': 'Message', + id: 'message', + label: 'Message', }, { - 'id': 'closedate', - 'label': 'Close Date', + id: 'closedate', + label: 'Close Date', }, { - 'id': 'hs_analytics_average_page_views', - 'label': 'Average Pageviews', + id: 'hs_analytics_average_page_views', + label: 'Average Pageviews', }, { - 'id': 'hs_email_replied', - 'label': 'Marketing emails replied', + id: 'hs_email_replied', + label: 'Marketing emails replied', }, { - 'id': 'hs_analytics_revenue', - 'label': 'Event Revenue', + id: 'hs_analytics_revenue', + label: 'Event Revenue', }, { - 'id': 'hs_lifecyclestage_lead_date', - 'label': 'Became a Lead Date', + id: 'hs_lifecyclestage_lead_date', + label: 'Became a Lead Date', }, { - 'id': 'hs_lifecyclestage_marketingqualifiedlead_date', - 'label': 'Became a Marketing Qualified Lead Date', + id: 'hs_lifecyclestage_marketingqualifiedlead_date', + label: 'Became a Marketing Qualified Lead Date', }, { - 'id': 'hs_lifecyclestage_opportunity_date', - 'label': 'Became an Opportunity Date', + id: 'hs_lifecyclestage_opportunity_date', + label: 'Became an Opportunity Date', }, { - 'id': 'lifecyclestage', - 'label': 'Lifecycle Stage', + id: 'lifecyclestage', + label: 'Lifecycle Stage', }, { - 'id': 'hs_lifecyclestage_salesqualifiedlead_date', - 'label': 'Became a Sales Qualified Lead Date', + id: 'hs_lifecyclestage_salesqualifiedlead_date', + label: 'Became a Sales Qualified Lead Date', }, { - 'id': 'createdate', - 'label': 'Create Date', + id: 'createdate', + label: 'Create Date', }, { - 'id': 'hs_lifecyclestage_evangelist_date', - 'label': 'Became an Evangelist Date', + id: 'hs_lifecyclestage_evangelist_date', + label: 'Became an Evangelist Date', }, { - 'id': 'hs_lifecyclestage_customer_date', - 'label': 'Became a Customer Date', + id: 'hs_lifecyclestage_customer_date', + label: 'Became a Customer Date', }, { - 'id': 'hubspotscore', - 'label': 'HubSpot Score', + id: 'hubspotscore', + label: 'HubSpot Score', }, { - 'id': 'company', - 'label': 'Company Name', + id: 'company', + label: 'Company Name', }, { - 'id': 'hs_lifecyclestage_subscriber_date', - 'label': 'Became a Subscriber Date', + id: 'hs_lifecyclestage_subscriber_date', + label: 'Became a Subscriber Date', }, { - 'id': 'hs_lifecyclestage_other_date', - 'label': 'Became an Other Lifecycle Date', + id: 'hs_lifecyclestage_other_date', + label: 'Became an Other Lifecycle Date', }, { - 'id': 'website', - 'label': 'Website URL', + id: 'website', + label: 'Website URL', }, { - 'id': 'numemployees', - 'label': 'Number of Employees', + id: 'numemployees', + label: 'Number of Employees', }, { - 'id': 'annualrevenue', - 'label': 'Annual Revenue', + id: 'annualrevenue', + label: 'Annual Revenue', }, { - 'id': 'industry', - 'label': 'Industry', + id: 'industry', + label: 'Industry', }, { - 'id': 'associatedcompanyid', - 'label': 'Associated Company ID', + id: 'associatedcompanyid', + label: 'Associated Company ID', }, { - 'id': 'associatedcompanylastupdated', - 'label': 'Associated Company Last Updated', + id: 'associatedcompanylastupdated', + label: 'Associated Company Last Updated', }, { - 'id': 'hs_predictivecontactscorebucket', - 'label': 'Lead Rating', + id: 'hs_predictivecontactscorebucket', + label: 'Lead Rating', }, { - 'id': 'hs_predictivecontactscore', - 'label': 'Predictive Lead Score', + id: 'hs_predictivecontactscore', + label: 'Predictive Lead Score', }, ]; export const companyFields = [ { - 'id': 'about_us', - 'label': 'About Us', + id: 'about_us', + label: 'About Us', }, { - 'id': 'closedate_timestamp_earliest_value_a2a17e6e', - 'label': 'closedate_timestamp_earliest_value_a2a17e6e', + id: 'closedate_timestamp_earliest_value_a2a17e6e', + label: 'closedate_timestamp_earliest_value_a2a17e6e', }, { - 'id': 'facebookfans', - 'label': 'Facebook Fans', + id: 'facebookfans', + label: 'Facebook Fans', }, { - 'id': 'first_contact_createdate_timestamp_earliest_value_78b50eea', - 'label': 'first_contact_createdate_timestamp_earliest_value_78b50eea', + id: 'first_contact_createdate_timestamp_earliest_value_78b50eea', + label: 'first_contact_createdate_timestamp_earliest_value_78b50eea', }, { - 'id': 'first_conversion_date', - 'label': 'First Conversion Date', + id: 'first_conversion_date', + label: 'First Conversion Date', }, { - 'id': 'first_conversion_date_timestamp_earliest_value_61f58f2c', - 'label': 'first_conversion_date_timestamp_earliest_value_61f58f2c', + id: 'first_conversion_date_timestamp_earliest_value_61f58f2c', + label: 'first_conversion_date_timestamp_earliest_value_61f58f2c', }, { - 'id': 'first_conversion_event_name', - 'label': 'First Conversion', + id: 'first_conversion_event_name', + label: 'First Conversion', }, { - 'id': 'first_conversion_event_name_timestamp_earliest_value_68ddae0a', - 'label': 'first_conversion_event_name_timestamp_earliest_value_68ddae0a', + id: 'first_conversion_event_name_timestamp_earliest_value_68ddae0a', + label: 'first_conversion_event_name_timestamp_earliest_value_68ddae0a', }, { - 'id': 'first_deal_created_date', - 'label': 'First Deal Created Date', + id: 'first_deal_created_date', + label: 'First Deal Created Date', }, { - 'id': 'founded_year', - 'label': 'Year Founded', + id: 'founded_year', + label: 'Year Founded', }, { - 'id': 'hs_additional_domains', - 'label': 'Additional Domains', + id: 'hs_additional_domains', + label: 'Additional Domains', }, { - 'id': 'hs_analytics_first_timestamp', - 'label': 'Time First Seen', + id: 'hs_analytics_first_timestamp', + label: 'Time First Seen', }, { - 'id': 'hs_analytics_first_timestamp_timestamp_earliest_value_11e3a63a', - 'label': 'hs_analytics_first_timestamp_timestamp_earliest_value_11e3a63a', + id: 'hs_analytics_first_timestamp_timestamp_earliest_value_11e3a63a', + label: 'hs_analytics_first_timestamp_timestamp_earliest_value_11e3a63a', }, { - 'id': 'hs_analytics_first_touch_converting_campaign', - 'label': 'First Touch Converting Campaign', + id: 'hs_analytics_first_touch_converting_campaign', + label: 'First Touch Converting Campaign', }, { - 'id': 'hs_analytics_first_touch_converting_campaign_timestamp_earliest_value_4757fe10', - 'label': 'hs_analytics_first_touch_converting_campaign_timestamp_earliest_value_4757fe10', + id: 'hs_analytics_first_touch_converting_campaign_timestamp_earliest_value_4757fe10', + label: 'hs_analytics_first_touch_converting_campaign_timestamp_earliest_value_4757fe10', }, { - 'id': 'hs_analytics_first_visit_timestamp', - 'label': 'Time of First Session', + id: 'hs_analytics_first_visit_timestamp', + label: 'Time of First Session', }, { - 'id': 'hs_analytics_first_visit_timestamp_timestamp_earliest_value_accc17ae', - 'label': 'hs_analytics_first_visit_timestamp_timestamp_earliest_value_accc17ae', + id: 'hs_analytics_first_visit_timestamp_timestamp_earliest_value_accc17ae', + label: 'hs_analytics_first_visit_timestamp_timestamp_earliest_value_accc17ae', }, { - 'id': 'hs_analytics_last_timestamp', - 'label': 'Time Last Seen', + id: 'hs_analytics_last_timestamp', + label: 'Time Last Seen', }, { - 'id': 'hs_analytics_last_timestamp_timestamp_latest_value_4e16365a', - 'label': 'hs_analytics_last_timestamp_timestamp_latest_value_4e16365a', + id: 'hs_analytics_last_timestamp_timestamp_latest_value_4e16365a', + label: 'hs_analytics_last_timestamp_timestamp_latest_value_4e16365a', }, { - 'id': 'hs_analytics_last_touch_converting_campaign', - 'label': 'Last Touch Converting Campaign', + id: 'hs_analytics_last_touch_converting_campaign', + label: 'Last Touch Converting Campaign', }, { - 'id': 'hs_analytics_last_touch_converting_campaign_timestamp_latest_value_81a64e30', - 'label': 'hs_analytics_last_touch_converting_campaign_timestamp_latest_value_81a64e30', + id: 'hs_analytics_last_touch_converting_campaign_timestamp_latest_value_81a64e30', + label: 'hs_analytics_last_touch_converting_campaign_timestamp_latest_value_81a64e30', }, { - 'id': 'hs_analytics_last_visit_timestamp', - 'label': 'Time of Last Session', + id: 'hs_analytics_last_visit_timestamp', + label: 'Time of Last Session', }, { - 'id': 'hs_analytics_last_visit_timestamp_timestamp_latest_value_999a0fce', - 'label': 'hs_analytics_last_visit_timestamp_timestamp_latest_value_999a0fce', + id: 'hs_analytics_last_visit_timestamp_timestamp_latest_value_999a0fce', + label: 'hs_analytics_last_visit_timestamp_timestamp_latest_value_999a0fce', }, { - 'id': 'hs_analytics_num_page_views', - 'label': 'Number of Pageviews', + id: 'hs_analytics_num_page_views', + label: 'Number of Pageviews', }, { - 'id': 'hs_analytics_num_page_views_cardinality_sum_e46e85b0', - 'label': 'hs_analytics_num_page_views_cardinality_sum_e46e85b0', + id: 'hs_analytics_num_page_views_cardinality_sum_e46e85b0', + label: 'hs_analytics_num_page_views_cardinality_sum_e46e85b0', }, { - 'id': 'hs_analytics_num_visits', - 'label': 'Number of Sessions', + id: 'hs_analytics_num_visits', + label: 'Number of Sessions', }, { - 'id': 'hs_analytics_num_visits_cardinality_sum_53d952a6', - 'label': 'hs_analytics_num_visits_cardinality_sum_53d952a6', + id: 'hs_analytics_num_visits_cardinality_sum_53d952a6', + label: 'hs_analytics_num_visits_cardinality_sum_53d952a6', }, { - 'id': 'hs_analytics_source', - 'label': 'Original Source Type', + id: 'hs_analytics_source', + label: 'Original Source Type', }, { - 'id': 'hs_analytics_source_data_1', - 'label': 'Original Source Data 1', + id: 'hs_analytics_source_data_1', + label: 'Original Source Data 1', }, { - 'id': 'hs_analytics_source_data_1_timestamp_earliest_value_9b2f1fa1', - 'label': 'hs_analytics_source_data_1_timestamp_earliest_value_9b2f1fa1', + id: 'hs_analytics_source_data_1_timestamp_earliest_value_9b2f1fa1', + label: 'hs_analytics_source_data_1_timestamp_earliest_value_9b2f1fa1', }, { - 'id': 'hs_analytics_source_data_2', - 'label': 'Original Source Data 2', + id: 'hs_analytics_source_data_2', + label: 'Original Source Data 2', }, { - 'id': 'hs_analytics_source_data_2_timestamp_earliest_value_9b2f9400', - 'label': 'hs_analytics_source_data_2_timestamp_earliest_value_9b2f9400', + id: 'hs_analytics_source_data_2_timestamp_earliest_value_9b2f9400', + label: 'hs_analytics_source_data_2_timestamp_earliest_value_9b2f9400', }, { - 'id': 'hs_analytics_source_timestamp_earliest_value_25a3a52c', - 'label': 'hs_analytics_source_timestamp_earliest_value_25a3a52c', + id: 'hs_analytics_source_timestamp_earliest_value_25a3a52c', + label: 'hs_analytics_source_timestamp_earliest_value_25a3a52c', }, { - 'id': 'hs_avatar_filemanager_key', - 'label': 'Avatar FileManager key', + id: 'hs_avatar_filemanager_key', + label: 'Avatar FileManager key', }, { - 'id': 'hs_created_by_user_id', - 'label': 'Created by user ID', + id: 'hs_created_by_user_id', + label: 'Created by user ID', }, { - 'id': 'hs_createdate', - 'label': 'Object create date/time', + id: 'hs_createdate', + label: 'Object create date/time', }, { - 'id': 'hs_ideal_customer_profile', - 'label': 'Ideal Customer Profile Tier', + id: 'hs_ideal_customer_profile', + label: 'Ideal Customer Profile Tier', }, { - 'id': 'hs_is_target_account', - 'label': 'Target Account', + id: 'hs_is_target_account', + label: 'Target Account', }, { - 'id': 'hs_last_booked_meeting_date', - 'label': 'Last Booked Meeting Date', + id: 'hs_last_booked_meeting_date', + label: 'Last Booked Meeting Date', }, { - 'id': 'hs_last_logged_call_date', - 'label': 'Last Logged Call Date', + id: 'hs_last_logged_call_date', + label: 'Last Logged Call Date', }, { - 'id': 'hs_last_open_task_date', - 'label': 'Last Open Task Date', + id: 'hs_last_open_task_date', + label: 'Last Open Task Date', }, { - 'id': 'hs_last_sales_activity_date', - 'label': 'last sales activity date old', + id: 'hs_last_sales_activity_date', + label: 'last sales activity date old', }, { - 'id': 'hs_last_sales_activity_timestamp', - 'label': 'Last Engagement Date', + id: 'hs_last_sales_activity_timestamp', + label: 'Last Engagement Date', }, { - 'id': 'hs_lastmodifieddate', - 'label': 'Last Modified Date', + id: 'hs_lastmodifieddate', + label: 'Last Modified Date', }, { - 'id': 'hs_merged_object_ids', - 'label': 'Merged object IDs', + id: 'hs_merged_object_ids', + label: 'Merged object IDs', }, { - 'id': 'hs_num_blockers', - 'label': 'Number of blockers', + id: 'hs_num_blockers', + label: 'Number of blockers', }, { - 'id': 'hs_num_contacts_with_buying_roles', - 'label': 'Number of contacts with a buying role', + id: 'hs_num_contacts_with_buying_roles', + label: 'Number of contacts with a buying role', }, { - 'id': 'hs_num_decision_makers', - 'label': 'Number of decision makers', + id: 'hs_num_decision_makers', + label: 'Number of decision makers', }, { - 'id': 'hs_num_open_deals', - 'label': 'Number of open deals', + id: 'hs_num_open_deals', + label: 'Number of open deals', }, { - 'id': 'hs_object_id', - 'label': 'Company ID', + id: 'hs_object_id', + label: 'Company ID', }, { - 'id': 'hs_predictivecontactscore_v2', - 'label': 'Likelihood to close', + id: 'hs_predictivecontactscore_v2', + label: 'Likelihood to close', }, { - 'id': 'hs_predictivecontactscore_v2_next_max_max_d4e58c1e', - 'label': 'hs_predictivecontactscore_v2_next_max_max_d4e58c1e', + id: 'hs_predictivecontactscore_v2_next_max_max_d4e58c1e', + label: 'hs_predictivecontactscore_v2_next_max_max_d4e58c1e', }, { - 'id': 'hs_target_account', - 'label': 'Target Account', + id: 'hs_target_account', + label: 'Target Account', }, { - 'id': 'hs_target_account_probability', - 'label': 'Target Account Probability', + id: 'hs_target_account_probability', + label: 'Target Account Probability', }, { - 'id': 'hs_target_account_recommendation_snooze_time', - 'label': 'Target Account Recommendation Snooze Time', + id: 'hs_target_account_recommendation_snooze_time', + label: 'Target Account Recommendation Snooze Time', }, { - 'id': 'hs_target_account_recommendation_state', - 'label': 'Target Account Recommendation State', + id: 'hs_target_account_recommendation_state', + label: 'Target Account Recommendation State', }, { - 'id': 'hs_total_deal_value', - 'label': 'Total open deal value', + id: 'hs_total_deal_value', + label: 'Total open deal value', }, { - 'id': 'hs_updated_by_user_id', - 'label': 'Updated by user ID', + id: 'hs_updated_by_user_id', + label: 'Updated by user ID', }, { - 'id': 'hs_user_ids_of_all_owners', - 'label': 'User IDs of all owners', + id: 'hs_user_ids_of_all_owners', + label: 'User IDs of all owners', }, { - 'id': 'hubspot_owner_assigneddate', - 'label': 'Owner Assigned Date', + id: 'hubspot_owner_assigneddate', + label: 'Owner Assigned Date', }, { - 'id': 'is_public', - 'label': 'Is Public', + id: 'is_public', + label: 'Is Public', }, { - 'id': 'num_associated_contacts', - 'label': 'Associated Contacts', + id: 'num_associated_contacts', + label: 'Associated Contacts', }, { - 'id': 'num_associated_deals', - 'label': 'Associated Deals', + id: 'num_associated_deals', + label: 'Associated Deals', }, { - 'id': 'num_conversion_events', - 'label': 'Number of Form Submissions', + id: 'num_conversion_events', + label: 'Number of Form Submissions', }, { - 'id': 'num_conversion_events_cardinality_sum_d095f14b', - 'label': 'num_conversion_events_cardinality_sum_d095f14b', + id: 'num_conversion_events_cardinality_sum_d095f14b', + label: 'num_conversion_events_cardinality_sum_d095f14b', }, { - 'id': 'recent_conversion_date', - 'label': 'Recent Conversion Date', + id: 'recent_conversion_date', + label: 'Recent Conversion Date', }, { - 'id': 'recent_conversion_date_timestamp_latest_value_72856da1', - 'label': 'recent_conversion_date_timestamp_latest_value_72856da1', + id: 'recent_conversion_date_timestamp_latest_value_72856da1', + label: 'recent_conversion_date_timestamp_latest_value_72856da1', }, { - 'id': 'recent_conversion_event_name', - 'label': 'Recent Conversion', + id: 'recent_conversion_event_name', + label: 'Recent Conversion', }, { - 'id': 'recent_conversion_event_name_timestamp_latest_value_66c820bf', - 'label': 'recent_conversion_event_name_timestamp_latest_value_66c820bf', + id: 'recent_conversion_event_name_timestamp_latest_value_66c820bf', + label: 'recent_conversion_event_name_timestamp_latest_value_66c820bf', }, { - 'id': 'recent_deal_amount', - 'label': 'Recent Deal Amount', + id: 'recent_deal_amount', + label: 'Recent Deal Amount', }, { - 'id': 'recent_deal_close_date', - 'label': 'Recent Deal Close Date', + id: 'recent_deal_close_date', + label: 'Recent Deal Close Date', }, { - 'id': 'timezone', - 'label': 'Time Zone', + id: 'timezone', + label: 'Time Zone', }, { - 'id': 'total_money_raised', - 'label': 'Total Money Raised', + id: 'total_money_raised', + label: 'Total Money Raised', }, { - 'id': 'total_revenue', - 'label': 'Total Revenue', + id: 'total_revenue', + label: 'Total Revenue', }, { - 'id': 'name', - 'label': 'Name', + id: 'name', + label: 'Name', }, { - 'id': 'owneremail', - 'label': 'HubSpot Owner Email', + id: 'owneremail', + label: 'HubSpot Owner Email', }, { - 'id': 'twitterhandle', - 'label': 'Twitter Handle', + id: 'twitterhandle', + label: 'Twitter Handle', }, { - 'id': 'ownername', - 'label': 'HubSpot Owner Name', + id: 'ownername', + label: 'HubSpot Owner Name', }, { - 'id': 'phone', - 'label': 'Phone Number', + id: 'phone', + label: 'Phone Number', }, { - 'id': 'twitterbio', - 'label': 'Twitter Bio', + id: 'twitterbio', + label: 'Twitter Bio', }, { - 'id': 'twitterfollowers', - 'label': 'Twitter Followers', + id: 'twitterfollowers', + label: 'Twitter Followers', }, { - 'id': 'address', - 'label': 'Street Address', + id: 'address', + label: 'Street Address', }, { - 'id': 'address2', - 'label': 'Street Address 2', + id: 'address2', + label: 'Street Address 2', }, { - 'id': 'facebook_company_page', - 'label': 'Facebook Company Page', + id: 'facebook_company_page', + label: 'Facebook Company Page', }, { - 'id': 'city', - 'label': 'City', + id: 'city', + label: 'City', }, { - 'id': 'linkedin_company_page', - 'label': 'LinkedIn Company Page', + id: 'linkedin_company_page', + label: 'LinkedIn Company Page', }, { - 'id': 'linkedinbio', - 'label': 'LinkedIn Bio', + id: 'linkedinbio', + label: 'LinkedIn Bio', }, { - 'id': 'state', - 'label': 'State/Region', + id: 'state', + label: 'State/Region', }, { - 'id': 'googleplus_page', - 'label': 'Google Plus Page', + id: 'googleplus_page', + label: 'Google Plus Page', }, { - 'id': 'engagements_last_meeting_booked', - 'label': 'Date of last meeting booked in meetings tool', + id: 'engagements_last_meeting_booked', + label: 'Date of last meeting booked in meetings tool', }, { - 'id': 'engagements_last_meeting_booked_campaign', - 'label': 'Campaign of last booking in meetings tool', + id: 'engagements_last_meeting_booked_campaign', + label: 'Campaign of last booking in meetings tool', }, { - 'id': 'engagements_last_meeting_booked_medium', - 'label': 'Medium of last booking in meetings tool', + id: 'engagements_last_meeting_booked_medium', + label: 'Medium of last booking in meetings tool', }, { - 'id': 'engagements_last_meeting_booked_source', - 'label': 'Source of last booking in meetings tool', + id: 'engagements_last_meeting_booked_source', + label: 'Source of last booking in meetings tool', }, { - 'id': 'hs_latest_meeting_activity', - 'label': 'Latest meeting activity', + id: 'hs_latest_meeting_activity', + label: 'Latest meeting activity', }, { - 'id': 'hs_sales_email_last_replied', - 'label': 'Recent Sales Email Replied Date', + id: 'hs_sales_email_last_replied', + label: 'Recent Sales Email Replied Date', }, { - 'id': 'hubspot_owner_id', - 'label': 'Company owner', + id: 'hubspot_owner_id', + label: 'Company owner', }, { - 'id': 'notes_last_contacted', - 'label': 'Last Contacted', + id: 'notes_last_contacted', + label: 'Last Contacted', }, { - 'id': 'notes_last_updated', - 'label': 'Last Activity Date', + id: 'notes_last_updated', + label: 'Last Activity Date', }, { - 'id': 'notes_next_activity_date', - 'label': 'Next Activity Date', + id: 'notes_next_activity_date', + label: 'Next Activity Date', }, { - 'id': 'num_contacted_notes', - 'label': 'Number of times contacted', + id: 'num_contacted_notes', + label: 'Number of times contacted', }, { - 'id': 'num_notes', - 'label': 'Number of Sales Activities', + id: 'num_notes', + label: 'Number of Sales Activities', }, { - 'id': 'zip', - 'label': 'Postal Code', + id: 'zip', + label: 'Postal Code', }, { - 'id': 'country', - 'label': 'Country/Region', + id: 'country', + label: 'Country/Region', }, { - 'id': 'hubspot_team_id', - 'label': 'HubSpot Team', + id: 'hubspot_team_id', + label: 'HubSpot Team', }, { - 'id': 'hs_all_owner_ids', - 'label': 'All owner ids', + id: 'hs_all_owner_ids', + label: 'All owner ids', }, { - 'id': 'website', - 'label': 'Website URL', + id: 'website', + label: 'Website URL', }, { - 'id': 'domain', - 'label': 'Company Domain Name', + id: 'domain', + label: 'Company Domain Name', }, { - 'id': 'hs_all_team_ids', - 'label': 'All team ids', + id: 'hs_all_team_ids', + label: 'All team ids', }, { - 'id': 'hs_all_accessible_team_ids', - 'label': 'All accessible team ids', + id: 'hs_all_accessible_team_ids', + label: 'All accessible team ids', }, { - 'id': 'numberofemployees', - 'label': 'Number of Employees', + id: 'numberofemployees', + label: 'Number of Employees', }, { - 'id': 'industry', - 'label': 'Industry', + id: 'industry', + label: 'Industry', }, { - 'id': 'annualrevenue', - 'label': 'Annual Revenue', + id: 'annualrevenue', + label: 'Annual Revenue', }, { - 'id': 'lifecyclestage', - 'label': 'Lifecycle Stage', + id: 'lifecyclestage', + label: 'Lifecycle Stage', }, { - 'id': 'hs_lead_status', - 'label': 'Lead Status', + id: 'hs_lead_status', + label: 'Lead Status', }, { - 'id': 'hs_parent_company_id', - 'label': 'Parent Company', + id: 'hs_parent_company_id', + label: 'Parent Company', }, { - 'id': 'type', - 'label': 'Type', + id: 'type', + label: 'Type', }, { - 'id': 'description', - 'label': 'Description', + id: 'description', + label: 'Description', }, { - 'id': 'hs_num_child_companies', - 'label': 'Number of child companies', + id: 'hs_num_child_companies', + label: 'Number of child companies', }, { - 'id': 'hubspotscore', - 'label': 'HubSpot Score', + id: 'hubspotscore', + label: 'HubSpot Score', }, { - 'id': 'createdate', - 'label': 'Create Date', + id: 'createdate', + label: 'Create Date', }, { - 'id': 'closedate', - 'label': 'Close Date', + id: 'closedate', + label: 'Close Date', }, { - 'id': 'first_contact_createdate', - 'label': 'First Contact Create Date', + id: 'first_contact_createdate', + label: 'First Contact Create Date', }, { - 'id': 'days_to_close', - 'label': 'Days to Close', + id: 'days_to_close', + label: 'Days to Close', }, { - 'id': 'web_technologies', - 'label': 'Web Technologies', + id: 'web_technologies', + label: 'Web Technologies', }, ]; export const dealFields = [ { - 'id': 'amount_in_home_currency', - 'label': 'Amount in company currency', + id: 'amount_in_home_currency', + label: 'Amount in company currency', }, { - 'id': 'days_to_close', - 'label': 'Days to close', + id: 'days_to_close', + label: 'Days to close', }, { - 'id': 'deal_currency_code', - 'label': 'Currency', + id: 'deal_currency_code', + label: 'Currency', }, { - 'id': 'hs_acv', - 'label': 'Annual contract value', + id: 'hs_acv', + label: 'Annual contract value', }, { - 'id': 'hs_analytics_source', - 'label': 'Original Source Type', + id: 'hs_analytics_source', + label: 'Original Source Type', }, { - 'id': 'hs_analytics_source_data_1', - 'label': 'Original Source Data 1', + id: 'hs_analytics_source_data_1', + label: 'Original Source Data 1', }, { - 'id': 'hs_analytics_source_data_2', - 'label': 'Original Source Data 2', + id: 'hs_analytics_source_data_2', + label: 'Original Source Data 2', }, { - 'id': 'hs_arr', - 'label': 'Annual recurring revenue', + id: 'hs_arr', + label: 'Annual recurring revenue', }, { - 'id': 'hs_campaign', - 'label': 'HubSpot Campaign', + id: 'hs_campaign', + label: 'HubSpot Campaign', }, { - 'id': 'hs_closed_amount', - 'label': 'Closed Deal Amount', + id: 'hs_closed_amount', + label: 'Closed Deal Amount', }, { - 'id': 'hs_closed_amount_in_home_currency', - 'label': 'Closed Deal Amount In Home Currency', + id: 'hs_closed_amount_in_home_currency', + label: 'Closed Deal Amount In Home Currency', }, { - 'id': 'hs_created_by_user_id', - 'label': 'Created by user ID', + id: 'hs_created_by_user_id', + label: 'Created by user ID', }, { - 'id': 'hs_date_entered_appointmentscheduled', - 'label': 'Date entered \'Appointment Scheduled (Sales Pipeline)\'', + id: 'hs_date_entered_appointmentscheduled', + label: "Date entered 'Appointment Scheduled (Sales Pipeline)'", }, { - 'id': 'hs_date_entered_closedlost', - 'label': 'Date entered \'Closed Lost (Sales Pipeline)\'', + id: 'hs_date_entered_closedlost', + label: "Date entered 'Closed Lost (Sales Pipeline)'", }, { - 'id': 'hs_date_entered_closedwon', - 'label': 'Date entered \'Closed Won (Sales Pipeline)\'', + id: 'hs_date_entered_closedwon', + label: "Date entered 'Closed Won (Sales Pipeline)'", }, { - 'id': 'hs_date_entered_contractsent', - 'label': 'Date entered \'Contract Sent (Sales Pipeline)\'', + id: 'hs_date_entered_contractsent', + label: "Date entered 'Contract Sent (Sales Pipeline)'", }, { - 'id': 'hs_date_entered_decisionmakerboughtin', - 'label': 'Date entered \'Decision Maker Bought-In (Sales Pipeline)\'', + id: 'hs_date_entered_decisionmakerboughtin', + label: "Date entered 'Decision Maker Bought-In (Sales Pipeline)'", }, { - 'id': 'hs_date_entered_presentationscheduled', - 'label': 'Date entered \'Presentation Scheduled (Sales Pipeline)\'', + id: 'hs_date_entered_presentationscheduled', + label: "Date entered 'Presentation Scheduled (Sales Pipeline)'", }, { - 'id': 'hs_date_entered_qualifiedtobuy', - 'label': 'Date entered \'Qualified To Buy (Sales Pipeline)\'', + id: 'hs_date_entered_qualifiedtobuy', + label: "Date entered 'Qualified To Buy (Sales Pipeline)'", }, { - 'id': 'hs_date_exited_appointmentscheduled', - 'label': 'Date exited \'Appointment Scheduled (Sales Pipeline)\'', + id: 'hs_date_exited_appointmentscheduled', + label: "Date exited 'Appointment Scheduled (Sales Pipeline)'", }, { - 'id': 'hs_date_exited_closedlost', - 'label': 'Date exited \'Closed Lost (Sales Pipeline)\'', + id: 'hs_date_exited_closedlost', + label: "Date exited 'Closed Lost (Sales Pipeline)'", }, { - 'id': 'hs_date_exited_closedwon', - 'label': 'Date exited \'Closed Won (Sales Pipeline)\'', + id: 'hs_date_exited_closedwon', + label: "Date exited 'Closed Won (Sales Pipeline)'", }, { - 'id': 'hs_date_exited_contractsent', - 'label': 'Date exited \'Contract Sent (Sales Pipeline)\'', + id: 'hs_date_exited_contractsent', + label: "Date exited 'Contract Sent (Sales Pipeline)'", }, { - 'id': 'hs_date_exited_decisionmakerboughtin', - 'label': 'Date exited \'Decision Maker Bought-In (Sales Pipeline)\'', + id: 'hs_date_exited_decisionmakerboughtin', + label: "Date exited 'Decision Maker Bought-In (Sales Pipeline)'", }, { - 'id': 'hs_date_exited_presentationscheduled', - 'label': 'Date exited \'Presentation Scheduled (Sales Pipeline)\'', + id: 'hs_date_exited_presentationscheduled', + label: "Date exited 'Presentation Scheduled (Sales Pipeline)'", }, { - 'id': 'hs_date_exited_qualifiedtobuy', - 'label': 'Date exited \'Qualified To Buy (Sales Pipeline)\'', + id: 'hs_date_exited_qualifiedtobuy', + label: "Date exited 'Qualified To Buy (Sales Pipeline)'", }, { - 'id': 'hs_deal_amount_calculation_preference', - 'label': 'Deal amount calculation preference', + id: 'hs_deal_amount_calculation_preference', + label: 'Deal amount calculation preference', }, { - 'id': 'hs_deal_stage_probability', - 'label': 'Deal Stage Probability', + id: 'hs_deal_stage_probability', + label: 'Deal Stage Probability', }, { - 'id': 'hs_forecast_amount', - 'label': 'Forecast Amount', + id: 'hs_forecast_amount', + label: 'Forecast Amount', }, { - 'id': 'hs_forecast_probability', - 'label': 'Forecast Probability', + id: 'hs_forecast_probability', + label: 'Forecast Probability', }, { - 'id': 'hs_is_closed', - 'label': 'Is Deal Closed?', + id: 'hs_is_closed', + label: 'Is Deal Closed?', }, { - 'id': 'hs_lastmodifieddate', - 'label': 'Last Modified Date', + id: 'hs_lastmodifieddate', + label: 'Last Modified Date', }, { - 'id': 'hs_likelihood_to_close', - 'label': 'Likelihood to close by the close date', + id: 'hs_likelihood_to_close', + label: 'Likelihood to close by the close date', }, { - 'id': 'hs_line_item_global_term_hs_discount_percentage', - 'label': 'Global Term Line Item Discount Percentage', + id: 'hs_line_item_global_term_hs_discount_percentage', + label: 'Global Term Line Item Discount Percentage', }, { - 'id': 'hs_line_item_global_term_hs_discount_percentage_enabled', - 'label': 'Global Term Line Item Discount Percentage Enabled', + id: 'hs_line_item_global_term_hs_discount_percentage_enabled', + label: 'Global Term Line Item Discount Percentage Enabled', }, { - 'id': 'hs_line_item_global_term_hs_recurring_billing_period', - 'label': 'Global Term Line Item Recurring Billing Period', + id: 'hs_line_item_global_term_hs_recurring_billing_period', + label: 'Global Term Line Item Recurring Billing Period', }, { - 'id': 'hs_line_item_global_term_hs_recurring_billing_period_enabled', - 'label': 'Global Term Line Item Recurring Billing Period Enabled', + id: 'hs_line_item_global_term_hs_recurring_billing_period_enabled', + label: 'Global Term Line Item Recurring Billing Period Enabled', }, { - 'id': 'hs_line_item_global_term_hs_recurring_billing_start_date', - 'label': 'Global Term Line Item Recurring Billing Start Date', + id: 'hs_line_item_global_term_hs_recurring_billing_start_date', + label: 'Global Term Line Item Recurring Billing Start Date', }, { - 'id': 'hs_line_item_global_term_hs_recurring_billing_start_date_enabled', - 'label': 'Global Term Line Item Recurring Billing Start Date Enabled', + id: 'hs_line_item_global_term_hs_recurring_billing_start_date_enabled', + label: 'Global Term Line Item Recurring Billing Start Date Enabled', }, { - 'id': 'hs_line_item_global_term_recurringbillingfrequency', - 'label': 'Global Term Line Item Recurring Billing Frequency', + id: 'hs_line_item_global_term_recurringbillingfrequency', + label: 'Global Term Line Item Recurring Billing Frequency', }, { - 'id': 'hs_line_item_global_term_recurringbillingfrequency_enabled', - 'label': 'Global Term Line Item Recurring Billing Frequency Enabled', + id: 'hs_line_item_global_term_recurringbillingfrequency_enabled', + label: 'Global Term Line Item Recurring Billing Frequency Enabled', }, { - 'id': 'hs_manual_forecast_category', - 'label': 'Forecast category', + id: 'hs_manual_forecast_category', + label: 'Forecast category', }, { - 'id': 'hs_merged_object_ids', - 'label': 'Merged object IDs', + id: 'hs_merged_object_ids', + label: 'Merged object IDs', }, { - 'id': 'hs_mrr', - 'label': 'Monthly recurring revenue', + id: 'hs_mrr', + label: 'Monthly recurring revenue', }, { - 'id': 'hs_next_step', - 'label': 'Next step', + id: 'hs_next_step', + label: 'Next step', }, { - 'id': 'hs_object_id', - 'label': 'Deal ID', + id: 'hs_object_id', + label: 'Deal ID', }, { - 'id': 'hs_predicted_amount', - 'label': 'The predicted deal amount', + id: 'hs_predicted_amount', + label: 'The predicted deal amount', }, { - 'id': 'hs_predicted_amount_in_home_currency', - 'label': 'The predicted deal amount in your company\'s currency', + id: 'hs_predicted_amount_in_home_currency', + label: "The predicted deal amount in your company's currency", }, { - 'id': 'hs_projected_amount', - 'label': 'Projected Deal Amount', + id: 'hs_projected_amount', + label: 'Projected Deal Amount', }, { - 'id': 'hs_projected_amount_in_home_currency', - 'label': 'Projected Deal Amount in Home Currency', + id: 'hs_projected_amount_in_home_currency', + label: 'Projected Deal Amount in Home Currency', }, { - 'id': 'hs_tcv', - 'label': 'Total contract value', + id: 'hs_tcv', + label: 'Total contract value', }, { - 'id': 'hs_time_in_appointmentscheduled', - 'label': 'Time in \'Appointment Scheduled (Sales Pipeline)\'', + id: 'hs_time_in_appointmentscheduled', + label: "Time in 'Appointment Scheduled (Sales Pipeline)'", }, { - 'id': 'hs_time_in_closedlost', - 'label': 'Time in \'Closed Lost (Sales Pipeline)\'', + id: 'hs_time_in_closedlost', + label: "Time in 'Closed Lost (Sales Pipeline)'", }, { - 'id': 'hs_time_in_closedwon', - 'label': 'Time in \'Closed Won (Sales Pipeline)\'', + id: 'hs_time_in_closedwon', + label: "Time in 'Closed Won (Sales Pipeline)'", }, { - 'id': 'hs_time_in_contractsent', - 'label': 'Time in \'Contract Sent (Sales Pipeline)\'', + id: 'hs_time_in_contractsent', + label: "Time in 'Contract Sent (Sales Pipeline)'", }, { - 'id': 'hs_time_in_decisionmakerboughtin', - 'label': 'Time in \'Decision Maker Bought-In (Sales Pipeline)\'', + id: 'hs_time_in_decisionmakerboughtin', + label: "Time in 'Decision Maker Bought-In (Sales Pipeline)'", }, { - 'id': 'hs_time_in_presentationscheduled', - 'label': 'Time in \'Presentation Scheduled (Sales Pipeline)\'', + id: 'hs_time_in_presentationscheduled', + label: "Time in 'Presentation Scheduled (Sales Pipeline)'", }, { - 'id': 'hs_time_in_qualifiedtobuy', - 'label': 'Time in \'Qualified To Buy (Sales Pipeline)\'', + id: 'hs_time_in_qualifiedtobuy', + label: "Time in 'Qualified To Buy (Sales Pipeline)'", }, { - 'id': 'hs_updated_by_user_id', - 'label': 'Updated by user ID', + id: 'hs_updated_by_user_id', + label: 'Updated by user ID', }, { - 'id': 'hs_user_ids_of_all_owners', - 'label': 'User IDs of all owners', + id: 'hs_user_ids_of_all_owners', + label: 'User IDs of all owners', }, { - 'id': 'hubspot_owner_assigneddate', - 'label': 'Owner Assigned Date', + id: 'hubspot_owner_assigneddate', + label: 'Owner Assigned Date', }, { - 'id': 'testing', - 'label': 'testing', + id: 'testing', + label: 'testing', }, { - 'id': 'dealname', - 'label': 'Deal Name', + id: 'dealname', + label: 'Deal Name', }, { - 'id': 'amount', - 'label': 'Amount', + id: 'amount', + label: 'Amount', }, { - 'id': 'dealstage', - 'label': 'Deal Stage', + id: 'dealstage', + label: 'Deal Stage', }, { - 'id': 'pipeline', - 'label': 'Pipeline', + id: 'pipeline', + label: 'Pipeline', }, { - 'id': 'closedate', - 'label': 'Close Date', + id: 'closedate', + label: 'Close Date', }, { - 'id': 'createdate', - 'label': 'Create Date', + id: 'createdate', + label: 'Create Date', }, { - 'id': 'engagements_last_meeting_booked', - 'label': 'Date of last meeting booked in meetings tool', + id: 'engagements_last_meeting_booked', + label: 'Date of last meeting booked in meetings tool', }, { - 'id': 'engagements_last_meeting_booked_campaign', - 'label': 'Campaign of last booking in meetings tool', + id: 'engagements_last_meeting_booked_campaign', + label: 'Campaign of last booking in meetings tool', }, { - 'id': 'engagements_last_meeting_booked_medium', - 'label': 'Medium of last booking in meetings tool', + id: 'engagements_last_meeting_booked_medium', + label: 'Medium of last booking in meetings tool', }, { - 'id': 'engagements_last_meeting_booked_source', - 'label': 'Source of last booking in meetings tool', + id: 'engagements_last_meeting_booked_source', + label: 'Source of last booking in meetings tool', }, { - 'id': 'hs_latest_meeting_activity', - 'label': 'Latest meeting activity', + id: 'hs_latest_meeting_activity', + label: 'Latest meeting activity', }, { - 'id': 'hs_sales_email_last_replied', - 'label': 'Recent Sales Email Replied Date', + id: 'hs_sales_email_last_replied', + label: 'Recent Sales Email Replied Date', }, { - 'id': 'hubspot_owner_id', - 'label': 'Deal owner', + id: 'hubspot_owner_id', + label: 'Deal owner', }, { - 'id': 'notes_last_contacted', - 'label': 'Last Contacted', + id: 'notes_last_contacted', + label: 'Last Contacted', }, { - 'id': 'notes_last_updated', - 'label': 'Last Activity Date', + id: 'notes_last_updated', + label: 'Last Activity Date', }, { - 'id': 'notes_next_activity_date', - 'label': 'Next Activity Date', + id: 'notes_next_activity_date', + label: 'Next Activity Date', }, { - 'id': 'num_contacted_notes', - 'label': 'Number of times contacted', + id: 'num_contacted_notes', + label: 'Number of times contacted', }, { - 'id': 'num_notes', - 'label': 'Number of Sales Activities', + id: 'num_notes', + label: 'Number of Sales Activities', }, { - 'id': 'hs_createdate', - 'label': 'HubSpot Create Date', + id: 'hs_createdate', + label: 'HubSpot Create Date', }, { - 'id': 'hubspot_team_id', - 'label': 'HubSpot Team', + id: 'hubspot_team_id', + label: 'HubSpot Team', }, { - 'id': 'dealtype', - 'label': 'Deal Type', + id: 'dealtype', + label: 'Deal Type', }, { - 'id': 'hs_all_owner_ids', - 'label': 'All owner ids', + id: 'hs_all_owner_ids', + label: 'All owner ids', }, { - 'id': 'description', - 'label': 'Deal Description', + id: 'description', + label: 'Deal Description', }, { - 'id': 'hs_all_team_ids', - 'label': 'All team ids', + id: 'hs_all_team_ids', + label: 'All team ids', }, { - 'id': 'hs_all_accessible_team_ids', - 'label': 'All accessible team ids', + id: 'hs_all_accessible_team_ids', + label: 'All accessible team ids', }, { - 'id': 'num_associated_contacts', - 'label': 'Number of Contacts', + id: 'num_associated_contacts', + label: 'Number of Contacts', }, { - 'id': 'closed_lost_reason', - 'label': 'Closed Lost Reason', + id: 'closed_lost_reason', + label: 'Closed Lost Reason', }, { - 'id': 'closed_won_reason', - 'label': 'Closed Won Reason', + id: 'closed_won_reason', + label: 'Closed Won Reason', }, ]; const reduceMetadatFields = (data: string[]) => { - return data.reduce((a, v) => { - //@ts-ignore - a.push(...v.split(',')); - return a; - }, []).map(email => ({ email })); + return data + .reduce((a, v) => { + //@ts-ignore + a.push(...v.split(',')); + return a; + }, []) + .map((email) => ({ email })); }; export const getEmailMetadata = (meta: IDataObject) => { @@ -1922,8 +1940,8 @@ export const getEmailMetadata = (meta: IDataObject) => { ...(meta.firstName && { firstName: meta.firstName }), ...(meta.lastName && { lastName: meta.lastName }), }, - cc: reduceMetadatFields(meta.cc as string[] || []), - bcc: reduceMetadatFields(meta.bcc as string[] || []), + cc: reduceMetadatFields((meta.cc as string[]) || []), + bcc: reduceMetadatFields((meta.bcc as string[]) || []), ...(meta.subject && { subject: meta.subject }), ...(meta.html && { html: meta.html }), ...(meta.text && { text: meta.text }), @@ -1960,12 +1978,11 @@ export const getCallMetadata = (meta: IDataObject) => { }; }; - export const getAssociations = (associations: { - companyIds: string, - dealIds: string, - ownerIds: string, - contactIds: string, + companyIds: string; + dealIds: string; + ownerIds: string; + contactIds: string; ticketIds: string; }) => { return { @@ -1980,15 +1997,13 @@ export const getAssociations = (associations: { export async function validateCredentials( this: ICredentialTestFunctions, decryptedCredentials: ICredentialDataDecryptedObject, -): Promise { // tslint:disable-line:no-any + // tslint:disable-next-line:no-any +): Promise { const credentials = decryptedCredentials; - const { - apiKey, - appToken, - } = credentials as { - appToken: string, - apiKey: string, + const { apiKey, appToken } = credentials as { + appToken: string; + apiKey: string; }; const options: OptionsWithUri = { diff --git a/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts b/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts index 5f3d278ce4..e77aff9e1f 100644 --- a/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts +++ b/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -28,57 +26,27 @@ import { hubspotApiRequestAllItems, } from './GenericFunctions'; -import { - contactFields, - contactOperations, -} from './ContactDescription'; +import { contactFields, contactOperations } from './ContactDescription'; -import { - contactListFields, - contactListOperations, -} from './ContactListDescription'; +import { contactListFields, contactListOperations } from './ContactListDescription'; -import { - companyFields, - companyOperations, -} from './CompanyDescription'; +import { companyFields, companyOperations } from './CompanyDescription'; -import { - dealFields, - dealOperations, -} from './DealDescription'; +import { dealFields, dealOperations } from './DealDescription'; -import { - engagementFields, - engagementOperations, -} from './EngagementDescription'; +import { engagementFields, engagementOperations } from './EngagementDescription'; -import { - formFields, - formOperations, -} from './FormDescription'; +import { formFields, formOperations } from './FormDescription'; -import { - ticketFields, - ticketOperations, -} from './TicketDescription'; +import { ticketFields, ticketOperations } from './TicketDescription'; -import { - IForm, -} from './FormInterface'; +import { IForm } from './FormInterface'; -import { - IAssociation, - IDeal, -} from './DealInterface'; +import { IAssociation, IDeal } from './DealInterface'; -import { - snakeCase, -} from 'change-case'; +import { snakeCase } from 'change-case'; -import { - validateCredentials -} from './GenericFunctions'; +import { validateCredentials } from './GenericFunctions'; export class Hubspot implements INodeType { description: INodeTypeDescription = { displayName: 'HubSpot', @@ -100,9 +68,7 @@ export class Hubspot implements INodeType { testedBy: 'hubspotApiTest', displayOptions: { show: { - authentication: [ - 'apiKey', - ], + authentication: ['apiKey'], }, }, }, @@ -112,9 +78,7 @@ export class Hubspot implements INodeType { testedBy: 'hubspotApiTest', displayOptions: { show: { - authentication: [ - 'appToken', - ], + authentication: ['appToken'], }, }, }, @@ -123,9 +87,7 @@ export class Hubspot implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -214,7 +176,10 @@ export class Hubspot implements INodeType { methods = { credentialTest: { - async hubspotApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { + async hubspotApiTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { try { await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject); } catch (error) { @@ -282,7 +247,9 @@ export class Hubspot implements INodeType { // Get all the contact lifecycle stages to display them to user so that he can // select them easily - async getContactLifeCycleStages(this: ILoadOptionsFunctions): Promise { + async getContactLifeCycleStages( + this: ILoadOptionsFunctions, + ): Promise { const returnData: INodePropertyOptions[] = []; const endpoint = '/properties/v2/contacts/properties'; const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {}); @@ -303,7 +270,9 @@ export class Hubspot implements INodeType { // Get all the contact lifecycle stages to display them to user so that he can // select them easily - async getContactOriginalSources(this: ILoadOptionsFunctions): Promise { + async getContactOriginalSources( + this: ILoadOptionsFunctions, + ): Promise { const returnData: INodePropertyOptions[] = []; const endpoint = '/properties/v2/contacts/properties'; const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {}); @@ -324,7 +293,9 @@ export class Hubspot implements INodeType { // Get all the contact preffered languages to display them to user so that he can // select them easily - async getContactPrefferedLanguages(this: ILoadOptionsFunctions): Promise { + async getContactPrefferedLanguages( + this: ILoadOptionsFunctions, + ): Promise { const returnData: INodePropertyOptions[] = []; const endpoint = '/properties/v2/contacts/properties'; const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {}); @@ -383,7 +354,9 @@ export class Hubspot implements INodeType { // Get all the contact properties to display them to user so that he can // select them easily - async getContactCustomProperties(this: ILoadOptionsFunctions): Promise { + async getContactCustomProperties( + this: ILoadOptionsFunctions, + ): Promise { const returnData: INodePropertyOptions[] = []; const endpoint = '/properties/v2/contacts/properties'; const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {}); @@ -402,7 +375,9 @@ export class Hubspot implements INodeType { // Get all the contact number of employees options to display them to user so that he can // select them easily - async getContactNumberOfEmployees(this: ILoadOptionsFunctions): Promise { + async getContactNumberOfEmployees( + this: ILoadOptionsFunctions, + ): Promise { const returnData: INodePropertyOptions[] = []; const endpoint = '/properties/v2/contacts/properties'; const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {}); @@ -469,7 +444,9 @@ export class Hubspot implements INodeType { // Get all the company lifecycle stages to display them to user so that he can // select them easily - async getCompanylifecycleStages(this: ILoadOptionsFunctions): Promise { + async getCompanylifecycleStages( + this: ILoadOptionsFunctions, + ): Promise { const returnData: INodePropertyOptions[] = []; const endpoint = '/properties/v2/companies/properties'; const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {}); @@ -553,7 +530,9 @@ export class Hubspot implements INodeType { // Get all the company web technologies stages to display them to user so that he can // select them easily - async getCompanyWebTechnologies(this: ILoadOptionsFunctions): Promise { + async getCompanyWebTechnologies( + this: ILoadOptionsFunctions, + ): Promise { const returnData: INodePropertyOptions[] = []; const endpoint = '/properties/v2/companies/properties'; const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {}); @@ -591,7 +570,9 @@ export class Hubspot implements INodeType { // Get all the company custom properties to display them to user so that he can // select them easily - async getCompanyCustomProperties(this: ILoadOptionsFunctions): Promise { + async getCompanyCustomProperties( + this: ILoadOptionsFunctions, + ): Promise { const returnData: INodePropertyOptions[] = []; const endpoint = '/properties/v2/companies/properties'; const properties = await hubspotApiRequest.call(this, 'GET', endpoint, {}); @@ -708,7 +689,13 @@ export class Hubspot implements INodeType { async getSubscriptionTypes(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const endpoint = '/email/public/v1/subscriptions'; - const subscriptions = await hubspotApiRequestAllItems.call(this, 'subscriptionDefinitions', 'GET', endpoint, {}); + const subscriptions = await hubspotApiRequestAllItems.call( + this, + 'subscriptionDefinitions', + 'GET', + endpoint, + {}, + ); for (const subscription of subscriptions) { const subscriptionName = subscription.name; const subscriptionId = subscription.id; @@ -742,7 +729,7 @@ export class Hubspot implements INodeType { } } } - return returnData.sort((a, b) => a.name < b.name ? 0 : 1); + return returnData.sort((a, b) => (a.name < b.name ? 0 : 1)); }, // Get all the ticket pipelines to display them to user so that he can @@ -818,7 +805,7 @@ export class Hubspot implements INodeType { } } } - return returnData.sort((a, b) => a.name < b.name ? 0 : 1); + return returnData.sort((a, b) => (a.name < b.name ? 0 : 1)); }, // Get all the ticket sources to display them to user so that he can @@ -839,7 +826,7 @@ export class Hubspot implements INodeType { } } } - return returnData.sort((a, b) => a.name < b.name ? 0 : 1); + return returnData.sort((a, b) => (a.name < b.name ? 0 : 1)); }, // Get all the ticket stages to display them to user so that he can @@ -896,16 +883,25 @@ export class Hubspot implements INodeType { properties: ['name'], }; const endpoint = '/companies/v2/companies/paged'; - const companies = await hubspotApiRequestAllItems.call(this, 'companies', 'GET', endpoint, {}, qs); + const companies = await hubspotApiRequestAllItems.call( + this, + 'companies', + 'GET', + endpoint, + {}, + qs, + ); for (const company of companies) { - const companyName = (company.properties.name) ? company.properties.name.value : company.companyId; + const companyName = company.properties.name + ? company.properties.name.value + : company.companyId; const companyId = company.companyId; returnData.push({ name: companyName, value: companyId, }); } - return returnData.sort((a, b) => a.name < b.name ? 0 : 1); + return returnData.sort((a, b) => (a.name < b.name ? 0 : 1)); }, // Get all the companies to display them to user so that he can @@ -926,9 +922,8 @@ export class Hubspot implements INodeType { description: `Contact VID: ${contactId}`, }); } - return returnData.sort((a, b) => a.name < b.name ? 0 : 1); + return returnData.sort((a, b) => (a.name < b.name ? 0 : 1)); }, - }, }; @@ -958,7 +953,12 @@ export class Hubspot implements INodeType { body.emails.push(email as never); } } - responseData = await hubspotApiRequest.call(this, 'POST', `/contacts/v1/lists/${listId}/add`, body); + responseData = await hubspotApiRequest.call( + this, + 'POST', + `/contacts/v1/lists/${listId}/add`, + body, + ); returnData.push(responseData); } //https://legacydocs.hubspot.com/docs/methods/lists/remove_contact_from_list @@ -969,7 +969,12 @@ export class Hubspot implements INodeType { const id = this.getNodeParameter('id', i) as string; body.vids.push(parseInt(id, 10) as never); } - responseData = await hubspotApiRequest.call(this, 'POST', `/contacts/v1/lists/${listId}/remove`, body); + responseData = await hubspotApiRequest.call( + this, + 'POST', + `/contacts/v1/lists/${listId}/remove`, + body, + ); returnData.push(responseData); } } catch (error) { @@ -1262,7 +1267,8 @@ export class Hubspot implements INodeType { } if (additionalFields.customPropertiesUi) { - const customProperties = (additionalFields.customPropertiesUi as IDataObject).customPropertiesValues as IDataObject[]; + const customProperties = (additionalFields.customPropertiesUi as IDataObject) + .customPropertiesValues as IDataObject[]; if (customProperties) { for (const customProperty of customProperties) { @@ -1275,7 +1281,9 @@ export class Hubspot implements INodeType { } const endpoint = `/contacts/v1/contact/createOrUpdate/email/${email}`; - responseData = await hubspotApiRequest.call(this, 'POST', endpoint, { properties: body }); + responseData = await hubspotApiRequest.call(this, 'POST', endpoint, { + properties: body, + }); if (additionalFields.associatedCompanyId) { const companyAssociations: IDataObject[] = []; @@ -1285,7 +1293,12 @@ export class Hubspot implements INodeType { category: 'HUBSPOT_DEFINED', definitionId: 1, }); - await hubspotApiRequest.call(this, 'PUT', '/crm-associations/v1/associations/create-batch', companyAssociations); + await hubspotApiRequest.call( + this, + 'PUT', + '/crm-associations/v1/associations/create-batch', + companyAssociations, + ); } if (resolveData) { @@ -1294,7 +1307,13 @@ export class Hubspot implements INodeType { if (additionalFields.properties) { qs.property = additionalFields.properties as string[]; } - responseData = await hubspotApiRequest.call(this, 'GET', `/contacts/v1/contact/vid/${responseData.vid}/profile`, {}, qs); + responseData = await hubspotApiRequest.call( + this, + 'GET', + `/contacts/v1/contact/vid/${responseData.vid}/profile`, + {}, + qs, + ); responseData.isNew = isNew; } } @@ -1335,7 +1354,14 @@ export class Hubspot implements INodeType { } const endpoint = '/contacts/v1/lists/all/contacts/all'; if (returnAll) { - responseData = await hubspotApiRequestAllItems.call(this, 'contacts', 'GET', endpoint, {}, qs); + responseData = await hubspotApiRequestAllItems.call( + this, + 'contacts', + 'GET', + endpoint, + {}, + qs, + ); } else { qs.count = this.getNodeParameter('limit', 0) as number; responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs); @@ -1363,7 +1389,14 @@ export class Hubspot implements INodeType { endpoint = '/contacts/v1/lists/recently_updated/contacts/recent'; if (returnAll) { - responseData = await hubspotApiRequestAllItems.call(this, 'contacts', 'GET', endpoint, {}, qs); + responseData = await hubspotApiRequestAllItems.call( + this, + 'contacts', + 'GET', + endpoint, + {}, + qs, + ); } else { qs.count = this.getNodeParameter('limit', 0) as number; responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs); @@ -1394,12 +1427,14 @@ export class Hubspot implements INodeType { }; if (filtersGroupsUi) { - const filterGroupValues = (filtersGroupsUi as IDataObject).filterGroupsValues as IDataObject[]; + const filterGroupValues = (filtersGroupsUi as IDataObject) + .filterGroupsValues as IDataObject[]; if (filterGroupValues) { body.filterGroups = []; for (const filterGroupValue of filterGroupValues) { if (filterGroupValue.filtersUi) { - const filterValues = (filterGroupValue.filtersUi as IDataObject).filterValues as IDataObject[]; + const filterValues = (filterGroupValue.filtersUi as IDataObject) + .filterValues as IDataObject[]; if (filterValues) { //@ts-ignore body.filterGroups.push({ filters: filterValues }); @@ -1414,7 +1449,14 @@ export class Hubspot implements INodeType { const endpoint = '/crm/v3/objects/contacts/search'; if (returnAll) { - responseData = await hubspotApiRequestAllItems.call(this, 'results', 'POST', endpoint, body, qs); + responseData = await hubspotApiRequestAllItems.call( + this, + 'results', + 'POST', + endpoint, + body, + qs, + ); } else { body.limit = this.getNodeParameter('limit', 0) as number; responseData = await hubspotApiRequest.call(this, 'POST', endpoint, body, qs); @@ -1632,7 +1674,8 @@ export class Hubspot implements INodeType { }); } if (additionalFields.customPropertiesUi) { - const customProperties = (additionalFields.customPropertiesUi as IDataObject).customPropertiesValues as IDataObject[]; + const customProperties = (additionalFields.customPropertiesUi as IDataObject) + .customPropertiesValues as IDataObject[]; if (customProperties) { for (const customProperty of customProperties) { @@ -1644,7 +1687,9 @@ export class Hubspot implements INodeType { } } const endpoint = '/companies/v2/companies'; - responseData = await hubspotApiRequest.call(this, 'POST', endpoint, { properties: body }); + responseData = await hubspotApiRequest.call(this, 'POST', endpoint, { + properties: body, + }); } //https://developers.hubspot.com/docs/methods/companies/update_company if (operation === 'update') { @@ -1856,7 +1901,8 @@ export class Hubspot implements INodeType { }); } if (updateFields.customPropertiesUi) { - const customProperties = (updateFields.customPropertiesUi as IDataObject).customPropertiesValues as IDataObject[]; + const customProperties = (updateFields.customPropertiesUi as IDataObject) + .customPropertiesValues as IDataObject[]; if (customProperties) { for (const customProperty of customProperties) { @@ -1868,7 +1914,9 @@ export class Hubspot implements INodeType { } } const endpoint = `/companies/v2/companies/${companyId}`; - responseData = await hubspotApiRequest.call(this, 'PUT', endpoint, { properties: body }); + responseData = await hubspotApiRequest.call(this, 'PUT', endpoint, { + properties: body, + }); } //https://developers.hubspot.com/docs/methods/companies/get_company if (operation === 'get') { @@ -1895,7 +1943,14 @@ export class Hubspot implements INodeType { } const endpoint = `/companies/v2/companies/paged`; if (returnAll) { - responseData = await hubspotApiRequestAllItems.call(this, 'companies', 'GET', endpoint, {}, qs); + responseData = await hubspotApiRequestAllItems.call( + this, + 'companies', + 'GET', + endpoint, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs); @@ -1916,7 +1971,14 @@ export class Hubspot implements INodeType { endpoint = `/companies/v2/companies/recent/modified`; } if (returnAll) { - responseData = await hubspotApiRequestAllItems.call(this, 'results', 'GET', endpoint, {}, qs); + responseData = await hubspotApiRequestAllItems.call( + this, + 'results', + 'GET', + endpoint, + {}, + qs, + ); } else { qs.count = this.getNodeParameter('limit', 0) as number; responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs); @@ -1936,7 +1998,13 @@ export class Hubspot implements INodeType { } const endpoint = `/companies/v2/domains/${domain}/companies`; if (returnAll) { - responseData = await hubspotApiRequestAllItems.call(this, 'results', 'POST', endpoint, body); + responseData = await hubspotApiRequestAllItems.call( + this, + 'results', + 'POST', + endpoint, + body, + ); } else { body.limit = this.getNodeParameter('limit', 0) as number; responseData = await hubspotApiRequest.call(this, 'POST', endpoint, body); @@ -2007,7 +2075,8 @@ export class Hubspot implements INodeType { }); } if (additionalFields.customPropertiesUi) { - const customProperties = (additionalFields.customPropertiesUi as IDataObject).customPropertiesValues as IDataObject[]; + const customProperties = (additionalFields.customPropertiesUi as IDataObject) + .customPropertiesValues as IDataObject[]; if (customProperties) { for (const customProperty of customProperties) { body.properties.push({ @@ -2069,7 +2138,8 @@ export class Hubspot implements INodeType { }); } if (updateFields.customPropertiesUi) { - const customProperties = (updateFields.customPropertiesUi as IDataObject).customPropertiesValues as IDataObject[]; + const customProperties = (updateFields.customPropertiesUi as IDataObject) + .customPropertiesValues as IDataObject[]; if (customProperties) { for (const customProperty of customProperties) { body.properties.push({ @@ -2099,15 +2169,26 @@ export class Hubspot implements INodeType { } if (filters.properties) { const properties = filters.properties as string | string[]; - qs.properties = (!Array.isArray(filters.properties)) ? (properties as string).split(',') : properties; + qs.properties = !Array.isArray(filters.properties) + ? (properties as string).split(',') + : properties; } if (filters.propertiesWithHistory) { const propertiesWithHistory = filters.propertiesWithHistory as string | string[]; - qs.propertiesWithHistory = (!Array.isArray(filters.propertiesWithHistory)) ? (propertiesWithHistory as string).split(',') : propertiesWithHistory; + qs.propertiesWithHistory = !Array.isArray(filters.propertiesWithHistory) + ? (propertiesWithHistory as string).split(',') + : propertiesWithHistory; } const endpoint = `/deals/v1/deal/paged`; if (returnAll) { - responseData = await hubspotApiRequestAllItems.call(this, 'deals', 'GET', endpoint, {}, qs); + responseData = await hubspotApiRequestAllItems.call( + this, + 'deals', + 'GET', + endpoint, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs); @@ -2130,7 +2211,14 @@ export class Hubspot implements INodeType { endpoint = `/deals/v1/deal/recent/modified`; } if (returnAll) { - responseData = await hubspotApiRequestAllItems.call(this, 'results', 'GET', endpoint, {}, qs); + responseData = await hubspotApiRequestAllItems.call( + this, + 'results', + 'GET', + endpoint, + {}, + qs, + ); } else { qs.count = this.getNodeParameter('limit', 0) as number; responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs); @@ -2160,12 +2248,14 @@ export class Hubspot implements INodeType { }; if (filtersGroupsUi) { - const filterGroupValues = (filtersGroupsUi as IDataObject).filterGroupsValues as IDataObject[]; + const filterGroupValues = (filtersGroupsUi as IDataObject) + .filterGroupsValues as IDataObject[]; if (filterGroupValues) { body.filterGroups = []; for (const filterGroupValue of filterGroupValues) { if (filterGroupValue.filtersUi) { - const filterValues = (filterGroupValue.filtersUi as IDataObject).filterValues as IDataObject[]; + const filterValues = (filterGroupValue.filtersUi as IDataObject) + .filterValues as IDataObject[]; if (filterValues) { //@ts-ignore body.filterGroups.push({ filters: filterValues }); @@ -2180,9 +2270,14 @@ export class Hubspot implements INodeType { const endpoint = '/crm/v3/objects/deals/search'; if (returnAll) { - - responseData = await hubspotApiRequestAllItems.call(this, 'results', 'POST', endpoint, body, qs); - + responseData = await hubspotApiRequestAllItems.call( + this, + 'results', + 'POST', + endpoint, + body, + qs, + ); } else { body.limit = this.getNodeParameter('limit', 0) as number; responseData = await hubspotApiRequest.call(this, 'POST', endpoint, body, qs); @@ -2195,19 +2290,24 @@ export class Hubspot implements INodeType { if (operation === 'create') { const type = this.getNodeParameter('type', i) as string; const metadata = this.getNodeParameter('metadata', i) as IDataObject; - const associations = this.getNodeParameter('additionalFields.associations', i, {}) as IDataObject; + const associations = this.getNodeParameter( + 'additionalFields.associations', + i, + {}, + ) as IDataObject; if (!Object.keys(metadata).length) { throw new NodeOperationError( this.getNode(), - `At least one metadata field needs to set`, { itemIndex: i }, + `At least one metadata field needs to set`, + { itemIndex: i }, ); } const body: { - engagement: { type: string }, - metadata: IDataObject, - associations: IDataObject + engagement: { type: string }; + metadata: IDataObject; + associations: IDataObject; } = { engagement: { type: type.toUpperCase(), @@ -2256,7 +2356,14 @@ export class Hubspot implements INodeType { const returnAll = this.getNodeParameter('returnAll', 0) as boolean; const endpoint = `/engagements/v1/engagements/paged`; if (returnAll) { - responseData = await hubspotApiRequestAllItems.call(this, 'results', 'GET', endpoint, {}, qs); + responseData = await hubspotApiRequestAllItems.call( + this, + 'results', + 'GET', + endpoint, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; responseData = await hubspotApiRequest.call(this, 'GET', endpoint, {}, qs); @@ -2269,16 +2376,27 @@ export class Hubspot implements INodeType { //https://developers.hubspot.com/docs/methods/forms/v2/get_fields if (operation === 'getFields') { const formId = this.getNodeParameter('formId', i) as string; - responseData = await hubspotApiRequest.call(this, 'GET', `/forms/v2/fields/${formId}`); + responseData = await hubspotApiRequest.call( + this, + 'GET', + `/forms/v2/fields/${formId}`, + ); } //https://developers.hubspot.com/docs/methods/forms/submit_form_v3 if (operation === 'submit') { const formId = this.getNodeParameter('formId', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - const context = (this.getNodeParameter('contextUi', i) as IDataObject).contextValue as IDataObject; - const legalConsent = (this.getNodeParameter('lengalConsentUi', i) as IDataObject).lengalConsentValues as IDataObject; - const legitimateInteres = (this.getNodeParameter('lengalConsentUi', i) as IDataObject).legitimateInterestValues as IDataObject; - const { portalId } = await hubspotApiRequest.call(this, 'GET', `/forms/v2/forms/${formId}`); + const context = (this.getNodeParameter('contextUi', i) as IDataObject) + .contextValue as IDataObject; + const legalConsent = (this.getNodeParameter('lengalConsentUi', i) as IDataObject) + .lengalConsentValues as IDataObject; + const legitimateInteres = (this.getNodeParameter('lengalConsentUi', i) as IDataObject) + .legitimateInterestValues as IDataObject; + const { portalId } = await hubspotApiRequest.call( + this, + 'GET', + `/forms/v2/forms/${formId}`, + ); const body: IForm = { formId, portalId, @@ -2300,7 +2418,8 @@ export class Hubspot implements INodeType { consent!.text = legalConsent.text as string; } if (legalConsent.communicationsUi) { - consent.communications = (legalConsent.communicationsUi as IDataObject).communicationValues as IDataObject; + consent.communications = (legalConsent.communicationsUi as IDataObject) + .communicationValues as IDataObject; } } body.legalConsentOptions!.consent = consent; @@ -2309,7 +2428,9 @@ export class Hubspot implements INodeType { body.fields?.push({ name: key, value: fields[key] }); } if (body.legalConsentOptions!.legitimateInterest) { - Object.assign(body, { legalConsentOptions: { legitimateInterest: legitimateInteres } }); + Object.assign(body, { + legalConsentOptions: { legitimateInterest: legitimateInteres }, + }); } if (context) { clean(context); @@ -2405,7 +2526,12 @@ export class Hubspot implements INodeType { definitionId: 26, }); } - await hubspotApiRequest.call(this, 'PUT', '/crm-associations/v1/associations/create-batch', companyAssociations); + await hubspotApiRequest.call( + this, + 'PUT', + '/crm-associations/v1/associations/create-batch', + companyAssociations, + ); } if (additionalFields.associatedContactIds) { @@ -2418,7 +2544,12 @@ export class Hubspot implements INodeType { definitionId: 16, }); } - await hubspotApiRequest.call(this, 'PUT', '/crm-associations/v1/associations/create-batch', contactAssociations); + await hubspotApiRequest.call( + this, + 'PUT', + '/crm-associations/v1/associations/create-batch', + contactAssociations, + ); } } //https://developers.hubspot.com/docs/methods/tickets/get_ticket_by_id @@ -2429,7 +2560,9 @@ export class Hubspot implements INodeType { qs.properties = additionalFields.properties as string[]; } if (additionalFields.propertiesWithHistory) { - qs.propertiesWithHistory = (additionalFields.propertiesWithHistory as string).split(','); + qs.propertiesWithHistory = (additionalFields.propertiesWithHistory as string).split( + ',', + ); } if (additionalFields.includeDeleted) { qs.includeDeleted = additionalFields.includeDeleted as boolean; @@ -2445,14 +2578,30 @@ export class Hubspot implements INodeType { qs.properties = additionalFields.properties as string[]; } if (additionalFields.propertiesWithHistory) { - qs.propertiesWithHistory = (additionalFields.propertiesWithHistory as string).split(','); + qs.propertiesWithHistory = (additionalFields.propertiesWithHistory as string).split( + ',', + ); } const endpoint = `/crm-objects/v1/objects/tickets/paged`; if (returnAll) { - responseData = await hubspotApiRequestAllItems.call(this, 'objects', 'GET', endpoint, {}, qs); + responseData = await hubspotApiRequestAllItems.call( + this, + 'objects', + 'GET', + endpoint, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; - responseData = await hubspotApiRequestAllItems.call(this, 'objects', 'GET', endpoint, {}, qs); + responseData = await hubspotApiRequestAllItems.call( + this, + 'objects', + 'GET', + endpoint, + {}, + qs, + ); responseData = responseData.splice(0, qs.limit); } } @@ -2547,7 +2696,12 @@ export class Hubspot implements INodeType { definitionId: 26, }); } - await hubspotApiRequest.call(this, 'PUT', '/crm-associations/v1/associations/create-batch', companyAssociations); + await hubspotApiRequest.call( + this, + 'PUT', + '/crm-associations/v1/associations/create-batch', + companyAssociations, + ); } if (updateFields.associatedContactIds) { @@ -2560,7 +2714,12 @@ export class Hubspot implements INodeType { definitionId: 16, }); } - await hubspotApiRequest.call(this, 'PUT', '/crm-associations/v1/associations/create-batch', contactAssociations); + await hubspotApiRequest.call( + this, + 'PUT', + '/crm-associations/v1/associations/create-batch', + contactAssociations, + ); } } } diff --git a/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts b/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts index a21be0fc08..b61269430c 100644 --- a/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts +++ b/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -22,13 +19,9 @@ import { propertyEvents, } from './GenericFunctions'; -import { - createHash, -} from 'crypto'; +import { createHash } from 'crypto'; -import { - capitalCase, -} from 'change-case'; +import { capitalCase } from 'change-case'; export class HubspotTrigger implements INodeType { description: INodeTypeDescription = { @@ -86,52 +79,60 @@ export class HubspotTrigger implements INodeType { { name: 'Company Created', value: 'company.creation', - description: 'To get notified if any company is created in a customer\'s account', + description: + "To get notified if any company is created in a customer's account", }, { name: 'Company Deleted', value: 'company.deletion', - description: 'To get notified if any company is deleted in a customer\'s account', + description: + "To get notified if any company is deleted in a customer's account", }, { name: 'Company Property Changed', value: 'company.propertyChange', - description: 'To get notified if a specified property is changed for any company in a customer\'s account', + description: + "To get notified if a specified property is changed for any company in a customer's account", }, { name: 'Contact Created', value: 'contact.creation', - description: 'To get notified if any contact is created in a customer\'s account', + description: + "To get notified if any contact is created in a customer's account", }, { name: 'Contact Deleted', value: 'contact.deletion', - description: 'To get notified if any contact is deleted in a customer\'s account', + description: + "To get notified if any contact is deleted in a customer's account", }, { name: 'Contact Privacy Deleted', value: 'contact.privacyDeletion', - description: 'To get notified if a contact is deleted for privacy compliance reasons', + description: + 'To get notified if a contact is deleted for privacy compliance reasons', }, { name: 'Contact Property Changed', value: 'contact.propertyChange', - description: 'To get notified if a specified property is changed for any contact in a customer\'s account', + description: + "To get notified if a specified property is changed for any contact in a customer's account", }, { name: 'Deal Created', value: 'deal.creation', - description: 'To get notified if any deal is created in a customer\'s account', + description: "To get notified if any deal is created in a customer's account", }, { name: 'Deal Deleted', value: 'deal.deletion', - description: 'To get notified if any deal is deleted in a customer\'s account', + description: "To get notified if any deal is deleted in a customer's account", }, { name: 'Deal Property Changed', value: 'deal.propertyChange', - description: 'To get notified if a specified property is changed for any deal in a customer\'s account', + description: + "To get notified if a specified property is changed for any deal in a customer's account", }, ], default: 'contact.creation', @@ -141,18 +142,15 @@ export class HubspotTrigger implements INodeType { displayName: 'Property Name or ID', name: 'property', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'contact.propertyChange', - ], + loadOptionsDependsOn: ['contact.propertyChange'], loadOptionsMethod: 'getContactProperties', }, displayOptions: { show: { - name: [ - 'contact.propertyChange', - ], + name: ['contact.propertyChange'], }, }, default: '', @@ -162,18 +160,15 @@ export class HubspotTrigger implements INodeType { displayName: 'Property Name or ID', name: 'property', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'company.propertyChange', - ], + loadOptionsDependsOn: ['company.propertyChange'], loadOptionsMethod: 'getCompanyProperties', }, displayOptions: { show: { - name: [ - 'company.propertyChange', - ], + name: ['company.propertyChange'], }, }, default: '', @@ -183,18 +178,15 @@ export class HubspotTrigger implements INodeType { displayName: 'Property Name or ID', name: 'property', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'deal.propertyChange', - ], + loadOptionsDependsOn: ['deal.propertyChange'], loadOptionsMethod: 'getDealProperties', }, displayOptions: { show: { - name: [ - 'deal.propertyChange', - ], + name: ['deal.propertyChange'], }, }, default: '', @@ -288,9 +280,17 @@ export class HubspotTrigger implements INodeType { const { appId } = await this.getCredentials('hubspotDeveloperApi'); try { - const { targetUrl } = await hubspotApiRequest.call(this, 'GET', `/webhooks/v3/${appId}/settings`, {}); + const { targetUrl } = await hubspotApiRequest.call( + this, + 'GET', + `/webhooks/v3/${appId}/settings`, + {}, + ); if (targetUrl !== currentWebhookUrl) { - throw new NodeOperationError(this.getNode(), `The APP ID ${appId} already has a target url ${targetUrl}. Delete it or use another APP ID before executing the trigger. Due to Hubspot API limitations, you can have just one trigger per APP.`); + throw new NodeOperationError( + this.getNode(), + `The APP ID ${appId} already has a target url ${targetUrl}. Delete it or use another APP ID before executing the trigger. Due to Hubspot API limitations, you can have just one trigger per APP.`, + ); } } catch (error) { if (error.statusCode === 404) { @@ -299,11 +299,21 @@ export class HubspotTrigger implements INodeType { } // if the app is using the current webhook url. Delete everything and create it again with the current events - const { results: subscriptions } = await hubspotApiRequest.call(this, 'GET', `/webhooks/v3/${appId}/subscriptions`, {}); + const { results: subscriptions } = await hubspotApiRequest.call( + this, + 'GET', + `/webhooks/v3/${appId}/subscriptions`, + {}, + ); // delete all subscriptions for (const subscription of subscriptions) { - await hubspotApiRequest.call(this, 'DELETE', `/webhooks/v3/${appId}/subscriptions/${subscription.id}`, {}); + await hubspotApiRequest.call( + this, + 'DELETE', + `/webhooks/v3/${appId}/subscriptions/${subscription.id}`, + {}, + ); } await hubspotApiRequest.call(this, 'DELETE', `/webhooks/v3/${appId}/settings`, {}); @@ -313,7 +323,9 @@ export class HubspotTrigger implements INodeType { async create(this: IHookFunctions): Promise { const webhookUrl = this.getNodeWebhookUrl('default'); const { appId } = await this.getCredentials('hubspotDeveloperApi'); - const events = (this.getNodeParameter('eventsUi') as IDataObject || {}).eventValues as IDataObject[] || []; + const events = + (((this.getNodeParameter('eventsUi') as IDataObject) || {}) + .eventValues as IDataObject[]) || []; const additionalFields = this.getNodeParameter('additionalFields') as IDataObject; let endpoint = `/webhooks/v3/${appId}/settings`; let body: IDataObject = { @@ -346,10 +358,20 @@ export class HubspotTrigger implements INodeType { async delete(this: IHookFunctions): Promise { const { appId } = await this.getCredentials('hubspotDeveloperApi'); - const { results: subscriptions } = await hubspotApiRequest.call(this, 'GET', `/webhooks/v3/${appId}/subscriptions`, {}); + const { results: subscriptions } = await hubspotApiRequest.call( + this, + 'GET', + `/webhooks/v3/${appId}/subscriptions`, + {}, + ); for (const subscription of subscriptions) { - await hubspotApiRequest.call(this, 'DELETE', `/webhooks/v3/${appId}/subscriptions/${subscription.id}`, {}); + await hubspotApiRequest.call( + this, + 'DELETE', + `/webhooks/v3/${appId}/subscriptions/${subscription.id}`, + {}, + ); } try { @@ -363,7 +385,6 @@ export class HubspotTrigger implements INodeType { }; async webhook(this: IWebhookFunctions): Promise { - const credentials = await this.getCredentials('hubspotDeveloperApi'); if (credentials === undefined) { @@ -399,9 +420,7 @@ export class HubspotTrigger implements INodeType { delete bodyData[i].objectId; } return { - workflowData: [ - this.helpers.returnJsonArray(bodyData), - ], + workflowData: [this.helpers.returnJsonArray(bodyData)], }; } } diff --git a/packages/nodes-base/nodes/Hubspot/TicketDescription.ts b/packages/nodes-base/nodes/Hubspot/TicketDescription.ts index c41fbbd6bc..63e8fabce1 100644 --- a/packages/nodes-base/nodes/Hubspot/TicketDescription.ts +++ b/packages/nodes-base/nodes/Hubspot/TicketDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const ticketOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const ticketOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'ticket', - ], + resource: ['ticket'], }, }, options: [ @@ -52,7 +48,6 @@ export const ticketOperations: INodeProperties[] = [ ]; export const ticketFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* ticket:create */ /* -------------------------------------------------------------------------- */ @@ -66,16 +61,13 @@ export const ticketFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, default: '', - description: 'The ID of the pipeline the ticket is in. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the pipeline the ticket is in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Stage Name or ID', @@ -84,22 +76,17 @@ export const ticketFields: INodeProperties[] = [ required: true, typeOptions: { loadOptionsMethod: 'getTicketStages', - loadOptionsDependsOn: [ - 'pipelineId', - ], + loadOptionsDependsOn: ['pipelineId'], }, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, default: '', - description: 'The ID of the pipeline the ticket is in. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the pipeline the ticket is in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Ticket Name', @@ -108,12 +95,8 @@ export const ticketFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, default: '', @@ -127,12 +110,8 @@ export const ticketFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, options: [ @@ -144,7 +123,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanies', }, default: [], - description: 'Companies associated with the ticket. Choose from the list, or specify IDs using an expression.', + description: + 'Companies associated with the ticket. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Contact Names or IDs', @@ -154,7 +134,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getContacts', }, default: [], - description: 'Contacts associated with the ticket. Choose from the list, or specify IDs using an expression.', + description: + 'Contacts associated with the ticket. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Category Name or ID', @@ -164,7 +145,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getTicketCategories', }, default: '', - description: 'Main reason customer reached out for help. Choose from the list, or specify an ID using an expression.', + description: + 'Main reason customer reached out for help. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Close Date', @@ -198,7 +180,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getTicketPriorities', }, default: '', - description: 'The level of attention needed on the ticket. Choose from the list, or specify an ID using an expression.', + description: + 'The level of attention needed on the ticket. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Resolution Name or ID', @@ -208,7 +191,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getTicketResolutions', }, default: '', - description: 'The action taken to resolve the ticket. Choose from the list, or specify an ID using an expression.', + description: + 'The action taken to resolve the ticket. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Source Name or ID', @@ -218,7 +202,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getTicketSources', }, default: '', - description: 'Channel where ticket was originally submitted. Choose from the list, or specify an ID using an expression.', + description: + 'Channel where ticket was originally submitted. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Ticket Owner Name or ID', @@ -228,7 +213,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getOwners', }, default: '', - description: 'The user from your team that the ticket is assigned to. You can assign additional users to a ticket record by creating a custom HubSpot user property. Choose from the list, or specify an ID using an expression.', + description: + 'The user from your team that the ticket is assigned to. You can assign additional users to a ticket record by creating a custom HubSpot user property. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -242,12 +228,8 @@ export const ticketFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'update', - ], + resource: ['ticket'], + operation: ['update'], }, }, default: '', @@ -261,12 +243,8 @@ export const ticketFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'update', - ], + resource: ['ticket'], + operation: ['update'], }, }, options: [ @@ -278,7 +256,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanies', }, default: [], - description: 'Companies associated with the ticket. Choose from the list, or specify IDs using an expression.', + description: + 'Companies associated with the ticket. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Contact Names or IDs', @@ -288,7 +267,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getContacts', }, default: [], - description: 'Contact associated with the ticket. Choose from the list, or specify IDs using an expression.', + description: + 'Contact associated with the ticket. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Category Name or ID', @@ -298,7 +278,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getTicketCategories', }, default: '', - description: 'Main reason customer reached out for help. Choose from the list, or specify an ID using an expression.', + description: + 'Main reason customer reached out for help. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Close Date', @@ -332,7 +313,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getTicketPipelines', }, default: '', - description: 'The ID of the pipeline the ticket is in. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the pipeline the ticket is in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Priority Name or ID', @@ -342,7 +324,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getTicketPriorities', }, default: '', - description: 'The level of attention needed on the ticket. Choose from the list, or specify an ID using an expression.', + description: + 'The level of attention needed on the ticket. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Resolution Name or ID', @@ -352,7 +335,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getTicketResolutions', }, default: '', - description: 'The action taken to resolve the ticket. Choose from the list, or specify an ID using an expression.', + description: + 'The action taken to resolve the ticket. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Source Name or ID', @@ -362,7 +346,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getTicketSources', }, default: '', - description: 'Channel where ticket was originally submitted. Choose from the list, or specify an ID using an expression.', + description: + 'Channel where ticket was originally submitted. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Stage Name or ID', @@ -370,12 +355,11 @@ export const ticketFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getTicketStages', - loadOptionsDependsOn: [ - 'updateFields.pipelineId', - ], + loadOptionsDependsOn: ['updateFields.pipelineId'], }, default: '', - description: 'The stage ID of the pipeline the ticket is in; depends on Pipeline ID. Choose from the list, or specify an ID using an expression.', + description: + 'The stage ID of the pipeline the ticket is in; depends on Pipeline ID. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Ticket Name', @@ -392,7 +376,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getOwners', }, default: '', - description: 'The user from your team that the ticket is assigned to. You can assign additional users to a ticket record by creating a custom HubSpot user property. Choose from the list, or specify an ID using an expression.', + description: + 'The user from your team that the ticket is assigned to. You can assign additional users to a ticket record by creating a custom HubSpot user property. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -407,12 +392,8 @@ export const ticketFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'get', - ], + resource: ['ticket'], + operation: ['get'], }, }, default: '', @@ -426,12 +407,8 @@ export const ticketFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'get', - ], + resource: ['ticket'], + operation: ['get'], }, }, options: [ @@ -449,14 +426,16 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getTicketProperties', }, default: [], - description: '

Used to include specific ticket properties in the results. By default, the results will only include ticket ID and will not include the values for any properties for your tickets.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', + description: + '

Used to include specific ticket properties in the results. By default, the results will only include ticket ID and will not include the values for any properties for your tickets.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Properties With History', name: 'propertiesWithHistory', type: 'string', default: '', - description: 'Works similarly to properties=, but this parameter will include the history for the specified property, instead of just including the current value. Use this parameter when you need the full history of changes to a property\'s value.', + description: + "Works similarly to properties=, but this parameter will include the history for the specified property, instead of just including the current value. Use this parameter when you need the full history of changes to a property's value.", }, ], }, @@ -470,12 +449,8 @@ export const ticketFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], + resource: ['ticket'], + operation: ['getAll'], }, }, default: false, @@ -487,15 +462,9 @@ export const ticketFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['ticket'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -513,12 +482,8 @@ export const ticketFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], + resource: ['ticket'], + operation: ['getAll'], }, }, options: [ @@ -530,14 +495,16 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getTicketProperties', }, default: [], - description: '

Used to include specific ticket properties in the results. By default, the results will only include ticket ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', + description: + '

Used to include specific ticket properties in the results. By default, the results will only include ticket ID and will not include the values for any properties for your company.

Including this parameter will include the data for the specified property in the results. You can include this parameter multiple times to request multiple properties separated by a comma: ,.

. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Properties With History', name: 'propertiesWithHistory', type: 'string', default: '', - description: 'Works similarly to properties=, but this parameter will include the history for the specified property, instead of just including the current value. Use this parameter when you need the full history of changes to a property\'s value.', + description: + "Works similarly to properties=, but this parameter will include the history for the specified property, instead of just including the current value. Use this parameter when you need the full history of changes to a property's value.", }, ], }, @@ -552,12 +519,8 @@ export const ticketFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'delete', - ], + resource: ['ticket'], + operation: ['delete'], }, }, default: '', diff --git a/packages/nodes-base/nodes/HumanticAI/GenericFunctions.ts b/packages/nodes-base/nodes/HumanticAI/GenericFunctions.ts index 8e0603f969..b67b048845 100644 --- a/packages/nodes-base/nodes/HumanticAI/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HumanticAI/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,11 +7,18 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function humanticAiApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function humanticAiApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { try { const credentials = await this.getCredentials('humanticAiApi'); let options: OptionsWithUri = { @@ -41,7 +46,6 @@ export async function humanticAiApiRequest(this: IHookFunctions | IExecuteFuncti } return response; - } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/HumanticAI/HumanticAi.node.ts b/packages/nodes-base/nodes/HumanticAI/HumanticAi.node.ts index 93cffa1ef7..2248d72ff5 100644 --- a/packages/nodes-base/nodes/HumanticAI/HumanticAi.node.ts +++ b/packages/nodes-base/nodes/HumanticAI/HumanticAi.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryData, @@ -12,14 +10,9 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - humanticAiApiRequest, -} from './GenericFunctions'; +import { humanticAiApiRequest } from './GenericFunctions'; -import { - profileFields, - profileOperations, -} from './ProfileDescription'; +import { profileFields, profileOperations } from './ProfileDescription'; export class HumanticAi implements INodeType { description: INodeTypeDescription = { @@ -81,7 +74,9 @@ export class HumanticAi implements INodeType { const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; if (items[i].binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const item = items[i].binary as IBinaryKeyData; @@ -90,7 +85,11 @@ export class HumanticAi implements INodeType { const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); if (binaryData === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + { itemIndex: i }, + ); } responseData = await humanticAiApiRequest.call( @@ -111,7 +110,13 @@ export class HumanticAi implements INodeType { }, ); } else { - responseData = await humanticAiApiRequest.call(this, 'GET', `/user-profile/create`, {}, qs); + responseData = await humanticAiApiRequest.call( + this, + 'GET', + `/user-profile/create`, + {}, + qs, + ); } if (responseData.data !== undefined) { @@ -142,7 +147,9 @@ export class HumanticAi implements INodeType { const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; if (items[i].binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const item = items[i].binary as IBinaryKeyData; @@ -151,7 +158,11 @@ export class HumanticAi implements INodeType { const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); if (binaryData === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + { itemIndex: i }, + ); } responseData = await humanticAiApiRequest.call( @@ -180,7 +191,13 @@ export class HumanticAi implements INodeType { qs.userid = userId; - responseData = await humanticAiApiRequest.call(this, 'POST', `/user-profile/create`, body, qs); + responseData = await humanticAiApiRequest.call( + this, + 'POST', + `/user-profile/create`, + body, + qs, + ); responseData = responseData.data; } } diff --git a/packages/nodes-base/nodes/HumanticAI/ProfileDescription.ts b/packages/nodes-base/nodes/HumanticAI/ProfileDescription.ts index e29cdb36b3..b9c5b6b1fe 100644 --- a/packages/nodes-base/nodes/HumanticAI/ProfileDescription.ts +++ b/packages/nodes-base/nodes/HumanticAI/ProfileDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const profileOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const profileOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'profile', - ], + resource: ['profile'], }, }, options: [ @@ -51,15 +47,12 @@ export const profileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'profile', - ], + operation: ['create'], + resource: ['profile'], }, }, - description: 'The LinkedIn profile URL or email ID for creating a Humantic profile. If you are sending the resume, this should be a unique string.', + description: + 'The LinkedIn profile URL or email ID for creating a Humantic profile. If you are sending the resume, this should be a unique string.', }, { displayName: 'Send Resume', @@ -68,12 +61,8 @@ export const profileFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'profile', - ], + operation: ['create'], + resource: ['profile'], }, }, description: 'Whether to send a resume for a resume based analysis', @@ -85,15 +74,9 @@ export const profileFields: INodeProperties[] = [ default: 'data', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'profile', - ], - sendResume: [ - true, - ], + operation: ['create'], + resource: ['profile'], + sendResume: [true], }, }, description: 'The resume in PDF or DOCX format', @@ -110,15 +93,12 @@ export const profileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'profile', - ], + operation: ['get'], + resource: ['profile'], }, }, - description: 'This value is the same as the User ID that was provided when the analysis was created. This could be a LinkedIn URL, email ID, or a unique string in case of resume based analysis.', + description: + 'This value is the same as the User ID that was provided when the analysis was created. This could be a LinkedIn URL, email ID, or a unique string in case of resume based analysis.', }, { displayName: 'Options', @@ -128,12 +108,8 @@ export const profileFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'profile', - ], + operation: ['get'], + resource: ['profile'], }, }, options: [ @@ -152,13 +128,12 @@ export const profileFields: INodeProperties[] = [ }, ], default: [], - description: 'Fetch the Humantic profile of the user for a particular persona type. Multiple persona values can be supported using comma as a delimiter.', + description: + 'Fetch the Humantic profile of the user for a particular persona type. Multiple persona values can be supported using comma as a delimiter.', }, ], }, - - /* -------------------------------------------------------------------------- */ /* profile:update */ /* -------------------------------------------------------------------------- */ @@ -170,15 +145,12 @@ export const profileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'profile', - ], + operation: ['update'], + resource: ['profile'], }, }, - description: 'This value is the same as the User ID that was provided when the analysis was created. Currently only supported for profiles created using LinkedIn URL.', + description: + 'This value is the same as the User ID that was provided when the analysis was created. Currently only supported for profiles created using LinkedIn URL.', }, { displayName: 'Send Resume', @@ -187,12 +159,8 @@ export const profileFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'profile', - ], + operation: ['update'], + resource: ['profile'], }, }, description: 'Whether to send a resume for a resume of the user', @@ -204,15 +172,9 @@ export const profileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'profile', - ], - sendResume: [ - false, - ], + operation: ['update'], + resource: ['profile'], + sendResume: [false], }, }, description: 'Additional text written by the user', @@ -224,15 +186,9 @@ export const profileFields: INodeProperties[] = [ default: 'data', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'profile', - ], - sendResume: [ - true, - ], + operation: ['update'], + resource: ['profile'], + sendResume: [true], }, }, description: 'The resume in PDF or DOCX format', diff --git a/packages/nodes-base/nodes/Hunter/GenericFunctions.ts b/packages/nodes-base/nodes/Hunter/GenericFunctions.ts index 2dbd9c75ad..26315d498d 100644 --- a/packages/nodes-base/nodes/Hunter/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Hunter/GenericFunctions.ts @@ -5,16 +5,26 @@ import { IHookFunctions, ILoadOptionsFunctions, } from 'n8n-core'; -import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function hunterApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function hunterApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('hunterApi'); qs = Object.assign({ api_key: credentials.apiKey }, qs); let options: OptionsWithUri = { method, qs, body, - uri: uri ||`https://api.hunter.io/v2${resource}`, + uri: uri || `https://api.hunter.io/v2${resource}`, json: true, }; options = Object.assign({}, options, option); @@ -32,8 +42,16 @@ export async function hunterApiRequest(this: IHookFunctions | IExecuteFunctions * Make an API request to paginated flow endpoint * and return all results */ -export async function hunterApiRequestAllItems(this: IHookFunctions | IExecuteFunctions| ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function hunterApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; diff --git a/packages/nodes-base/nodes/Hunter/Hunter.node.ts b/packages/nodes-base/nodes/Hunter/Hunter.node.ts index d8520f1af5..15f57573f8 100644 --- a/packages/nodes-base/nodes/Hunter/Hunter.node.ts +++ b/packages/nodes-base/nodes/Hunter/Hunter.node.ts @@ -1,16 +1,6 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; -import { - hunterApiRequest, - hunterApiRequestAllItems, -} from './GenericFunctions'; +import { IExecuteFunctions } from 'n8n-core'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; +import { hunterApiRequest, hunterApiRequestAllItems } from './GenericFunctions'; export class Hunter implements INodeType { description: INodeTypeDescription = { @@ -43,14 +33,18 @@ export class Hunter implements INodeType { { name: 'Domain Search', value: 'domainSearch', - description: 'Get every email address found on the internet using a given domain name, with sources', - action: 'Get every email address found on the internet using a given domain name, with sources', + description: + 'Get every email address found on the internet using a given domain name, with sources', + action: + 'Get every email address found on the internet using a given domain name, with sources', }, { name: 'Email Finder', value: 'emailFinder', - description: 'Generate or retrieve the most likely email address from a domain name, a first name and a last name', - action: 'Generate or retrieve the most likely email address from a domain name, a first name and a last name', + description: + 'Generate or retrieve the most likely email address from a domain name, a first name and a last name', + action: + 'Generate or retrieve the most likely email address from a domain name, a first name and a last name', }, { name: 'Email Verifier', @@ -68,14 +62,13 @@ export class Hunter implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'domainSearch', - ], + operation: ['domainSearch'], }, }, default: '', required: true, - description: 'Domain name from which you want to find the email addresses. For example, "stripe.com".', + description: + 'Domain name from which you want to find the email addresses. For example, "stripe.com".', }, { displayName: 'Only Emails', @@ -83,9 +76,7 @@ export class Hunter implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'domainSearch', - ], + operation: ['domainSearch'], }, }, default: true, @@ -97,9 +88,7 @@ export class Hunter implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'domainSearch', - ], + operation: ['domainSearch'], }, }, default: false, @@ -111,12 +100,8 @@ export class Hunter implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'domainSearch', - ], - returnAll: [ - false, - ], + operation: ['domainSearch'], + returnAll: [false], }, }, typeOptions: { @@ -134,9 +119,7 @@ export class Hunter implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'domainSearch', - ], + operation: ['domainSearch'], }, }, options: [ @@ -233,13 +216,12 @@ export class Hunter implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'emailFinder', - ], + operation: ['emailFinder'], }, }, required: true, - description: 'Domain name from which you want to find the email addresses. For example, "stripe.com".', + description: + 'Domain name from which you want to find the email addresses. For example, "stripe.com".', }, { displayName: 'First Name', @@ -247,14 +229,12 @@ export class Hunter implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'emailFinder', - ], + operation: ['emailFinder'], }, }, default: '', required: true, - description: 'The person\'s first name. It doesn\'t need to be in lowercase.', + description: "The person's first name. It doesn't need to be in lowercase.", }, { displayName: 'Last Name', @@ -262,14 +242,12 @@ export class Hunter implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'emailFinder', - ], + operation: ['emailFinder'], }, }, default: '', required: true, - description: 'The person\'s last name. It doesn\'t need to be in lowercase.', + description: "The person's last name. It doesn't need to be in lowercase.", }, { displayName: 'Email', @@ -278,9 +256,7 @@ export class Hunter implements INodeType { placeholder: 'name@email.com', displayOptions: { show: { - operation: [ - 'emailVerifier', - ], + operation: ['emailVerifier'], }, }, default: '', @@ -307,17 +283,24 @@ export class Hunter implements INodeType { const onlyEmails = this.getNodeParameter('onlyEmails', i, false) as boolean; qs.domain = domain; - if (filters.type){ + if (filters.type) { qs.type = filters.type; } - if (filters.seniority){ + if (filters.seniority) { qs.seniority = (filters.seniority as string[]).join(','); } - if (filters.department){ + if (filters.department) { qs.department = (filters.department as string[]).join(','); } if (returnAll) { - responseData = await hunterApiRequestAllItems.call(this, 'data', 'GET', '/domain-search', {}, qs); + responseData = await hunterApiRequestAllItems.call( + this, + 'data', + 'GET', + '/domain-search', + {}, + qs, + ); // Make sure that the company information is there only once and // the emails are combined underneath it. @@ -329,7 +312,10 @@ export class Hunter implements INodeType { tempReturnData = responseData[i]; continue; } - ((tempReturnData as IDataObject).emails as IDataObject[]).push.apply(tempReturnData.emails, responseData[i].emails); + ((tempReturnData as IDataObject).emails as IDataObject[]).push.apply( + tempReturnData.emails, + responseData[i].emails, + ); } responseData = tempReturnData; diff --git a/packages/nodes-base/nodes/ICalendar/ICalendar.node.ts b/packages/nodes-base/nodes/ICalendar/ICalendar.node.ts index de845ca8c3..5fecdf3f38 100644 --- a/packages/nodes-base/nodes/ICalendar/ICalendar.node.ts +++ b/packages/nodes-base/nodes/ICalendar/ICalendar.node.ts @@ -1,18 +1,9 @@ /* eslint-disable n8n-nodes-base/node-filename-against-convention */ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - promisify, -} from 'util'; +import { promisify } from 'util'; import moment from 'moment-timezone'; @@ -62,7 +53,8 @@ export class ICalendar implements INodeType { type: 'dateTime', default: '', required: true, - description: 'Date and time at which the event begins. (For all-day events, the time will be ignored.).', + description: + 'Date and time at which the event begins. (For all-day events, the time will be ignored.).', }, { displayName: 'End', @@ -70,7 +62,8 @@ export class ICalendar implements INodeType { type: 'dateTime', default: '', required: true, - description: 'Date and time at which the event ends. (For all-day events, the time will be ignored.).', + description: + 'Date and time at which the event ends. (For all-day events, the time will be ignored.).', }, { displayName: 'All Day', @@ -95,9 +88,7 @@ export class ICalendar implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'createEventFile', - ], + operation: ['createEventFile'], }, }, options: [ @@ -163,7 +154,8 @@ export class ICalendar implements INodeType { name: 'calName', type: 'string', default: '', - description: 'Specifies the calendar (not event) name. Used by Apple iCal and Microsoft Outlook (spec).', + description: + 'Specifies the calendar (not event) name. Used by Apple iCal and Microsoft Outlook (spec).', }, { displayName: 'Description', @@ -220,7 +212,8 @@ export class ICalendar implements INodeType { name: 'recurrenceRule', type: 'string', default: '', - description: 'A rule to define the repeat pattern of the event (RRULE). (Rule generator).', + description: + 'A rule to define the repeat pattern of the event (RRULE). (Rule generator).', }, { displayName: 'Organizer', @@ -260,7 +253,8 @@ export class ICalendar implements INodeType { name: 'sequence', type: 'number', default: 0, - description: 'When sending an update for an event (with the same uid), defines the revision sequence number', + description: + 'When sending an update for an event (with the same uid), defines the revision sequence number', }, { displayName: 'Status', @@ -287,7 +281,8 @@ export class ICalendar implements INodeType { name: 'uid', type: 'string', default: '', - description: 'Universally unique ID for the event (will be auto-generated if not specified here). Should be globally unique.', + description: + 'Universally unique ID for the event (will be auto-generated if not specified here). Should be globally unique.', }, { displayName: 'URL', @@ -312,14 +307,18 @@ export class ICalendar implements INodeType { const allDay = this.getNodeParameter('allDay', i) as boolean; const start = this.getNodeParameter('start', i) as string; let end = this.getNodeParameter('end', i) as string; - end = (allDay) ? moment(end).utc().add(1, 'day').format() as string : end; + end = allDay ? (moment(end).utc().add(1, 'day').format() as string) : end; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; let fileName = 'event.ics'; - const eventStart = moment(start).toArray().splice(0, (allDay) ? 3 : 6) as ics.DateArray; + const eventStart = moment(start) + .toArray() + .splice(0, allDay ? 3 : 6) as ics.DateArray; eventStart[1]++; - const eventEnd = moment(end).toArray().splice(0, (allDay) ? 3 : 6) as ics.DateArray; + const eventEnd = moment(end) + .toArray() + .splice(0, allDay ? 3 : 6) as ics.DateArray; eventEnd[1]++; if (additionalFields.fileName) { @@ -335,34 +334,35 @@ export class ICalendar implements INodeType { }; if (additionalFields.geolocationUi) { - data.geo = (additionalFields.geolocationUi as IDataObject).geolocationValues as ics.GeoCoordinates; + data.geo = (additionalFields.geolocationUi as IDataObject) + .geolocationValues as ics.GeoCoordinates; delete additionalFields.geolocationUi; } if (additionalFields.organizerUi) { - data.organizer = (additionalFields.organizerUi as IDataObject).organizerValues as ics.Person; + data.organizer = (additionalFields.organizerUi as IDataObject) + .organizerValues as ics.Person; delete additionalFields.organizerUi; } if (additionalFields.attendeesUi) { - data.attendees = (additionalFields.attendeesUi as IDataObject).attendeeValues as ics.Attendee[]; + data.attendees = (additionalFields.attendeesUi as IDataObject) + .attendeeValues as ics.Attendee[]; delete additionalFields.attendeesUi; } Object.assign(data, additionalFields); - const buffer = Buffer.from(await createEvent(data) as string); + const buffer = Buffer.from((await createEvent(data)) as string); const binaryData = await this.helpers.prepareBinaryData(buffer, fileName, 'text/calendar'); - returnData.push( - { - json: {}, - binary: { - [binaryPropertyName]: binaryData, - }, - pairedItem: { - item: i, - }, + returnData.push({ + json: {}, + binary: { + [binaryPropertyName]: binaryData, }, - ); + pairedItem: { + item: i, + }, + }); } } return [returnData]; diff --git a/packages/nodes-base/nodes/If/If.node.ts b/packages/nodes-base/nodes/If/If.node.ts index fe32b0be0d..099482799f 100644 --- a/packages/nodes-base/nodes/If/If.node.ts +++ b/packages/nodes-base/nodes/If/If.node.ts @@ -9,7 +9,6 @@ import { NodeParameterValue, } from 'n8n-workflow'; - export class If implements INodeType { description: INodeTypeDescription = { displayName: 'IF', @@ -177,10 +176,7 @@ export class If implements INodeType { type: 'number', displayOptions: { hide: { - operation: [ - 'isEmpty', - 'isNotEmpty', - ], + operation: ['isEmpty', 'isNotEmpty'], }, }, default: 0, @@ -264,12 +260,7 @@ export class If implements INodeType { type: 'string', displayOptions: { hide: { - operation: [ - 'isEmpty', - 'isNotEmpty', - 'regex', - 'notRegex', - ], + operation: ['isEmpty', 'isNotEmpty', 'regex', 'notRegex'], }, }, default: '', @@ -281,10 +272,7 @@ export class If implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'regex', - 'notRegex', - ], + operation: ['regex', 'notRegex'], }, }, default: '', @@ -312,12 +300,12 @@ export class If implements INodeType { }, ], default: 'all', - description: 'If multiple rules got set this settings decides if it is true as soon as ANY condition matches or only if ALL get meet', + description: + 'If multiple rules got set this settings decides if it is true as soon as ANY condition matches or only if ALL get meet', }, ], }; - async execute(this: IExecuteFunctions): Promise { const returnDataTrue: INodeExecutionData[] = []; const returnDataFalse: INodeExecutionData[] = []; @@ -331,22 +319,44 @@ export class If implements INodeType { const compareOperationFunctions: { [key: string]: (value1: NodeParameterValue, value2: NodeParameterValue) => boolean; } = { - after: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) > (value2 || 0), - before: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) < (value2 || 0), - contains: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || '').toString().includes((value2 || '').toString()), - notContains: (value1: NodeParameterValue, value2: NodeParameterValue) => !(value1 || '').toString().includes((value2 || '').toString()), - endsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 as string).endsWith(value2 as string), - notEndsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => !(value1 as string).endsWith(value2 as string), + after: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 || 0) > (value2 || 0), + before: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 || 0) < (value2 || 0), + contains: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 || '').toString().includes((value2 || '').toString()), + notContains: (value1: NodeParameterValue, value2: NodeParameterValue) => + !(value1 || '').toString().includes((value2 || '').toString()), + endsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 as string).endsWith(value2 as string), + notEndsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => + !(value1 as string).endsWith(value2 as string), equal: (value1: NodeParameterValue, value2: NodeParameterValue) => value1 === value2, notEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => value1 !== value2, - larger: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) > (value2 || 0), - largerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) >= (value2 || 0), - smaller: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) < (value2 || 0), - smallerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) <= (value2 || 0), - startsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 as string).startsWith(value2 as string), - notStartsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => !(value1 as string).startsWith(value2 as string), - isEmpty: (value1: NodeParameterValue) => (([undefined, null, ''].includes(value1 as string)) || ((typeof value1 === 'object' && value1 !== null) ? (Object.entries(value1 as string).length === 0) : false)), - isNotEmpty: (value1: NodeParameterValue) => !(([undefined, null, ''].includes(value1 as string)) || ((typeof value1 === 'object' && value1 !== null) ? (Object.entries(value1 as string).length === 0) : false)), + larger: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 || 0) > (value2 || 0), + largerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 || 0) >= (value2 || 0), + smaller: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 || 0) < (value2 || 0), + smallerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 || 0) <= (value2 || 0), + startsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 as string).startsWith(value2 as string), + notStartsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => + !(value1 as string).startsWith(value2 as string), + isEmpty: (value1: NodeParameterValue) => + [undefined, null, ''].includes(value1 as string) || + (typeof value1 === 'object' && value1 !== null + ? Object.entries(value1 as string).length === 0 + : false), + isNotEmpty: (value1: NodeParameterValue) => + !( + [undefined, null, ''].includes(value1 as string) || + (typeof value1 === 'object' && value1 !== null + ? Object.entries(value1 as string).length === 0 + : false) + ), regex: (value1: NodeParameterValue, value2: NodeParameterValue) => { const regexMatch = (value2 || '').toString().match(new RegExp('^/(.*?)/([gimusy]*)$')); @@ -384,34 +394,33 @@ export class If implements INodeType { returnValue = new Date(value).getTime(); } else if (typeof value === 'number') { returnValue = value; - } if (moment.isMoment(value)) { + } + if (moment.isMoment(value)) { returnValue = value.unix(); - } if ((value as unknown as object) instanceof Date) { + } + if ((value as unknown as object) instanceof Date) { returnValue = (value as unknown as Date).getTime(); } if (returnValue === undefined || isNaN(returnValue)) { - throw new NodeOperationError(this.getNode(), `The value "${value}" is not a valid DateTime.`); + throw new NodeOperationError( + this.getNode(), + `The value "${value}" is not a valid DateTime.`, + ); } return returnValue; }; // The different dataTypes to check the values in - const dataTypes = [ - 'boolean', - 'dateTime', - 'number', - 'string', - ]; + const dataTypes = ['boolean', 'dateTime', 'number', 'string']; // Itterate over all items to check which ones should be output as via output "true" and // which ones via output "false" let dataType: string; let compareOperationResult: boolean; let value1: NodeParameterValue, value2: NodeParameterValue; - itemLoop: - for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { + itemLoop: for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { item = items[itemIndex]; let compareData: INodeParameters; @@ -421,7 +430,11 @@ export class If implements INodeType { // Check all the values of the different dataTypes for (dataType of dataTypes) { // Check all the values of the current dataType - for (compareData of this.getNodeParameter(`conditions.${dataType}`, itemIndex, []) as INodeParameters[]) { + for (compareData of this.getNodeParameter( + `conditions.${dataType}`, + itemIndex, + [], + ) as INodeParameters[]) { // Check if the values passes value1 = compareData.value1 as NodeParameterValue; @@ -432,7 +445,10 @@ export class If implements INodeType { value2 = convertDateTime(value2); } - compareOperationResult = compareOperationFunctions[compareData.operation as string](value1, value2); + compareOperationResult = compareOperationFunctions[compareData.operation as string]( + value1, + value2, + ); if (compareOperationResult === true && combineOperation === 'any') { // If it passes and the operation is "any" we do not have to check any diff --git a/packages/nodes-base/nodes/Intercom/CompanyDescription.ts b/packages/nodes-base/nodes/Intercom/CompanyDescription.ts index 5cd85504f0..d76d624e80 100644 --- a/packages/nodes-base/nodes/Intercom/CompanyDescription.ts +++ b/packages/nodes-base/nodes/Intercom/CompanyDescription.ts @@ -8,9 +8,7 @@ export const companyOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'company', - ], + resource: ['company'], }, }, options: [ @@ -41,7 +39,7 @@ export const companyOperations: INodeProperties[] = [ { name: 'Users', value: 'users', - description: 'List company\'s users', + description: "List company's users", action: 'List users of a company', }, ], @@ -50,7 +48,6 @@ export const companyOperations: INodeProperties[] = [ ]; export const companyFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* company:users */ /* -------------------------------------------------------------------------- */ @@ -60,12 +57,8 @@ export const companyFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'users', - ], + resource: ['company'], + operation: ['users'], }, }, options: [ @@ -90,12 +83,8 @@ export const companyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'users', - ], + resource: ['company'], + operation: ['users'], }, }, description: 'View by value', @@ -106,12 +95,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'users', - ], + resource: ['company'], + operation: ['users'], }, }, default: false, @@ -123,15 +108,9 @@ export const companyFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'users', - ], - returnAll: [ - false, - ], + resource: ['company'], + operation: ['users'], + returnAll: [false], }, }, typeOptions: { @@ -151,12 +130,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], + resource: ['company'], + operation: ['getAll'], }, }, default: false, @@ -168,15 +143,9 @@ export const companyFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['company'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -194,12 +163,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], + resource: ['company'], + operation: ['getAll'], }, }, options: [ @@ -229,12 +194,8 @@ export const companyFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'get', - ], + resource: ['company'], + operation: ['get'], }, }, options: [ @@ -265,12 +226,8 @@ export const companyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'get', - ], + resource: ['company'], + operation: ['get'], }, }, description: 'View by value', @@ -286,13 +243,8 @@ export const companyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - 'update', - ], + resource: ['company'], + operation: ['create', 'update'], }, }, description: 'The company ID you have defined for the company', @@ -304,13 +256,8 @@ export const companyFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'create', - 'update', - ], - resource: [ - 'company', - ], + operation: ['create', 'update'], + resource: ['company'], }, }, }, @@ -322,13 +269,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - 'update', - ], - resource: [ - 'company', - ], + operation: ['create', 'update'], + resource: ['company'], }, }, options: [ @@ -374,7 +316,8 @@ export const companyFields: INodeProperties[] = [ name: 'website', type: 'string', default: '', - description: 'The URL for this company\'s website. Please note that the value specified here is not validated. Accepts any string.', + description: + "The URL for this company's website. Please note that the value specified here is not validated. Accepts any string.", }, ], }, @@ -387,20 +330,14 @@ export const companyFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['company'], + operation: ['create', 'update'], + jsonParameters: [true], }, }, default: '', - description: 'A hash of key/value pairs to represent custom data you want to attribute to a user', + description: + 'A hash of key/value pairs to represent custom data you want to attribute to a user', }, { displayName: 'Custom Attributes', @@ -413,16 +350,9 @@ export const companyFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - 'update', - ], - jsonParameters: [ - false, - ], + resource: ['company'], + operation: ['create', 'update'], + jsonParameters: [false], }, }, options: [ @@ -445,6 +375,7 @@ export const companyFields: INodeProperties[] = [ ], }, ], - description: 'A hash of key/value pairs to represent custom data you want to attribute to a user', + description: + 'A hash of key/value pairs to represent custom data you want to attribute to a user', }, ]; diff --git a/packages/nodes-base/nodes/Intercom/GenericFunctions.ts b/packages/nodes-base/nodes/Intercom/GenericFunctions.ts index f0d666c367..dea51de529 100644 --- a/packages/nodes-base/nodes/Intercom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Intercom/GenericFunctions.ts @@ -7,15 +7,24 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function intercomApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, endpoint: string, method: string, body: any = {}, query?: IDataObject, uri?: string): Promise { // tslint:disable-line:no-any +export async function intercomApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + endpoint: string, + method: string, + // tslint:disable-next-line:no-any + body: any = {}, + query?: IDataObject, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('intercomApi'); - const headerWithAuthentication = Object.assign({}, - { Authorization: `Bearer ${credentials.apiKey}`, Accept: 'application/json' }); + const headerWithAuthentication = Object.assign( + {}, + { Authorization: `Bearer ${credentials.apiKey}`, Accept: 'application/json' }, + ); const options: OptionsWithUri = { headers: headerWithAuthentication, @@ -33,14 +42,20 @@ export async function intercomApiRequest(this: IHookFunctions | IExecuteFunction } } - - /** * Make an API request to paginated intercom endpoint * and return all results */ -export async function intercomApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, propertyName: string, endpoint: string, method: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function intercomApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions, + propertyName: string, + endpoint: string, + method: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -62,8 +77,8 @@ export async function intercomApiRequestAllItems(this: IHookFunctions | IExecute return returnData; } - -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); diff --git a/packages/nodes-base/nodes/Intercom/Intercom.node.ts b/packages/nodes-base/nodes/Intercom/Intercom.node.ts index 56c1baec03..64a9c64470 100644 --- a/packages/nodes-base/nodes/Intercom/Intercom.node.ts +++ b/packages/nodes-base/nodes/Intercom/Intercom.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, ILoadOptionsFunctions, @@ -11,32 +9,12 @@ import { NodeApiError, NodeOperationError, } from 'n8n-workflow'; -import { - leadFields, - leadOpeations, -} from './LeadDescription'; -import { - intercomApiRequest, - intercomApiRequestAllItems, - validateJSON, -} from './GenericFunctions'; -import { - IAvatar, - ILead, - ILeadCompany, -} from './LeadInterface'; -import { - userFields, - userOpeations, -} from './UserDescription'; -import { - IUser, - IUserCompany, -} from './UserInterface'; -import { - companyFields, - companyOperations, -} from './CompanyDescription'; +import { leadFields, leadOpeations } from './LeadDescription'; +import { intercomApiRequest, intercomApiRequestAllItems, validateJSON } from './GenericFunctions'; +import { IAvatar, ILead, ILeadCompany } from './LeadInterface'; +import { userFields, userOpeations } from './UserDescription'; +import { IUser, IUserCompany } from './UserInterface'; +import { companyFields, companyOperations } from './CompanyDescription'; import { ICompany } from './CompanyInteface'; export class Intercom implements INodeType { @@ -70,7 +48,8 @@ export class Intercom implements INodeType { { name: 'Company', value: 'company', - description: 'Companies allow you to represent commercial organizations using your product', + description: + 'Companies allow you to represent commercial organizations using your product', }, { name: 'Lead', @@ -180,7 +159,7 @@ export class Intercom implements INodeType { if (additionalFields.companies) { const companies: ILeadCompany[] = []; // @ts-ignore - additionalFields.companies.forEach(o => { + additionalFields.companies.forEach((o) => { const company: ILeadCompany = {}; company.company_id = o; companies.push(company); @@ -188,17 +167,22 @@ export class Intercom implements INodeType { body.companies = companies; } if (!jsonActive) { - const customAttributesValues = (this.getNodeParameter('customAttributesUi', i) as IDataObject).customAttributesValues as IDataObject[]; + const customAttributesValues = ( + this.getNodeParameter('customAttributesUi', i) as IDataObject + ).customAttributesValues as IDataObject[]; if (customAttributesValues) { const customAttributes = {}; for (let i = 0; i < customAttributesValues.length; i++) { // @ts-ignore - customAttributes[customAttributesValues[i].name] = customAttributesValues[i].value; + customAttributes[customAttributesValues[i].name] = + customAttributesValues[i].value; } body.custom_attributes = customAttributes; } } else { - const customAttributesJson = validateJSON(this.getNodeParameter('customAttributesJson', i) as string); + const customAttributesJson = validateJSON( + this.getNodeParameter('customAttributesJson', i) as string, + ); if (customAttributesJson) { body.custom_attributes = customAttributesJson; } @@ -251,7 +235,14 @@ export class Intercom implements INodeType { try { if (returnAll === true) { - responseData = await intercomApiRequestAllItems.call(this, 'contacts', '/contacts', 'GET', {}, qs); + responseData = await intercomApiRequestAllItems.call( + this, + 'contacts', + '/contacts', + 'GET', + {}, + qs, + ); } else { qs.per_page = this.getNodeParameter('limit', i) as number; responseData = await intercomApiRequest.call(this, '/contacts', 'GET', {}, qs); @@ -338,7 +329,7 @@ export class Intercom implements INodeType { if (additionalFields.companies) { const companies: IUserCompany[] = []; // @ts-ignore - additionalFields.companies.forEach(o => { + additionalFields.companies.forEach((o) => { const company: IUserCompany = {}; company.company_id = o; companies.push(company); @@ -349,17 +340,22 @@ export class Intercom implements INodeType { body.session_count = additionalFields.sessionCount as number; } if (!jsonActive) { - const customAttributesValues = (this.getNodeParameter('customAttributesUi', i) as IDataObject).customAttributesValues as IDataObject[]; + const customAttributesValues = ( + this.getNodeParameter('customAttributesUi', i) as IDataObject + ).customAttributesValues as IDataObject[]; if (customAttributesValues) { const customAttributes = {}; for (let i = 0; i < customAttributesValues.length; i++) { // @ts-ignore - customAttributes[customAttributesValues[i].name] = customAttributesValues[i].value; + customAttributes[customAttributesValues[i].name] = + customAttributesValues[i].value; } body.custom_attributes = customAttributes; } } else { - const customAttributesJson = validateJSON(this.getNodeParameter('customAttributesJson', i) as string); + const customAttributesJson = validateJSON( + this.getNodeParameter('customAttributesJson', i) as string, + ); if (customAttributesJson) { body.custom_attributes = customAttributesJson; } @@ -393,7 +389,13 @@ export class Intercom implements INodeType { } try { if (selectBy === 'id') { - responseData = await intercomApiRequest.call(this, `/users/${value}`, 'GET', {}, qs); + responseData = await intercomApiRequest.call( + this, + `/users/${value}`, + 'GET', + {}, + qs, + ); } else { responseData = await intercomApiRequest.call(this, '/users', 'GET', {}, qs); } @@ -408,7 +410,14 @@ export class Intercom implements INodeType { try { if (returnAll === true) { - responseData = await intercomApiRequestAllItems.call(this, 'users', '/users', 'GET', {}, qs); + responseData = await intercomApiRequestAllItems.call( + this, + 'users', + '/users', + 'GET', + {}, + qs, + ); } else { qs.per_page = this.getNodeParameter('limit', i) as number; responseData = await intercomApiRequest.call(this, '/users', 'GET', {}, qs); @@ -423,7 +432,11 @@ export class Intercom implements INodeType { try { responseData = await intercomApiRequest.call(this, `/users/${id}`, 'DELETE'); } catch (error) { - throw new NodeOperationError(this.getNode(), `Intercom Error: ${JSON.stringify(error)}`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Intercom Error: ${JSON.stringify(error)}`, + { itemIndex: i }, + ); } } } @@ -455,17 +468,22 @@ export class Intercom implements INodeType { body.industry = additionalFields.industry as string; } if (!jsonActive) { - const customAttributesValues = (this.getNodeParameter('customAttributesUi', i) as IDataObject).customAttributesValues as IDataObject[]; + const customAttributesValues = ( + this.getNodeParameter('customAttributesUi', i) as IDataObject + ).customAttributesValues as IDataObject[]; if (customAttributesValues) { const customAttributes = {}; for (let i = 0; i < customAttributesValues.length; i++) { // @ts-ignore - customAttributes[customAttributesValues[i].name] = customAttributesValues[i].value; + customAttributes[customAttributesValues[i].name] = + customAttributesValues[i].value; } body.custom_attributes = customAttributes; } } else { - const customAttributesJson = validateJSON(this.getNodeParameter('customAttributesJson', i) as string); + const customAttributesJson = validateJSON( + this.getNodeParameter('customAttributesJson', i) as string, + ); if (customAttributesJson) { body.custom_attributes = customAttributesJson; } @@ -473,7 +491,11 @@ export class Intercom implements INodeType { try { responseData = await intercomApiRequest.call(this, '/companies', 'POST', body, qs); } catch (error) { - throw new NodeOperationError(this.getNode(), `Intercom Error: ${JSON.stringify(error)}`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Intercom Error: ${JSON.stringify(error)}`, + { itemIndex: i }, + ); } } if (operation === 'get') { @@ -487,12 +509,22 @@ export class Intercom implements INodeType { } try { if (selectBy === 'id') { - responseData = await intercomApiRequest.call(this, `/companies/${value}`, 'GET', {}, qs); + responseData = await intercomApiRequest.call( + this, + `/companies/${value}`, + 'GET', + {}, + qs, + ); } else { responseData = await intercomApiRequest.call(this, '/companies', 'GET', {}, qs); } } catch (error) { - throw new NodeOperationError(this.getNode(), `Intercom Error: ${JSON.stringify(error)}`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Intercom Error: ${JSON.stringify(error)}`, + { itemIndex: i }, + ); } } if (operation === 'getAll') { @@ -502,14 +534,25 @@ export class Intercom implements INodeType { try { if (returnAll === true) { - responseData = await intercomApiRequestAllItems.call(this, 'companies', '/companies', 'GET', {}, qs); + responseData = await intercomApiRequestAllItems.call( + this, + 'companies', + '/companies', + 'GET', + {}, + qs, + ); } else { qs.per_page = this.getNodeParameter('limit', i) as number; responseData = await intercomApiRequest.call(this, '/companies', 'GET', {}, qs); responseData = responseData.companies; } } catch (error) { - throw new NodeOperationError(this.getNode(), `Intercom Error: ${JSON.stringify(error)}`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Intercom Error: ${JSON.stringify(error)}`, + { itemIndex: i }, + ); } } if (operation === 'users') { @@ -524,18 +567,37 @@ export class Intercom implements INodeType { try { if (listBy === 'id') { if (returnAll === true) { - responseData = await intercomApiRequestAllItems.call(this, 'users', `/companies/${value}/users`, 'GET', {}, qs); + responseData = await intercomApiRequestAllItems.call( + this, + 'users', + `/companies/${value}/users`, + 'GET', + {}, + qs, + ); } else { qs.per_page = this.getNodeParameter('limit', i) as number; - responseData = await intercomApiRequest.call(this, `/companies/${value}/users`, 'GET', {}, qs); + responseData = await intercomApiRequest.call( + this, + `/companies/${value}/users`, + 'GET', + {}, + qs, + ); responseData = responseData.users; } - } else { qs.type = 'users'; if (returnAll === true) { - responseData = await intercomApiRequestAllItems.call(this, 'users', '/companies', 'GET', {}, qs); + responseData = await intercomApiRequestAllItems.call( + this, + 'users', + '/companies', + 'GET', + {}, + qs, + ); } else { qs.per_page = this.getNodeParameter('limit', i) as number; responseData = await intercomApiRequest.call(this, '/companies', 'GET', {}, qs); @@ -543,7 +605,11 @@ export class Intercom implements INodeType { } } } catch (error) { - throw new NodeOperationError(this.getNode(), `Intercom Error: ${JSON.stringify(error)}`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Intercom Error: ${JSON.stringify(error)}`, + { itemIndex: i }, + ); } } } diff --git a/packages/nodes-base/nodes/Intercom/LeadDescription.ts b/packages/nodes-base/nodes/Intercom/LeadDescription.ts index 4fe9d5b27c..bd5a898605 100644 --- a/packages/nodes-base/nodes/Intercom/LeadDescription.ts +++ b/packages/nodes-base/nodes/Intercom/LeadDescription.ts @@ -8,9 +8,7 @@ export const leadOpeations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'lead', - ], + resource: ['lead'], }, }, options: [ @@ -50,7 +48,6 @@ export const leadOpeations: INodeProperties[] = [ ]; export const leadFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* lead:delete */ /* -------------------------------------------------------------------------- */ @@ -60,12 +57,8 @@ export const leadFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'delete', - ], + resource: ['lead'], + operation: ['delete'], }, }, options: [ @@ -90,12 +83,8 @@ export const leadFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'delete', - ], + resource: ['lead'], + operation: ['delete'], }, }, description: 'Delete by value', @@ -110,12 +99,8 @@ export const leadFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'get', - ], + resource: ['lead'], + operation: ['get'], }, }, options: [ @@ -151,12 +136,8 @@ export const leadFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'get', - ], + resource: ['lead'], + operation: ['get'], }, }, description: 'View by value', @@ -171,12 +152,8 @@ export const leadFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'getAll', - ], + resource: ['lead'], + operation: ['getAll'], }, }, default: false, @@ -188,15 +165,9 @@ export const leadFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['lead'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -214,12 +185,8 @@ export const leadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'getAll', - ], + resource: ['lead'], + operation: ['getAll'], }, }, options: [ @@ -250,12 +217,8 @@ export const leadFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'update', - ], + resource: ['lead'], + operation: ['update'], }, }, options: [ @@ -281,12 +244,8 @@ export const leadFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'update', - ], + resource: ['lead'], + operation: ['update'], }, }, description: 'Value of the property to identify the lead to update', @@ -304,12 +263,8 @@ export const leadFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - ], + resource: ['lead'], + operation: ['create'], }, }, description: 'The email of the user', @@ -321,13 +276,8 @@ export const leadFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'create', - 'update', - ], - resource: [ - 'lead', - ], + operation: ['create', 'update'], + resource: ['lead'], }, }, }, @@ -339,13 +289,8 @@ export const leadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - 'update', - ], - resource: [ - 'lead', - ], + operation: ['create', 'update'], + resource: ['lead'], }, }, options: [ @@ -364,7 +309,8 @@ export const leadFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanies', }, default: [], - description: 'Identifies the companies this user belongs to. Choose from the list, or specify IDs using an expression.', + description: + 'Identifies the companies this user belongs to. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Email', @@ -374,12 +320,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - '/resource': [ - 'lead', - ], - '/operation': [ - 'update', - ], + '/resource': ['lead'], + '/operation': ['update'], }, }, description: 'The email of the user', @@ -410,7 +352,8 @@ export const leadFields: INodeProperties[] = [ name: 'updateLastRequestAt', type: 'boolean', default: false, - description: 'Whether to instruct Intercom to update the users last_request_at value to the current API service time in UTC. default value if not sent is false.', + description: + 'Whether to instruct Intercom to update the users last_request_at value to the current API service time in UTC. default value if not sent is false.', }, { displayName: 'UTM Campaign', @@ -458,20 +401,14 @@ export const leadFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['lead'], + operation: ['create', 'update'], + jsonParameters: [true], }, }, default: '', - description: 'A hash of key/value pairs to represent custom data you want to attribute to a user', + description: + 'A hash of key/value pairs to represent custom data you want to attribute to a user', }, { displayName: 'Custom Attributes', @@ -484,16 +421,9 @@ export const leadFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - 'update', - ], - jsonParameters: [ - false, - ], + resource: ['lead'], + operation: ['create', 'update'], + jsonParameters: [false], }, }, options: [ @@ -516,6 +446,7 @@ export const leadFields: INodeProperties[] = [ ], }, ], - description: 'A hash of key/value pairs to represent custom data you want to attribute to a user', + description: + 'A hash of key/value pairs to represent custom data you want to attribute to a user', }, ]; diff --git a/packages/nodes-base/nodes/Intercom/UserDescription.ts b/packages/nodes-base/nodes/Intercom/UserDescription.ts index c9d85f4569..5ed0f2661e 100644 --- a/packages/nodes-base/nodes/Intercom/UserDescription.ts +++ b/packages/nodes-base/nodes/Intercom/UserDescription.ts @@ -8,9 +8,7 @@ export const userOpeations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -50,7 +48,6 @@ export const userOpeations: INodeProperties[] = [ ]; export const userFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* user:delete */ /* -------------------------------------------------------------------------- */ @@ -61,12 +58,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'delete', - ], + resource: ['user'], + operation: ['delete'], }, }, default: '', @@ -82,12 +75,8 @@ export const userFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, default: false, @@ -99,15 +88,9 @@ export const userFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['user'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -125,12 +108,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, options: [ @@ -166,7 +145,6 @@ export const userFields: INodeProperties[] = [ ], }, - /* -------------------------------------------------------------------------- */ /* user:get */ /* -------------------------------------------------------------------------- */ @@ -176,12 +154,8 @@ export const userFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, options: [ @@ -209,12 +183,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, description: 'View by value', @@ -229,12 +199,8 @@ export const userFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, options: [ @@ -253,7 +219,6 @@ export const userFields: INodeProperties[] = [ value: 'userId', description: 'Automatically generated identifier for the user', }, - ], default: 'id', description: 'The property via which to query the user', @@ -266,12 +231,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, description: 'Value of the property to identify the user to update', @@ -286,24 +247,22 @@ export const userFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, options: [ { name: 'User ID', value: 'userId', - description: 'A unique string identifier for the user. It is required on creation if an email is not supplied.', + description: + 'A unique string identifier for the user. It is required on creation if an email is not supplied.', }, { name: 'Email', value: 'email', - description: 'The user\'s email address. It is required on creation if a user_id is not supplied.', + description: + "The user's email address. It is required on creation if a user_id is not supplied.", }, ], default: '', @@ -317,12 +276,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, description: 'Unique string identifier value', @@ -334,13 +289,8 @@ export const userFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'create', - 'update', - ], - resource: [ - 'user', - ], + operation: ['create', 'update'], + resource: ['user'], }, }, }, @@ -352,13 +302,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - 'update', - ], - resource: [ - 'user', - ], + operation: ['create', 'update'], + resource: ['user'], }, }, options: [ @@ -377,24 +322,19 @@ export const userFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanies', }, default: [], - description: 'Identifies the companies this user belongs to. Choose from the list, or specify IDs using an expression.', + description: + 'Identifies the companies this user belongs to. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Email', name: 'email', displayOptions: { show: { - '/operation': [ - 'update', - ], - '/resource': [ - 'user', - ], + '/operation': ['update'], + '/resource': ['user'], }, hide: { - '/updateBy': [ - 'email', - ], + '/updateBy': ['email'], }, }, type: 'string', @@ -430,18 +370,11 @@ export const userFields: INodeProperties[] = [ name: 'userId', displayOptions: { show: { - '/operation': [ - 'update', - ], - '/resource': [ - 'user', - ], + '/operation': ['update'], + '/resource': ['user'], }, hide: { - '/updateBy': [ - 'email', - 'userId', - ], + '/updateBy': ['email', 'userId'], }, }, type: 'string', @@ -462,7 +395,8 @@ export const userFields: INodeProperties[] = [ type: 'boolean', default: false, options: [], - description: 'Whether to instruct Intercom to update the users last_request_at value to the current API service time in UTC', + description: + 'Whether to instruct Intercom to update the users last_request_at value to the current API service time in UTC', }, { displayName: 'UTM Campaign', @@ -510,20 +444,14 @@ export const userFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['user'], + operation: ['create', 'update'], + jsonParameters: [true], }, }, default: '', - description: 'A hash of key/value pairs to represent custom data you want to attribute to a user', + description: + 'A hash of key/value pairs to represent custom data you want to attribute to a user', }, { displayName: 'Custom Attributes', @@ -536,16 +464,9 @@ export const userFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - 'update', - ], - jsonParameters: [ - false, - ], + resource: ['user'], + operation: ['create', 'update'], + jsonParameters: [false], }, }, options: [ @@ -568,6 +489,7 @@ export const userFields: INodeProperties[] = [ ], }, ], - description: 'A hash of key/value pairs to represent custom data you want to attribute to a user', + description: + 'A hash of key/value pairs to represent custom data you want to attribute to a user', }, ]; diff --git a/packages/nodes-base/nodes/Interval/Interval.node.ts b/packages/nodes-base/nodes/Interval/Interval.node.ts index 3a112528fa..cf36eb15af 100644 --- a/packages/nodes-base/nodes/Interval/Interval.node.ts +++ b/packages/nodes-base/nodes/Interval/Interval.node.ts @@ -6,7 +6,6 @@ import { NodeOperationError, } from 'n8n-workflow'; - export class Interval implements INodeType { description: INodeTypeDescription = { displayName: 'Interval', @@ -16,7 +15,8 @@ export class Interval implements INodeType { version: 1, description: 'Triggers the workflow in a given interval', eventTriggerDescription: '', - activationMessage: 'Your interval trigger will now trigger executions on the schedule you have defined.', + activationMessage: + 'Your interval trigger will now trigger executions on the schedule you have defined.', defaults: { name: 'Interval', color: '#00FF00', @@ -26,7 +26,8 @@ export class Interval implements INodeType { outputs: ['main'], properties: [ { - displayName: 'This workflow will run on the schedule you define here once you activate it.

For testing, you can also trigger it manually: by going back to the canvas and clicking ‘execute workflow’', + displayName: + 'This workflow will run on the schedule you define here once you activate it.

For testing, you can also trigger it manually: by going back to the canvas and clicking ‘execute workflow’', name: 'notice', type: 'notice', default: '', @@ -65,14 +66,15 @@ export class Interval implements INodeType { ], }; - - async trigger(this: ITriggerFunctions): Promise { const interval = this.getNodeParameter('interval') as number; const unit = this.getNodeParameter('unit') as string; if (interval <= 0) { - throw new NodeOperationError(this.getNode(), 'The interval has to be set to at least 1 or higher!'); + throw new NodeOperationError( + this.getNode(), + 'The interval has to be set to at least 1 or higher!', + ); } let intervalValue = interval; @@ -108,6 +110,5 @@ export class Interval implements INodeType { closeFunction, manualTriggerFunction, }; - } } diff --git a/packages/nodes-base/nodes/InvoiceNinja/ClientDescription.ts b/packages/nodes-base/nodes/InvoiceNinja/ClientDescription.ts index 35ce436f46..99bdc71ae0 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/ClientDescription.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/ClientDescription.ts @@ -8,9 +8,7 @@ export const clientOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'client', - ], + resource: ['client'], }, }, options: [ @@ -44,9 +42,9 @@ export const clientOperations: INodeProperties[] = [ ]; export const clientFields: INodeProperties[] = [ -/* -------------------------------------------------------------------------- */ -/* client:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* client:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Additional Fields', name: 'additionalFields', @@ -55,12 +53,8 @@ export const clientFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'client', - ], + operation: ['create'], + resource: ['client'], }, }, options: [ @@ -115,12 +109,8 @@ export const clientFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'client', - ], - operation: [ - 'create', - ], + resource: ['client'], + operation: ['create'], }, }, default: {}, @@ -163,7 +153,8 @@ export const clientFields: INodeProperties[] = [ displayName: 'Country Code Name or ID', name: 'countryCode', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCountryCodes', }, @@ -183,12 +174,8 @@ export const clientFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'client', - ], - operation: [ - 'create', - ], + resource: ['client'], + operation: ['create'], }, }, default: {}, @@ -236,12 +223,8 @@ export const clientFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'client', - ], - operation: [ - 'create', - ], + resource: ['client'], + operation: ['create'], }, }, default: {}, @@ -284,7 +267,8 @@ export const clientFields: INodeProperties[] = [ displayName: 'Country Code Name or ID', name: 'countryCode', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCountryCodes', }, @@ -294,9 +278,9 @@ export const clientFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* client:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* client:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Client ID', name: 'clientId', @@ -305,18 +289,14 @@ export const clientFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'client', - ], - operation: [ - 'delete', - ], + resource: ['client'], + operation: ['delete'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* client:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* client:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Client ID', name: 'clientId', @@ -325,12 +305,8 @@ export const clientFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'client', - ], - operation: [ - 'get', - ], + resource: ['client'], + operation: ['get'], }, }, }, @@ -342,12 +318,8 @@ export const clientFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'client', - ], + operation: ['get'], + resource: ['client'], }, }, options: [ @@ -365,21 +337,17 @@ export const clientFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* client:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* client:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'client', - ], - operation: [ - 'getAll', - ], + resource: ['client'], + operation: ['getAll'], }, }, default: false, @@ -391,15 +359,9 @@ export const clientFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'client', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['client'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -417,12 +379,8 @@ export const clientFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'client', - ], + operation: ['getAll'], + resource: ['client'], }, }, options: [ diff --git a/packages/nodes-base/nodes/InvoiceNinja/ExpenseDescription.ts b/packages/nodes-base/nodes/InvoiceNinja/ExpenseDescription.ts index 3614edfb36..e51d36c2f2 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/ExpenseDescription.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/ExpenseDescription.ts @@ -8,9 +8,7 @@ export const expenseOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'expense', - ], + resource: ['expense'], }, }, options: [ @@ -44,9 +42,9 @@ export const expenseOperations: INodeProperties[] = [ ]; export const expenseFields: INodeProperties[] = [ -/* -------------------------------------------------------------------------- */ -/* expense:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* expense:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Additional Fields', name: 'additionalFields', @@ -55,12 +53,8 @@ export const expenseFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'expense', - ], + operation: ['create'], + resource: ['expense'], }, }, options: [ @@ -80,7 +74,8 @@ export const expenseFields: INodeProperties[] = [ displayName: 'Client Name or ID', name: 'client', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getClients', }, @@ -102,7 +97,8 @@ export const expenseFields: INodeProperties[] = [ displayName: 'Category Name or ID', name: 'category', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getExpenseCategories', }, @@ -308,7 +304,8 @@ export const expenseFields: INodeProperties[] = [ displayName: 'Vendor Name or ID', name: 'vendor', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getVendors', }, @@ -316,9 +313,9 @@ export const expenseFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* expense:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* expense:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Expense ID', name: 'expenseId', @@ -327,18 +324,14 @@ export const expenseFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'expense', - ], - operation: [ - 'delete', - ], + resource: ['expense'], + operation: ['delete'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* expense:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* expense:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Expense ID', name: 'expenseId', @@ -347,30 +340,22 @@ export const expenseFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'expense', - ], - operation: [ - 'get', - ], + resource: ['expense'], + operation: ['get'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* expense:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* expense:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'expense', - ], - operation: [ - 'getAll', - ], + resource: ['expense'], + operation: ['getAll'], }, }, default: false, @@ -382,15 +367,9 @@ export const expenseFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'expense', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['expense'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts b/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts index 072ef66fb0..ef2dc4042a 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,15 +7,20 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - get, -} from 'lodash'; +import { get } from 'lodash'; -export async function invoiceNinjaApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query?: IDataObject, uri?: string): Promise { // tslint:disable-line:no-any +export async function invoiceNinjaApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query?: IDataObject, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('invoiceNinjaApi'); const baseUrl = credentials!.url || 'https://app.invoiceninja.com'; @@ -39,8 +42,16 @@ export async function invoiceNinjaApiRequest(this: IHookFunctions | IExecuteFunc } } -export async function invoiceNinjaApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function invoiceNinjaApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; diff --git a/packages/nodes-base/nodes/InvoiceNinja/ISOCountryCodes.ts b/packages/nodes-base/nodes/InvoiceNinja/ISOCountryCodes.ts index 494faf610e..2b78305fa3 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/ISOCountryCodes.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/ISOCountryCodes.ts @@ -2,1580 +2,1580 @@ import { IDataObject } from 'n8n-workflow'; export const countryCodes = [ { - 'name': 'Afghanistan', - 'alpha2': 'AF', - 'alpha3': 'AFG', - 'numeric': '004', + name: 'Afghanistan', + alpha2: 'AF', + alpha3: 'AFG', + numeric: '004', }, { - 'name': 'Åland Islands', - 'alpha2': 'AX', - 'alpha3': 'ALA', - 'numeric': '248', - 'altName': 'Aland Islands', + name: 'Åland Islands', + alpha2: 'AX', + alpha3: 'ALA', + numeric: '248', + altName: 'Aland Islands', }, { - 'name': 'Albania', - 'alpha2': 'AL', - 'alpha3': 'ALB', - 'numeric': '008', + name: 'Albania', + alpha2: 'AL', + alpha3: 'ALB', + numeric: '008', }, { - 'name': 'Algeria', - 'alpha2': 'DZ', - 'alpha3': 'DZA', - 'numeric': '012', + name: 'Algeria', + alpha2: 'DZ', + alpha3: 'DZA', + numeric: '012', }, { - 'name': 'American Samoa', - 'alpha2': 'AS', - 'alpha3': 'ASM', - 'numeric': '016', + name: 'American Samoa', + alpha2: 'AS', + alpha3: 'ASM', + numeric: '016', }, { - 'name': 'Andorra', - 'alpha2': 'AD', - 'alpha3': 'AND', - 'numeric': '020', + name: 'Andorra', + alpha2: 'AD', + alpha3: 'AND', + numeric: '020', }, { - 'name': 'Angola', - 'alpha2': 'AO', - 'alpha3': 'AGO', - 'numeric': '024', + name: 'Angola', + alpha2: 'AO', + alpha3: 'AGO', + numeric: '024', }, { - 'name': 'Anguilla', - 'alpha2': 'AI', - 'alpha3': 'AIA', - 'numeric': '660', + name: 'Anguilla', + alpha2: 'AI', + alpha3: 'AIA', + numeric: '660', }, { - 'name': 'Antarctica', - 'alpha2': 'AQ', - 'alpha3': 'ATA', - 'numeric': '010', + name: 'Antarctica', + alpha2: 'AQ', + alpha3: 'ATA', + numeric: '010', }, { - 'name': 'Antigua and Barbuda', - 'alpha2': 'AG', - 'alpha3': 'ATG', - 'numeric': '028', + name: 'Antigua and Barbuda', + alpha2: 'AG', + alpha3: 'ATG', + numeric: '028', }, { - 'name': 'Argentina', - 'alpha2': 'AR', - 'alpha3': 'ARG', - 'numeric': '032', + name: 'Argentina', + alpha2: 'AR', + alpha3: 'ARG', + numeric: '032', }, { - 'name': 'Armenia', - 'alpha2': 'AM', - 'alpha3': 'ARM', - 'numeric': '051', + name: 'Armenia', + alpha2: 'AM', + alpha3: 'ARM', + numeric: '051', }, { - 'name': 'Aruba', - 'alpha2': 'AW', - 'alpha3': 'ABW', - 'numeric': '533', + name: 'Aruba', + alpha2: 'AW', + alpha3: 'ABW', + numeric: '533', }, { - 'name': 'Australia', - 'alpha2': 'AU', - 'alpha3': 'AUS', - 'numeric': '036', + name: 'Australia', + alpha2: 'AU', + alpha3: 'AUS', + numeric: '036', }, { - 'name': 'Austria', - 'alpha2': 'AT', - 'alpha3': 'AUT', - 'numeric': '040', + name: 'Austria', + alpha2: 'AT', + alpha3: 'AUT', + numeric: '040', }, { - 'name': 'Azerbaijan', - 'alpha2': 'AZ', - 'alpha3': 'AZE', - 'numeric': '031', + name: 'Azerbaijan', + alpha2: 'AZ', + alpha3: 'AZE', + numeric: '031', }, { - 'name': 'Bahamas (the)', - 'alpha2': 'BS', - 'alpha3': 'BHS', - 'numeric': '044', - 'altName': 'Bahamas', + name: 'Bahamas (the)', + alpha2: 'BS', + alpha3: 'BHS', + numeric: '044', + altName: 'Bahamas', }, { - 'name': 'Bahrain', - 'alpha2': 'BH', - 'alpha3': 'BHR', - 'numeric': '048', + name: 'Bahrain', + alpha2: 'BH', + alpha3: 'BHR', + numeric: '048', }, { - 'name': 'Bangladesh', - 'alpha2': 'BD', - 'alpha3': 'BGD', - 'numeric': '050', + name: 'Bangladesh', + alpha2: 'BD', + alpha3: 'BGD', + numeric: '050', }, { - 'name': 'Barbados', - 'alpha2': 'BB', - 'alpha3': 'BRB', - 'numeric': '052', + name: 'Barbados', + alpha2: 'BB', + alpha3: 'BRB', + numeric: '052', }, { - 'name': 'Belarus', - 'alpha2': 'BY', - 'alpha3': 'BLR', - 'numeric': '112', + name: 'Belarus', + alpha2: 'BY', + alpha3: 'BLR', + numeric: '112', }, { - 'name': 'Belgium', - 'alpha2': 'BE', - 'alpha3': 'BEL', - 'numeric': '056', + name: 'Belgium', + alpha2: 'BE', + alpha3: 'BEL', + numeric: '056', }, { - 'name': 'Belize', - 'alpha2': 'BZ', - 'alpha3': 'BLZ', - 'numeric': '084', + name: 'Belize', + alpha2: 'BZ', + alpha3: 'BLZ', + numeric: '084', }, { - 'name': 'Benin', - 'alpha2': 'BJ', - 'alpha3': 'BEN', - 'numeric': '204', + name: 'Benin', + alpha2: 'BJ', + alpha3: 'BEN', + numeric: '204', }, { - 'name': 'Bermuda', - 'alpha2': 'BM', - 'alpha3': 'BMU', - 'numeric': '060', + name: 'Bermuda', + alpha2: 'BM', + alpha3: 'BMU', + numeric: '060', }, { - 'name': 'Bhutan', - 'alpha2': 'BT', - 'alpha3': 'BTN', - 'numeric': '064', + name: 'Bhutan', + alpha2: 'BT', + alpha3: 'BTN', + numeric: '064', }, { - 'name': 'Bolivia (Plurinational State of)', - 'alpha2': 'BO', - 'alpha3': 'BOL', - 'numeric': '068', - 'altName': 'Bolivia', + name: 'Bolivia (Plurinational State of)', + alpha2: 'BO', + alpha3: 'BOL', + numeric: '068', + altName: 'Bolivia', }, { - 'name': 'Bonaire, Sint Eustatius and Saba', - 'alpha2': 'BQ', - 'alpha3': 'BES', - 'numeric': '535', + name: 'Bonaire, Sint Eustatius and Saba', + alpha2: 'BQ', + alpha3: 'BES', + numeric: '535', }, { - 'name': 'Bosnia and Herzegovina', - 'alpha2': 'BA', - 'alpha3': 'BIH', - 'numeric': '070', + name: 'Bosnia and Herzegovina', + alpha2: 'BA', + alpha3: 'BIH', + numeric: '070', }, { - 'name': 'Botswana', - 'alpha2': 'BW', - 'alpha3': 'BWA', - 'numeric': '072', + name: 'Botswana', + alpha2: 'BW', + alpha3: 'BWA', + numeric: '072', }, { - 'name': 'Bouvet Island', - 'alpha2': 'BV', - 'alpha3': 'BVT', - 'numeric': '074', + name: 'Bouvet Island', + alpha2: 'BV', + alpha3: 'BVT', + numeric: '074', }, { - 'name': 'Brazil', - 'alpha2': 'BR', - 'alpha3': 'BRA', - 'numeric': '076', + name: 'Brazil', + alpha2: 'BR', + alpha3: 'BRA', + numeric: '076', }, { - 'name': 'British Indian Ocean Territory (the)', - 'alpha2': 'IO', - 'alpha3': 'IOT', - 'numeric': '086', - 'altName': 'British Indian Ocean Territory', + name: 'British Indian Ocean Territory (the)', + alpha2: 'IO', + alpha3: 'IOT', + numeric: '086', + altName: 'British Indian Ocean Territory', }, { - 'name': 'Brunei Darussalam', - 'alpha2': 'BN', - 'alpha3': 'BRN', - 'numeric': '096', - 'shortName': 'Brunei', + name: 'Brunei Darussalam', + alpha2: 'BN', + alpha3: 'BRN', + numeric: '096', + shortName: 'Brunei', }, { - 'name': 'Bulgaria', - 'alpha2': 'BG', - 'alpha3': 'BGR', - 'numeric': '100', + name: 'Bulgaria', + alpha2: 'BG', + alpha3: 'BGR', + numeric: '100', }, { - 'name': 'Burkina Faso', - 'alpha2': 'BF', - 'alpha3': 'BFA', - 'numeric': '854', + name: 'Burkina Faso', + alpha2: 'BF', + alpha3: 'BFA', + numeric: '854', }, { - 'name': 'Burundi', - 'alpha2': 'BI', - 'alpha3': 'BDI', - 'numeric': '108', + name: 'Burundi', + alpha2: 'BI', + alpha3: 'BDI', + numeric: '108', }, { - 'name': 'Cabo Verde', - 'alpha2': 'CV', - 'alpha3': 'CPV', - 'numeric': '132', - 'altName': 'Cape Verde', + name: 'Cabo Verde', + alpha2: 'CV', + alpha3: 'CPV', + numeric: '132', + altName: 'Cape Verde', }, { - 'name': 'Cambodia', - 'alpha2': 'KH', - 'alpha3': 'KHM', - 'numeric': '116', + name: 'Cambodia', + alpha2: 'KH', + alpha3: 'KHM', + numeric: '116', }, { - 'name': 'Cameroon', - 'alpha2': 'CM', - 'alpha3': 'CMR', - 'numeric': '120', + name: 'Cameroon', + alpha2: 'CM', + alpha3: 'CMR', + numeric: '120', }, { - 'name': 'Canada', - 'alpha2': 'CA', - 'alpha3': 'CAN', - 'numeric': '124', + name: 'Canada', + alpha2: 'CA', + alpha3: 'CAN', + numeric: '124', }, { - 'name': 'Cayman Islands (the)', - 'alpha2': 'KY', - 'alpha3': 'CYM', - 'numeric': '136', - 'altName': 'Cayman Islands', + name: 'Cayman Islands (the)', + alpha2: 'KY', + alpha3: 'CYM', + numeric: '136', + altName: 'Cayman Islands', }, { - 'name': 'Central African Republic (the)', - 'alpha2': 'CF', - 'alpha3': 'CAF', - 'numeric': '140', - 'altName': 'Central African Republic', + name: 'Central African Republic (the)', + alpha2: 'CF', + alpha3: 'CAF', + numeric: '140', + altName: 'Central African Republic', }, { - 'name': 'Chad', - 'alpha2': 'TD', - 'alpha3': 'TCD', - 'numeric': '148', + name: 'Chad', + alpha2: 'TD', + alpha3: 'TCD', + numeric: '148', }, { - 'name': 'Chile', - 'alpha2': 'CL', - 'alpha3': 'CHL', - 'numeric': '152', + name: 'Chile', + alpha2: 'CL', + alpha3: 'CHL', + numeric: '152', }, { - 'name': 'China', - 'alpha2': 'CN', - 'alpha3': 'CHN', - 'numeric': '156', + name: 'China', + alpha2: 'CN', + alpha3: 'CHN', + numeric: '156', }, { - 'name': 'Christmas Island', - 'alpha2': 'CX', - 'alpha3': 'CXR', - 'numeric': '162', + name: 'Christmas Island', + alpha2: 'CX', + alpha3: 'CXR', + numeric: '162', }, { - 'name': 'Cocos (Keeling) Islands (the)', - 'alpha2': 'CC', - 'alpha3': 'CCK', - 'numeric': '166', - 'altName': 'Cocos (Keeling) Islands', - 'shortName': 'Cocos Islands', + name: 'Cocos (Keeling) Islands (the)', + alpha2: 'CC', + alpha3: 'CCK', + numeric: '166', + altName: 'Cocos (Keeling) Islands', + shortName: 'Cocos Islands', }, { - 'name': 'Colombia', - 'alpha2': 'CO', - 'alpha3': 'COL', - 'numeric': '170', + name: 'Colombia', + alpha2: 'CO', + alpha3: 'COL', + numeric: '170', }, { - 'name': 'Comoros (the)', - 'alpha2': 'KM', - 'alpha3': 'COM', - 'numeric': '174', - 'altName': 'Comoros', + name: 'Comoros (the)', + alpha2: 'KM', + alpha3: 'COM', + numeric: '174', + altName: 'Comoros', }, { - 'name': 'Congo (the Democratic Republic of the)', - 'alpha2': 'CD', - 'alpha3': 'COD', - 'numeric': '180', - 'altName': 'Congo, (Kinshasa)', - 'shortName': 'Democratic Republic of the Congo', + name: 'Congo (the Democratic Republic of the)', + alpha2: 'CD', + alpha3: 'COD', + numeric: '180', + altName: 'Congo, (Kinshasa)', + shortName: 'Democratic Republic of the Congo', }, { - 'name': 'Congo (the)', - 'alpha2': 'CG', - 'alpha3': 'COG', - 'numeric': '178', - 'altName': 'Congo (Brazzaville)', - 'shortName': 'Republic of the Congo', + name: 'Congo (the)', + alpha2: 'CG', + alpha3: 'COG', + numeric: '178', + altName: 'Congo (Brazzaville)', + shortName: 'Republic of the Congo', }, { - 'name': 'Cook Islands (the)', - 'alpha2': 'CK', - 'alpha3': 'COK', - 'numeric': '184', - 'altName': 'Cook Islands', + name: 'Cook Islands (the)', + alpha2: 'CK', + alpha3: 'COK', + numeric: '184', + altName: 'Cook Islands', }, { - 'name': 'Costa Rica', - 'alpha2': 'CR', - 'alpha3': 'CRI', - 'numeric': '188', + name: 'Costa Rica', + alpha2: 'CR', + alpha3: 'CRI', + numeric: '188', }, { - 'name': 'Côte d\'Ivoire', - 'alpha2': 'CI', - 'alpha3': 'CIV', - 'numeric': '384', - 'shortName': 'Ivory Coast', + name: "Côte d'Ivoire", + alpha2: 'CI', + alpha3: 'CIV', + numeric: '384', + shortName: 'Ivory Coast', }, { - 'name': 'Croatia', - 'alpha2': 'HR', - 'alpha3': 'HRV', - 'numeric': '191', + name: 'Croatia', + alpha2: 'HR', + alpha3: 'HRV', + numeric: '191', }, { - 'name': 'Cuba', - 'alpha2': 'CU', - 'alpha3': 'CUB', - 'numeric': '192', + name: 'Cuba', + alpha2: 'CU', + alpha3: 'CUB', + numeric: '192', }, { - 'name': 'Curaçao', - 'alpha2': 'CW', - 'alpha3': 'CUW', - 'numeric': '531', - 'shortName': 'Curacao', + name: 'Curaçao', + alpha2: 'CW', + alpha3: 'CUW', + numeric: '531', + shortName: 'Curacao', }, { - 'name': 'Cyprus', - 'alpha2': 'CY', - 'alpha3': 'CYP', - 'numeric': '196', + name: 'Cyprus', + alpha2: 'CY', + alpha3: 'CYP', + numeric: '196', }, { - 'name': 'Czechia', - 'alpha2': 'CZ', - 'alpha3': 'CZE', - 'numeric': '203', - 'altName': 'Czech Republic', + name: 'Czechia', + alpha2: 'CZ', + alpha3: 'CZE', + numeric: '203', + altName: 'Czech Republic', }, { - 'name': 'Denmark', - 'alpha2': 'DK', - 'alpha3': 'DNK', - 'numeric': '208', + name: 'Denmark', + alpha2: 'DK', + alpha3: 'DNK', + numeric: '208', }, { - 'name': 'Djibouti', - 'alpha2': 'DJ', - 'alpha3': 'DJI', - 'numeric': '262', + name: 'Djibouti', + alpha2: 'DJ', + alpha3: 'DJI', + numeric: '262', }, { - 'name': 'Dominica', - 'alpha2': 'DM', - 'alpha3': 'DMA', - 'numeric': '212', + name: 'Dominica', + alpha2: 'DM', + alpha3: 'DMA', + numeric: '212', }, { - 'name': 'Dominican Republic (the)', - 'alpha2': 'DO', - 'alpha3': 'DOM', - 'numeric': '214', - 'altName': 'Dominican Republic', + name: 'Dominican Republic (the)', + alpha2: 'DO', + alpha3: 'DOM', + numeric: '214', + altName: 'Dominican Republic', }, { - 'name': 'Ecuador', - 'alpha2': 'EC', - 'alpha3': 'ECU', - 'numeric': '218', + name: 'Ecuador', + alpha2: 'EC', + alpha3: 'ECU', + numeric: '218', }, { - 'name': 'Egypt', - 'alpha2': 'EG', - 'alpha3': 'EGY', - 'numeric': '818', + name: 'Egypt', + alpha2: 'EG', + alpha3: 'EGY', + numeric: '818', }, { - 'name': 'El Salvador', - 'alpha2': 'SV', - 'alpha3': 'SLV', - 'numeric': '222', + name: 'El Salvador', + alpha2: 'SV', + alpha3: 'SLV', + numeric: '222', }, { - 'name': 'Equatorial Guinea', - 'alpha2': 'GQ', - 'alpha3': 'GNQ', - 'numeric': '226', + name: 'Equatorial Guinea', + alpha2: 'GQ', + alpha3: 'GNQ', + numeric: '226', }, { - 'name': 'Eritrea', - 'alpha2': 'ER', - 'alpha3': 'ERI', - 'numeric': '232', + name: 'Eritrea', + alpha2: 'ER', + alpha3: 'ERI', + numeric: '232', }, { - 'name': 'Estonia', - 'alpha2': 'EE', - 'alpha3': 'EST', - 'numeric': '233', + name: 'Estonia', + alpha2: 'EE', + alpha3: 'EST', + numeric: '233', }, { - 'name': 'Ethiopia', - 'alpha2': 'ET', - 'alpha3': 'ETH', - 'numeric': '231', + name: 'Ethiopia', + alpha2: 'ET', + alpha3: 'ETH', + numeric: '231', }, { - 'name': 'Falkland Islands (the) [Malvinas]', - 'alpha2': 'FK', - 'alpha3': 'FLK', - 'numeric': '238', - 'altName': 'Falkland Islands (Malvinas)', - 'shortName': 'Falkland Islands', + name: 'Falkland Islands (the) [Malvinas]', + alpha2: 'FK', + alpha3: 'FLK', + numeric: '238', + altName: 'Falkland Islands (Malvinas)', + shortName: 'Falkland Islands', }, { - 'name': 'Faroe Islands (the)', - 'alpha2': 'FO', - 'alpha3': 'FRO', - 'numeric': '234', - 'altName': 'Faroe Islands', + name: 'Faroe Islands (the)', + alpha2: 'FO', + alpha3: 'FRO', + numeric: '234', + altName: 'Faroe Islands', }, { - 'name': 'Fiji', - 'alpha2': 'FJ', - 'alpha3': 'FJI', - 'numeric': '242', + name: 'Fiji', + alpha2: 'FJ', + alpha3: 'FJI', + numeric: '242', }, { - 'name': 'Finland', - 'alpha2': 'FI', - 'alpha3': 'FIN', - 'numeric': '246', + name: 'Finland', + alpha2: 'FI', + alpha3: 'FIN', + numeric: '246', }, { - 'name': 'France', - 'alpha2': 'FR', - 'alpha3': 'FRA', - 'numeric': '250', + name: 'France', + alpha2: 'FR', + alpha3: 'FRA', + numeric: '250', }, { - 'name': 'French Guiana', - 'alpha2': 'GF', - 'alpha3': 'GUF', - 'numeric': '254', + name: 'French Guiana', + alpha2: 'GF', + alpha3: 'GUF', + numeric: '254', }, { - 'name': 'French Polynesia', - 'alpha2': 'PF', - 'alpha3': 'PYF', - 'numeric': '258', + name: 'French Polynesia', + alpha2: 'PF', + alpha3: 'PYF', + numeric: '258', }, { - 'name': 'French Southern Territories (the)', - 'alpha2': 'TF', - 'alpha3': 'ATF', - 'numeric': '260', - 'altName': 'French Southern Territories', + name: 'French Southern Territories (the)', + alpha2: 'TF', + alpha3: 'ATF', + numeric: '260', + altName: 'French Southern Territories', }, { - 'name': 'Gabon', - 'alpha2': 'GA', - 'alpha3': 'GAB', - 'numeric': '266', + name: 'Gabon', + alpha2: 'GA', + alpha3: 'GAB', + numeric: '266', }, { - 'name': 'Gambia (the)', - 'alpha2': 'GM', - 'alpha3': 'GMB', - 'numeric': '270', - 'altName': 'Gambia', + name: 'Gambia (the)', + alpha2: 'GM', + alpha3: 'GMB', + numeric: '270', + altName: 'Gambia', }, { - 'name': 'Georgia', - 'alpha2': 'GE', - 'alpha3': 'GEO', - 'numeric': '268', + name: 'Georgia', + alpha2: 'GE', + alpha3: 'GEO', + numeric: '268', }, { - 'name': 'Germany', - 'alpha2': 'DE', - 'alpha3': 'DEU', - 'numeric': '276', + name: 'Germany', + alpha2: 'DE', + alpha3: 'DEU', + numeric: '276', }, { - 'name': 'Ghana', - 'alpha2': 'GH', - 'alpha3': 'GHA', - 'numeric': '288', + name: 'Ghana', + alpha2: 'GH', + alpha3: 'GHA', + numeric: '288', }, { - 'name': 'Gibraltar', - 'alpha2': 'GI', - 'alpha3': 'GIB', - 'numeric': '292', + name: 'Gibraltar', + alpha2: 'GI', + alpha3: 'GIB', + numeric: '292', }, { - 'name': 'Greece', - 'alpha2': 'GR', - 'alpha3': 'GRC', - 'numeric': '300', + name: 'Greece', + alpha2: 'GR', + alpha3: 'GRC', + numeric: '300', }, { - 'name': 'Greenland', - 'alpha2': 'GL', - 'alpha3': 'GRL', - 'numeric': '304', + name: 'Greenland', + alpha2: 'GL', + alpha3: 'GRL', + numeric: '304', }, { - 'name': 'Grenada', - 'alpha2': 'GD', - 'alpha3': 'GRD', - 'numeric': '308', + name: 'Grenada', + alpha2: 'GD', + alpha3: 'GRD', + numeric: '308', }, { - 'name': 'Guadeloupe', - 'alpha2': 'GP', - 'alpha3': 'GLP', - 'numeric': '312', + name: 'Guadeloupe', + alpha2: 'GP', + alpha3: 'GLP', + numeric: '312', }, { - 'name': 'Guam', - 'alpha2': 'GU', - 'alpha3': 'GUM', - 'numeric': '316', + name: 'Guam', + alpha2: 'GU', + alpha3: 'GUM', + numeric: '316', }, { - 'name': 'Guatemala', - 'alpha2': 'GT', - 'alpha3': 'GTM', - 'numeric': '320', + name: 'Guatemala', + alpha2: 'GT', + alpha3: 'GTM', + numeric: '320', }, { - 'name': 'Guernsey', - 'alpha2': 'GG', - 'alpha3': 'GGY', - 'numeric': '831', + name: 'Guernsey', + alpha2: 'GG', + alpha3: 'GGY', + numeric: '831', }, { - 'name': 'Guinea', - 'alpha2': 'GN', - 'alpha3': 'GIN', - 'numeric': '324', + name: 'Guinea', + alpha2: 'GN', + alpha3: 'GIN', + numeric: '324', }, { - 'name': 'Guinea-Bissau', - 'alpha2': 'GW', - 'alpha3': 'GNB', - 'numeric': '624', + name: 'Guinea-Bissau', + alpha2: 'GW', + alpha3: 'GNB', + numeric: '624', }, { - 'name': 'Guyana', - 'alpha2': 'GY', - 'alpha3': 'GUY', - 'numeric': '328', + name: 'Guyana', + alpha2: 'GY', + alpha3: 'GUY', + numeric: '328', }, { - 'name': 'Haiti', - 'alpha2': 'HT', - 'alpha3': 'HTI', - 'numeric': '332', + name: 'Haiti', + alpha2: 'HT', + alpha3: 'HTI', + numeric: '332', }, { - 'name': 'Heard Island and McDonald Islands', - 'alpha2': 'HM', - 'alpha3': 'HMD', - 'numeric': '334', - 'altName': 'Heard and Mcdonald Islands', + name: 'Heard Island and McDonald Islands', + alpha2: 'HM', + alpha3: 'HMD', + numeric: '334', + altName: 'Heard and Mcdonald Islands', }, { - 'name': 'Holy See (the)', - 'alpha2': 'VA', - 'alpha3': 'VAT', - 'numeric': '336', - 'altName': 'Holy See (Vatican City State)', - 'shortName': 'Vatican', + name: 'Holy See (the)', + alpha2: 'VA', + alpha3: 'VAT', + numeric: '336', + altName: 'Holy See (Vatican City State)', + shortName: 'Vatican', }, { - 'name': 'Honduras', - 'alpha2': 'HN', - 'alpha3': 'HND', - 'numeric': '340', + name: 'Honduras', + alpha2: 'HN', + alpha3: 'HND', + numeric: '340', }, { - 'name': 'Hong Kong', - 'alpha2': 'HK', - 'alpha3': 'HKG', - 'numeric': '344', - 'altName': 'Hong Kong, SAR China', + name: 'Hong Kong', + alpha2: 'HK', + alpha3: 'HKG', + numeric: '344', + altName: 'Hong Kong, SAR China', }, { - 'name': 'Hungary', - 'alpha2': 'HU', - 'alpha3': 'HUN', - 'numeric': '348', + name: 'Hungary', + alpha2: 'HU', + alpha3: 'HUN', + numeric: '348', }, { - 'name': 'Iceland', - 'alpha2': 'IS', - 'alpha3': 'ISL', - 'numeric': '352', + name: 'Iceland', + alpha2: 'IS', + alpha3: 'ISL', + numeric: '352', }, { - 'name': 'India', - 'alpha2': 'IN', - 'alpha3': 'IND', - 'numeric': '356', + name: 'India', + alpha2: 'IN', + alpha3: 'IND', + numeric: '356', }, { - 'name': 'Indonesia', - 'alpha2': 'ID', - 'alpha3': 'IDN', - 'numeric': '360', + name: 'Indonesia', + alpha2: 'ID', + alpha3: 'IDN', + numeric: '360', }, { - 'name': 'Iran (Islamic Republic of)', - 'alpha2': 'IR', - 'alpha3': 'IRN', - 'numeric': '364', - 'altName': 'Iran, Islamic Republic of', - 'shortName': 'Iran', + name: 'Iran (Islamic Republic of)', + alpha2: 'IR', + alpha3: 'IRN', + numeric: '364', + altName: 'Iran, Islamic Republic of', + shortName: 'Iran', }, { - 'name': 'Iraq', - 'alpha2': 'IQ', - 'alpha3': 'IRQ', - 'numeric': '368', + name: 'Iraq', + alpha2: 'IQ', + alpha3: 'IRQ', + numeric: '368', }, { - 'name': 'Ireland', - 'alpha2': 'IE', - 'alpha3': 'IRL', - 'numeric': '372', + name: 'Ireland', + alpha2: 'IE', + alpha3: 'IRL', + numeric: '372', }, { - 'name': 'Isle of Man', - 'alpha2': 'IM', - 'alpha3': 'IMN', - 'numeric': '833', + name: 'Isle of Man', + alpha2: 'IM', + alpha3: 'IMN', + numeric: '833', }, { - 'name': 'Israel', - 'alpha2': 'IL', - 'alpha3': 'ISR', - 'numeric': '376', + name: 'Israel', + alpha2: 'IL', + alpha3: 'ISR', + numeric: '376', }, { - 'name': 'Italy', - 'alpha2': 'IT', - 'alpha3': 'ITA', - 'numeric': '380', + name: 'Italy', + alpha2: 'IT', + alpha3: 'ITA', + numeric: '380', }, { - 'name': 'Jamaica', - 'alpha2': 'JM', - 'alpha3': 'JAM', - 'numeric': '388', + name: 'Jamaica', + alpha2: 'JM', + alpha3: 'JAM', + numeric: '388', }, { - 'name': 'Japan', - 'alpha2': 'JP', - 'alpha3': 'JPN', - 'numeric': '392', + name: 'Japan', + alpha2: 'JP', + alpha3: 'JPN', + numeric: '392', }, { - 'name': 'Jersey', - 'alpha2': 'JE', - 'alpha3': 'JEY', - 'numeric': '832', + name: 'Jersey', + alpha2: 'JE', + alpha3: 'JEY', + numeric: '832', }, { - 'name': 'Jordan', - 'alpha2': 'JO', - 'alpha3': 'JOR', - 'numeric': '400', + name: 'Jordan', + alpha2: 'JO', + alpha3: 'JOR', + numeric: '400', }, { - 'name': 'Kazakhstan', - 'alpha2': 'KZ', - 'alpha3': 'KAZ', - 'numeric': '398', + name: 'Kazakhstan', + alpha2: 'KZ', + alpha3: 'KAZ', + numeric: '398', }, { - 'name': 'Kenya', - 'alpha2': 'KE', - 'alpha3': 'KEN', - 'numeric': '404', + name: 'Kenya', + alpha2: 'KE', + alpha3: 'KEN', + numeric: '404', }, { - 'name': 'Kiribati', - 'alpha2': 'KI', - 'alpha3': 'KIR', - 'numeric': '296', + name: 'Kiribati', + alpha2: 'KI', + alpha3: 'KIR', + numeric: '296', }, { - 'name': 'Korea (the Democratic People\'s Republic of)', - 'alpha2': 'KP', - 'alpha3': 'PRK', - 'numeric': '408', - 'altName': 'Korea (North)', - 'shortName': 'North Korea', + name: "Korea (the Democratic People's Republic of)", + alpha2: 'KP', + alpha3: 'PRK', + numeric: '408', + altName: 'Korea (North)', + shortName: 'North Korea', }, { - 'name': 'Korea (the Republic of)', - 'alpha2': 'KR', - 'alpha3': 'KOR', - 'numeric': '410', - 'altName': 'Korea (South)', - 'shortName': 'South Korea', + name: 'Korea (the Republic of)', + alpha2: 'KR', + alpha3: 'KOR', + numeric: '410', + altName: 'Korea (South)', + shortName: 'South Korea', }, { - 'name': 'Kuwait', - 'alpha2': 'KW', - 'alpha3': 'KWT', - 'numeric': '414', + name: 'Kuwait', + alpha2: 'KW', + alpha3: 'KWT', + numeric: '414', }, { - 'name': 'Kyrgyzstan', - 'alpha2': 'KG', - 'alpha3': 'KGZ', - 'numeric': '417', + name: 'Kyrgyzstan', + alpha2: 'KG', + alpha3: 'KGZ', + numeric: '417', }, { - 'name': 'Lao People\'s Democratic Republic (the)', - 'alpha2': 'LA', - 'alpha3': 'LAO', - 'numeric': '418', - 'altName': 'Lao PDR', - 'shortName': 'Laos', + name: "Lao People's Democratic Republic (the)", + alpha2: 'LA', + alpha3: 'LAO', + numeric: '418', + altName: 'Lao PDR', + shortName: 'Laos', }, { - 'name': 'Latvia', - 'alpha2': 'LV', - 'alpha3': 'LVA', - 'numeric': '428', + name: 'Latvia', + alpha2: 'LV', + alpha3: 'LVA', + numeric: '428', }, { - 'name': 'Lebanon', - 'alpha2': 'LB', - 'alpha3': 'LBN', - 'numeric': '422', + name: 'Lebanon', + alpha2: 'LB', + alpha3: 'LBN', + numeric: '422', }, { - 'name': 'Lesotho', - 'alpha2': 'LS', - 'alpha3': 'LSO', - 'numeric': '426', + name: 'Lesotho', + alpha2: 'LS', + alpha3: 'LSO', + numeric: '426', }, { - 'name': 'Liberia', - 'alpha2': 'LR', - 'alpha3': 'LBR', - 'numeric': '430', + name: 'Liberia', + alpha2: 'LR', + alpha3: 'LBR', + numeric: '430', }, { - 'name': 'Libya', - 'alpha2': 'LY', - 'alpha3': 'LBY', - 'numeric': '434', + name: 'Libya', + alpha2: 'LY', + alpha3: 'LBY', + numeric: '434', }, { - 'name': 'Liechtenstein', - 'alpha2': 'LI', - 'alpha3': 'LIE', - 'numeric': '438', + name: 'Liechtenstein', + alpha2: 'LI', + alpha3: 'LIE', + numeric: '438', }, { - 'name': 'Lithuania', - 'alpha2': 'LT', - 'alpha3': 'LTU', - 'numeric': '440', + name: 'Lithuania', + alpha2: 'LT', + alpha3: 'LTU', + numeric: '440', }, { - 'name': 'Luxembourg', - 'alpha2': 'LU', - 'alpha3': 'LUX', - 'numeric': '442', + name: 'Luxembourg', + alpha2: 'LU', + alpha3: 'LUX', + numeric: '442', }, { - 'name': 'Macao', - 'alpha2': 'MO', - 'alpha3': 'MAC', - 'numeric': '446', - 'altName': 'Macao, SAR China', - 'shortName': 'Macau', + name: 'Macao', + alpha2: 'MO', + alpha3: 'MAC', + numeric: '446', + altName: 'Macao, SAR China', + shortName: 'Macau', }, { - 'name': 'Macedonia (the former Yugoslav Republic of)', - 'alpha2': 'MK', - 'alpha3': 'MKD', - 'numeric': '807', - 'altName': 'Macedonia, Republic of', - 'shortName': 'Macedonia', + name: 'Macedonia (the former Yugoslav Republic of)', + alpha2: 'MK', + alpha3: 'MKD', + numeric: '807', + altName: 'Macedonia, Republic of', + shortName: 'Macedonia', }, { - 'name': 'Madagascar', - 'alpha2': 'MG', - 'alpha3': 'MDG', - 'numeric': '450', + name: 'Madagascar', + alpha2: 'MG', + alpha3: 'MDG', + numeric: '450', }, { - 'name': 'Malawi', - 'alpha2': 'MW', - 'alpha3': 'MWI', - 'numeric': '454', + name: 'Malawi', + alpha2: 'MW', + alpha3: 'MWI', + numeric: '454', }, { - 'name': 'Malaysia', - 'alpha2': 'MY', - 'alpha3': 'MYS', - 'numeric': '458', + name: 'Malaysia', + alpha2: 'MY', + alpha3: 'MYS', + numeric: '458', }, { - 'name': 'Maldives', - 'alpha2': 'MV', - 'alpha3': 'MDV', - 'numeric': '462', + name: 'Maldives', + alpha2: 'MV', + alpha3: 'MDV', + numeric: '462', }, { - 'name': 'Mali', - 'alpha2': 'ML', - 'alpha3': 'MLI', - 'numeric': '466', + name: 'Mali', + alpha2: 'ML', + alpha3: 'MLI', + numeric: '466', }, { - 'name': 'Malta', - 'alpha2': 'MT', - 'alpha3': 'MLT', - 'numeric': '470', + name: 'Malta', + alpha2: 'MT', + alpha3: 'MLT', + numeric: '470', }, { - 'name': 'Marshall Islands (the)', - 'alpha2': 'MH', - 'alpha3': 'MHL', - 'numeric': '584', - 'altName': 'Marshall Islands', + name: 'Marshall Islands (the)', + alpha2: 'MH', + alpha3: 'MHL', + numeric: '584', + altName: 'Marshall Islands', }, { - 'name': 'Martinique', - 'alpha2': 'MQ', - 'alpha3': 'MTQ', - 'numeric': '474', + name: 'Martinique', + alpha2: 'MQ', + alpha3: 'MTQ', + numeric: '474', }, { - 'name': 'Mauritania', - 'alpha2': 'MR', - 'alpha3': 'MRT', - 'numeric': '478', + name: 'Mauritania', + alpha2: 'MR', + alpha3: 'MRT', + numeric: '478', }, { - 'name': 'Mauritius', - 'alpha2': 'MU', - 'alpha3': 'MUS', - 'numeric': '480', + name: 'Mauritius', + alpha2: 'MU', + alpha3: 'MUS', + numeric: '480', }, { - 'name': 'Mayotte', - 'alpha2': 'YT', - 'alpha3': 'MYT', - 'numeric': '175', + name: 'Mayotte', + alpha2: 'YT', + alpha3: 'MYT', + numeric: '175', }, { - 'name': 'Mexico', - 'alpha2': 'MX', - 'alpha3': 'MEX', - 'numeric': '484', + name: 'Mexico', + alpha2: 'MX', + alpha3: 'MEX', + numeric: '484', }, { - 'name': 'Micronesia (Federated States of)', - 'alpha2': 'FM', - 'alpha3': 'FSM', - 'numeric': '583', - 'altName': 'Micronesia, Federated States of', - 'shortName': 'Micronesia', + name: 'Micronesia (Federated States of)', + alpha2: 'FM', + alpha3: 'FSM', + numeric: '583', + altName: 'Micronesia, Federated States of', + shortName: 'Micronesia', }, { - 'name': 'Moldova (the Republic of)', - 'alpha2': 'MD', - 'alpha3': 'MDA', - 'numeric': '498', - 'altName': 'Moldova', + name: 'Moldova (the Republic of)', + alpha2: 'MD', + alpha3: 'MDA', + numeric: '498', + altName: 'Moldova', }, { - 'name': 'Monaco', - 'alpha2': 'MC', - 'alpha3': 'MCO', - 'numeric': '492', + name: 'Monaco', + alpha2: 'MC', + alpha3: 'MCO', + numeric: '492', }, { - 'name': 'Mongolia', - 'alpha2': 'MN', - 'alpha3': 'MNG', - 'numeric': '496', + name: 'Mongolia', + alpha2: 'MN', + alpha3: 'MNG', + numeric: '496', }, { - 'name': 'Montenegro', - 'alpha2': 'ME', - 'alpha3': 'MNE', - 'numeric': '499', + name: 'Montenegro', + alpha2: 'ME', + alpha3: 'MNE', + numeric: '499', }, { - 'name': 'Montserrat', - 'alpha2': 'MS', - 'alpha3': 'MSR', - 'numeric': '500', + name: 'Montserrat', + alpha2: 'MS', + alpha3: 'MSR', + numeric: '500', }, { - 'name': 'Morocco', - 'alpha2': 'MA', - 'alpha3': 'MAR', - 'numeric': '504', + name: 'Morocco', + alpha2: 'MA', + alpha3: 'MAR', + numeric: '504', }, { - 'name': 'Mozambique', - 'alpha2': 'MZ', - 'alpha3': 'MOZ', - 'numeric': '508', + name: 'Mozambique', + alpha2: 'MZ', + alpha3: 'MOZ', + numeric: '508', }, { - 'name': 'Myanmar', - 'alpha2': 'MM', - 'alpha3': 'MMR', - 'numeric': '104', + name: 'Myanmar', + alpha2: 'MM', + alpha3: 'MMR', + numeric: '104', }, { - 'name': 'Namibia', - 'alpha2': 'NA', - 'alpha3': 'NAM', - 'numeric': '516', + name: 'Namibia', + alpha2: 'NA', + alpha3: 'NAM', + numeric: '516', }, { - 'name': 'Nauru', - 'alpha2': 'NR', - 'alpha3': 'NRU', - 'numeric': '520', + name: 'Nauru', + alpha2: 'NR', + alpha3: 'NRU', + numeric: '520', }, { - 'name': 'Nepal', - 'alpha2': 'NP', - 'alpha3': 'NPL', - 'numeric': '524', + name: 'Nepal', + alpha2: 'NP', + alpha3: 'NPL', + numeric: '524', }, { - 'name': 'Netherlands (the)', - 'alpha2': 'NL', - 'alpha3': 'NLD', - 'numeric': '528', - 'altName': 'Netherlands', + name: 'Netherlands (the)', + alpha2: 'NL', + alpha3: 'NLD', + numeric: '528', + altName: 'Netherlands', }, { - 'name': 'New Caledonia', - 'alpha2': 'NC', - 'alpha3': 'NCL', - 'numeric': '540', + name: 'New Caledonia', + alpha2: 'NC', + alpha3: 'NCL', + numeric: '540', }, { - 'name': 'New Zealand', - 'alpha2': 'NZ', - 'alpha3': 'NZL', - 'numeric': '554', + name: 'New Zealand', + alpha2: 'NZ', + alpha3: 'NZL', + numeric: '554', }, { - 'name': 'Nicaragua', - 'alpha2': 'NI', - 'alpha3': 'NIC', - 'numeric': '558', + name: 'Nicaragua', + alpha2: 'NI', + alpha3: 'NIC', + numeric: '558', }, { - 'name': 'Niger (the)', - 'alpha2': 'NE', - 'alpha3': 'NER', - 'numeric': '562', - 'altName': 'Niger', + name: 'Niger (the)', + alpha2: 'NE', + alpha3: 'NER', + numeric: '562', + altName: 'Niger', }, { - 'name': 'Nigeria', - 'alpha2': 'NG', - 'alpha3': 'NGA', - 'numeric': '566', + name: 'Nigeria', + alpha2: 'NG', + alpha3: 'NGA', + numeric: '566', }, { - 'name': 'Niue', - 'alpha2': 'NU', - 'alpha3': 'NIU', - 'numeric': '570', + name: 'Niue', + alpha2: 'NU', + alpha3: 'NIU', + numeric: '570', }, { - 'name': 'Norfolk Island', - 'alpha2': 'NF', - 'alpha3': 'NFK', - 'numeric': '574', + name: 'Norfolk Island', + alpha2: 'NF', + alpha3: 'NFK', + numeric: '574', }, { - 'name': 'Northern Mariana Islands (the)', - 'alpha2': 'MP', - 'alpha3': 'MNP', - 'numeric': '580', - 'altName': 'Northern Mariana Islands', + name: 'Northern Mariana Islands (the)', + alpha2: 'MP', + alpha3: 'MNP', + numeric: '580', + altName: 'Northern Mariana Islands', }, { - 'name': 'Norway', - 'alpha2': 'NO', - 'alpha3': 'NOR', - 'numeric': '578', + name: 'Norway', + alpha2: 'NO', + alpha3: 'NOR', + numeric: '578', }, { - 'name': 'Oman', - 'alpha2': 'OM', - 'alpha3': 'OMN', - 'numeric': '512', + name: 'Oman', + alpha2: 'OM', + alpha3: 'OMN', + numeric: '512', }, { - 'name': 'Pakistan', - 'alpha2': 'PK', - 'alpha3': 'PAK', - 'numeric': '586', + name: 'Pakistan', + alpha2: 'PK', + alpha3: 'PAK', + numeric: '586', }, { - 'name': 'Palau', - 'alpha2': 'PW', - 'alpha3': 'PLW', - 'numeric': '585', + name: 'Palau', + alpha2: 'PW', + alpha3: 'PLW', + numeric: '585', }, { - 'name': 'Palestine, State of', - 'alpha2': 'PS', - 'alpha3': 'PSE', - 'numeric': '275', - 'altName': 'Palestinian Territory', - 'shortName': 'Palestine', + name: 'Palestine, State of', + alpha2: 'PS', + alpha3: 'PSE', + numeric: '275', + altName: 'Palestinian Territory', + shortName: 'Palestine', }, { - 'name': 'Panama', - 'alpha2': 'PA', - 'alpha3': 'PAN', - 'numeric': '591', + name: 'Panama', + alpha2: 'PA', + alpha3: 'PAN', + numeric: '591', }, { - 'name': 'Papua New Guinea', - 'alpha2': 'PG', - 'alpha3': 'PNG', - 'numeric': '598', + name: 'Papua New Guinea', + alpha2: 'PG', + alpha3: 'PNG', + numeric: '598', }, { - 'name': 'Paraguay', - 'alpha2': 'PY', - 'alpha3': 'PRY', - 'numeric': '600', + name: 'Paraguay', + alpha2: 'PY', + alpha3: 'PRY', + numeric: '600', }, { - 'name': 'Peru', - 'alpha2': 'PE', - 'alpha3': 'PER', - 'numeric': '604', + name: 'Peru', + alpha2: 'PE', + alpha3: 'PER', + numeric: '604', }, { - 'name': 'Philippines (the)', - 'alpha2': 'PH', - 'alpha3': 'PHL', - 'numeric': '608', - 'altName': 'Philippines', + name: 'Philippines (the)', + alpha2: 'PH', + alpha3: 'PHL', + numeric: '608', + altName: 'Philippines', }, { - 'name': 'Pitcairn', - 'alpha2': 'PN', - 'alpha3': 'PCN', - 'numeric': '612', + name: 'Pitcairn', + alpha2: 'PN', + alpha3: 'PCN', + numeric: '612', }, { - 'name': 'Poland', - 'alpha2': 'PL', - 'alpha3': 'POL', - 'numeric': '616', + name: 'Poland', + alpha2: 'PL', + alpha3: 'POL', + numeric: '616', }, { - 'name': 'Portugal', - 'alpha2': 'PT', - 'alpha3': 'PRT', - 'numeric': '620', + name: 'Portugal', + alpha2: 'PT', + alpha3: 'PRT', + numeric: '620', }, { - 'name': 'Puerto Rico', - 'alpha2': 'PR', - 'alpha3': 'PRI', - 'numeric': '630', + name: 'Puerto Rico', + alpha2: 'PR', + alpha3: 'PRI', + numeric: '630', }, { - 'name': 'Qatar', - 'alpha2': 'QA', - 'alpha3': 'QAT', - 'numeric': '634', + name: 'Qatar', + alpha2: 'QA', + alpha3: 'QAT', + numeric: '634', }, { - 'name': 'Réunion', - 'alpha2': 'RE', - 'alpha3': 'REU', - 'numeric': '638', - 'shortName': 'Reunion', + name: 'Réunion', + alpha2: 'RE', + alpha3: 'REU', + numeric: '638', + shortName: 'Reunion', }, { - 'name': 'Romania', - 'alpha2': 'RO', - 'alpha3': 'ROU', - 'numeric': '642', + name: 'Romania', + alpha2: 'RO', + alpha3: 'ROU', + numeric: '642', }, { - 'name': 'Russian Federation (the)', - 'alpha2': 'RU', - 'alpha3': 'RUS', - 'numeric': '643', - 'altName': 'Russian Federation', - 'shortName': 'Russia', + name: 'Russian Federation (the)', + alpha2: 'RU', + alpha3: 'RUS', + numeric: '643', + altName: 'Russian Federation', + shortName: 'Russia', }, { - 'name': 'Rwanda', - 'alpha2': 'RW', - 'alpha3': 'RWA', - 'numeric': '646', + name: 'Rwanda', + alpha2: 'RW', + alpha3: 'RWA', + numeric: '646', }, { - 'name': 'Saint Barthélemy', - 'alpha2': 'BL', - 'alpha3': 'BLM', - 'numeric': '652', - 'altName': 'Saint-Barthélemy', - 'shortName': 'Saint Barthelemy', + name: 'Saint Barthélemy', + alpha2: 'BL', + alpha3: 'BLM', + numeric: '652', + altName: 'Saint-Barthélemy', + shortName: 'Saint Barthelemy', }, { - 'name': 'Saint Helena, Ascension and Tristan da Cunha', - 'alpha2': 'SH', - 'alpha3': 'SHN', - 'numeric': '654', - 'altName': 'Saint Helena', + name: 'Saint Helena, Ascension and Tristan da Cunha', + alpha2: 'SH', + alpha3: 'SHN', + numeric: '654', + altName: 'Saint Helena', }, { - 'name': 'Saint Kitts and Nevis', - 'alpha2': 'KN', - 'alpha3': 'KNA', - 'numeric': '659', + name: 'Saint Kitts and Nevis', + alpha2: 'KN', + alpha3: 'KNA', + numeric: '659', }, { - 'name': 'Saint Lucia', - 'alpha2': 'LC', - 'alpha3': 'LCA', - 'numeric': '662', + name: 'Saint Lucia', + alpha2: 'LC', + alpha3: 'LCA', + numeric: '662', }, { - 'name': 'Saint Martin (French part)', - 'alpha2': 'MF', - 'alpha3': 'MAF', - 'numeric': '663', - 'altName': 'Saint-Martin (French part)', - 'shortName': 'Saint Martin', + name: 'Saint Martin (French part)', + alpha2: 'MF', + alpha3: 'MAF', + numeric: '663', + altName: 'Saint-Martin (French part)', + shortName: 'Saint Martin', }, { - 'name': 'Saint Pierre and Miquelon', - 'alpha2': 'PM', - 'alpha3': 'SPM', - 'numeric': '666', + name: 'Saint Pierre and Miquelon', + alpha2: 'PM', + alpha3: 'SPM', + numeric: '666', }, { - 'name': 'Saint Vincent and the Grenadines', - 'alpha2': 'VC', - 'alpha3': 'VCT', - 'numeric': '670', - 'altName': 'Saint Vincent and Grenadines', + name: 'Saint Vincent and the Grenadines', + alpha2: 'VC', + alpha3: 'VCT', + numeric: '670', + altName: 'Saint Vincent and Grenadines', }, { - 'name': 'Samoa', - 'alpha2': 'WS', - 'alpha3': 'WSM', - 'numeric': '882', + name: 'Samoa', + alpha2: 'WS', + alpha3: 'WSM', + numeric: '882', }, { - 'name': 'San Marino', - 'alpha2': 'SM', - 'alpha3': 'SMR', - 'numeric': '674', + name: 'San Marino', + alpha2: 'SM', + alpha3: 'SMR', + numeric: '674', }, { - 'name': 'Sao Tome and Principe', - 'alpha2': 'ST', - 'alpha3': 'STP', - 'numeric': '678', + name: 'Sao Tome and Principe', + alpha2: 'ST', + alpha3: 'STP', + numeric: '678', }, { - 'name': 'Saudi Arabia', - 'alpha2': 'SA', - 'alpha3': 'SAU', - 'numeric': '682', + name: 'Saudi Arabia', + alpha2: 'SA', + alpha3: 'SAU', + numeric: '682', }, { - 'name': 'Senegal', - 'alpha2': 'SN', - 'alpha3': 'SEN', - 'numeric': '686', + name: 'Senegal', + alpha2: 'SN', + alpha3: 'SEN', + numeric: '686', }, { - 'name': 'Serbia', - 'alpha2': 'RS', - 'alpha3': 'SRB', - 'numeric': '688', + name: 'Serbia', + alpha2: 'RS', + alpha3: 'SRB', + numeric: '688', }, { - 'name': 'Seychelles', - 'alpha2': 'SC', - 'alpha3': 'SYC', - 'numeric': '690', + name: 'Seychelles', + alpha2: 'SC', + alpha3: 'SYC', + numeric: '690', }, { - 'name': 'Sierra Leone', - 'alpha2': 'SL', - 'alpha3': 'SLE', - 'numeric': '694', + name: 'Sierra Leone', + alpha2: 'SL', + alpha3: 'SLE', + numeric: '694', }, { - 'name': 'Singapore', - 'alpha2': 'SG', - 'alpha3': 'SGP', - 'numeric': '702', + name: 'Singapore', + alpha2: 'SG', + alpha3: 'SGP', + numeric: '702', }, { - 'name': 'Sint Maarten (Dutch part)', - 'alpha2': 'SX', - 'alpha3': 'SXM', - 'numeric': '534', - 'shortName': 'Sint Maarten', + name: 'Sint Maarten (Dutch part)', + alpha2: 'SX', + alpha3: 'SXM', + numeric: '534', + shortName: 'Sint Maarten', }, { - 'name': 'Slovakia', - 'alpha2': 'SK', - 'alpha3': 'SVK', - 'numeric': '703', + name: 'Slovakia', + alpha2: 'SK', + alpha3: 'SVK', + numeric: '703', }, { - 'name': 'Slovenia', - 'alpha2': 'SI', - 'alpha3': 'SVN', - 'numeric': '705', + name: 'Slovenia', + alpha2: 'SI', + alpha3: 'SVN', + numeric: '705', }, { - 'name': 'Solomon Islands', - 'alpha2': 'SB', - 'alpha3': 'SLB', - 'numeric': '090', + name: 'Solomon Islands', + alpha2: 'SB', + alpha3: 'SLB', + numeric: '090', }, { - 'name': 'Somalia', - 'alpha2': 'SO', - 'alpha3': 'SOM', - 'numeric': '706', + name: 'Somalia', + alpha2: 'SO', + alpha3: 'SOM', + numeric: '706', }, { - 'name': 'South Africa', - 'alpha2': 'ZA', - 'alpha3': 'ZAF', - 'numeric': '710', + name: 'South Africa', + alpha2: 'ZA', + alpha3: 'ZAF', + numeric: '710', }, { - 'name': 'South Georgia and the South Sandwich Islands', - 'alpha2': 'GS', - 'alpha3': 'SGS', - 'numeric': '239', + name: 'South Georgia and the South Sandwich Islands', + alpha2: 'GS', + alpha3: 'SGS', + numeric: '239', }, { - 'name': 'South Sudan', - 'alpha2': 'SS', - 'alpha3': 'SSD', - 'numeric': '728', + name: 'South Sudan', + alpha2: 'SS', + alpha3: 'SSD', + numeric: '728', }, { - 'name': 'Spain', - 'alpha2': 'ES', - 'alpha3': 'ESP', - 'numeric': '724', + name: 'Spain', + alpha2: 'ES', + alpha3: 'ESP', + numeric: '724', }, { - 'name': 'Sri Lanka', - 'alpha2': 'LK', - 'alpha3': 'LKA', - 'numeric': '144', + name: 'Sri Lanka', + alpha2: 'LK', + alpha3: 'LKA', + numeric: '144', }, { - 'name': 'Sudan (the)', - 'alpha2': 'SD', - 'alpha3': 'SDN', - 'numeric': '729', - 'altName': 'Sudan', + name: 'Sudan (the)', + alpha2: 'SD', + alpha3: 'SDN', + numeric: '729', + altName: 'Sudan', }, { - 'name': 'Suriname', - 'alpha2': 'SR', - 'alpha3': 'SUR', - 'numeric': '740', + name: 'Suriname', + alpha2: 'SR', + alpha3: 'SUR', + numeric: '740', }, { - 'name': 'Svalbard and Jan Mayen', - 'alpha2': 'SJ', - 'alpha3': 'SJM', - 'numeric': '744', - 'altName': 'Svalbard and Jan Mayen Islands', + name: 'Svalbard and Jan Mayen', + alpha2: 'SJ', + alpha3: 'SJM', + numeric: '744', + altName: 'Svalbard and Jan Mayen Islands', }, { - 'name': 'Swaziland', - 'alpha2': 'SZ', - 'alpha3': 'SWZ', - 'numeric': '748', + name: 'Swaziland', + alpha2: 'SZ', + alpha3: 'SWZ', + numeric: '748', }, { - 'name': 'Sweden', - 'alpha2': 'SE', - 'alpha3': 'SWE', - 'numeric': '752', + name: 'Sweden', + alpha2: 'SE', + alpha3: 'SWE', + numeric: '752', }, { - 'name': 'Switzerland', - 'alpha2': 'CH', - 'alpha3': 'CHE', - 'numeric': '756', + name: 'Switzerland', + alpha2: 'CH', + alpha3: 'CHE', + numeric: '756', }, { - 'name': 'Syrian Arab Republic', - 'alpha2': 'SY', - 'alpha3': 'SYR', - 'numeric': '760', - 'altName': 'Syrian Arab Republic (Syria)', - 'shortName': 'Syria', + name: 'Syrian Arab Republic', + alpha2: 'SY', + alpha3: 'SYR', + numeric: '760', + altName: 'Syrian Arab Republic (Syria)', + shortName: 'Syria', }, { - 'name': 'Taiwan (Province of China)', - 'alpha2': 'TW', - 'alpha3': 'TWN', - 'numeric': '158', - 'altName': 'Taiwan, Republic of China', - 'shortName': 'Taiwan', + name: 'Taiwan (Province of China)', + alpha2: 'TW', + alpha3: 'TWN', + numeric: '158', + altName: 'Taiwan, Republic of China', + shortName: 'Taiwan', }, { - 'name': 'Tajikistan', - 'alpha2': 'TJ', - 'alpha3': 'TJK', - 'numeric': '762', + name: 'Tajikistan', + alpha2: 'TJ', + alpha3: 'TJK', + numeric: '762', }, { - 'name': 'Tanzania, United Republic of', - 'alpha2': 'TZ', - 'alpha3': 'TZA', - 'numeric': '834', - 'shortName': 'Tanzania', + name: 'Tanzania, United Republic of', + alpha2: 'TZ', + alpha3: 'TZA', + numeric: '834', + shortName: 'Tanzania', }, { - 'name': 'Thailand', - 'alpha2': 'TH', - 'alpha3': 'THA', - 'numeric': '764', + name: 'Thailand', + alpha2: 'TH', + alpha3: 'THA', + numeric: '764', }, { - 'name': 'Timor-Leste', - 'alpha2': 'TL', - 'alpha3': 'TLS', - 'numeric': '626', - 'shortName': 'East Timor', + name: 'Timor-Leste', + alpha2: 'TL', + alpha3: 'TLS', + numeric: '626', + shortName: 'East Timor', }, { - 'name': 'Togo', - 'alpha2': 'TG', - 'alpha3': 'TGO', - 'numeric': '768', + name: 'Togo', + alpha2: 'TG', + alpha3: 'TGO', + numeric: '768', }, { - 'name': 'Tokelau', - 'alpha2': 'TK', - 'alpha3': 'TKL', - 'numeric': '772', + name: 'Tokelau', + alpha2: 'TK', + alpha3: 'TKL', + numeric: '772', }, { - 'name': 'Tonga', - 'alpha2': 'TO', - 'alpha3': 'TON', - 'numeric': '776', + name: 'Tonga', + alpha2: 'TO', + alpha3: 'TON', + numeric: '776', }, { - 'name': 'Trinidad and Tobago', - 'alpha2': 'TT', - 'alpha3': 'TTO', - 'numeric': '780', + name: 'Trinidad and Tobago', + alpha2: 'TT', + alpha3: 'TTO', + numeric: '780', }, { - 'name': 'Tunisia', - 'alpha2': 'TN', - 'alpha3': 'TUN', - 'numeric': '788', + name: 'Tunisia', + alpha2: 'TN', + alpha3: 'TUN', + numeric: '788', }, { - 'name': 'Turkey', - 'alpha2': 'TR', - 'alpha3': 'TUR', - 'numeric': '792', + name: 'Turkey', + alpha2: 'TR', + alpha3: 'TUR', + numeric: '792', }, { - 'name': 'Turkmenistan', - 'alpha2': 'TM', - 'alpha3': 'TKM', - 'numeric': '795', + name: 'Turkmenistan', + alpha2: 'TM', + alpha3: 'TKM', + numeric: '795', }, { - 'name': 'Turks and Caicos Islands (the)', - 'alpha2': 'TC', - 'alpha3': 'TCA', - 'numeric': '796', - 'altName': 'Turks and Caicos Islands', + name: 'Turks and Caicos Islands (the)', + alpha2: 'TC', + alpha3: 'TCA', + numeric: '796', + altName: 'Turks and Caicos Islands', }, { - 'name': 'Tuvalu', - 'alpha2': 'TV', - 'alpha3': 'TUV', - 'numeric': '798', + name: 'Tuvalu', + alpha2: 'TV', + alpha3: 'TUV', + numeric: '798', }, { - 'name': 'Uganda', - 'alpha2': 'UG', - 'alpha3': 'UGA', - 'numeric': '800', + name: 'Uganda', + alpha2: 'UG', + alpha3: 'UGA', + numeric: '800', }, { - 'name': 'Ukraine', - 'alpha2': 'UA', - 'alpha3': 'UKR', - 'numeric': '804', + name: 'Ukraine', + alpha2: 'UA', + alpha3: 'UKR', + numeric: '804', }, { - 'name': 'United Arab Emirates (the)', - 'alpha2': 'AE', - 'alpha3': 'ARE', - 'numeric': '784', - 'altName': 'United Arab Emirates', + name: 'United Arab Emirates (the)', + alpha2: 'AE', + alpha3: 'ARE', + numeric: '784', + altName: 'United Arab Emirates', }, { - 'name': 'United Kingdom of Great Britain and Northern Ireland (the)', - 'alpha2': 'GB', - 'alpha3': 'GBR', - 'numeric': '826', - 'altName': 'United Kingdom', + name: 'United Kingdom of Great Britain and Northern Ireland (the)', + alpha2: 'GB', + alpha3: 'GBR', + numeric: '826', + altName: 'United Kingdom', }, { - 'name': 'United States Minor Outlying Islands (the)', - 'alpha2': 'UM', - 'alpha3': 'UMI', - 'numeric': '581', - 'altName': 'US Minor Outlying Islands', + name: 'United States Minor Outlying Islands (the)', + alpha2: 'UM', + alpha3: 'UMI', + numeric: '581', + altName: 'US Minor Outlying Islands', }, { - 'name': 'United States of America (the)', - 'alpha2': 'US', - 'alpha3': 'USA', - 'numeric': '840', - 'altName': 'United States of America', - 'shortName': 'United States', + name: 'United States of America (the)', + alpha2: 'US', + alpha3: 'USA', + numeric: '840', + altName: 'United States of America', + shortName: 'United States', }, { - 'name': 'Uruguay', - 'alpha2': 'UY', - 'alpha3': 'URY', - 'numeric': '858', + name: 'Uruguay', + alpha2: 'UY', + alpha3: 'URY', + numeric: '858', }, { - 'name': 'Uzbekistan', - 'alpha2': 'UZ', - 'alpha3': 'UZB', - 'numeric': '860', + name: 'Uzbekistan', + alpha2: 'UZ', + alpha3: 'UZB', + numeric: '860', }, { - 'name': 'Vanuatu', - 'alpha2': 'VU', - 'alpha3': 'VUT', - 'numeric': '548', + name: 'Vanuatu', + alpha2: 'VU', + alpha3: 'VUT', + numeric: '548', }, { - 'name': 'Venezuela (Bolivarian Republic of)', - 'alpha2': 'VE', - 'alpha3': 'VEN', - 'numeric': '862', - 'altName': 'Venezuela (Bolivarian Republic)', - 'shortName': 'Venezuela', + name: 'Venezuela (Bolivarian Republic of)', + alpha2: 'VE', + alpha3: 'VEN', + numeric: '862', + altName: 'Venezuela (Bolivarian Republic)', + shortName: 'Venezuela', }, { - 'name': 'Viet Nam', - 'alpha2': 'VN', - 'alpha3': 'VNM', - 'numeric': '704', - 'shortName': 'Vietnam', + name: 'Viet Nam', + alpha2: 'VN', + alpha3: 'VNM', + numeric: '704', + shortName: 'Vietnam', }, { - 'name': 'Virgin Islands (British)', - 'alpha2': 'VG', - 'alpha3': 'VGB', - 'numeric': '092', - 'altName': 'British Virgin Islands', + name: 'Virgin Islands (British)', + alpha2: 'VG', + alpha3: 'VGB', + numeric: '092', + altName: 'British Virgin Islands', }, { - 'name': 'Virgin Islands (U.S.)', - 'alpha2': 'VI', - 'alpha3': 'VIR', - 'numeric': '850', - 'altName': 'Virgin Islands, US', - 'shortName': 'U.S. Virgin Islands', + name: 'Virgin Islands (U.S.)', + alpha2: 'VI', + alpha3: 'VIR', + numeric: '850', + altName: 'Virgin Islands, US', + shortName: 'U.S. Virgin Islands', }, { - 'name': 'Wallis and Futuna', - 'alpha2': 'WF', - 'alpha3': 'WLF', - 'numeric': '876', - 'altName': 'Wallis and Futuna Islands', + name: 'Wallis and Futuna', + alpha2: 'WF', + alpha3: 'WLF', + numeric: '876', + altName: 'Wallis and Futuna Islands', }, { - 'name': 'Western Sahara*', - 'alpha2': 'EH', - 'alpha3': 'ESH', - 'numeric': '732', - 'altName': 'Western Sahara', + name: 'Western Sahara*', + alpha2: 'EH', + alpha3: 'ESH', + numeric: '732', + altName: 'Western Sahara', }, { - 'name': 'Yemen', - 'alpha2': 'YE', - 'alpha3': 'YEM', - 'numeric': '887', + name: 'Yemen', + alpha2: 'YE', + alpha3: 'YEM', + numeric: '887', }, { - 'name': 'Zambia', - 'alpha2': 'ZM', - 'alpha3': 'ZMB', - 'numeric': '894', + name: 'Zambia', + alpha2: 'ZM', + alpha3: 'ZMB', + numeric: '894', }, { - 'name': 'Zimbabwe', - 'alpha2': 'ZW', - 'alpha3': 'ZWE', - 'numeric': '716', + name: 'Zimbabwe', + alpha2: 'ZW', + alpha3: 'ZWE', + numeric: '716', }, ] as IDataObject[]; diff --git a/packages/nodes-base/nodes/InvoiceNinja/InvoiceDescription.ts b/packages/nodes-base/nodes/InvoiceNinja/InvoiceDescription.ts index ae31c4d514..6d521fe3f3 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/InvoiceDescription.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/InvoiceDescription.ts @@ -8,9 +8,7 @@ export const invoiceOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'invoice', - ], + resource: ['invoice'], }, }, options: [ @@ -50,9 +48,9 @@ export const invoiceOperations: INodeProperties[] = [ ]; export const invoiceFields: INodeProperties[] = [ -/* -------------------------------------------------------------------------- */ -/* invoice:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* invoice:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Additional Fields', name: 'additionalFields', @@ -61,12 +59,8 @@ export const invoiceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'invoice', - ], + operation: ['create'], + resource: ['invoice'], }, }, options: [ @@ -74,7 +68,8 @@ export const invoiceFields: INodeProperties[] = [ displayName: 'Client Name or ID', name: 'client', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getClients', }, @@ -241,12 +236,8 @@ export const invoiceFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'create', - ], + resource: ['invoice'], + operation: ['create'], }, }, default: {}, @@ -316,9 +307,9 @@ export const invoiceFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* invoice:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* invoice:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Invoice ID', name: 'invoiceId', @@ -327,18 +318,14 @@ export const invoiceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'delete', - ], + resource: ['invoice'], + operation: ['delete'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* invoice:email */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* invoice:email */ + /* -------------------------------------------------------------------------- */ { displayName: 'Invoice ID', name: 'invoiceId', @@ -347,18 +334,14 @@ export const invoiceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'email', - ], + resource: ['invoice'], + operation: ['email'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* invoice:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* invoice:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Invoice ID', name: 'invoiceId', @@ -367,12 +350,8 @@ export const invoiceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'get', - ], + resource: ['invoice'], + operation: ['get'], }, }, }, @@ -384,12 +363,8 @@ export const invoiceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'invoice', - ], + operation: ['get'], + resource: ['invoice'], }, }, options: [ @@ -407,21 +382,17 @@ export const invoiceFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* invoice:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* invoice:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'getAll', - ], + resource: ['invoice'], + operation: ['getAll'], }, }, default: false, @@ -433,15 +404,9 @@ export const invoiceFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['invoice'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -459,12 +424,8 @@ export const invoiceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'invoice', - ], + operation: ['getAll'], + resource: ['invoice'], }, }, options: [ diff --git a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts index 100db76493..0a4af25b5d 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,70 +9,33 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - invoiceNinjaApiRequest, - invoiceNinjaApiRequestAllItems, -} from './GenericFunctions'; +import { invoiceNinjaApiRequest, invoiceNinjaApiRequestAllItems } from './GenericFunctions'; -import { - clientFields, - clientOperations, -} from './ClientDescription'; +import { clientFields, clientOperations } from './ClientDescription'; -import { - invoiceFields, - invoiceOperations, -} from './InvoiceDescription'; +import { invoiceFields, invoiceOperations } from './InvoiceDescription'; -import { - IClient, - IContact, -} from './ClientInterface'; +import { IClient, IContact } from './ClientInterface'; -import { - countryCodes, -} from './ISOCountryCodes'; +import { countryCodes } from './ISOCountryCodes'; -import { - IInvoice, - IItem, -} from './invoiceInterface'; +import { IInvoice, IItem } from './invoiceInterface'; -import { - taskFields, - taskOperations, -} from './TaskDescription'; +import { taskFields, taskOperations } from './TaskDescription'; -import { - ITask, -} from './TaskInterface'; +import { ITask } from './TaskInterface'; -import { - paymentFields, - paymentOperations, -} from './PaymentDescription'; +import { paymentFields, paymentOperations } from './PaymentDescription'; -import { - IPayment, -} from './PaymentInterface'; +import { IPayment } from './PaymentInterface'; -import { - expenseFields, - expenseOperations, -} from './ExpenseDescription'; +import { expenseFields, expenseOperations } from './ExpenseDescription'; -import { - IExpense, -} from './ExpenseInterface'; +import { IExpense } from './ExpenseInterface'; -import { - quoteFields, - quoteOperations, -} from './QuoteDescription'; +import { quoteFields, quoteOperations } from './QuoteDescription'; -import { - IQuote, -} from './QuoteInterface'; +import { IQuote } from './QuoteInterface'; export class InvoiceNinja implements INodeType { description: INodeTypeDescription = { @@ -166,7 +127,12 @@ export class InvoiceNinja implements INodeType { // select them easily async getProjects(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const projects = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/projects'); + const projects = await invoiceNinjaApiRequestAllItems.call( + this, + 'data', + 'GET', + '/projects', + ); for (const project of projects) { const projectName = project.name; const projectId = project.id; @@ -181,7 +147,12 @@ export class InvoiceNinja implements INodeType { // select them easily async getInvoices(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const invoices = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/invoices'); + const invoices = await invoiceNinjaApiRequestAllItems.call( + this, + 'data', + 'GET', + '/invoices', + ); for (const invoice of invoices) { const invoiceName = invoice.invoice_number; const invoiceId = invoice.id; @@ -225,7 +196,12 @@ export class InvoiceNinja implements INodeType { // select them easily async getExpenseCategories(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const categories = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/expense_categories'); + const categories = await invoiceNinjaApiRequestAllItems.call( + this, + 'data', + 'GET', + '/expense_categories', + ); for (const category of categories) { const categoryName = category.name; const categoryId = category.id; @@ -278,7 +254,8 @@ export class InvoiceNinja implements INodeType { if (additionalFields.website) { body.website = additionalFields.website as string; } - const contactsValues = (this.getNodeParameter('contactsUi', i) as IDataObject).contacstValues as IDataObject[]; + const contactsValues = (this.getNodeParameter('contactsUi', i) as IDataObject) + .contacstValues as IDataObject[]; if (contactsValues) { const contacts: IContact[] = []; for (const contactValue of contactsValues) { @@ -292,7 +269,9 @@ export class InvoiceNinja implements INodeType { } body.contacts = contacts; } - const shippingAddressValue = (this.getNodeParameter('shippingAddressUi', i) as IDataObject).shippingAddressValue as IDataObject; + const shippingAddressValue = ( + this.getNodeParameter('shippingAddressUi', i) as IDataObject + ).shippingAddressValue as IDataObject; if (shippingAddressValue) { body.shipping_address1 = shippingAddressValue.streetAddress as string; body.shipping_address2 = shippingAddressValue.aptSuite as string; @@ -301,7 +280,9 @@ export class InvoiceNinja implements INodeType { body.shipping_postal_code = shippingAddressValue.postalCode as string; body.shipping_country_id = parseInt(shippingAddressValue.countryCode as string, 10); } - const billingAddressValue = (this.getNodeParameter('billingAddressUi', i) as IDataObject).billingAddressValue as IDataObject; + const billingAddressValue = ( + this.getNodeParameter('billingAddressUi', i) as IDataObject + ).billingAddressValue as IDataObject; if (billingAddressValue) { body.address1 = billingAddressValue.streetAddress as string; body.address2 = billingAddressValue.aptSuite as string; @@ -319,7 +300,13 @@ export class InvoiceNinja implements INodeType { if (options.include) { qs.include = options.include as string; } - responseData = await invoiceNinjaApiRequest.call(this, 'GET', `/clients/${clientId}`, {}, qs); + responseData = await invoiceNinjaApiRequest.call( + this, + 'GET', + `/clients/${clientId}`, + {}, + qs, + ); responseData = responseData.data; } if (operation === 'getAll') { @@ -329,7 +316,14 @@ export class InvoiceNinja implements INodeType { qs.include = options.include as string; } if (returnAll === true) { - responseData = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/clients', {}, qs); + responseData = await invoiceNinjaApiRequestAllItems.call( + this, + 'data', + 'GET', + '/clients', + {}, + qs, + ); } else { qs.per_page = this.getNodeParameter('limit', 0) as number; responseData = await invoiceNinjaApiRequest.call(this, 'GET', '/clients', {}, qs); @@ -338,7 +332,11 @@ export class InvoiceNinja implements INodeType { } if (operation === 'delete') { const clientId = this.getNodeParameter('clientId', i) as string; - responseData = await invoiceNinjaApiRequest.call(this, 'DELETE', `/clients/${clientId}`); + responseData = await invoiceNinjaApiRequest.call( + this, + 'DELETE', + `/clients/${clientId}`, + ); responseData = responseData.data; } } @@ -412,7 +410,8 @@ export class InvoiceNinja implements INodeType { if (additionalFields.emailInvoice) { body.email_invoice = additionalFields.emailInvoice as boolean; } - const invoceItemsValues = (this.getNodeParameter('invoiceItemsUi', i) as IDataObject).invoiceItemsValues as IDataObject[]; + const invoceItemsValues = (this.getNodeParameter('invoiceItemsUi', i) as IDataObject) + .invoiceItemsValues as IDataObject[]; if (invoceItemsValues) { const items: IItem[] = []; for (const itemValue of invoceItemsValues) { @@ -435,7 +434,9 @@ export class InvoiceNinja implements INodeType { } if (operation === 'email') { const invoiceId = this.getNodeParameter('invoiceId', i) as string; - responseData = await invoiceNinjaApiRequest.call(this, 'POST', '/email_invoice', { id: invoiceId }); + responseData = await invoiceNinjaApiRequest.call(this, 'POST', '/email_invoice', { + id: invoiceId, + }); } if (operation === 'get') { const invoiceId = this.getNodeParameter('invoiceId', i) as string; @@ -443,7 +444,13 @@ export class InvoiceNinja implements INodeType { if (options.include) { qs.include = options.include as string; } - responseData = await invoiceNinjaApiRequest.call(this, 'GET', `/invoices/${invoiceId}`, {}, qs); + responseData = await invoiceNinjaApiRequest.call( + this, + 'GET', + `/invoices/${invoiceId}`, + {}, + qs, + ); responseData = responseData.data; } if (operation === 'getAll') { @@ -456,7 +463,14 @@ export class InvoiceNinja implements INodeType { qs.invoice_number = options.invoiceNumber as string; } if (returnAll === true) { - responseData = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/invoices', {}, qs); + responseData = await invoiceNinjaApiRequestAllItems.call( + this, + 'data', + 'GET', + '/invoices', + {}, + qs, + ); } else { qs.per_page = this.getNodeParameter('limit', 0) as number; responseData = await invoiceNinjaApiRequest.call(this, 'GET', '/invoices', {}, qs); @@ -465,7 +479,11 @@ export class InvoiceNinja implements INodeType { } if (operation === 'delete') { const invoiceId = this.getNodeParameter('invoiceId', i) as string; - responseData = await invoiceNinjaApiRequest.call(this, 'DELETE', `/invoices/${invoiceId}`); + responseData = await invoiceNinjaApiRequest.call( + this, + 'DELETE', + `/invoices/${invoiceId}`, + ); responseData = responseData.data; } } @@ -488,19 +506,21 @@ export class InvoiceNinja implements INodeType { if (additionalFields.description) { body.description = additionalFields.description as string; } - const timeLogsValues = (this.getNodeParameter('timeLogsUi', i) as IDataObject).timeLogsValues as IDataObject[]; + const timeLogsValues = (this.getNodeParameter('timeLogsUi', i) as IDataObject) + .timeLogsValues as IDataObject[]; if (timeLogsValues) { const logs: number[][] = []; for (const logValue of timeLogsValues) { - let from = 0, to; + let from = 0, + to; if (logValue.startDate) { - from = new Date(logValue.startDate as string).getTime() / 1000 as number; + from = (new Date(logValue.startDate as string).getTime() / 1000) as number; } if (logValue.endDate) { - to = new Date(logValue.endDate as string).getTime() / 1000 as number; + to = (new Date(logValue.endDate as string).getTime() / 1000) as number; } if (logValue.duration) { - to = from + (logValue.duration as number * 3600); + to = from + (logValue.duration as number) * 3600; } logs.push([from as number, to as number]); } @@ -515,7 +535,13 @@ export class InvoiceNinja implements INodeType { if (options.include) { qs.include = options.include as string; } - responseData = await invoiceNinjaApiRequest.call(this, 'GET', `/tasks/${taskId}`, {}, qs); + responseData = await invoiceNinjaApiRequest.call( + this, + 'GET', + `/tasks/${taskId}`, + {}, + qs, + ); responseData = responseData.data; } if (operation === 'getAll') { @@ -525,7 +551,14 @@ export class InvoiceNinja implements INodeType { qs.include = options.include as string; } if (returnAll === true) { - responseData = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/tasks', {}, qs); + responseData = await invoiceNinjaApiRequestAllItems.call( + this, + 'data', + 'GET', + '/tasks', + {}, + qs, + ); } else { qs.per_page = this.getNodeParameter('limit', 0) as number; responseData = await invoiceNinjaApiRequest.call(this, 'GET', '/tasks', {}, qs); @@ -565,7 +598,13 @@ export class InvoiceNinja implements INodeType { if (options.include) { qs.include = options.include as string; } - responseData = await invoiceNinjaApiRequest.call(this, 'GET', `/payments/${paymentId}`, {}, qs); + responseData = await invoiceNinjaApiRequest.call( + this, + 'GET', + `/payments/${paymentId}`, + {}, + qs, + ); responseData = responseData.data; } if (operation === 'getAll') { @@ -575,7 +614,14 @@ export class InvoiceNinja implements INodeType { qs.include = options.include as string; } if (returnAll === true) { - responseData = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/payments', {}, qs); + responseData = await invoiceNinjaApiRequestAllItems.call( + this, + 'data', + 'GET', + '/payments', + {}, + qs, + ); } else { qs.per_page = this.getNodeParameter('limit', 0) as number; responseData = await invoiceNinjaApiRequest.call(this, 'GET', '/payments', {}, qs); @@ -584,7 +630,11 @@ export class InvoiceNinja implements INodeType { } if (operation === 'delete') { const paymentId = this.getNodeParameter('paymentId', i) as string; - responseData = await invoiceNinjaApiRequest.call(this, 'DELETE', `/payments/${paymentId}`); + responseData = await invoiceNinjaApiRequest.call( + this, + 'DELETE', + `/payments/${paymentId}`, + ); responseData = responseData.data; } } @@ -648,13 +698,26 @@ export class InvoiceNinja implements INodeType { } if (operation === 'get') { const expenseId = this.getNodeParameter('expenseId', i) as string; - responseData = await invoiceNinjaApiRequest.call(this, 'GET', `/expenses/${expenseId}`, {}, qs); + responseData = await invoiceNinjaApiRequest.call( + this, + 'GET', + `/expenses/${expenseId}`, + {}, + qs, + ); responseData = responseData.data; } if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', 0) as boolean; if (returnAll === true) { - responseData = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/expenses', {}, qs); + responseData = await invoiceNinjaApiRequestAllItems.call( + this, + 'data', + 'GET', + '/expenses', + {}, + qs, + ); } else { qs.per_page = this.getNodeParameter('limit', 0) as number; responseData = await invoiceNinjaApiRequest.call(this, 'GET', '/expenses', {}, qs); @@ -663,7 +726,11 @@ export class InvoiceNinja implements INodeType { } if (operation === 'delete') { const expenseId = this.getNodeParameter('expenseId', i) as string; - responseData = await invoiceNinjaApiRequest.call(this, 'DELETE', `/expenses/${expenseId}`); + responseData = await invoiceNinjaApiRequest.call( + this, + 'DELETE', + `/expenses/${expenseId}`, + ); responseData = responseData.data; } } @@ -739,7 +806,8 @@ export class InvoiceNinja implements INodeType { if (additionalFields.emailQuote) { body.email_invoice = additionalFields.emailQuote as boolean; } - const invoceItemsValues = (this.getNodeParameter('invoiceItemsUi', i) as IDataObject).invoiceItemsValues as IDataObject[]; + const invoceItemsValues = (this.getNodeParameter('invoiceItemsUi', i) as IDataObject) + .invoiceItemsValues as IDataObject[]; if (invoceItemsValues) { const items: IItem[] = []; for (const itemValue of invoceItemsValues) { @@ -762,7 +830,9 @@ export class InvoiceNinja implements INodeType { } if (operation === 'email') { const quoteId = this.getNodeParameter('quoteId', i) as string; - responseData = await invoiceNinjaApiRequest.call(this, 'POST', '/email_invoice', { id: quoteId }); + responseData = await invoiceNinjaApiRequest.call(this, 'POST', '/email_invoice', { + id: quoteId, + }); } if (operation === 'get') { const quoteId = this.getNodeParameter('quoteId', i) as string; @@ -770,7 +840,13 @@ export class InvoiceNinja implements INodeType { if (options.include) { qs.include = options.include as string; } - responseData = await invoiceNinjaApiRequest.call(this, 'GET', `/invoices/${quoteId}`, {}, qs); + responseData = await invoiceNinjaApiRequest.call( + this, + 'GET', + `/invoices/${quoteId}`, + {}, + qs, + ); responseData = responseData.data; } if (operation === 'getAll') { @@ -783,7 +859,14 @@ export class InvoiceNinja implements INodeType { qs.invoice_number = options.invoiceNumber as string; } if (returnAll === true) { - responseData = await invoiceNinjaApiRequestAllItems.call(this, 'data', 'GET', '/quotes', {}, qs); + responseData = await invoiceNinjaApiRequestAllItems.call( + this, + 'data', + 'GET', + '/quotes', + {}, + qs, + ); } else { qs.per_page = this.getNodeParameter('limit', 0) as number; responseData = await invoiceNinjaApiRequest.call(this, 'GET', '/quotes', {}, qs); @@ -792,7 +875,11 @@ export class InvoiceNinja implements INodeType { } if (operation === 'delete') { const quoteId = this.getNodeParameter('quoteId', i) as string; - responseData = await invoiceNinjaApiRequest.call(this, 'DELETE', `/invoices/${quoteId}`); + responseData = await invoiceNinjaApiRequest.call( + this, + 'DELETE', + `/invoices/${quoteId}`, + ); responseData = responseData.data; } } diff --git a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinjaTrigger.node.ts b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinjaTrigger.node.ts index c2e4916868..556bdabe05 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinjaTrigger.node.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinjaTrigger.node.ts @@ -1,17 +1,8 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import { - INodeType, - INodeTypeDescription, - IWebhookResponseData, -} from 'n8n-workflow'; +import { INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; -import { - invoiceNinjaApiRequest, -} from './GenericFunctions'; +import { invoiceNinjaApiRequest } from './GenericFunctions'; export class InvoiceNinjaTrigger implements INodeType { description: INodeTypeDescription = { @@ -71,7 +62,6 @@ export class InvoiceNinjaTrigger implements INodeType { required: true, }, ], - }; // @ts-ignore (because of request) @@ -106,7 +96,6 @@ export class InvoiceNinjaTrigger implements INodeType { async delete(this: IHookFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); if (webhookData.webhookId !== undefined) { - const endpoint = `/hooks/${webhookData.webhookId}`; try { @@ -128,9 +117,7 @@ export class InvoiceNinjaTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const bodyData = this.getBodyData(); return { - workflowData: [ - this.helpers.returnJsonArray(bodyData), - ], + workflowData: [this.helpers.returnJsonArray(bodyData)], }; } } diff --git a/packages/nodes-base/nodes/InvoiceNinja/PaymentDescription.ts b/packages/nodes-base/nodes/InvoiceNinja/PaymentDescription.ts index fe3fd58579..0c63275a6e 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/PaymentDescription.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/PaymentDescription.ts @@ -8,9 +8,7 @@ export const paymentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'payment', - ], + resource: ['payment'], }, }, options: [ @@ -44,25 +42,22 @@ export const paymentOperations: INodeProperties[] = [ ]; export const paymentFields: INodeProperties[] = [ -/* -------------------------------------------------------------------------- */ -/* payment:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* payment:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Invoice Name or ID', name: 'invoice', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getInvoices', }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'payment', - ], + operation: ['create'], + resource: ['payment'], }, }, default: '', @@ -73,12 +68,8 @@ export const paymentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'payment', - ], + operation: ['create'], + resource: ['payment'], }, }, typeOptions: { @@ -94,12 +85,8 @@ export const paymentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'payment', - ], + operation: ['create'], + resource: ['payment'], }, }, options: [ @@ -257,9 +244,9 @@ export const paymentFields: INodeProperties[] = [ ], }, -/* -------------------------------------------------------------------------- */ -/* payment:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* payment:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Payment ID', name: 'paymentId', @@ -268,18 +255,14 @@ export const paymentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'delete', - ], + resource: ['payment'], + operation: ['delete'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* payment:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* payment:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Payment ID', name: 'paymentId', @@ -288,12 +271,8 @@ export const paymentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'get', - ], + resource: ['payment'], + operation: ['get'], }, }, }, @@ -305,12 +284,8 @@ export const paymentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'payment', - ], + operation: ['get'], + resource: ['payment'], }, }, options: [ @@ -328,21 +303,17 @@ export const paymentFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* payment:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* payment:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'getAll', - ], + resource: ['payment'], + operation: ['getAll'], }, }, default: false, @@ -354,15 +325,9 @@ export const paymentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['payment'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -380,12 +345,8 @@ export const paymentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'payment', - ], + operation: ['getAll'], + resource: ['payment'], }, }, options: [ @@ -403,5 +364,4 @@ export const paymentFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/InvoiceNinja/QuoteDescription.ts b/packages/nodes-base/nodes/InvoiceNinja/QuoteDescription.ts index e78426b7c2..12bf04d6b2 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/QuoteDescription.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/QuoteDescription.ts @@ -8,9 +8,7 @@ export const quoteOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'quote', - ], + resource: ['quote'], }, }, options: [ @@ -50,9 +48,9 @@ export const quoteOperations: INodeProperties[] = [ ]; export const quoteFields: INodeProperties[] = [ -/* -------------------------------------------------------------------------- */ -/* quote:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* quote:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Additional Fields', name: 'additionalFields', @@ -61,12 +59,8 @@ export const quoteFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'quote', - ], + operation: ['create'], + resource: ['quote'], }, }, options: [ @@ -74,7 +68,8 @@ export const quoteFields: INodeProperties[] = [ displayName: 'Client Name or ID', name: 'client', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getClients', }, @@ -241,12 +236,8 @@ export const quoteFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'create', - ], + resource: ['quote'], + operation: ['create'], }, }, default: {}, @@ -316,9 +307,9 @@ export const quoteFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* quote:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* quote:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Quote ID', name: 'quoteId', @@ -327,18 +318,14 @@ export const quoteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'delete', - ], + resource: ['quote'], + operation: ['delete'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* quote:email */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* quote:email */ + /* -------------------------------------------------------------------------- */ { displayName: 'Quote ID', name: 'quoteId', @@ -347,18 +334,14 @@ export const quoteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'email', - ], + resource: ['quote'], + operation: ['email'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* quote:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* quote:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Quote ID', name: 'quoteId', @@ -367,12 +350,8 @@ export const quoteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'get', - ], + resource: ['quote'], + operation: ['get'], }, }, }, @@ -384,12 +363,8 @@ export const quoteFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'quote', - ], + operation: ['get'], + resource: ['quote'], }, }, options: [ @@ -407,21 +382,17 @@ export const quoteFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* quote:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* quote:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'getAll', - ], + resource: ['quote'], + operation: ['getAll'], }, }, default: false, @@ -433,15 +404,9 @@ export const quoteFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['quote'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -459,12 +424,8 @@ export const quoteFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'quote', - ], + operation: ['getAll'], + resource: ['quote'], }, }, options: [ diff --git a/packages/nodes-base/nodes/InvoiceNinja/TaskDescription.ts b/packages/nodes-base/nodes/InvoiceNinja/TaskDescription.ts index 6da174001d..486b80ca3c 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/TaskDescription.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/TaskDescription.ts @@ -8,9 +8,7 @@ export const taskOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'task', - ], + resource: ['task'], }, }, options: [ @@ -44,9 +42,9 @@ export const taskOperations: INodeProperties[] = [ ]; export const taskFields: INodeProperties[] = [ -/* -------------------------------------------------------------------------- */ -/* task:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* task:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Additional Fields', name: 'additionalFields', @@ -55,12 +53,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'task', - ], + operation: ['create'], + resource: ['task'], }, }, options: [ @@ -68,7 +62,8 @@ export const taskFields: INodeProperties[] = [ displayName: 'Client Name or ID', name: 'client', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getClients', }, @@ -99,7 +94,8 @@ export const taskFields: INodeProperties[] = [ displayName: 'Project Name or ID', name: 'project', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getProjects', }, @@ -117,12 +113,8 @@ export const taskFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, default: {}, @@ -156,9 +148,9 @@ export const taskFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* task:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* task:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Task ID', name: 'taskId', @@ -167,18 +159,14 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'delete', - ], + resource: ['task'], + operation: ['delete'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* task:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* task:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Task ID', name: 'taskId', @@ -187,12 +175,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'get', - ], + resource: ['task'], + operation: ['get'], }, }, }, @@ -204,12 +188,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'task', - ], + operation: ['get'], + resource: ['task'], }, }, options: [ @@ -227,21 +207,17 @@ export const taskFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* task:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* task:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, default: false, @@ -253,15 +229,9 @@ export const taskFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['task'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -279,12 +249,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], + operation: ['getAll'], + resource: ['task'], }, }, options: [ @@ -302,5 +268,4 @@ export const taskFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/ItemLists/ItemLists.node.ts b/packages/nodes-base/nodes/ItemLists/ItemLists.node.ts index c097fb4d4c..11f92d0834 100644 --- a/packages/nodes-base/nodes/ItemLists/ItemLists.node.ts +++ b/packages/nodes-base/nodes/ItemLists/ItemLists.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,22 +9,9 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - get, - isEmpty, - isEqual, - isObject, - lt, - merge, - pick, - reduce, - set, - unset, -} from 'lodash'; +import { get, isEmpty, isEqual, isObject, lt, merge, pick, reduce, set, unset } from 'lodash'; -const { - NodeVM, -} = require('vm2'); +const { NodeVM } = require('vm2'); export class ItemLists implements INodeType { description: INodeTypeDescription = { @@ -105,12 +90,8 @@ export class ItemLists implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'splitOutItems', - ], + resource: ['itemList'], + operation: ['splitOutItems'], }, }, description: 'The name of the input field to break out into separate items', @@ -137,12 +118,8 @@ export class ItemLists implements INodeType { description: 'Whether to copy any other fields into the new items', displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'splitOutItems', - ], + resource: ['itemList'], + operation: ['splitOutItems'], }, }, }, @@ -157,15 +134,9 @@ export class ItemLists implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'splitOutItems', - ], - include: [ - 'selectedOtherFields', - ], + resource: ['itemList'], + operation: ['splitOutItems'], + include: ['selectedOtherFields'], }, }, options: [ @@ -202,12 +173,8 @@ export class ItemLists implements INodeType { ], displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'aggregateItems', - ], + resource: ['itemList'], + operation: ['aggregateItems'], }, }, }, @@ -220,18 +187,12 @@ export class ItemLists implements INodeType { multipleValues: true, }, placeholder: 'Add Field To Aggregate', - default: {fieldToAggregate: [{fieldToAggregate: '', renameField: false}]}, + default: { fieldToAggregate: [{ fieldToAggregate: '', renameField: false }] }, displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'aggregateItems', - ], - aggregate: [ - 'aggregateIndividualFields', - ], + resource: ['itemList'], + operation: ['aggregateItems'], + aggregate: ['aggregateIndividualFields'], }, }, options: [ @@ -258,14 +219,13 @@ export class ItemLists implements INodeType { name: 'outputFieldName', displayOptions: { show: { - renameField: [ - true, - ], + renameField: [true], }, }, type: 'string', default: '', - description: 'The name of the field to put the aggregated data in. Leave blank to use the input field name.', + description: + 'The name of the field to put the aggregated data in. Leave blank to use the input field name.', }, ], }, @@ -278,15 +238,9 @@ export class ItemLists implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'itemList', - ], - 'operation': [ - 'aggregateItems', - ], - aggregate: [ - 'aggregateAllItemData', - ], + resource: ['itemList'], + operation: ['aggregateItems'], + aggregate: ['aggregateAllItemData'], }, }, default: 'data', @@ -313,15 +267,9 @@ export class ItemLists implements INodeType { ], displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'aggregateItems', - ], - aggregate: [ - 'aggregateAllItemData', - ], + resource: ['itemList'], + operation: ['aggregateItems'], + aggregate: ['aggregateAllItemData'], }, }, }, @@ -351,18 +299,10 @@ export class ItemLists implements INodeType { ], displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'aggregateItems', - ], - aggregate: [ - 'aggregateAllItemData', - ], - include: [ - 'allFieldsExcept', - ], + resource: ['itemList'], + operation: ['aggregateItems'], + aggregate: ['aggregateAllItemData'], + include: ['allFieldsExcept'], }, }, }, @@ -392,18 +332,10 @@ export class ItemLists implements INodeType { ], displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'aggregateItems', - ], - aggregate: [ - 'aggregateAllItemData', - ], - include: [ - 'specifiedFields', - ], + resource: ['itemList'], + operation: ['aggregateItems'], + aggregate: ['aggregateAllItemData'], + include: ['specifiedFields'], }, }, }, @@ -430,12 +362,8 @@ export class ItemLists implements INodeType { description: 'The fields of the input items to compare to see if they are the same', displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'removeDuplicates', - ], + resource: ['itemList'], + operation: ['removeDuplicates'], }, }, }, @@ -450,15 +378,9 @@ export class ItemLists implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'removeDuplicates', - ], - compare: [ - 'allFieldsExcept', - ], + resource: ['itemList'], + operation: ['removeDuplicates'], + compare: ['allFieldsExcept'], }, }, options: [ @@ -488,15 +410,9 @@ export class ItemLists implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'removeDuplicates', - ], - compare: [ - 'selectedFields', - ], + resource: ['itemList'], + operation: ['removeDuplicates'], + compare: ['selectedFields'], }, }, options: [ @@ -538,12 +454,8 @@ export class ItemLists implements INodeType { description: 'The fields of the input items to compare to see if they are the same', displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'sort', - ], + resource: ['itemList'], + operation: ['sort'], }, }, }, @@ -592,15 +504,9 @@ export class ItemLists implements INodeType { description: 'The fields of the input items to compare to see if they are the same', displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'sort', - ], - type: [ - 'simple', - ], + resource: ['itemList'], + operation: ['sort'], + type: ['simple'], }, }, }, @@ -631,15 +537,9 @@ return 0;`, description: 'Javascript code to determine the order of any two items', displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'sort', - ], - type: [ - 'code', - ], + resource: ['itemList'], + operation: ['sort'], + type: ['code'], }, }, }, @@ -655,12 +555,8 @@ return 0;`, description: 'If there are more items than this number, some are removed', displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'limit', - ], + resource: ['itemList'], + operation: ['limit'], }, }, }, @@ -682,12 +578,8 @@ return 0;`, description: 'When removing items, whether to keep the ones at the start or the ending', displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'limit', - ], + resource: ['itemList'], + operation: ['limit'], }, }, }, @@ -699,16 +591,9 @@ return 0;`, default: {}, displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'removeDuplicates', - ], - compare: [ - 'allFieldsExcept', - 'selectedFields', - ], + resource: ['itemList'], + operation: ['removeDuplicates'], + compare: ['allFieldsExcept', 'selectedFields'], }, }, options: [ @@ -717,14 +602,16 @@ return 0;`, name: 'removeOtherFields', type: 'boolean', default: false, - description: 'Whether to remove any fields that are not being compared. If disabled, will keep the values from the first of the duplicates.', + description: + 'Whether to remove any fields that are not being compared. If disabled, will keep the values from the first of the duplicates.', }, { displayName: 'Disable Dot Notation', name: 'disableDotNotation', type: 'boolean', default: false, - description: 'Whether to disallow referencing child fields using `parent.child` in the field name', + description: + 'Whether to disallow referencing child fields using `parent.child` in the field name', }, ], }, @@ -736,15 +623,9 @@ return 0;`, default: {}, displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'sort', - ], - type: [ - 'simple', - ], + resource: ['itemList'], + operation: ['sort'], + type: ['simple'], }, }, options: [ @@ -753,7 +634,8 @@ return 0;`, name: 'disableDotNotation', type: 'boolean', default: false, - description: 'Whether to disallow referencing child fields using `parent.child` in the field name', + description: + 'Whether to disallow referencing child fields using `parent.child` in the field name', }, ], }, @@ -765,18 +647,11 @@ return 0;`, default: {}, displayOptions: { show: { - resource: [ - 'itemList', - ], - operation: [ - 'splitOutItems', - 'aggregateItems', - ], + resource: ['itemList'], + operation: ['splitOutItems', 'aggregateItems'], }, hide: { - 'aggregate': [ - 'aggregateAllItemData', - ], + aggregate: ['aggregateAllItemData'], }, }, options: [ @@ -786,14 +661,12 @@ return 0;`, type: 'boolean', displayOptions: { show: { - '/operation': [ - 'splitOutItems', - 'aggregateItems', - ], + '/operation': ['splitOutItems', 'aggregateItems'], }, }, default: false, - description: 'Whether to disallow referencing child fields using `parent.child` in the field name', + description: + 'Whether to disallow referencing child fields using `parent.child` in the field name', }, { displayName: 'Destination Field Name', @@ -801,9 +674,7 @@ return 0;`, type: 'string', displayOptions: { show: { - '/operation': [ - 'splitOutItems', - ], + '/operation': ['splitOutItems'], }, }, default: '', @@ -815,13 +686,12 @@ return 0;`, type: 'boolean', displayOptions: { show: { - '/operation': [ - 'aggregateItems', - ], + '/operation': ['aggregateItems'], }, }, default: false, - description: 'Whether to merge the output into a single flat list (rather than a list of lists), if the field to aggregate is a list', + description: + 'Whether to merge the output into a single flat list (rather than a list of lists), if the field to aggregate is a list', }, { displayName: 'Keep Missing And Null Values', @@ -829,13 +699,12 @@ return 0;`, type: 'boolean', displayOptions: { show: { - '/operation': [ - 'aggregateItems', - ], + '/operation': ['aggregateItems'], }, }, default: false, - description: 'Whether to add a null entry to the aggregated list when there is a missing or null value', + description: + 'Whether to add a null entry to the aggregated list when there is a missing or null value', }, ], }, @@ -850,11 +719,18 @@ return 0;`, const operation = this.getNodeParameter('operation', 0) as string; if (resource === 'itemList') { if (operation === 'splitOutItems') { - for (let i = 0; i < length; i++) { const fieldToSplitOut = this.getNodeParameter('fieldToSplitOut', i) as string; - const disableDotNotation = this.getNodeParameter('options.disableDotNotation', 0, false) as boolean; - const destinationFieldName = this.getNodeParameter('options.destinationFieldName', i, '') as string; + const disableDotNotation = this.getNodeParameter( + 'options.disableDotNotation', + 0, + false, + ) as boolean; + const destinationFieldName = this.getNodeParameter( + 'options.destinationFieldName', + i, + '', + ) as string; const include = this.getNodeParameter('include', i) as string; let arrayToSplit; @@ -866,25 +742,41 @@ return 0;`, if (arrayToSplit === undefined) { if (fieldToSplitOut.includes('.') && disableDotNotation === true) { - throw new NodeOperationError(this.getNode(), `Couldn't find the field '${fieldToSplitOut}' in the input data`, { description: `If you're trying to use a nested field, make sure you turn off 'disable dot notation' in the node options` }); + throw new NodeOperationError( + this.getNode(), + `Couldn't find the field '${fieldToSplitOut}' in the input data`, + { + description: `If you're trying to use a nested field, make sure you turn off 'disable dot notation' in the node options`, + }, + ); } else { - throw new NodeOperationError(this.getNode(), `Couldn't find the field '${fieldToSplitOut}' in the input data`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Couldn't find the field '${fieldToSplitOut}' in the input data`, + { itemIndex: i }, + ); } } if (!Array.isArray(arrayToSplit)) { - throw new NodeOperationError(this.getNode(), `The provided field '${fieldToSplitOut}' is not an array`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The provided field '${fieldToSplitOut}' is not an array`, + { itemIndex: i }, + ); } else { - for (const element of arrayToSplit) { let newItem = {}; if (include === 'selectedOtherFields') { - - const fieldsToInclude = (this.getNodeParameter('fieldsToInclude.fields', i, []) as [{ fieldName: string }]).map(field => field.fieldName); + const fieldsToInclude = ( + this.getNodeParameter('fieldsToInclude.fields', i, []) as [{ fieldName: string }] + ).map((field) => field.fieldName); if (!fieldsToInclude.length) { - throw new NodeOperationError(this.getNode(), 'No fields specified', { description: 'Please add a field to include' }); + throw new NodeOperationError(this.getNode(), 'No fields specified', { + description: 'Please add a field to include', + }); } newItem = { @@ -898,13 +790,11 @@ return 0;`, } else { value = items[i].json[field as string]; } - prev = { ...prev, [field as string]: value, }; + prev = { ...prev, [field as string]: value }; return prev; }, {}), }; - } else if (include === 'allOtherFields') { - const keys = Object.keys(items[i].json); newItem = { @@ -915,7 +805,7 @@ return 0;`, } else { value = items[i].json[field as string]; } - prev = { ...prev, [field as string]: value, }; + prev = { ...prev, [field as string]: value }; return prev; }, {}), }; @@ -923,10 +813,17 @@ return 0;`, unset(newItem, fieldToSplitOut); } - if (typeof element === 'object' && include === 'noOtherFields' && destinationFieldName === '') { + if ( + typeof element === 'object' && + include === 'noOtherFields' && + destinationFieldName === '' + ) { newItem = { ...newItem, ...element }; } else { - newItem = { ...newItem, [destinationFieldName as string || fieldToSplitOut as string]: element }; + newItem = { + ...newItem, + [(destinationFieldName as string) || (fieldToSplitOut as string)]: element, + }; } returnData.push({ @@ -940,24 +837,35 @@ return 0;`, } return this.prepareOutputData(returnData); - } else if (operation === 'aggregateItems') { const aggregate = this.getNodeParameter('aggregate', 0, '') as string; - if ( aggregate === 'aggregateIndividualFields') { - const disableDotNotation = this.getNodeParameter('options.disableDotNotation', 0, false) as boolean; + if (aggregate === 'aggregateIndividualFields') { + const disableDotNotation = this.getNodeParameter( + 'options.disableDotNotation', + 0, + false, + ) as boolean; const mergeLists = this.getNodeParameter('options.mergeLists', 0, false) as boolean; - const fieldsToAggregate = this.getNodeParameter('fieldsToAggregate.fieldToAggregate', 0, []) as [{ fieldToAggregate: string, renameField: boolean, outputFieldName: string }]; + const fieldsToAggregate = this.getNodeParameter( + 'fieldsToAggregate.fieldToAggregate', + 0, + [], + ) as [{ fieldToAggregate: string; renameField: boolean; outputFieldName: string }]; const keepMissing = this.getNodeParameter('options.keepMissing', 0, false) as boolean; if (!fieldsToAggregate.length) { - throw new NodeOperationError(this.getNode(), 'No fields specified', { description: 'Please add a field to aggregate' }); + throw new NodeOperationError(this.getNode(), 'No fields specified', { + description: 'Please add a field to aggregate', + }); } for (const { fieldToAggregate } of fieldsToAggregate) { let found = false; for (const item of items) { if (fieldToAggregate === '') { - throw new NodeOperationError(this.getNode(), 'Field to aggregate is blank', { description: 'Please add a field to aggregate' }); + throw new NodeOperationError(this.getNode(), 'Field to aggregate is blank', { + description: 'Please add a field to aggregate', + }); } if (disableDotNotation === false) { if (get(item.json, fieldToAggregate) !== undefined) { @@ -968,17 +876,25 @@ return 0;`, } } if (found === false && disableDotNotation && fieldToAggregate.includes('.')) { - throw new NodeOperationError(this.getNode(), `Couldn't find the field '${fieldToAggregate}' in the input data`, { description: `If you're trying to use a nested field, make sure you turn off 'disable dot notation' in the node options` }); + throw new NodeOperationError( + this.getNode(), + `Couldn't find the field '${fieldToAggregate}' in the input data`, + { + description: `If you're trying to use a nested field, make sure you turn off 'disable dot notation' in the node options`, + }, + ); } else if (found === false && keepMissing === false) { - throw new NodeOperationError(this.getNode(), `Couldn't find the field '${fieldToAggregate}' in the input data`); + throw new NodeOperationError( + this.getNode(), + `Couldn't find the field '${fieldToAggregate}' in the input data`, + ); } } - let newItem: INodeExecutionData; newItem = { json: {}, - pairedItem: Array.from({length}, (_, i) => i).map(index => { + pairedItem: Array.from({ length }, (_, i) => i).map((index) => { return { item: index, }; @@ -990,18 +906,26 @@ return 0;`, const outputFields: string[] = []; for (const { fieldToAggregate, outputFieldName, renameField } of fieldsToAggregate) { - - const field = (renameField) ? outputFieldName : fieldToAggregate; + const field = renameField ? outputFieldName : fieldToAggregate; if (outputFields.includes(field)) { - throw new NodeOperationError(this.getNode(), `The '${field}' output field is used more than once`, { description: `Please make sure each output field name is unique` }); + throw new NodeOperationError( + this.getNode(), + `The '${field}' output field is used more than once`, + { description: `Please make sure each output field name is unique` }, + ); } else { outputFields.push(field); } - const getFieldToAggregate = () => ((disableDotNotation === false && fieldToAggregate.includes('.')) ? fieldToAggregate.split('.').pop() : fieldToAggregate); + const getFieldToAggregate = () => + disableDotNotation === false && fieldToAggregate.includes('.') + ? fieldToAggregate.split('.').pop() + : fieldToAggregate; - const _outputFieldName = (outputFieldName) ? (outputFieldName) : getFieldToAggregate() as string; + const _outputFieldName = outputFieldName + ? outputFieldName + : (getFieldToAggregate() as string); if (fieldToAggregate !== '') { values[_outputFieldName] = []; @@ -1011,7 +935,7 @@ return 0;`, if (!keepMissing) { if (Array.isArray(value)) { - value = value.filter(value => value !== null); + value = value.filter((value) => value !== null); } else if (value === null || value === undefined) { continue; } @@ -1022,13 +946,12 @@ return 0;`, } else { values[_outputFieldName].push(value); } - } else { let value = items[i].json[fieldToAggregate]; if (!keepMissing) { if (Array.isArray(value)) { - value = value.filter(value => value !== null); + value = value.filter((value) => value !== null); } else if (value === null || value === undefined) { continue; } @@ -1055,27 +978,31 @@ return 0;`, returnData.push(newItem); return this.prepareOutputData(returnData); - } else { - let newItems: IDataObject[] = items.map(item => item.json); + let newItems: IDataObject[] = items.map((item) => item.json); const destinationFieldName = this.getNodeParameter('destinationFieldName', 0) as string; - const fieldsToExclude = (this.getNodeParameter('fieldsToExclude.fields', 0, []) as IDataObject[]).map(entry => entry.fieldName); - const fieldsToInclude = (this.getNodeParameter('fieldsToInclude.fields', 0, []) as IDataObject[]).map(entry => entry.fieldName); - + const fieldsToExclude = ( + this.getNodeParameter('fieldsToExclude.fields', 0, []) as IDataObject[] + ).map((entry) => entry.fieldName); + const fieldsToInclude = ( + this.getNodeParameter('fieldsToInclude.fields', 0, []) as IDataObject[] + ).map((entry) => entry.fieldName); if (fieldsToExclude.length || fieldsToInclude.length) { newItems = newItems.reduce((acc, item) => { - const newItem:IDataObject = {}; + const newItem: IDataObject = {}; let outputFields = Object.keys(item); if (fieldsToExclude.length) { - outputFields = outputFields.filter(key => !fieldsToExclude.includes(key)); + outputFields = outputFields.filter((key) => !fieldsToExclude.includes(key)); } if (fieldsToInclude.length) { - outputFields = outputFields.filter(key => fieldsToInclude.length ? fieldsToInclude.includes(key) : true); + outputFields = outputFields.filter((key) => + fieldsToInclude.length ? fieldsToInclude.includes(key) : true, + ); } - outputFields.forEach( key => { + outputFields.forEach((key) => { newItem[key] = item[key]; }); @@ -1086,21 +1013,31 @@ return 0;`, }, [] as IDataObject[]); } - const output: INodeExecutionData = { json: {[destinationFieldName]: newItems} }; + const output: INodeExecutionData = { json: { [destinationFieldName]: newItems } }; return this.prepareOutputData([output]); } - } else if (operation === 'removeDuplicates') { - const compare = this.getNodeParameter('compare', 0) as string; - const disableDotNotation = this.getNodeParameter('options.disableDotNotation', 0, false) as boolean; - const removeOtherFields = this.getNodeParameter('options.removeOtherFields', 0, false) as boolean; + const disableDotNotation = this.getNodeParameter( + 'options.disableDotNotation', + 0, + false, + ) as boolean; + const removeOtherFields = this.getNodeParameter( + 'options.removeOtherFields', + 0, + false, + ) as boolean; - let keys = (disableDotNotation) ? Object.keys(items[0].json) : Object.keys(flattenKeys(items[0].json)); + let keys = disableDotNotation + ? Object.keys(items[0].json) + : Object.keys(flattenKeys(items[0].json)); for (const item of items) { - for (const key of (disableDotNotation) ? Object.keys(item.json) : Object.keys(flattenKeys(item.json))) { + for (const key of disableDotNotation + ? Object.keys(item.json) + : Object.keys(flattenKeys(item.json))) { if (!keys.includes(key)) { keys.push(key); } @@ -1108,29 +1045,45 @@ return 0;`, } if (compare === 'allFieldsExcept') { - const fieldsToExclude = (this.getNodeParameter('fieldsToExclude.fields', 0, []) as [{ fieldName: string }]).map(field => field.fieldName); + const fieldsToExclude = ( + this.getNodeParameter('fieldsToExclude.fields', 0, []) as [{ fieldName: string }] + ).map((field) => field.fieldName); if (!fieldsToExclude.length) { - throw new NodeOperationError(this.getNode(), 'No fields specified. Please add a field to exclude from comparison'); + throw new NodeOperationError( + this.getNode(), + 'No fields specified. Please add a field to exclude from comparison', + ); } if (disableDotNotation === false) { keys = Object.keys(flattenKeys(items[0].json)); } - keys = keys.filter(key => !fieldsToExclude.includes(key)); - - } if (compare === 'selectedFields') { - const fieldsToCompare = (this.getNodeParameter('fieldsToCompare.fields', 0, []) as [{ fieldName: string }]).map(field => field.fieldName); + keys = keys.filter((key) => !fieldsToExclude.includes(key)); + } + if (compare === 'selectedFields') { + const fieldsToCompare = ( + this.getNodeParameter('fieldsToCompare.fields', 0, []) as [{ fieldName: string }] + ).map((field) => field.fieldName); if (!fieldsToCompare.length) { - throw new NodeOperationError(this.getNode(), 'No fields specified. Please add a field to compare on'); + throw new NodeOperationError( + this.getNode(), + 'No fields specified. Please add a field to compare on', + ); } if (disableDotNotation === false) { keys = Object.keys(flattenKeys(items[0].json)); } - keys = fieldsToCompare.map(key => (key.trim())); + keys = fieldsToCompare.map((key) => key.trim()); } // This solution is O(nlogn) // add original index to the items - const newItems = items.map((item, index) => ({ json: { ...item['json'], __INDEX: index, }, pairedItem: { item: index, } } as INodeExecutionData)); + const newItems = items.map( + (item, index) => + ({ + json: { ...item['json'], __INDEX: index }, + pairedItem: { item: index }, + } as INodeExecutionData), + ); //sort items using the compare keys newItems.sort((a, b) => { let result = 0; @@ -1163,14 +1116,25 @@ return 0;`, if (key === '') { throw new NodeOperationError(this.getNode(), `Name of field to compare is blank`); } - const value = ((!disableDotNotation) ? get(item.json, key) : item.json[key]); + const value = !disableDotNotation ? get(item.json, key) : item.json[key]; if (value === undefined && disableDotNotation && key.includes('.')) { - throw new NodeOperationError(this.getNode(), `'${key}' field is missing from some input items`, { description: `If you're trying to use a nested field, make sure you turn off 'disable dot notation' in the node options` }); + throw new NodeOperationError( + this.getNode(), + `'${key}' field is missing from some input items`, + { + description: `If you're trying to use a nested field, make sure you turn off 'disable dot notation' in the node options`, + }, + ); } else if (value === undefined) { - throw new NodeOperationError(this.getNode(), `'${key}' field is missing from some input items`); + throw new NodeOperationError( + this.getNode(), + `'${key}' field is missing from some input items`, + ); } if (type !== undefined && value !== undefined && type !== typeof value) { - throw new NodeOperationError(this.getNode(), `'${key}' isn't always the same type`, { description: 'The type of this field varies between items' }); + throw new NodeOperationError(this.getNode(), `'${key}' isn't always the same type`, { + description: 'The type of this field varies between items', + }); } else { type = typeof value; } @@ -1191,17 +1155,22 @@ return 0;`, let data = items.filter((_, index) => !removedIndexes.includes(index)); if (removeOtherFields) { - data = data.map((item, index) => ({ json: pick(item.json, ...keys), pairedItem: { item: index, } })); + data = data.map((item, index) => ({ + json: pick(item.json, ...keys), + pairedItem: { item: index }, + })); } // return the filtered items return this.prepareOutputData(data); - } else if (operation === 'sort') { - let newItems = [...items]; const type = this.getNodeParameter('type', 0) as string; - const disableDotNotation = this.getNodeParameter('options.disableDotNotation', 0, false) as boolean; + const disableDotNotation = this.getNodeParameter( + 'options.disableDotNotation', + 0, + false, + ) as boolean; if (type === 'random') { shuffleArray(newItems); @@ -1209,16 +1178,17 @@ return 0;`, } if (type === 'simple') { - const sortFieldsUi = this.getNodeParameter('sortFieldsUi', 0) as IDataObject; const sortFields = sortFieldsUi.sortField as Array<{ fieldName: string; - order: 'ascending' | 'descending' + order: 'ascending' | 'descending'; }>; - if (!sortFields || !sortFields.length) { - throw new NodeOperationError(this.getNode(), 'No sorting specified. Please add a field to sort by'); + throw new NodeOperationError( + this.getNode(), + 'No sorting specified. Please add a field to sort by', + ); } for (const { fieldName } of sortFields) { @@ -1233,37 +1203,73 @@ return 0;`, } } if (found === false && disableDotNotation && fieldName.includes('.')) { - throw new NodeOperationError(this.getNode(), `Couldn't find the field '${fieldName}' in the input data`, { description: `If you're trying to use a nested field, make sure you turn off 'disable dot notation' in the node options` }); + throw new NodeOperationError( + this.getNode(), + `Couldn't find the field '${fieldName}' in the input data`, + { + description: `If you're trying to use a nested field, make sure you turn off 'disable dot notation' in the node options`, + }, + ); } else if (found === false) { - throw new NodeOperationError(this.getNode(), `Couldn't find the field '${fieldName}' in the input data`); + throw new NodeOperationError( + this.getNode(), + `Couldn't find the field '${fieldName}' in the input data`, + ); } } - const sortFieldsWithDirection = sortFields.map(field => ({ name: field.fieldName, dir: field.order === 'ascending' ? 1 : -1 })); + const sortFieldsWithDirection = sortFields.map((field) => ({ + name: field.fieldName, + dir: field.order === 'ascending' ? 1 : -1, + })); newItems.sort((a, b) => { let result = 0; for (const field of sortFieldsWithDirection) { let equal; if (disableDotNotation === false) { - const _a = (typeof get(a.json, field.name) === 'string') ? (get(a.json, field.name) as string).toLowerCase() : get(a.json, field.name); - const _b = (typeof get(b.json, field.name) === 'string') ? (get(b.json, field.name) as string).toLowerCase() : get(b.json, field.name); + const _a = + typeof get(a.json, field.name) === 'string' + ? (get(a.json, field.name) as string).toLowerCase() + : get(a.json, field.name); + const _b = + typeof get(b.json, field.name) === 'string' + ? (get(b.json, field.name) as string).toLowerCase() + : get(b.json, field.name); equal = isEqual(_a, _b); } else { - const _a = (typeof a.json[field.name as string] === 'string') ? (a.json[field.name as string] as string).toLowerCase() : a.json[field.name as string]; - const _b = (typeof b.json[field.name as string] === 'string') ? (b.json[field.name as string] as string).toLowerCase() : b.json[field.name as string]; + const _a = + typeof a.json[field.name as string] === 'string' + ? (a.json[field.name as string] as string).toLowerCase() + : a.json[field.name as string]; + const _b = + typeof b.json[field.name as string] === 'string' + ? (b.json[field.name as string] as string).toLowerCase() + : b.json[field.name as string]; equal = isEqual(_a, _b); } if (!equal) { let lessThan; if (disableDotNotation === false) { - const _a = (typeof get(a.json, field.name) === 'string') ? (get(a.json, field.name) as string).toLowerCase() : get(a.json, field.name); - const _b = (typeof get(b.json, field.name) === 'string') ? (get(b.json, field.name) as string).toLowerCase() : get(b.json, field.name); + const _a = + typeof get(a.json, field.name) === 'string' + ? (get(a.json, field.name) as string).toLowerCase() + : get(a.json, field.name); + const _b = + typeof get(b.json, field.name) === 'string' + ? (get(b.json, field.name) as string).toLowerCase() + : get(b.json, field.name); lessThan = lt(_a, _b); } else { - const _a = (typeof a.json[field.name as string] === 'string') ? (a.json[field.name as string] as string).toLowerCase() : a.json[field.name as string]; - const _b = (typeof b.json[field.name as string] === 'string') ? (b.json[field.name as string] as string).toLowerCase() : b.json[field.name as string]; + const _a = + typeof a.json[field.name as string] === 'string' + ? (a.json[field.name as string] as string).toLowerCase() + : a.json[field.name as string]; + const _b = + typeof b.json[field.name as string] === 'string' + ? (b.json[field.name as string] as string).toLowerCase() + : b.json[field.name as string]; lessThan = lt(_a, _b); } if (lessThan) { @@ -1281,33 +1287,35 @@ return 0;`, const regexCheck = /\breturn\b/g.exec(code); if (regexCheck && regexCheck.length) { - const sandbox = { newItems, }; const mode = this.getMode(); const options = { - console: (mode === 'manual') ? 'redirect' : 'inherit', + console: mode === 'manual' ? 'redirect' : 'inherit', sandbox, }; const vm = new NodeVM(options); - newItems = (await vm.run(` + newItems = await vm.run( + ` module.exports = async function() { newItems.sort( (a,b) => { ${code} }) return newItems; - }()`, __dirname)); - + }()`, + __dirname, + ); } else { - throw new NodeOperationError(this.getNode(), `Sort code doesn't return. Please add a 'return' statement to your code`); + throw new NodeOperationError( + this.getNode(), + `Sort code doesn't return. Please add a 'return' statement to your code`, + ); } } return this.prepareOutputData(newItems); - } else if (operation === 'limit') { - let newItems = items; const maxItems = this.getNodeParameter('maxItems', 0) as number; const keep = this.getNodeParameter('keep', 0) as string; @@ -1322,7 +1330,6 @@ return 0;`, newItems = items.slice(items.length - maxItems, items.length); } return this.prepareOutputData(newItems); - } else { throw new NodeOperationError(this.getNode(), `Operation '${operation}' is not recognized`); } @@ -1332,7 +1339,13 @@ return 0;`, } } -const compareItems = (obj: INodeExecutionData, obj2: INodeExecutionData, keys: string[], disableDotNotation: boolean, node: INode) => { +const compareItems = ( + obj: INodeExecutionData, + obj2: INodeExecutionData, + keys: string[], + disableDotNotation: boolean, + node: INode, +) => { let result = true; for (const key of keys) { if (disableDotNotation === false) { diff --git a/packages/nodes-base/nodes/Iterable/EventDescription.ts b/packages/nodes-base/nodes/Iterable/EventDescription.ts index 04cd175fe2..d7c737d249 100644 --- a/packages/nodes-base/nodes/Iterable/EventDescription.ts +++ b/packages/nodes-base/nodes/Iterable/EventDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const eventOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const eventOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'event', - ], + resource: ['event'], }, }, options: [ @@ -28,7 +24,6 @@ export const eventOperations: INodeProperties[] = [ ]; export const eventFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* event:track */ /* -------------------------------------------------------------------------- */ @@ -39,12 +34,8 @@ export const eventFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'track', - ], + resource: ['event'], + operation: ['track'], }, }, description: 'The name of the event to track', @@ -58,12 +49,8 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'track', - ], + resource: ['event'], + operation: ['track'], }, }, options: [ @@ -119,14 +106,16 @@ export const eventFields: INodeProperties[] = [ type: 'string', placeholder: 'name@email.com', default: '', - description: 'Either email or userId must be passed in to identify the user. If both are passed in, email takes precedence.', + description: + 'Either email or userId must be passed in to identify the user. If both are passed in, email takes precedence.', }, { displayName: 'ID', name: 'id', type: 'string', default: '', - description: 'Optional event ID. If an event exists with that ID, the event will be updated. If none is specified, a new ID will automatically be generated and returned.', + description: + 'Optional event ID. If an event exists with that ID, the event will be updated. If none is specified, a new ID will automatically be generated and returned.', }, { displayName: 'Template ID', diff --git a/packages/nodes-base/nodes/Iterable/GenericFunctions.ts b/packages/nodes-base/nodes/Iterable/GenericFunctions.ts index 068598b270..051cfd5baf 100644 --- a/packages/nodes-base/nodes/Iterable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Iterable/GenericFunctions.ts @@ -1,25 +1,26 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; - -export async function iterableApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError } from 'n8n-workflow'; +export async function iterableApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('iterableApi'); const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', - 'Api_Key': credentials.apiKey, + Api_Key: credentials.apiKey, }, method, body, @@ -36,14 +37,21 @@ export async function iterableApiRequest(this: IExecuteFunctions | IExecuteSingl } //@ts-ignore return await this.helpers.request.call(this, options); - } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function iterableApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function iterableApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -53,10 +61,7 @@ export async function iterableApiRequestAllItems(this: IExecuteFunctions | ILoad responseData = await iterableApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData['nextPageToken']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['nextPageToken'] !== undefined && - responseData['nextPageToken'] !== '' - ); + } while (responseData['nextPageToken'] !== undefined && responseData['nextPageToken'] !== ''); return returnData; } diff --git a/packages/nodes-base/nodes/Iterable/Iterable.node.ts b/packages/nodes-base/nodes/Iterable/Iterable.node.ts index 7ee0b57810..430f44fbbe 100644 --- a/packages/nodes-base/nodes/Iterable/Iterable.node.ts +++ b/packages/nodes-base/nodes/Iterable/Iterable.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -13,24 +11,13 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - iterableApiRequest, -} from './GenericFunctions'; +import { iterableApiRequest } from './GenericFunctions'; -import { - eventFields, - eventOperations, -} from './EventDescription'; +import { eventFields, eventOperations } from './EventDescription'; -import { - userFields, - userOperations, -} from './UserDescription'; +import { userFields, userOperations } from './UserDescription'; -import { - userListFields, - userListOperations, -} from './UserListDescription'; +import { userListFields, userListOperations } from './UserListDescription'; import moment from 'moment-timezone'; @@ -119,13 +106,16 @@ export class Iterable implements INodeType { const events = []; for (let i = 0; i < length; i++) { - const name = this.getNodeParameter('name', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (!additionalFields.email && !additionalFields.id) { - throw new NodeOperationError(this.getNode(), 'Either email or userId must be passed in to identify the user. Please add one of both via "Additional Fields". If both are passed in, email takes precedence.', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Either email or userId must be passed in to identify the user. Please add one of both via "Additional Fields". If both are passed in, email takes precedence.', + { itemIndex: i }, + ); } const body: IDataObject = { @@ -161,7 +151,6 @@ export class Iterable implements INodeType { if (operation === 'upsert') { // https://api.iterable.com/api/docs#users_updateUser for (let i = 0; i < length; i++) { - const identifier = this.getNodeParameter('identifier', i) as string; const value = this.getNodeParameter('value', i) as string; @@ -193,8 +182,10 @@ export class Iterable implements INodeType { if (this.continueOnFail() === false) { if (responseData.code !== 'Success') { - throw new NodeOperationError(this.getNode(), - `Iterable error response [400]: ${responseData.msg}`, { itemIndex: i }, + throw new NodeOperationError( + this.getNode(), + `Iterable error response [400]: ${responseData.msg}`, + { itemIndex: i }, ); } } @@ -235,7 +226,6 @@ export class Iterable implements INodeType { // https://api.iterable.com/api/docs#users_getUser // https://api.iterable.com/api/docs#users_getUserById for (let i = 0; i < length; i++) { - const by = this.getNodeParameter('by', i) as string; let endpoint; @@ -253,9 +243,10 @@ export class Iterable implements INodeType { if (this.continueOnFail() === false) { if (Object.keys(responseData).length === 0) { - throw new NodeApiError(this.getNode(), responseData, - { message: `User not found`, httpCode: '404' }, - ); + throw new NodeApiError(this.getNode(), responseData, { + message: `User not found`, + httpCode: '404', + }); } } @@ -280,7 +271,6 @@ export class Iterable implements INodeType { const subscribers: IDataObject[] = []; for (let i = 0; i < length; i++) { - const value = this.getNodeParameter('value', i) as string; if (identifier === 'email') { @@ -315,7 +305,6 @@ export class Iterable implements INodeType { const subscribers: IDataObject[] = []; for (let i = 0; i < length; i++) { - const value = this.getNodeParameter('value', i) as string; if (identifier === 'email') { diff --git a/packages/nodes-base/nodes/Iterable/UserDescription.ts b/packages/nodes-base/nodes/Iterable/UserDescription.ts index 531be9b245..840df98256 100644 --- a/packages/nodes-base/nodes/Iterable/UserDescription.ts +++ b/packages/nodes-base/nodes/Iterable/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -40,7 +36,6 @@ export const userOperations: INodeProperties[] = [ ]; export const userFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* user:upsert */ /* -------------------------------------------------------------------------- */ @@ -61,12 +56,8 @@ export const userFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'upsert', - ], + resource: ['user'], + operation: ['upsert'], }, }, default: '', @@ -79,12 +70,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'upsert', - ], + resource: ['user'], + operation: ['upsert'], }, }, default: '', @@ -96,15 +83,9 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'upsert', - ], - identifier: [ - 'userId', - ], + resource: ['user'], + operation: ['upsert'], + identifier: ['userId'], }, }, default: true, @@ -118,12 +99,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'upsert', - ], + resource: ['user'], + operation: ['upsert'], }, }, options: [ @@ -164,7 +141,8 @@ export const userFields: INodeProperties[] = [ name: 'mergeNestedObjects', type: 'boolean', default: false, - description: 'Whether to merge top level objects instead of overwriting (default: false), e.g. if user profile has data: {mySettings:{mobile:true}} and change contact field has data: {mySettings:{email:true}}, the resulting profile: {mySettings:{mobile:true,email:true}}', + description: + 'Whether to merge top level objects instead of overwriting (default: false), e.g. if user profile has data: {mySettings:{mobile:true}} and change contact field has data: {mySettings:{email:true}}, the resulting profile: {mySettings:{mobile:true,email:true}}', }, ], }, @@ -189,12 +167,8 @@ export const userFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'delete', - ], + resource: ['user'], + operation: ['delete'], }, }, default: 'email', @@ -207,15 +181,9 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'delete', - ], - by: [ - 'userId', - ], + resource: ['user'], + operation: ['delete'], + by: ['userId'], }, }, default: '', @@ -229,15 +197,9 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'delete', - ], - by: [ - 'email', - ], + resource: ['user'], + operation: ['delete'], + by: ['email'], }, }, default: '', @@ -264,12 +226,8 @@ export const userFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, default: 'email', @@ -282,15 +240,9 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], - by: [ - 'userId', - ], + resource: ['user'], + operation: ['get'], + by: ['userId'], }, }, default: '', @@ -304,15 +256,9 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], - by: [ - 'email', - ], + resource: ['user'], + operation: ['get'], + by: ['email'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Iterable/UserListDescription.ts b/packages/nodes-base/nodes/Iterable/UserListDescription.ts index 70f34c23c2..f6ce56e456 100644 --- a/packages/nodes-base/nodes/Iterable/UserListDescription.ts +++ b/packages/nodes-base/nodes/Iterable/UserListDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userListOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userListOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'userList', - ], + resource: ['userList'], }, }, options: [ @@ -34,7 +30,6 @@ export const userListOperations: INodeProperties[] = [ ]; export const userListFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* userList:add */ /* -------------------------------------------------------------------------- */ @@ -48,16 +43,13 @@ export const userListFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'userList', - ], - operation: [ - 'add', - ], + resource: ['userList'], + operation: ['add'], }, }, default: '', - description: 'Identifier to be used. Choose from the list, or specify an ID using an expression.', + description: + 'Identifier to be used. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Identifier', @@ -76,12 +68,8 @@ export const userListFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'userList', - ], - operation: [ - 'add', - ], + resource: ['userList'], + operation: ['add'], }, }, default: '', @@ -94,12 +82,8 @@ export const userListFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'userList', - ], - operation: [ - 'add', - ], + resource: ['userList'], + operation: ['add'], }, }, default: '', @@ -118,16 +102,13 @@ export const userListFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'userList', - ], - operation: [ - 'remove', - ], + resource: ['userList'], + operation: ['remove'], }, }, default: '', - description: 'Identifier to be used. Choose from the list, or specify an ID using an expression.', + description: + 'Identifier to be used. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Identifier', @@ -146,12 +127,8 @@ export const userListFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'userList', - ], - operation: [ - 'remove', - ], + resource: ['userList'], + operation: ['remove'], }, }, default: '', @@ -164,12 +141,8 @@ export const userListFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'userList', - ], - operation: [ - 'remove', - ], + resource: ['userList'], + operation: ['remove'], }, }, default: '', @@ -182,12 +155,8 @@ export const userListFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'userList', - ], - operation: [ - 'remove', - ], + resource: ['userList'], + operation: ['remove'], }, }, options: [ @@ -203,7 +172,8 @@ export const userListFields: INodeProperties[] = [ name: 'channelUnsubscribe', type: 'boolean', default: false, - description: 'Whether to unsubscribe email from list\'s associated channel - essentially a global unsubscribe', + description: + "Whether to unsubscribe email from list's associated channel - essentially a global unsubscribe", }, ], }, diff --git a/packages/nodes-base/nodes/Jenkins/GenericFunctions.ts b/packages/nodes-base/nodes/Jenkins/GenericFunctions.ts index f176018d6e..a19be32f53 100644 --- a/packages/nodes-base/nodes/Jenkins/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Jenkins/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,16 +7,22 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function jenkinsApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, uri: string, qs: IDataObject = {}, body: any = '', option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function jenkinsApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + uri: string, + qs: IDataObject = {}, + // tslint:disable-next-line:no-any + body: any = '', + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('jenkinsApi'); let options: OptionsWithUri = { headers: { - 'Accept': 'application/json', + Accept: 'application/json', }, method, auth: { @@ -39,7 +43,5 @@ export async function jenkinsApiRequest(this: IHookFunctions | IExecuteFunctions } export function tolerateTrailingSlash(baseUrl: string) { - return baseUrl.endsWith('/') - ? baseUrl.substr(0, baseUrl.length - 1) - : baseUrl; + return baseUrl.endsWith('/') ? baseUrl.substr(0, baseUrl.length - 1) : baseUrl; } diff --git a/packages/nodes-base/nodes/Jenkins/Jenkins.node.ts b/packages/nodes-base/nodes/Jenkins/Jenkins.node.ts index 1cc35f1906..ef6e448d5f 100644 --- a/packages/nodes-base/nodes/Jenkins/Jenkins.node.ts +++ b/packages/nodes-base/nodes/Jenkins/Jenkins.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -15,10 +13,7 @@ import { NodeApiError, } from 'n8n-workflow'; -import { - jenkinsApiRequest, - tolerateTrailingSlash -} from './GenericFunctions'; +import { jenkinsApiRequest, tolerateTrailingSlash } from './GenericFunctions'; export type JenkinsApiCredentials = { username: string; @@ -80,9 +75,7 @@ export class Jenkins implements INodeType { type: 'options', displayOptions: { show: { - resource: [ - 'job', - ], + resource: ['job'], }, }, options: [ @@ -116,17 +109,14 @@ export class Jenkins implements INodeType { noDataExpression: true, }, { - displayName: 'Make sure the job is setup to support triggering with parameters. More info', + displayName: + 'Make sure the job is setup to support triggering with parameters. More info', name: 'triggerParamsNotice', type: 'notice', displayOptions: { show: { - resource: [ - 'job', - ], - operation: [ - 'triggerParams', - ], + resource: ['job'], + operation: ['triggerParams'], }, }, default: '', @@ -140,19 +130,14 @@ export class Jenkins implements INodeType { }, displayOptions: { show: { - resource: [ - 'job', - ], - operation: [ - 'trigger', - 'triggerParams', - 'copy', - ], + resource: ['job'], + operation: ['trigger', 'triggerParams', 'copy'], }, }, required: true, default: '', - description: 'Name of the job. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the job. Choose from the list, or specify an ID using an expression.', }, // -------------------------------------------------------------------------------------------------------- @@ -165,12 +150,8 @@ export class Jenkins implements INodeType { placeholder: 'Add Parameter', displayOptions: { show: { - resource: [ - 'job', - ], - operation: [ - 'triggerParams', - ], + resource: ['job'], + operation: ['triggerParams'], }, }, required: true, @@ -187,12 +168,11 @@ export class Jenkins implements INodeType { displayName: 'Name or ID', name: 'name', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getJobParameters', - loadOptionsDependsOn: [ - 'job', - ], + loadOptionsDependsOn: ['job'], }, default: '', }, @@ -217,13 +197,8 @@ export class Jenkins implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'job', - ], - operation: [ - 'copy', - 'create', - ], + resource: ['job'], + operation: ['copy', 'create'], }, }, required: true, @@ -239,12 +214,8 @@ export class Jenkins implements INodeType { }, displayOptions: { show: { - resource: [ - 'job', - ], - operation: [ - 'create', - ], + resource: ['job'], + operation: ['create'], }, }, required: true, @@ -252,18 +223,15 @@ export class Jenkins implements INodeType { description: 'XML of Jenkins config', }, { - displayName: 'To get the XML of an existing job, add ‘config.xml’ to the end of the job URL', + displayName: + 'To get the XML of an existing job, add ‘config.xml’ to the end of the job URL', name: 'createNotice', type: 'notice', default: '', displayOptions: { show: { - resource: [ - 'job', - ], - operation: [ - 'create', - ], + resource: ['job'], + operation: ['create'], }, }, }, @@ -277,9 +245,7 @@ export class Jenkins implements INodeType { type: 'options', displayOptions: { show: { - resource: [ - 'instance', - ], + resource: ['instance'], }, }, options: [ @@ -292,7 +258,8 @@ export class Jenkins implements INodeType { { name: 'Quiet Down', value: 'quietDown', - description: 'Put Jenkins in quiet mode, no builds can be started, Jenkins is ready for shutdown', + description: + 'Put Jenkins in quiet mode, no builds can be started, Jenkins is ready for shutdown', action: 'Quiet Down an instance', }, { @@ -304,7 +271,8 @@ export class Jenkins implements INodeType { { name: 'Safely Restart', value: 'safeRestart', - description: 'Restart Jenkins once no jobs are running on environments where it is possible', + description: + 'Restart Jenkins once no jobs are running on environments where it is possible', action: 'Safely Restart an instance', }, { @@ -330,27 +298,22 @@ export class Jenkins implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'instance', - ], - operation: [ - 'quietDown', - ], + resource: ['instance'], + operation: ['quietDown'], }, }, default: '', description: 'Freeform reason for quiet down mode', }, { - displayName: 'Instance operation can shutdown Jenkins instance and make it unresponsive. Some commands may not be available depending on instance implementation.', + displayName: + 'Instance operation can shutdown Jenkins instance and make it unresponsive. Some commands may not be available depending on instance implementation.', name: 'instanceNotice', type: 'notice', default: '', displayOptions: { show: { - resource: [ - 'instance', - ], + resource: ['instance'], }, }, }, @@ -364,9 +327,7 @@ export class Jenkins implements INodeType { type: 'options', displayOptions: { show: { - resource: [ - 'build', - ], + resource: ['build'], }, }, options: [ @@ -389,17 +350,14 @@ export class Jenkins implements INodeType { }, displayOptions: { show: { - resource: [ - 'build', - ], - operation: [ - 'getAll', - ], + resource: ['build'], + operation: ['getAll'], }, }, required: true, default: '', - description: 'Name of the job. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the job. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -408,12 +366,8 @@ export class Jenkins implements INodeType { default: false, displayOptions: { show: { - resource: [ - 'build', - ], - operation: [ - 'getAll', - ], + resource: ['build'], + operation: ['getAll'], }, }, description: 'Whether to return all results or only up to a given limit', @@ -428,15 +382,9 @@ export class Jenkins implements INodeType { }, displayOptions: { show: { - resource: [ - 'build', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['build'], + operation: ['getAll'], + returnAll: [false], }, }, description: 'Max number of results to return', @@ -493,8 +441,12 @@ export class Jenkins implements INodeType { }); } returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -516,8 +468,12 @@ export class Jenkins implements INodeType { } } returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -554,7 +510,12 @@ export class Jenkins implements INodeType { }, {}); } const endpoint = `/job/${job}/buildWithParameters`; - await jenkinsApiRequest.call(this, 'POST', endpoint, {}, {}, + await jenkinsApiRequest.call( + this, + 'POST', + endpoint, + {}, + {}, { form: body, headers: { @@ -577,8 +538,7 @@ export class Jenkins implements INodeType { try { await jenkinsApiRequest.call(this, 'POST', endpoint, queryParams); responseData = { success: true }; - } - catch (error) { + } catch (error) { if (error.httpCode === '302') { responseData = { success: true }; } else { @@ -598,7 +558,10 @@ export class Jenkins implements INodeType { const body = this.getNodeParameter('xml', i) as string; const endpoint = `/createItem`; - await jenkinsApiRequest.call(this, 'POST', endpoint, queryParams, body, { headers, json: false }); + await jenkinsApiRequest.call(this, 'POST', endpoint, queryParams, body, { + headers, + json: false, + }); responseData = { success: true }; } } diff --git a/packages/nodes-base/nodes/Jira/GenericFunctions.ts b/packages/nodes-base/nodes/Jira/GenericFunctions.ts index b0a8b0d8e8..b51c2d28de 100644 --- a/packages/nodes-base/nodes/Jira/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Jira/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -17,8 +15,17 @@ import { NodeOperationError, } from 'n8n-workflow'; -export async function jiraSoftwareCloudApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, endpoint: string, method: string, body: any = {}, query?: IDataObject, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function jiraSoftwareCloudApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + endpoint: string, + method: string, + // tslint:disable-next-line:no-any + body: any = {}, + query?: IDataObject, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const jiraVersion = this.getNodeParameter('jiraVersion', 0) as string; let domain = ''; @@ -64,8 +71,16 @@ export async function jiraSoftwareCloudApiRequest(this: IHookFunctions | IExecut } } -export async function jiraSoftwareCloudApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, endpoint: string, method: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function jiraSoftwareCloudApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + endpoint: string, + method: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -80,14 +95,13 @@ export async function jiraSoftwareCloudApiRequestAllItems(this: IHookFunctions | returnData.push.apply(returnData, responseData[propertyName]); query.startAt = responseData.startAt + responseData.maxResults; body.startAt = responseData.startAt + responseData.maxResults; - } while ( - (responseData.startAt + responseData.maxResults < responseData.total) - ); + } while (responseData.startAt + responseData.maxResults < responseData.total); return returnData; } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); @@ -111,11 +125,11 @@ export function getId(url: string) { } export function simplifyIssueOutput(responseData: { - names: { [key: string]: string }, - fields: IDataObject, - id: string, - key: string, - self: string + names: { [key: string]: string }; + fields: IDataObject; + id: string; + key: string; + self: string; }) { const mappedFields: IDataObject = { id: responseData.id, diff --git a/packages/nodes-base/nodes/Jira/IssueAttachmentDescription.ts b/packages/nodes-base/nodes/Jira/IssueAttachmentDescription.ts index 0438205d9a..086d8f17cf 100644 --- a/packages/nodes-base/nodes/Jira/IssueAttachmentDescription.ts +++ b/packages/nodes-base/nodes/Jira/IssueAttachmentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const issueAttachmentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const issueAttachmentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'issueAttachment', - ], + resource: ['issueAttachment'], }, }, options: [ @@ -46,7 +42,6 @@ export const issueAttachmentOperations: INodeProperties[] = [ ]; export const issueAttachmentFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* issueAttachment:add */ /* -------------------------------------------------------------------------- */ @@ -57,12 +52,8 @@ export const issueAttachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issueAttachment', - ], - operation: [ - 'add', - ], + resource: ['issueAttachment'], + operation: ['add'], }, }, default: '', @@ -71,12 +62,8 @@ export const issueAttachmentFields: INodeProperties[] = [ displayName: 'Binary Property', displayOptions: { show: { - resource: [ - 'issueAttachment', - ], - operation: [ - 'add', - ], + resource: ['issueAttachment'], + operation: ['add'], }, }, name: 'binaryPropertyName', @@ -96,12 +83,8 @@ export const issueAttachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issueAttachment', - ], - operation: [ - 'get', - ], + resource: ['issueAttachment'], + operation: ['get'], }, }, default: '', @@ -115,12 +98,8 @@ export const issueAttachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issueAttachment', - ], - operation: [ - 'get', - ], + resource: ['issueAttachment'], + operation: ['get'], }, }, }, @@ -131,15 +110,9 @@ export const issueAttachmentFields: INodeProperties[] = [ default: 'data', displayOptions: { show: { - resource: [ - 'issueAttachment', - ], - operation: [ - 'get', - ], - download: [ - true, - ], + resource: ['issueAttachment'], + operation: ['get'], + download: [true], }, }, description: 'Object property name which holds binary data', @@ -155,12 +128,8 @@ export const issueAttachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issueAttachment', - ], - operation: [ - 'getAll', - ], + resource: ['issueAttachment'], + operation: ['getAll'], }, }, default: '', @@ -171,12 +140,8 @@ export const issueAttachmentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'issueAttachment', - ], - operation: [ - 'getAll', - ], + resource: ['issueAttachment'], + operation: ['getAll'], }, }, default: false, @@ -188,15 +153,9 @@ export const issueAttachmentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'issueAttachment', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['issueAttachment'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -214,12 +173,8 @@ export const issueAttachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issueAttachment', - ], - operation: [ - 'getAll', - ], + resource: ['issueAttachment'], + operation: ['getAll'], }, }, }, @@ -230,15 +185,9 @@ export const issueAttachmentFields: INodeProperties[] = [ default: 'data', displayOptions: { show: { - resource: [ - 'issueAttachment', - ], - operation: [ - 'getAll', - ], - download: [ - true, - ], + resource: ['issueAttachment'], + operation: ['getAll'], + download: [true], }, }, description: 'Object property name which holds binary data', @@ -254,12 +203,8 @@ export const issueAttachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issueAttachment', - ], - operation: [ - 'remove', - ], + resource: ['issueAttachment'], + operation: ['remove'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Jira/IssueCommentDescription.ts b/packages/nodes-base/nodes/Jira/IssueCommentDescription.ts index ff05f40ce3..aedcbf1b61 100644 --- a/packages/nodes-base/nodes/Jira/IssueCommentDescription.ts +++ b/packages/nodes-base/nodes/Jira/IssueCommentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const issueCommentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const issueCommentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'issueComment', - ], + resource: ['issueComment'], }, }, options: [ @@ -52,7 +48,6 @@ export const issueCommentOperations: INodeProperties[] = [ ]; export const issueCommentFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* issueComment:add */ /* -------------------------------------------------------------------------- */ @@ -63,12 +58,8 @@ export const issueCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'add', - ], + resource: ['issueComment'], + operation: ['add'], }, }, default: '', @@ -82,12 +73,8 @@ export const issueCommentFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'add', - ], + resource: ['issueComment'], + operation: ['add'], }, }, }, @@ -98,18 +85,12 @@ export const issueCommentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'add', - ], - jsonParameters: [ - false, - ], + resource: ['issueComment'], + operation: ['add'], + jsonParameters: [false], }, }, - description: 'Comment\'s text', + description: "Comment's text", }, { displayName: 'Document Format (JSON)', @@ -118,18 +99,13 @@ export const issueCommentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'add', - ], - jsonParameters: [ - true, - ], + resource: ['issueComment'], + operation: ['add'], + jsonParameters: [true], }, }, - description: 'The Atlassian Document Format (ADF). Online builder can be found here.', + description: + 'The Atlassian Document Format (ADF). Online builder can be found here.', }, { displayName: 'Options', @@ -139,12 +115,8 @@ export const issueCommentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'add', - ], + resource: ['issueComment'], + operation: ['add'], }, }, options: [ @@ -159,7 +131,8 @@ export const issueCommentFields: INodeProperties[] = [ }, ], default: '', - description: 'Use expand to include additional information about comments in the response. This parameter accepts Rendered Body, which returns the comment body rendered in HTML.', + description: + 'Use expand to include additional information about comments in the response. This parameter accepts Rendered Body, which returns the comment body rendered in HTML.', }, ], }, @@ -174,12 +147,8 @@ export const issueCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'get', - ], + resource: ['issueComment'], + operation: ['get'], }, }, default: '', @@ -193,12 +162,8 @@ export const issueCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'get', - ], + resource: ['issueComment'], + operation: ['get'], }, }, description: 'The ID of the comment', @@ -211,12 +176,8 @@ export const issueCommentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'get', - ], + resource: ['issueComment'], + operation: ['get'], }, }, options: [ @@ -231,7 +192,8 @@ export const issueCommentFields: INodeProperties[] = [ }, ], default: '', - description: 'Use expand to include additional information about comments in the response. This parameter accepts Rendered Body, which returns the comment body rendered in HTML.', + description: + 'Use expand to include additional information about comments in the response. This parameter accepts Rendered Body, which returns the comment body rendered in HTML.', }, ], }, @@ -246,12 +208,8 @@ export const issueCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'getAll', - ], + resource: ['issueComment'], + operation: ['getAll'], }, }, default: '', @@ -263,12 +221,8 @@ export const issueCommentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'getAll', - ], + resource: ['issueComment'], + operation: ['getAll'], }, }, default: false, @@ -280,15 +234,9 @@ export const issueCommentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['issueComment'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -306,12 +254,8 @@ export const issueCommentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'getAll', - ], + resource: ['issueComment'], + operation: ['getAll'], }, }, options: [ @@ -326,7 +270,8 @@ export const issueCommentFields: INodeProperties[] = [ }, ], default: '', - description: 'Use expand to include additional information about comments in the response. This parameter accepts Rendered Body, which returns the comment body rendered in HTML.', + description: + 'Use expand to include additional information about comments in the response. This parameter accepts Rendered Body, which returns the comment body rendered in HTML.', }, ], }, @@ -341,12 +286,8 @@ export const issueCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'remove', - ], + resource: ['issueComment'], + operation: ['remove'], }, }, default: '', @@ -360,12 +301,8 @@ export const issueCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'remove', - ], + resource: ['issueComment'], + operation: ['remove'], }, }, description: 'The ID of the comment', @@ -381,12 +318,8 @@ export const issueCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'update', - ], + resource: ['issueComment'], + operation: ['update'], }, }, default: '', @@ -400,12 +333,8 @@ export const issueCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'update', - ], + resource: ['issueComment'], + operation: ['update'], }, }, description: 'The ID of the comment', @@ -417,12 +346,8 @@ export const issueCommentFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'update', - ], + resource: ['issueComment'], + operation: ['update'], }, }, }, @@ -433,18 +358,12 @@ export const issueCommentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'update', - ], - jsonParameters: [ - false, - ], + resource: ['issueComment'], + operation: ['update'], + jsonParameters: [false], }, }, - description: 'Comment\'s text', + description: "Comment's text", }, { displayName: 'Document Format (JSON)', @@ -453,18 +372,13 @@ export const issueCommentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['issueComment'], + operation: ['update'], + jsonParameters: [true], }, }, - description: 'The Atlassian Document Format (ADF). Online builder can be found here.', + description: + 'The Atlassian Document Format (ADF). Online builder can be found here.', }, { displayName: 'Options', @@ -474,12 +388,8 @@ export const issueCommentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issueComment', - ], - operation: [ - 'update', - ], + resource: ['issueComment'], + operation: ['update'], }, }, options: [ @@ -494,7 +404,8 @@ export const issueCommentFields: INodeProperties[] = [ }, ], default: '', - description: 'Use expand to include additional information about comments in the response. This parameter accepts Rendered Body, which returns the comment body rendered in HTML.', + description: + 'Use expand to include additional information about comments in the response. This parameter accepts Rendered Body, which returns the comment body rendered in HTML.', }, ], }, diff --git a/packages/nodes-base/nodes/Jira/IssueDescription.ts b/packages/nodes-base/nodes/Jira/IssueDescription.ts index da3a47eaab..73713bb49d 100644 --- a/packages/nodes-base/nodes/Jira/IssueDescription.ts +++ b/packages/nodes-base/nodes/Jira/IssueDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const issueOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const issueOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'issue', - ], + resource: ['issue'], }, }, options: [ @@ -55,7 +51,8 @@ export const issueOperations: INodeProperties[] = [ { name: 'Status', value: 'transitions', - description: 'Return either all transitions or a transition that can be performed by the user on an issue, based on the issue\'s status', + description: + "Return either all transitions or a transition that can be performed by the user on an issue, based on the issue's status", action: 'Get the status of an issue', }, { @@ -70,7 +67,6 @@ export const issueOperations: INodeProperties[] = [ ]; export const issueFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* issue:create */ /* -------------------------------------------------------------------------- */ @@ -78,24 +74,19 @@ export const issueFields: INodeProperties[] = [ displayName: 'Project Name or ID', name: 'project', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', required: true, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'create', - ], + resource: ['issue'], + operation: ['create'], }, }, typeOptions: { loadOptionsMethod: 'getProjects', - loadOptionsDependsOn: [ - 'jiraVersion', - ], + loadOptionsDependsOn: ['jiraVersion'], }, }, { @@ -106,21 +97,16 @@ export const issueFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'create', - ], + resource: ['issue'], + operation: ['create'], }, }, typeOptions: { loadOptionsMethod: 'getIssueTypes', - loadOptionsDependsOn: [ - 'project', - ], + loadOptionsDependsOn: ['project'], }, - description: 'Issue Types. Choose from the list, or specify an ID using an expression.', + description: + 'Issue Types. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Summary', @@ -129,12 +115,8 @@ export const issueFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'create', - ], + resource: ['issue'], + operation: ['create'], }, }, default: '', @@ -147,12 +129,8 @@ export const issueFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'create', - ], + resource: ['issue'], + operation: ['create'], }, }, options: [ @@ -160,7 +138,8 @@ export const issueFields: INodeProperties[] = [ displayName: 'Assignee Name or ID', name: 'assignee', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getUsers', }, @@ -176,12 +155,11 @@ export const issueFields: INodeProperties[] = [ displayName: 'Component Names or IDs', name: 'componentIds', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getProjectComponents', - loadOptionsDependsOn: [ - 'project', - ], + loadOptionsDependsOn: ['project'], }, default: [], }, @@ -205,11 +183,10 @@ export const issueFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCustomFields', - loadOptionsDependsOn: [ - 'project', - ], + loadOptionsDependsOn: ['project'], }, - description: 'ID of the field to set. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the field to set. Choose from the list, or specify an ID using an expression.', default: '', }, { @@ -227,16 +204,15 @@ export const issueFields: INodeProperties[] = [ displayName: 'Label Names or IDs', name: 'labels', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getLabels', }, default: [], displayOptions: { show: { - '/jiraVersion': [ - 'cloud', - ], + '/jiraVersion': ['cloud'], }, }, }, @@ -247,9 +223,7 @@ export const issueFields: INodeProperties[] = [ default: [], displayOptions: { show: { - '/jiraVersion': [ - 'server', - ], + '/jiraVersion': ['server'], }, }, typeOptions: { @@ -266,7 +240,8 @@ export const issueFields: INodeProperties[] = [ displayName: 'Priority Name or ID', name: 'priority', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getPriorities', }, @@ -276,7 +251,8 @@ export const issueFields: INodeProperties[] = [ displayName: 'Reporter Name or ID', name: 'reporter', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getUsers', }, @@ -287,7 +263,8 @@ export const issueFields: INodeProperties[] = [ name: 'updateHistory', type: 'boolean', default: false, - description: 'Whether the project in which the issue is created is added to the user\'s Recently viewed project list, as shown under Projects in Jira', + description: + "Whether the project in which the issue is created is added to the user's Recently viewed project list, as shown under Projects in Jira", }, ], }, @@ -302,12 +279,8 @@ export const issueFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'update', - ], + resource: ['issue'], + operation: ['update'], }, }, default: '', @@ -320,12 +293,8 @@ export const issueFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'update', - ], + resource: ['issue'], + operation: ['update'], }, }, options: [ @@ -333,7 +302,8 @@ export const issueFields: INodeProperties[] = [ displayName: 'Assignee Name or ID', name: 'assignee', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getUsers', }, @@ -365,11 +335,10 @@ export const issueFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCustomFields', - loadOptionsDependsOn: [ - 'issueKey', - ], + loadOptionsDependsOn: ['issueKey'], }, - description: 'ID of the field to set. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the field to set. Choose from the list, or specify an ID using an expression.', default: '', }, { @@ -394,16 +363,15 @@ export const issueFields: INodeProperties[] = [ displayName: 'Label Names or IDs', name: 'labels', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getLabels', }, default: [], displayOptions: { show: { - '/jiraVersion': [ - 'cloud', - ], + '/jiraVersion': ['cloud'], }, }, }, @@ -414,9 +382,7 @@ export const issueFields: INodeProperties[] = [ default: [], displayOptions: { show: { - '/jiraVersion': [ - 'server', - ], + '/jiraVersion': ['server'], }, }, typeOptions: { @@ -433,7 +399,8 @@ export const issueFields: INodeProperties[] = [ displayName: 'Priority Name or ID', name: 'priority', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getPriorities', }, @@ -443,7 +410,8 @@ export const issueFields: INodeProperties[] = [ displayName: 'Reporter Name or ID', name: 'reporter', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getUsers', }, @@ -463,7 +431,8 @@ export const issueFields: INodeProperties[] = [ loadOptionsMethod: 'getTransitions', }, default: '', - description: 'The ID of the issue status. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the issue status. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -478,12 +447,8 @@ export const issueFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'delete', - ], + resource: ['issue'], + operation: ['delete'], }, }, default: '', @@ -495,12 +460,8 @@ export const issueFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'delete', - ], + resource: ['issue'], + operation: ['delete'], }, }, default: false, @@ -516,12 +477,8 @@ export const issueFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'get', - ], + resource: ['issue'], + operation: ['get'], }, }, default: '', @@ -532,12 +489,8 @@ export const issueFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'get', - ], + resource: ['issue'], + operation: ['get'], }, }, default: false, @@ -551,12 +504,8 @@ export const issueFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'get', - ], + resource: ['issue'], + operation: ['get'], }, }, options: [ @@ -581,28 +530,32 @@ export const issueFields: INodeProperties[] = [ name: 'fields', type: 'string', default: '', - description: 'A list of fields to return for the issue. This parameter accepts a comma-separated list. Use it to retrieve a subset of fields. Allowed values: *all Returns all fields. *navigable Returns navigable fields. Any issue field, prefixed with a minus to exclude.', + description: + 'A list of fields to return for the issue. This parameter accepts a comma-separated list. Use it to retrieve a subset of fields. Allowed values: *all Returns all fields. *navigable Returns navigable fields. Any issue field, prefixed with a minus to exclude.', }, { displayName: 'Fields By Key', name: 'fieldsByKey', type: 'boolean', default: false, - description: 'Whether fields in fields are referenced by keys rather than IDs. This parameter is useful where fields have been added by a connect app and a field\'s key may differ from its ID.', + description: + "Whether fields in fields are referenced by keys rather than IDs. This parameter is useful where fields have been added by a connect app and a field's key may differ from its ID.", }, { displayName: 'Properties', name: 'properties', type: 'string', default: '', - description: 'A list of issue properties to return for the issue. This parameter accepts a comma-separated list. Allowed values: *all Returns all issue properties. Any issue property key, prefixed with a minus to exclude. Examples: *all Returns all properties. *all,-prop1 Returns all properties except prop1. prop1,prop2 Returns prop1 and prop2 properties. This parameter may be specified multiple times. For example, properties=prop1,prop2& properties=prop3.', + description: + 'A list of issue properties to return for the issue. This parameter accepts a comma-separated list. Allowed values: *all Returns all issue properties. Any issue property key, prefixed with a minus to exclude. Examples: *all Returns all properties. *all,-prop1 Returns all properties except prop1. prop1,prop2 Returns prop1 and prop2 properties. This parameter may be specified multiple times. For example, properties=prop1,prop2& properties=prop3.', }, { displayName: 'Update History', name: 'updateHistory', type: 'boolean', default: false, - description: 'Whether the project in which the issue is created is added to the user\'s Recently viewed project list, as shown under Projects in Jira. This also populates the JQL issues search lastViewed field.', + description: + "Whether the project in which the issue is created is added to the user's Recently viewed project list, as shown under Projects in Jira. This also populates the JQL issues search lastViewed field.", }, ], }, @@ -616,12 +569,8 @@ export const issueFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'getAll', - ], + resource: ['issue'], + operation: ['getAll'], }, }, default: false, @@ -633,15 +582,9 @@ export const issueFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['issue'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -658,12 +601,8 @@ export const issueFields: INodeProperties[] = [ placeholder: 'Add Option', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'issue', - ], + operation: ['getAll'], + resource: ['issue'], }, }, default: {}, @@ -677,7 +616,8 @@ export const issueFields: INodeProperties[] = [ { name: 'Changelog', value: 'changelog', - description: 'Returns a list of recent updates to an issue, sorted by date, starting from the most recent', + description: + 'Returns a list of recent updates to an issue, sorted by date, starting from the most recent', }, { name: 'Editmeta', @@ -712,7 +652,7 @@ export const issueFields: INodeProperties[] = [ { name: 'Versioned Representations', value: 'versionedRepresentations', - description: 'JSON array containing each version of a field\'s value', + description: "JSON array containing each version of a field's value", }, ], description: 'Use expand to include additional information about issues in the response', @@ -722,14 +662,16 @@ export const issueFields: INodeProperties[] = [ name: 'fields', type: 'string', default: '*navigable', - description: 'A list of fields to return for each issue, use it to retrieve a subset of fields. This parameter accepts a comma-separated list. Expand options include: *all Returns all fields. *navigable Returns navigable fields. Any issue field, prefixed with a minus to exclude.', + description: + 'A list of fields to return for each issue, use it to retrieve a subset of fields. This parameter accepts a comma-separated list. Expand options include: *all Returns all fields. *navigable Returns navigable fields. Any issue field, prefixed with a minus to exclude.', }, { displayName: 'Fields By Key', name: 'fieldsByKey', type: 'boolean', default: false, - description: 'Whether fields in fields are referenced by keys rather than IDs. This parameter is useful where fields have been added by a connect app and a field\'s key may differ from its ID.', + description: + "Whether fields in fields are referenced by keys rather than IDs. This parameter is useful where fields have been added by a connect app and a field's key may differ from its ID.", }, { displayName: 'JQL', @@ -753,12 +695,8 @@ export const issueFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'changelog', - ], + resource: ['issue'], + operation: ['changelog'], }, }, default: '', @@ -769,12 +707,8 @@ export const issueFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'changelog', - ], + resource: ['issue'], + operation: ['changelog'], }, }, default: false, @@ -786,15 +720,9 @@ export const issueFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'changelog', - ], - returnAll: [ - false, - ], + resource: ['issue'], + operation: ['changelog'], + returnAll: [false], }, }, typeOptions: { @@ -814,12 +742,8 @@ export const issueFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'notify', - ], + resource: ['issue'], + operation: ['notify'], }, }, default: '', @@ -831,12 +755,8 @@ export const issueFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'notify', - ], + resource: ['issue'], + operation: ['notify'], }, }, }, @@ -848,12 +768,8 @@ export const issueFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'notify', - ], + resource: ['issue'], + operation: ['notify'], }, }, options: [ @@ -872,7 +788,8 @@ export const issueFields: INodeProperties[] = [ name: 'subject', type: 'string', default: '', - description: 'The subject of the email notification for the issue. If this is not specified, then the subject is set to the issue key and summary.', + description: + 'The subject of the email notification for the issue. If this is not specified, then the subject is set to the issue key and summary.', }, { displayName: 'Text Body', @@ -882,7 +799,8 @@ export const issueFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'The subject of the email notification for the issue. If this is not specified, then the subject is set to the issue key and summary.', + description: + 'The subject of the email notification for the issue. If this is not specified, then the subject is set to the issue key and summary.', }, ], }, @@ -898,15 +816,9 @@ export const issueFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'notify', - ], - jsonParameters: [ - false, - ], + resource: ['issue'], + operation: ['notify'], + jsonParameters: [false], }, }, options: [ @@ -918,7 +830,7 @@ export const issueFields: INodeProperties[] = [ displayName: 'Reporter', name: 'reporter', type: 'boolean', - description: 'Whether the notification should be sent to the issue\'s reporter', + description: "Whether the notification should be sent to the issue's reporter", default: false, }, { @@ -926,21 +838,21 @@ export const issueFields: INodeProperties[] = [ name: 'assignee', type: 'boolean', default: false, - description: 'Whether the notification should be sent to the issue\'s assignees', + description: "Whether the notification should be sent to the issue's assignees", }, { displayName: 'Watchers', name: 'watchers', type: 'boolean', default: false, - description: 'Whether the notification should be sent to the issue\'s assignees', + description: "Whether the notification should be sent to the issue's assignees", }, { displayName: 'Voters', name: 'voters', type: 'boolean', default: false, - description: 'Whether the notification should be sent to the issue\'s voters', + description: "Whether the notification should be sent to the issue's voters", }, { displayName: 'User Names or IDs', @@ -950,7 +862,8 @@ export const issueFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: [], - description: 'List of users to receive the notification. Choose from the list, or specify IDs using an expression.', + description: + 'List of users to receive the notification. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Group Names or IDs', @@ -960,10 +873,10 @@ export const issueFields: INodeProperties[] = [ loadOptionsMethod: 'getGroups', }, default: [], - description: 'List of groups to receive the notification. Choose from the list, or specify IDs using an expression.', + description: + 'List of groups to receive the notification. Choose from the list, or specify IDs using an expression.', }, ], - }, ], }, @@ -976,15 +889,9 @@ export const issueFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'notify', - ], - jsonParameters: [ - true, - ], + resource: ['issue'], + operation: ['notify'], + jsonParameters: [true], }, }, default: '', @@ -1002,15 +909,9 @@ export const issueFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'notify', - ], - jsonParameters: [ - false, - ], + resource: ['issue'], + operation: ['notify'], + jsonParameters: [false], }, }, options: [ @@ -1026,7 +927,8 @@ export const issueFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: [], - description: 'List of users to receive the notification. Choose from the list, or specify IDs using an expression.', + description: + 'List of users to receive the notification. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Group Names or IDs', @@ -1036,10 +938,10 @@ export const issueFields: INodeProperties[] = [ loadOptionsMethod: 'getGroups', }, default: [], - description: 'List of groups to receive the notification. Choose from the list, or specify IDs using an expression.', + description: + 'List of groups to receive the notification. Choose from the list, or specify IDs using an expression.', }, ], - }, ], }, @@ -1052,15 +954,9 @@ export const issueFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'notify', - ], - jsonParameters: [ - true, - ], + resource: ['issue'], + operation: ['notify'], + jsonParameters: [true], }, }, default: '', @@ -1077,12 +973,8 @@ export const issueFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'transitions', - ], + resource: ['issue'], + operation: ['transitions'], }, }, default: '', @@ -1095,12 +987,8 @@ export const issueFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'transitions', - ], + resource: ['issue'], + operation: ['transitions'], }, }, options: [ @@ -1109,7 +997,8 @@ export const issueFields: INodeProperties[] = [ name: 'expand', type: 'string', default: '', - description: 'Use expand to include additional information about transitions in the response. This parameter accepts transitions.fields, which returns information about the fields in the transition screen for each transition. Fields hidden from the screen are not returned. Use this information to populate the fields and update fields in Transition issue.', + description: + 'Use expand to include additional information about transitions in the response. This parameter accepts transitions.fields, which returns information about the fields in the transition screen for each transition. Fields hidden from the screen are not returned. Use this information to populate the fields and update fields in Transition issue.', }, { displayName: 'Transition ID', @@ -1123,7 +1012,8 @@ export const issueFields: INodeProperties[] = [ name: 'skipRemoteOnlyCondition', type: 'boolean', default: false, - description: 'Whether transitions with the condition Hide From User Condition are included in the response', + description: + 'Whether transitions with the condition Hide From User Condition are included in the response', }, ], }, diff --git a/packages/nodes-base/nodes/Jira/IssueInterface.ts b/packages/nodes-base/nodes/Jira/IssueInterface.ts index 1e7b21b0ba..57bc665a03 100644 --- a/packages/nodes-base/nodes/Jira/IssueInterface.ts +++ b/packages/nodes-base/nodes/Jira/IssueInterface.ts @@ -1,6 +1,4 @@ -import { - IDataObject, -} from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export interface IFields { assignee?: IDataObject; diff --git a/packages/nodes-base/nodes/Jira/Jira.node.ts b/packages/nodes-base/nodes/Jira/Jira.node.ts index f5d94d56f2..f5d159cfa7 100644 --- a/packages/nodes-base/nodes/Jira/Jira.node.ts +++ b/packages/nodes-base/nodes/Jira/Jira.node.ts @@ -1,11 +1,6 @@ +import { mergeWith } from 'lodash'; -import { - mergeWith, -} from 'lodash'; - -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryData, @@ -26,20 +21,11 @@ import { validateJSON, } from './GenericFunctions'; -import { - issueAttachmentFields, - issueAttachmentOperations, -} from './IssueAttachmentDescription'; +import { issueAttachmentFields, issueAttachmentOperations } from './IssueAttachmentDescription'; -import { - issueCommentFields, - issueCommentOperations, -} from './IssueCommentDescription'; +import { issueCommentFields, issueCommentOperations } from './IssueCommentDescription'; -import { - issueFields, - issueOperations, -} from './IssueDescription'; +import { issueFields, issueOperations } from './IssueDescription'; import { IFields, @@ -49,10 +35,7 @@ import { NotificationRecipientsRestrictions, } from './IssueInterface'; -import { - userFields, - userOperations, -} from './UserDescription'; +import { userFields, userOperations } from './UserDescription'; export class Jira implements INodeType { description: INodeTypeDescription = { @@ -74,9 +57,7 @@ export class Jira implements INodeType { required: true, displayOptions: { show: { - jiraVersion: [ - 'cloud', - ], + jiraVersion: ['cloud'], }, }, }, @@ -85,9 +66,7 @@ export class Jira implements INodeType { required: true, displayOptions: { show: { - jiraVersion: [ - 'server', - ], + jiraVersion: ['server'], }, }, }, @@ -118,7 +97,8 @@ export class Jira implements INodeType { { name: 'Issue', value: 'issue', - description: 'Creates an issue or, where the option to create subtasks is enabled in Jira, a subtask', + description: + 'Creates an issue or, where the option to create subtasks is enabled in Jira, a subtask', }, { name: 'Issue Attachment', @@ -164,7 +144,12 @@ export class Jira implements INodeType { projects = await jiraSoftwareCloudApiRequest.call(this, endpoint, 'GET'); } else { endpoint = '/api/2/project/search'; - projects = await jiraSoftwareCloudApiRequestAllItems.call(this, 'values', endpoint, 'GET'); + projects = await jiraSoftwareCloudApiRequestAllItems.call( + this, + 'values', + endpoint, + 'GET', + ); } if (projects.values && Array.isArray(projects.values)) { @@ -180,8 +165,12 @@ export class Jira implements INodeType { } returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -193,7 +182,11 @@ export class Jira implements INodeType { async getIssueTypes(this: ILoadOptionsFunctions): Promise { const projectId = this.getCurrentNodeParameter('project'); const returnData: INodePropertyOptions[] = []; - const { issueTypes } = await jiraSoftwareCloudApiRequest.call(this, `/api/2/project/${projectId}`, 'GET'); + const { issueTypes } = await jiraSoftwareCloudApiRequest.call( + this, + `/api/2/project/${projectId}`, + 'GET', + ); for (const issueType of issueTypes) { const issueTypeName = issueType.name; const issueTypeId = issueType.id; @@ -204,8 +197,12 @@ export class Jira implements INodeType { } returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); return returnData; @@ -229,8 +226,12 @@ export class Jira implements INodeType { } returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -255,8 +256,12 @@ export class Jira implements INodeType { } returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -272,23 +277,24 @@ export class Jira implements INodeType { if (jiraVersion === 'server') { endpoint = '/api/2/user/search'; - query.username = '\''; + query.username = "'"; } const users = await jiraSoftwareCloudApiRequest.call(this, endpoint, 'GET', {}, query); - return users.reduce((activeUsers: INodePropertyOptions[], user: IDataObject) => { - if (user.active) { - activeUsers.push({ - name: user.displayName as string, - value: (user.accountId || user.name) as string, - }); - } - return activeUsers; - }, []).sort((a: INodePropertyOptions, b: INodePropertyOptions) => { - return a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1; - }); - + return users + .reduce((activeUsers: INodePropertyOptions[], user: IDataObject) => { + if (user.active) { + activeUsers.push({ + name: user.displayName as string, + value: (user.accountId || user.name) as string, + }); + } + return activeUsers; + }, []) + .sort((a: INodePropertyOptions, b: INodePropertyOptions) => { + return a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1; + }); }, // Get all the groups to display them to user so that he can @@ -309,8 +315,12 @@ export class Jira implements INodeType { } returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -323,7 +333,11 @@ export class Jira implements INodeType { const returnData: INodePropertyOptions[] = []; const issueKey = this.getCurrentNodeParameter('issueKey'); - const transitions = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/transitions`, 'GET'); + const transitions = await jiraSoftwareCloudApiRequest.call( + this, + `/api/2/issue/${issueKey}/transitions`, + 'GET', + ); for (const transition of transitions.transitions) { returnData.push({ @@ -333,8 +347,12 @@ export class Jira implements INodeType { } returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -353,15 +371,28 @@ export class Jira implements INodeType { issueTypeId = this.getCurrentNodeParameter('issueType') as string; } else { const issueKey = this.getCurrentNodeParameter('issueKey') as string; - const res = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'GET', {}, {}); + const res = await jiraSoftwareCloudApiRequest.call( + this, + `/api/2/issue/${issueKey}`, + 'GET', + {}, + {}, + ); projectId = res.fields.project.id; issueTypeId = res.fields.issuetype.id; } - const res = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/createmeta?projectIds=${projectId}&issueTypeIds=${issueTypeId}&expand=projects.issuetypes.fields`, 'GET'); + const res = await jiraSoftwareCloudApiRequest.call( + this, + `/api/2/issue/createmeta?projectIds=${projectId}&issueTypeIds=${issueTypeId}&expand=projects.issuetypes.fields`, + 'GET', + ); - // tslint:disable-next-line: no-any - const fields = res.projects.find((o: any) => o.id === projectId).issuetypes.find((o: any) => o.id === issueTypeId).fields; + const fields = res.projects + // tslint:disable-next-line:no-any + .find((o: any) => o.id === projectId) + // tslint:disable-next-line:no-any + .issuetypes.find((o: any) => o.id === issueTypeId).fields; for (const key of Object.keys(fields)) { const field = fields[key]; if (field.schema && Object.keys(field.schema).includes('customId')) { @@ -380,7 +411,11 @@ export class Jira implements INodeType { const returnData: INodePropertyOptions[] = []; const project = this.getCurrentNodeParameter('project'); - const { values: components } = await jiraSoftwareCloudApiRequest.call(this, `/api/2/project/${project}/component`, 'GET'); + const { values: components } = await jiraSoftwareCloudApiRequest.call( + this, + `/api/2/project/${project}/component`, + 'GET', + ); for (const component of components) { returnData.push({ @@ -390,8 +425,12 @@ export class Jira implements INodeType { } returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -469,28 +508,39 @@ export class Jira implements INodeType { qs.updateHistory = additionalFields.updateHistory as boolean; } if (additionalFields.componentIds) { - fields.components = (additionalFields.componentIds as string[]).map(id => ({ id })); + fields.components = (additionalFields.componentIds as string[]).map((id) => ({ id })); } if (additionalFields.customFieldsUi) { - const customFields = (additionalFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (additionalFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { - const data = customFields.reduce((obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), {}); + const data = customFields.reduce( + (obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), + {}, + ); Object.assign(fields, data); } } - const issueTypes = await jiraSoftwareCloudApiRequest.call(this, '/api/2/issuetype', 'GET', body, qs); + const issueTypes = await jiraSoftwareCloudApiRequest.call( + this, + '/api/2/issuetype', + 'GET', + body, + qs, + ); const subtaskIssues = []; for (const issueType of issueTypes) { if (issueType.subtask) { subtaskIssues.push(issueType.id); } } - if (!additionalFields.parentIssueKey - && subtaskIssues.includes(issueTypeId)) { - throw new NodeOperationError(this.getNode(), 'You must define a Parent Issue Key when Issue type is sub-task', { itemIndex: i }); - - } else if (additionalFields.parentIssueKey - && subtaskIssues.includes(issueTypeId)) { + if (!additionalFields.parentIssueKey && subtaskIssues.includes(issueTypeId)) { + throw new NodeOperationError( + this.getNode(), + 'You must define a Parent Issue Key when Issue type is sub-task', + { itemIndex: i }, + ); + } else if (additionalFields.parentIssueKey && subtaskIssues.includes(issueTypeId)) { fields.parent = { key: (additionalFields.parentIssueKey as string).toUpperCase(), }; @@ -552,25 +602,38 @@ export class Jira implements INodeType { fields.description = updateFields.description as string; } if (updateFields.customFieldsUi) { - const customFields = (updateFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (updateFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { - const data = customFields.reduce((obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), {}); + const data = customFields.reduce( + (obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), + {}, + ); Object.assign(fields, data); } } - const issueTypes = await jiraSoftwareCloudApiRequest.call(this, '/api/2/issuetype', 'GET', body); + const issueTypes = await jiraSoftwareCloudApiRequest.call( + this, + '/api/2/issuetype', + 'GET', + body, + ); const subtaskIssues = []; for (const issueType of issueTypes) { if (issueType.subtask) { subtaskIssues.push(issueType.id); } } - if (!updateFields.parentIssueKey - && subtaskIssues.includes(updateFields.issueType)) { - throw new NodeOperationError(this.getNode(), 'You must define a Parent Issue Key when Issue type is sub-task', { itemIndex: i }); - - } else if (updateFields.parentIssueKey - && subtaskIssues.includes(updateFields.issueType)) { + if (!updateFields.parentIssueKey && subtaskIssues.includes(updateFields.issueType)) { + throw new NodeOperationError( + this.getNode(), + 'You must define a Parent Issue Key when Issue type is sub-task', + { itemIndex: i }, + ); + } else if ( + updateFields.parentIssueKey && + subtaskIssues.includes(updateFields.issueType) + ) { fields.parent = { key: (updateFields.parentIssueKey as string).toUpperCase(), }; @@ -578,10 +641,20 @@ export class Jira implements INodeType { body.fields = fields; if (updateFields.statusId) { - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/transitions`, 'POST', { transition: { id: updateFields.statusId } }); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/2/issue/${issueKey}/transitions`, + 'POST', + { transition: { id: updateFields.statusId } }, + ); } - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'PUT', body); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/2/issue/${issueKey}`, + 'PUT', + body, + ); returnData.push({ success: true }); } } @@ -609,19 +682,27 @@ export class Jira implements INodeType { if (additionalFields.updateHistory) { qs.updateHistory = additionalFields.updateHistory as string; } - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'GET', {}, qs); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/2/issue/${issueKey}`, + 'GET', + {}, + qs, + ); if (simplifyOutput) { // Use rendered fields if requested and available qs.expand = qs.expand || ''; if ( (qs.expand as string).toLowerCase().indexOf('renderedfields') !== -1 && - responseData.renderedFields && Object.keys(responseData.renderedFields).length + responseData.renderedFields && + Object.keys(responseData.renderedFields).length ) { responseData.fields = mergeWith( responseData.fields, responseData.renderedFields, - (a,b) => b === null ? a : b); + (a, b) => (b === null ? a : b), + ); } returnData.push(simplifyIssueOutput(responseData)); } else { @@ -649,11 +730,22 @@ export class Jira implements INodeType { } } if (returnAll) { - responseData = await jiraSoftwareCloudApiRequestAllItems.call(this, 'issues', `/api/2/search`, 'POST', body); + responseData = await jiraSoftwareCloudApiRequestAllItems.call( + this, + 'issues', + `/api/2/search`, + 'POST', + body, + ); } else { const limit = this.getNodeParameter('limit', i) as number; body.maxResults = limit; - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/search`, 'POST', body); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/2/search`, + 'POST', + body, + ); responseData = responseData.issues; } returnData.push(...responseData); @@ -665,10 +757,21 @@ export class Jira implements INodeType { const issueKey = this.getNodeParameter('issueKey', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll) { - responseData = await jiraSoftwareCloudApiRequestAllItems.call(this, 'values', `/api/2/issue/${issueKey}/changelog`, 'GET'); + responseData = await jiraSoftwareCloudApiRequestAllItems.call( + this, + 'values', + `/api/2/issue/${issueKey}/changelog`, + 'GET', + ); } else { qs.maxResults = this.getNodeParameter('limit', i) as number; - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/changelog`, 'GET', {}, qs); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/2/issue/${issueKey}/changelog`, + 'GET', + {}, + qs, + ); responseData = responseData.values; } returnData.push.apply(returnData, responseData); @@ -688,7 +791,9 @@ export class Jira implements INodeType { body.htmlBody = additionalFields.htmlBody as string; } if (!jsonActive) { - const notificationRecipientsValues = (this.getNodeParameter('notificationRecipientsUi', i) as IDataObject).notificationRecipientsValues as IDataObject[]; + const notificationRecipientsValues = ( + this.getNodeParameter('notificationRecipientsUi', i) as IDataObject + ).notificationRecipientsValues as IDataObject[]; const notificationRecipients: INotificationRecipients = {}; if (notificationRecipientsValues) { // @ts-ignore @@ -714,7 +819,7 @@ export class Jira implements INodeType { // @ts-ignore if (notificationRecipientsValues.users.length > 0) { // @ts-ignore - notificationRecipients.users = notificationRecipientsValues.users.map(user => { + notificationRecipients.users = notificationRecipientsValues.users.map((user) => { return { accountId: user, }; @@ -723,7 +828,7 @@ export class Jira implements INodeType { // @ts-ignore if (notificationRecipientsValues.groups.length > 0) { // @ts-ignore - notificationRecipients.groups = notificationRecipientsValues.groups.map(group => { + notificationRecipients.groups = notificationRecipientsValues.groups.map((group) => { return { name: group, }; @@ -731,31 +836,44 @@ export class Jira implements INodeType { } } body.to = notificationRecipients; - const notificationRecipientsRestrictionsValues = (this.getNodeParameter('notificationRecipientsRestrictionsUi', i) as IDataObject).notificationRecipientsRestrictionsValues as IDataObject[]; + const notificationRecipientsRestrictionsValues = ( + this.getNodeParameter('notificationRecipientsRestrictionsUi', i) as IDataObject + ).notificationRecipientsRestrictionsValues as IDataObject[]; const notificationRecipientsRestrictions: NotificationRecipientsRestrictions = {}; if (notificationRecipientsRestrictionsValues) { // @ts-ignore if (notificationRecipientsRestrictionsValues.groups.length > 0) { - // @ts-ignore - notificationRecipientsRestrictions.groups = notificationRecipientsRestrictionsValues.groups.map(group => { - return { - name: group, - }; - }); + notificationRecipientsRestrictions.groups = + // @ts-ignore + notificationRecipientsRestrictionsValues.groups.map((group) => { + return { + name: group, + }; + }); } } body.restrict = notificationRecipientsRestrictions; } else { - const notificationRecipientsJson = validateJSON(this.getNodeParameter('notificationRecipientsJson', i) as string); + const notificationRecipientsJson = validateJSON( + this.getNodeParameter('notificationRecipientsJson', i) as string, + ); if (notificationRecipientsJson) { body.to = notificationRecipientsJson; } - const notificationRecipientsRestrictionsJson = validateJSON(this.getNodeParameter('notificationRecipientsRestrictionsJson', i) as string); + const notificationRecipientsRestrictionsJson = validateJSON( + this.getNodeParameter('notificationRecipientsRestrictionsJson', i) as string, + ); if (notificationRecipientsRestrictionsJson) { body.restrict = notificationRecipientsRestrictionsJson; } } - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/notify`, 'POST', body, qs); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/2/issue/${issueKey}/notify`, + 'POST', + body, + qs, + ); returnData.push(responseData); } } @@ -773,7 +891,13 @@ export class Jira implements INodeType { if (additionalFields.skipRemoteOnlyCondition) { qs.skipRemoteOnlyCondition = additionalFields.skipRemoteOnlyCondition as boolean; } - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/transitions`, 'GET', {}, qs); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/2/issue/${issueKey}/transitions`, + 'GET', + {}, + qs, + ); responseData = responseData.transitions; returnData.push.apply(returnData, responseData); } @@ -784,13 +908,19 @@ export class Jira implements INodeType { const issueKey = this.getNodeParameter('issueKey', i) as string; const deleteSubtasks = this.getNodeParameter('deleteSubtasks', i) as boolean; qs.deleteSubtasks = deleteSubtasks; - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'DELETE', {}, qs); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/2/issue/${issueKey}`, + 'DELETE', + {}, + qs, + ); returnData.push({ success: true }); } } } if (resource === 'issueAttachment') { - const apiVersion = jiraVersion === 'server' ? '2' : '3' as string; + const apiVersion = jiraVersion === 'server' ? '2' : ('3' as string); //https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-issue-issueidorkey-attachments-post if (operation === 'add') { @@ -799,7 +929,9 @@ export class Jira implements INodeType { const issueKey = this.getNodeParameter('issueKey', i) as string; if (items[i].binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const item = items[i].binary as IBinaryKeyData; @@ -808,7 +940,11 @@ export class Jira implements INodeType { const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); if (binaryData === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + { itemIndex: i }, + ); } responseData = await jiraSoftwareCloudApiRequest.call( @@ -836,7 +972,13 @@ export class Jira implements INodeType { if (operation === 'remove') { for (let i = 0; i < length; i++) { const attachmentId = this.getNodeParameter('attachmentId', i) as string; - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/attachment/${attachmentId}`, 'DELETE', {}, qs); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/${apiVersion}/attachment/${attachmentId}`, + 'DELETE', + {}, + qs, + ); returnData.push({ success: true }); } } @@ -845,17 +987,38 @@ export class Jira implements INodeType { const download = this.getNodeParameter('download', 0) as boolean; for (let i = 0; i < length; i++) { const attachmentId = this.getNodeParameter('attachmentId', i) as string; - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/attachment/${attachmentId}`, 'GET', {}, qs); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/${apiVersion}/attachment/${attachmentId}`, + 'GET', + {}, + qs, + ); returnData.push({ json: responseData }); } if (download) { const binaryPropertyName = this.getNodeParameter('binaryProperty', 0) as string; for (const [index, attachment] of returnData.entries()) { returnData[index]['binary'] = {}; + + const buffer = await jiraSoftwareCloudApiRequest.call( + this, + '', + 'GET', + {}, + {}, + // @ts-ignore + attachment?.json!.content, + { json: false, encoding: null }, + ); //@ts-ignore - const buffer = await jiraSoftwareCloudApiRequest.call(this, '', 'GET', {}, {}, attachment?.json!.content, { json: false, encoding: null }); - //@ts-ignore - returnData[index]['binary'][binaryPropertyName] = await this.helpers.prepareBinaryData(buffer, attachment.json.filename, attachment.json.mimeType); + returnData[index]['binary'][binaryPropertyName] = await this.helpers.prepareBinaryData( + buffer, + // @ts-ignore + attachment.json.filename, + // @ts-ignore + attachment.json.mimeType, + ); } } } @@ -864,7 +1027,15 @@ export class Jira implements INodeType { for (let i = 0; i < length; i++) { const issueKey = this.getNodeParameter('issueKey', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; - const { fields: { attachment } } = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'GET', {}, qs); + const { + fields: { attachment }, + } = await jiraSoftwareCloudApiRequest.call( + this, + `/api/2/issue/${issueKey}`, + 'GET', + {}, + qs, + ); responseData = attachment; if (returnAll === false) { const limit = this.getNodeParameter('limit', i) as number; @@ -878,16 +1049,31 @@ export class Jira implements INodeType { for (const [index, attachment] of returnData.entries()) { returnData[index]['binary'] = {}; //@ts-ignore - const buffer = await jiraSoftwareCloudApiRequest.call(this, '', 'GET', {}, {}, attachment.json.content, { json: false, encoding: null }); + const buffer = await jiraSoftwareCloudApiRequest.call( + this, + '', + 'GET', + {}, + {}, + // @ts-ignore + attachment.json.content, + { json: false, encoding: null }, + ); //@ts-ignore - returnData[index]['binary'][binaryPropertyName] = await this.helpers.prepareBinaryData(buffer, attachment.json.filename, attachment.json.mimeType); + returnData[index]['binary'][binaryPropertyName] = await this.helpers.prepareBinaryData( + buffer, + // @ts-ignore + attachment.json.filename, + // @ts-ignore + attachment.json.mimeType, + ); } } } } if (resource === 'issueComment') { - const apiVersion = jiraVersion === 'server' ? '2' : '3' as string; + const apiVersion = jiraVersion === 'server' ? '2' : ('3' as string); //https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-post if (operation === 'add') { @@ -929,13 +1115,21 @@ export class Jira implements INodeType { const commentJson = this.getNodeParameter('commentJson', i) as string; const json = validateJSON(commentJson); if (json === '') { - throw new NodeOperationError(this.getNode(), 'Document Format must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Document Format must be a valid JSON', { + itemIndex: i, + }); } Object.assign(body, { body: json }); } - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment`, 'POST', body, qs); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/${apiVersion}/issue/${issueKey}/comment`, + 'POST', + body, + qs, + ); returnData.push(responseData); } } @@ -946,7 +1140,13 @@ export class Jira implements INodeType { const commentId = this.getNodeParameter('commentId', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; Object.assign(qs, options); - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`, 'GET', {}, qs); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`, + 'GET', + {}, + qs, + ); returnData.push(responseData); } } @@ -959,11 +1159,24 @@ export class Jira implements INodeType { const body: IDataObject = {}; Object.assign(qs, options); if (returnAll) { - responseData = await jiraSoftwareCloudApiRequestAllItems.call(this, 'comments', `/api/${apiVersion}/issue/${issueKey}/comment`, 'GET', body, qs); + responseData = await jiraSoftwareCloudApiRequestAllItems.call( + this, + 'comments', + `/api/${apiVersion}/issue/${issueKey}/comment`, + 'GET', + body, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; body.maxResults = limit; - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment`, 'GET', body, qs); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/${apiVersion}/issue/${issueKey}/comment`, + 'GET', + body, + qs, + ); responseData = responseData.comments; } returnData.push.apply(returnData, responseData); @@ -974,7 +1187,13 @@ export class Jira implements INodeType { for (let i = 0; i < length; i++) { const issueKey = this.getNodeParameter('issueKey', i) as string; const commentId = this.getNodeParameter('commentId', i) as string; - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`, 'DELETE', {}, qs); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`, + 'DELETE', + {}, + qs, + ); returnData.push({ success: true }); } } @@ -1018,19 +1237,27 @@ export class Jira implements INodeType { const commentJson = this.getNodeParameter('commentJson', i) as string; const json = validateJSON(commentJson); if (json === '') { - throw new NodeOperationError(this.getNode(), 'Document Format must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Document Format must be a valid JSON', { + itemIndex: i, + }); } Object.assign(body, { body: json }); } - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`, 'PUT', body, qs); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`, + 'PUT', + body, + qs, + ); returnData.push(responseData); } } } if (resource === 'user') { - const apiVersion = jiraVersion === 'server' ? '2' : '3' as string; + const apiVersion = jiraVersion === 'server' ? '2' : ('3' as string); if (operation === 'create') { // https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-post @@ -1045,14 +1272,26 @@ export class Jira implements INodeType { Object.assign(body, additionalFields); - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/user`, 'POST', body, {}); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/${apiVersion}/user`, + 'POST', + body, + {}, + ); returnData.push(responseData); } } else if (operation === 'delete') { // https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-delete for (let i = 0; i < length; i++) { qs.accountId = this.getNodeParameter('accountId', i); - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/user`, 'DELETE', {}, qs); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/${apiVersion}/user`, + 'DELETE', + {}, + qs, + ); returnData.push({ success: true }); } } else if (operation === 'get') { @@ -1066,7 +1305,13 @@ export class Jira implements INodeType { qs.expand = expand.join(','); } - responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/user`, 'GET', {}, qs); + responseData = await jiraSoftwareCloudApiRequest.call( + this, + `/api/${apiVersion}/user`, + 'GET', + {}, + qs, + ); returnData.push(responseData); } } diff --git a/packages/nodes-base/nodes/Jira/JiraTrigger.node.ts b/packages/nodes-base/nodes/Jira/JiraTrigger.node.ts index b6d24d1a12..e517bf58c0 100644 --- a/packages/nodes-base/nodes/Jira/JiraTrigger.node.ts +++ b/packages/nodes-base/nodes/Jira/JiraTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -12,12 +9,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - allEvents, - eventExists, - getId, - jiraSoftwareCloudApiRequest, -} from './GenericFunctions'; +import { allEvents, eventExists, getId, jiraSoftwareCloudApiRequest } from './GenericFunctions'; import * as queryString from 'querystring'; @@ -40,9 +32,7 @@ export class JiraTrigger implements INodeType { required: true, displayOptions: { show: { - jiraVersion: [ - 'cloud', - ], + jiraVersion: ['cloud'], }, }, }, @@ -51,9 +41,7 @@ export class JiraTrigger implements INodeType { required: true, displayOptions: { show: { - jiraVersion: [ - 'server', - ], + jiraVersion: ['server'], }, }, }, @@ -63,9 +51,7 @@ export class JiraTrigger implements INodeType { required: true, displayOptions: { show: { - incomingAuthentication: [ - 'queryAuth', - ], + incomingAuthentication: ['queryAuth'], }, }, }, @@ -294,7 +280,8 @@ export class JiraTrigger implements INodeType { name: 'excludeBody', type: 'boolean', default: false, - description: 'Whether a request with empty body will be sent to the URL. Leave unchecked if you want to receive JSON.', + description: + 'Whether a request with empty body will be sent to the URL. Leave unchecked if you want to receive JSON.', }, { displayName: 'Filter', @@ -305,7 +292,8 @@ export class JiraTrigger implements INodeType { }, default: '', placeholder: 'Project = JRA AND resolution = Fixed', - description: 'You can specify a JQL query to send only events triggered by matching issues. The JQL filter only applies to events under the Issue and Comment columns.', + description: + 'You can specify a JQL query to send only events triggered by matching issues. The JQL filter only applies to events under the Issue and Comment columns.', }, { displayName: 'Include Fields', @@ -420,8 +408,7 @@ export class JiraTrigger implements INodeType { name: `n8n-webhook:${webhookUrl}`, url: webhookUrl, events, - filters: { - }, + filters: {}, excludeBody: false, }; @@ -440,19 +427,23 @@ export class JiraTrigger implements INodeType { if (incomingAuthentication === 'queryAuth') { let httpQueryAuth; - try{ + try { httpQueryAuth = await this.getCredentials('httpQueryAuth'); } catch (e) { - throw new NodeOperationError(this.getNode(), `Could not retrieve HTTP Query Auth credentials: ${e}`); + throw new NodeOperationError( + this.getNode(), + `Could not retrieve HTTP Query Auth credentials: ${e}`, + ); } if (!httpQueryAuth.name && !httpQueryAuth.value) { throw new NodeOperationError(this.getNode(), `HTTP Query Auth credentials are empty`); } - parameters[encodeURIComponent(httpQueryAuth.name as string)] = Buffer.from(httpQueryAuth.value as string).toString('base64'); + parameters[encodeURIComponent(httpQueryAuth.name as string)] = Buffer.from( + httpQueryAuth.value as string, + ).toString('base64'); } if (additionalFields.includeFields) { - for (const field of additionalFields.includeFields as string[]) { parameters[field] = '${' + field + '}'; } @@ -502,11 +493,12 @@ export class JiraTrigger implements INodeType { try { httpQueryAuth = await this.getCredentials('httpQueryAuth'); - } catch (error) { } + } catch (error) {} if (httpQueryAuth === undefined || !httpQueryAuth.name || !httpQueryAuth.value) { - - response.status(403).json({ message: 'Auth settings are not valid, some data are missing' }); + response + .status(403) + .json({ message: 'Auth settings are not valid, some data are missing' }); return { noWebhookResponse: true, @@ -517,7 +509,6 @@ export class JiraTrigger implements INodeType { const paramValue = Buffer.from(httpQueryAuth.value as string).toString('base64'); if (!queryData.hasOwnProperty(paramName) || queryData[paramName] !== paramValue) { - response.status(403).json({ message: 'Provided authentication data is not valid' }); return { @@ -528,15 +519,12 @@ export class JiraTrigger implements INodeType { delete queryData[paramName]; Object.assign(bodyData, queryData); - } else { Object.assign(bodyData, queryData); } return { - workflowData: [ - this.helpers.returnJsonArray(bodyData), - ], + workflowData: [this.helpers.returnJsonArray(bodyData)], }; } } diff --git a/packages/nodes-base/nodes/Jira/UserDescription.ts b/packages/nodes-base/nodes/Jira/UserDescription.ts index db0388cb21..888ce86e0d 100644 --- a/packages/nodes-base/nodes/Jira/UserDescription.ts +++ b/packages/nodes-base/nodes/Jira/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -40,7 +36,6 @@ export const userOperations: INodeProperties[] = [ ]; export const userFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* user:create */ /* -------------------------------------------------------------------------- */ @@ -52,12 +47,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, }, @@ -69,12 +60,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, }, @@ -85,12 +72,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, default: '', @@ -103,12 +86,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, options: [ @@ -117,7 +96,8 @@ export const userFields: INodeProperties[] = [ name: 'password', type: 'string', default: '', - description: 'Password for the user. If a password is not set, a random password is generated.', + description: + 'Password for the user. If a password is not set, a random password is generated.', typeOptions: { password: true, }, @@ -127,7 +107,8 @@ export const userFields: INodeProperties[] = [ name: 'notification', type: 'boolean', default: false, - description: 'Whether to send the user an email confirmation that they have been added to Jira', + description: + 'Whether to send the user an email confirmation that they have been added to Jira', }, ], }, @@ -142,12 +123,8 @@ export const userFields: INodeProperties[] = [ description: 'Account ID of the user to delete', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'delete', - ], + resource: ['user'], + operation: ['delete'], }, }, }, @@ -162,12 +139,8 @@ export const userFields: INodeProperties[] = [ description: 'Account ID of the user to retrieve', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, }, @@ -179,12 +152,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, options: [ diff --git a/packages/nodes-base/nodes/JotForm/GenericFunctions.ts b/packages/nodes-base/nodes/JotForm/GenericFunctions.ts index 6a5fd10580..05e3b1a0b7 100644 --- a/packages/nodes-base/nodes/JotForm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/JotForm/GenericFunctions.ts @@ -6,13 +6,28 @@ import { ILoadOptionsFunctions, IWebhookFunctions, } from 'n8n-core'; -import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function jotformApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function jotformApiRequest( + this: + | IHookFunctions + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IWebhookFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('jotFormApi'); let options: OptionsWithUri = { headers: { - 'APIKEY': credentials.apiKey, + APIKEY: credentials.apiKey, 'Content-Type': 'application/x-www-form-urlencoded', }, method, diff --git a/packages/nodes-base/nodes/JotForm/JotFormTrigger.node.ts b/packages/nodes-base/nodes/JotForm/JotFormTrigger.node.ts index bd31c595aa..f71df59222 100644 --- a/packages/nodes-base/nodes/JotForm/JotFormTrigger.node.ts +++ b/packages/nodes-base/nodes/JotForm/JotFormTrigger.node.ts @@ -1,9 +1,6 @@ import * as formidable from 'formidable'; -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -14,10 +11,7 @@ import { IWebhookResponseData, } from 'n8n-workflow'; -import { - jotformApiRequest, -} from './GenericFunctions'; - +import { jotformApiRequest } from './GenericFunctions'; interface IQuestionData { name: string; @@ -62,7 +56,8 @@ export class JotFormTrigger implements INodeType { loadOptionsMethod: 'getForms', }, default: '', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', }, { displayName: 'Resolve Data', @@ -70,7 +65,8 @@ export class JotFormTrigger implements INodeType { type: 'boolean', default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default does the webhook-data use internal keys instead of the names. If this option gets activated, it will resolve the keys automatically to the actual names.', + description: + 'By default does the webhook-data use internal keys instead of the names. If this option gets activated, it will resolve the keys automatically to the actual names.', }, { displayName: 'Only Answers', @@ -80,7 +76,6 @@ export class JotFormTrigger implements INodeType { description: 'Whether to return only the answers of the form and not any of the other data', }, ], - }; methods = { @@ -91,7 +86,7 @@ export class JotFormTrigger implements INodeType { const returnData: INodePropertyOptions[] = []; const qs: IDataObject = { limit: 1000, - }; + }; const forms = await jotformApiRequest.call(this, 'GET', '/user/forms', {}, qs); for (const form of forms.content) { const formName = form.title; @@ -149,7 +144,7 @@ export class JotFormTrigger implements INodeType { const endpoint = `/form/${formId}/webhooks/${webhookData.webhookId}`; try { responseData = await jotformApiRequest.call(this, 'DELETE', endpoint); - } catch(error) { + } catch (error) { return false; } if (responseData.message !== 'success') { @@ -171,9 +166,7 @@ export class JotFormTrigger implements INodeType { const form = new formidable.IncomingForm({}); return new Promise((resolve, reject) => { - form.parse(req, async (err, data, files) => { - const rawRequest = JSON.parse(data.rawRequest as string); data.rawRequest = rawRequest; @@ -186,9 +179,7 @@ export class JotFormTrigger implements INodeType { } resolve({ - workflowData: [ - this.helpers.returnJsonArray(returnData), - ], + workflowData: [this.helpers.returnJsonArray(returnData)], }); } @@ -227,12 +218,9 @@ export class JotFormTrigger implements INodeType { } resolve({ - workflowData: [ - this.helpers.returnJsonArray(returnData), - ], + workflowData: [this.helpers.returnJsonArray(returnData)], }); }); - }); } } diff --git a/packages/nodes-base/nodes/Kafka/Kafka.node.ts b/packages/nodes-base/nodes/Kafka/Kafka.node.ts index 15eedaf453..96080587d7 100644 --- a/packages/nodes-base/nodes/Kafka/Kafka.node.ts +++ b/packages/nodes-base/nodes/Kafka/Kafka.node.ts @@ -8,9 +8,7 @@ import { import { SchemaRegistry } from '@kafkajs/confluent-schema-registry'; -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -61,9 +59,7 @@ export class Kafka implements INodeType { type: 'string', displayOptions: { show: { - sendInputData: [ - false, - ], + sendInputData: [false], }, }, default: '', @@ -89,9 +85,7 @@ export class Kafka implements INodeType { required: true, displayOptions: { show: { - useSchemaRegistry: [ - true, - ], + useSchemaRegistry: [true], }, }, placeholder: 'https://schema-registry-domain:8081', @@ -105,9 +99,7 @@ export class Kafka implements INodeType { required: true, displayOptions: { show: { - useSchemaRegistry: [ - true, - ], + useSchemaRegistry: [true], }, }, default: '', @@ -120,9 +112,7 @@ export class Kafka implements INodeType { type: 'fixedCollection', displayOptions: { show: { - jsonParameters: [ - false, - ], + jsonParameters: [false], }, }, typeOptions: { @@ -156,9 +146,7 @@ export class Kafka implements INodeType { type: 'json', displayOptions: { show: { - jsonParameters: [ - true, - ], + jsonParameters: [true], }, }, default: '', @@ -216,7 +204,7 @@ export class Kafka implements INodeType { let compression = CompressionTypes.None; - const acks = (options.acks === true) ? 1 : 0; + const acks = options.acks === true ? 1 : 0; if (options.compression === true) { compression = CompressionTypes.GZIP; @@ -224,7 +212,9 @@ export class Kafka implements INodeType { const credentials = await this.getCredentials('kafka'); - const brokers = (credentials.brokers as string || '').split(',').map(item => item.trim()) as string[]; + const brokers = ((credentials.brokers as string) || '') + .split(',') + .map((item) => item.trim()) as string[]; const clientId = credentials.clientId as string; @@ -237,8 +227,11 @@ export class Kafka implements INodeType { }; if (credentials.authentication === true) { - if(!(credentials.username && credentials.password)) { - throw new NodeOperationError(this.getNode(), 'Username and password are required for authentication'); + if (!(credentials.username && credentials.password)) { + throw new NodeOperationError( + this.getNode(), + 'Username and password are required for authentication', + ); } config.sasl = { username: credentials.username as string, @@ -272,7 +265,10 @@ export class Kafka implements INodeType { message = await registry.encode(id, JSON.parse(message)); } catch (exception) { - throw new NodeOperationError(this.getNode(), 'Verify your Schema Registry configuration'); + throw new NodeOperationError( + this.getNode(), + 'Verify your Schema Registry configuration', + ); } } @@ -290,7 +286,8 @@ export class Kafka implements INodeType { throw new NodeOperationError(this.getNode(), 'Headers must be a valid json'); } } else { - const values = (this.getNodeParameter('headersUi', i) as IDataObject).headerValues as IDataObject[]; + const values = (this.getNodeParameter('headersUi', i) as IDataObject) + .headerValues as IDataObject[]; headers = {}; if (values !== undefined) { for (const value of values) { @@ -300,24 +297,23 @@ export class Kafka implements INodeType { } } - topicMessages.push( - { - topic, - messages: [{ + topicMessages.push({ + topic, + messages: [ + { value: message, headers, - }], - }); + }, + ], + }); } - responseData = await producer.sendBatch( - { - topicMessages, - timeout, - compression, - acks, - }, - ); + responseData = await producer.sendBatch({ + topicMessages, + timeout, + compression, + acks, + }); if (responseData.length === 0) { responseData.push({ diff --git a/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts b/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts index a1bea2f47e..69e68a93f3 100644 --- a/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts +++ b/packages/nodes-base/nodes/Kafka/KafkaTrigger.node.ts @@ -1,15 +1,8 @@ -import { - Kafka as apacheKafka, - KafkaConfig, - logLevel, - SASLOptions, -} from 'kafkajs'; +import { Kafka as apacheKafka, KafkaConfig, logLevel, SASLOptions } from 'kafkajs'; import { SchemaRegistry } from '@kafkajs/confluent-schema-registry'; -import { - ITriggerFunctions, -} from 'n8n-core'; +import { ITriggerFunctions } from 'n8n-core'; import { IDataObject, @@ -71,9 +64,7 @@ export class KafkaTrigger implements INodeType { required: true, displayOptions: { show: { - useSchemaRegistry: [ - true, - ], + useSchemaRegistry: [true], }, }, placeholder: 'https://schema-registry-domain:8081', @@ -99,14 +90,16 @@ export class KafkaTrigger implements INodeType { name: 'autoCommitThreshold', type: 'number', default: 0, - description: 'The consumer will commit offsets after resolving a given number of messages', + description: + 'The consumer will commit offsets after resolving a given number of messages', }, { displayName: 'Auto Commit Interval', name: 'autoCommitInterval', type: 'number', default: 0, - description: 'The consumer will commit offsets after a given period, for example, five seconds', + description: + 'The consumer will commit offsets after a given period, for example, five seconds', hint: 'Value in milliseconds', }, { @@ -114,7 +107,7 @@ export class KafkaTrigger implements INodeType { name: 'heartbeatInterval', type: 'number', default: 3000, - description: 'Heartbeats are used to ensure that the consumer\'s session stays active', + description: "Heartbeats are used to ensure that the consumer's session stays active", hint: 'The value must be set lower than Session Timeout', }, { @@ -122,7 +115,8 @@ export class KafkaTrigger implements INodeType { name: 'maxInFlightRequests', type: 'number', default: 0, - description: 'Max number of requests that may be in progress at any time. If falsey then no limit.', + description: + 'Max number of requests that may be in progress at any time. If falsey then no limit.', }, { displayName: 'Read Messages From Beginning', @@ -144,9 +138,7 @@ export class KafkaTrigger implements INodeType { type: 'boolean', displayOptions: { show: { - jsonParseMessage: [ - true, - ], + jsonParseMessage: [true], }, }, default: false, @@ -173,14 +165,15 @@ export class KafkaTrigger implements INodeType { }; async trigger(this: ITriggerFunctions): Promise { - const topic = this.getNodeParameter('topic') as string; const groupId = this.getNodeParameter('groupId') as string; const credentials = await this.getCredentials('kafka'); - const brokers = (credentials.brokers as string || '').split(',').map(item => item.trim()) as string[]; + const brokers = ((credentials.brokers as string) || '') + .split(',') + .map((item) => item.trim()) as string[]; const clientId = credentials.clientId as string; @@ -194,8 +187,11 @@ export class KafkaTrigger implements INodeType { }; if (credentials.authentication === true) { - if(!(credentials.username && credentials.password)) { - throw new NodeOperationError(this.getNode(), 'Username and password are required for authentication'); + if (!(credentials.username && credentials.password)) { + throw new NodeOperationError( + this.getNode(), + 'Username and password are required for authentication', + ); } config.sasl = { username: credentials.username as string, @@ -211,13 +207,13 @@ export class KafkaTrigger implements INodeType { maxInFlightRequests: this.getNodeParameter('options.maxInFlightRequests', 0) as number, sessionTimeout: this.getNodeParameter('options.sessionTimeout', 30000) as number, heartbeatInterval: this.getNodeParameter('options.heartbeatInterval', 3000) as number, - }); + }); await consumer.connect(); const options = this.getNodeParameter('options', {}) as IDataObject; - await consumer.subscribe({ topic, fromBeginning: (options.fromBeginning)? true : false }); + await consumer.subscribe({ topic, fromBeginning: options.fromBeginning ? true : false }); const self = this; @@ -227,28 +223,27 @@ export class KafkaTrigger implements INodeType { const startConsumer = async () => { await consumer.run({ - autoCommitInterval: options.autoCommitInterval as number || null, - autoCommitThreshold: options.autoCommitThreshold as number || null, + autoCommitInterval: (options.autoCommitInterval as number) || null, + autoCommitThreshold: (options.autoCommitThreshold as number) || null, eachMessage: async ({ topic, message }) => { - let data: IDataObject = {}; let value = message.value?.toString() as string; if (options.jsonParseMessage) { try { value = JSON.parse(value); - } catch (error) { } + } catch (error) {} } if (useSchemaRegistry) { try { const registry = new SchemaRegistry({ host: schemaRegistryUrl }); value = await registry.decode(message.value as Buffer); - } catch (error) { } + } catch (error) {} } if (options.returnHeaders && message.headers) { - const headers: {[key: string]: string} = {}; + const headers: { [key: string]: string } = {}; for (const key of Object.keys(message.headers)) { const header = message.headers[key]; headers[key] = header?.toString('utf8') || ''; diff --git a/packages/nodes-base/nodes/Keap/CompanyDescription.ts b/packages/nodes-base/nodes/Keap/CompanyDescription.ts index 9bbfece62f..eae28cf946 100644 --- a/packages/nodes-base/nodes/Keap/CompanyDescription.ts +++ b/packages/nodes-base/nodes/Keap/CompanyDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, - } from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const companyOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const companyOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'company', - ], + resource: ['company'], }, }, options: [ @@ -34,10 +30,9 @@ export const companyOperations: INodeProperties[] = [ ]; export const companyFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* company:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* company:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Company Name', name: 'companyName', @@ -45,12 +40,8 @@ export const companyFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'company', - ], + operation: ['create'], + resource: ['company'], }, }, default: '', @@ -63,12 +54,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'company', - ], + operation: ['create'], + resource: ['company'], }, }, options: [ @@ -112,12 +99,8 @@ export const companyFields: INodeProperties[] = [ placeholder: 'Add Address', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], + resource: ['company'], + operation: ['create'], }, }, options: [ @@ -189,12 +172,8 @@ export const companyFields: INodeProperties[] = [ placeholder: 'Add Fax', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], + resource: ['company'], + operation: ['create'], }, }, options: [ @@ -229,12 +208,8 @@ export const companyFields: INodeProperties[] = [ placeholder: 'Add Phone', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], + resource: ['company'], + operation: ['create'], }, }, options: [ @@ -258,21 +233,17 @@ export const companyFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* company:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* company:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'company', - ], + operation: ['getAll'], + resource: ['company'], }, }, default: false, @@ -284,15 +255,9 @@ export const companyFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'company', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['company'], + returnAll: [false], }, }, typeOptions: { @@ -310,12 +275,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'company', - ], + operation: ['getAll'], + resource: ['company'], }, }, options: [ @@ -368,7 +329,8 @@ export const companyFields: INodeProperties[] = [ name: 'fields', type: 'string', default: '', - description: 'Comma-delimited list of Company properties to include in the response. (Fields such as notes, fax_number and custom_fields aren\'t included, by default.).', + description: + "Comma-delimited list of Company properties to include in the response. (Fields such as notes, fax_number and custom_fields aren't included, by default.).", }, ], }, diff --git a/packages/nodes-base/nodes/Keap/ConctactInterface.ts b/packages/nodes-base/nodes/Keap/ConctactInterface.ts index 1bbdb6d6f1..a2772e083a 100644 --- a/packages/nodes-base/nodes/Keap/ConctactInterface.ts +++ b/packages/nodes-base/nodes/Keap/ConctactInterface.ts @@ -1,6 +1,4 @@ -import { - IDataObject, - } from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export interface IAddress { country_code?: string; diff --git a/packages/nodes-base/nodes/Keap/ContactDescription.ts b/packages/nodes-base/nodes/Keap/ContactDescription.ts index 19e97ea76a..9d9b582923 100644 --- a/packages/nodes-base/nodes/Keap/ContactDescription.ts +++ b/packages/nodes-base/nodes/Keap/ContactDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, - } from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactOperations: INodeProperties[] = [ { @@ -10,16 +8,15 @@ export const contactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contact', - ], + resource: ['contact'], }, }, options: [ { name: 'Create or Update', value: 'upsert', - description: 'Create a new contact, or update the current one if it already exists (upsert)', + description: + 'Create a new contact, or update the current one if it already exists (upsert)', action: 'Create or update a contact', }, { @@ -46,10 +43,9 @@ export const contactOperations: INodeProperties[] = [ ]; export const contactFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* contact:upsert */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contact:upsert */ + /* -------------------------------------------------------------------------- */ { displayName: 'Duplicate Option', name: 'duplicateOption', @@ -67,16 +63,13 @@ export const contactFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'upsert', - ], - resource: [ - 'contact', - ], + operation: ['upsert'], + resource: ['contact'], }, }, default: 'email', - description: 'Performs duplicate checking by one of the following options: Email, EmailAndName. If a match is found using the option provided, the existing contact will be updated.', + description: + 'Performs duplicate checking by one of the following options: Email, EmailAndName. If a match is found using the option provided, the existing contact will be updated.', }, { displayName: 'Additional Fields', @@ -86,12 +79,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'upsert', - ], - resource: [ - 'contact', - ], + operation: ['upsert'], + resource: ['contact'], }, }, options: [ @@ -114,7 +103,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Contact Type Name or ID', name: 'contactType', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getContactTypes', }, @@ -166,7 +156,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Owner Name or ID', name: 'ownerId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getUsers', }, @@ -227,7 +218,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Timezone Name or ID', name: 'timezone', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTimezones', }, @@ -252,12 +244,8 @@ export const contactFields: INodeProperties[] = [ placeholder: 'Add Address', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'upsert', - ], + resource: ['contact'], + operation: ['upsert'], }, }, options: [ @@ -289,7 +277,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Country Code Name or ID', name: 'countryCode', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCountries', }, @@ -352,12 +341,8 @@ export const contactFields: INodeProperties[] = [ placeholder: 'Add Email', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'upsert', - ], + resource: ['contact'], + operation: ['upsert'], }, }, options: [ @@ -407,12 +392,8 @@ export const contactFields: INodeProperties[] = [ placeholder: 'Add Fax', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'upsert', - ], + resource: ['contact'], + operation: ['upsert'], }, }, options: [ @@ -457,12 +438,8 @@ export const contactFields: INodeProperties[] = [ placeholder: 'Add Phone', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'upsert', - ], + resource: ['contact'], + operation: ['upsert'], }, }, options: [ @@ -519,12 +496,8 @@ export const contactFields: INodeProperties[] = [ placeholder: 'Add Social Account', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'upsert', - ], + resource: ['contact'], + operation: ['upsert'], }, }, options: [ @@ -562,9 +535,9 @@ export const contactFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* contact:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contact:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Contact ID', name: 'contactId', @@ -572,19 +545,15 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'contact', - ], + operation: ['delete'], + resource: ['contact'], }, }, default: '', }, -/* -------------------------------------------------------------------------- */ -/* contact:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contact:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Contact ID', name: 'contactId', @@ -592,12 +561,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], + operation: ['get'], + resource: ['contact'], }, }, default: '', @@ -610,12 +575,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], + operation: ['get'], + resource: ['contact'], }, }, options: [ @@ -624,25 +585,22 @@ export const contactFields: INodeProperties[] = [ name: 'fields', type: 'string', default: '', - description: 'Comma-delimited list of Contact properties to include in the response. (Some fields such as lead_source_id, custom_fields, and job_title aren\'t included, by default.).', + description: + "Comma-delimited list of Contact properties to include in the response. (Some fields such as lead_source_id, custom_fields, and job_title aren't included, by default.).", }, ], }, -/* -------------------------------------------------------------------------- */ -/* contact:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contact:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], + operation: ['getAll'], + resource: ['contact'], }, }, default: false, @@ -654,15 +612,9 @@ export const contactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['contact'], + returnAll: [false], }, }, typeOptions: { @@ -680,12 +632,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], + operation: ['getAll'], + resource: ['contact'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Keap/ContactNoteDescription.ts b/packages/nodes-base/nodes/Keap/ContactNoteDescription.ts index cfad2a1c95..976c927e71 100644 --- a/packages/nodes-base/nodes/Keap/ContactNoteDescription.ts +++ b/packages/nodes-base/nodes/Keap/ContactNoteDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, - } from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactNoteOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const contactNoteOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contactNote', - ], + resource: ['contactNote'], }, }, options: [ @@ -52,10 +48,9 @@ export const contactNoteOperations: INodeProperties[] = [ ]; export const contactNoteFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* contactNote:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contactNote:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'User Name or ID', name: 'userId', @@ -65,16 +60,13 @@ export const contactNoteFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contactNote', - ], + operation: ['create'], + resource: ['contactNote'], }, }, default: '', - description: 'The infusionsoft user to create the note on behalf of. Choose from the list, or specify an ID using an expression.', + description: + 'The infusionsoft user to create the note on behalf of. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Contact ID', @@ -82,12 +74,8 @@ export const contactNoteFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contactNote', - ], + operation: ['create'], + resource: ['contactNote'], }, }, default: '', @@ -100,12 +88,8 @@ export const contactNoteFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contactNote', - ], + operation: ['create'], + resource: ['contactNote'], }, }, options: [ @@ -158,9 +142,9 @@ export const contactNoteFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* contactNote:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contactNote:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Note ID', name: 'noteId', @@ -168,19 +152,15 @@ export const contactNoteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'contactNote', - ], + operation: ['delete'], + resource: ['contactNote'], }, }, default: '', }, -/* -------------------------------------------------------------------------- */ -/* contactNote:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contactNote:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Note ID', name: 'noteId', @@ -188,31 +168,23 @@ export const contactNoteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'contactNote', - ], + operation: ['get'], + resource: ['contactNote'], }, }, default: '', }, -/* -------------------------------------------------------------------------- */ -/* contactNote:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contactNote:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contactNote', - ], + operation: ['getAll'], + resource: ['contactNote'], }, }, default: false, @@ -224,15 +196,9 @@ export const contactNoteFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contactNote', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['contactNote'], + returnAll: [false], }, }, typeOptions: { @@ -250,12 +216,8 @@ export const contactNoteFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contactNote', - ], + operation: ['getAll'], + resource: ['contactNote'], }, }, options: [ @@ -272,7 +234,8 @@ export const contactNoteFields: INodeProperties[] = [ displayName: 'User Name or ID', name: 'userId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getUsers', }, @@ -280,9 +243,9 @@ export const contactNoteFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* contactNote:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contactNote:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'Note ID', name: 'noteId', @@ -290,12 +253,8 @@ export const contactNoteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'contactNote', - ], + operation: ['update'], + resource: ['contactNote'], }, }, default: '', @@ -308,12 +267,8 @@ export const contactNoteFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'contactNote', - ], + operation: ['update'], + resource: ['contactNote'], }, }, options: [ @@ -381,7 +336,8 @@ export const contactNoteFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'The infusionsoft user to create the note on behalf of. Choose from the list, or specify an ID using an expression.', + description: + 'The infusionsoft user to create the note on behalf of. Choose from the list, or specify an ID using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/Keap/ContactNoteInterface.ts b/packages/nodes-base/nodes/Keap/ContactNoteInterface.ts index 221bd73e35..25ceabcb0e 100644 --- a/packages/nodes-base/nodes/Keap/ContactNoteInterface.ts +++ b/packages/nodes-base/nodes/Keap/ContactNoteInterface.ts @@ -1,4 +1,3 @@ - export interface INote { body?: string; contact_id?: number; diff --git a/packages/nodes-base/nodes/Keap/ContactTagDescription.ts b/packages/nodes-base/nodes/Keap/ContactTagDescription.ts index aef3f77e69..2e512cb643 100644 --- a/packages/nodes-base/nodes/Keap/ContactTagDescription.ts +++ b/packages/nodes-base/nodes/Keap/ContactTagDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, - } from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactTagOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const contactTagOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contactTag', - ], + resource: ['contactTag'], }, }, options: [ @@ -25,13 +21,13 @@ export const contactTagOperations: INodeProperties[] = [ { name: 'Delete', value: 'delete', - description: 'Delete a contact\'s tag', + description: "Delete a contact's tag", action: 'Delete a contact tag', }, { name: 'Get All', value: 'getAll', - description: 'Retrieve all contact\'s tags', + description: "Retrieve all contact's tags", action: 'Get all contact tags', }, ], @@ -40,10 +36,9 @@ export const contactTagOperations: INodeProperties[] = [ ]; export const contactTagFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* contactTag:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contactTag:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Contact ID', name: 'contactId', @@ -51,12 +46,8 @@ export const contactTagFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contactTag', - ], + operation: ['create'], + resource: ['contactTag'], }, }, default: '', @@ -65,26 +56,23 @@ export const contactTagFields: INodeProperties[] = [ displayName: 'Tag Names or IDs', name: 'tagIds', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getTags', }, required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contactTag', - ], + operation: ['create'], + resource: ['contactTag'], }, }, default: [], }, -/* -------------------------------------------------------------------------- */ -/* contactTag:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contactTag:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Contact ID', name: 'contactId', @@ -92,12 +80,8 @@ export const contactTagFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'contactTag', - ], + operation: ['delete'], + resource: ['contactTag'], }, }, default: '', @@ -109,19 +93,15 @@ export const contactTagFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'contactTag', - ], + operation: ['delete'], + resource: ['contactTag'], }, }, default: 'Tag IDs, multiple ids can be set separated by comma.', }, -/* -------------------------------------------------------------------------- */ -/* contactTag:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contactTag:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Contact ID', name: 'contactId', @@ -129,12 +109,8 @@ export const contactTagFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contactTag', - ], + operation: ['getAll'], + resource: ['contactTag'], }, }, default: '', @@ -145,12 +121,8 @@ export const contactTagFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contactTag', - ], + operation: ['getAll'], + resource: ['contactTag'], }, }, default: false, @@ -162,15 +134,9 @@ export const contactTagFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contactTag', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['contactTag'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Keap/EcommerceOrderDescripion.ts b/packages/nodes-base/nodes/Keap/EcommerceOrderDescripion.ts index a7a5729c95..3f6c9c5343 100644 --- a/packages/nodes-base/nodes/Keap/EcommerceOrderDescripion.ts +++ b/packages/nodes-base/nodes/Keap/EcommerceOrderDescripion.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, - } from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const ecommerceOrderOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const ecommerceOrderOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'ecommerceOrder', - ], + resource: ['ecommerceOrder'], }, }, options: [ @@ -46,10 +42,9 @@ export const ecommerceOrderOperations: INodeProperties[] = [ ]; export const ecommerceOrderFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* ecommerceOrder:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* ecommerceOrder:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Contact ID', name: 'contactId', @@ -57,12 +52,8 @@ export const ecommerceOrderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, default: '', @@ -74,12 +65,8 @@ export const ecommerceOrderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, default: '', @@ -91,12 +78,8 @@ export const ecommerceOrderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, default: '', @@ -118,12 +101,8 @@ export const ecommerceOrderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, default: '', @@ -136,12 +115,8 @@ export const ecommerceOrderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, options: [ @@ -159,7 +134,8 @@ export const ecommerceOrderFields: INodeProperties[] = [ name: 'promoCodes', type: 'string', default: '', - description: 'Uses multiple strings separated by comma as promo codes. The corresponding discount will be applied to the order.', + description: + 'Uses multiple strings separated by comma as promo codes. The corresponding discount will be applied to the order.', }, { displayName: 'Sales Affiliate ID', @@ -183,12 +159,8 @@ export const ecommerceOrderFields: INodeProperties[] = [ placeholder: 'Add Address', displayOptions: { show: { - resource: [ - 'ecommerceOrder', - ], - operation: [ - 'create', - ], + resource: ['ecommerceOrder'], + operation: ['create'], }, }, options: [ @@ -206,7 +178,8 @@ export const ecommerceOrderFields: INodeProperties[] = [ displayName: 'Country Code Name or ID', name: 'countryCode', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCountries', }, @@ -287,12 +260,8 @@ export const ecommerceOrderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'ecommerceOrder', - ], - operation: [ - 'create', - ], + resource: ['ecommerceOrder'], + operation: ['create'], }, }, options: [ @@ -314,7 +283,8 @@ export const ecommerceOrderFields: INodeProperties[] = [ minValue: 0, }, default: 0, - description: 'Overridable price of the product, if not specified, the default will be used', + description: + 'Overridable price of the product, if not specified, the default will be used', }, { displayName: 'Product ID', @@ -338,9 +308,9 @@ export const ecommerceOrderFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* ecommerceOrder:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* ecommerceOrder:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Order ID', name: 'orderId', @@ -348,19 +318,15 @@ export const ecommerceOrderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['delete'], + resource: ['ecommerceOrder'], }, }, default: '', }, -/* -------------------------------------------------------------------------- */ -/* ecommerceOrder:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* ecommerceOrder:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Order ID', name: 'orderId', @@ -368,31 +334,23 @@ export const ecommerceOrderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['get'], + resource: ['ecommerceOrder'], }, }, default: '', }, -/* -------------------------------------------------------------------------- */ -/* ecommerceOrder:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* ecommerceOrder:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['getAll'], + resource: ['ecommerceOrder'], }, }, default: false, @@ -404,15 +362,9 @@ export const ecommerceOrderFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceOrder', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['ecommerceOrder'], + returnAll: [false], }, }, typeOptions: { @@ -430,12 +382,8 @@ export const ecommerceOrderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['getAll'], + resource: ['ecommerceOrder'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Keap/EcommerceOrderInterface.ts b/packages/nodes-base/nodes/Keap/EcommerceOrderInterface.ts index ba7eb8264b..8a381b34bc 100644 --- a/packages/nodes-base/nodes/Keap/EcommerceOrderInterface.ts +++ b/packages/nodes-base/nodes/Keap/EcommerceOrderInterface.ts @@ -1,5 +1,3 @@ - - export interface IItem { description?: string; price?: number; @@ -8,18 +6,18 @@ export interface IItem { } export interface IShippingAddress { - company?: string; - country_code?: string; - first_name?: string; - last_name?: string; - line1?: string; - line2?: string; - locality?: string; - middle_name?: string; - postal_code?: string; - region?: string; - zip_code?: string; - zip_four?: string; + company?: string; + country_code?: string; + first_name?: string; + last_name?: string; + line1?: string; + line2?: string; + locality?: string; + middle_name?: string; + postal_code?: string; + region?: string; + zip_code?: string; + zip_four?: string; } export interface IEcommerceOrder { diff --git a/packages/nodes-base/nodes/Keap/EcommerceProductDescription.ts b/packages/nodes-base/nodes/Keap/EcommerceProductDescription.ts index 570a2a541c..195b793998 100644 --- a/packages/nodes-base/nodes/Keap/EcommerceProductDescription.ts +++ b/packages/nodes-base/nodes/Keap/EcommerceProductDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, - } from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const ecommerceProductOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const ecommerceProductOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'ecommerceProduct', - ], + resource: ['ecommerceProduct'], }, }, options: [ @@ -46,10 +42,9 @@ export const ecommerceProductOperations: INodeProperties[] = [ ]; export const ecommerceProductFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* ecommerceProduct:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* ecommerceProduct:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Product Name', name: 'productName', @@ -57,12 +52,8 @@ export const ecommerceProductFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceProduct', - ], + operation: ['create'], + resource: ['ecommerceProduct'], }, }, default: '', @@ -75,12 +66,8 @@ export const ecommerceProductFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceProduct', - ], + operation: ['create'], + resource: ['ecommerceProduct'], }, }, options: [ @@ -128,9 +115,9 @@ export const ecommerceProductFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* ecommerceProduct:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* ecommerceProduct:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Product ID', name: 'productId', @@ -138,19 +125,15 @@ export const ecommerceProductFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'ecommerceProduct', - ], + operation: ['delete'], + resource: ['ecommerceProduct'], }, }, default: '', }, -/* -------------------------------------------------------------------------- */ -/* ecommerceProduct:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* ecommerceProduct:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Product ID', name: 'productId', @@ -158,31 +141,23 @@ export const ecommerceProductFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'ecommerceProduct', - ], + operation: ['get'], + resource: ['ecommerceProduct'], }, }, default: '', }, -/* -------------------------------------------------------------------------- */ -/* ecommerceProduct:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* ecommerceProduct:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceProduct', - ], + operation: ['getAll'], + resource: ['ecommerceProduct'], }, }, default: false, @@ -194,15 +169,9 @@ export const ecommerceProductFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceProduct', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['ecommerceProduct'], + returnAll: [false], }, }, typeOptions: { @@ -220,12 +189,8 @@ export const ecommerceProductFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'ecommerceProduct', - ], + operation: ['getAll'], + resource: ['ecommerceProduct'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Keap/EcommerceProductInterface.ts b/packages/nodes-base/nodes/Keap/EcommerceProductInterface.ts index 23c2fbb493..d3d8415b40 100644 --- a/packages/nodes-base/nodes/Keap/EcommerceProductInterface.ts +++ b/packages/nodes-base/nodes/Keap/EcommerceProductInterface.ts @@ -1,4 +1,3 @@ - export interface IEcommerceProduct { active?: string; product_name?: string; diff --git a/packages/nodes-base/nodes/Keap/EmaiIInterface.ts b/packages/nodes-base/nodes/Keap/EmaiIInterface.ts index 5a8fdf5128..5465e26525 100644 --- a/packages/nodes-base/nodes/Keap/EmaiIInterface.ts +++ b/packages/nodes-base/nodes/Keap/EmaiIInterface.ts @@ -3,7 +3,6 @@ export interface IAttachment { file_name?: string; } - export interface IEmail { address_field?: string; attachments?: IAttachment[]; diff --git a/packages/nodes-base/nodes/Keap/EmailDescription.ts b/packages/nodes-base/nodes/Keap/EmailDescription.ts index 4d717c8740..f2a98b945d 100644 --- a/packages/nodes-base/nodes/Keap/EmailDescription.ts +++ b/packages/nodes-base/nodes/Keap/EmailDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, - } from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const emailOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const emailOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'email', - ], + resource: ['email'], }, }, options: [ @@ -40,10 +36,9 @@ export const emailOperations: INodeProperties[] = [ ]; export const emailFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* email:createRecord */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* email:createRecord */ + /* -------------------------------------------------------------------------- */ { displayName: 'Sent To Address', name: 'sentToAddress', @@ -51,12 +46,8 @@ export const emailFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'createRecord', - ], - resource: [ - 'email', - ], + operation: ['createRecord'], + resource: ['email'], }, }, default: '', @@ -69,12 +60,8 @@ export const emailFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'createRecord', - ], - resource: [ - 'email', - ], + operation: ['createRecord'], + resource: ['email'], }, }, }, @@ -86,12 +73,8 @@ export const emailFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'createRecord', - ], - resource: [ - 'email', - ], + operation: ['createRecord'], + resource: ['email'], }, }, options: [ @@ -159,7 +142,8 @@ export const emailFields: INodeProperties[] = [ name: 'originalProviderId', type: 'string', default: '', - description: 'Provider ID that sent the email, must be unique when combined with provider. If omitted a UUID without dashes is autogenerated for the record.', + description: + 'Provider ID that sent the email, must be unique when combined with provider. If omitted a UUID without dashes is autogenerated for the record.', }, { displayName: 'Plain Content', @@ -212,21 +196,17 @@ export const emailFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* email:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* email:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'email', - ], + operation: ['getAll'], + resource: ['email'], }, }, default: false, @@ -238,15 +218,9 @@ export const emailFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'email', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['email'], + returnAll: [false], }, }, typeOptions: { @@ -264,12 +238,8 @@ export const emailFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'email', - ], + operation: ['getAll'], + resource: ['email'], }, }, options: [ @@ -294,8 +264,8 @@ export const emailFields: INodeProperties[] = [ name: 'sinceSentDate', type: 'dateTime', default: '', - description: 'Emails sent since the provided date, must be present if untilDate is provided', - + description: + 'Emails sent since the provided date, must be present if untilDate is provided', }, { displayName: 'Until Sent Date', @@ -306,9 +276,9 @@ export const emailFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* email:send */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* email:send */ + /* -------------------------------------------------------------------------- */ { displayName: 'User Name or ID', name: 'userId', @@ -319,16 +289,13 @@ export const emailFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'email', - ], + operation: ['send'], + resource: ['email'], }, }, default: '', - description: 'The infusionsoft user to send the email on behalf of. Choose from the list, or specify an ID using an expression.', + description: + 'The infusionsoft user to send the email on behalf of. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Contact IDs', @@ -336,12 +303,8 @@ export const emailFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'email', - ], + operation: ['send'], + resource: ['email'], }, }, default: '', @@ -353,12 +316,8 @@ export const emailFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'email', - ], + operation: ['send'], + resource: ['email'], }, }, default: '', @@ -372,12 +331,8 @@ export const emailFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'email', - ], + operation: ['send'], + resource: ['email'], }, }, options: [ @@ -386,7 +341,8 @@ export const emailFields: INodeProperties[] = [ name: 'addressField', type: 'string', default: '', - description: 'Email field of each Contact record to address the email to, such as \'EmailAddress1\', \'EmailAddress2\', \'EmailAddress3\', defaulting to the contact\'s primary email', + description: + "Email field of each Contact record to address the email to, such as 'EmailAddress1', 'EmailAddress2', 'EmailAddress3', defaulting to the contact's primary email", }, { displayName: 'HTML Content', @@ -414,12 +370,8 @@ export const emailFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'email', - ], + operation: ['send'], + resource: ['email'], }, }, options: [ @@ -455,12 +407,14 @@ export const emailFields: INodeProperties[] = [ name: 'property', type: 'string', default: '', - description: 'Name of the binary properties which contain data which should be added to email as attachment', + description: + 'Name of the binary properties which contain data which should be added to email as attachment', }, ], }, ], default: {}, - description: 'Attachments to be sent with each copy of the email, maximum of 10 with size of 1MB each', + description: + 'Attachments to be sent with each copy of the email, maximum of 10 with size of 1MB each', }, ]; diff --git a/packages/nodes-base/nodes/Keap/FileDescription.ts b/packages/nodes-base/nodes/Keap/FileDescription.ts index 9420789541..3558abef06 100644 --- a/packages/nodes-base/nodes/Keap/FileDescription.ts +++ b/packages/nodes-base/nodes/Keap/FileDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, - } from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const fileOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const fileOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'file', - ], + resource: ['file'], }, }, options: [ @@ -40,9 +36,9 @@ export const fileOperations: INodeProperties[] = [ ]; export const fileFields: INodeProperties[] = [ -/* -------------------------------------------------------------------------- */ -/* file:upload */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* file:upload */ + /* -------------------------------------------------------------------------- */ { displayName: 'Binary Data', name: 'binaryData', @@ -50,12 +46,8 @@ export const fileFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, description: 'Whether the data to upload should be taken from binary field', @@ -68,15 +60,9 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], - binaryData: [ - true, - ], + operation: ['upload'], + resource: ['file'], + binaryData: [true], }, }, description: 'Name of the binary property which contains the data for the file to be uploaded', @@ -102,12 +88,8 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, default: '', @@ -119,15 +101,9 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], - fileAssociation: [ - 'contact', - ], + operation: ['upload'], + resource: ['file'], + fileAssociation: ['contact'], }, }, default: '', @@ -139,15 +115,9 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], - binaryData: [ - false, - ], + operation: ['upload'], + resource: ['file'], + binaryData: [false], }, }, default: '', @@ -163,15 +133,9 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], - binaryData: [ - false, - ], + operation: ['upload'], + resource: ['file'], + binaryData: [false], }, }, default: '', @@ -184,18 +148,14 @@ export const fileFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* file:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* file:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'File ID', name: 'fileId', @@ -203,31 +163,23 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'file', - ], + operation: ['delete'], + resource: ['file'], }, }, default: '', }, -/* -------------------------------------------------------------------------- */ -/* file:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* file:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'file', - ], + operation: ['getAll'], + resource: ['file'], }, }, default: false, @@ -239,15 +191,9 @@ export const fileFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'file', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['file'], + returnAll: [false], }, }, typeOptions: { @@ -265,12 +211,8 @@ export const fileFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'file', - ], + operation: ['getAll'], + resource: ['file'], }, }, options: [ @@ -289,7 +231,8 @@ export const fileFields: INodeProperties[] = [ name: 'name', type: 'string', default: '', - description: 'Filter files based on name, with \'*\' preceding or following to indicate LIKE queries', + description: + "Filter files based on name, with '*' preceding or following to indicate LIKE queries", }, { displayName: 'Permission', diff --git a/packages/nodes-base/nodes/Keap/FileInterface.ts b/packages/nodes-base/nodes/Keap/FileInterface.ts index e924826d26..715236079f 100644 --- a/packages/nodes-base/nodes/Keap/FileInterface.ts +++ b/packages/nodes-base/nodes/Keap/FileInterface.ts @@ -1,4 +1,3 @@ - export interface IFile { file_name?: string; file_data?: string; diff --git a/packages/nodes-base/nodes/Keap/GenericFunctions.ts b/packages/nodes-base/nodes/Keap/GenericFunctions.ts index 61e6130877..549cb089d7 100644 --- a/packages/nodes-base/nodes/Keap/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Keap/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,15 +7,22 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -import { - snakeCase, -} from 'change-case'; +import { snakeCase } from 'change-case'; -export async function keapApiRequest(this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function keapApiRequest( + this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { let options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -43,8 +48,16 @@ export async function keapApiRequest(this: IWebhookFunctions | IHookFunctions | } } -export async function keapApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function keapApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -55,9 +68,7 @@ export async function keapApiRequestAllItems(this: IHookFunctions | IExecuteFunc responseData = await keapApiRequest.call(this, method, endpoint, body, query, uri); uri = responseData.next; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - returnData.length < responseData.count - ); + } while (returnData.length < responseData.count); return returnData; } diff --git a/packages/nodes-base/nodes/Keap/Keap.node.ts b/packages/nodes-base/nodes/Keap/Keap.node.ts index 70d9317e98..ed8691ee8c 100644 --- a/packages/nodes-base/nodes/Keap/Keap.node.ts +++ b/packages/nodes-base/nodes/Keap/Keap.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryKeyData, @@ -13,51 +11,23 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - keapApiRequest, - keapApiRequestAllItems, - keysToSnakeCase, -} from './GenericFunctions'; +import { keapApiRequest, keapApiRequestAllItems, keysToSnakeCase } from './GenericFunctions'; -import { - contactFields, - contactOperations, -} from './ContactDescription'; +import { contactFields, contactOperations } from './ContactDescription'; -import { - contactNoteFields, - contactNoteOperations, -} from './ContactNoteDescription'; +import { contactNoteFields, contactNoteOperations } from './ContactNoteDescription'; -import { - contactTagFields, - contactTagOperations, -} from './ContactTagDescription'; +import { contactTagFields, contactTagOperations } from './ContactTagDescription'; -import { - ecommerceOrderFields, - ecommerceOrderOperations, -} from './EcommerceOrderDescripion'; +import { ecommerceOrderFields, ecommerceOrderOperations } from './EcommerceOrderDescripion'; -import { - ecommerceProductFields, - ecommerceProductOperations, -} from './EcommerceProductDescription'; +import { ecommerceProductFields, ecommerceProductOperations } from './EcommerceProductDescription'; -import { - emailFields, - emailOperations, -} from './EmailDescription'; +import { emailFields, emailOperations } from './EmailDescription'; -import { - fileFields, - fileOperations, -} from './FileDescription'; +import { fileFields, fileOperations } from './FileDescription'; -import { - companyFields, - companyOperations, -} from './CompanyDescription'; +import { companyFields, companyOperations } from './CompanyDescription'; import { IAddress, @@ -68,37 +38,19 @@ import { ISocialAccount, } from './ConctactInterface'; -import { - IAttachment, - IEmail, -} from './EmaiIInterface'; +import { IAttachment, IEmail } from './EmaiIInterface'; -import { - INote, -} from './ContactNoteInterface'; +import { INote } from './ContactNoteInterface'; -import { - IEcommerceOrder, - IItem, - IShippingAddress, -} from './EcommerceOrderInterface'; +import { IEcommerceOrder, IItem, IShippingAddress } from './EcommerceOrderInterface'; -import { - IEcommerceProduct, -} from './EcommerceProductInterface'; +import { IEcommerceProduct } from './EcommerceProductInterface'; -import { - IFile, -} from './FileInterface'; +import { IFile } from './FileInterface'; -import { - ICompany, -} from './CompanyInterface'; +import { ICompany } from './CompanyInterface'; -import { - capitalCase, - pascalCase, -} from 'change-case'; +import { capitalCase, pascalCase } from 'change-case'; import moment from 'moment-timezone'; @@ -244,7 +196,11 @@ export class Keap implements INodeType { async getProvinces(this: ILoadOptionsFunctions): Promise { const countryCode = this.getCurrentNodeParameter('countryCode') as string; const returnData: INodePropertyOptions[] = []; - const { provinces } = await keapApiRequest.call(this, 'GET', `/locales/countries/${countryCode}/provinces`); + const { provinces } = await keapApiRequest.call( + this, + 'GET', + `/locales/countries/${countryCode}/provinces`, + ); for (const key of Object.keys(provinces)) { const provinceName = provinces[key]; const provinceId = key; @@ -299,9 +255,12 @@ export class Keap implements INodeType { if (resource === 'company') { //https://developer.keap.com/docs/rest/#!/Company/createCompanyUsingPOST if (operation === 'create') { - const addresses = (this.getNodeParameter('addressesUi', i) as IDataObject).addressesValues as IDataObject[]; - const faxes = (this.getNodeParameter('faxesUi', i) as IDataObject).faxesValues as IDataObject[]; - const phones = (this.getNodeParameter('phonesUi', i) as IDataObject).phonesValues as IDataObject[]; + const addresses = (this.getNodeParameter('addressesUi', i) as IDataObject) + .addressesValues as IDataObject[]; + const faxes = (this.getNodeParameter('faxesUi', i) as IDataObject) + .faxesValues as IDataObject[]; + const phones = (this.getNodeParameter('phonesUi', i) as IDataObject) + .phonesValues as IDataObject[]; const companyName = this.getNodeParameter('companyName', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body: ICompany = { @@ -331,7 +290,14 @@ export class Keap implements INodeType { delete qs.fields; } if (returnAll) { - responseData = await keapApiRequestAllItems.call(this, 'companies', 'GET', '/companies', {}, qs); + responseData = await keapApiRequestAllItems.call( + this, + 'companies', + 'GET', + '/companies', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await keapApiRequest.call(this, 'GET', '/companies', {}, qs); @@ -343,11 +309,16 @@ export class Keap implements INodeType { //https://developer.infusionsoft.com/docs/rest/#!/Contact/createOrUpdateContactUsingPUT if (operation === 'upsert') { const duplicateOption = this.getNodeParameter('duplicateOption', i) as string; - const addresses = (this.getNodeParameter('addressesUi', i) as IDataObject).addressesValues as IDataObject[]; - const emails = (this.getNodeParameter('emailsUi', i) as IDataObject).emailsValues as IDataObject[]; - const faxes = (this.getNodeParameter('faxesUi', i) as IDataObject).faxesValues as IDataObject[]; - const socialAccounts = (this.getNodeParameter('socialAccountsUi', i) as IDataObject).socialAccountsValues as IDataObject[]; - const phones = (this.getNodeParameter('phonesUi', i) as IDataObject).phonesValues as IDataObject[]; + const addresses = (this.getNodeParameter('addressesUi', i) as IDataObject) + .addressesValues as IDataObject[]; + const emails = (this.getNodeParameter('emailsUi', i) as IDataObject) + .emailsValues as IDataObject[]; + const faxes = (this.getNodeParameter('faxesUi', i) as IDataObject) + .faxesValues as IDataObject[]; + const socialAccounts = (this.getNodeParameter('socialAccountsUi', i) as IDataObject) + .socialAccountsValues as IDataObject[]; + const phones = (this.getNodeParameter('phonesUi', i) as IDataObject) + .phonesValues as IDataObject[]; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body: IContact = { duplicate_option: pascalCase(duplicateOption), @@ -468,7 +439,14 @@ export class Keap implements INodeType { qs.until = options.until as string; } if (returnAll) { - responseData = await keapApiRequestAllItems.call(this, 'contacts', 'GET', '/contacts', {}, qs); + responseData = await keapApiRequestAllItems.call( + this, + 'contacts', + 'GET', + '/contacts', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await keapApiRequest.call(this, 'GET', '/contacts', {}, qs); @@ -511,7 +489,14 @@ export class Keap implements INodeType { keysToSnakeCase(filters); Object.assign(qs, filters); if (returnAll) { - responseData = await keapApiRequestAllItems.call(this, 'notes', 'GET', '/notes', {}, qs); + responseData = await keapApiRequestAllItems.call( + this, + 'notes', + 'GET', + '/notes', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await keapApiRequest.call(this, 'GET', '/notes', {}, qs); @@ -539,14 +524,25 @@ export class Keap implements INodeType { const body: IDataObject = { tagIds, }; - responseData = await keapApiRequest.call(this, 'POST', `/contacts/${contactId}/tags`, body); + responseData = await keapApiRequest.call( + this, + 'POST', + `/contacts/${contactId}/tags`, + body, + ); } //https://developer.infusionsoft.com/docs/rest/#!/Contact/removeTagsFromContactUsingDELETE_1 if (operation === 'delete') { const contactId = parseInt(this.getNodeParameter('contactId', i) as string, 10); const tagIds = this.getNodeParameter('tagIds', i) as string; qs.ids = tagIds; - responseData = await keapApiRequest.call(this, 'DELETE', `/contacts/${contactId}/tags`, {}, qs); + responseData = await keapApiRequest.call( + this, + 'DELETE', + `/contacts/${contactId}/tags`, + {}, + qs, + ); responseData = { success: true }; } //https://developer.infusionsoft.com/docs/rest/#!/Contact/listAppliedTagsUsingGET @@ -554,10 +550,23 @@ export class Keap implements INodeType { const returnAll = this.getNodeParameter('returnAll', i) as boolean; const contactId = parseInt(this.getNodeParameter('contactId', i) as string, 10); if (returnAll) { - responseData = await keapApiRequestAllItems.call(this, 'tags', 'GET', `/contacts/${contactId}/tags`, {}, qs); + responseData = await keapApiRequestAllItems.call( + this, + 'tags', + 'GET', + `/contacts/${contactId}/tags`, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await keapApiRequest.call(this, 'GET', `/contacts/${contactId}/tags`, {}, qs); + responseData = await keapApiRequest.call( + this, + 'GET', + `/contacts/${contactId}/tags`, + {}, + qs, + ); responseData = responseData.tags; } } @@ -569,8 +578,10 @@ export class Keap implements INodeType { const orderDate = this.getNodeParameter('orderDate', i) as string; const orderTitle = this.getNodeParameter('orderTitle', i) as string; const orderType = this.getNodeParameter('orderType', i) as string; - const orderItems = (this.getNodeParameter('orderItemsUi', i) as IDataObject).orderItemsValues as IDataObject[]; - const shippingAddress = (this.getNodeParameter('addressUi', i) as IDataObject).addressValues as IDataObject; + const orderItems = (this.getNodeParameter('orderItemsUi', i) as IDataObject) + .orderItemsValues as IDataObject[]; + const shippingAddress = (this.getNodeParameter('addressUi', i) as IDataObject) + .addressValues as IDataObject; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body: IEcommerceOrder = { contact_id: contactId, @@ -579,7 +590,9 @@ export class Keap implements INodeType { order_type: pascalCase(orderType), }; if (additionalFields.promoCodes) { - additionalFields.promoCodes = (additionalFields.promoCodes as string).split(',') as string[]; + additionalFields.promoCodes = (additionalFields.promoCodes as string).split( + ',', + ) as string[]; } keysToSnakeCase(additionalFields); Object.assign(body, additionalFields); @@ -607,7 +620,14 @@ export class Keap implements INodeType { keysToSnakeCase(options); Object.assign(qs, options); if (returnAll) { - responseData = await keapApiRequestAllItems.call(this, 'orders', 'GET', '/orders', {}, qs); + responseData = await keapApiRequestAllItems.call( + this, + 'orders', + 'GET', + '/orders', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await keapApiRequest.call(this, 'GET', '/orders', {}, qs); @@ -645,7 +665,14 @@ export class Keap implements INodeType { keysToSnakeCase(filters); Object.assign(qs, filters); if (returnAll) { - responseData = await keapApiRequestAllItems.call(this, 'products', 'GET', '/products', {}, qs); + responseData = await keapApiRequestAllItems.call( + this, + 'products', + 'GET', + '/products', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await keapApiRequest.call(this, 'GET', '/products', {}, qs); @@ -680,7 +707,14 @@ export class Keap implements INodeType { keysToSnakeCase(filters); Object.assign(qs, filters); if (returnAll) { - responseData = await keapApiRequestAllItems.call(this, 'emails', 'GET', '/emails', {}, qs); + responseData = await keapApiRequestAllItems.call( + this, + 'emails', + 'GET', + '/emails', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await keapApiRequest.call(this, 'GET', '/emails', {}, qs); @@ -690,7 +724,9 @@ export class Keap implements INodeType { //https://developer.infusionsoft.com/docs/rest/#!/Email/deleteEmailUsingDELETE if (operation === 'send') { const userId = this.getNodeParameter('userId', i) as number; - const contactIds = ((this.getNodeParameter('contactIds', i) as string).split(',') as string[]).map((e) => (parseInt(e, 10))); + const contactIds = ( + (this.getNodeParameter('contactIds', i) as string).split(',') as string[] + ).map((e) => parseInt(e, 10)); const subject = this.getNodeParameter('subject', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body: IEmail = { @@ -708,19 +744,25 @@ export class Keap implements INodeType { keysToSnakeCase(attachmentsUi.attachmentsValues as IDataObject); attachments = attachmentsUi.attachmentsValues as IAttachment[]; } - if (attachmentsUi.attachmentsBinary - && (attachmentsUi.attachmentsBinary as IDataObject).length) { - + if ( + attachmentsUi.attachmentsBinary && + (attachmentsUi.attachmentsBinary as IDataObject).length + ) { if (items[i].binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } for (const { property } of attachmentsUi.attachmentsBinary as IDataObject[]) { - const item = items[i].binary as IBinaryKeyData; if (item[property as string] === undefined) { - throw new NodeOperationError(this.getNode(), `Binary data property "${property}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Binary data property "${property}" does not exists on item!`, + { itemIndex: i }, + ); } attachments.push({ @@ -759,7 +801,14 @@ export class Keap implements INodeType { qs.viewable = (qs.viewable as string).toUpperCase(); } if (returnAll) { - responseData = await keapApiRequestAllItems.call(this, 'files', 'GET', '/files', {}, qs); + responseData = await keapApiRequestAllItems.call( + this, + 'files', + 'GET', + '/files', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await keapApiRequest.call(this, 'GET', '/files', {}, qs); @@ -783,18 +832,23 @@ export class Keap implements INodeType { const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; if (items[i].binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const item = items[i].binary as IBinaryKeyData; if (item[binaryPropertyName as string] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + { itemIndex: i }, + ); } body.file_data = item[binaryPropertyName as string].data; body.file_name = item[binaryPropertyName as string].fileName; - } else { const fileName = this.getNodeParameter('fileName', i) as string; const fileData = this.getNodeParameter('fileData', i) as string; diff --git a/packages/nodes-base/nodes/Keap/KeapTrigger.node.ts b/packages/nodes-base/nodes/Keap/KeapTrigger.node.ts index 956ff820c2..5b6f3b5071 100644 --- a/packages/nodes-base/nodes/Keap/KeapTrigger.node.ts +++ b/packages/nodes-base/nodes/Keap/KeapTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -12,13 +9,9 @@ import { IWebhookResponseData, } from 'n8n-workflow'; -import { - keapApiRequest, -} from './GenericFunctions'; +import { keapApiRequest } from './GenericFunctions'; -import { - capitalCase, - } from 'change-case'; +import { capitalCase } from 'change-case'; export class KeapTrigger implements INodeType { description: INodeTypeDescription = { @@ -54,7 +47,8 @@ export class KeapTrigger implements INodeType { displayName: 'Event Name or ID', name: 'eventId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getEvents', }, @@ -102,9 +96,11 @@ export class KeapTrigger implements INodeType { const responseData = await keapApiRequest.call(this, 'GET', '/hooks', {}); for (const existingData of responseData) { - if (existingData.hookUrl === webhookUrl - && existingData.eventKey === eventId - && existingData.status === 'Verified') { + if ( + existingData.hookUrl === webhookUrl && + existingData.eventKey === eventId && + existingData.status === 'Verified' + ) { // The webhook exists already webhookData.webhookId = existingData.key; return true; @@ -138,7 +134,6 @@ export class KeapTrigger implements INodeType { const webhookData = this.getWorkflowStaticData('node'); if (webhookData.webhookId !== undefined) { - try { await keapApiRequest.call(this, 'DELETE', `/hooks/${webhookData.webhookId}`); } catch (error) { @@ -172,9 +167,7 @@ export class KeapTrigger implements INodeType { if (rawData) { return { - workflowData: [ - this.helpers.returnJsonArray(bodyData), - ], + workflowData: [this.helpers.returnJsonArray(bodyData)], }; } @@ -189,9 +182,7 @@ export class KeapTrigger implements INodeType { }); } return { - workflowData: [ - this.helpers.returnJsonArray(responseData), - ], + workflowData: [this.helpers.returnJsonArray(responseData)], }; } } diff --git a/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts b/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts index 80884f0e33..6b41026e62 100644 --- a/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts @@ -1,19 +1,14 @@ -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - IHookFunctions, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, IHookFunctions, NodeApiError } from 'n8n-workflow'; export async function kitemakerRequest( this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, body: IDataObject = {}, ) { - const { personalAccessToken } = await this.getCredentials('kitemakerApi') as { personalAccessToken: string }; + const { personalAccessToken } = (await this.getCredentials('kitemakerApi')) as { + personalAccessToken: string; + }; const options = { headers: { @@ -55,7 +50,6 @@ export async function kitemakerRequestAllItems( if (!returnAll && returnData.length > limit) { return returnData.slice(0, limit); } - } while (responseData.data[group].hasMore); return returnData; @@ -68,18 +62,15 @@ function getGroupAndItems(resource: 'space' | 'user' | 'workItem') { workItem: { group: 'workItems', items: 'workItems' }, }; - return [ - map[resource]['group'], - map[resource]['items'], - ]; + return [map[resource]['group'], map[resource]['items']]; } export function createLoadOptions( resources: Array<{ name?: string; username?: string; title?: string; id: string }>, ): Array<{ name: string; value: string }> { - return resources.map(option => { - if (option.username) return ({ name: option.username, value: option.id }); - if (option.title) return ({ name: option.title, value: option.id }); - return ({ name: option.name ?? 'Unnamed', value: option.id }); + return resources.map((option) => { + if (option.username) return { name: option.username, value: option.id }; + if (option.title) return { name: option.title, value: option.id }; + return { name: option.name ?? 'Unnamed', value: option.id }; }); } diff --git a/packages/nodes-base/nodes/Kitemaker/Kitemaker.node.ts b/packages/nodes-base/nodes/Kitemaker/Kitemaker.node.ts index d0dbbbfae6..29bddeff27 100644 --- a/packages/nodes-base/nodes/Kitemaker/Kitemaker.node.ts +++ b/packages/nodes-base/nodes/Kitemaker/Kitemaker.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -8,7 +6,7 @@ import { INodeExecutionData, INodeType, INodeTypeDescription, - NodeOperationError + NodeOperationError, } from 'n8n-workflow'; import { @@ -21,11 +19,7 @@ import { workItemOperations, } from './descriptions'; -import { - createLoadOptions, - kitemakerRequest, - kitemakerRequestAllItems, -} from './GenericFunctions'; +import { createLoadOptions, kitemakerRequest, kitemakerRequestAllItems } from './GenericFunctions'; import { getAllSpaces, @@ -40,10 +34,7 @@ import { getWorkItems, } from './queries'; -import { - createWorkItem, - editWorkItem, -} from './mutations'; +import { createWorkItem, editWorkItem } from './mutations'; export class Kitemaker implements INodeType { description: INodeTypeDescription = { @@ -106,14 +97,22 @@ export class Kitemaker implements INodeType { loadOptions: { async getLabels(this: ILoadOptionsFunctions) { const responseData = await kitemakerRequest.call(this, { query: getLabels }); - const { data: { organization: { spaces } } } = responseData; + const { + data: { + organization: { spaces }, + }, + } = responseData; return createLoadOptions(spaces[0].labels); }, async getSpaces(this: ILoadOptionsFunctions) { const responseData = await kitemakerRequest.call(this, { query: getSpaces }); - const { data: { organization: { spaces } } } = responseData; + const { + data: { + organization: { spaces }, + }, + } = responseData; return createLoadOptions(spaces); }, @@ -121,19 +120,30 @@ export class Kitemaker implements INodeType { async getStatuses(this: ILoadOptionsFunctions) { const spaceId = this.getNodeParameter('spaceId', 0) as string; if (!spaceId.length) { - throw new NodeOperationError(this.getNode(), 'Please choose a space to set for the work item to create.'); + throw new NodeOperationError( + this.getNode(), + 'Please choose a space to set for the work item to create.', + ); } const responseData = await kitemakerRequest.call(this, { query: getStatuses }); - const { data: { organization: { spaces } } } = responseData; - const space = spaces.find((e: { [x: string]: string; }) => e.id === spaceId); + const { + data: { + organization: { spaces }, + }, + } = responseData; + const space = spaces.find((e: { [x: string]: string }) => e.id === spaceId); return createLoadOptions(space.statuses); }, async getUsers(this: ILoadOptionsFunctions) { const responseData = await kitemakerRequest.call(this, { query: getUsers }); - const { data: { organization: { users } } } = responseData; + const { + data: { + organization: { users }, + }, + } = responseData; return createLoadOptions(users); }, @@ -146,11 +156,14 @@ export class Kitemaker implements INodeType { variables: { spaceId }, }); - const { data: { workItems: { workItems } } } = responseData; + const { + data: { + workItems: { workItems }, + }, + } = responseData; return createLoadOptions(workItems); }, - }, }; @@ -166,15 +179,12 @@ export class Kitemaker implements INodeType { // https://github.com/kitemakerhq/docs/blob/main/kitemaker.graphql for (let i = 0; i < items.length; i++) { - if (resource === 'organization') { - // ********************************************************************* // organization // ********************************************************************* if (operation === 'get') { - // ---------------------------------- // organization: get // ---------------------------------- @@ -184,17 +194,13 @@ export class Kitemaker implements INodeType { }); returnData.push(responseData.data.organization); - } - } else if (resource === 'space') { - // ********************************************************************* // space // ********************************************************************* if (operation === 'getAll') { - // ---------------------------------- // space: getAll // ---------------------------------- @@ -205,17 +211,13 @@ export class Kitemaker implements INodeType { }); returnData.push(...allItems); - } - } else if (resource === 'user') { - // ********************************************************************* // user // ********************************************************************* if (operation === 'getAll') { - // ---------------------------------- // user: getAll // ---------------------------------- @@ -226,17 +228,13 @@ export class Kitemaker implements INodeType { }); returnData.push(...allItems); - } - } else if (resource === 'workItem') { - // ********************************************************************* // workItem // ********************************************************************* if (operation === 'create') { - // ---------------------------------- // workItem: create // ---------------------------------- @@ -247,7 +245,11 @@ export class Kitemaker implements INodeType { }; if (!input.statusId.length) { - throw new NodeOperationError(this.getNode(), 'Please enter a status to set for the work item to create.', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Please enter a status to set for the work item to create.', + { itemIndex: i }, + ); } const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; @@ -262,9 +264,7 @@ export class Kitemaker implements INodeType { }); returnData.push(responseData.data.createWorkItem.workItem); - } else if (operation === 'get') { - // ---------------------------------- // workItem: get // ---------------------------------- @@ -277,9 +277,7 @@ export class Kitemaker implements INodeType { }); returnData.push(responseData.data.workItem); - } else if (operation === 'getAll') { - // ---------------------------------- // workItem: getAll // ---------------------------------- @@ -292,9 +290,7 @@ export class Kitemaker implements INodeType { }); returnData.push(...allItems); - } else if (operation === 'update') { - // ---------------------------------- // workItem: update // ---------------------------------- @@ -306,7 +302,11 @@ export class Kitemaker implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; if (!Object.keys(updateFields).length) { - throw new NodeOperationError(this.getNode(), 'Please enter at least one field to update for the work item.', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Please enter at least one field to update for the work item.', + { itemIndex: i }, + ); } Object.assign(input, updateFields); @@ -317,7 +317,6 @@ export class Kitemaker implements INodeType { }); returnData.push(responseData.data.editWorkItem.workItem); - } } } diff --git a/packages/nodes-base/nodes/Kitemaker/descriptions/OrganizationDescription.ts b/packages/nodes-base/nodes/Kitemaker/descriptions/OrganizationDescription.ts index 41d8e962cc..d1bd8bd217 100644 --- a/packages/nodes-base/nodes/Kitemaker/descriptions/OrganizationDescription.ts +++ b/packages/nodes-base/nodes/Kitemaker/descriptions/OrganizationDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const organizationOperations: INodeProperties[] = [ { @@ -13,15 +11,13 @@ export const organizationOperations: INodeProperties[] = [ { name: 'Get', value: 'get', - description: 'Retrieve data on the logged-in user\'s organization', - action: 'Get the logged-in user\'s organization', + description: "Retrieve data on the logged-in user's organization", + action: "Get the logged-in user's organization", }, ], displayOptions: { show: { - resource: [ - 'organization', - ], + resource: ['organization'], }, }, }, diff --git a/packages/nodes-base/nodes/Kitemaker/descriptions/SpaceDescription.ts b/packages/nodes-base/nodes/Kitemaker/descriptions/SpaceDescription.ts index 8258c69777..5ade4fa169 100644 --- a/packages/nodes-base/nodes/Kitemaker/descriptions/SpaceDescription.ts +++ b/packages/nodes-base/nodes/Kitemaker/descriptions/SpaceDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const spaceOperations: INodeProperties[] = [ { @@ -13,15 +11,13 @@ export const spaceOperations: INodeProperties[] = [ { name: 'Get All', value: 'getAll', - description: 'Retrieve data on all the spaces in the logged-in user\'s organization', + description: "Retrieve data on all the spaces in the logged-in user's organization", action: 'Get all spaces', }, ], displayOptions: { show: { - resource: [ - 'space', - ], + resource: ['space'], }, }, }, @@ -36,12 +32,8 @@ export const spaceFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'space', - ], - operation: [ - 'getAll', - ], + resource: ['space'], + operation: ['getAll'], }, }, }, @@ -57,15 +49,9 @@ export const spaceFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'space', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['space'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Kitemaker/descriptions/UserDescription.ts b/packages/nodes-base/nodes/Kitemaker/descriptions/UserDescription.ts index 9b108a629d..24f5b5cbf9 100644 --- a/packages/nodes-base/nodes/Kitemaker/descriptions/UserDescription.ts +++ b/packages/nodes-base/nodes/Kitemaker/descriptions/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -13,15 +11,13 @@ export const userOperations: INodeProperties[] = [ { name: 'Get All', value: 'getAll', - description: 'Retrieve data on all the users in the logged-in user\'s organization', + description: "Retrieve data on all the users in the logged-in user's organization", action: 'Get all users', }, ], displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, }, @@ -36,12 +32,8 @@ export const userFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, }, @@ -57,15 +49,9 @@ export const userFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['user'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Kitemaker/descriptions/WorkItemDescription.ts b/packages/nodes-base/nodes/Kitemaker/descriptions/WorkItemDescription.ts index 91debc9c4b..365bcc9ddd 100644 --- a/packages/nodes-base/nodes/Kitemaker/descriptions/WorkItemDescription.ts +++ b/packages/nodes-base/nodes/Kitemaker/descriptions/WorkItemDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const workItemOperations: INodeProperties[] = [ { @@ -33,9 +31,7 @@ export const workItemOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'workItem', - ], + resource: ['workItem'], }, }, }, @@ -54,12 +50,8 @@ export const workItemFields: INodeProperties[] = [ description: 'Title of the work item to create', displayOptions: { show: { - resource: [ - 'workItem', - ], - operation: [ - 'create', - ], + resource: ['workItem'], + operation: ['create'], }, }, }, @@ -72,15 +64,12 @@ export const workItemFields: INodeProperties[] = [ }, default: [], required: true, - description: 'ID of the space to retrieve the work items from. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the space to retrieve the work items from. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'workItem', - ], - operation: [ - 'create', - ], + resource: ['workItem'], + operation: ['create'], }, }, }, @@ -94,15 +83,12 @@ export const workItemFields: INodeProperties[] = [ }, default: [], required: true, - description: 'ID of the status to set on the item to create. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the status to set on the item to create. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'workItem', - ], - operation: [ - 'create', - ], + resource: ['workItem'], + operation: ['create'], }, }, }, @@ -114,12 +100,8 @@ export const workItemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'workItem', - ], - operation: [ - 'create', - ], + resource: ['workItem'], + operation: ['create'], }, }, options: [ @@ -183,7 +165,8 @@ export const workItemFields: INodeProperties[] = [ loadOptionsMethod: 'getLabels', }, default: [], - description: 'ID of the label to set on the item to create. Choose from the list, or specify IDs using an expression.', + description: + 'ID of the label to set on the item to create. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Member Names or IDs', @@ -193,7 +176,8 @@ export const workItemFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: [], - description: 'ID of the user to assign to the item to create. Choose from the list, or specify IDs using an expression.', + description: + 'ID of the user to assign to the item to create. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -210,12 +194,8 @@ export const workItemFields: INodeProperties[] = [ description: 'ID of the work item to retrieve', displayOptions: { show: { - resource: [ - 'workItem', - ], - operation: [ - 'get', - ], + resource: ['workItem'], + operation: ['get'], }, }, }, @@ -232,15 +212,12 @@ export const workItemFields: INodeProperties[] = [ }, default: [], required: true, - description: 'ID of the space to retrieve the work items from. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the space to retrieve the work items from. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'workItem', - ], - operation: [ - 'getAll', - ], + resource: ['workItem'], + operation: ['getAll'], }, }, }, @@ -252,12 +229,8 @@ export const workItemFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'workItem', - ], - operation: [ - 'getAll', - ], + resource: ['workItem'], + operation: ['getAll'], }, }, }, @@ -273,15 +246,9 @@ export const workItemFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'workItem', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['workItem'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -298,12 +265,8 @@ export const workItemFields: INodeProperties[] = [ description: 'ID of the work item to update', displayOptions: { show: { - resource: [ - 'workItem', - ], - operation: [ - 'update', - ], + resource: ['workItem'], + operation: ['update'], }, }, }, @@ -315,12 +278,8 @@ export const workItemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'workItem', - ], - operation: [ - 'update', - ], + resource: ['workItem'], + operation: ['update'], }, }, options: [ @@ -384,7 +343,8 @@ export const workItemFields: INodeProperties[] = [ loadOptionsMethod: 'getStatuses', }, default: [], - description: 'ID of the status to set on the item to update. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the status to set on the item to update. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Title', diff --git a/packages/nodes-base/nodes/KoBoToolbox/FormDescription.ts b/packages/nodes-base/nodes/KoBoToolbox/FormDescription.ts index 9b4dae7854..dda88bb370 100644 --- a/packages/nodes-base/nodes/KoBoToolbox/FormDescription.ts +++ b/packages/nodes-base/nodes/KoBoToolbox/FormDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const formOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const formOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'form', - ], + resource: ['form'], }, }, options: [ @@ -34,7 +30,6 @@ export const formOperations: INodeProperties[] = [ ]; export const formFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* form:get */ /* -------------------------------------------------------------------------- */ @@ -46,12 +41,8 @@ export const formFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'form', - ], - operation: [ - 'get', - ], + resource: ['form'], + operation: ['get'], }, }, description: 'Form ID (e.g. aSAvYreNzVEkrWg5Gdcvg)', @@ -67,12 +58,8 @@ export const formFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'form', - ], - operation: [ - 'getAll', - ], + resource: ['form'], + operation: ['getAll'], }, }, description: 'Whether to return all results or only up to a given limit', @@ -86,15 +73,9 @@ export const formFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'form', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['form'], + operation: ['getAll'], + returnAll: [false], }, }, default: 1000, @@ -108,12 +89,8 @@ export const formFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'form', - ], - operation: [ - 'getAll', - ], + resource: ['form'], + operation: ['getAll'], }, }, options: [ @@ -181,12 +158,8 @@ export const formFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'form', - ], - operation: [ - 'getAll', - ], + resource: ['form'], + operation: ['getAll'], }, }, options: [ @@ -195,7 +168,8 @@ export const formFields: INodeProperties[] = [ name: 'filter', type: 'string', default: 'asset_type:survey', - description: 'A text search query based on form data - e.g. "owner__username:meg AND name__icontains:quixotic" - see docs for more details', + description: + 'A text search query based on form data - e.g. "owner__username:meg AND name__icontains:quixotic" - see docs for more details', }, ], }, diff --git a/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts b/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts index 481aa5c482..3913b3455d 100644 --- a/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts +++ b/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts @@ -1,7 +1,4 @@ -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject, @@ -14,7 +11,11 @@ import { import _ from 'lodash'; -export async function koBoToolboxApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function koBoToolboxApiRequest( + this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('koBoToolboxApi'); // Set up pagination / scrolling @@ -29,7 +30,7 @@ export async function koBoToolboxApiRequest(this: IExecuteFunctions | IWebhookFu const options: IHttpRequestOptions = { url: '', headers: { - 'Accept': 'application/json', + Accept: 'application/json', }, json: true, }; @@ -43,13 +44,16 @@ export async function koBoToolboxApiRequest(this: IExecuteFunctions | IWebhookFu let results = null; let keepLooking = true; while (keepLooking) { - const response = await this.helpers.httpRequestWithAuthentication.call(this, 'koBoToolboxApi', options); + const response = await this.helpers.httpRequestWithAuthentication.call( + this, + 'koBoToolboxApi', + options, + ); // Append or set results results = response.results ? _.concat(results || [], response.results) : response; if (returnAll && response.next) { options.url = response.next; - } - else { + } else { keepLooking = false; } } @@ -61,12 +65,12 @@ function parseGeoPoint(geoPoint: string): null | number[] { // Check if it looks like a "lat lon z precision" flat string e.g. "-1.931161 30.079811 0 0" (lat, lon, elevation, precision) // NOTE: we are discarding the elevation and precision values since they're not (well) supported in GeoJSON const coordinates = _.split(geoPoint, ' '); - if (coordinates.length >= 2 && _.every(coordinates, coord => coord && /^-?\d+(?:\.\d+)?$/.test(_.toString(coord)))) { + if ( + coordinates.length >= 2 && + _.every(coordinates, (coord) => coord && /^-?\d+(?:\.\d+)?$/.test(_.toString(coord))) + ) { // NOTE: GeoJSON uses lon, lat, while most common systems use lat, lon order! - return [ - _.toNumber(coordinates[1]), - _.toNumber(coordinates[0]), - ]; + return [_.toNumber(coordinates[1]), _.toNumber(coordinates[0])]; } return null; } @@ -80,7 +84,8 @@ const matchWildcard = (value: string, pattern: string): boolean => { return regex.test(value); }; -const formatValue = (value: any, format: string): any => { //tslint:disable-line:no-any +// tslint:disable-next-line:no-any +const formatValue = (value: any, format: string): any => { if (_.isString(value)) { // Sanitize value value = _.toString(value); @@ -102,15 +107,14 @@ const formatValue = (value: any, format: string): any => { //tslint:disable-line // Only return if all values are properly parsed if (coordinates.length === points.length) { // If the shape is closed, declare it as Polygon, otherwise as LineString - return _.first(points) === _.last(points) - ? { + if (_.first(points) === _.last(points)) { + return { type: 'Polygon', coordinates: [coordinates], - } - : { - type: 'LineString', - coordinates, }; + } + + return { type: 'LineString', coordinates }; } } @@ -128,20 +132,27 @@ const formatValue = (value: any, format: string): any => { //tslint:disable-line return value; }; -export function formatSubmission(submission: IDataObject, selectMasks: string[] = [], numberMasks: string[] = []): IDataObject { +export function formatSubmission( + submission: IDataObject, + selectMasks: string[] = [], + numberMasks: string[] = [], +): IDataObject { // Create a shallow copy of the submission const response = {} as IDataObject; for (const key of Object.keys(submission)) { let value = _.clone(submission[key]); // Sanitize key names: split by group, trim _ - const sanitizedKey = key.split('/').map(k => _.trim(k, ' _')).join('.'); + const sanitizedKey = key + .split('/') + .map((k) => _.trim(k, ' _')) + .join('.'); const leafKey = sanitizedKey.split('.').pop() || ''; let format = 'string'; - if (_.some(numberMasks, mask => matchWildcard(leafKey, mask))) { + if (_.some(numberMasks, (mask) => matchWildcard(leafKey, mask))) { format = 'number'; } - if (_.some(selectMasks, mask => matchWildcard(leafKey, mask))) { + if (_.some(selectMasks, (mask) => matchWildcard(leafKey, mask))) { format = 'multiSelect'; } @@ -151,7 +162,12 @@ export function formatSubmission(submission: IDataObject, selectMasks: string[] } // Reformat _geolocation - if (_.isArray(response.geolocation) && response.geolocation.length === 2 && response.geolocation[0] && response.geolocation[1]) { + if ( + _.isArray(response.geolocation) && + response.geolocation.length === 2 && + response.geolocation[0] && + response.geolocation[1] + ) { response.geolocation = { type: 'Point', coordinates: [response.geolocation[1], response.geolocation[0]], @@ -161,7 +177,11 @@ export function formatSubmission(submission: IDataObject, selectMasks: string[] return response; } -export async function downloadAttachments(this: IExecuteFunctions | IWebhookFunctions, submission: IDataObject, options: IDataObject): Promise { +export async function downloadAttachments( + this: IExecuteFunctions | IWebhookFunctions, + submission: IDataObject, + options: IDataObject, +): Promise { // Initialize return object with the original submission JSON content const binaryItem: INodeExecutionData = { json: { @@ -173,20 +193,20 @@ export async function downloadAttachments(this: IExecuteFunctions | IWebhookFunc const credentials = await this.getCredentials('koBoToolboxApi'); // Look for attachment links - there can be more than one - const attachmentList = (submission['_attachments'] || submission['attachments']) as any[]; // tslint:disable-line:no-any + const attachmentList = (submission['_attachments'] || submission['attachments']) as any[]; // tslint:disable-line:no-any if (attachmentList && attachmentList.length) { for (const [index, attachment] of attachmentList.entries()) { // look for the question name linked to this attachment const fileName = attachment.filename; - const sanitizedFileName = _.toString(fileName).replace(/_[^_]+(?=\.\w+)/,''); // strip suffix + const sanitizedFileName = _.toString(fileName).replace(/_[^_]+(?=\.\w+)/, ''); // strip suffix let relatedQuestion = null; - if('question' === options.binaryNamingScheme) { - for(const question of Object.keys(submission)) { + if ('question' === options.binaryNamingScheme) { + for (const question of Object.keys(submission)) { // The logic to map attachments to question is sometimes ambiguous: // - If the attachment is linked to a question, the question's value is the same as the attachment's filename (with spaces replaced by underscores) // - BUT sometimes the attachment's filename has an extra suffix, e.g. "My_Picture_0OdlaKJ.jpg", would map to the question "picture": "My Picture.jpg" - const sanitizedQuestionValue = _.toString(submission[question]).replace(/\s/g, '_'); // replace spaces with underscores + const sanitizedQuestionValue = _.toString(submission[question]).replace(/\s/g, '_'); // replace spaces with underscores if (sanitizedFileName === sanitizedQuestionValue) { relatedQuestion = question; // Just use the first match... @@ -199,14 +219,16 @@ export async function downloadAttachments(this: IExecuteFunctions | IWebhookFunc // NOTE: this needs to follow redirects (possibly across domains), while keeping Authorization headers // The Axios client will not propagate the Authorization header on redirects (see https://github.com/axios/axios/issues/3607), so we need to follow ourselves... let response = null; - const attachmentUrl = attachment[options.version as string] || attachment.download_url as string; - let final = false, redir = 0; + const attachmentUrl = + attachment[options.version as string] || (attachment.download_url as string); + let final = false, + redir = 0; const axiosOptions: IHttpRequestOptions = { url: attachmentUrl, method: 'GET', headers: { - 'Authorization': `Token ${credentials.token}`, + Authorization: `Token ${credentials.token}`, }, ignoreHttpStatusErrors: true, returnFullResponse: true, @@ -229,14 +251,16 @@ export async function downloadAttachments(this: IExecuteFunctions | IWebhookFunc if (response && response.body) { // Use the provided prefix if any, otherwise try to use the original question name let binaryName; - if('question' === options.binaryNamingScheme && relatedQuestion) { + if ('question' === options.binaryNamingScheme && relatedQuestion) { binaryName = relatedQuestion; - } - else { + } else { binaryName = `${options.dataPropertyAttachmentsPrefixName || 'attachment_'}${index}`; } - binaryItem.binary![binaryName] = await this.helpers.prepareBinaryData(response.body, fileName); + binaryItem.binary![binaryName] = await this.helpers.prepareBinaryData( + response.body, + fileName, + ); } } } else { @@ -257,5 +281,5 @@ export async function loadForms(this: ILoadOptionsFunctions): Promise ({ name: survey.name, value: survey.uid })) || []; // tslint:disable-line:no-any + return responseData?.map((survey: any) => ({ name: survey.name, value: survey.uid })) || []; // tslint:disable-line:no-any } diff --git a/packages/nodes-base/nodes/KoBoToolbox/HookDescription.ts b/packages/nodes-base/nodes/KoBoToolbox/HookDescription.ts index 56392de5e6..80537a16ec 100644 --- a/packages/nodes-base/nodes/KoBoToolbox/HookDescription.ts +++ b/packages/nodes-base/nodes/KoBoToolbox/HookDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const hookOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const hookOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'hook', - ], + resource: ['hook'], }, }, options: [ @@ -52,7 +48,6 @@ export const hookOperations: INodeProperties[] = [ ]; export const hookFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* hook:get */ /* -------------------------------------------------------------------------- */ @@ -67,18 +62,12 @@ export const hookFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'hook', - ], - operation: [ - 'get', - 'retryOne', - 'retryAll', - 'getLogs', - ], + resource: ['hook'], + operation: ['get', 'retryOne', 'retryAll', 'getLogs'], }, }, - description: 'Form ID (e.g. aSAvYreNzVEkrWg5Gdcvg). Choose from the list, or specify an ID using an expression.', + description: + 'Form ID (e.g. aSAvYreNzVEkrWg5Gdcvg). Choose from the list, or specify an ID using an expression.', }, { displayName: 'Hook ID', @@ -87,15 +76,8 @@ export const hookFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'hook', - ], - operation: [ - 'get', - 'retryOne', - 'retryAll', - 'getLogs', - ], + resource: ['hook'], + operation: ['get', 'retryOne', 'retryAll', 'getLogs'], }, }, default: '', @@ -115,15 +97,12 @@ export const hookFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'hook', - ], - operation: [ - 'getAll', - ], + resource: ['hook'], + operation: ['getAll'], }, }, - description: 'Form ID (e.g. aSAvYreNzVEkrWg5Gdcvg). Choose from the list, or specify an ID using an expression.', + description: + 'Form ID (e.g. aSAvYreNzVEkrWg5Gdcvg). Choose from the list, or specify an ID using an expression.', }, { displayName: 'Hook Log ID', @@ -132,12 +111,8 @@ export const hookFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'hook', - ], - operation: [ - 'retryOne', - ], + resource: ['hook'], + operation: ['retryOne'], }, }, default: '', @@ -151,13 +126,8 @@ export const hookFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'hook', - ], - operation: [ - 'getAll', - 'getLogs', - ], + resource: ['hook'], + operation: ['getAll', 'getLogs'], }, }, description: 'Whether to return all results or only up to a given limit', @@ -171,16 +141,9 @@ export const hookFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'hook', - ], - operation: [ - 'getAll', - 'getLogs', - ], - returnAll: [ - false, - ], + resource: ['hook'], + operation: ['getAll', 'getLogs'], + returnAll: [false], }, }, default: 1000, diff --git a/packages/nodes-base/nodes/KoBoToolbox/KoBoToolbox.node.ts b/packages/nodes-base/nodes/KoBoToolbox/KoBoToolbox.node.ts index b85d9a248e..e7dcbea461 100644 --- a/packages/nodes-base/nodes/KoBoToolbox/KoBoToolbox.node.ts +++ b/packages/nodes-base/nodes/KoBoToolbox/KoBoToolbox.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -21,20 +19,11 @@ import { parseStringList, } from './GenericFunctions'; -import { - formFields, - formOperations -} from './FormDescription'; +import { formFields, formOperations } from './FormDescription'; -import { - submissionFields, - submissionOperations, -} from './SubmissionDescription'; +import { submissionFields, submissionOperations } from './SubmissionDescription'; -import { - hookFields, - hookOperations, -} from './HookDescription'; +import { hookFields, hookOperations } from './HookDescription'; export class KoBoToolbox implements INodeType { description: INodeTypeDescription = { @@ -106,7 +95,6 @@ export class KoBoToolbox implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < items.length; i++) { - if (resource === 'form') { // ********************************************************************* // Form @@ -117,9 +105,11 @@ export class KoBoToolbox implements INodeType { // Form: get // ---------------------------------- const formId = this.getNodeParameter('formId', i) as string; - responseData = [await koBoToolboxApiRequest.call(this, { - url: `/api/v2/assets/${formId}`, - })]; + responseData = [ + await koBoToolboxApiRequest.call(this, { + url: `/api/v2/assets/${formId}`, + }), + ]; } if (operation === 'getAll') { @@ -129,10 +119,10 @@ export class KoBoToolbox implements INodeType { const formQueryOptions = this.getNodeParameter('options', i) as { sort: { value: { - descending: boolean, - ordering: string, - } - } + descending: boolean; + ordering: string; + }; + }; }; const formFilterOptions = this.getNodeParameter('filters', i) as IDataObject; @@ -141,7 +131,11 @@ export class KoBoToolbox implements INodeType { qs: { limit: this.getNodeParameter('limit', i, 1000) as number, ...(formFilterOptions.filter && { q: formFilterOptions.filter }), - ...(formQueryOptions?.sort?.value?.ordering && { ordering: (formQueryOptions?.sort?.value?.descending ? '-' : '') + formQueryOptions?.sort?.value?.ordering }), + ...(formQueryOptions?.sort?.value?.ordering && { + ordering: + (formQueryOptions?.sort?.value?.descending ? '-' : '') + + formQueryOptions?.sort?.value?.ordering, + }), }, scroll: this.getNodeParameter('returnAll', i) as boolean, }); @@ -167,21 +161,29 @@ export class KoBoToolbox implements INodeType { limit: this.getNodeParameter('limit', i, 1000) as number, ...(filterJson && { query: filterJson }), ...(submissionQueryOptions.sort && { sort: submissionQueryOptions.sort }), - ...(submissionQueryOptions.fields && { fields: JSON.stringify(parseStringList(submissionQueryOptions.fields as string)) }), + ...(submissionQueryOptions.fields && { + fields: JSON.stringify(parseStringList(submissionQueryOptions.fields as string)), + }), }, scroll: this.getNodeParameter('returnAll', i) as boolean, }); if (submissionQueryOptions.reformat) { responseData = responseData.map((submission: IDataObject) => { - return formatSubmission(submission, parseStringList(submissionQueryOptions.selectMask as string), parseStringList(submissionQueryOptions.numberMask as string)); + return formatSubmission( + submission, + parseStringList(submissionQueryOptions.selectMask as string), + parseStringList(submissionQueryOptions.numberMask as string), + ); }); } if (submissionQueryOptions.download) { // Download related attachments for (const submission of responseData) { - binaryItems.push(await downloadAttachments.call(this, submission, submissionQueryOptions)); + binaryItems.push( + await downloadAttachments.call(this, submission, submissionQueryOptions), + ); } } } @@ -193,16 +195,24 @@ export class KoBoToolbox implements INodeType { const submissionId = this.getNodeParameter('submissionId', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; - responseData = [await koBoToolboxApiRequest.call(this, { - url: `/api/v2/assets/${formId}/data/${submissionId}`, - qs: { - ...(options.fields && { fields: JSON.stringify(parseStringList(options.fields as string)) }), - }, - })]; + responseData = [ + await koBoToolboxApiRequest.call(this, { + url: `/api/v2/assets/${formId}/data/${submissionId}`, + qs: { + ...(options.fields && { + fields: JSON.stringify(parseStringList(options.fields as string)), + }), + }, + }), + ]; if (options.reformat) { responseData = responseData.map((submission: IDataObject) => { - return formatSubmission(submission, parseStringList(options.selectMask as string), parseStringList(options.numberMask as string)); + return formatSubmission( + submission, + parseStringList(options.selectMask as string), + parseStringList(options.numberMask as string), + ); }); } @@ -225,9 +235,11 @@ export class KoBoToolbox implements INodeType { url: `/api/v2/assets/${formId}/data/${id}`, }); - responseData = [{ - success: true, - }]; + responseData = [ + { + success: true, + }, + ]; } if (operation === 'getValidation') { @@ -236,9 +248,11 @@ export class KoBoToolbox implements INodeType { // ---------------------------------- const submissionId = this.getNodeParameter('submissionId', i) as string; - responseData = [await koBoToolboxApiRequest.call(this, { - url: `/api/v2/assets/${formId}/data/${submissionId}/validation_status/`, - })]; + responseData = [ + await koBoToolboxApiRequest.call(this, { + url: `/api/v2/assets/${formId}/data/${submissionId}/validation_status/`, + }), + ]; } if (operation === 'setValidation') { @@ -248,13 +262,15 @@ export class KoBoToolbox implements INodeType { const submissionId = this.getNodeParameter('submissionId', i) as string; const status = this.getNodeParameter('validationStatus', i) as string; - responseData = [await koBoToolboxApiRequest.call(this, { - method: 'PATCH', - url: `/api/v2/assets/${formId}/data/${submissionId}/validation_status/`, - body: { - 'validation_status.uid': status, - }, - })]; + responseData = [ + await koBoToolboxApiRequest.call(this, { + method: 'PATCH', + url: `/api/v2/assets/${formId}/data/${submissionId}/validation_status/`, + body: { + 'validation_status.uid': status, + }, + }), + ]; } } @@ -282,9 +298,11 @@ export class KoBoToolbox implements INodeType { // Hook: get // ---------------------------------- const hookId = this.getNodeParameter('hookId', i) as string; - responseData = [await koBoToolboxApiRequest.call(this, { - url: `/api/v2/assets/${formId}/hooks/${hookId}`, - })]; + responseData = [ + await koBoToolboxApiRequest.call(this, { + url: `/api/v2/assets/${formId}/hooks/${hookId}`, + }), + ]; } if (operation === 'retryAll') { @@ -292,10 +310,12 @@ export class KoBoToolbox implements INodeType { // Hook: retryAll // ---------------------------------- const hookId = this.getNodeParameter('hookId', i) as string; - responseData = [await koBoToolboxApiRequest.call(this, { - method: 'PATCH', - url: `/api/v2/assets/${formId}/hooks/${hookId}/retry/`, - })]; + responseData = [ + await koBoToolboxApiRequest.call(this, { + method: 'PATCH', + url: `/api/v2/assets/${formId}/hooks/${hookId}/retry/`, + }), + ]; } if (operation === 'getLogs') { @@ -320,9 +340,11 @@ export class KoBoToolbox implements INodeType { const hookId = this.getNodeParameter('hookId', i) as string; const logId = this.getNodeParameter('logId', i) as string; - responseData = [await koBoToolboxApiRequest.call(this, { - url: `/api/v2/assets/${formId}/hooks/${hookId}/logs/${logId}/retry/`, - })]; + responseData = [ + await koBoToolboxApiRequest.call(this, { + url: `/api/v2/assets/${formId}/hooks/${hookId}/logs/${logId}/retry/`, + }), + ]; } } @@ -330,8 +352,6 @@ export class KoBoToolbox implements INodeType { } // Map data to n8n data - return binaryItems.length > 0 - ? [binaryItems] - : [this.helpers.returnJsonArray(returnData)]; + return binaryItems.length > 0 ? [binaryItems] : [this.helpers.returnJsonArray(returnData)]; } } diff --git a/packages/nodes-base/nodes/KoBoToolbox/KoBoToolboxTrigger.node.ts b/packages/nodes-base/nodes/KoBoToolbox/KoBoToolboxTrigger.node.ts index 51b9dfd743..02a52fbe47 100644 --- a/packages/nodes-base/nodes/KoBoToolbox/KoBoToolboxTrigger.node.ts +++ b/packages/nodes-base/nodes/KoBoToolbox/KoBoToolboxTrigger.node.ts @@ -12,12 +12,10 @@ import { formatSubmission, koBoToolboxApiRequest, loadForms, - parseStringList + parseStringList, } from './GenericFunctions'; -import { - options, -} from './Options'; +import { options } from './Options'; export class KoBoToolboxTrigger implements INodeType { description: INodeTypeDescription = { @@ -57,7 +55,8 @@ export class KoBoToolboxTrigger implements INodeType { }, required: true, default: '', - description: 'Form ID (e.g. aSAvYreNzVEkrWg5Gdcvg). Choose from the list, or specify an ID using an expression.', + description: + 'Form ID (e.g. aSAvYreNzVEkrWg5Gdcvg). Choose from the list, or specify an ID using an expression.', }, { displayName: 'Trigger On', @@ -146,6 +145,7 @@ export class KoBoToolboxTrigger implements INodeType { const req = this.getRequestObject(); const formatOptions = this.getNodeParameter('formatOptions') as IDataObject; + // prettier-ignore const responseData = formatOptions.reformat ? formatSubmission(req.body, parseStringList(formatOptions.selectMask as string), parseStringList(formatOptions.numberMask as string)) : req.body; @@ -153,16 +153,11 @@ export class KoBoToolboxTrigger implements INodeType { if (formatOptions.download) { // Download related attachments return { - workflowData: [ - [await downloadAttachments.call(this, responseData, formatOptions)], - ], + workflowData: [[await downloadAttachments.call(this, responseData, formatOptions)]], }; - } - else { + } else { return { - workflowData: [ - this.helpers.returnJsonArray([responseData]), - ], + workflowData: [this.helpers.returnJsonArray([responseData])], }; } } diff --git a/packages/nodes-base/nodes/KoBoToolbox/Options.ts b/packages/nodes-base/nodes/KoBoToolbox/Options.ts index dedba111c3..bff6f8bc9e 100644 --- a/packages/nodes-base/nodes/KoBoToolbox/Options.ts +++ b/packages/nodes-base/nodes/KoBoToolbox/Options.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const options = { displayName: 'Options', @@ -23,9 +21,7 @@ export const options = { default: 'sequence', displayOptions: { show: { - download: [ - true, - ], + download: [true], }, }, options: [ @@ -45,16 +41,13 @@ export const options = { type: 'string', displayOptions: { show: { - download: [ - true, - ], - binaryNamingScheme: [ - 'sequence', - ], + download: [true], + binaryNamingScheme: ['sequence'], }, }, default: 'attachment_', - description: 'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"', + description: + 'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"', }, { displayName: 'File Size', @@ -62,9 +55,7 @@ export const options = { type: 'options', displayOptions: { show: { - download: [ - true, - ], + download: [true], }, }, default: 'download_url', @@ -93,21 +84,24 @@ export const options = { name: 'selectMask', type: 'string', default: 'select_*', - description: 'Comma-separated list of wildcard-style selectors for fields that should be treated as multiselect fields, i.e. parsed as arrays.', + description: + 'Comma-separated list of wildcard-style selectors for fields that should be treated as multiselect fields, i.e. parsed as arrays.', }, { displayName: 'Number Mask', name: 'numberMask', type: 'string', default: 'n_*, f_*', - description: 'Comma-separated list of wildcard-style selectors for fields that should be treated as numbers', + description: + 'Comma-separated list of wildcard-style selectors for fields that should be treated as numbers', }, { displayName: 'Reformat', name: 'reformat', type: 'boolean', default: false, - description: 'Whether to apply some reformatting to the submission data, such as parsing GeoJSON coordinates', + description: + 'Whether to apply some reformatting to the submission data, such as parsing GeoJSON coordinates', }, ], } as INodeProperties; diff --git a/packages/nodes-base/nodes/KoBoToolbox/SubmissionDescription.ts b/packages/nodes-base/nodes/KoBoToolbox/SubmissionDescription.ts index f06a7efd8d..0a6e495050 100644 --- a/packages/nodes-base/nodes/KoBoToolbox/SubmissionDescription.ts +++ b/packages/nodes-base/nodes/KoBoToolbox/SubmissionDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const submissionOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const submissionOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'submission', - ], + resource: ['submission'], }, }, options: [ @@ -52,7 +48,6 @@ export const submissionOperations: INodeProperties[] = [ ]; export const submissionFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* submission:get */ /* -------------------------------------------------------------------------- */ @@ -67,18 +62,12 @@ export const submissionFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'submission', - ], - operation: [ - 'get', - 'delete', - 'getValidation', - 'setValidation', - ], + resource: ['submission'], + operation: ['get', 'delete', 'getValidation', 'setValidation'], }, }, - description: 'Form ID (e.g. aSAvYreNzVEkrWg5Gdcvg). Choose from the list, or specify an ID using an expression.', + description: + 'Form ID (e.g. aSAvYreNzVEkrWg5Gdcvg). Choose from the list, or specify an ID using an expression.', }, { displayName: 'Submission ID', @@ -88,15 +77,8 @@ export const submissionFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'submission', - ], - operation: [ - 'get', - 'delete', - 'getValidation', - 'setValidation', - ], + resource: ['submission'], + operation: ['get', 'delete', 'getValidation', 'setValidation'], }, }, description: 'Submission ID (number, e.g. 245128)', @@ -108,12 +90,8 @@ export const submissionFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'submission', - ], - operation: [ - 'setValidation', - ], + resource: ['submission'], + operation: ['setValidation'], }, }, default: '', @@ -147,15 +125,12 @@ export const submissionFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'submission', - ], - operation: [ - 'getAll', - ], + resource: ['submission'], + operation: ['getAll'], }, }, - description: 'Form ID (e.g. aSAvYreNzVEkrWg5Gdcvg). Choose from the list, or specify an ID using an expression.', + description: + 'Form ID (e.g. aSAvYreNzVEkrWg5Gdcvg). Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -165,12 +140,8 @@ export const submissionFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'submission', - ], - operation: [ - 'getAll', - ], + resource: ['submission'], + operation: ['getAll'], }, }, description: 'Whether to return all results or only up to a given limit', @@ -184,15 +155,9 @@ export const submissionFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'submission', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['submission'], + operation: ['getAll'], + returnAll: [false], }, }, default: 100, @@ -205,12 +170,8 @@ export const submissionFields: INodeProperties[] = [ default: 'none', displayOptions: { show: { - resource: [ - 'submission', - ], - operation: [ - 'getAll', - ], + resource: ['submission'], + operation: ['getAll'], }, }, options: [ @@ -225,20 +186,15 @@ export const submissionFields: INodeProperties[] = [ ], }, { - displayName: 'See Formhub API docs to creating filters, using the MongoDB JSON format - e.g. {"_submission_time":{"$lt":"2021-10-01T01:02:03"}}', + displayName: + 'See Formhub API docs to creating filters, using the MongoDB JSON format - e.g. {"_submission_time":{"$lt":"2021-10-01T01:02:03"}}', name: 'jsonNotice', type: 'notice', displayOptions: { show: { - resource: [ - 'submission', - ], - operation: [ - 'getAll', - ], - filterType: [ - 'json', - ], + resource: ['submission'], + operation: ['getAll'], + filterType: ['json'], }, }, default: '', @@ -253,15 +209,9 @@ export const submissionFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'submission', - ], - operation: [ - 'getAll', - ], - filterType: [ - 'json', - ], + resource: ['submission'], + operation: ['getAll'], + filterType: ['json'], }, }, }, @@ -271,13 +221,8 @@ export const submissionFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - resource: [ - 'submission', - ], - operation: [ - 'get', - 'getAll', - ], + resource: ['submission'], + operation: ['get', 'getAll'], }, }, default: {}, @@ -297,9 +242,7 @@ export const submissionFields: INodeProperties[] = [ default: 'sequence', displayOptions: { show: { - download: [ - true, - ], + download: [true], }, }, options: [ @@ -319,23 +262,21 @@ export const submissionFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - download: [ - true, - ], - binaryNamingScheme: [ - 'sequence', - ], + download: [true], + binaryNamingScheme: ['sequence'], }, }, default: 'attachment_', - description: 'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"', + description: + 'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"', }, { displayName: 'Fields to Retrieve', name: 'fields', type: 'string', default: '', - description: 'Comma-separated list of fields to retrieve (e.g. _submission_time,_submitted_by). If left blank, all fields are retrieved.', + description: + 'Comma-separated list of fields to retrieve (e.g. _submission_time,_submitted_by). If left blank, all fields are retrieved.', }, { displayName: 'File Size', @@ -343,9 +284,7 @@ export const submissionFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - download: [ - true, - ], + download: [true], }, }, default: 'download_url', @@ -374,21 +313,24 @@ export const submissionFields: INodeProperties[] = [ name: 'selectMask', type: 'string', default: 'select_*', - description: 'Comma-separated list of wildcard-style selectors for fields that should be treated as multiselect fields, i.e. parsed as arrays.', + description: + 'Comma-separated list of wildcard-style selectors for fields that should be treated as multiselect fields, i.e. parsed as arrays.', }, { displayName: 'Number Mask', name: 'numberMask', type: 'string', default: 'n_*, f_*', - description: 'Comma-separated list of wildcard-style selectors for fields that should be treated as numbers', + description: + 'Comma-separated list of wildcard-style selectors for fields that should be treated as numbers', }, { displayName: 'Reformat', name: 'reformat', type: 'boolean', default: false, - description: 'Whether to apply some reformatting to the submission data, such as parsing GeoJSON coordinates', + description: + 'Whether to apply some reformatting to the submission data, such as parsing GeoJSON coordinates', }, { displayName: 'Sort', diff --git a/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts b/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts index 1168a923a0..5f1fed85df 100644 --- a/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts @@ -1,21 +1,10 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - IDataObject, - ILoadOptionsFunctions, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, ILoadOptionsFunctions, NodeApiError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - capitalCase, -} from 'change-case'; +import { capitalCase } from 'change-case'; /** * Make an authenticated API request to Lemlist. @@ -28,9 +17,8 @@ export async function lemlistApiRequest( qs: IDataObject = {}, option: IDataObject = {}, ) { - - const { apiKey } = await this.getCredentials('lemlistApi') as { - apiKey: string, + const { apiKey } = (await this.getCredentials('lemlistApi')) as { + apiKey: string; }; const encodedApiKey = Buffer.from(':' + apiKey).toString('base64'); @@ -38,7 +26,7 @@ export async function lemlistApiRequest( const options: OptionsWithUri = { headers: { 'user-agent': 'n8n', - 'Authorization': `Basic ${encodedApiKey}`, + Authorization: `Basic ${encodedApiKey}`, }, method, uri: `https://api.lemlist.com/api${endpoint}`, @@ -86,14 +74,11 @@ export async function lemlistApiRequestAllItems( responseData = await lemlistApiRequest.call(this, method, endpoint, {}, qs); returnData.push(...responseData); qs.offset += qs.limit; - } while ( - responseData.length !== 0 - ); + } while (responseData.length !== 0); return returnData; } export function getEvents() { - const events = [ '*', 'emailsBounced', @@ -108,5 +93,8 @@ export function getEvents() { 'emailsUnsubscribed', ]; - return events.map((event: string) => ({ name: (event === '*') ? '*' : capitalCase(event), value: event })); + return events.map((event: string) => ({ + name: event === '*' ? '*' : capitalCase(event), + value: event, + })); } diff --git a/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts b/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts index bce09d3da3..4b49b23865 100644 --- a/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts +++ b/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts @@ -1,13 +1,6 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - ILoadOptionsFunctions, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, ILoadOptionsFunctions, INodeType, INodeTypeDescription } from 'n8n-workflow'; import { activityFields, @@ -22,15 +15,9 @@ import { unsubscribeOperations, } from './descriptions'; -import { - lemlistApiRequest, - lemlistApiRequestAllItems, -} from './GenericFunctions'; +import { lemlistApiRequest, lemlistApiRequestAllItems } from './GenericFunctions'; -import { - isEmpty, - omit, -} from 'lodash'; +import { isEmpty, omit } from 'lodash'; export class Lemlist implements INodeType { description: INodeTypeDescription = { @@ -99,7 +86,7 @@ export class Lemlist implements INodeType { loadOptions: { async getCampaigns(this: ILoadOptionsFunctions) { const campaigns = await lemlistApiRequest.call(this, 'GET', '/campaigns'); - return campaigns.map(({ _id, name }: { _id: string, name: string }) => ({ + return campaigns.map(({ _id, name }: { _id: string; name: string }) => ({ name, value: _id, })); @@ -117,17 +104,13 @@ export class Lemlist implements INodeType { const returnData: IDataObject[] = []; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'activity') { - // ********************************************************************* // activity // ********************************************************************* if (operation === 'getAll') { - // ---------------------------------- // activity: getAll // ---------------------------------- @@ -149,17 +132,13 @@ export class Lemlist implements INodeType { const limit = this.getNodeParameter('limit', 0) as number; responseData = responseData.slice(0, limit); } - } - } else if (resource === 'campaign') { - // ********************************************************************* // campaign // ********************************************************************* if (operation === 'getAll') { - // ---------------------------------- // campaign: getAll // ---------------------------------- @@ -175,15 +154,12 @@ export class Lemlist implements INodeType { responseData = responseData.slice(0, limit); } } - } else if (resource === 'lead') { - // ********************************************************************* // lead // ********************************************************************* if (operation === 'create') { - // ---------------------------------- // lead: create // ---------------------------------- @@ -210,9 +186,7 @@ export class Lemlist implements INodeType { const endpoint = `/campaigns/${campaignId}/leads/${email}`; responseData = await lemlistApiRequest.call(this, 'POST', endpoint, body, qs); - } else if (operation === 'delete') { - // ---------------------------------- // lead: delete // ---------------------------------- @@ -222,10 +196,14 @@ export class Lemlist implements INodeType { const campaignId = this.getNodeParameter('campaignId', i); const email = this.getNodeParameter('email', i); const endpoint = `/campaigns/${campaignId}/leads/${email}`; - responseData = await lemlistApiRequest.call(this, 'DELETE', endpoint, {}, { action: 'remove' }); - + responseData = await lemlistApiRequest.call( + this, + 'DELETE', + endpoint, + {}, + { action: 'remove' }, + ); } else if (operation === 'get') { - // ---------------------------------- // lead: get // ---------------------------------- @@ -234,9 +212,7 @@ export class Lemlist implements INodeType { const email = this.getNodeParameter('email', i); responseData = await lemlistApiRequest.call(this, 'GET', `/leads/${email}`); - } else if (operation === 'unsubscribe') { - // ---------------------------------- // lead: unsubscribe // ---------------------------------- @@ -247,17 +223,13 @@ export class Lemlist implements INodeType { const email = this.getNodeParameter('email', i); const endpoint = `/campaigns/${campaignId}/leads/${email}`; responseData = await lemlistApiRequest.call(this, 'DELETE', endpoint); - } - } else if (resource === 'team') { - // ********************************************************************* // team // ********************************************************************* if (operation === 'get') { - // ---------------------------------- // team: get // ---------------------------------- @@ -265,17 +237,13 @@ export class Lemlist implements INodeType { // https://developer.lemlist.com/#team responseData = await lemlistApiRequest.call(this, 'GET', '/team'); - } - } else if (resource === 'unsubscribe') { - // ********************************************************************* // unsubscribe // ********************************************************************* if (operation === 'add') { - // ---------------------------------- // unsubscribe: Add // ---------------------------------- @@ -284,9 +252,7 @@ export class Lemlist implements INodeType { const email = this.getNodeParameter('email', i); responseData = await lemlistApiRequest.call(this, 'POST', `/unsubscribes/${email}`); - } else if (operation === 'delete') { - // ---------------------------------- // unsubscribe: delete // ---------------------------------- @@ -295,9 +261,7 @@ export class Lemlist implements INodeType { const email = this.getNodeParameter('email', i); responseData = await lemlistApiRequest.call(this, 'DELETE', `/unsubscribes/${email}`); - } else if (operation === 'getAll') { - // ---------------------------------- // unsubscribe: getAll // ---------------------------------- @@ -316,7 +280,6 @@ export class Lemlist implements INodeType { } } } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.toString() }); diff --git a/packages/nodes-base/nodes/Lemlist/LemlistTrigger.node.ts b/packages/nodes-base/nodes/Lemlist/LemlistTrigger.node.ts index 4f49f0a3fa..05c16c57f1 100644 --- a/packages/nodes-base/nodes/Lemlist/LemlistTrigger.node.ts +++ b/packages/nodes-base/nodes/Lemlist/LemlistTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -11,10 +8,7 @@ import { IWebhookResponseData, } from 'n8n-workflow'; -import { - getEvents, - lemlistApiRequest, -} from './GenericFunctions'; +import { getEvents, lemlistApiRequest } from './GenericFunctions'; export class LemlistTrigger implements INodeType { description: INodeTypeDescription = { @@ -51,9 +45,7 @@ export class LemlistTrigger implements INodeType { type: 'options', required: true, default: '', - options: [ - ...getEvents(), - ], + options: [...getEvents()], }, { displayName: 'Options', @@ -70,7 +62,8 @@ export class LemlistTrigger implements INodeType { loadOptionsMethod: 'getCampaigns', }, default: '', - description: 'We\'ll call this hook only for this campaignId. Choose from the list, or specify an ID using an expression.', + description: + 'We\'ll call this hook only for this campaignId. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Is First', @@ -88,7 +81,7 @@ export class LemlistTrigger implements INodeType { loadOptions: { async getCampaigns(this: ILoadOptionsFunctions) { const campaigns = await lemlistApiRequest.call(this, 'GET', '/campaigns'); - return campaigns.map(({ _id, name }: { _id: string, name: string }) => ({ + return campaigns.map(({ _id, name }: { _id: string; name: string }) => ({ name, value: _id, })); @@ -143,9 +136,7 @@ export class LemlistTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/Lemlist/descriptions/ActivityDescription.ts b/packages/nodes-base/nodes/Lemlist/descriptions/ActivityDescription.ts index aecd228f29..49bd696f38 100644 --- a/packages/nodes-base/nodes/Lemlist/descriptions/ActivityDescription.ts +++ b/packages/nodes-base/nodes/Lemlist/descriptions/ActivityDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const activityOperations: INodeProperties[] = [ { @@ -18,9 +16,7 @@ export const activityOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'activity', - ], + resource: ['activity'], }, }, }, @@ -38,12 +34,8 @@ export const activityFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getAll', - ], + resource: ['activity'], + operation: ['getAll'], }, }, }, @@ -59,15 +51,9 @@ export const activityFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['activity'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -79,12 +65,8 @@ export const activityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getAll', - ], + resource: ['activity'], + operation: ['getAll'], }, }, options: [ @@ -96,7 +78,8 @@ export const activityFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCampaigns', }, - description: 'ID of the campaign to retrieve activity for. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the campaign to retrieve activity for. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Type', diff --git a/packages/nodes-base/nodes/Lemlist/descriptions/CampaignDescription.ts b/packages/nodes-base/nodes/Lemlist/descriptions/CampaignDescription.ts index 2a82f06f73..306b060d0d 100644 --- a/packages/nodes-base/nodes/Lemlist/descriptions/CampaignDescription.ts +++ b/packages/nodes-base/nodes/Lemlist/descriptions/CampaignDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const campaignOperations: INodeProperties[] = [ { @@ -18,9 +16,7 @@ export const campaignOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'campaign', - ], + resource: ['campaign'], }, }, }, @@ -38,12 +34,8 @@ export const campaignFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'getAll', - ], + resource: ['campaign'], + operation: ['getAll'], }, }, }, @@ -59,15 +51,9 @@ export const campaignFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['campaign'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Lemlist/descriptions/LeadDescription.ts b/packages/nodes-base/nodes/Lemlist/descriptions/LeadDescription.ts index 50c873f534..38d89f2645 100644 --- a/packages/nodes-base/nodes/Lemlist/descriptions/LeadDescription.ts +++ b/packages/nodes-base/nodes/Lemlist/descriptions/LeadDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const leadOperations: INodeProperties[] = [ { @@ -33,9 +31,7 @@ export const leadOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'lead', - ], + resource: ['lead'], }, }, }, @@ -54,15 +50,12 @@ export const leadFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCampaigns', }, - description: 'ID of the campaign to create the lead under. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the campaign to create the lead under. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - ], + resource: ['lead'], + operation: ['create'], }, }, }, @@ -75,12 +68,8 @@ export const leadFields: INodeProperties[] = [ description: 'Email of the lead to create', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - ], + resource: ['lead'], + operation: ['create'], }, }, }, @@ -92,12 +81,8 @@ export const leadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - ], + resource: ['lead'], + operation: ['create'], }, }, options: [ @@ -113,7 +98,8 @@ export const leadFields: INodeProperties[] = [ name: 'deduplicate', type: 'boolean', default: false, - description: 'Whether to do not insert if this email is already present in another campaign', + description: + 'Whether to do not insert if this email is already present in another campaign', }, { displayName: 'First Name', @@ -172,15 +158,12 @@ export const leadFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCampaigns', }, - description: 'ID of the campaign to remove the lead from. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the campaign to remove the lead from. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'delete', - ], + resource: ['lead'], + operation: ['delete'], }, }, }, @@ -193,12 +176,8 @@ export const leadFields: INodeProperties[] = [ description: 'Email of the lead to delete', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'delete', - ], + resource: ['lead'], + operation: ['delete'], }, }, }, @@ -215,12 +194,8 @@ export const leadFields: INodeProperties[] = [ description: 'Email of the lead to retrieve', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'get', - ], + resource: ['lead'], + operation: ['get'], }, }, }, @@ -237,15 +212,12 @@ export const leadFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCampaigns', }, - description: 'ID of the campaign to unsubscribe the lead from. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the campaign to unsubscribe the lead from. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'unsubscribe', - ], + resource: ['lead'], + operation: ['unsubscribe'], }, }, }, @@ -258,12 +230,8 @@ export const leadFields: INodeProperties[] = [ description: 'Email of the lead to unsubscribe', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'unsubscribe', - ], + resource: ['lead'], + operation: ['unsubscribe'], }, }, }, diff --git a/packages/nodes-base/nodes/Lemlist/descriptions/TeamDescription.ts b/packages/nodes-base/nodes/Lemlist/descriptions/TeamDescription.ts index 9292bc1b1e..4346ea7e0c 100644 --- a/packages/nodes-base/nodes/Lemlist/descriptions/TeamDescription.ts +++ b/packages/nodes-base/nodes/Lemlist/descriptions/TeamDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const teamOperations: INodeProperties[] = [ { @@ -18,9 +16,7 @@ export const teamOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'team', - ], + resource: ['team'], }, }, }, @@ -30,5 +26,4 @@ export const teamFields: INodeProperties[] = [ // ---------------------------------- // team: get // ---------------------------------- - ]; diff --git a/packages/nodes-base/nodes/Lemlist/descriptions/UnsubscribeDescription.ts b/packages/nodes-base/nodes/Lemlist/descriptions/UnsubscribeDescription.ts index 694fece931..cf20beb72e 100644 --- a/packages/nodes-base/nodes/Lemlist/descriptions/UnsubscribeDescription.ts +++ b/packages/nodes-base/nodes/Lemlist/descriptions/UnsubscribeDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const unsubscribeOperations: INodeProperties[] = [ { @@ -28,9 +26,7 @@ export const unsubscribeOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'unsubscribe', - ], + resource: ['unsubscribe'], }, }, }, @@ -49,12 +45,8 @@ export const unsubscribeFields: INodeProperties[] = [ description: 'Email to add to the unsubscribes', displayOptions: { show: { - resource: [ - 'unsubscribe', - ], - operation: [ - 'add', - ], + resource: ['unsubscribe'], + operation: ['add'], }, }, }, @@ -71,12 +63,8 @@ export const unsubscribeFields: INodeProperties[] = [ description: 'Email to delete from the unsubscribes', displayOptions: { show: { - resource: [ - 'unsubscribe', - ], - operation: [ - 'delete', - ], + resource: ['unsubscribe'], + operation: ['delete'], }, }, }, @@ -92,12 +80,8 @@ export const unsubscribeFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'unsubscribe', - ], - operation: [ - 'getAll', - ], + resource: ['unsubscribe'], + operation: ['getAll'], }, }, }, @@ -113,15 +97,9 @@ export const unsubscribeFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'unsubscribe', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['unsubscribe'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Line/GenericFunctions.ts b/packages/nodes-base/nodes/Line/GenericFunctions.ts index c8c0c392a3..1cbfc20ca4 100644 --- a/packages/nodes-base/nodes/Line/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Line/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,12 +7,19 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; - -export async function lineApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError } from 'n8n-workflow'; +export async function lineApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { let options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -33,8 +38,9 @@ export async function lineApiRequest(this: IExecuteFunctions | IExecuteSingleFun } //@ts-ignore - return await this.helpers.requestOAuth2.call(this, 'lineNotifyOAuth2Api', options, { tokenType: 'Bearer' }); - + return await this.helpers.requestOAuth2.call(this, 'lineNotifyOAuth2Api', options, { + tokenType: 'Bearer', + }); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Line/Line.node.ts b/packages/nodes-base/nodes/Line/Line.node.ts index acf482d37f..b66cf3d408 100644 --- a/packages/nodes-base/nodes/Line/Line.node.ts +++ b/packages/nodes-base/nodes/Line/Line.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryKeyData, @@ -11,14 +9,9 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - lineApiRequest, -} from './GenericFunctions'; +import { lineApiRequest } from './GenericFunctions'; -import { - notificationFields, - notificationOperations, -} from './NotificationDescription'; +import { notificationFields, notificationOperations } from './NotificationDescription'; export class Line implements INodeType { description: INodeTypeDescription = { @@ -41,9 +34,7 @@ export class Line implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'notification', - ], + resource: ['notification'], }, }, }, @@ -76,7 +67,6 @@ export class Line implements INodeType { const resource = this.getNodeParameter('resource', 0) as string; const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < length; i++) { - try { if (resource === 'notification') { //https://notify-bot.line.me/doc/en/ @@ -92,7 +82,7 @@ export class Line implements INodeType { Object.assign(body, additionalFields); if (body.hasOwnProperty('notificationDisabled')) { - body.notificationDisabled = (body.notificationDisabled) ? 'true' : 'false'; + body.notificationDisabled = body.notificationDisabled ? 'true' : 'false'; } if (body.stickerUi) { @@ -109,15 +99,26 @@ export class Line implements INodeType { if (image && image.binaryData === true) { if (items[i].binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } //@ts-ignore if (items[i].binary[image.binaryProperty] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${image.binaryProperty}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${image.binaryProperty}" does not exists on item!`, + { itemIndex: i }, + ); } - const binaryData = (items[i].binary as IBinaryKeyData)[image.binaryProperty as string]; - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, image.binaryProperty as string); + const binaryData = (items[i].binary as IBinaryKeyData)[ + image.binaryProperty as string + ]; + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + i, + image.binaryProperty as string, + ); body.imageFile = { value: binaryDataBuffer, @@ -131,12 +132,19 @@ export class Line implements INodeType { } delete body.imageUi; } - responseData = await lineApiRequest.call(this, 'POST', '', {}, {}, 'https://notify-api.line.me/api/notify', { formData: body }); + responseData = await lineApiRequest.call( + this, + 'POST', + '', + {}, + {}, + 'https://notify-api.line.me/api/notify', + { formData: body }, + ); } } if (Array.isArray(responseData)) { returnData.push.apply(returnData, responseData as IDataObject[]); - } else if (responseData !== undefined) { returnData.push(responseData as IDataObject); } diff --git a/packages/nodes-base/nodes/Line/NotificationDescription.ts b/packages/nodes-base/nodes/Line/NotificationDescription.ts index 330006c507..af8b7fe148 100644 --- a/packages/nodes-base/nodes/Line/NotificationDescription.ts +++ b/packages/nodes-base/nodes/Line/NotificationDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const notificationOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const notificationOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'notification', - ], + resource: ['notification'], }, }, options: [ @@ -28,7 +24,6 @@ export const notificationOperations: INodeProperties[] = [ ]; export const notificationFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* notification:send */ /* -------------------------------------------------------------------------- */ @@ -39,12 +34,8 @@ export const notificationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'notification', - ], + operation: ['send'], + resource: ['notification'], }, }, default: '', @@ -57,12 +48,8 @@ export const notificationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'notification', - ], + operation: ['send'], + resource: ['notification'], }, }, options: [ @@ -93,9 +80,7 @@ export const notificationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - binaryData: [ - false, - ], + binaryData: [false], }, }, description: 'HTTP/HTTPS URL. Maximum size of 2048×2048px JPEG.', @@ -106,9 +91,7 @@ export const notificationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - binaryData: [ - false, - ], + binaryData: [false], }, }, default: '', @@ -120,9 +103,7 @@ export const notificationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - binaryData: [ - true, - ], + binaryData: [true], }, }, default: 'data', @@ -138,7 +119,8 @@ export const notificationFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: '

true: The user doesn\'t receive a push notification when the message is sent.

false: The user receives a push notification when the message is sent

', + description: + "

true: The user doesn't receive a push notification when the message is sent.

false: The user receives a push notification when the message is sent

", }, { displayName: 'Sticker', diff --git a/packages/nodes-base/nodes/Linear/GenericFunctions.ts b/packages/nodes-base/nodes/Linear/GenericFunctions.ts index a00392ba4d..d8d2b04700 100644 --- a/packages/nodes-base/nodes/Linear/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Linear/GenericFunctions.ts @@ -1,11 +1,6 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -19,11 +14,15 @@ import { import get from 'lodash.get'; -import { - query, -} from './Queries'; +import { query } from './Queries'; -export async function linearApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, body: any = {}, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function linearApiRequest( + this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, + // tslint:disable-next-line:no-any + body: any = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('linearApi'); const endpoint = 'https://api.linear.app/graphql'; @@ -41,7 +40,6 @@ export async function linearApiRequest(this: IExecuteFunctions | IWebhookFunctio options = Object.assign({}, options, option); try { return await this.helpers.request!(options); - } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); } @@ -51,8 +49,13 @@ export function capitalizeFirstLetter(data: string) { return data.charAt(0).toUpperCase() + data.slice(1); } -export async function linearApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, body: any = {}): Promise { // tslint:disable-line:no-any - +export async function linearApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + // tslint:disable-next-line:no-any + body: any = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -63,13 +66,15 @@ export async function linearApiRequestAllItems(this: IHookFunctions | IExecuteFu responseData = await linearApiRequest.call(this, body); returnData.push.apply(returnData, get(responseData, `${propertyName}.nodes`)); body.variables.after = get(responseData, `${propertyName}.pageInfo.endCursor`); - } while ( - get(responseData, `${propertyName}.pageInfo.hasNextPage`) - ); + } while (get(responseData, `${propertyName}.pageInfo.hasNextPage`)); return returnData; } -export async function validateCredentials(this: ICredentialTestFunctions, decryptedCredentials: ICredentialDataDecryptedObject): Promise { // tslint:disable-line:no-any +export async function validateCredentials( + this: ICredentialTestFunctions, + decryptedCredentials: ICredentialDataDecryptedObject, + // tslint:disable-next-line:no-any +): Promise { const credentials = decryptedCredentials; const options: OptionsWithUri = { @@ -93,7 +98,11 @@ export async function validateCredentials(this: ICredentialTestFunctions, decryp //@ts-ignore export const sort = (a, b) => { - if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { return -1; } - if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { return 1; } + if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { + return -1; + } + if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { + return 1; + } return 0; }; diff --git a/packages/nodes-base/nodes/Linear/IssueDescription.ts b/packages/nodes-base/nodes/Linear/IssueDescription.ts index 9c1fa4d3eb..16ad27b982 100644 --- a/packages/nodes-base/nodes/Linear/IssueDescription.ts +++ b/packages/nodes-base/nodes/Linear/IssueDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const issueOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const issueOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'issue', - ], + resource: ['issue'], }, }, options: [ @@ -52,7 +48,6 @@ export const issueOperations: INodeProperties[] = [ ]; export const issueFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* issue:create */ /* -------------------------------------------------------------------------- */ @@ -60,16 +55,13 @@ export const issueFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'teamId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'create', - ], + resource: ['issue'], + operation: ['create'], }, }, typeOptions: { @@ -84,12 +76,8 @@ export const issueFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'create', - ], + resource: ['issue'], + operation: ['create'], }, }, default: '', @@ -102,12 +90,8 @@ export const issueFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'create', - ], + resource: ['issue'], + operation: ['create'], }, }, options: [ @@ -115,7 +99,8 @@ export const issueFields: INodeProperties[] = [ displayName: 'Assignee Name or ID', name: 'assigneeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getUsers', }, @@ -163,7 +148,8 @@ export const issueFields: INodeProperties[] = [ displayName: 'State Name or ID', name: 'stateId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getStates', }, @@ -181,13 +167,8 @@ export const issueFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'get', - 'delete', - ], + resource: ['issue'], + operation: ['get', 'delete'], }, }, default: '', @@ -202,12 +183,8 @@ export const issueFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'getAll', - ], + resource: ['issue'], + operation: ['getAll'], }, }, description: 'Whether to return all results or only up to a given limit', @@ -223,15 +200,9 @@ export const issueFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['issue'], + operation: ['getAll'], + returnAll: [false], }, }, description: 'Max number of results to return', @@ -246,12 +217,8 @@ export const issueFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'update', - ], + resource: ['issue'], + operation: ['update'], }, }, default: '', @@ -264,12 +231,8 @@ export const issueFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'update', - ], + resource: ['issue'], + operation: ['update'], }, }, options: [ @@ -277,7 +240,8 @@ export const issueFields: INodeProperties[] = [ displayName: 'Assignee Name or ID', name: 'assigneeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getUsers', }, @@ -325,7 +289,8 @@ export const issueFields: INodeProperties[] = [ displayName: 'State Name or ID', name: 'stateId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getStates', }, @@ -335,7 +300,8 @@ export const issueFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'teamId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTeams', }, diff --git a/packages/nodes-base/nodes/Linear/Linear.node.ts b/packages/nodes-base/nodes/Linear/Linear.node.ts index d6833abbcc..7052ffe041 100644 --- a/packages/nodes-base/nodes/Linear/Linear.node.ts +++ b/packages/nodes-base/nodes/Linear/Linear.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -23,14 +21,9 @@ import { validateCredentials, } from './GenericFunctions'; -import { - issueFields, - issueOperations, -} from './IssueDescription'; +import { issueFields, issueOperations } from './IssueDescription'; -import { - query, -} from './Queries'; +import { query } from './Queries'; interface IGraphqlBody { query: string; variables: IDataObject; @@ -77,13 +70,18 @@ export class Linear implements INodeType { methods = { credentialTest: { - async linearApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { + async linearApiTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { try { await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject); } catch (error) { const { error: err } = error as JsonObject; const errors = (err as IDataObject).errors as [{ extensions: { code: string } }]; - const authenticationError = Boolean(errors.filter(e => e.extensions.code === 'AUTHENTICATION_ERROR').length); + const authenticationError = Boolean( + errors.filter((e) => e.extensions.code === 'AUTHENTICATION_ERROR').length, + ); if (authenticationError) { return { status: 'Error', diff --git a/packages/nodes-base/nodes/Linear/LinearTrigger.node.ts b/packages/nodes-base/nodes/Linear/LinearTrigger.node.ts index a806bb07a6..ac570e456f 100644 --- a/packages/nodes-base/nodes/Linear/LinearTrigger.node.ts +++ b/packages/nodes-base/nodes/Linear/LinearTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { ILoadOptionsFunctions, @@ -11,10 +8,7 @@ import { IWebhookResponseData, } from 'n8n-workflow'; -import { - capitalizeFirstLetter, - linearApiRequest, -} from './GenericFunctions'; +import { capitalizeFirstLetter, linearApiRequest } from './GenericFunctions'; export class LinearTrigger implements INodeType { description: INodeTypeDescription = { @@ -51,7 +45,8 @@ export class LinearTrigger implements INodeType { displayName: 'Team Name or ID', name: 'teamId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTeams', }, @@ -91,7 +86,6 @@ export class LinearTrigger implements INodeType { name: 'Project', value: 'project', }, - ], default: [], required: true, @@ -104,8 +98,7 @@ export class LinearTrigger implements INodeType { async getTeams(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const body = { - query: - `query Teams { + query: `query Teams { teams { nodes { id @@ -114,7 +107,11 @@ export class LinearTrigger implements INodeType { } }`, }; - const { data: { teams: { nodes } } } = await linearApiRequest.call(this, body); + const { + data: { + teams: { nodes }, + }, + } = await linearApiRequest.call(this, body); for (const node of nodes) { returnData.push({ @@ -135,8 +132,7 @@ export class LinearTrigger implements INodeType { const webhookData = this.getWorkflowStaticData('node'); const teamId = this.getNodeParameter('teamId') as string; const body = { - query: - `query { + query: `query { webhooks { nodes { id @@ -152,12 +148,14 @@ export class LinearTrigger implements INodeType { }; // Check all the webhooks which exist already if it is identical to the // one that is supposed to get created. - const { data: { webhooks: { nodes } } } = await linearApiRequest.call(this, body); + const { + data: { + webhooks: { nodes }, + }, + } = await linearApiRequest.call(this, body); for (const node of nodes) { - if (node.url === webhookUrl && - node.team.id === teamId && - node.enabled === true) { + if (node.url === webhookUrl && node.team.id === teamId && node.enabled === true) { webhookData.webhookId = node.id as string; return true; } @@ -193,7 +191,14 @@ export class LinearTrigger implements INodeType { }, }; - const { data: { webhookCreate: { success, webhook: { id } } } } = await linearApiRequest.call(this, body); + const { + data: { + webhookCreate: { + success, + webhook: { id }, + }, + }, + } = await linearApiRequest.call(this, body); if (!success) { return false; @@ -236,9 +241,7 @@ export class LinearTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const bodyData = this.getBodyData(); return { - workflowData: [ - this.helpers.returnJsonArray(bodyData), - ], + workflowData: [this.helpers.returnJsonArray(bodyData)], }; } } diff --git a/packages/nodes-base/nodes/LingvaNex/ActivityDescription.ts b/packages/nodes-base/nodes/LingvaNex/ActivityDescription.ts index 043843ebba..48b4b73b80 100644 --- a/packages/nodes-base/nodes/LingvaNex/ActivityDescription.ts +++ b/packages/nodes-base/nodes/LingvaNex/ActivityDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const activityOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const activityOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'activity', - ], + resource: ['activity'], }, }, options: [ @@ -34,7 +30,6 @@ export const activityOperations: INodeProperties[] = [ ]; export const activityFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* activity:create */ /* -------------------------------------------------------------------------- */ @@ -42,7 +37,8 @@ export const activityFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -50,12 +46,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, }, @@ -67,12 +59,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, }, @@ -84,12 +72,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, }, @@ -100,12 +84,8 @@ export const activityFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, default: {}, @@ -118,7 +98,8 @@ export const activityFields: INodeProperties[] = [ loadOptionsMethod: 'getActivityTypes', }, default: '', - description: 'A user-defined way to group activities of the same nature. Choose from the list, or specify an ID using an expression.', + description: + 'A user-defined way to group activities of the same nature. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Description', @@ -165,7 +146,8 @@ export const activityFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -173,12 +155,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getAll', - ], + resource: ['activity'], + operation: ['getAll'], }, }, }, @@ -188,12 +166,8 @@ export const activityFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'activity', - ], + operation: ['getAll'], + resource: ['activity'], }, }, default: false, @@ -205,15 +179,9 @@ export const activityFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'activity', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['activity'], + returnAll: [false], }, }, typeOptions: { @@ -231,12 +199,8 @@ export const activityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getAll', - ], + resource: ['activity'], + operation: ['getAll'], }, }, options: [ diff --git a/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts b/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts index f08c43bf69..b9f0c03229 100644 --- a/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts +++ b/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,11 +7,19 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function lingvaNexApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function lingvaNexApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { try { const credentials = await this.getCredentials('lingvaNexApi'); let options: OptionsWithUri = { @@ -36,7 +42,6 @@ export async function lingvaNexApiRequest(this: IHookFunctions | IExecuteFunctio } return response; - } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/LingvaNex/LingvaNex.node.ts b/packages/nodes-base/nodes/LingvaNex/LingvaNex.node.ts index 25d5130db5..1a544b462b 100644 --- a/packages/nodes-base/nodes/LingvaNex/LingvaNex.node.ts +++ b/packages/nodes-base/nodes/LingvaNex/LingvaNex.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,9 +9,7 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - lingvaNexApiRequest, -} from './GenericFunctions'; +import { lingvaNexApiRequest } from './GenericFunctions'; export class LingvaNex implements INodeType { description: INodeTypeDescription = { @@ -64,9 +60,7 @@ export class LingvaNex implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'translate', - ], + operation: ['translate'], }, }, }, @@ -79,13 +73,12 @@ export class LingvaNex implements INodeType { loadOptionsMethod: 'getLanguages', }, default: '', - description: 'The language to use for translation of the input text, set to one of the language codes listed in Language Support. Choose from the list, or specify an ID using an expression.', + description: + 'The language to use for translation of the input text, set to one of the language codes listed in Language Support. Choose from the list, or specify an ID using an expression.', required: true, displayOptions: { show: { - operation: [ - 'translate', - ], + operation: ['translate'], }, }, }, @@ -97,9 +90,7 @@ export class LingvaNex implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'translate', - ], + operation: ['translate'], }, }, options: [ @@ -112,7 +103,8 @@ export class LingvaNex implements INodeType { loadOptionsMethod: 'getLanguages', }, default: '', - description: 'The language code in the format “language code_code of the country”. If this parameter is not present, the auto-detect language mode is enabled. Choose from the list, or specify an ID using an expression.', + description: + 'The language code in the format “language code_code of the country”. If this parameter is not present, the auto-detect language mode is enabled. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Platform', @@ -125,7 +117,8 @@ export class LingvaNex implements INodeType { name: 'translateMode', type: 'string', default: '', - description: 'Describe the input text format. Possible value is "html" for translating and preserving html structure. If value is not specified or is other than "html" than plain text is translating.', + description: + 'Describe the input text format. Possible value is "html" for translating and preserving html structure. If value is not specified or is other than "html" than plain text is translating.', }, ], }, @@ -134,16 +127,14 @@ export class LingvaNex implements INodeType { methods = { loadOptions: { - async getLanguages( - this: ILoadOptionsFunctions, - ): Promise { + async getLanguages(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const data = await lingvaNexApiRequest.call( this, 'GET', '/getLanguages', {}, - {'platform': 'api'}, + { platform: 'api' }, ); for (const language of data.result) { returnData.push({ diff --git a/packages/nodes-base/nodes/LinkedIn/GenericFunctions.ts b/packages/nodes-base/nodes/LinkedIn/GenericFunctions.ts index 49879afaf2..64d43fd23b 100644 --- a/packages/nodes-base/nodes/LinkedIn/GenericFunctions.ts +++ b/packages/nodes-base/nodes/LinkedIn/GenericFunctions.ts @@ -1,18 +1,21 @@ -import { - OptionsWithUrl, -} from 'request'; +import { OptionsWithUrl } from 'request'; -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { NodeApiError } from 'n8n-workflow'; -export async function linkedInApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, binary?: boolean, headers?: object): Promise { // tslint:disable-line:no-any +export async function linkedInApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + binary?: boolean, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUrl = { headers: { - 'Accept': 'application/json', + Accept: 'application/json', 'X-Restli-Protocol-Version': '2.0.0', }, method, @@ -32,14 +35,16 @@ export async function linkedInApiRequest(this: IHookFunctions | IExecuteFunction } try { - return await this.helpers.requestOAuth2!.call(this, 'linkedInOAuth2Api', options, { tokenType: 'Bearer' }); + return await this.helpers.requestOAuth2!.call(this, 'linkedInOAuth2Api', options, { + tokenType: 'Bearer', + }); } catch (error) { throw new NodeApiError(this.getNode(), error); } } - -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); diff --git a/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts b/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts index 2672c9c4c9..8a10edc4e4 100644 --- a/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts +++ b/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts @@ -9,10 +9,7 @@ import { NodeOperationError, } from 'n8n-workflow'; import { linkedInApiRequest } from './GenericFunctions'; -import { - postFields, - postOperations, -} from './PostDescription'; +import { postFields, postOperations } from './PostDescription'; export class LinkedIn implements INodeType { // eslint-disable-next-line n8n-nodes-base/node-class-description-missing-subtitle @@ -53,8 +50,6 @@ export class LinkedIn implements INodeType { ...postOperations, ...postFields, ], - - }; methods = { @@ -64,7 +59,10 @@ export class LinkedIn implements INodeType { async getPersonUrn(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const person = await linkedInApiRequest.call(this, 'GET', '/me', {}); - returnData.push({ name: `${person.localizedFirstName} ${person.localizedLastName}`, value: person.id }); + returnData.push({ + name: `${person.localizedFirstName} ${person.localizedLastName}`, + value: person.id, + }); return returnData; }, }, @@ -77,7 +75,7 @@ export class LinkedIn implements INodeType { const resource = this.getNodeParameter('resource', 0) as string; const operation = this.getNodeParameter('operation', 0) as string; - let body:any = {};// tslint:disable-line:no-any + let body: any = {}; // tslint:disable-line:no-any for (let i = 0; i < items.length; i++) { try { @@ -94,7 +92,7 @@ export class LinkedIn implements INodeType { if (postAs === 'person') { const personUrn = this.getNodeParameter('person', i) as string; // Only if posting as a person can user decide if post visible by public or connections - visibility = additionalFields.visibility as string || 'PUBLIC'; + visibility = (additionalFields.visibility as string) || 'PUBLIC'; authorUrn = `urn:li:person:${personUrn}`; } else { const organizationUrn = this.getNodeParameter('organization', i) as string; @@ -106,7 +104,6 @@ export class LinkedIn implements INodeType { let originalUrl = ''; if (shareMediaCategory === 'IMAGE') { - if (additionalFields.description) { description = additionalFields.description as string; } @@ -116,9 +113,7 @@ export class LinkedIn implements INodeType { // Send a REQUEST to prepare a register of a media image file const registerRequest = { registerUploadRequest: { - recipes: [ - 'urn:li:digitalmediaRecipe:feedshare-image', - ], + recipes: ['urn:li:digitalmediaRecipe:feedshare-image'], owner: authorUrn, serviceRelationships: [ { @@ -129,23 +124,36 @@ export class LinkedIn implements INodeType { }, }; - const registerObject = await linkedInApiRequest.call(this, 'POST', '/assets?action=registerUpload', registerRequest); + const registerObject = await linkedInApiRequest.call( + this, + 'POST', + '/assets?action=registerUpload', + registerRequest, + ); // Response provides a specific upload URL that is used to upload the binary image file - const uploadUrl = registerObject.value.uploadMechanism['com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest'].uploadUrl as string; + const uploadUrl = registerObject.value.uploadMechanism[ + 'com.linkedin.digitalmedia.uploading.MediaUploadHttpRequest' + ].uploadUrl as string; const asset = registerObject.value.asset as string; // Prepare binary file upload const item = items[i]; if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string; if (item.binary[propertyNameUpload] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${propertyNameUpload}" does not exists on item!`, + { itemIndex: i }, + ); } // Buffer binary data @@ -180,7 +188,6 @@ export class LinkedIn implements INodeType { 'com.linkedin.ugc.MemberNetworkVisibility': visibility, }, }; - } else if (shareMediaCategory === 'ARTICLE') { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; @@ -229,7 +236,6 @@ export class LinkedIn implements INodeType { if (title === '') { delete body.specificContent['com.linkedin.ugc.ShareContent'].media[0].title; } - } else { body = { author: authorUrn, diff --git a/packages/nodes-base/nodes/LinkedIn/PostDescription.ts b/packages/nodes-base/nodes/LinkedIn/PostDescription.ts index 7edd96e58d..b03fa7f5f3 100644 --- a/packages/nodes-base/nodes/LinkedIn/PostDescription.ts +++ b/packages/nodes-base/nodes/LinkedIn/PostDescription.ts @@ -8,9 +8,7 @@ export const postOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'post', - ], + resource: ['post'], }, }, options: [ @@ -26,9 +24,9 @@ export const postOperations: INodeProperties[] = [ ]; export const postFields: INodeProperties[] = [ -/* -------------------------------------------------------------------------- */ -/* post:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* post:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Post As', name: 'postAs', @@ -55,18 +53,13 @@ export const postFields: INodeProperties[] = [ }, default: '', required: true, - description: 'Person as which the post should be posted as. Choose from the list, or specify an ID using an expression.', + description: + 'Person as which the post should be posted as. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - operation: [ - 'create', - ], - postAs: [ - 'person', - ], - resource: [ - 'post', - ], + operation: ['create'], + postAs: ['person'], + resource: ['post'], }, }, }, @@ -79,15 +72,9 @@ export const postFields: INodeProperties[] = [ description: 'URN of Organization as which the post should be posted as', displayOptions: { show: { - operation: [ - 'create', - ], - postAs: [ - 'organization', - ], - resource: [ - 'post', - ], + operation: ['create'], + postAs: ['organization'], + resource: ['post'], }, }, }, @@ -99,12 +86,8 @@ export const postFields: INodeProperties[] = [ description: 'The primary content of the post', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'post', - ], + operation: ['create'], + resource: ['post'], }, }, }, @@ -132,12 +115,8 @@ export const postFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'post', - ], + operation: ['create'], + resource: ['post'], }, }, }, @@ -145,15 +124,9 @@ export const postFields: INodeProperties[] = [ displayName: 'Binary Property', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'post', - ], - shareMediaCategory: [ - 'IMAGE', - ], + operation: ['create'], + resource: ['post'], + shareMediaCategory: ['IMAGE'], }, }, name: 'binaryPropertyName', @@ -170,12 +143,8 @@ export const postFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'post', - ], + operation: ['create'], + resource: ['post'], }, }, options: [ @@ -187,10 +156,7 @@ export const postFields: INodeProperties[] = [ description: 'Provide a short description for your image or article', displayOptions: { show: { - '/shareMediaCategory': [ - 'ARTICLE', - 'IMAGE', - ], + '/shareMediaCategory': ['ARTICLE', 'IMAGE'], }, }, }, @@ -202,9 +168,7 @@ export const postFields: INodeProperties[] = [ description: 'Provide the URL of the article you would like to share here', displayOptions: { show: { - '/shareMediaCategory': [ - 'ARTICLE', - ], + '/shareMediaCategory': ['ARTICLE'], }, }, }, @@ -216,10 +180,7 @@ export const postFields: INodeProperties[] = [ description: 'Customize the title of your image or article', displayOptions: { show: { - '/shareMediaCategory': [ - 'ARTICLE', - 'IMAGE', - ], + '/shareMediaCategory': ['ARTICLE', 'IMAGE'], }, }, }, @@ -231,9 +192,7 @@ export const postFields: INodeProperties[] = [ description: 'Dictate if post will be seen by the public or only connections', displayOptions: { show: { - '/postAs': [ - 'person', - ], + '/postAs': ['person'], }, }, options: [ diff --git a/packages/nodes-base/nodes/LocalFileTrigger/LocalFileTrigger.node.ts b/packages/nodes-base/nodes/LocalFileTrigger/LocalFileTrigger.node.ts index b5b4c54157..2288bc01e0 100644 --- a/packages/nodes-base/nodes/LocalFileTrigger/LocalFileTrigger.node.ts +++ b/packages/nodes-base/nodes/LocalFileTrigger/LocalFileTrigger.node.ts @@ -1,14 +1,8 @@ import { ITriggerFunctions } from 'n8n-core'; -import { - IDataObject, - INodeType, - INodeTypeDescription, - ITriggerResponse, -} from 'n8n-workflow'; +import { IDataObject, INodeType, INodeTypeDescription, ITriggerResponse } from 'n8n-workflow'; import { watch } from 'chokidar'; - export class LocalFileTrigger implements INodeType { description: INodeTypeDescription = { displayName: 'Local File Trigger', @@ -49,9 +43,7 @@ export class LocalFileTrigger implements INodeType { type: 'string', displayOptions: { show: { - triggerOn: [ - 'file', - ], + triggerOn: ['file'], }, }, default: '', @@ -63,9 +55,7 @@ export class LocalFileTrigger implements INodeType { type: 'string', displayOptions: { show: { - triggerOn: [ - 'folder', - ], + triggerOn: ['folder'], }, }, default: '', @@ -77,9 +67,7 @@ export class LocalFileTrigger implements INodeType { type: 'multiOptions', displayOptions: { show: { - triggerOn: [ - 'folder', - ], + triggerOn: ['folder'], }, }, options: [ @@ -126,7 +114,8 @@ export class LocalFileTrigger implements INodeType { name: 'followSymlinks', type: 'boolean', default: true, - description: 'Whether linked files/folders will also be watched (this includes symlinks, aliases on MacOS and shortcuts on Windows). Otherwise only the links themselves will be monitored).', + description: + 'Whether linked files/folders will also be watched (this includes symlinks, aliases on MacOS and shortcuts on Windows). Otherwise only the links themselves will be monitored).', }, { displayName: 'Ignore', @@ -134,7 +123,8 @@ export class LocalFileTrigger implements INodeType { type: 'string', default: '', placeholder: '**/*.txt', - description: 'Files or paths to ignore. The whole path is tested, not just the filename. Supports Anymatch- syntax.', + description: + 'Files or paths to ignore. The whole path is tested, not just the filename. Supports Anymatch- syntax.', }, // eslint-disable-next-line n8n-nodes-base/node-param-default-missing { @@ -176,11 +166,9 @@ export class LocalFileTrigger implements INodeType { }, ], }, - ], }; - async trigger(this: ITriggerFunctions): Promise { const triggerOn = this.getNodeParameter('triggerOn') as string; const path = this.getNodeParameter('path') as string; @@ -188,7 +176,7 @@ export class LocalFileTrigger implements INodeType { let events: string[]; if (triggerOn === 'file') { - events = [ 'change' ]; + events = ['change']; } else { events = this.getNodeParameter('events', []) as string[]; } @@ -197,16 +185,19 @@ export class LocalFileTrigger implements INodeType { ignored: options.ignored, persistent: true, ignoreInitial: true, - followSymlinks: options.followSymlinks === undefined ? true : options.followSymlinks as boolean, - depth: [-1, undefined].includes(options.depth as number) ? undefined : options.depth as number, + followSymlinks: + options.followSymlinks === undefined ? true : (options.followSymlinks as boolean), + depth: [-1, undefined].includes(options.depth as number) + ? undefined + : (options.depth as number), }); const executeTrigger = (event: string, path: string) => { - this.emit([this.helpers.returnJsonArray([{ event,path }])]); + this.emit([this.helpers.returnJsonArray([{ event, path }])]); }; for (const eventName of events) { - watcher.on(eventName, path => executeTrigger(eventName, path)); + watcher.on(eventName, (path) => executeTrigger(eventName, path)); } function closeFunction() { @@ -216,6 +207,5 @@ export class LocalFileTrigger implements INodeType { return { closeFunction, }; - } } diff --git a/packages/nodes-base/nodes/MQTT/Mqtt.node.ts b/packages/nodes-base/nodes/MQTT/Mqtt.node.ts index 1156b7f461..98959481d8 100644 --- a/packages/nodes-base/nodes/MQTT/Mqtt.node.ts +++ b/packages/nodes-base/nodes/MQTT/Mqtt.node.ts @@ -1,19 +1,10 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; import mqtt from 'mqtt'; -import { - IClientOptions, -} from 'mqtt'; +import { IClientOptions } from 'mqtt'; export class Mqtt implements INodeType { description: INodeTypeDescription = { @@ -57,9 +48,7 @@ export class Mqtt implements INodeType { required: true, displayOptions: { show: { - sendInputData: [ - false, - ], + sendInputData: [false], }, }, default: '', @@ -99,7 +88,8 @@ export class Mqtt implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Normally if a publisher publishes a message to a topic, and no one is subscribed to that topic the message is simply discarded by the broker. However the publisher can tell the broker to keep the last message on that topic by setting the retain flag to true.', + description: + 'Normally if a publisher publishes a message to a topic, and no one is subscribed to that topic the message is simply discarded by the broker. However the publisher can tell the broker to keep the last message on that topic by setting the retain flag to true.', }, ], }, @@ -111,11 +101,12 @@ export class Mqtt implements INodeType { const length = items.length; const credentials = await this.getCredentials('mqtt'); - const protocol = credentials.protocol as string || 'mqtt'; + const protocol = (credentials.protocol as string) || 'mqtt'; const host = credentials.host as string; const brokerUrl = `${protocol}://${host}`; - const port = credentials.port as number || 1883; - const clientId = credentials.clientId as string || `mqttjs_${Math.random().toString(16).substr(2, 8)}`; + const port = (credentials.port as number) || 1883; + const clientId = + (credentials.clientId as string) || `mqttjs_${Math.random().toString(16).substr(2, 8)}`; const clean = credentials.clean as boolean; const ssl = credentials.ssl as boolean; const ca = credentials.ca as string; @@ -133,13 +124,12 @@ export class Mqtt implements INodeType { }; if (credentials.username && credentials.password) { - clientOptions.username = credentials.username as string; - clientOptions.password = credentials.password as string; + clientOptions.username = credentials.username as string; + clientOptions.password = credentials.password as string; } - client = mqtt.connect(brokerUrl, clientOptions); - } - else { + client = mqtt.connect(brokerUrl, clientOptions); + } else { const clientOptions: IClientOptions = { port, clean, @@ -154,7 +144,7 @@ export class Mqtt implements INodeType { clientOptions.password = credentials.password as string; } - client = mqtt.connect(brokerUrl, clientOptions); + client = mqtt.connect(brokerUrl, clientOptions); } const sendInputData = this.getNodeParameter('sendInputData', 0) as boolean; @@ -163,10 +153,9 @@ export class Mqtt implements INodeType { const data = await new Promise((resolve, reject): any => { client.on('connect', () => { for (let i = 0; i < length; i++) { - let message; - const topic = (this.getNodeParameter('topic', i) as string); - const options = (this.getNodeParameter('options', i) as IDataObject); + const topic = this.getNodeParameter('topic', i) as string; + const options = this.getNodeParameter('options', i) as IDataObject; try { if (sendInputData === true) { diff --git a/packages/nodes-base/nodes/MQTT/MqttTrigger.node.ts b/packages/nodes-base/nodes/MQTT/MqttTrigger.node.ts index 6296d86ade..ec4561f148 100644 --- a/packages/nodes-base/nodes/MQTT/MqttTrigger.node.ts +++ b/packages/nodes-base/nodes/MQTT/MqttTrigger.node.ts @@ -1,6 +1,4 @@ -import { - ITriggerFunctions, -} from 'n8n-core'; +import { ITriggerFunctions } from 'n8n-core'; import { IDataObject, @@ -12,9 +10,7 @@ import { import mqtt from 'mqtt'; -import { - IClientOptions, ISubscriptionMap, -} from 'mqtt'; +import { IClientOptions, ISubscriptionMap } from 'mqtt'; export class MqttTrigger implements INodeType { description: INodeTypeDescription = { @@ -41,7 +37,8 @@ export class MqttTrigger implements INodeType { name: 'topics', type: 'string', default: '', - description: 'Topics to subscribe to, multiple can be defined with comma. Wildcard characters are supported (+ - for single level and # - for multi level). By default all subscription used QoS=0. To set a different QoS, write the QoS desired after the topic preceded by a colom. For Example: topicA:1,topicB:2', + description: + 'Topics to subscribe to, multiple can be defined with comma. Wildcard characters are supported (+ - for single level and # - for multi level). By default all subscription used QoS=0. To set a different QoS, write the QoS desired after the topic preceded by a colom. For Example: topicA:1,topicB:2', }, { displayName: 'Options', @@ -70,7 +67,6 @@ export class MqttTrigger implements INodeType { }; async trigger(this: ITriggerFunctions): Promise { - const credentials = await this.getCredentials('mqtt'); const topics = (this.getNodeParameter('topics') as string).split(','); @@ -79,7 +75,7 @@ export class MqttTrigger implements INodeType { for (const data of topics) { const [topic, qos] = data.split(':'); - topicsQoS[topic] = (qos) ? { qos: parseInt(qos, 10) } : { qos: 0 }; + topicsQoS[topic] = qos ? { qos: parseInt(qos, 10) } : { qos: 0 }; } const options = this.getNodeParameter('options') as IDataObject; @@ -88,11 +84,12 @@ export class MqttTrigger implements INodeType { throw new NodeOperationError(this.getNode(), 'Topics are mandatory!'); } - const protocol = credentials.protocol as string || 'mqtt'; + const protocol = (credentials.protocol as string) || 'mqtt'; const host = credentials.host as string; const brokerUrl = `${protocol}://${host}`; - const port = credentials.port as number || 1883; - const clientId = credentials.clientId as string || `mqttjs_${Math.random().toString(16).substr(2, 8)}`; + const port = (credentials.port as number) || 1883; + const clientId = + (credentials.clientId as string) || `mqttjs_${Math.random().toString(16).substr(2, 8)}`; const clean = credentials.clean as boolean; const ssl = credentials.ssl as boolean; const ca = credentials.ca as string; @@ -110,13 +107,12 @@ export class MqttTrigger implements INodeType { }; if (credentials.username && credentials.password) { - clientOptions.username = credentials.username as string; - clientOptions.password = credentials.password as string; + clientOptions.username = credentials.username as string; + clientOptions.password = credentials.password as string; } - client = mqtt.connect(brokerUrl, clientOptions); - } - else { + client = mqtt.connect(brokerUrl, clientOptions); + } else { const clientOptions: IClientOptions = { port, clean, @@ -131,7 +127,7 @@ export class MqttTrigger implements INodeType { clientOptions.password = credentials.password as string; } - client = mqtt.connect(brokerUrl, clientOptions); + client = mqtt.connect(brokerUrl, clientOptions); } const self = this; @@ -143,7 +139,8 @@ export class MqttTrigger implements INodeType { if (err) { reject(err); } - client.on('message', (topic: string, message: Buffer | string) => { // tslint:disable-line:no-any + client.on('message', (topic: string, message: Buffer | string) => { + // tslint:disable-line:no-any let result: IDataObject = {}; message = message.toString() as string; @@ -151,7 +148,7 @@ export class MqttTrigger implements INodeType { if (options.jsonParseBody) { try { message = JSON.parse(message.toString()); - } catch (err) { } + } catch (err) {} } result.message = message; diff --git a/packages/nodes-base/nodes/Magento/CustomerDescription.ts b/packages/nodes-base/nodes/Magento/CustomerDescription.ts index 6e130b304b..b691dd1c18 100644 --- a/packages/nodes-base/nodes/Magento/CustomerDescription.ts +++ b/packages/nodes-base/nodes/Magento/CustomerDescription.ts @@ -1,11 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - getCustomerOptionalFields, - getSearchFilters, -} from './GenericFunctions'; +import { getCustomerOptionalFields, getSearchFilters } from './GenericFunctions'; export const customerOperations: INodeProperties[] = [ { @@ -15,9 +10,7 @@ export const customerOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'customer', - ], + resource: ['customer'], }, }, options: [ @@ -57,7 +50,6 @@ export const customerOperations: INodeProperties[] = [ ]; export const customerFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* customer:create */ /* -------------------------------------------------------------------------- */ @@ -70,12 +62,8 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'create', - ], + resource: ['customer'], + operation: ['create'], }, }, description: 'Email address of the user to create', @@ -88,12 +76,8 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'create', - ], + resource: ['customer'], + operation: ['create'], }, }, description: 'First name of the user to create', @@ -106,12 +90,8 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'create', - ], + resource: ['customer'], + operation: ['create'], }, }, description: 'Last name of the user to create', @@ -124,17 +104,11 @@ export const customerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'create', - ], + resource: ['customer'], + operation: ['create'], }, }, - options: [ - ...getCustomerOptionalFields(), - ], + options: [...getCustomerOptionalFields()], }, /* -------------------------------------------------------------------------- */ @@ -147,12 +121,8 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'update', - ], + resource: ['customer'], + operation: ['update'], }, }, description: 'ID of the customer to update', @@ -165,12 +135,8 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'update', - ], + resource: ['customer'], + operation: ['update'], }, }, }, @@ -181,12 +147,8 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'update', - ], + resource: ['customer'], + operation: ['update'], }, }, }, @@ -197,12 +159,8 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'update', - ], + resource: ['customer'], + operation: ['update'], }, }, }, @@ -210,15 +168,12 @@ export const customerFields: INodeProperties[] = [ displayName: 'Website Name or ID', name: 'website_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'update', - ], + resource: ['customer'], + operation: ['update'], }, }, typeOptions: { @@ -234,17 +189,11 @@ export const customerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'update', - ], + resource: ['customer'], + operation: ['update'], }, }, - options: [ - ...getCustomerOptionalFields(), - ], + options: [...getCustomerOptionalFields()], }, /* -------------------------------------------------------------------------- */ @@ -258,13 +207,8 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'delete', - 'get', - ], + resource: ['customer'], + operation: ['delete', 'get'], }, }, }, @@ -278,12 +222,8 @@ export const customerFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'getAll', - ], + resource: ['customer'], + operation: ['getAll'], }, }, default: false, @@ -295,15 +235,9 @@ export const customerFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['customer'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -313,9 +247,5 @@ export const customerFields: INodeProperties[] = [ default: 5, description: 'Max number of results to return', }, - ...getSearchFilters( - 'customer', - 'getSystemAttributes', - 'getSystemAttributes', - ), + ...getSearchFilters('customer', 'getSystemAttributes', 'getSystemAttributes'), ]; diff --git a/packages/nodes-base/nodes/Magento/GenericFunctions.ts b/packages/nodes-base/nodes/Magento/GenericFunctions.ts index c62c731b26..89ac48223b 100644 --- a/packages/nodes-base/nodes/Magento/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Magento/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,22 +7,22 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, - INodeProperties, - INodePropertyOptions, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, INodeProperties, INodePropertyOptions, NodeApiError } from 'n8n-workflow'; -import { - Address, - Filter, - FilterGroup, - ProductAttribute, - Search, -} from './Types'; +import { Address, Filter, FilterGroup, ProductAttribute, Search } from './Types'; -export async function magentoApiRequest(this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function magentoApiRequest( + this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('magento2Api'); let options: OptionsWithUri = { @@ -47,8 +45,16 @@ export async function magentoApiRequest(this: IWebhookFunctions | IHookFunctions } } -export async function magentoApiRequestAllItems(this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function magentoApiRequestAllItems( + this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, + propertyName: string, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -56,10 +62,8 @@ export async function magentoApiRequestAllItems(this: IHookFunctions | ILoadOpti do { responseData = await magentoApiRequest.call(this, method, resource, body, query); returnData.push.apply(returnData, responseData[propertyName]); - query['current_page'] = (query.current_page) ? (query.current_page as number)++ : 1; - } while ( - returnData.length < responseData.total_count - ); + query['current_page'] = query.current_page ? (query.current_page as number)++ : 1; + } while (returnData.length < responseData.total_count); return returnData; } @@ -110,7 +114,8 @@ export function getAddressesUi(): INodeProperties { displayName: 'Country Name or ID', name: 'country_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCountries', }, @@ -189,7 +194,7 @@ export function getAddressesUi(): INodeProperties { } // tslint:disable-next-line: no-any -export function adjustAddresses(addresses: [{ street: string, [key: string]: string }]): Address[] { +export function adjustAddresses(addresses: [{ street: string; [key: string]: string }]): Address[] { const _addresses: Address[] = []; for (let i = 0; i < addresses.length; i++) { if (addresses[i]?.region === '') { @@ -203,7 +208,11 @@ export function adjustAddresses(addresses: [{ street: string, [key: string]: str return _addresses; } -export function getSearchFilters(resource: string, filterableAttributeFunction: string, sortableAttributeFunction: string): INodeProperties[] { +export function getSearchFilters( + resource: string, + filterableAttributeFunction: string, + sortableAttributeFunction: string, +): INodeProperties[] { return [ { displayName: 'Filter', @@ -225,12 +234,8 @@ export function getSearchFilters(resource: string, filterableAttributeFunction: ], displayOptions: { show: { - resource: [ - resource, - ], - operation: [ - 'getAll', - ], + resource: [resource], + operation: ['getAll'], }, }, default: 'none', @@ -251,15 +256,9 @@ export function getSearchFilters(resource: string, filterableAttributeFunction: ], displayOptions: { show: { - resource: [ - resource, - ], - operation: [ - 'getAll', - ], - filterType: [ - 'manual', - ], + resource: [resource], + operation: ['getAll'], + filterType: ['manual'], }, }, default: 'anyFilter', @@ -273,15 +272,9 @@ export function getSearchFilters(resource: string, filterableAttributeFunction: }, displayOptions: { show: { - resource: [ - resource, - ], - operation: [ - 'getAll', - ], - filterType: [ - 'manual', - ], + resource: [resource], + operation: ['getAll'], + filterType: ['manual'], }, }, default: {}, @@ -290,27 +283,20 @@ export function getSearchFilters(resource: string, filterableAttributeFunction: { displayName: 'Conditions', name: 'conditions', - values: [ - ...getConditions(filterableAttributeFunction), - ], + values: [...getConditions(filterableAttributeFunction)], }, ], }, { - displayName: 'See Magento guide to creating filters', + displayName: + 'See Magento guide to creating filters', name: 'jsonNotice', type: 'notice', displayOptions: { show: { - resource: [ - resource, - ], - operation: [ - 'getAll', - ], - filterType: [ - 'json', - ], + resource: [resource], + operation: ['getAll'], + filterType: ['json'], }, }, default: '', @@ -324,15 +310,9 @@ export function getSearchFilters(resource: string, filterableAttributeFunction: }, displayOptions: { show: { - resource: [ - resource, - ], - operation: [ - 'getAll', - ], - filterType: [ - 'json', - ], + resource: [resource], + operation: ['getAll'], + filterType: ['json'], }, }, default: '', @@ -345,12 +325,8 @@ export function getSearchFilters(resource: string, filterableAttributeFunction: default: {}, displayOptions: { show: { - resource: [ - resource, - ], - operation: [ - 'getAll', - ], + resource: [resource], + operation: ['getAll'], }, }, options: [ @@ -494,10 +470,7 @@ function getConditions(attributeFunction: string): INodeProperties[] { type: 'string', displayOptions: { hide: { - condition_type: [ - 'null', - 'notnull', - ], + condition_type: ['null', 'notnull'], }, }, default: '', @@ -505,8 +478,11 @@ function getConditions(attributeFunction: string): INodeProperties[] { ]; } -export function getFilterQuery(data: { conditions?: Filter[], matchType: string, sort: [{ direction: string, field: string }] }): Search { - +export function getFilterQuery(data: { + conditions?: Filter[]; + matchType: string; + sort: [{ direction: string; field: string }]; +}): Search { if (!data.hasOwnProperty('conditions') || data.conditions?.length === 0) { throw new Error('At least one filter has to be set'); } @@ -539,7 +515,8 @@ export function getFilterQuery(data: { conditions?: Filter[], matchType: string, }; } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); @@ -582,7 +559,8 @@ export function getCustomerOptionalFields(): INodeProperties[] { displayName: 'Attribute Code Name or ID', name: 'attribute_code', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCustomAttributes', }, @@ -640,7 +618,8 @@ export function getCustomerOptionalFields(): INodeProperties[] { displayName: 'Group Name or ID', name: 'group_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getGroups', }, @@ -674,7 +653,8 @@ export function getCustomerOptionalFields(): INodeProperties[] { displayName: 'Store Name or ID', name: 'store_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getStores', }, @@ -702,12 +682,11 @@ export function getCustomerOptionalFields(): INodeProperties[] { displayName: 'Website Name or ID', name: 'website_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', displayOptions: { show: { - '/operation': [ - 'create', - ], + '/operation': ['create'], }, }, typeOptions: { @@ -724,12 +703,11 @@ export function getProductOptionalFields(): INodeProperties[] { displayName: 'Attribute Set Name or ID', name: 'attribute_set_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', displayOptions: { show: { - '/operation': [ - 'update', - ], + '/operation': ['update'], }, }, typeOptions: { @@ -743,9 +721,7 @@ export function getProductOptionalFields(): INodeProperties[] { type: 'string', displayOptions: { show: { - '/operation': [ - 'update', - ], + '/operation': ['update'], }, }, default: '', @@ -798,9 +774,7 @@ export function getProductOptionalFields(): INodeProperties[] { type: 'number', displayOptions: { show: { - '/operation': [ - 'update', - ], + '/operation': ['update'], }, }, default: 0, @@ -825,7 +799,8 @@ export function getProductOptionalFields(): INodeProperties[] { displayName: 'Type Name or ID', name: 'type_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getProductTypes', }, @@ -1000,21 +975,38 @@ export function getOrderFields() { ]; } export const sort = (a: { name: string }, b: { name: string }) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }; -// tslint:disable-next-line: no-any -export async function getProductAttributes(this: ILoadOptionsFunctions, filter?: (attribute: ProductAttribute) => any, extraValue?: { name: string, value: string }): Promise { +export async function getProductAttributes( + this: ILoadOptionsFunctions, + // tslint:disable-next-line:no-any + filter?: (attribute: ProductAttribute) => any, + extraValue?: { name: string; value: string }, +): Promise { //https://magento.redoc.ly/2.3.7-admin/tag/productsattribute-setssetslist#operation/catalogAttributeSetRepositoryV1GetListGet - let attributes: ProductAttribute[] = await magentoApiRequestAllItems.call(this, 'items', 'GET', `/rest/default/V1/products/attributes`, {}, { - search_criteria: 0, - }); + let attributes: ProductAttribute[] = await magentoApiRequestAllItems.call( + this, + 'items', + 'GET', + `/rest/default/V1/products/attributes`, + {}, + { + search_criteria: 0, + }, + ); - attributes = attributes.filter((attribute) => - attribute.default_frontend_label !== undefined && attribute.default_frontend_label !== ''); + attributes = attributes.filter( + (attribute) => + attribute.default_frontend_label !== undefined && attribute.default_frontend_label !== '', + ); if (filter) { attributes = attributes.filter(filter); diff --git a/packages/nodes-base/nodes/Magento/InvoiceDescription.ts b/packages/nodes-base/nodes/Magento/InvoiceDescription.ts index 2d45168282..6e1bf2e903 100644 --- a/packages/nodes-base/nodes/Magento/InvoiceDescription.ts +++ b/packages/nodes-base/nodes/Magento/InvoiceDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const invoiceOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const invoiceOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'invoice', - ], + resource: ['invoice'], }, }, options: [ @@ -28,7 +24,6 @@ export const invoiceOperations: INodeProperties[] = [ ]; export const invoiceFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* invoice:create */ /* -------------------------------------------------------------------------- */ @@ -40,12 +35,8 @@ export const invoiceFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'create', - ], + resource: ['invoice'], + operation: ['create'], }, }, }, diff --git a/packages/nodes-base/nodes/Magento/Magento2.node.ts b/packages/nodes-base/nodes/Magento/Magento2.node.ts index 99f0af1783..4441b771b4 100644 --- a/packages/nodes-base/nodes/Magento/Magento2.node.ts +++ b/packages/nodes-base/nodes/Magento/Magento2.node.ts @@ -1,11 +1,6 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; - -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -31,25 +26,13 @@ import { validateJSON, } from './GenericFunctions'; -import { - customerFields, - customerOperations, -} from './CustomerDescription'; +import { customerFields, customerOperations } from './CustomerDescription'; -import { - orderFields, - orderOperations, -} from './OrderDescription'; +import { orderFields, orderOperations } from './OrderDescription'; -import { - productFields, - productOperations, -} from './ProductDescription'; +import { productFields, productOperations } from './ProductDescription'; -import { - invoiceFields, - invoiceOperations, -} from './InvoiceDescription'; +import { invoiceFields, invoiceOperations } from './InvoiceDescription'; import { CustomAttribute, @@ -60,9 +43,7 @@ import { Search, } from './Types'; -import { - capitalCase, -} from 'change-case'; +import { capitalCase } from 'change-case'; export class Magento2 implements INodeType { description: INodeTypeDescription = { @@ -125,7 +106,11 @@ export class Magento2 implements INodeType { loadOptions: { async getCountries(this: ILoadOptionsFunctions): Promise { //https://magento.redoc.ly/2.3.7-admin/tag/directorycountries - const countries = await magentoApiRequest.call(this, 'GET', '/rest/default/V1/directory/countries'); + const countries = await magentoApiRequest.call( + this, + 'GET', + '/rest/default/V1/directory/countries', + ); const returnData: INodePropertyOptions[] = []; for (const country of countries) { returnData.push({ @@ -138,7 +123,11 @@ export class Magento2 implements INodeType { }, async getGroups(this: ILoadOptionsFunctions): Promise { //https://magento.redoc.ly/2.3.7-admin/tag/customerGroupsdefault#operation/customerGroupManagementV1GetDefaultGroupGet - const group = await magentoApiRequest.call(this, 'GET', '/rest/default/V1/customerGroups/default'); + const group = await magentoApiRequest.call( + this, + 'GET', + '/rest/default/V1/customerGroups/default', + ); const returnData: INodePropertyOptions[] = []; returnData.push({ name: group.code, @@ -149,7 +138,11 @@ export class Magento2 implements INodeType { }, async getStores(this: ILoadOptionsFunctions): Promise { //https://magento.redoc.ly/2.3.7-admin/tag/storestoreConfigs - const stores = await magentoApiRequest.call(this, 'GET', '/rest/default/V1/store/storeConfigs'); + const stores = await magentoApiRequest.call( + this, + 'GET', + '/rest/default/V1/store/storeConfigs', + ); const returnData: INodePropertyOptions[] = []; for (const store of stores) { returnData.push({ @@ -162,7 +155,11 @@ export class Magento2 implements INodeType { }, async getWebsites(this: ILoadOptionsFunctions): Promise { //https://magento.redoc.ly/2.3.7-admin/tag/storewebsites - const websites = await magentoApiRequest.call(this, 'GET', '/rest/default/V1/store/websites'); + const websites = await magentoApiRequest.call( + this, + 'GET', + '/rest/default/V1/store/websites', + ); const returnData: INodePropertyOptions[] = []; for (const website of websites) { returnData.push({ @@ -176,7 +173,11 @@ export class Magento2 implements INodeType { async getCustomAttributes(this: ILoadOptionsFunctions): Promise { //https://magento.redoc.ly/2.3.7-admin/tag/attributeMetadatacustomer#operation/customerCustomerMetadataV1GetAllAttributesMetadataGet const resource = this.getCurrentNodeParameter('resource') as string; - const attributes = await magentoApiRequest.call(this, 'GET', `/rest/default/V1/attributeMetadata/${resource}`) as CustomerAttributeMetadata[]; + const attributes = (await magentoApiRequest.call( + this, + 'GET', + `/rest/default/V1/attributeMetadata/${resource}`, + )) as CustomerAttributeMetadata[]; const returnData: INodePropertyOptions[] = []; for (const attribute of attributes) { if (attribute.system === false && attribute.frontend_label !== '') { @@ -192,7 +193,11 @@ export class Magento2 implements INodeType { async getSystemAttributes(this: ILoadOptionsFunctions): Promise { //https://magento.redoc.ly/2.3.7-admin/tag/attributeMetadatacustomer#operation/customerCustomerMetadataV1GetAllAttributesMetadataGet const resource = this.getCurrentNodeParameter('resource') as string; - const attributes = await magentoApiRequest.call(this, 'GET', `/rest/default/V1/attributeMetadata/${resource}`) as CustomerAttributeMetadata[]; + const attributes = (await magentoApiRequest.call( + this, + 'GET', + `/rest/default/V1/attributeMetadata/${resource}`, + )) as CustomerAttributeMetadata[]; const returnData: INodePropertyOptions[] = []; for (const attribute of attributes) { if (attribute.system === true && attribute.frontend_label !== null) { @@ -207,7 +212,11 @@ export class Magento2 implements INodeType { }, async getProductTypes(this: ILoadOptionsFunctions): Promise { //https://magento.redoc.ly/2.3.7-admin/tag/productslinkstypes - const types = await magentoApiRequest.call(this, 'GET', `/rest/default/V1/products/types`) as IDataObject[]; + const types = (await magentoApiRequest.call( + this, + 'GET', + `/rest/default/V1/products/types`, + )) as IDataObject[]; const returnData: INodePropertyOptions[] = []; for (const type of types) { returnData.push({ @@ -220,21 +229,27 @@ export class Magento2 implements INodeType { }, async getCategories(this: ILoadOptionsFunctions): Promise { //https://magento.redoc.ly/2.3.7-admin/tag/categories#operation/catalogCategoryManagementV1GetTreeGet - const { items: categories } = await magentoApiRequest.call(this, 'GET', `/rest/default/V1/categories/list`, {}, { - search_criteria: { - filter_groups: [ - { - filters: [ - { - field: 'is_active', - condition_type: 'eq', - value: 1, - }, - ], - }, - ], + const { items: categories } = (await magentoApiRequest.call( + this, + 'GET', + `/rest/default/V1/categories/list`, + {}, + { + search_criteria: { + filter_groups: [ + { + filters: [ + { + field: 'is_active', + condition_type: 'eq', + value: 1, + }, + ], + }, + ], + }, }, - }) as { items: IDataObject[] }; + )) as { items: IDataObject[] }; const returnData: INodePropertyOptions[] = []; for (const category of categories) { returnData.push({ @@ -247,9 +262,15 @@ export class Magento2 implements INodeType { }, async getAttributeSets(this: ILoadOptionsFunctions): Promise { //https://magento.redoc.ly/2.3.7-admin/tag/productsattribute-setssetslist#operation/catalogAttributeSetRepositoryV1GetListGet - const { items: attributeSets } = await magentoApiRequest.call(this, 'GET', `/rest/default/V1/products/attribute-sets/sets/list`, {}, { - search_criteria: 0, - }) as { items: IDataObject[] }; + const { items: attributeSets } = (await magentoApiRequest.call( + this, + 'GET', + `/rest/default/V1/products/attribute-sets/sets/list`, + {}, + { + search_criteria: 0, + }, + )) as { items: IDataObject[] }; const returnData: INodePropertyOptions[] = []; for (const attributeSet of attributeSets) { returnData.push({ @@ -260,7 +281,9 @@ export class Magento2 implements INodeType { returnData.sort(sort); return returnData; }, - async getFilterableCustomerAttributes(this: ILoadOptionsFunctions): Promise { + async getFilterableCustomerAttributes( + this: ILoadOptionsFunctions, + ): Promise { return getProductAttributes.call(this, (attribute) => attribute.is_filterable === true); }, async getProductAttributes(this: ILoadOptionsFunctions): Promise { @@ -269,14 +292,20 @@ export class Magento2 implements INodeType { // async getProductAttributesFields(this: ILoadOptionsFunctions): Promise { // return getProductAttributes.call(this, undefined, { name: '*', value: '*', description: 'All properties' }); // }, - async getFilterableProductAttributes(this: ILoadOptionsFunctions): Promise { + async getFilterableProductAttributes( + this: ILoadOptionsFunctions, + ): Promise { return getProductAttributes.call(this, (attribute) => attribute.is_searchable === '1'); }, - async getSortableProductAttributes(this: ILoadOptionsFunctions): Promise { + async getSortableProductAttributes( + this: ILoadOptionsFunctions, + ): Promise { return getProductAttributes.call(this, (attribute) => attribute.used_for_sort_by === true); }, async getOrderAttributes(this: ILoadOptionsFunctions): Promise { - return getOrderFields().map(field => ({ name: capitalCase(field), value: field })).sort(sort); + return getOrderFields() + .map((field) => ({ name: capitalCase(field), value: field })) + .sort(sort); }, }, }; @@ -299,21 +328,21 @@ export class Magento2 implements INodeType { const firstname = this.getNodeParameter('firstname', i) as string; const lastname = this.getNodeParameter('lastname', i) as string; - const { - addresses, - customAttributes, - password, - ...rest - } = this.getNodeParameter('additionalFields', i) as { + const { addresses, customAttributes, password, ...rest } = this.getNodeParameter( + 'additionalFields', + i, + ) as { addresses: { - address: [{ - street: string, - }] + address: [ + { + street: string; + }, + ]; }; customAttributes: { - customAttribute: CustomAttribute[], - }, - password: string, + customAttribute: CustomAttribute[]; + }; + password: string; }; const body: NewCustomer = { @@ -328,7 +357,12 @@ export class Magento2 implements INodeType { body.customer!.custom_attributes = customAttributes?.customAttribute || {}; - body.customer!.extension_attributes = ['amazon_id', 'is_subscribed', 'vertex_customer_code', 'vertex_customer_country'] + body.customer!.extension_attributes = [ + 'amazon_id', + 'is_subscribed', + 'vertex_customer_code', + 'vertex_customer_country', + ] // tslint:disable-next-line: no-any .reduce((obj, value: string): any => { if ((rest as IDataObject).hasOwnProperty(value)) { @@ -353,7 +387,11 @@ export class Magento2 implements INodeType { //https://magento.redoc.ly/2.3.7-admin/tag/customerscustomerId#operation/customerCustomerRepositoryV1SavePut const customerId = this.getNodeParameter('customerId', i) as string; - responseData = await magentoApiRequest.call(this, 'DELETE', `/rest/default/V1/customers/${customerId}`); + responseData = await magentoApiRequest.call( + this, + 'DELETE', + `/rest/default/V1/customers/${customerId}`, + ); responseData = { success: true }; } @@ -362,13 +400,19 @@ export class Magento2 implements INodeType { //https://magento.redoc.ly/2.3.7-admin/tag/customerscustomerId#operation/customerCustomerRepositoryV1GetByIdGet const customerId = this.getNodeParameter('customerId', i) as string; - responseData = await magentoApiRequest.call(this, 'GET', `/rest/default/V1/customers/${customerId}`); + responseData = await magentoApiRequest.call( + this, + 'GET', + `/rest/default/V1/customers/${customerId}`, + ); } if (operation === 'getAll') { //https://magento.redoc.ly/2.3.7-admin/tag/customerssearch const filterType = this.getNodeParameter('filterType', i) as string; - const sort = this.getNodeParameter('options.sort', i, {}) as { sort: [{ direction: string, field: string }] }; + const sort = this.getNodeParameter('options.sort', i, {}) as { + sort: [{ direction: string; field: string }]; + }; const returnAll = this.getNodeParameter('returnAll', 0) as boolean; let qs: Search = {}; @@ -381,7 +425,9 @@ export class Magento2 implements INodeType { if (validateJSON(filterJson) !== undefined) { qs = JSON.parse(filterJson); } else { - throw new NodeApiError(this.getNode(), { message: 'Filter (JSON) must be a valid json' }); + throw new NodeApiError(this.getNode(), { + message: 'Filter (JSON) must be a valid json', + }); } } else { qs = { @@ -397,12 +443,24 @@ export class Magento2 implements INodeType { if (returnAll === true) { qs.search_criteria!.page_size = 100; - responseData = await magentoApiRequestAllItems.call(this, 'items', 'GET', `/rest/default/V1/customers/search`, {}, qs as unknown as IDataObject); - + responseData = await magentoApiRequestAllItems.call( + this, + 'items', + 'GET', + `/rest/default/V1/customers/search`, + {}, + qs as unknown as IDataObject, + ); } else { const limit = this.getNodeParameter('limit', 0) as number; qs.search_criteria!.page_size = limit; - responseData = await magentoApiRequest.call(this, 'GET', `/rest/default/V1/customers/search`, {}, qs as unknown as IDataObject); + responseData = await magentoApiRequest.call( + this, + 'GET', + `/rest/default/V1/customers/search`, + {}, + qs as unknown as IDataObject, + ); responseData = responseData.items; } } @@ -414,21 +472,21 @@ export class Magento2 implements INodeType { const lastName = this.getNodeParameter('lastName', i) as string; const email = this.getNodeParameter('email', i) as string; - const { - addresses, - customAttributes, - password, - ...rest - } = this.getNodeParameter('updateFields', i) as { + const { addresses, customAttributes, password, ...rest } = this.getNodeParameter( + 'updateFields', + i, + ) as { addresses: { - address: [{ - street: string, - }] + address: [ + { + street: string; + }, + ]; }; customAttributes: { - customAttribute: CustomAttribute[], - }, - password: string, + customAttribute: CustomAttribute[]; + }; + password: string; }; const body: NewCustomer = { @@ -445,7 +503,12 @@ export class Magento2 implements INodeType { body.customer!.custom_attributes = customAttributes?.customAttribute || {}; - body.customer!.extension_attributes = ['amazon_id', 'is_subscribed', 'vertex_customer_code', 'vertex_customer_country'] + body.customer!.extension_attributes = [ + 'amazon_id', + 'is_subscribed', + 'vertex_customer_code', + 'vertex_customer_country', + ] // tslint:disable-next-line: no-any .reduce((obj, value: string): any => { if ((rest as IDataObject).hasOwnProperty(value)) { @@ -463,7 +526,12 @@ export class Magento2 implements INodeType { Object.assign(body.customer, rest); - responseData = await magentoApiRequest.call(this, 'PUT', `/rest/V1/customers/${customerId}`, body); + responseData = await magentoApiRequest.call( + this, + 'PUT', + `/rest/V1/customers/${customerId}`, + body, + ); } } @@ -472,19 +540,26 @@ export class Magento2 implements INodeType { ///https://magento.redoc.ly/2.3.7-admin/tag/orderorderIdinvoice const orderId = this.getNodeParameter('orderId', i) as string; - responseData = await magentoApiRequest.call(this, 'POST', `/rest/default/V1/order/${orderId}/invoice`); + responseData = await magentoApiRequest.call( + this, + 'POST', + `/rest/default/V1/order/${orderId}/invoice`, + ); responseData = { success: true }; } } if (resource === 'order') { - if (operation === 'cancel') { //https://magento.redoc.ly/2.3.7-admin/tag/ordersidcancel const orderId = this.getNodeParameter('orderId', i) as string; - responseData = await magentoApiRequest.call(this, 'POST', `/rest/default/V1/orders/${orderId}/cancel`); + responseData = await magentoApiRequest.call( + this, + 'POST', + `/rest/default/V1/orders/${orderId}/cancel`, + ); responseData = { success: true }; } @@ -493,14 +568,22 @@ export class Magento2 implements INodeType { //https://magento.redoc.ly/2.3.7-admin/tag/ordersid#operation/salesOrderRepositoryV1GetGet const orderId = this.getNodeParameter('orderId', i) as string; - responseData = await magentoApiRequest.call(this, 'GET', `/rest/default/V1/orders/${orderId}`); + responseData = await magentoApiRequest.call( + this, + 'GET', + `/rest/default/V1/orders/${orderId}`, + ); } if (operation === 'ship') { ///https://magento.redoc.ly/2.3.7-admin/tag/orderorderIdship#operation/salesShipOrderV1ExecutePost const orderId = this.getNodeParameter('orderId', i) as string; - responseData = await magentoApiRequest.call(this, 'POST', `/rest/default/V1/order/${orderId}/ship`); + responseData = await magentoApiRequest.call( + this, + 'POST', + `/rest/default/V1/order/${orderId}/ship`, + ); responseData = { success: true }; } @@ -508,7 +591,9 @@ export class Magento2 implements INodeType { if (operation === 'getAll') { //https://magento.redoc.ly/2.3.7-admin/tag/orders#operation/salesOrderRepositoryV1GetListGet const filterType = this.getNodeParameter('filterType', i) as string; - const sort = this.getNodeParameter('options.sort', i, {}) as { sort: [{ direction: string, field: string }] }; + const sort = this.getNodeParameter('options.sort', i, {}) as { + sort: [{ direction: string; field: string }]; + }; const returnAll = this.getNodeParameter('returnAll', 0) as boolean; let qs: Search = {}; @@ -521,7 +606,9 @@ export class Magento2 implements INodeType { if (validateJSON(filterJson) !== undefined) { qs = JSON.parse(filterJson); } else { - throw new NodeApiError(this.getNode(), { message: 'Filter (JSON) must be a valid json' }); + throw new NodeApiError(this.getNode(), { + message: 'Filter (JSON) must be a valid json', + }); } } else { qs = { @@ -536,12 +623,24 @@ export class Magento2 implements INodeType { if (returnAll === true) { qs.search_criteria!.page_size = 100; - responseData = await magentoApiRequestAllItems.call(this, 'items', 'GET', `/rest/default/V1/orders`, {}, qs as unknown as IDataObject); - + responseData = await magentoApiRequestAllItems.call( + this, + 'items', + 'GET', + `/rest/default/V1/orders`, + {}, + qs as unknown as IDataObject, + ); } else { const limit = this.getNodeParameter('limit', 0) as number; qs.search_criteria!.page_size = limit; - responseData = await magentoApiRequest.call(this, 'GET', `/rest/default/V1/orders`, {}, qs as unknown as IDataObject); + responseData = await magentoApiRequest.call( + this, + 'GET', + `/rest/default/V1/orders`, + {}, + qs as unknown as IDataObject, + ); responseData = responseData.items; } } @@ -555,15 +654,14 @@ export class Magento2 implements INodeType { const attributeSetId = this.getNodeParameter('attributeSetId', i) as string; const price = this.getNodeParameter('price', i) as number; - const { - customAttributes, - category, - ...rest - } = this.getNodeParameter('additionalFields', i) as { + const { customAttributes, category, ...rest } = this.getNodeParameter( + 'additionalFields', + i, + ) as { customAttributes: { - customAttribute: CustomAttribute[], - }, - category: string, + customAttribute: CustomAttribute[]; + }; + category: string; }; const body: NewProduct = { @@ -579,14 +677,23 @@ export class Magento2 implements INodeType { Object.assign(body.product, rest); - responseData = await magentoApiRequest.call(this, 'POST', '/rest/default/V1/products', body); + responseData = await magentoApiRequest.call( + this, + 'POST', + '/rest/default/V1/products', + body, + ); } if (operation === 'delete') { //https://magento.redoc.ly/2.3.7-admin/tag/productssku#operation/catalogProductRepositoryV1DeleteByIdDelete const sku = this.getNodeParameter('sku', i) as string; - responseData = await magentoApiRequest.call(this, 'DELETE', `/rest/default/V1/products/${sku}`); + responseData = await magentoApiRequest.call( + this, + 'DELETE', + `/rest/default/V1/products/${sku}`, + ); responseData = { success: true }; } @@ -595,13 +702,19 @@ export class Magento2 implements INodeType { //https://magento.redoc.ly/2.3.7-admin/tag/productssku#operation/catalogProductRepositoryV1GetGet const sku = this.getNodeParameter('sku', i) as string; - responseData = await magentoApiRequest.call(this, 'GET', `/rest/default/V1/products/${sku}`); + responseData = await magentoApiRequest.call( + this, + 'GET', + `/rest/default/V1/products/${sku}`, + ); } if (operation === 'getAll') { //https://magento.redoc.ly/2.3.7-admin/tag/customerssearch const filterType = this.getNodeParameter('filterType', i) as string; - const sort = this.getNodeParameter('options.sort', i, {}) as { sort: [{ direction: string, field: string }] }; + const sort = this.getNodeParameter('options.sort', i, {}) as { + sort: [{ direction: string; field: string }]; + }; const returnAll = this.getNodeParameter('returnAll', 0) as boolean; let qs: Search = {}; @@ -614,7 +727,9 @@ export class Magento2 implements INodeType { if (validateJSON(filterJson) !== undefined) { qs = JSON.parse(filterJson); } else { - throw new NodeApiError(this.getNode(), { message: 'Filter (JSON) must be a valid json' }); + throw new NodeApiError(this.getNode(), { + message: 'Filter (JSON) must be a valid json', + }); } } else { qs = { @@ -629,12 +744,24 @@ export class Magento2 implements INodeType { if (returnAll === true) { qs.search_criteria!.page_size = 100; - responseData = await magentoApiRequestAllItems.call(this, 'items', 'GET', `/rest/default/V1/products`, {}, qs as unknown as IDataObject); - + responseData = await magentoApiRequestAllItems.call( + this, + 'items', + 'GET', + `/rest/default/V1/products`, + {}, + qs as unknown as IDataObject, + ); } else { const limit = this.getNodeParameter('limit', 0) as number; qs.search_criteria!.page_size = limit; - responseData = await magentoApiRequest.call(this, 'GET', `/rest/default/V1/products`, {}, qs as unknown as IDataObject); + responseData = await magentoApiRequest.call( + this, + 'GET', + `/rest/default/V1/products`, + {}, + qs as unknown as IDataObject, + ); responseData = responseData.items; } } @@ -643,17 +770,16 @@ export class Magento2 implements INodeType { //https://magento.redoc.ly/2.3.7-admin/tag/productssku#operation/catalogProductRepositoryV1SavePut const sku = this.getNodeParameter('sku', i) as string; - const { - customAttributes, - ...rest - } = this.getNodeParameter('updateFields', i) as { + const { customAttributes, ...rest } = this.getNodeParameter('updateFields', i) as { customAttributes: { - customAttribute: CustomAttribute[], - }, + customAttribute: CustomAttribute[]; + }; }; if (!Object.keys(rest).length) { - throw new NodeApiError(this.getNode(), { message: 'At least one parameter has to be updated' }); + throw new NodeApiError(this.getNode(), { + message: 'At least one parameter has to be updated', + }); } const body: NewProduct = { @@ -666,14 +792,18 @@ export class Magento2 implements INodeType { Object.assign(body.product, rest); - responseData = await magentoApiRequest.call(this, 'PUT', `/rest/default/V1/products/${sku}`, body); + responseData = await magentoApiRequest.call( + this, + 'PUT', + `/rest/default/V1/products/${sku}`, + body, + ); } } Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/Magento/OrderDescription.ts b/packages/nodes-base/nodes/Magento/OrderDescription.ts index be77951525..b8db955c5b 100644 --- a/packages/nodes-base/nodes/Magento/OrderDescription.ts +++ b/packages/nodes-base/nodes/Magento/OrderDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - getSearchFilters, -} from './GenericFunctions'; +import { getSearchFilters } from './GenericFunctions'; export const orderOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const orderOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'order', - ], + resource: ['order'], }, }, options: [ @@ -50,7 +44,6 @@ export const orderOperations: INodeProperties[] = [ ]; export const orderFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* order:cancel */ /* -------------------------------------------------------------------------- */ @@ -62,14 +55,8 @@ export const orderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'cancel', - 'get', - 'ship', - ], + resource: ['order'], + operation: ['cancel', 'get', 'ship'], }, }, }, @@ -83,12 +70,8 @@ export const orderFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'getAll', - ], + resource: ['order'], + operation: ['getAll'], }, }, default: false, @@ -100,15 +83,9 @@ export const orderFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['order'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -118,10 +95,5 @@ export const orderFields: INodeProperties[] = [ default: 5, description: 'Max number of results to return', }, - ...getSearchFilters( - 'order', - 'getOrderAttributes', - 'getOrderAttributes', - ), - + ...getSearchFilters('order', 'getOrderAttributes', 'getOrderAttributes'), ]; diff --git a/packages/nodes-base/nodes/Magento/ProductDescription.ts b/packages/nodes-base/nodes/Magento/ProductDescription.ts index eb86e367b9..a8a99bf354 100644 --- a/packages/nodes-base/nodes/Magento/ProductDescription.ts +++ b/packages/nodes-base/nodes/Magento/ProductDescription.ts @@ -1,11 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - getProductOptionalFields, - getSearchFilters, -} from './GenericFunctions'; +import { getProductOptionalFields, getSearchFilters } from './GenericFunctions'; export const productOperations: INodeProperties[] = [ { @@ -15,9 +10,7 @@ export const productOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'product', - ], + resource: ['product'], }, }, options: [ @@ -57,7 +50,6 @@ export const productOperations: INodeProperties[] = [ ]; export const productFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* product:create */ /* -------------------------------------------------------------------------- */ @@ -69,13 +61,8 @@ export const productFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'create', - 'update', - ], + resource: ['product'], + operation: ['create', 'update'], }, }, description: 'Stock-keeping unit of the product', @@ -87,12 +74,8 @@ export const productFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'create', - ], + resource: ['product'], + operation: ['create'], }, }, default: '', @@ -101,15 +84,12 @@ export const productFields: INodeProperties[] = [ displayName: 'Attribute Set Name or ID', name: 'attributeSetId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'create', - ], + resource: ['product'], + operation: ['create'], }, }, typeOptions: { @@ -123,12 +103,8 @@ export const productFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'create', - ], + resource: ['product'], + operation: ['create'], }, }, default: 0, @@ -141,17 +117,11 @@ export const productFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'create', - ], + resource: ['product'], + operation: ['create'], }, }, - options: [ - ...getProductOptionalFields(), - ], + options: [...getProductOptionalFields()], }, { displayName: 'Update Fields', @@ -161,17 +131,11 @@ export const productFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'update', - ], + resource: ['product'], + operation: ['update'], }, }, - options: [ - ...getProductOptionalFields(), - ], + options: [...getProductOptionalFields()], }, /* -------------------------------------------------------------------------- */ @@ -185,13 +149,8 @@ export const productFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'delete', - 'get', - ], + resource: ['product'], + operation: ['delete', 'get'], }, }, description: 'Stock-keeping unit of the product', @@ -206,12 +165,8 @@ export const productFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'getAll', - ], + resource: ['product'], + operation: ['getAll'], }, }, default: false, @@ -223,15 +178,9 @@ export const productFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['product'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -245,6 +194,6 @@ export const productFields: INodeProperties[] = [ 'product', //'getProductAttributesFields', 'getFilterableProductAttributes', - 'getSortableProductAttributes'), - + 'getSortableProductAttributes', + ), ]; diff --git a/packages/nodes-base/nodes/Magento/Types.d.ts b/packages/nodes-base/nodes/Magento/Types.d.ts index f5367245e6..2126a6c3f9 100644 --- a/packages/nodes-base/nodes/Magento/Types.d.ts +++ b/packages/nodes-base/nodes/Magento/Types.d.ts @@ -1,4 +1,3 @@ - export interface NewCustomer { customer?: Customer; password?: string; @@ -121,8 +120,7 @@ export interface CustomerAttributeMetadataOption { options?: OptionOption[]; } -export interface OptionOption { -} +export interface OptionOption {} export interface ValidationRule { name?: string; @@ -174,19 +172,21 @@ export interface Product { updated_at?: string; weight?: number; extension_attributes?: { - category_links?: [{ - category_id?: string, - }] - } + category_links?: [ + { + category_id?: string; + }, + ]; + }; custom_attributes?: CustomAttribute[]; } export interface ProductAttribute { - is_filterable_in_search: boolean, + is_filterable_in_search: boolean; default_frontend_label: string; attribute_id: string; is_filterable: boolean; used_for_sort_by: boolean; - is_searchable: string, - attribute_code: string, + is_searchable: string; + attribute_code: string; } diff --git a/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts b/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts index 62e24f6c7e..59ec675311 100644 --- a/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,17 +7,26 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject -} from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; -export async function mailCheckApiRequest(this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function mailCheckApiRequest( + this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('mailcheckApi'); let options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', - 'Authorization': `Bearer ${credentials.apiKey}`, + Authorization: `Bearer ${credentials.apiKey}`, }, method, body, @@ -40,7 +47,9 @@ export async function mailCheckApiRequest(this: IWebhookFunctions | IHookFunctio } catch (error) { if (error.response && error.response.body && error.response.body.message) { // Try to return the error prettier - throw new Error(`Mailcheck error response [${error.statusCode}]: ${error.response.body.message}`); + throw new Error( + `Mailcheck error response [${error.statusCode}]: ${error.response.body.message}`, + ); } throw error; } diff --git a/packages/nodes-base/nodes/Mailcheck/Mailcheck.node.ts b/packages/nodes-base/nodes/Mailcheck/Mailcheck.node.ts index 8674c6c7ad..d5fd4645fc 100644 --- a/packages/nodes-base/nodes/Mailcheck/Mailcheck.node.ts +++ b/packages/nodes-base/nodes/Mailcheck/Mailcheck.node.ts @@ -1,17 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - mailCheckApiRequest, -} from './GenericFunctions'; +import { mailCheckApiRequest } from './GenericFunctions'; export class Mailcheck implements INodeType { description: INodeTypeDescription = { @@ -54,9 +45,7 @@ export class Mailcheck implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'email', - ], + resource: ['email'], }, }, options: [ @@ -75,12 +64,8 @@ export class Mailcheck implements INodeType { placeholder: 'name@email.com', displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'check', - ], + resource: ['email'], + operation: ['check'], }, }, default: '', @@ -102,7 +87,9 @@ export class Mailcheck implements INodeType { if (resource === 'email') { if (operation === 'check') { const email = this.getNodeParameter('email', i) as string; - responseData = await mailCheckApiRequest.call(this, 'POST', '/singleEmail:check', { email }); + responseData = await mailCheckApiRequest.call(this, 'POST', '/singleEmail:check', { + email, + }); } } } catch (error) { diff --git a/packages/nodes-base/nodes/Mailchimp/GenericFunctions.ts b/packages/nodes-base/nodes/Mailchimp/GenericFunctions.ts index 4d4f07bc0b..bdecbed95f 100644 --- a/packages/nodes-base/nodes/Mailchimp/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mailchimp/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUrl, - } from 'request'; +import { OptionsWithUrl } from 'request'; import { IExecuteFunctions, @@ -9,18 +7,25 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, - } from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function mailchimpApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, endpoint: string, method: string, body: any = {}, qs: IDataObject = {} ,headers?: object): Promise { // tslint:disable-line:no-any +export async function mailchimpApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + endpoint: string, + method: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0) as string; const host = 'api.mailchimp.com/3.0'; const options: OptionsWithUrl = { headers: { - 'Accept': 'application/json', + Accept: 'application/json', }, method, qs, @@ -45,19 +50,32 @@ export async function mailchimpApiRequest(this: IHookFunctions | IExecuteFunctio } else { const credentials = await this.getCredentials('mailchimpOAuth2Api'); - const { api_endpoint } = await getMetadata.call(this, credentials.oauthTokenData as IDataObject); + const { api_endpoint } = await getMetadata.call( + this, + credentials.oauthTokenData as IDataObject, + ); options.url = `${api_endpoint}/3.0${endpoint}`; //@ts-ignore - return await this.helpers.requestOAuth2!.call(this, 'mailchimpOAuth2Api', options, { tokenType: 'Bearer' }); + return await this.helpers.requestOAuth2!.call(this, 'mailchimpOAuth2Api', options, { + tokenType: 'Bearer', + }); } } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function mailchimpApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, endpoint: string, method: string, propertyName: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function mailchimpApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + endpoint: string, + method: string, + propertyName: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -69,14 +87,13 @@ export async function mailchimpApiRequestAllItems(this: IExecuteFunctions | ILoa responseData = await mailchimpApiRequest.call(this, endpoint, method, body, query); returnData.push.apply(returnData, responseData[propertyName]); query.offset += query.count; - } while ( - responseData[propertyName] && responseData[propertyName].length !== 0 - ); + } while (responseData[propertyName] && responseData[propertyName].length !== 0); return returnData; } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); @@ -86,12 +103,15 @@ export function validateJSON(json: string | undefined): any { // tslint:disable- return result; } -async function getMetadata(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, oauthTokenData: IDataObject) { +async function getMetadata( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + oauthTokenData: IDataObject, +) { const credentials = await this.getCredentials('mailchimpOAuth2Api'); const options: OptionsWithUrl = { headers: { - 'Accept': 'application/json', - 'Authorization': `OAuth ${oauthTokenData.access_token}`, + Accept: 'application/json', + Authorization: `OAuth ${oauthTokenData.access_token}`, }, method: 'GET', url: credentials.metadataUrl as string, diff --git a/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts b/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts index e2978a7384..f41a49d542 100644 --- a/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts +++ b/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts @@ -1,7 +1,4 @@ - -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -52,7 +49,6 @@ interface ICreateMemberBody { } export class Mailchimp implements INodeType { - description: INodeTypeDescription = { displayName: 'Mailchimp', name: 'mailchimp', @@ -72,9 +68,7 @@ export class Mailchimp implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'apiKey', - ], + authentication: ['apiKey'], }, }, }, @@ -83,9 +77,7 @@ export class Mailchimp implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -141,9 +133,7 @@ export class Mailchimp implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'member', - ], + resource: ['member'], }, }, options: [ @@ -188,9 +178,7 @@ export class Mailchimp implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'memberTag', - ], + resource: ['memberTag'], }, }, options: [ @@ -217,9 +205,7 @@ export class Mailchimp implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'listGroup', - ], + resource: ['listGroup'], }, }, options: [ @@ -235,16 +221,13 @@ export class Mailchimp implements INodeType { { displayName: 'Operation', name: 'operation', - type:'options', + type: 'options', noDataExpression: true, required: true, - displayOptions : { + displayOptions: { show: { - resource: [ - 'campaign', - ], + resource: ['campaign'], }, - }, options: [ { @@ -286,9 +269,9 @@ export class Mailchimp implements INodeType { ], default: 'getAll', }, -/* -------------------------------------------------------------------------- */ -/* member:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* member:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'List Name or ID', name: 'list', @@ -298,18 +281,15 @@ export class Mailchimp implements INodeType { }, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'create', - ], + resource: ['member'], + operation: ['create'], }, }, default: '', options: [], required: true, - description: 'List of lists. Choose from the list, or specify an ID using an expression.', + description: + 'List of lists. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Email', @@ -319,12 +299,8 @@ export class Mailchimp implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'create', - ], + resource: ['member'], + operation: ['create'], }, }, default: '', @@ -337,12 +313,8 @@ export class Mailchimp implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'create', - ], + resource: ['member'], + operation: ['create'], }, }, options: [ @@ -368,7 +340,7 @@ export class Mailchimp implements INodeType { }, ], default: '', - description: 'Subscriber\'s current status', + description: "Subscriber's current status", }, { displayName: 'JSON Parameters', @@ -377,12 +349,8 @@ export class Mailchimp implements INodeType { default: false, displayOptions: { show: { - resource:[ - 'member', - ], - operation: [ - 'create', - ], + resource: ['member'], + operation: ['create'], }, }, }, @@ -394,12 +362,8 @@ export class Mailchimp implements INodeType { default: {}, displayOptions: { show: { - resource:[ - 'member', - ], - operation: [ - 'create', - ], + resource: ['member'], + operation: ['create'], }, }, options: [ @@ -425,7 +389,7 @@ export class Mailchimp implements INodeType { name: 'language', type: 'string', default: '', - description: 'If set/detected, the subscriber\'s language', + description: "If set/detected, the subscriber's language", }, { displayName: 'Opt-in IP', @@ -446,7 +410,8 @@ export class Mailchimp implements INodeType { name: 'timestampSignup', type: 'dateTime', default: '', - description: 'The date and time the subscriber signed up for the list in ISO 8601 format', + description: + 'The date and time the subscriber signed up for the list in ISO 8601 format', }, { displayName: 'Tags', @@ -468,7 +433,8 @@ export class Mailchimp implements INodeType { name: 'timestampOpt', type: 'dateTime', default: '', - description: 'The date and time the subscribe confirmed their opt-in status in ISO 8601 format', + description: + 'The date and time the subscribe confirmed their opt-in status in ISO 8601 format', }, ], }, @@ -481,15 +447,9 @@ export class Mailchimp implements INodeType { description: 'Subscriber location information.n', displayOptions: { show: { - resource:[ - 'member', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['member'], + operation: ['create'], + jsonParameters: [false], }, }, options: [ @@ -528,15 +488,9 @@ export class Mailchimp implements INodeType { }, displayOptions: { show: { - resource:[ - 'member', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['member'], + operation: ['create'], + jsonParameters: [false], }, }, description: 'An individual merge var and value for a member', @@ -554,12 +508,11 @@ export class Mailchimp implements INodeType { type: 'options', typeOptions: { loadOptionsMethod: 'getMergeFields', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, required: true, - description: 'Merge Field name. Choose from the list, or specify an ID using an expression.', + description: + 'Merge Field name. Choose from the list, or specify an ID using an expression.', default: '', }, { @@ -584,15 +537,9 @@ export class Mailchimp implements INodeType { default: '', displayOptions: { show: { - resource:[ - 'member', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['member'], + operation: ['create'], + jsonParameters: [true], }, }, }, @@ -606,15 +553,9 @@ export class Mailchimp implements INodeType { default: '', displayOptions: { show: { - resource:[ - 'member', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['member'], + operation: ['create'], + jsonParameters: [true], }, }, }, @@ -629,15 +570,9 @@ export class Mailchimp implements INodeType { }, displayOptions: { show: { - resource:[ - 'member', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['member'], + operation: ['create'], + jsonParameters: [false], }, }, options: [ @@ -652,12 +587,11 @@ export class Mailchimp implements INodeType { displayName: 'Category Name or ID', name: 'categoryId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getGroupCategories', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, default: '', }, @@ -687,21 +621,15 @@ export class Mailchimp implements INodeType { default: '', displayOptions: { show: { - resource:[ - 'member', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['member'], + operation: ['create'], + jsonParameters: [true], }, }, }, -/* -------------------------------------------------------------------------- */ -/* member:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* member:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'List Name or ID', name: 'list', @@ -711,18 +639,15 @@ export class Mailchimp implements INodeType { }, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'delete', - ], + resource: ['member'], + operation: ['delete'], }, }, default: '', options: [], required: true, - description: 'List of lists. Choose from the list, or specify an ID using an expression.', + description: + 'List of lists. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Email', @@ -731,21 +656,17 @@ export class Mailchimp implements INodeType { placeholder: 'name@email.com', displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'delete', - ], + resource: ['member'], + operation: ['delete'], }, }, default: '', required: true, - description: 'Member\'s email', + description: "Member's email", }, -/* -------------------------------------------------------------------------- */ -/* member:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* member:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'List Name or ID', name: 'list', @@ -755,18 +676,15 @@ export class Mailchimp implements INodeType { }, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'get', - ], + resource: ['member'], + operation: ['get'], }, }, default: '', options: [], required: true, - description: 'List of lists. Choose from the list, or specify an ID using an expression.', + description: + 'List of lists. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Email', @@ -775,17 +693,13 @@ export class Mailchimp implements INodeType { placeholder: 'name@email.com', displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'get', - ], + resource: ['member'], + operation: ['get'], }, }, default: '', required: true, - description: 'Member\'s email', + description: "Member's email", }, { displayName: 'Options', @@ -795,12 +709,8 @@ export class Mailchimp implements INodeType { default: {}, displayOptions: { show: { - resource:[ - 'member', - ], - operation: [ - 'get', - ], + resource: ['member'], + operation: ['get'], }, }, options: [ @@ -820,9 +730,9 @@ export class Mailchimp implements INodeType { }, ], }, -/* -------------------------------------------------------------------------- */ -/* member:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* member:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'List Name or ID', name: 'list', @@ -832,18 +742,15 @@ export class Mailchimp implements INodeType { }, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'getAll', - ], + resource: ['member'], + operation: ['getAll'], }, }, default: '', options: [], required: true, - description: 'List of lists. Choose from the list, or specify an ID using an expression.', + description: + 'List of lists. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -851,12 +758,8 @@ export class Mailchimp implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'getAll', - ], + resource: ['member'], + operation: ['getAll'], }, }, default: false, @@ -868,15 +771,9 @@ export class Mailchimp implements INodeType { type: 'number', displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['member'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -894,12 +791,8 @@ export class Mailchimp implements INodeType { default: {}, displayOptions: { show: { - resource:[ - 'member', - ], - operation: [ - 'getAll', - ], + resource: ['member'], + operation: ['getAll'], }, }, options: [ @@ -908,7 +801,8 @@ export class Mailchimp implements INodeType { name: 'beforeLastChanged', type: 'dateTime', default: '', - description: 'Restrict results to subscribers whose information changed before the set timeframe', + description: + 'Restrict results to subscribers whose information changed before the set timeframe', }, { displayName: 'Before Timestamp Opt', @@ -975,20 +869,21 @@ export class Mailchimp implements INodeType { }, ], default: '', - description: 'Subscriber\'s current status', + description: "Subscriber's current status", }, { displayName: 'Since Last Changed', name: 'sinceLastChanged', type: 'dateTime', default: '', - description: 'Restrict results to subscribers whose information changed after the set timeframe', + description: + 'Restrict results to subscribers whose information changed after the set timeframe', }, ], }, -/* -------------------------------------------------------------------------- */ -/* member:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* member:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'List Name or ID', name: 'list', @@ -998,18 +893,15 @@ export class Mailchimp implements INodeType { }, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'update', - ], + resource: ['member'], + operation: ['update'], }, }, default: '', options: [], required: true, - description: 'List of lists. Choose from the list, or specify an ID using an expression.', + description: + 'List of lists. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Email', @@ -1019,12 +911,8 @@ export class Mailchimp implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'update', - ], + resource: ['member'], + operation: ['update'], }, }, default: '', @@ -1037,12 +925,8 @@ export class Mailchimp implements INodeType { default: false, displayOptions: { show: { - resource:[ - 'member', - ], - operation: [ - 'update', - ], + resource: ['member'], + operation: ['update'], }, }, }, @@ -1054,12 +938,8 @@ export class Mailchimp implements INodeType { default: {}, displayOptions: { show: { - resource:[ - 'member', - ], - operation: [ - 'update', - ], + resource: ['member'], + operation: ['update'], }, }, options: [ @@ -1091,15 +971,9 @@ export class Mailchimp implements INodeType { }, displayOptions: { show: { - '/resource':[ - 'member', - ], - '/operation':[ - 'update', - ], - '/jsonParameters': [ - false, - ], + '/resource': ['member'], + '/operation': ['update'], + '/jsonParameters': [false], }, }, options: [ @@ -1114,12 +988,11 @@ export class Mailchimp implements INodeType { displayName: 'Category Name or ID', name: 'categoryId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getGroupCategories', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, default: '', }, @@ -1144,7 +1017,7 @@ export class Mailchimp implements INodeType { name: 'language', type: 'string', default: '', - description: 'If set/detected, the subscriber\'s language', + description: "If set/detected, the subscriber's language", }, { displayName: 'Merge Fields', @@ -1157,15 +1030,9 @@ export class Mailchimp implements INodeType { }, displayOptions: { show: { - '/resource':[ - 'member', - ], - '/operation':[ - 'update', - ], - '/jsonParameters': [ - false, - ], + '/resource': ['member'], + '/operation': ['update'], + '/jsonParameters': [false], }, }, description: 'An individual merge var and value for a member', @@ -1183,12 +1050,11 @@ export class Mailchimp implements INodeType { type: 'options', typeOptions: { loadOptionsMethod: 'getMergeFields', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, required: true, - description: 'Merge Field name. Choose from the list, or specify an ID using an expression.', + description: + 'Merge Field name. Choose from the list, or specify an ID using an expression.', default: '', }, { @@ -1222,14 +1088,16 @@ export class Mailchimp implements INodeType { name: 'timestampSignup', type: 'dateTime', default: '', - description: 'The date and time the subscriber signed up for the list in ISO 8601 format', + description: + 'The date and time the subscriber signed up for the list in ISO 8601 format', }, { displayName: 'Skip Merge Validation', name: 'skipMergeValidation', type: 'boolean', default: false, - description: 'Whether member data will be accepted without merge field values, even if the merge field is usually required', + description: + 'Whether member data will be accepted without merge field values, even if the merge field is usually required', }, { displayName: 'Status', @@ -1258,7 +1126,7 @@ export class Mailchimp implements INodeType { }, ], default: '', - description: 'Subscriber\'s current status', + description: "Subscriber's current status", }, { displayName: 'Vip', @@ -1277,15 +1145,9 @@ export class Mailchimp implements INodeType { description: 'Subscriber location information.n', displayOptions: { show: { - '/resource':[ - 'member', - ], - '/operation':[ - 'update', - ], - '/jsonParameters': [ - false, - ], + '/resource': ['member'], + '/operation': ['update'], + '/jsonParameters': [false], }, }, options: [ @@ -1318,7 +1180,8 @@ export class Mailchimp implements INodeType { name: 'timestampOpt', type: 'dateTime', default: '', - description: 'The date and time the subscribe confirmed their opt-in status in ISO 8601 format', + description: + 'The date and time the subscribe confirmed their opt-in status in ISO 8601 format', }, ], }, @@ -1332,15 +1195,9 @@ export class Mailchimp implements INodeType { default: '', displayOptions: { show: { - resource:[ - 'member', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['member'], + operation: ['update'], + jsonParameters: [true], }, }, }, @@ -1354,15 +1211,9 @@ export class Mailchimp implements INodeType { default: '', displayOptions: { show: { - resource:[ - 'member', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['member'], + operation: ['update'], + jsonParameters: [true], }, }, }, @@ -1376,21 +1227,15 @@ export class Mailchimp implements INodeType { default: '', displayOptions: { show: { - resource:[ - 'member', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['member'], + operation: ['update'], + jsonParameters: [true], }, }, }, -/* -------------------------------------------------------------------------- */ -/* memberTag:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* memberTag:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'List Name or ID', name: 'list', @@ -1400,19 +1245,15 @@ export class Mailchimp implements INodeType { }, displayOptions: { show: { - resource: [ - 'memberTag', - ], - operation: [ - 'create', - 'delete', - ], + resource: ['memberTag'], + operation: ['create', 'delete'], }, }, default: '', options: [], required: true, - description: 'List of lists. Choose from the list, or specify an ID using an expression.', + description: + 'List of lists. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Email', @@ -1422,13 +1263,8 @@ export class Mailchimp implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'memberTag', - ], - operation: [ - 'create', - 'delete', - ], + resource: ['memberTag'], + operation: ['create', 'delete'], }, }, default: '', @@ -1444,13 +1280,8 @@ export class Mailchimp implements INodeType { }, displayOptions: { show: { - resource:[ - 'memberTag', - ], - operation: [ - 'create', - 'delete', - ], + resource: ['memberTag'], + operation: ['create', 'delete'], }, }, default: [], @@ -1463,13 +1294,8 @@ export class Mailchimp implements INodeType { default: {}, displayOptions: { show: { - resource:[ - 'memberTag', - ], - operation: [ - 'create', - 'delete', - ], + resource: ['memberTag'], + operation: ['create', 'delete'], }, }, options: [ @@ -1482,9 +1308,9 @@ export class Mailchimp implements INodeType { }, ], }, -/* -------------------------------------------------------------------------- */ -/* member:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* member:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'List Name or ID', name: 'list', @@ -1494,38 +1320,30 @@ export class Mailchimp implements INodeType { }, displayOptions: { show: { - resource: [ - 'listGroup', - ], - operation: [ - 'getAll', - ], + resource: ['listGroup'], + operation: ['getAll'], }, }, default: '', options: [], required: true, - description: 'List of lists. Choose from the list, or specify an ID using an expression.', + description: + 'List of lists. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Group Category Name or ID', name: 'groupCategory', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getGroupCategories', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, displayOptions: { show: { - resource: [ - 'listGroup', - ], - operation: [ - 'getAll', - ], + resource: ['listGroup'], + operation: ['getAll'], }, }, default: '', @@ -1538,12 +1356,8 @@ export class Mailchimp implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'listGroup', - ], - operation: [ - 'getAll', - ], + resource: ['listGroup'], + operation: ['getAll'], }, }, default: false, @@ -1555,15 +1369,9 @@ export class Mailchimp implements INodeType { type: 'number', displayOptions: { show: { - resource: [ - 'listGroup', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['listGroup'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -1573,21 +1381,17 @@ export class Mailchimp implements INodeType { default: 500, description: 'Max number of results to return', }, -/* -------------------------------------------------------------------------- */ -/* campaign:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* campaign:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'getAll', - ], + resource: ['campaign'], + operation: ['getAll'], }, }, default: false, @@ -1599,15 +1403,9 @@ export class Mailchimp implements INodeType { type: 'number', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['campaign'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -1625,12 +1423,8 @@ export class Mailchimp implements INodeType { default: {}, displayOptions: { show: { - resource:[ - 'campaign', - ], - operation: [ - 'getAll', - ], + resource: ['campaign'], + operation: ['getAll'], }, }, options: [ @@ -1656,7 +1450,8 @@ export class Mailchimp implements INodeType { loadOptionsMethod: 'getCampaignsFields', }, default: [], - description: 'A comma-separated list of fields to exclude. Choose from the list, or specify IDs using an expression.', + description: + 'A comma-separated list of fields to exclude. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Field Names or IDs', @@ -1673,7 +1468,8 @@ export class Mailchimp implements INodeType { 'campaigns.settings.reply_to', 'campaigns.settings.title', ], - description: 'A comma-separated list of fields to return. Choose from the list, or specify IDs using an expression.', + description: + 'A comma-separated list of fields to return. Choose from the list, or specify IDs using an expression.', }, { displayName: 'List Name or ID', @@ -1683,7 +1479,8 @@ export class Mailchimp implements INodeType { loadOptionsMethod: 'getLists', }, default: '', - description: 'List of lists. Choose from the list, or specify an ID using an expression.', + description: + 'List of lists. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Since Create Time', @@ -1760,39 +1557,29 @@ export class Mailchimp implements INodeType { }, ], }, -/* -------------------------------------------------------------------------- */ -/* campaign:send */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* campaign:send */ + /* -------------------------------------------------------------------------- */ { displayName: 'Campaign ID', name: 'campaignId', type: 'string', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'send', - 'get', - 'delete', - 'replicate', - 'resend', - ], + resource: ['campaign'], + operation: ['send', 'get', 'delete', 'replicate', 'resend'], }, }, required: true, default: '', description: 'List of Campaigns', - options:[], + options: [], }, ], }; - methods = { loadOptions: { - // Get all the available lists to display them to user so that he can // select them easily async getLists(this: ILoadOptionsFunctions): Promise { @@ -1814,7 +1601,11 @@ export class Mailchimp implements INodeType { async getMergeFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const listId = this.getCurrentNodeParameter('list'); - const { merge_fields } = await mailchimpApiRequest.call(this, `/lists/${listId}/merge-fields`, 'GET'); + const { merge_fields } = await mailchimpApiRequest.call( + this, + `/lists/${listId}/merge-fields`, + 'GET', + ); for (const mergeField of merge_fields) { const mergeFieldName = mergeField.name; const mergeFieldId = mergeField.tag; @@ -1831,7 +1622,11 @@ export class Mailchimp implements INodeType { async getGroupCategories(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const listId = this.getCurrentNodeParameter('list'); - const { categories } = await mailchimpApiRequest.call(this, `/lists/${listId}/interest-categories`, 'GET'); + const { categories } = await mailchimpApiRequest.call( + this, + `/lists/${listId}/interest-categories`, + 'GET', + ); for (const category of categories) { const categoryName = category.title; const categoryId = category.id; @@ -1846,7 +1641,12 @@ export class Mailchimp implements INodeType { // Get all the available campaigns to display them to users so that they can select them easily async getCampaigns(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const campaigns = await mailchimpApiRequestAllItems.call(this, '/campaigns', 'GET', 'campaigns'); + const campaigns = await mailchimpApiRequestAllItems.call( + this, + '/campaigns', + 'GET', + 'campaigns', + ); for (const campaign of campaigns) { const campaignName = campaign.settings.title; const campaignId = campaign.id; @@ -1891,10 +1691,23 @@ export class Mailchimp implements INodeType { const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll === true) { - responseData = await mailchimpApiRequestAllItems.call(this, `/lists/${listId}/interest-categories/${categoryId}/interests`, 'GET', 'interests', {}, qs); + responseData = await mailchimpApiRequestAllItems.call( + this, + `/lists/${listId}/interest-categories/${categoryId}/interests`, + 'GET', + 'interests', + {}, + qs, + ); } else { qs.count = this.getNodeParameter('limit', i) as number; - responseData = await mailchimpApiRequest.call(this, `/lists/${listId}/interest-categories/${categoryId}/interests`, 'GET', {}, qs); + responseData = await mailchimpApiRequest.call( + this, + `/lists/${listId}/interest-categories/${categoryId}/interests`, + 'GET', + {}, + qs, + ); responseData = responseData.interests; } } @@ -1929,17 +1742,22 @@ export class Mailchimp implements INodeType { body.ip_opt = options.ipOptIn as string; } if (options.timestampOpt) { - body.timestamp_opt = moment(options.timestampOpt as string).format('YYYY-MM-DD HH:MM:SS') as string; + body.timestamp_opt = moment(options.timestampOpt as string).format( + 'YYYY-MM-DD HH:MM:SS', + ) as string; } if (options.timestampSignup) { - body.timestamp_signup = moment(options.timestampSignup as string).format('YYYY-MM-DD HH:MM:SS') as string; + body.timestamp_signup = moment(options.timestampSignup as string).format( + 'YYYY-MM-DD HH:MM:SS', + ) as string; } if (options.tags) { // @ts-ignore body.tags = options.tags.split(',') as string[]; } if (!jsonActive) { - const locationValues = (this.getNodeParameter('locationFieldsUi', i) as IDataObject).locationFieldsValues as IDataObject; + const locationValues = (this.getNodeParameter('locationFieldsUi', i) as IDataObject) + .locationFieldsValues as IDataObject; if (locationValues) { const location: ILocation = {}; for (const key of Object.keys(locationValues)) { @@ -1951,7 +1769,8 @@ export class Mailchimp implements INodeType { } body.location = location; } - const mergeFieldsValues = (this.getNodeParameter('mergeFieldsUi', i) as IDataObject).mergeFieldsValues as IDataObject[]; + const mergeFieldsValues = (this.getNodeParameter('mergeFieldsUi', i) as IDataObject) + .mergeFieldsValues as IDataObject[]; if (mergeFieldsValues) { const mergeFields = {}; for (let i = 0; i < mergeFieldsValues.length; i++) { @@ -1961,7 +1780,8 @@ export class Mailchimp implements INodeType { body.merge_fields = mergeFields; } - const groupsValues = (this.getNodeParameter('groupsUi', i) as IDataObject).groupsValues as IDataObject[]; + const groupsValues = (this.getNodeParameter('groupsUi', i) as IDataObject) + .groupsValues as IDataObject[]; if (groupsValues) { const groups = {}; for (let i = 0; i < groupsValues.length; i++) { @@ -1972,7 +1792,9 @@ export class Mailchimp implements INodeType { } } else { const locationJson = validateJSON(this.getNodeParameter('locationJson', i) as string); - const mergeFieldsJson = validateJSON(this.getNodeParameter('mergeFieldsJson', i) as string); + const mergeFieldsJson = validateJSON( + this.getNodeParameter('mergeFieldsJson', i) as string, + ); const groupJson = validateJSON(this.getNodeParameter('groupJson', i) as string); if (locationJson) { body.location = locationJson; @@ -1984,20 +1806,27 @@ export class Mailchimp implements INodeType { body.interests = groupJson; } } - responseData = await mailchimpApiRequest.call(this, `/lists/${listId}/members`, 'POST', body); + responseData = await mailchimpApiRequest.call( + this, + `/lists/${listId}/members`, + 'POST', + body, + ); } //https://mailchimp.com/developer/reference/lists/list-members/ if (operation === 'delete') { - const listId = this.getNodeParameter('list', i) as string; const email = this.getNodeParameter('email', i) as string; - responseData = await mailchimpApiRequest.call(this, `/lists/${listId}/members/${email}/actions/delete-permanent`, 'POST'); + responseData = await mailchimpApiRequest.call( + this, + `/lists/${listId}/members/${email}/actions/delete-permanent`, + 'POST', + ); responseData = { success: true }; } //https://mailchimp.com/developer/reference/lists/list-members/#get_/lists/-list_id-/members/-subscriber_hash- if (operation === 'get') { - const listId = this.getNodeParameter('list', i) as string; const email = this.getNodeParameter('email', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; @@ -2010,7 +1839,13 @@ export class Mailchimp implements INodeType { qs.exclude_fields = options.excludeFields as string; } - responseData = await mailchimpApiRequest.call(this, `/lists/${listId}/members/${email}`, 'GET', {}, qs); + responseData = await mailchimpApiRequest.call( + this, + `/lists/${listId}/members/${email}`, + 'GET', + {}, + qs, + ); } //https://mailchimp.com/developer/reference/lists/list-members/#get_/lists/-list_id-/members if (operation === 'getAll') { @@ -2044,16 +1879,28 @@ export class Mailchimp implements INodeType { qs.since_last_changed = options.sinceLastChanged as string; } if (returnAll === true) { - responseData = await mailchimpApiRequestAllItems.call(this, `/lists/${listId}/members`, 'GET', 'members', {}, qs); + responseData = await mailchimpApiRequestAllItems.call( + this, + `/lists/${listId}/members`, + 'GET', + 'members', + {}, + qs, + ); } else { qs.count = this.getNodeParameter('limit', i) as number; - responseData = await mailchimpApiRequest.call(this, `/lists/${listId}/members`, 'GET', {}, qs); + responseData = await mailchimpApiRequest.call( + this, + `/lists/${listId}/members`, + 'GET', + {}, + qs, + ); responseData = responseData.members; } } //https://mailchimp.com/developer/reference/lists/list-members/#put_/lists/-list_id-/members/-subscriber_hash- if (operation === 'update') { - const listId = this.getNodeParameter('list', i) as string; const email = this.getNodeParameter('email', i) as string; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; @@ -2084,14 +1931,19 @@ export class Mailchimp implements INodeType { body.ip_opt = updateFields.ipOptIn as string; } if (updateFields.timestampOpt) { - body.timestamp_opt = moment(updateFields.timestampOpt as string).format('YYYY-MM-DD HH:MM:SS') as string; + body.timestamp_opt = moment(updateFields.timestampOpt as string).format( + 'YYYY-MM-DD HH:MM:SS', + ) as string; } if (updateFields.timestampSignup) { - body.timestamp_signup = moment(updateFields.timestampSignup as string).format('YYYY-MM-DD HH:MM:SS') as string; + body.timestamp_signup = moment(updateFields.timestampSignup as string).format( + 'YYYY-MM-DD HH:MM:SS', + ) as string; } if (!jsonActive) { if (updateFields.locationFieldsUi) { - const locationValues = (updateFields.locationFieldsUi as IDataObject).locationFieldsValues as IDataObject; + const locationValues = (updateFields.locationFieldsUi as IDataObject) + .locationFieldsValues as IDataObject; if (locationValues) { const location: ILocation = {}; for (const key of Object.keys(locationValues)) { @@ -2105,7 +1957,8 @@ export class Mailchimp implements INodeType { } } if (updateFields.mergeFieldsUi) { - const mergeFieldsValues = (updateFields.mergeFieldsUi as IDataObject).mergeFieldsValues as IDataObject[]; + const mergeFieldsValues = (updateFields.mergeFieldsUi as IDataObject) + .mergeFieldsValues as IDataObject[]; if (mergeFieldsValues) { const mergeFields = {}; for (let i = 0; i < mergeFieldsValues.length; i++) { @@ -2116,7 +1969,8 @@ export class Mailchimp implements INodeType { } } if (updateFields.groupsUi) { - const groupsValues = (updateFields.groupsUi as IDataObject).groupsValues as IDataObject[]; + const groupsValues = (updateFields.groupsUi as IDataObject) + .groupsValues as IDataObject[]; if (groupsValues) { const groups = {}; for (let i = 0; i < groupsValues.length; i++) { @@ -2128,7 +1982,9 @@ export class Mailchimp implements INodeType { } } else { const locationJson = validateJSON(this.getNodeParameter('locationJson', i) as string); - const mergeFieldsJson = validateJSON(this.getNodeParameter('mergeFieldsJson', i) as string); + const mergeFieldsJson = validateJSON( + this.getNodeParameter('mergeFieldsJson', i) as string, + ); const groupJson = validateJSON(this.getNodeParameter('groupJson', i) as string); if (locationJson) { @@ -2141,11 +1997,16 @@ export class Mailchimp implements INodeType { body.interests = groupJson; } } - responseData = await mailchimpApiRequest.call(this, `/lists/${listId}/members/${email}`, 'PUT', body); + responseData = await mailchimpApiRequest.call( + this, + `/lists/${listId}/members/${email}`, + 'PUT', + body, + ); } } if (resource === 'memberTag') { - //https://mailchimp.com/developer/reference/lists/list-members/list-member-tags/#post_/lists/-list_id-/members/-subscriber_hash-/tags + //https://mailchimp.com/developer/reference/lists/list-members/list-member-tags/#post_/lists/-list_id-/members/-subscriber_hash-/tags if (operation === 'create') { const listId = this.getNodeParameter('list', i) as string; const email = this.getNodeParameter('email', i) as string; @@ -2168,12 +2029,16 @@ export class Mailchimp implements INodeType { }); } - responseData = await mailchimpApiRequest.call(this, `/lists/${listId}/members/${email}/tags`, 'POST', body); + responseData = await mailchimpApiRequest.call( + this, + `/lists/${listId}/members/${email}/tags`, + 'POST', + body, + ); responseData = { success: true }; } - //https://mailchimp.com/developer/reference/lists/list-members/list-member-tags/#post_/lists/-list_id-/members/-subscriber_hash-/tags + //https://mailchimp.com/developer/reference/lists/list-members/list-member-tags/#post_/lists/-list_id-/members/-subscriber_hash-/tags if (operation === 'delete') { - const listId = this.getNodeParameter('list', i) as string; const email = this.getNodeParameter('email', i) as string; const tags = this.getNodeParameter('tags', i) as string[]; @@ -2194,7 +2059,12 @@ export class Mailchimp implements INodeType { status: 'inactive', }); } - responseData = await mailchimpApiRequest.call(this, `/lists/${listId}/members/${email}/tags`, 'POST', body); + responseData = await mailchimpApiRequest.call( + this, + `/lists/${listId}/members/${email}/tags`, + 'POST', + body, + ); responseData = { success: true }; } } @@ -2247,7 +2117,14 @@ export class Mailchimp implements INodeType { qs.sort_field = options.sortField as string; } if (returnAll === true) { - responseData = await mailchimpApiRequestAllItems.call(this, `/campaigns`, 'GET', 'campaigns', {}, qs); + responseData = await mailchimpApiRequestAllItems.call( + this, + `/campaigns`, + 'GET', + 'campaigns', + {}, + qs, + ); } else { qs.count = this.getNodeParameter('limit', i) as number; responseData = await mailchimpApiRequest.call(this, `/campaigns`, 'GET', {}, qs); @@ -2257,29 +2134,54 @@ export class Mailchimp implements INodeType { //https://mailchimp.com/developer/api/marketing/campaigns/send-campaign/ if (operation === 'send') { const campaignId = this.getNodeParameter('campaignId', i) as string; - responseData = await mailchimpApiRequest.call(this, `/campaigns/${campaignId}/actions/send`, 'POST', {}); + responseData = await mailchimpApiRequest.call( + this, + `/campaigns/${campaignId}/actions/send`, + 'POST', + {}, + ); responseData = { success: true }; } //https://mailchimp.com/developer/api/marketing/campaigns/get-campaign-info/ if (operation === 'get') { const campaignId = this.getNodeParameter('campaignId', i) as string; - responseData = await mailchimpApiRequest.call(this, `/campaigns/${campaignId}`, 'GET', {}); + responseData = await mailchimpApiRequest.call( + this, + `/campaigns/${campaignId}`, + 'GET', + {}, + ); } //https://mailchimp.com/developer/api/marketing/campaigns/delete-campaign/ if (operation === 'delete') { const campaignId = this.getNodeParameter('campaignId', i) as string; - responseData = await mailchimpApiRequest.call(this, `/campaigns/${campaignId}`, 'DELETE', {}); + responseData = await mailchimpApiRequest.call( + this, + `/campaigns/${campaignId}`, + 'DELETE', + {}, + ); responseData = { success: true }; } //https://mailchimp.com/developer/api/marketing/campaigns/replicate-campaign/ if (operation === 'replicate') { const campaignId = this.getNodeParameter('campaignId', i) as string; - responseData = await mailchimpApiRequest.call(this, `/campaigns/${campaignId}/actions/replicate`, 'POST', {}); + responseData = await mailchimpApiRequest.call( + this, + `/campaigns/${campaignId}/actions/replicate`, + 'POST', + {}, + ); } //https://mailchimp.com/developer/api/marketing/campaigns/resend-campaign/ if (operation === 'resend') { const campaignId = this.getNodeParameter('campaignId', i) as string; - responseData = await mailchimpApiRequest.call(this, `/campaigns/${campaignId}/actions/create-resend`, 'POST', {}); + responseData = await mailchimpApiRequest.call( + this, + `/campaigns/${campaignId}/actions/create-resend`, + 'POST', + {}, + ); } } diff --git a/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts b/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts index 5e7115e72a..6cdc52ce0d 100644 --- a/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts +++ b/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -13,9 +10,7 @@ import { NodeApiError, NodeOperationError, } from 'n8n-workflow'; -import { - mailchimpApiRequest, -} from './GenericFunctions'; +import { mailchimpApiRequest } from './GenericFunctions'; export class MailchimpTrigger implements INodeType { description: INodeTypeDescription = { @@ -36,9 +31,7 @@ export class MailchimpTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'apiKey', - ], + authentication: ['apiKey'], }, }, }, @@ -47,9 +40,7 @@ export class MailchimpTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -91,7 +82,8 @@ export class MailchimpTrigger implements INodeType { type: 'options', required: true, default: '', - description: 'The list that is gonna fire the event. Choose from the list, or specify an ID using an expression.', + description: + 'The list that is gonna fire the event. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getLists', }, @@ -113,17 +105,19 @@ export class MailchimpTrigger implements INodeType { { name: 'Cleaned', value: 'cleaned', - description: 'Whether the webhook is triggered when a subscriber\'s email address is cleaned from the list', + description: + "Whether the webhook is triggered when a subscriber's email address is cleaned from the list", }, { name: 'Email Address Updated', value: 'upemail', - description: 'Whether the webhook is triggered when a subscriber\'s email address is changed', + description: + "Whether the webhook is triggered when a subscriber's email address is changed", }, { name: 'Profile Updated', value: 'profile', - description: 'Whether the webhook is triggered when a subscriber\'s profile is updated', + description: "Whether the webhook is triggered when a subscriber's profile is updated", }, { name: 'Subscribe', @@ -143,7 +137,8 @@ export class MailchimpTrigger implements INodeType { type: 'multiOptions', required: true, default: [], - description: 'The possible sources of any events that can trigger the webhook and whether they are enabled', + description: + 'The possible sources of any events that can trigger the webhook and whether they are enabled', options: [ { name: 'User', @@ -153,7 +148,8 @@ export class MailchimpTrigger implements INodeType { { name: 'Admin', value: 'admin', - description: 'Whether the webhook is triggered by admin-initiated actions in the web interface', + description: + 'Whether the webhook is triggered by admin-initiated actions in the web interface', }, { name: 'API', @@ -283,16 +279,17 @@ export class MailchimpTrigger implements INodeType { if (req.body.id !== webhookData.id) { return {}; } - // @ts-ignore - if (!webhookData.events.includes(req.body.type) + + if ( // @ts-ignore - && !webhookData.sources.includes(req.body.type)) { + !webhookData.events.includes(req.body.type) && + // @ts-ignore + !webhookData.sources.includes(req.body.type) + ) { return {}; } return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/MailerLite/GenericFunctions.ts b/packages/nodes-base/nodes/MailerLite/GenericFunctions.ts index a9ef546ab5..bc9002ee55 100644 --- a/packages/nodes-base/nodes/MailerLite/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MailerLite/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,12 +7,18 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; - -export async function mailerliteApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, option = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError } from 'n8n-workflow'; +export async function mailerliteApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, + method: string, + path: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + option = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('mailerLiteApi'); const options: OptionsWithUri = { @@ -38,7 +42,15 @@ export async function mailerliteApiRequest(this: IExecuteFunctions | IExecuteSin } } -export async function mailerliteApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function mailerliteApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -50,8 +62,6 @@ export async function mailerliteApiRequestAllItems(this: IExecuteFunctions | ILo responseData = await mailerliteApiRequest.call(this, method, endpoint, body, query); returnData.push.apply(returnData, responseData); query.offset = query.offset + query.limit; - } while ( - responseData.length !== 0 - ); + } while (responseData.length !== 0); return returnData; } diff --git a/packages/nodes-base/nodes/MailerLite/MailerLite.node.ts b/packages/nodes-base/nodes/MailerLite/MailerLite.node.ts index 3162a4f52d..1e10572d41 100644 --- a/packages/nodes-base/nodes/MailerLite/MailerLite.node.ts +++ b/packages/nodes-base/nodes/MailerLite/MailerLite.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,15 +9,9 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - mailerliteApiRequest, - mailerliteApiRequestAllItems, -} from './GenericFunctions'; +import { mailerliteApiRequest, mailerliteApiRequestAllItems } from './GenericFunctions'; -import { - subscriberFields, - subscriberOperations, -} from './SubscriberDescription'; +import { subscriberFields, subscriberOperations } from './SubscriberDescription'; export class MailerLite implements INodeType { description: INodeTypeDescription = { @@ -104,7 +96,8 @@ export class MailerLite implements INodeType { Object.assign(body, additionalFields); if (additionalFields.customFieldsUi) { - const customFieldsValues = (additionalFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFieldsValues = (additionalFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFieldsValues) { const fields = {}; @@ -125,7 +118,11 @@ export class MailerLite implements INodeType { if (operation === 'get') { const subscriberId = this.getNodeParameter('subscriberId', i) as string; - responseData = await mailerliteApiRequest.call(this, 'GET', `/subscribers/${subscriberId}`); + responseData = await mailerliteApiRequest.call( + this, + 'GET', + `/subscribers/${subscriberId}`, + ); } //https://developers.mailerlite.com/reference#subscribers if (operation === 'getAll') { @@ -136,8 +133,13 @@ export class MailerLite implements INodeType { Object.assign(qs, filters); if (returnAll) { - - responseData = await mailerliteApiRequestAllItems.call(this, 'GET', `/subscribers`, {}, qs); + responseData = await mailerliteApiRequestAllItems.call( + this, + 'GET', + `/subscribers`, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; @@ -155,7 +157,8 @@ export class MailerLite implements INodeType { Object.assign(body, updateFields); if (updateFields.customFieldsUi) { - const customFieldsValues = (updateFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFieldsValues = (updateFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFieldsValues) { const fields = {}; @@ -170,7 +173,12 @@ export class MailerLite implements INodeType { } } - responseData = await mailerliteApiRequest.call(this, 'PUT', `/subscribers/${subscriberId}`, body); + responseData = await mailerliteApiRequest.call( + this, + 'PUT', + `/subscribers/${subscriberId}`, + body, + ); } } } catch (error) { @@ -183,7 +191,6 @@ export class MailerLite implements INodeType { } if (Array.isArray(responseData)) { returnData.push.apply(returnData, responseData as IDataObject[]); - } else if (responseData !== undefined) { returnData.push(responseData as IDataObject); } diff --git a/packages/nodes-base/nodes/MailerLite/MailerLiteTrigger.node.ts b/packages/nodes-base/nodes/MailerLite/MailerLiteTrigger.node.ts index 1ae79ef5f5..f9157531dc 100644 --- a/packages/nodes-base/nodes/MailerLite/MailerLiteTrigger.node.ts +++ b/packages/nodes-base/nodes/MailerLite/MailerLiteTrigger.node.ts @@ -1,18 +1,8 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import { - IDataObject, - INodeType, - INodeTypeDescription, - IWebhookResponseData, -} from 'n8n-workflow'; +import { IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; -import { - mailerliteApiRequest, -} from './GenericFunctions'; +import { mailerliteApiRequest } from './GenericFunctions'; export class MailerLiteTrigger implements INodeType { description: INodeTypeDescription = { @@ -101,7 +91,7 @@ export class MailerLiteTrigger implements INodeType { { name: 'Subscriber Updated', value: 'subscriber.update', - description: 'Fired when any of the subscriber\'s custom fields are updated', + description: "Fired when any of the subscriber's custom fields are updated", }, ], required: true, @@ -123,8 +113,7 @@ export class MailerLiteTrigger implements INodeType { const endpoint = '/webhooks'; const { webhooks } = await mailerliteApiRequest.call(this, 'GET', endpoint, {}); for (const webhook of webhooks) { - if (webhook.url === webhookUrl && - webhook.event === event) { + if (webhook.url === webhookUrl && webhook.event === event) { // Set webhook-id to be sure that it can be deleted webhookData.webhookId = webhook.id as string; return true; @@ -157,7 +146,6 @@ export class MailerLiteTrigger implements INodeType { async delete(this: IHookFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); if (webhookData.webhookId !== undefined) { - const endpoint = `/webhooks/${webhookData.webhookId}`; try { @@ -181,9 +169,7 @@ export class MailerLiteTrigger implements INodeType { const events = body.events as IDataObject[]; return { - workflowData: [ - this.helpers.returnJsonArray(events), - ], + workflowData: [this.helpers.returnJsonArray(events)], }; } } diff --git a/packages/nodes-base/nodes/MailerLite/SubscriberDescription.ts b/packages/nodes-base/nodes/MailerLite/SubscriberDescription.ts index d30bb6b326..8667a611c0 100644 --- a/packages/nodes-base/nodes/MailerLite/SubscriberDescription.ts +++ b/packages/nodes-base/nodes/MailerLite/SubscriberDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const subscriberOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const subscriberOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'subscriber', - ], + resource: ['subscriber'], }, }, options: [ @@ -46,7 +42,6 @@ export const subscriberOperations: INodeProperties[] = [ ]; export const subscriberFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* subscriber:create */ /* -------------------------------------------------------------------------- */ @@ -59,12 +54,8 @@ export const subscriberFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'create', - ], + resource: ['subscriber'], + operation: ['create'], }, }, description: 'Email of new subscriber', @@ -77,12 +68,8 @@ export const subscriberFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'create', - ], + resource: ['subscriber'], + operation: ['create'], }, }, options: [ @@ -121,7 +108,8 @@ export const subscriberFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -192,12 +180,8 @@ export const subscriberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'update', - ], + resource: ['subscriber'], + operation: ['update'], }, }, default: '', @@ -211,12 +195,8 @@ export const subscriberFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'update', - ], + resource: ['subscriber'], + operation: ['update'], }, }, options: [ @@ -243,7 +223,8 @@ export const subscriberFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -302,12 +283,8 @@ export const subscriberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'delete', - ], + resource: ['subscriber'], + operation: ['delete'], }, }, default: '', @@ -324,12 +301,8 @@ export const subscriberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'get', - ], + resource: ['subscriber'], + operation: ['get'], }, }, default: '', @@ -344,12 +317,8 @@ export const subscriberFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'getAll', - ], + resource: ['subscriber'], + operation: ['getAll'], }, }, default: false, @@ -361,15 +330,9 @@ export const subscriberFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['subscriber'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -386,12 +349,8 @@ export const subscriberFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'subscriber', - ], + operation: ['getAll'], + resource: ['subscriber'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts b/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts index 9a191ee9e0..77c82dfc1f 100644 --- a/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts +++ b/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts @@ -8,7 +8,6 @@ import { NodeOperationError, } from 'n8n-workflow'; - export class Mailgun implements INodeType { description: INodeTypeDescription = { displayName: 'Mailgun', @@ -97,12 +96,12 @@ export class Mailgun implements INodeType { name: 'attachments', type: 'string', default: '', - description: 'Name of the binary properties which contain data which should be added to email as attachment. Multiple ones can be comma-separated.', + description: + 'Name of the binary properties which contain data which should be added to email as attachment. Multiple ones can be comma-separated.', }, ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); @@ -141,22 +140,25 @@ export class Mailgun implements INodeType { } if (attachmentPropertyString && item.binary) { - const attachments = []; - const attachmentProperties: string[] = attachmentPropertyString.split(',').map((propertyName) => { - return propertyName.trim(); - }); + const attachmentProperties: string[] = attachmentPropertyString + .split(',') + .map((propertyName) => { + return propertyName.trim(); + }); for (const propertyName of attachmentProperties) { if (!item.binary.hasOwnProperty(propertyName)) { continue; } - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, propertyName); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + itemIndex, + propertyName, + ); attachments.push({ value: binaryDataBuffer, options: { filename: item.binary[propertyName].fileName || 'unknown', - }, }); } diff --git a/packages/nodes-base/nodes/Mailjet/EmailDescription.ts b/packages/nodes-base/nodes/Mailjet/EmailDescription.ts index 87eb3943fc..a3f2534592 100644 --- a/packages/nodes-base/nodes/Mailjet/EmailDescription.ts +++ b/packages/nodes-base/nodes/Mailjet/EmailDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const emailOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const emailOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'email', - ], + resource: ['email'], }, }, options: [ @@ -34,7 +30,6 @@ export const emailOperations: INodeProperties[] = [ ]; export const emailFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* email:send */ /* -------------------------------------------------------------------------- */ @@ -46,12 +41,8 @@ export const emailFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'send', - ], + resource: ['email'], + operation: ['send'], }, }, placeholder: 'admin@example.com', @@ -67,12 +58,8 @@ export const emailFields: INodeProperties[] = [ description: 'Email address of the recipient. Multiple ones can be separated by comma.', displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'send', - ], + resource: ['email'], + operation: ['send'], }, }, }, @@ -93,12 +80,8 @@ export const emailFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'send', - ], + resource: ['email'], + operation: ['send'], }, }, default: '', @@ -113,12 +96,8 @@ export const emailFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'send', - ], + resource: ['email'], + operation: ['send'], }, }, default: '', @@ -131,12 +110,8 @@ export const emailFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'send', - ], + resource: ['email'], + operation: ['send'], }, }, }, @@ -148,12 +123,8 @@ export const emailFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'send', - ], + resource: ['email'], + operation: ['send'], }, }, options: [ @@ -255,15 +226,9 @@ export const emailFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'send', - ], - jsonParameters: [ - true, - ], + resource: ['email'], + operation: ['send'], + jsonParameters: [true], }, }, default: '', @@ -278,15 +243,9 @@ export const emailFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'send', - ], - jsonParameters: [ - false, - ], + resource: ['email'], + operation: ['send'], + jsonParameters: [false], }, }, placeholder: 'Add Variable', @@ -323,12 +282,8 @@ export const emailFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'sendTemplate', - ], + resource: ['email'], + operation: ['sendTemplate'], }, }, placeholder: 'admin@example.com', @@ -344,12 +299,8 @@ export const emailFields: INodeProperties[] = [ description: 'Email address of the recipient. Multiple ones can be separated by comma.', displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'sendTemplate', - ], + resource: ['email'], + operation: ['sendTemplate'], }, }, }, @@ -357,7 +308,8 @@ export const emailFields: INodeProperties[] = [ displayName: 'Template Name or ID', name: 'templateId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTemplates', }, @@ -365,12 +317,8 @@ export const emailFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'sendTemplate', - ], + resource: ['email'], + operation: ['sendTemplate'], }, }, }, @@ -381,12 +329,8 @@ export const emailFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'sendTemplate', - ], + resource: ['email'], + operation: ['sendTemplate'], }, }, }, @@ -398,12 +342,8 @@ export const emailFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'sendTemplate', - ], + resource: ['email'], + operation: ['sendTemplate'], }, }, options: [ @@ -477,15 +417,9 @@ export const emailFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'sendTemplate', - ], - jsonParameters: [ - false, - ], + resource: ['email'], + operation: ['sendTemplate'], + jsonParameters: [false], }, }, placeholder: 'Add Variable', @@ -520,15 +454,9 @@ export const emailFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'sendTemplate', - ], - jsonParameters: [ - true, - ], + resource: ['email'], + operation: ['sendTemplate'], + jsonParameters: [true], }, }, default: '', diff --git a/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts b/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts index c8f861c141..ad035356da 100644 --- a/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts @@ -1,35 +1,33 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - IHookFunctions, - JsonObject, - NodeApiError, -} from 'n8n-workflow'; - -export async function mailjetApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, IHookFunctions, JsonObject, NodeApiError } from 'n8n-workflow'; +export async function mailjetApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | IHookFunctions | ILoadOptionsFunctions, + method: string, + path: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const resource = this.getNodeParameter('resource', 0) as string; let credentialType; if (resource === 'email' || this.getNode().type.includes('Trigger')) { credentialType = 'mailjetEmailApi'; - const { sandboxMode } = await this.getCredentials('mailjetEmailApi') as - { sandboxMode: boolean }; + const { sandboxMode } = (await this.getCredentials('mailjetEmailApi')) as { + sandboxMode: boolean; + }; if (!this.getNode().type.includes('Trigger')) { Object.assign(body, { SandboxMode: sandboxMode }); } - } else { credentialType = 'mailjetSmsApi'; } @@ -57,8 +55,15 @@ export async function mailjetApiRequest(this: IExecuteFunctions | IExecuteSingle } } -export async function mailjetApiRequestAllItems(this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function mailjetApiRequestAllItems( + this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -67,16 +72,17 @@ export async function mailjetApiRequestAllItems(this: IExecuteFunctions | IHookF query.Offset = 0; do { - responseData = await mailjetApiRequest.call(this, method, endpoint, body, query, undefined, { resolveWithFullResponse: true }); + responseData = await mailjetApiRequest.call(this, method, endpoint, body, query, undefined, { + resolveWithFullResponse: true, + }); returnData.push.apply(returnData, responseData.body); query.Offset = query.Offset + query.Limit; - } while ( - responseData.length !== 0 - ); + } while (responseData.length !== 0); return returnData; } -export function validateJSON(json: string | undefined): IDataObject | undefined { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): IDataObject | undefined { let result; try { result = JSON.parse(json!); @@ -87,7 +93,7 @@ export function validateJSON(json: string | undefined): IDataObject | undefined } export interface IMessage { - From?: { Email?: string, Name?: string }; + From?: { Email?: string; Name?: string }; Subject?: string; To?: IDataObject[]; Cc?: IDataObject[]; diff --git a/packages/nodes-base/nodes/Mailjet/Mailjet.node.ts b/packages/nodes-base/nodes/Mailjet/Mailjet.node.ts index d57f75baef..01f7d4bb89 100644 --- a/packages/nodes-base/nodes/Mailjet/Mailjet.node.ts +++ b/packages/nodes-base/nodes/Mailjet/Mailjet.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -13,21 +11,11 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - IMessage, - mailjetApiRequest, - validateJSON, -} from './GenericFunctions'; +import { IMessage, mailjetApiRequest, validateJSON } from './GenericFunctions'; -import { - emailFields, - emailOperations, -} from './EmailDescription'; +import { emailFields, emailOperations } from './EmailDescription'; -import { - smsFields, - smsOperations, -} from './SmsDescription'; +import { smsFields, smsOperations } from './SmsDescription'; export class Mailjet implements INodeType { description: INodeTypeDescription = { displayName: 'Mailjet', @@ -48,9 +36,7 @@ export class Mailjet implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'email', - ], + resource: ['email'], }, }, }, @@ -59,9 +45,7 @@ export class Mailjet implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'sms', - ], + resource: ['sms'], }, }, }, @@ -151,11 +135,17 @@ export class Mailjet implements INodeType { const variablesJson = this.getNodeParameter('variablesJson', i) as string; const parsedJson = validateJSON(variablesJson); if (parsedJson === undefined) { - throw new NodeOperationError(this.getNode(),`Parameter 'Variables (JSON)' has a invalid JSON`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Parameter 'Variables (JSON)' has a invalid JSON`, + { itemIndex: i }, + ); } body.Variables = parsedJson; } else { - const variables = (this.getNodeParameter('variablesUi', i) as IDataObject).variablesValues as IDataObject[] || []; + const variables = + ((this.getNodeParameter('variablesUi', i) as IDataObject) + .variablesValues as IDataObject[]) || []; for (const variable of variables) { body.Variables![variable.name as string] = variable.value; } @@ -204,9 +194,10 @@ export class Mailjet implements INodeType { if (additionalFields.priority) { body.Priority = additionalFields.priority as number; } - responseData = await mailjetApiRequest.call(this, 'POST', '/v3.1/send', { Messages: [body] }); + responseData = await mailjetApiRequest.call(this, 'POST', '/v3.1/send', { + Messages: [body], + }); responseData = responseData.Messages; - } //https://dev.mailjet.com/email/guides/send-api-v31/#use-a-template if (operation === 'sendTemplate') { @@ -239,11 +230,17 @@ export class Mailjet implements INodeType { const variablesJson = this.getNodeParameter('variablesJson', i) as string; const parsedJson = validateJSON(variablesJson); if (parsedJson === undefined) { - throw new NodeOperationError(this.getNode(), `Parameter 'Variables (JSON)' has a invalid JSON`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Parameter 'Variables (JSON)' has a invalid JSON`, + { itemIndex: i }, + ); } body.Variables = parsedJson; } else { - const variables = (this.getNodeParameter('variablesUi', i) as IDataObject).variablesValues as IDataObject[] || []; + const variables = + ((this.getNodeParameter('variablesUi', i) as IDataObject) + .variablesValues as IDataObject[]) || []; for (const variable of variables) { body.Variables![variable.name as string] = variable.value; } @@ -286,7 +283,9 @@ export class Mailjet implements INodeType { if (additionalFields.priority) { body.Priority = additionalFields.priority as number; } - responseData = await mailjetApiRequest.call(this, 'POST', '/v3.1/send', { Messages: [body] }); + responseData = await mailjetApiRequest.call(this, 'POST', '/v3.1/send', { + Messages: [body], + }); responseData = responseData.Messages; } } diff --git a/packages/nodes-base/nodes/Mailjet/MailjetTrigger.node.ts b/packages/nodes-base/nodes/Mailjet/MailjetTrigger.node.ts index c25bca6889..4277c71eed 100644 --- a/packages/nodes-base/nodes/Mailjet/MailjetTrigger.node.ts +++ b/packages/nodes-base/nodes/Mailjet/MailjetTrigger.node.ts @@ -1,18 +1,8 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import { - IDataObject, - INodeType, - INodeTypeDescription, - IWebhookResponseData, -} from 'n8n-workflow'; +import { IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; -import { - mailjetApiRequest, -} from './GenericFunctions'; +import { mailjetApiRequest } from './GenericFunctions'; export class MailjetTrigger implements INodeType { description: INodeTypeDescription = { @@ -77,7 +67,6 @@ export class MailjetTrigger implements INodeType { description: 'Determines which resource events the webhook is triggered for', }, ], - }; // @ts-ignore @@ -121,7 +110,7 @@ export class MailjetTrigger implements INodeType { const endpoint = `/v3/rest/eventcallbackurl/${webhookData.webhookId}`; try { await mailjetApiRequest.call(this, 'DELETE', endpoint); - } catch(error) { + } catch (error) { return false; } delete webhookData.webhookId; @@ -134,9 +123,7 @@ export class MailjetTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/Mailjet/SmsDescription.ts b/packages/nodes-base/nodes/Mailjet/SmsDescription.ts index f2b48f5755..b5831f24ed 100644 --- a/packages/nodes-base/nodes/Mailjet/SmsDescription.ts +++ b/packages/nodes-base/nodes/Mailjet/SmsDescription.ts @@ -8,9 +8,7 @@ export const smsOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'sms', - ], + resource: ['sms'], }, }, options: [ @@ -26,10 +24,9 @@ export const smsOperations: INodeProperties[] = [ ]; export const smsFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* sms:send */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* sms:send */ + /* -------------------------------------------------------------------------- */ { displayName: 'From', name: 'from', @@ -38,15 +35,12 @@ export const smsFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'sms', - ], - operation: [ - 'send', - ], + resource: ['sms'], + operation: ['send'], }, }, - description: 'Customizable sender name. Should be between 3 and 11 characters in length, only alphanumeric characters are allowed.', + description: + 'Customizable sender name. Should be between 3 and 11 characters in length, only alphanumeric characters are allowed.', }, { displayName: 'To', @@ -56,15 +50,12 @@ export const smsFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'sms', - ], - operation: [ - 'send', - ], + resource: ['sms'], + operation: ['send'], }, }, - description: 'Message recipient. Should be between 3 and 15 characters in length. The number always starts with a plus sign followed by a country code, followed by the number. Phone numbers are expected to comply with the E.164 format.', + description: + 'Message recipient. Should be between 3 and 15 characters in length. The number always starts with a plus sign followed by a country code, followed by the number. Phone numbers are expected to comply with the E.164 format.', }, { displayName: 'Text', @@ -77,12 +68,8 @@ export const smsFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'sms', - ], - operation: [ - 'send', - ], + resource: ['sms'], + operation: ['send'], }, }, }, diff --git a/packages/nodes-base/nodes/Mandrill/GenericFunctions.ts b/packages/nodes-base/nodes/Mandrill/GenericFunctions.ts index c7555b99b4..ae848dea6f 100644 --- a/packages/nodes-base/nodes/Mandrill/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mandrill/GenericFunctions.ts @@ -1,17 +1,20 @@ -import { - OptionsWithUri, - } from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; import _ from 'lodash'; -import { NodeApiError, NodeOperationError, } from 'n8n-workflow'; +import { NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function mandrillApiRequest(this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, resource: string, method: string, action: string, body: any = {}, headers?: object): Promise { // tslint:disable-line:no-any +export async function mandrillApiRequest( + this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, + resource: string, + method: string, + action: string, + // tslint:disable-next-line:no-any + body: any = {}, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('mandrillApi'); const data = Object.assign({}, body, { key: credentials.apiKey }); @@ -26,7 +29,6 @@ export async function mandrillApiRequest(this: IExecuteFunctions | IHookFunction json: true, }; - try { return await this.helpers.request!(options); } catch (error) { @@ -34,7 +36,8 @@ export async function mandrillApiRequest(this: IExecuteFunctions | IHookFunction } } -export function getToEmailArray(toEmail: string): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function getToEmailArray(toEmail: string): any { let toEmailArray; if (toEmail.split(',').length > 0) { const array = toEmail.split(','); @@ -45,10 +48,12 @@ export function getToEmailArray(toEmail: string): any { // tslint:disable-line:n }; }); } else { - toEmailArray = [{ - email: toEmail, - type: 'to', - }]; + toEmailArray = [ + { + email: toEmail, + type: 'to', + }, + ]; } return toEmailArray; } @@ -63,7 +68,8 @@ export function getGoogleAnalyticsDomainsArray(s: string): string[] { return array; } -export function getTags(s: string): any[] { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function getTags(s: string): any[] { let array = []; if (s.split(',').length > 0) { array = s.split(','); @@ -73,7 +79,8 @@ export function getTags(s: string): any[] { // tslint:disable-line:no-any return array; } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); diff --git a/packages/nodes-base/nodes/Mandrill/Mandrill.node.ts b/packages/nodes-base/nodes/Mandrill/Mandrill.node.ts index d8081a2d62..69e6b576fd 100644 --- a/packages/nodes-base/nodes/Mandrill/Mandrill.node.ts +++ b/packages/nodes-base/nodes/Mandrill/Mandrill.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, - } from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -18,7 +16,7 @@ import { getTags, getToEmailArray, mandrillApiRequest, - validateJSON + validateJSON, } from './GenericFunctions'; import moment from 'moment'; @@ -139,9 +137,7 @@ export class Mandrill implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'message', - ], + resource: ['message'], }, }, options: [ @@ -169,15 +165,14 @@ export class Mandrill implements INodeType { }, displayOptions: { show: { - operation: [ - 'sendTemplate', - ], + operation: ['sendTemplate'], }, }, default: '', options: [], required: true, - description: 'The template you want to send. Choose from the list, or specify an ID using an expression.', + description: + 'The template you want to send. Choose from the list, or specify an ID using an expression.', }, { displayName: 'From Email', @@ -189,10 +184,7 @@ export class Mandrill implements INodeType { description: 'Email address of the sender optional with name', displayOptions: { show: { - operation: [ - 'sendHtml', - 'sendTemplate', - ], + operation: ['sendHtml', 'sendTemplate'], }, }, }, @@ -206,10 +198,7 @@ export class Mandrill implements INodeType { description: 'Email address of the recipient. Multiple ones can be separated by comma.', displayOptions: { show: { - operation: [ - 'sendHtml', - 'sendTemplate', - ], + operation: ['sendHtml', 'sendTemplate'], }, }, }, @@ -220,10 +209,7 @@ export class Mandrill implements INodeType { default: false, displayOptions: { show: { - operation: [ - 'sendHtml', - 'sendTemplate', - ], + operation: ['sendHtml', 'sendTemplate'], }, }, }, @@ -235,10 +221,7 @@ export class Mandrill implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'sendHtml', - 'sendTemplate', - ], + operation: ['sendHtml', 'sendTemplate'], }, }, options: [ @@ -247,21 +230,24 @@ export class Mandrill implements INodeType { name: 'async', type: 'boolean', default: false, - description: 'Whether to enable a background sending mode that is optimized for bulk sending. In async mode, messages/send will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the \'reject\' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.', + description: + 'Whether to enable a background sending mode that is optimized for bulk sending. In async mode, messages/send will immediately return a status of "queued" for every recipient. To handle rejections when sending in async mode, set up a webhook for the \'reject\' event. Defaults to false for messages with no more than 10 recipients; messages with more than 10 recipients are always sent asynchronously, regardless of the value of async.', }, { displayName: 'Auto Text', name: 'autoText', type: 'boolean', default: false, - description: 'Whether or not to automatically generate a text part for messages that are not given text', + description: + 'Whether or not to automatically generate a text part for messages that are not given text', }, { displayName: 'Auto HTML', name: 'autoHtml', type: 'boolean', default: false, - description: 'Whether or not to automatically generate an HTML part for messages that are not given HTML', + description: + 'Whether or not to automatically generate an HTML part for messages that are not given HTML', }, { displayName: 'BCC Address', @@ -269,7 +255,7 @@ export class Mandrill implements INodeType { type: 'string', default: '', placeholder: 'message.bcc_address@example.com', - description: 'An optional address to receive an exact copy of each recipient\'s email', + description: "An optional address to receive an exact copy of each recipient's email", }, { displayName: 'From Name', @@ -285,7 +271,8 @@ export class Mandrill implements INodeType { type: 'string', default: '', placeholder: '', - description: 'Optional string indicating the value to set for the utm_campaign tracking parameter. If this isn\'t provided the email\'s from address will be used instead.', + description: + "Optional string indicating the value to set for the utm_campaign tracking parameter. If this isn't provided the email's from address will be used instead.", }, { displayName: 'Google Analytics Domains', @@ -293,7 +280,8 @@ export class Mandrill implements INodeType { type: 'string', default: '', placeholder: '', - description: 'An array of strings separated by a comma (,) indicating for which any matching URLs will automatically have Google Analytics parameters appended to their query string automatically', + description: + 'An array of strings separated by a comma (,) indicating for which any matching URLs will automatically have Google Analytics parameters appended to their query string automatically', }, { displayName: 'HTML', @@ -311,14 +299,16 @@ export class Mandrill implements INodeType { name: 'important', type: 'boolean', default: false, - description: 'Whether or not this message is important, and should be delivered ahead of non-important messages', + description: + 'Whether or not this message is important, and should be delivered ahead of non-important messages', }, { displayName: 'Inline CSS', name: 'inlineCss', type: 'boolean', default: false, - description: 'Whether or not to automatically inline all CSS styles provided in the message HTML - only for HTML documents less than 256KB in size', + description: + 'Whether or not to automatically inline all CSS styles provided in the message HTML - only for HTML documents less than 256KB in size', }, { displayName: 'Ip Pool', @@ -326,7 +316,8 @@ export class Mandrill implements INodeType { type: 'string', default: '', placeholder: '', - description: 'The name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.', + description: + 'The name of the dedicated ip pool that should be used to send the message. If you do not have any dedicated IPs, this parameter has no effect. If you specify a pool that does not exist, your default pool will be used instead.', }, { displayName: 'Preserve Recipients', @@ -341,7 +332,7 @@ export class Mandrill implements INodeType { type: 'string', default: '', placeholder: '', - description: 'A custom domain to use for the messages\'s return-path', + description: "A custom domain to use for the messages's return-path", }, { displayName: 'Sent At', @@ -349,7 +340,8 @@ export class Mandrill implements INodeType { type: 'dateTime', default: '', placeholder: '', - description: 'When this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately. An additional fee applies for scheduled email, and this feature is only available to accounts with a positive balance.', + description: + 'When this message should be sent as a UTC timestamp in YYYY-MM-DD HH:MM:SS format. If you specify a time in the past, the message will be sent immediately. An additional fee applies for scheduled email, and this feature is only available to accounts with a positive balance.', }, { displayName: 'Signing Domain', @@ -357,7 +349,8 @@ export class Mandrill implements INodeType { type: 'string', default: '', placeholder: '', - description: 'A custom domain to use for SPF/DKIM signing instead of mandrill(for "via" or "on behalf of" in email clients)', + description: + 'A custom domain to use for SPF/DKIM signing instead of mandrill(for "via" or "on behalf of" in email clients)', }, { displayName: 'Subaccount', @@ -365,7 +358,8 @@ export class Mandrill implements INodeType { type: 'string', default: '', placeholder: '', - description: 'The unique ID of a subaccount for this message - must already exist or will fail with an error', + description: + 'The unique ID of a subaccount for this message - must already exist or will fail with an error', }, { displayName: 'Subject', @@ -381,7 +375,8 @@ export class Mandrill implements INodeType { type: 'string', default: '', placeholder: '', - description: 'An array of string separated by a comma (,) to tag the message with. Stats are accumulated using tags, though we only store the first 100 we see, so this should not be unique or change frequently. Tags should be 50 characters or less. Any tags starting with an underscore are reserved for internal use and will cause errors.', + description: + 'An array of string separated by a comma (,) to tag the message with. Stats are accumulated using tags, though we only store the first 100 we see, so this should not be unique or change frequently. Tags should be 50 characters or less. Any tags starting with an underscore are reserved for internal use and will cause errors.', }, { displayName: 'Text', @@ -414,14 +409,16 @@ export class Mandrill implements INodeType { type: 'string', default: '', placeholder: '', - description: 'A custom domain to use for tracking opens and clicks instead of mandrillapp.com', + description: + 'A custom domain to use for tracking opens and clicks instead of mandrillapp.com', }, { displayName: 'Url Strip Qs', name: 'urlStripQs', type: 'boolean', default: false, - description: 'Whether or not to strip the query string from URLs when aggregating tracked URL data', + description: + 'Whether or not to strip the query string from URLs when aggregating tracked URL data', }, { displayName: 'View Content Link', @@ -447,9 +444,7 @@ export class Mandrill implements INodeType { ]`, displayOptions: { show: { - jsonParameters: [ - true, - ], + jsonParameters: [true], }, }, description: 'Global merge variables', @@ -465,9 +460,7 @@ export class Mandrill implements INodeType { }, displayOptions: { show: { - jsonParameters: [ - false, - ], + jsonParameters: [false], }, }, description: 'Per-recipient merge variables', @@ -503,12 +496,11 @@ export class Mandrill implements INodeType { }, displayOptions: { show: { - jsonParameters: [ - false, - ], + jsonParameters: [false], }, }, - description: 'Metadata an associative array of user metadata. Mandrill will store this metadata and make it available for retrieval. In addition, you can select up to 10 metadata fields to index and make searchable using the Mandrill search api.', + description: + 'Metadata an associative array of user metadata. Mandrill will store this metadata and make it available for retrieval. In addition, you can select up to 10 metadata fields to index and make searchable using the Mandrill search api.', options: [ { name: 'metadataValues', @@ -540,16 +532,15 @@ export class Mandrill implements INodeType { }, displayOptions: { show: { - jsonParameters: [ - true, - ], + jsonParameters: [true], }, }, default: '', placeholder: `{ "website": "www.example.com" }`, - description: 'Metadata an associative array of user metadata. Mandrill will store this metadata and make it available for retrieval. In addition, you can select up to 10 metadata fields to index and make searchable using the Mandrill search api.', + description: + 'Metadata an associative array of user metadata. Mandrill will store this metadata and make it available for retrieval. In addition, you can select up to 10 metadata fields to index and make searchable using the Mandrill search api.', }, { displayName: 'Attachments', @@ -560,9 +551,7 @@ export class Mandrill implements INodeType { }, displayOptions: { show: { - jsonParameters: [ - true, - ], + jsonParameters: [true], }, }, default: '', @@ -585,9 +574,7 @@ export class Mandrill implements INodeType { }, displayOptions: { show: { - jsonParameters: [ - false, - ], + jsonParameters: [false], }, }, options: [ @@ -630,7 +617,8 @@ export class Mandrill implements INodeType { name: 'property', type: 'string', default: '', - description: 'Name of the binary properties which contain data which should be added to email as attachment', + description: + 'Name of the binary properties which contain data which should be added to email as attachment', }, ], }, @@ -648,9 +636,7 @@ export class Mandrill implements INodeType { }`, displayOptions: { show: { - jsonParameters: [ - true, - ], + jsonParameters: [true], }, }, typeOptions: { @@ -669,9 +655,7 @@ export class Mandrill implements INodeType { }, displayOptions: { show: { - jsonParameters: [ - false, - ], + jsonParameters: [false], }, }, options: [ @@ -726,7 +710,6 @@ export class Mandrill implements INodeType { }, }; - async execute(this: IExecuteFunctions): Promise { const returnData: IDataObject[] = []; const items = this.getInputData(); @@ -738,7 +721,6 @@ export class Mandrill implements INodeType { for (let i = 0; i < items.length; i++) { try { if (resource === 'message') { - const options = this.getNodeParameter('options', i) as Options; const fromEmail = this.getNodeParameter('fromEmail', i) as string; const toEmail = this.getNodeParameter('toEmail', i) as string; @@ -746,31 +728,35 @@ export class Mandrill implements INodeType { const toEmailArray = getToEmailArray(toEmail); const message: Message = { - html: (options.html) ? options.html : '', - text: (options.text) ? options.text : '', - subject: (options.subject) ? options.subject : '', + html: options.html ? options.html : '', + text: options.text ? options.text : '', + subject: options.subject ? options.subject : '', from_email: fromEmail, to: toEmailArray, - important: (options.important) ? options.important : false, - track_opens: (options.trackOpens) ? options.trackOpens : false, - track_clicks: (options.trackClicks) ? options.trackClicks : false, - auto_text: (options.autoText) ? options.autoText : false, - auto_html: (options.autoHtml) ? options.autoHtml : false, - inline_css: (options.inlineCss) ? options.inlineCss : false, - url_strip_qs: (options.urlStripQs) ? options.urlStripQs : false, - preserve_recipients: (options.preserveRecipients) ? options.preserveRecipients : false, - view_content_link: (options.viewContentLink) ? options.viewContentLink : false, - async: (options.async) ? options.async : false, - google_analytics_campaign: (options.googleAnalyticsCampaign) ? options.googleAnalyticsCampaign : '', - ip_pool: (options.ipPool) ? options.ipPool : '', - bcc_address: (options.bccAddress) ? options.bccAddress : '', - tracking_domain: (options.trackingDomain) ? options.trackingDomain : '', - signing_domain: (options.signingDomain) ? options.signingDomain : '', - return_path_domain: (options.returnPathDomain) ? options.returnPathDomain : '', + important: options.important ? options.important : false, + track_opens: options.trackOpens ? options.trackOpens : false, + track_clicks: options.trackClicks ? options.trackClicks : false, + auto_text: options.autoText ? options.autoText : false, + auto_html: options.autoHtml ? options.autoHtml : false, + inline_css: options.inlineCss ? options.inlineCss : false, + url_strip_qs: options.urlStripQs ? options.urlStripQs : false, + preserve_recipients: options.preserveRecipients ? options.preserveRecipients : false, + view_content_link: options.viewContentLink ? options.viewContentLink : false, + async: options.async ? options.async : false, + google_analytics_campaign: options.googleAnalyticsCampaign + ? options.googleAnalyticsCampaign + : '', + ip_pool: options.ipPool ? options.ipPool : '', + bcc_address: options.bccAddress ? options.bccAddress : '', + tracking_domain: options.trackingDomain ? options.trackingDomain : '', + signing_domain: options.signingDomain ? options.signingDomain : '', + return_path_domain: options.returnPathDomain ? options.returnPathDomain : '', }; if (options.googleAnalyticsDomains) { - message.google_analytics_domains = getGoogleAnalyticsDomainsArray(options.googleAnalyticsDomains); + message.google_analytics_domains = getGoogleAnalyticsDomainsArray( + options.googleAnalyticsDomains, + ); } if (options.tags) { @@ -795,14 +781,17 @@ export class Mandrill implements INodeType { } if (jsonActive) { - body.message.headers = validateJSON(this.getNodeParameter('headersJson', i) as string); - body.message.metadata = validateJSON(this.getNodeParameter('metadataJson', i) as string); - body.message.global_merge_vars = validateJSON(this.getNodeParameter('mergeVarsJson', i) as string); - body.message.attachments = validateJSON(this.getNodeParameter('attachmentsJson', i) as string); - + body.message.metadata = validateJSON( + this.getNodeParameter('metadataJson', i) as string, + ); + body.message.global_merge_vars = validateJSON( + this.getNodeParameter('mergeVarsJson', i) as string, + ); + body.message.attachments = validateJSON( + this.getNodeParameter('attachmentsJson', i) as string, + ); } else { - const headersUi = this.getNodeParameter('headersUi', i) as IDataObject; if (!_.isEmpty(headersUi)) { // @ts-ignore @@ -827,20 +816,26 @@ export class Mandrill implements INodeType { const mergeVarsUi = this.getNodeParameter('mergeVarsUi', i) as IDataObject; if (!_.isEmpty(mergeVarsUi)) { // @ts-ignore - body.message.global_merge_vars = _.map(mergeVarsUi.mergeVarsValues, (o: IDataObject) => { - const aux: IDataObject = {}; - aux.name = o.name; - aux.content = o.content; - return aux; - }); + body.message.global_merge_vars = _.map( + // @ts-ignore + mergeVarsUi.mergeVarsValues, + (o: IDataObject) => { + const aux: IDataObject = {}; + aux.name = o.name; + aux.content = o.content; + return aux; + }, + ); } const attachmentsUi = this.getNodeParameter('attachmentsUi', i) as IDataObject; - let attachmentsBinary: Attachments[] = [], attachmentsValues: Attachments[] = []; + let attachmentsBinary: Attachments[] = [], + attachmentsValues: Attachments[] = []; if (!_.isEmpty(attachmentsUi)) { - - if (attachmentsUi.hasOwnProperty('attachmentsValues') - && !_.isEmpty(attachmentsUi.attachmentsValues)) { + if ( + attachmentsUi.hasOwnProperty('attachmentsValues') && + !_.isEmpty(attachmentsUi.attachmentsValues) + ) { // @ts-ignore attachmentsValues = _.map(attachmentsUi.attachmentsValues, (o: IDataObject) => { const aux: IDataObject = {}; @@ -852,9 +847,11 @@ export class Mandrill implements INodeType { }); } - if (attachmentsUi.hasOwnProperty('attachmentsBinary') - && !_.isEmpty(attachmentsUi.attachmentsBinary) - && items[i].binary) { + if ( + attachmentsUi.hasOwnProperty('attachmentsBinary') && + !_.isEmpty(attachmentsUi.attachmentsBinary) && + items[i].binary + ) { // @ts-ignore attachmentsBinary = _.map(attachmentsUi.attachmentsBinary, (o: IDataObject) => { if (items[i].binary!.hasOwnProperty(o.property as string)) { @@ -874,7 +871,13 @@ export class Mandrill implements INodeType { if (operation === 'sendTemplate') { const template = this.getNodeParameter('template', i) as string; body.template_name = template; - emailSentResponse = mandrillApiRequest.call(this, '/messages', 'POST', '/send-template', body); + emailSentResponse = mandrillApiRequest.call( + this, + '/messages', + 'POST', + '/send-template', + body, + ); } else if (operation === 'sendHtml') { emailSentResponse = mandrillApiRequest.call(this, '/messages', 'POST', '/send', body); } diff --git a/packages/nodes-base/nodes/Markdown/Markdown.node.ts b/packages/nodes-base/nodes/Markdown/Markdown.node.ts index c6566e2c56..3b65baf38c 100644 --- a/packages/nodes-base/nodes/Markdown/Markdown.node.ts +++ b/packages/nodes-base/nodes/Markdown/Markdown.node.ts @@ -21,7 +21,8 @@ export class Markdown implements INodeType { icon: 'file:markdown.svg', group: ['output'], version: 1, - subtitle: '={{$parameter["mode"]==="markdownToHtml" ? "Markdown to HTML" : "HTML to Markdown"}}', + subtitle: + '={{$parameter["mode"]==="markdownToHtml" ? "Markdown to HTML" : "HTML to Markdown"}}', description: 'Convert data between Markdown and HTML', defaults: { name: 'Markdown', @@ -176,7 +177,8 @@ export class Markdown implements INodeType { name: 'keepDataImages', type: 'boolean', default: false, - description: 'Whether to keep images with data: URI (Note: These can be up to 1MB each), e.g. <img src="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSK......0o/">', + description: + 'Whether to keep images with data: URI (Note: These can be up to 1MB each), e.g. <img src="data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSK......0o/">', }, { displayName: 'Line Start Escape Pattern', @@ -335,7 +337,8 @@ export class Markdown implements INodeType { name: 'completeHTMLDocument', type: 'boolean', default: false, - description: 'Whether to output a complete html document, including <html>, <head> and <body> tags instead of an HTML fragment', + description: + 'Whether to output a complete html document, including <html>, <head> and <body> tags instead of an HTML fragment', }, { displayName: 'Customized Header ID', @@ -365,7 +368,8 @@ export class Markdown implements INodeType { name: 'excludeTrailingPunctuationFromURLs', type: 'boolean', default: false, - description: 'Whether to exclude trailing punctuation from autolinking URLs. Punctuation excluded: . ! ? ( ). Only applies if simplifiedAutoLink option is set to true.', + description: + 'Whether to exclude trailing punctuation from autolinking URLs. Punctuation excluded: . ! ? ( ). Only applies if simplifiedAutoLink option is set to true.', }, { displayName: 'GitHub Code Blocks', @@ -379,7 +383,8 @@ export class Markdown implements INodeType { name: 'ghCompatibleHeaderId', type: 'boolean', default: false, - description: 'Whether to generate header IDs compatible with github style (spaces are replaced with dashes and a bunch of non alphanumeric chars are removed)', + description: + 'Whether to generate header IDs compatible with github style (spaces are replaced with dashes and a bunch of non alphanumeric chars are removed)', }, { displayName: 'GitHub Mention Link', @@ -460,7 +465,8 @@ export class Markdown implements INodeType { name: 'rawHeaderId', type: 'boolean', default: false, - description: 'Whether to remove only spaces, \' and " from generated header IDs (including prefixes), replacing them with dashes (-)', + description: + 'Whether to remove only spaces, \' and " from generated header IDs (including prefixes), replacing them with dashes (-)', }, { displayName: 'Raw Prefix Header ID', @@ -474,7 +480,8 @@ export class Markdown implements INodeType { name: 'simpleLineBreaks', type: 'boolean', default: false, - description: 'Whether to parse line breaks as <br>, like GitHub does, without needing 2 spaces at the end of the line', + description: + 'Whether to parse line breaks as <br>, like GitHub does, without needing 2 spaces at the end of the line', }, { displayName: 'Smart Indentation Fix', @@ -537,25 +544,39 @@ export class Markdown implements INodeType { const options = this.getNodeParameter('options', i) as IDataObject; const destinationKey = this.getNodeParameter('destinationKey', i) as string; - const textReplaceOption = this.getNodeParameter('options.textReplace.values', i, []) as IDataObject[]; + const textReplaceOption = this.getNodeParameter( + 'options.textReplace.values', + i, + [], + ) as IDataObject[]; options.textReplace = !isEmpty(textReplaceOption) ? textReplaceOption.map((entry) => [entry.pattern, entry.replacement]) : undefined; - const lineStartEscapeOption = this.getNodeParameter('options.lineStartEscape.value', i, {}) as IDataObject; + const lineStartEscapeOption = this.getNodeParameter( + 'options.lineStartEscape.value', + i, + {}, + ) as IDataObject; options.lineStartEscape = !isEmpty(lineStartEscapeOption) ? [lineStartEscapeOption.pattern, lineStartEscapeOption.replacement] : undefined; - const globalEscapeOption = this.getNodeParameter('options.globalEscape.value', i, {}) as IDataObject; + const globalEscapeOption = this.getNodeParameter( + 'options.globalEscape.value', + i, + {}, + ) as IDataObject; options.globalEscape = !isEmpty(globalEscapeOption) ? [globalEscapeOption.pattern, globalEscapeOption.replacement] : undefined; options.ignore = options.ignore - ? (options.ignore as string).split(',').map(element => element.trim()) : undefined; + ? (options.ignore as string).split(',').map((element) => element.trim()) + : undefined; options.blockElements = options.blockElements - ? (options.blockElements as string).split(',').map(element => element.trim()) : undefined; + ? (options.blockElements as string).split(',').map((element) => element.trim()) + : undefined; const markdownOptions = {} as IDataObject; diff --git a/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts b/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts index 325637134f..39963a4717 100644 --- a/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts @@ -1,16 +1,8 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function marketstackApiRequest( this: IExecuteFunctions, @@ -67,20 +59,15 @@ export async function marketstackApiRequestAllItems( } qs.offset += responseData.count; - } while ( - responseData.total > returnData.length - ); + } while (responseData.total > returnData.length); return returnData; } export const format = (datetime?: string) => datetime?.split('T')[0]; -export function validateTimeOptions( - this: IExecuteFunctions, - timeOptions: boolean[], -) { - if (timeOptions.every(o => !o)) { +export function validateTimeOptions(this: IExecuteFunctions, timeOptions: boolean[]) { + if (timeOptions.every((o) => !o)) { throw new NodeOperationError( this.getNode(), 'Please filter by latest, specific date or timeframe (start and end dates).', diff --git a/packages/nodes-base/nodes/Marketstack/Marketstack.node.ts b/packages/nodes-base/nodes/Marketstack/Marketstack.node.ts index 8aab3a5307..2fb0740c22 100644 --- a/packages/nodes-base/nodes/Marketstack/Marketstack.node.ts +++ b/packages/nodes-base/nodes/Marketstack/Marketstack.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -26,11 +24,7 @@ import { validateTimeOptions, } from './GenericFunctions'; -import { - EndOfDayDataFilters, - Operation, - Resource, -} from './types'; +import { EndOfDayDataFilters, Operation, Resource } from './types'; export class Marketstack implements INodeType { description: INodeTypeDescription = { @@ -97,13 +91,9 @@ export class Marketstack implements INodeType { const returnData: IDataObject[] = []; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'endOfDayData') { - if (operation === 'getAll') { - // ---------------------------------- // endOfDayData: getAll // ---------------------------------- @@ -112,13 +102,10 @@ export class Marketstack implements INodeType { symbols: this.getNodeParameter('symbols', i), }; - const { - latest, - specificDate, - dateFrom, - dateTo, - ...rest - } = this.getNodeParameter('filters', i) as EndOfDayDataFilters; + const { latest, specificDate, dateFrom, dateTo, ...rest } = this.getNodeParameter( + 'filters', + i, + ) as EndOfDayDataFilters; validateTimeOptions.call(this, [ latest !== undefined && latest !== false, @@ -140,7 +127,8 @@ export class Marketstack implements INodeType { if (!dateFrom || !dateTo) { throw new NodeOperationError( this.getNode(), - 'Please enter a start and end date to filter by timeframe.', { itemIndex: i }, + 'Please enter a start and end date to filter by timeframe.', + { itemIndex: i }, ); } endpoint = '/eod'; @@ -149,13 +137,9 @@ export class Marketstack implements INodeType { } responseData = await marketstackApiRequestAllItems.call(this, 'GET', endpoint, {}, qs); - } - } else if (resource === 'exchange') { - if (operation === 'get') { - // ---------------------------------- // exchange: get // ---------------------------------- @@ -164,13 +148,9 @@ export class Marketstack implements INodeType { const endpoint = `/exchanges/${exchange}`; responseData = await marketstackApiRequest.call(this, 'GET', endpoint); - } - } else if (resource === 'ticker') { - if (operation === 'get') { - // ---------------------------------- // ticker: get // ---------------------------------- @@ -179,11 +159,8 @@ export class Marketstack implements INodeType { const endpoint = `/tickers/${symbol}`; responseData = await marketstackApiRequest.call(this, 'GET', endpoint); - } - } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -195,7 +172,6 @@ export class Marketstack implements INodeType { Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Marketstack/descriptions/EndOfDayDataDescription.ts b/packages/nodes-base/nodes/Marketstack/descriptions/EndOfDayDataDescription.ts index 6dce611b96..c88d992b06 100644 --- a/packages/nodes-base/nodes/Marketstack/descriptions/EndOfDayDataDescription.ts +++ b/packages/nodes-base/nodes/Marketstack/descriptions/EndOfDayDataDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const endOfDayDataOperations: INodeProperties[] = [ { @@ -18,9 +16,7 @@ export const endOfDayDataOperations: INodeProperties[] = [ default: 'getAll', displayOptions: { show: { - resource: [ - 'endOfDayData', - ], + resource: ['endOfDayData'], }, }, }, @@ -34,16 +30,13 @@ export const endOfDayDataFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'endOfDayData', - ], - operation: [ - 'getAll', - ], + resource: ['endOfDayData'], + operation: ['getAll'], }, }, default: '', - description: 'One or multiple comma-separated stock symbols (tickers) to retrieve, e.g. AAPL or AAPL,MSFT', + description: + 'One or multiple comma-separated stock symbols (tickers) to retrieve, e.g. AAPL or AAPL,MSFT', }, { displayName: 'Return All', @@ -53,12 +46,8 @@ export const endOfDayDataFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'endOfDayData', - ], - operation: [ - 'getAll', - ], + resource: ['endOfDayData'], + operation: ['getAll'], }, }, }, @@ -73,15 +62,9 @@ export const endOfDayDataFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'endOfDayData', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['endOfDayData'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -93,12 +76,8 @@ export const endOfDayDataFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'endOfDayData', - ], - operation: [ - 'getAll', - ], + resource: ['endOfDayData'], + operation: ['getAll'], }, }, options: [ @@ -107,7 +86,8 @@ export const endOfDayDataFields: INodeProperties[] = [ name: 'exchange', type: 'string', default: '', - description: 'Stock exchange to filter results by, specified by Market Identifier Code, e.g. XNAS', + description: + 'Stock exchange to filter results by, specified by Market Identifier Code, e.g. XNAS', }, { displayName: 'Latest', @@ -138,21 +118,24 @@ export const endOfDayDataFields: INodeProperties[] = [ name: 'specificDate', type: 'dateTime', default: '', - description: 'Date in YYYY-MM-DD format, e.g. 2020-01-01, or in ISO-8601 date format, e.g. 2020-05-21T00:00:00+0000', + description: + 'Date in YYYY-MM-DD format, e.g. 2020-01-01, or in ISO-8601 date format, e.g. 2020-05-21T00:00:00+0000', }, { displayName: 'Timeframe Start Date', name: 'dateFrom', type: 'dateTime', default: '', - description: 'Timeframe start date in YYYY-MM-DD format, e.g. 2020-01-01, or in ISO-8601 date format, e.g. 2020-05-21T00:00:00+0000', + description: + 'Timeframe start date in YYYY-MM-DD format, e.g. 2020-01-01, or in ISO-8601 date format, e.g. 2020-05-21T00:00:00+0000', }, { displayName: 'Timeframe End Date', name: 'dateTo', type: 'dateTime', default: '', - description: 'Timeframe end date in YYYY-MM-DD format, e.g. 2020-01-01, or in ISO-8601 date format, e.g. 2020-05-21T00:00:00+0000', + description: + 'Timeframe end date in YYYY-MM-DD format, e.g. 2020-01-01, or in ISO-8601 date format, e.g. 2020-05-21T00:00:00+0000', }, ], }, diff --git a/packages/nodes-base/nodes/Marketstack/descriptions/ExchangeDescription.ts b/packages/nodes-base/nodes/Marketstack/descriptions/ExchangeDescription.ts index 86d686cf91..dd485e7e2e 100644 --- a/packages/nodes-base/nodes/Marketstack/descriptions/ExchangeDescription.ts +++ b/packages/nodes-base/nodes/Marketstack/descriptions/ExchangeDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const exchangeOperations: INodeProperties[] = [ { @@ -18,9 +16,7 @@ export const exchangeOperations: INodeProperties[] = [ default: 'get', displayOptions: { show: { - resource: [ - 'exchange', - ], + resource: ['exchange'], }, }, }, @@ -34,15 +30,12 @@ export const exchangeFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'exchange', - ], - operation: [ - 'get', - ], + resource: ['exchange'], + operation: ['get'], }, }, default: '', - description: 'Stock exchange to retrieve, specified by Market Identifier Code, e.g. XNAS', + description: + 'Stock exchange to retrieve, specified by Market Identifier Code, e.g. XNAS', }, ]; diff --git a/packages/nodes-base/nodes/Marketstack/descriptions/TickerDescription.ts b/packages/nodes-base/nodes/Marketstack/descriptions/TickerDescription.ts index 56ce11b735..836e513ba9 100644 --- a/packages/nodes-base/nodes/Marketstack/descriptions/TickerDescription.ts +++ b/packages/nodes-base/nodes/Marketstack/descriptions/TickerDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const tickerOperations: INodeProperties[] = [ { @@ -18,9 +16,7 @@ export const tickerOperations: INodeProperties[] = [ default: 'get', displayOptions: { show: { - resource: [ - 'ticker', - ], + resource: ['ticker'], }, }, }, @@ -34,12 +30,8 @@ export const tickerFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'ticker', - ], - operation: [ - 'get', - ], + resource: ['ticker'], + operation: ['get'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Matrix/AccountDescription.ts b/packages/nodes-base/nodes/Matrix/AccountDescription.ts index 66b35d80e4..1c2a3746b6 100644 --- a/packages/nodes-base/nodes/Matrix/AccountDescription.ts +++ b/packages/nodes-base/nodes/Matrix/AccountDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const accountOperations: INodeProperties[] = [ { @@ -10,17 +8,15 @@ export const accountOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'account', - ], + resource: ['account'], }, }, options: [ { name: 'Me', value: 'me', - description: 'Get current user\'s account information', - action: 'Get the current user\'s account information', + description: "Get current user's account information", + action: "Get the current user's account information", }, ], default: 'me', diff --git a/packages/nodes-base/nodes/Matrix/EventDescription.ts b/packages/nodes-base/nodes/Matrix/EventDescription.ts index 1a1c56143d..87bdf1bbe5 100644 --- a/packages/nodes-base/nodes/Matrix/EventDescription.ts +++ b/packages/nodes-base/nodes/Matrix/EventDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const eventOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const eventOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'event', - ], + resource: ['event'], }, }, options: [ @@ -27,9 +23,7 @@ export const eventOperations: INodeProperties[] = [ }, ]; - export const eventFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* event:get */ /* -------------------------------------------------------------------------- */ @@ -41,12 +35,8 @@ export const eventFields: INodeProperties[] = [ placeholder: '!123abc:matrix.org', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'event', - ], + operation: ['get'], + resource: ['event'], }, }, required: true, @@ -60,12 +50,8 @@ export const eventFields: INodeProperties[] = [ placeholder: '$1234abcd:matrix.org', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'event', - ], + operation: ['get'], + resource: ['event'], }, }, required: true, diff --git a/packages/nodes-base/nodes/Matrix/GenericFunctions.ts b/packages/nodes-base/nodes/Matrix/GenericFunctions.ts index 230ae6c3f5..2107885144 100644 --- a/packages/nodes-base/nodes/Matrix/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Matrix/GenericFunctions.ts @@ -1,19 +1,12 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; import _ from 'lodash'; import { v4 as uuid } from 'uuid'; - interface MessageResponse { chunk: Message[]; } @@ -24,10 +17,18 @@ interface Message { sender: string; type: string; user_id: string; - } -export async function matrixApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: string | object = {}, query: object = {}, headers: {} | undefined = undefined, option: {} = {}): Promise { // tslint:disable-line:no-any +export async function matrixApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + body: string | object = {}, + query: object = {}, + headers: {} | undefined = undefined, + option: {} = {}, + // tslint:disable-next-line:no-any +): Promise { let options: OptionsWithUri = { method, headers: headers || { @@ -46,12 +47,14 @@ export async function matrixApiRequest(this: IExecuteFunctions | IExecuteSingleF delete options.qs; } try { - let response: any; // tslint:disable-line:no-any const credentials = await this.getCredentials('matrixApi'); - //@ts-ignore - options.uri = `${credentials.homeserverUrl}/_matrix/${option.overridePrefix || 'client'}/r0${resource}`; + + options.uri = `${credentials.homeserverUrl}/_matrix/${ + //@ts-ignore + option.overridePrefix || 'client' + }/r0${resource}`; options.headers!.Authorization = `Bearer ${credentials.accessToken}`; //@ts-ignore response = await this.helpers.request(options); @@ -65,14 +68,19 @@ export async function matrixApiRequest(this: IExecuteFunctions | IExecuteSingleF } } -export async function handleMatrixCall(this: IExecuteFunctions, item: IDataObject, index: number, resource: string, operation: string): Promise { // tslint:disable-line:no-any - +export async function handleMatrixCall( + this: IExecuteFunctions, + item: IDataObject, + index: number, + resource: string, + operation: string, + // tslint:disable-next-line:no-any +): Promise { if (resource === 'account') { if (operation === 'me') { return await matrixApiRequest.call(this, 'GET', '/account/whoami'); } - } - else if (resource === 'room') { + } else if (resource === 'room') { if (operation === 'create') { const name = this.getNodeParameter('roomName', index) as string; const preset = this.getNodeParameter('preset', index) as string; @@ -125,7 +133,12 @@ export async function handleMatrixCall(this: IExecuteFunctions, item: IDataObjec body.body = fallbackText; } const messageId = uuid(); - return await matrixApiRequest.call(this, 'PUT', `/rooms/${roomId}/send/m.room.message/${messageId}`, body); + return await matrixApiRequest.call( + this, + 'PUT', + `/rooms/${roomId}/send/m.room.message/${messageId}`, + body, + ); } else if (operation === 'getAll') { const roomId = this.getNodeParameter('roomId', index) as string; const returnAll = this.getNodeParameter('returnAll', index) as boolean; @@ -145,7 +158,13 @@ export async function handleMatrixCall(this: IExecuteFunctions, item: IDataObjec qs.filter = otherOptions.filter; } - responseData = await matrixApiRequest.call(this, 'GET', `/rooms/${roomId}/messages`, {}, qs); + responseData = await matrixApiRequest.call( + this, + 'GET', + `/rooms/${roomId}/messages`, + {}, + qs, + ); returnData.push.apply(returnData, responseData.chunk); from = responseData.end; } while (responseData.chunk.length > 0); @@ -160,7 +179,13 @@ export async function handleMatrixCall(this: IExecuteFunctions, item: IDataObjec qs.filter = otherOptions.filter; } - const responseData = await matrixApiRequest.call(this, 'GET', `/rooms/${roomId}/messages`, {}, qs); + const responseData = await matrixApiRequest.call( + this, + 'GET', + `/rooms/${roomId}/messages`, + {}, + qs, + ); returnData.push.apply(returnData, responseData.chunk); } @@ -183,10 +208,15 @@ export async function handleMatrixCall(this: IExecuteFunctions, item: IDataObjec const headers: IDataObject = {}; let filename; - if (item.binary === undefined + if ( + item.binary === undefined || //@ts-ignore - || item.binary[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`); + item.binary[binaryPropertyName] === undefined + ) { + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + ); } // @ts-ignore @@ -199,10 +229,18 @@ export async function handleMatrixCall(this: IExecuteFunctions, item: IDataObjec headers['Content-Type'] = item.binary[binaryPropertyName].mimeType; headers['accept'] = 'application/json,text/*;q=0.99'; - const uploadRequestResult = await matrixApiRequest.call(this, 'POST', `/upload`, body, qs, headers, { - overridePrefix: 'media', - json: false, - }); + const uploadRequestResult = await matrixApiRequest.call( + this, + 'POST', + `/upload`, + body, + qs, + headers, + { + overridePrefix: 'media', + json: false, + }, + ); body = { msgtype: `m.${mediaType}`, @@ -210,8 +248,12 @@ export async function handleMatrixCall(this: IExecuteFunctions, item: IDataObjec url: uploadRequestResult.content_uri, }; const messageId = uuid(); - return await matrixApiRequest.call(this, 'PUT', `/rooms/${roomId}/send/m.room.message/${messageId}`, body); - + return await matrixApiRequest.call( + this, + 'PUT', + `/rooms/${roomId}/send/m.room.message/${messageId}`, + body, + ); } } else if (resource === 'roomMember') { if (operation === 'getAll') { @@ -221,11 +263,16 @@ export async function handleMatrixCall(this: IExecuteFunctions, item: IDataObjec membership: filters.membership ? filters.membership : '', not_membership: filters.notMembership ? filters.notMembership : '', }; - const roomMembersResponse = await matrixApiRequest.call(this, 'GET', `/rooms/${roomId}/members`, {}, qs); + const roomMembersResponse = await matrixApiRequest.call( + this, + 'GET', + `/rooms/${roomId}/members`, + {}, + qs, + ); return roomMembersResponse.chunk; } } - throw new NodeOperationError(this.getNode(), 'Not implemented yet'); } diff --git a/packages/nodes-base/nodes/Matrix/Matrix.node.ts b/packages/nodes-base/nodes/Matrix/Matrix.node.ts index 348fac18e9..609c7c6726 100644 --- a/packages/nodes-base/nodes/Matrix/Matrix.node.ts +++ b/packages/nodes-base/nodes/Matrix/Matrix.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,39 +9,19 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - handleMatrixCall, - matrixApiRequest, -} from './GenericFunctions'; +import { handleMatrixCall, matrixApiRequest } from './GenericFunctions'; -import { - accountOperations -} from './AccountDescription'; +import { accountOperations } from './AccountDescription'; -import { - eventFields, - eventOperations, -} from './EventDescription'; +import { eventFields, eventOperations } from './EventDescription'; -import { - mediaFields, - mediaOperations, -} from './MediaDescription'; +import { mediaFields, mediaOperations } from './MediaDescription'; -import { - messageFields, - messageOperations, -} from './MessageDescription'; +import { messageFields, messageOperations } from './MessageDescription'; -import { - roomFields, - roomOperations, -} from './RoomDescription'; +import { roomFields, roomOperations } from './RoomDescription'; -import { - roomMemberFields, - roomMemberOperations, -} from './RoomMemberDescription'; +import { roomMemberFields, roomMemberOperations } from './RoomMemberDescription'; export class Matrix implements INodeType { description: INodeTypeDescription = { @@ -67,7 +45,6 @@ export class Matrix implements INodeType { }, ], properties: [ - { displayName: 'Resource', name: 'resource', @@ -115,7 +92,6 @@ export class Matrix implements INodeType { ], }; - methods = { loadOptions: { async getChannels(this: ILoadOptionsFunctions): Promise { @@ -123,25 +99,35 @@ export class Matrix implements INodeType { const joinedRoomsResponse = await matrixApiRequest.call(this, 'GET', '/joined_rooms'); - await Promise.all(joinedRoomsResponse.joined_rooms.map(async (roomId: string) => { - try { - const roomNameResponse = await matrixApiRequest.call(this, 'GET', `/rooms/${roomId}/state/m.room.name`); - returnData.push({ - name: roomNameResponse.name, - value: roomId, - }); - } catch (error) { - // TODO: Check, there is probably another way to get the name of this private-chats - returnData.push({ - name: `Unknown: ${roomId}`, - value: roomId, - }); - } - })); + await Promise.all( + joinedRoomsResponse.joined_rooms.map(async (roomId: string) => { + try { + const roomNameResponse = await matrixApiRequest.call( + this, + 'GET', + `/rooms/${roomId}/state/m.room.name`, + ); + returnData.push({ + name: roomNameResponse.name, + value: roomId, + }); + } catch (error) { + // TODO: Check, there is probably another way to get the name of this private-chats + returnData.push({ + name: `Unknown: ${roomId}`, + value: roomId, + }); + } + }), + ); returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -150,9 +136,7 @@ export class Matrix implements INodeType { }, }; - async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData() as IDataObject[]; const returnData: IDataObject[] = []; const resource = this.getNodeParameter('resource', 0) as string; diff --git a/packages/nodes-base/nodes/Matrix/MediaDescription.ts b/packages/nodes-base/nodes/Matrix/MediaDescription.ts index 98b3aee73e..167cfed738 100644 --- a/packages/nodes-base/nodes/Matrix/MediaDescription.ts +++ b/packages/nodes-base/nodes/Matrix/MediaDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const mediaOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const mediaOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'media', - ], + resource: ['media'], }, }, options: [ @@ -28,7 +24,6 @@ export const mediaOperations: INodeProperties[] = [ ]; export const mediaFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* media:upload */ /* -------------------------------------------------------------------------- */ @@ -42,15 +37,12 @@ export const mediaFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'media', - ], - operation: [ - 'upload', - ], + resource: ['media'], + operation: ['upload'], }, }, - description: 'Room ID to post. Choose from the list, or specify an ID using an expression.', + description: + 'Room ID to post. Choose from the list, or specify an ID using an expression.', required: true, }, { @@ -61,12 +53,8 @@ export const mediaFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'media', - ], - operation: [ - 'upload', - ], + resource: ['media'], + operation: ['upload'], }, }, }, @@ -77,12 +65,8 @@ export const mediaFields: INodeProperties[] = [ default: 'image', displayOptions: { show: { - resource: [ - 'media', - ], - operation: [ - 'upload', - ], + resource: ['media'], + operation: ['upload'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Matrix/MessageDescription.ts b/packages/nodes-base/nodes/Matrix/MessageDescription.ts index 29bac50ebb..1f0313572e 100644 --- a/packages/nodes-base/nodes/Matrix/MessageDescription.ts +++ b/packages/nodes-base/nodes/Matrix/MessageDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const messageOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const messageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'message', - ], + resource: ['message'], }, }, options: [ @@ -34,7 +30,6 @@ export const messageOperations: INodeProperties[] = [ ]; export const messageFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* message:create */ /* -------------------------------------------------------------------------- */ @@ -49,16 +44,13 @@ export const messageFields: INodeProperties[] = [ placeholder: '!123abc:matrix.org', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'message', - ], + operation: ['create'], + resource: ['message'], }, }, required: true, - description: 'The channel to send the message to. Choose from the list, or specify an ID using an expression.', + description: + 'The channel to send the message to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Text', @@ -71,12 +63,8 @@ export const messageFields: INodeProperties[] = [ placeholder: 'Hello from n8n!', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'message', - ], + operation: ['create'], + resource: ['message'], }, }, description: 'The text to send', @@ -86,12 +74,8 @@ export const messageFields: INodeProperties[] = [ name: 'messageType', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'message', - ], + operation: ['create'], + resource: ['message'], }, }, type: 'options', @@ -120,12 +104,8 @@ export const messageFields: INodeProperties[] = [ name: 'messageFormat', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'message', - ], + operation: ['create'], + resource: ['message'], }, }, type: 'options', @@ -142,7 +122,7 @@ export const messageFields: INodeProperties[] = [ }, ], default: 'plain', - description: 'The format of the message\'s body', + description: "The format of the message's body", }, { displayName: 'Fallback Text', @@ -150,25 +130,19 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], - messageFormat: [ - 'org.matrix.custom.html', - ], + resource: ['message'], + operation: ['create'], + messageFormat: ['org.matrix.custom.html'], }, }, type: 'string', typeOptions: { alwaysOpenEditWindow: true, }, - description: 'A plain text message to display in case the HTML cannot be rendered by the Matrix client', + description: + 'A plain text message to display in case the HTML cannot be rendered by the Matrix client', }, - /* ----------------------------------------------------------------------- */ /* message:getAll */ /* ----------------------------------------------------------------------- */ @@ -182,15 +156,12 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'getAll', - ], + resource: ['message'], + operation: ['getAll'], }, }, - description: 'The token to start returning events from. This token can be obtained from a prev_batch token returned for each room by the sync API. Choose from the list, or specify an ID using an expression.', + description: + 'The token to start returning events from. This token can be obtained from a prev_batch token returned for each room by the sync API. Choose from the list, or specify an ID using an expression.', required: true, }, { @@ -200,12 +171,8 @@ export const messageFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'getAll', - ], + resource: ['message'], + operation: ['getAll'], }, }, description: 'Whether to return all results or only up to a given limit', @@ -217,15 +184,9 @@ export const messageFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['message'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -241,12 +202,8 @@ export const messageFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'getAll', - ], + resource: ['message'], + operation: ['getAll'], }, }, default: {}, @@ -257,11 +214,10 @@ export const messageFields: INodeProperties[] = [ name: 'filter', type: 'string', default: '', - description: 'A JSON RoomEventFilter to filter returned events with. More information can be found on this page.', + description: + 'A JSON RoomEventFilter to filter returned events with. More information can be found on this page.', placeholder: '{"contains_url":true,"types":["m.room.message", "m.sticker"]}', }, ], }, - - ]; diff --git a/packages/nodes-base/nodes/Matrix/RoomDescription.ts b/packages/nodes-base/nodes/Matrix/RoomDescription.ts index 4e0baebe02..4a21a883ea 100644 --- a/packages/nodes-base/nodes/Matrix/RoomDescription.ts +++ b/packages/nodes-base/nodes/Matrix/RoomDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const roomOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const roomOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'room', - ], + resource: ['room'], }, }, options: [ @@ -51,7 +47,6 @@ export const roomOperations: INodeProperties[] = [ }, ]; - export const roomFields: INodeProperties[] = [ /* -------------------------------------------------------------------------- */ /* room:create */ @@ -62,12 +57,8 @@ export const roomFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'room', - ], - operation: [ - 'create', - ], + resource: ['room'], + operation: ['create'], }, }, default: '', @@ -80,12 +71,8 @@ export const roomFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'room', - ], - operation: [ - 'create', - ], + resource: ['room'], + operation: ['create'], }, }, options: [ @@ -109,12 +96,8 @@ export const roomFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'room', - ], - operation: [ - 'create', - ], + resource: ['room'], + operation: ['create'], }, }, default: '', @@ -130,12 +113,8 @@ export const roomFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'room', - ], - operation: [ - 'join', - ], + resource: ['room'], + operation: ['join'], }, }, default: '', @@ -149,18 +128,15 @@ export const roomFields: INodeProperties[] = [ displayName: 'Room Name or ID', name: 'roomId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getChannels', }, displayOptions: { show: { - resource: [ - 'room', - ], - operation: [ - 'leave', - ], + resource: ['room'], + operation: ['leave'], }, }, default: '', @@ -174,18 +150,15 @@ export const roomFields: INodeProperties[] = [ displayName: 'Room Name or ID', name: 'roomId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getChannels', }, displayOptions: { show: { - resource: [ - 'room', - ], - operation: [ - 'invite', - ], + resource: ['room'], + operation: ['invite'], }, }, default: '', @@ -198,12 +171,8 @@ export const roomFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'room', - ], - operation: [ - 'invite', - ], + resource: ['room'], + operation: ['invite'], }, }, default: '', @@ -212,7 +181,6 @@ export const roomFields: INodeProperties[] = [ required: true, }, - /* -------------------------------------------------------------------------- */ /* room:kick */ /* -------------------------------------------------------------------------- */ @@ -220,18 +188,15 @@ export const roomFields: INodeProperties[] = [ displayName: 'Room Name or ID', name: 'roomId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getChannels', }, displayOptions: { show: { - resource: [ - 'room', - ], - operation: [ - 'kick', - ], + resource: ['room'], + operation: ['kick'], }, }, default: '', @@ -243,12 +208,8 @@ export const roomFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'room', - ], - operation: [ - 'kick', - ], + resource: ['room'], + operation: ['kick'], }, }, default: '', @@ -262,12 +223,8 @@ export const roomFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'room', - ], - operation: [ - 'kick', - ], + resource: ['room'], + operation: ['kick'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Matrix/RoomMemberDescription.ts b/packages/nodes-base/nodes/Matrix/RoomMemberDescription.ts index da05cf7fd0..2eb8a4aa4b 100644 --- a/packages/nodes-base/nodes/Matrix/RoomMemberDescription.ts +++ b/packages/nodes-base/nodes/Matrix/RoomMemberDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const roomMemberOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const roomMemberOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'roomMember', - ], + resource: ['roomMember'], }, }, options: [ @@ -27,7 +23,6 @@ export const roomMemberOperations: INodeProperties[] = [ }, ]; - export const roomMemberFields: INodeProperties[] = [ /* -------------------------------------------------------------------------- */ /* roomMember:getAll */ @@ -36,18 +31,15 @@ export const roomMemberFields: INodeProperties[] = [ displayName: 'Room Name or ID', name: 'roomId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getChannels', }, displayOptions: { show: { - resource: [ - 'roomMember', - ], - operation: [ - 'getAll', - ], + resource: ['roomMember'], + operation: ['getAll'], }, }, default: '', @@ -59,12 +51,8 @@ export const roomMemberFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - resource: [ - 'roomMember', - ], - operation: [ - 'getAll', - ], + resource: ['roomMember'], + operation: ['getAll'], }, }, default: {}, @@ -76,7 +64,8 @@ export const roomMemberFields: INodeProperties[] = [ name: 'notMembership', type: 'options', default: '', - description: 'Excludes members whose membership is other than selected (uses OR filter with membership)', + description: + 'Excludes members whose membership is other than selected (uses OR filter with membership)', options: [ { name: 'Any', @@ -110,7 +99,8 @@ export const roomMemberFields: INodeProperties[] = [ name: 'membership', type: 'options', default: '', - description: 'Only fetch users with selected membership status (uses OR filter with exclude membership)', + description: + 'Only fetch users with selected membership status (uses OR filter with exclude membership)', options: [ { name: 'Any', @@ -141,6 +131,4 @@ export const roomMemberFields: INodeProperties[] = [ }, ], }, - - ]; diff --git a/packages/nodes-base/nodes/Mattermost/Mattermost.node.ts b/packages/nodes-base/nodes/Mattermost/Mattermost.node.ts index f8d45d5cd9..939584d5ad 100644 --- a/packages/nodes-base/nodes/Mattermost/Mattermost.node.ts +++ b/packages/nodes-base/nodes/Mattermost/Mattermost.node.ts @@ -1,7 +1,4 @@ -import { - INodeTypeBaseDescription, - INodeVersionedType, -} from 'n8n-workflow'; +import { INodeTypeBaseDescription, INodeVersionedType } from 'n8n-workflow'; import { MattermostV1 } from './v1/MattermostV1.node'; import { NodeVersionedType } from '../../src/NodeVersionedType'; diff --git a/packages/nodes-base/nodes/Mattermost/v1/MattermostV1.node.ts b/packages/nodes-base/nodes/Mattermost/v1/MattermostV1.node.ts index a1b1f673a4..e771f1718d 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/MattermostV1.node.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/MattermostV1.node.ts @@ -1,19 +1,12 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - INodeType, - INodeTypeBaseDescription, - INodeTypeDescription, -} from 'n8n-workflow'; +import { INodeType, INodeTypeBaseDescription, INodeTypeDescription } from 'n8n-workflow'; import { versionDescription } from './actions/versionDescription'; import { loadOptions } from './methods'; import { router } from './actions/router'; export class MattermostV1 implements INodeType { - description: INodeTypeDescription; constructor(baseDescription: INodeTypeBaseDescription) { diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/Interfaces.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/Interfaces.ts index dceb5c94c4..38e30df5c6 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/Interfaces.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/Interfaces.ts @@ -1,8 +1,4 @@ -import { - AllEntities, - Entity, - PropertiesOf, -} from 'n8n-workflow'; +import { AllEntities, Entity, PropertiesOf } from 'n8n-workflow'; type MattermostMap = { channel: 'addUser' | 'create' | 'delete' | 'members' | 'restore' | 'statistics' | 'search'; diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/addUser/description.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/addUser/description.ts index 04a017287a..6401255a07 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/addUser/description.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/addUser/description.ts @@ -1,6 +1,4 @@ -import { - ChannelProperties, -} from '../../Interfaces'; +import { ChannelProperties } from '../../Interfaces'; export const channelAddUserDescription: ChannelProperties = [ { @@ -15,15 +13,12 @@ export const channelAddUserDescription: ChannelProperties = [ required: true, displayOptions: { show: { - operation: [ - 'addUser', - ], - resource: [ - 'channel', - ], + operation: ['addUser'], + resource: ['channel'], }, }, - description: 'The ID of the channel to invite user to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the channel to invite user to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'User Name or ID', @@ -37,14 +32,11 @@ export const channelAddUserDescription: ChannelProperties = [ required: true, displayOptions: { show: { - operation: [ - 'addUser', - ], - resource: [ - 'channel', - ], + operation: ['addUser'], + resource: ['channel'], }, }, - description: 'The ID of the user to invite into channel. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the user to invite into channel. Choose from the list, or specify an ID using an expression.', }, ]; diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/addUser/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/addUser/execute.ts index be11d494d8..4b4bee59b9 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/addUser/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/addUser/execute.ts @@ -1,17 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; -export async function addUser(this: IExecuteFunctions, index: number): Promise { +export async function addUser( + this: IExecuteFunctions, + index: number, +): Promise { const channelId = this.getNodeParameter('channelId', index) as string; const body = {} as IDataObject; @@ -24,4 +20,4 @@ export async function addUser(this: IExecuteFunctions, index: number): Promiseexpression.', + description: + 'The Mattermost Team. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Display Name', @@ -33,12 +28,8 @@ export const channelCreateDescription: ChannelProperties = [ placeholder: 'Announcements', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'channel', - ], + operation: ['create'], + resource: ['channel'], }, }, required: true, @@ -52,12 +43,8 @@ export const channelCreateDescription: ChannelProperties = [ placeholder: 'announcements', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'channel', - ], + operation: ['create'], + resource: ['channel'], }, }, required: true, @@ -69,12 +56,8 @@ export const channelCreateDescription: ChannelProperties = [ type: 'options', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'channel', - ], + operation: ['create'], + resource: ['channel'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/create/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/create/execute.ts index 410b96f87d..82d5cdfff7 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/create/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/create/execute.ts @@ -1,17 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; -export async function create(this: IExecuteFunctions, index: number): Promise { +export async function create( + this: IExecuteFunctions, + index: number, +): Promise { const body = {} as IDataObject; const qs = {} as IDataObject; const requestMethod = 'POST'; @@ -27,4 +23,4 @@ export async function create(this: IExecuteFunctions, index: number): Promiseexpression.', + description: + 'The ID of the channel to soft delete. Choose from the list, or specify an ID using an expression.', }, ]; diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/del/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/del/execute.ts index 710f9a5cca..bcc8f92d76 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/del/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/del/execute.ts @@ -1,15 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; export async function del(this: IExecuteFunctions, index: number): Promise { const channelId = this.getNodeParameter('channelId', index) as string; @@ -22,4 +15,4 @@ export async function del(this: IExecuteFunctions, index: number): Promiseexpression.', + description: + 'The Mattermost Team. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Channel Name or ID', @@ -31,24 +26,19 @@ export const channelMembersDescription: ChannelProperties = [ type: 'options', typeOptions: { loadOptionsMethod: 'getChannelsInTeam', - loadOptionsDependsOn: [ - 'teamId', - ], + loadOptionsDependsOn: ['teamId'], }, options: [], default: '', required: true, displayOptions: { show: { - operation: [ - 'members', - ], - resource: [ - 'channel', - ], + operation: ['members'], + resource: ['channel'], }, }, - description: 'The Mattermost Team. Choose from the list, or specify an ID using an expression.', + description: + 'The Mattermost Team. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Resolve Data', @@ -56,17 +46,14 @@ export const channelMembersDescription: ChannelProperties = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'members', - ], + resource: ['channel'], + operation: ['members'], }, }, default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default the response only contain the ID of the user. If this option gets activated, it will resolve the user automatically.', + description: + 'By default the response only contain the ID of the user. If this option gets activated, it will resolve the user automatically.', }, { displayName: 'Return All', @@ -74,12 +61,8 @@ export const channelMembersDescription: ChannelProperties = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'members', - ], - resource: [ - 'channel', - ], + operation: ['members'], + resource: ['channel'], }, }, default: true, @@ -91,15 +74,9 @@ export const channelMembersDescription: ChannelProperties = [ type: 'number', displayOptions: { show: { - operation: [ - 'members', - ], - resource: [ - 'channel', - ], - returnAll: [ - false, - ], + operation: ['members'], + resource: ['channel'], + returnAll: [false], }, }, typeOptions: { @@ -110,4 +87,3 @@ export const channelMembersDescription: ChannelProperties = [ description: 'Max number of results to return', }, ]; - diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/members/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/members/execute.ts index e67059ed06..0f4a260b10 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/members/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/members/execute.ts @@ -1,23 +1,18 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, - apiRequestAllItems, -} from '../../../transport'; +import { apiRequest, apiRequestAllItems } from '../../../transport'; -export async function members(this: IExecuteFunctions, index: number): Promise { +export async function members( + this: IExecuteFunctions, + index: number, +): Promise { const channelId = this.getNodeParameter('channelId', index) as string; const returnAll = this.getNodeParameter('returnAll', index) as boolean; const resolveData = this.getNodeParameter('resolveData', index) as boolean; const limit = this.getNodeParameter('limit', index, 0) as number; - + const body = {} as IDataObject; const qs = {} as IDataObject; const requestMethod = 'GET'; @@ -48,4 +43,4 @@ export async function members(this: IExecuteFunctions, index: number): Promise { +export async function restore( + this: IExecuteFunctions, + index: number, +): Promise { const channelId = this.getNodeParameter('channelId', index) as string; const body = {} as IDataObject; @@ -20,8 +15,7 @@ export async function restore(this: IExecuteFunctions, index: number): Promiseexpression.', + description: + 'The Mattermost Team. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Search Term', @@ -33,12 +28,8 @@ export const channelSearchDescription: ChannelProperties = [ placeholder: 'General', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'channel', - ], + operation: ['search'], + resource: ['channel'], }, }, required: true, @@ -52,12 +43,8 @@ export const channelSearchDescription: ChannelProperties = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'channel', - ], + operation: ['search'], + resource: ['channel'], }, }, }, @@ -73,15 +60,9 @@ export const channelSearchDescription: ChannelProperties = [ }, displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'channel', - ], - returnAll: [ - false, - ], + operation: ['search'], + resource: ['channel'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/search/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/search/execute.ts index b327cd0c0f..058febeb4f 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/search/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/search/execute.ts @@ -1,17 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; -export async function search(this: IExecuteFunctions, index: number): Promise { +export async function search( + this: IExecuteFunctions, + index: number, +): Promise { const body = {} as IDataObject; const qs = {} as IDataObject; const requestMethod = 'POST'; @@ -29,4 +25,4 @@ export async function search(this: IExecuteFunctions, index: number): Promiseexpression.', + description: + 'The ID of the channel to get the statistics from. Choose from the list, or specify an ID using an expression.', }, ]; - diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/statistics/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/statistics/execute.ts index dd923e8381..fe9c3ef848 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/statistics/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/statistics/execute.ts @@ -1,17 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; -export async function statistics(this: IExecuteFunctions, index: number): Promise { +export async function statistics( + this: IExecuteFunctions, + index: number, +): Promise { const channelId = this.getNodeParameter('channelId', index) as string; const body = {} as IDataObject; @@ -22,4 +18,4 @@ export async function statistics(this: IExecuteFunctions, index: number): Promis const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData); -} \ No newline at end of file +} diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/statistics/index.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/statistics/index.ts index 69461b7729..946856f3b1 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/statistics/index.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/statistics/index.ts @@ -1,7 +1,4 @@ import { statistics as execute } from './execute'; import { channelStatisticsDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/message/del/description.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/message/del/description.ts index 2586aadb5e..b464c8c7e5 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/message/del/description.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/message/del/description.ts @@ -1,6 +1,4 @@ -import { - MessageProperties, -} from '../../Interfaces'; +import { MessageProperties } from '../../Interfaces'; export const messageDeleteDescription: MessageProperties = [ { @@ -10,12 +8,8 @@ export const messageDeleteDescription: MessageProperties = [ required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'delete', - ], + resource: ['message'], + operation: ['delete'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/message/del/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/message/del/execute.ts index 28f074c225..20571d3cb1 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/message/del/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/message/del/execute.ts @@ -1,15 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; export async function del(this: IExecuteFunctions, index: number): Promise { const postId = this.getNodeParameter('postId', index) as string; @@ -22,4 +15,4 @@ export async function del(this: IExecuteFunctions, index: number): Promiseexpression.', + description: + 'The ID of the channel to post to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Message', @@ -35,12 +30,8 @@ export const messagePostDescription: MessageProperties = [ default: '', displayOptions: { show: { - operation: [ - 'post', - ], - resource: [ - 'message', - ], + operation: ['post'], + resource: ['message'], }, }, description: 'The text to send', @@ -55,12 +46,8 @@ export const messagePostDescription: MessageProperties = [ }, displayOptions: { show: { - operation: [ - 'post', - ], - resource: [ - 'message', - ], + operation: ['post'], + resource: ['message'], }, }, default: {}, @@ -71,7 +58,8 @@ export const messagePostDescription: MessageProperties = [ displayName: 'Actions', name: 'actions', placeholder: 'Add Actions', - description: 'Actions to add to message. More information can be found here.', + description: + 'Actions to add to message. More information can be found here.', type: 'fixedCollection', typeOptions: { multipleValues: true, @@ -105,9 +93,7 @@ export const messagePostDescription: MessageProperties = [ type: 'options', displayOptions: { show: { - type: [ - 'select', - ], + type: ['select'], }, }, options: [ @@ -123,7 +109,6 @@ export const messagePostDescription: MessageProperties = [ name: 'Users', value: 'users', }, - ], default: 'custom', description: 'The type of the action', @@ -139,12 +124,8 @@ export const messagePostDescription: MessageProperties = [ }, displayOptions: { show: { - data_source: [ - 'custom', - ], - type: [ - 'select', - ], + data_source: ['custom'], + type: ['select'], }, }, default: {}, @@ -416,12 +397,8 @@ export const messagePostDescription: MessageProperties = [ type: 'collection', displayOptions: { show: { - operation: [ - 'post', - ], - resource: [ - 'message', - ], + operation: ['post'], + resource: ['message'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/message/post/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/message/post/execute.ts index 16ca22f48a..40e12ccf43 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/message/post/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/message/post/execute.ts @@ -1,19 +1,10 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; -import { - IAttachment, -} from '../../Interfaces'; +import { IAttachment } from '../../Interfaces'; export async function post(this: IExecuteFunctions, index: number): Promise { const body = {} as IDataObject; @@ -58,7 +49,6 @@ export async function post(this: IExecuteFunctions, index: number): Promiseexpression.', + description: + 'ID of the user to send the ephemeral message to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Channel Name or ID', @@ -36,15 +31,12 @@ export const messagePostEphemeralDescription: MessageProperties = [ required: true, displayOptions: { show: { - operation: [ - 'postEphemeral', - ], - resource: [ - 'message', - ], + operation: ['postEphemeral'], + resource: ['message'], }, }, - description: 'ID of the channel to send the ephemeral message in. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the channel to send the ephemeral message in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Message', @@ -56,12 +48,8 @@ export const messagePostEphemeralDescription: MessageProperties = [ default: '', displayOptions: { show: { - operation: [ - 'postEphemeral', - ], - resource: [ - 'message', - ], + operation: ['postEphemeral'], + resource: ['message'], }, }, description: 'Text to send in the ephemeral message', diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/message/postEphemeral/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/message/postEphemeral/execute.ts index 3f48f0df1c..6ca5a50439 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/message/postEphemeral/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/message/postEphemeral/execute.ts @@ -1,21 +1,17 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; -export async function postEphemeral(this: IExecuteFunctions, index: number): Promise { +export async function postEphemeral( + this: IExecuteFunctions, + index: number, +): Promise { const qs = {} as IDataObject; const requestMethod = 'POST'; const endpoint = `posts/ephemeral`; - + const body = { user_id: this.getNodeParameter('userId', index), post: { @@ -23,8 +19,8 @@ export async function postEphemeral(this: IExecuteFunctions, index: number): Pro message: this.getNodeParameter('message', index), }, } as IDataObject; - + const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - + return this.helpers.returnJsonArray(responseData); -} \ No newline at end of file +} diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/message/postEphemeral/index.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/message/postEphemeral/index.ts index 5683df6fe6..db3575bba9 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/message/postEphemeral/index.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/message/postEphemeral/index.ts @@ -1,7 +1,4 @@ import { postEphemeral as execute } from './execute'; import { messagePostEphemeralDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/reaction/create/description.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/reaction/create/description.ts index bcf6727de8..04e4d938d5 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/reaction/create/description.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/reaction/create/description.ts @@ -1,6 +1,4 @@ -import { - ReactionProperties, -} from '../../Interfaces'; +import { ReactionProperties } from '../../Interfaces'; export const reactionCreateDescription: ReactionProperties = [ { @@ -15,15 +13,12 @@ export const reactionCreateDescription: ReactionProperties = [ required: true, displayOptions: { show: { - resource: [ - 'reaction', - ], - operation: [ - 'create', - ], + resource: ['reaction'], + operation: ['create'], }, }, - description: 'ID of the user sending the reaction. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user sending the reaction. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Post ID', @@ -34,15 +29,12 @@ export const reactionCreateDescription: ReactionProperties = [ required: true, displayOptions: { show: { - resource: [ - 'reaction', - ], - operation: [ - 'create', - ], + resource: ['reaction'], + operation: ['create'], }, }, - description: 'ID of the post to react to. Obtainable from the post link: https://mattermost.internal.n8n.io/[server]/pl/[postId]', + description: + 'ID of the post to react to. Obtainable from the post link: https://mattermost.internal.n8n.io/[server]/pl/[postId]', }, { displayName: 'Emoji Name', @@ -52,12 +44,8 @@ export const reactionCreateDescription: ReactionProperties = [ required: true, displayOptions: { show: { - resource: [ - 'reaction', - ], - operation: [ - 'create', - ], + resource: ['reaction'], + operation: ['create'], }, }, description: 'Emoji to use for this reaction', diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/reaction/create/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/reaction/create/execute.ts index 7c8d3d3172..b33acf035f 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/reaction/create/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/reaction/create/execute.ts @@ -1,17 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; -export async function create(this: IExecuteFunctions, index: number): Promise { +export async function create( + this: IExecuteFunctions, + index: number, +): Promise { const qs = {} as IDataObject; const requestMethod = 'POST'; const endpoint = 'reactions'; @@ -22,8 +18,7 @@ export async function create(this: IExecuteFunctions, index: number): Promiseexpression.', + description: + 'ID of the user whose reaction to delete. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Post ID', @@ -34,15 +29,12 @@ export const reactionDeleteDescription: ReactionProperties = [ required: true, displayOptions: { show: { - resource: [ - 'reaction', - ], - operation: [ - 'delete', - ], + resource: ['reaction'], + operation: ['delete'], }, }, - description: 'ID of the post whose reaction to delete. Obtainable from the post link: https://mattermost.internal.n8n.io/[server]/pl/[postId]', + description: + 'ID of the post whose reaction to delete. Obtainable from the post link: https://mattermost.internal.n8n.io/[server]/pl/[postId]', }, { displayName: 'Emoji Name', @@ -52,12 +44,8 @@ export const reactionDeleteDescription: ReactionProperties = [ required: true, displayOptions: { show: { - resource: [ - 'reaction', - ], - operation: [ - 'delete', - ], + resource: ['reaction'], + operation: ['delete'], }, }, description: 'Name of the emoji to delete', diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/reaction/del/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/reaction/del/execute.ts index eabd514c4e..feec92dd25 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/reaction/del/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/reaction/del/execute.ts @@ -1,15 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; export async function del(this: IExecuteFunctions, index: number): Promise { const userId = this.getNodeParameter('userId', index) as string; @@ -24,4 +17,4 @@ export async function del(this: IExecuteFunctions, index: number): Promise { +export async function getAll( + this: IExecuteFunctions, + index: number, +): Promise { const postId = this.getNodeParameter('postId', index) as string; const limit = this.getNodeParameter('limit', 0, 0) as number; @@ -25,4 +21,4 @@ export async function getAll(this: IExecuteFunctions, index: number): Promise { +export async function create( + this: IExecuteFunctions, + index: number, +): Promise { const username = this.getNodeParameter('username', index) as string; const authService = this.getNodeParameter('authService', index) as string; const additionalFields = this.getNodeParameter('additionalFields', index) as IDataObject; - + const qs = {} as IDataObject; const requestMethod = 'POST'; const endpoint = 'users'; @@ -40,4 +36,4 @@ export async function create(this: IExecuteFunctions, index: number): Promise { +export async function deactive( + this: IExecuteFunctions, + index: number, +): Promise { const userId = this.getNodeParameter('userId', index) as string; const qs = {} as IDataObject; const requestMethod = 'DELETE'; @@ -21,4 +17,4 @@ export async function deactive(this: IExecuteFunctions, index: number): Promise< const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData); -} \ No newline at end of file +} diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/user/deactive/index.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/user/deactive/index.ts index b1718aa1f5..c94f40b60d 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/user/deactive/index.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/user/deactive/index.ts @@ -1,7 +1,4 @@ import { deactive as execute } from './execute'; import { userDeactiveDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getAll/description.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getAll/description.ts index f5e278acda..cbbef83a92 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getAll/description.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getAll/description.ts @@ -1,6 +1,4 @@ -import { - UserProperties, -} from '../../Interfaces'; +import { UserProperties } from '../../Interfaces'; export const userGetAllDescription: UserProperties = [ { @@ -9,12 +7,8 @@ export const userGetAllDescription: UserProperties = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, default: true, @@ -26,15 +20,9 @@ export const userGetAllDescription: UserProperties = [ type: 'number', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['user'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -51,12 +39,8 @@ export const userGetAllDescription: UserProperties = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getAll/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getAll/execute.ts index 576c93df02..c55687d6d5 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getAll/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getAll/execute.ts @@ -1,23 +1,15 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, NodeOperationError } from 'n8n-workflow'; -import { - apiRequest, - apiRequestAllItems, -} from '../../../transport'; +import { apiRequest, apiRequestAllItems } from '../../../transport'; -import { - snakeCase, -} from 'change-case'; +import { snakeCase } from 'change-case'; -export async function getAll(this: IExecuteFunctions, index: number): Promise { +export async function getAll( + this: IExecuteFunctions, + index: number, +): Promise { const returnAll = this.getNodeParameter('returnAll', index) as boolean; const additionalFields = this.getNodeParameter('additionalFields', index) as IDataObject; @@ -53,27 +45,51 @@ export async function getAll(this: IExecuteFunctions, index: number): Promise { +export async function getByEmail( + this: IExecuteFunctions, + index: number, +): Promise { const email = this.getNodeParameter('email', index) as string; - + const qs = {} as IDataObject; const requestMethod = 'GET'; const endpoint = `users/email/${email}`; @@ -22,4 +18,4 @@ export async function getByEmail(this: IExecuteFunctions, index: number): Promis const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData); -} \ No newline at end of file +} diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getByEmail/index.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getByEmail/index.ts index bf29668fa0..cfea09fd8d 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getByEmail/index.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getByEmail/index.ts @@ -1,7 +1,4 @@ import { getByEmail as execute } from './execute'; import { userGetByEmailDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getById/description.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getById/description.ts index e8cf8a33b9..1c43e77d49 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getById/description.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getById/description.ts @@ -1,6 +1,4 @@ -import { - UserProperties, -} from '../../Interfaces'; +import { UserProperties } from '../../Interfaces'; export const userGetByIdDescription: UserProperties = [ { @@ -10,16 +8,12 @@ export const userGetByIdDescription: UserProperties = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getById', - ], + resource: ['user'], + operation: ['getById'], }, }, default: '', - description: 'User\'s ID', + description: "User's ID", }, { displayName: 'Additional Fields', @@ -28,12 +22,8 @@ export const userGetByIdDescription: UserProperties = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getById', - ], + resource: ['user'], + operation: ['getById'], }, }, default: {}, @@ -43,7 +33,8 @@ export const userGetByIdDescription: UserProperties = [ name: 'since', type: 'dateTime', default: '', - description: 'Only return users that have been modified since the given Unix timestamp (in milliseconds)', + description: + 'Only return users that have been modified since the given Unix timestamp (in milliseconds)', }, ], }, diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getById/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getById/execute.ts index 7ad792c658..ebe1c5fc29 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getById/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getById/execute.ts @@ -1,17 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; -export async function getById(this: IExecuteFunctions, index: number): Promise { +export async function getById( + this: IExecuteFunctions, + index: number, +): Promise { const qs = {} as IDataObject; const requestMethod = 'POST'; const endpoint = 'users/ids'; @@ -26,4 +22,4 @@ export async function getById(this: IExecuteFunctions, index: number): Promiseexpression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTeams', }, required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'invite', - ], + resource: ['user'], + operation: ['invite'], }, }, default: '', @@ -31,15 +26,11 @@ export const userInviteDescription: UserProperties = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'invite', - ], + resource: ['user'], + operation: ['invite'], }, }, default: '', - description: 'User\'s email. Multiple emails can be set separated by comma.', + description: "User's email. Multiple emails can be set separated by comma.", }, ]; diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/user/invite/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/user/invite/execute.ts index 03312da773..c05b825b5a 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/user/invite/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/user/invite/execute.ts @@ -1,22 +1,17 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; -export async function invite(this: IExecuteFunctions, index: number): Promise { - +export async function invite( + this: IExecuteFunctions, + index: number, +): Promise { const teamId = this.getNodeParameter('teamId', index) as string; const emails = (this.getNodeParameter('emails', index) as string).split(','); - + const qs = {} as IDataObject; const requestMethod = 'POST'; const endpoint = `teams/${teamId}/invite/email`; @@ -25,4 +20,4 @@ export async function invite(this: IExecuteFunctions, index: number): Promise { @@ -21,11 +19,13 @@ export async function getChannels(this: ILoadOptionsFunctions): Promise { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -43,7 +47,9 @@ export async function getChannels(this: ILoadOptionsFunctions): Promise { +export async function getChannelsInTeam( + this: ILoadOptionsFunctions, +): Promise { const teamId = this.getCurrentNodeParameter('teamId'); const endpoint = `users/me/teams/${teamId}/channels`; const responseData = await apiRequest.call(this, 'GET', endpoint, {}); @@ -55,15 +61,15 @@ export async function getChannelsInTeam(this: ILoadOptionsFunctions): Promise { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -94,7 +104,6 @@ export async function getTeams(this: ILoadOptionsFunctions): Promise { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -126,7 +139,6 @@ export async function getUsers(this: ILoadOptionsFunctions): Promise { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); return returnData; } - diff --git a/packages/nodes-base/nodes/Mattermost/v1/transport/index.ts b/packages/nodes-base/nodes/Mattermost/v1/transport/index.ts index 96fd780369..fccdc45302 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/transport/index.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/transport/index.ts @@ -1,8 +1,4 @@ -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { GenericValue, @@ -44,7 +40,6 @@ export async function apiRequestAllItems( body: IDataObject = {}, query: IDataObject = {}, ) { - const returnData: IDataObject[] = []; let responseData; @@ -55,9 +50,7 @@ export async function apiRequestAllItems( responseData = await apiRequest.call(this, method, endpoint, body, query); query.page++; returnData.push.apply(returnData, responseData); - } while ( - responseData.length !== 0 - ); + } while (responseData.length !== 0); return returnData; } diff --git a/packages/nodes-base/nodes/Mautic/CampaignContactDescription.ts b/packages/nodes-base/nodes/Mautic/CampaignContactDescription.ts index 5c9b06ea22..8eabc11f2e 100644 --- a/packages/nodes-base/nodes/Mautic/CampaignContactDescription.ts +++ b/packages/nodes-base/nodes/Mautic/CampaignContactDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const campaignContactOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const campaignContactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'campaignContact', - ], + resource: ['campaignContact'], }, }, options: [ @@ -34,7 +30,6 @@ export const campaignContactOperations: INodeProperties[] = [ ]; export const campaignContactFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* campaignContact:add */ /* -------------------------------------------------------------------------- */ @@ -45,39 +40,28 @@ export const campaignContactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'campaignContact', - ], - operation: [ - 'add', - 'remove', - ], + resource: ['campaignContact'], + operation: ['add', 'remove'], }, }, default: '', }, { - displayName: 'Campaign Name or ID', name: 'campaignId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, displayOptions: { show: { - resource: [ - 'campaignContact', - ], - operation: [ - 'add', - 'remove', - ], + resource: ['campaignContact'], + operation: ['add', 'remove'], }, }, typeOptions: { loadOptionsMethod: 'getCampaigns', }, default: '', - }, ]; diff --git a/packages/nodes-base/nodes/Mautic/CompanyContactDescription.ts b/packages/nodes-base/nodes/Mautic/CompanyContactDescription.ts index 50699f0f85..d5d815fe01 100644 --- a/packages/nodes-base/nodes/Mautic/CompanyContactDescription.ts +++ b/packages/nodes-base/nodes/Mautic/CompanyContactDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const companyContactOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const companyContactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'companyContact', - ], + resource: ['companyContact'], }, }, options: [ @@ -34,7 +30,6 @@ export const companyContactOperations: INodeProperties[] = [ ]; export const companyContactFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* companyContact:add */ /* -------------------------------------------------------------------------- */ @@ -44,13 +39,8 @@ export const companyContactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'companyContact', - ], - operation: [ - 'add', - 'remove', - ], + resource: ['companyContact'], + operation: ['add', 'remove'], }, }, default: '', @@ -62,13 +52,8 @@ export const companyContactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'companyContact', - ], - operation: [ - 'add', - 'remove', - ], + resource: ['companyContact'], + operation: ['add', 'remove'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Mautic/CompanyDescription.ts b/packages/nodes-base/nodes/Mautic/CompanyDescription.ts index 534722cba0..7b80e70b31 100644 --- a/packages/nodes-base/nodes/Mautic/CompanyDescription.ts +++ b/packages/nodes-base/nodes/Mautic/CompanyDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const companyOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const companyOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'company', - ], + resource: ['company'], }, }, options: [ @@ -52,7 +48,6 @@ export const companyOperations: INodeProperties[] = [ ]; export const companyFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* company:create */ /* -------------------------------------------------------------------------- */ @@ -62,12 +57,8 @@ export const companyFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], + resource: ['company'], + operation: ['create'], }, }, default: '', @@ -79,12 +70,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], + resource: ['company'], + operation: ['create'], }, }, default: true, @@ -98,12 +85,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], + resource: ['company'], + operation: ['create'], }, }, options: [ @@ -196,7 +179,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyFields', }, default: '', - description: 'ID of the field to set. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Field Value', @@ -225,7 +209,8 @@ export const companyFields: INodeProperties[] = [ displayName: 'Industry Name or ID', name: 'industry', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getIndustries', }, @@ -275,12 +260,8 @@ export const companyFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'company', - ], + operation: ['update'], + resource: ['company'], }, }, default: '', @@ -292,12 +273,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'update', - ], + resource: ['company'], + operation: ['update'], }, }, default: true, @@ -311,12 +288,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'update', - ], + resource: ['company'], + operation: ['update'], }, }, options: [ @@ -415,7 +388,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyFields', }, default: '', - description: 'ID of the field to set. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Field Value', @@ -444,7 +418,8 @@ export const companyFields: INodeProperties[] = [ displayName: 'Industry Name or ID', name: 'industry', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getIndustries', }, @@ -494,12 +469,8 @@ export const companyFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'company', - ], + operation: ['get'], + resource: ['company'], }, }, default: '', @@ -511,12 +482,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'get', - ], + resource: ['company'], + operation: ['get'], }, }, default: true, @@ -532,12 +499,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], + resource: ['company'], + operation: ['getAll'], }, }, default: false, @@ -549,15 +512,9 @@ export const companyFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['company'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -573,12 +530,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], + resource: ['company'], + operation: ['getAll'], }, }, default: true, @@ -592,12 +545,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], + resource: ['company'], + operation: ['getAll'], }, }, options: [ @@ -626,7 +575,8 @@ export const companyFields: INodeProperties[] = [ loadOptionsMethod: 'getCompanyFields', }, default: '', - description: 'Column to sort by. Can use any column listed in the response. Choose from the list, or specify an ID using an expression.', + description: + 'Column to sort by. Can use any column listed in the response. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Search', @@ -646,12 +596,8 @@ export const companyFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'company', - ], + operation: ['delete'], + resource: ['company'], }, }, default: '', @@ -663,12 +609,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'delete', - ], + resource: ['company'], + operation: ['delete'], }, }, default: true, diff --git a/packages/nodes-base/nodes/Mautic/ContactDescription.ts b/packages/nodes-base/nodes/Mautic/ContactDescription.ts index 07a50ad61e..d0ecc0d3ca 100644 --- a/packages/nodes-base/nodes/Mautic/ContactDescription.ts +++ b/packages/nodes-base/nodes/Mautic/ContactDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const contactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contact', - ], + resource: ['contact'], }, }, options: [ @@ -31,8 +27,8 @@ export const contactOperations: INodeProperties[] = [ { name: 'Edit Contact Points', value: 'editContactPoint', - description: 'Edit contact\'s points', - action: 'Edit a contact\'s points', + description: "Edit contact's points", + action: "Edit a contact's points", }, { name: 'Edit Do Not Contact List', @@ -70,7 +66,6 @@ export const contactOperations: INodeProperties[] = [ ]; export const contactFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* contact:create */ /* -------------------------------------------------------------------------- */ @@ -81,12 +76,8 @@ export const contactFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], + operation: ['create'], + resource: ['contact'], }, }, }, @@ -97,15 +88,9 @@ export const contactFields: INodeProperties[] = [ placeholder: 'name@email.com', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['contact'], + operation: ['create'], + jsonParameters: [false], }, }, default: '', @@ -117,15 +102,9 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['contact'], + operation: ['create'], + jsonParameters: [false], }, }, default: '', @@ -136,15 +115,9 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['contact'], + operation: ['create'], + jsonParameters: [false], }, }, default: '', @@ -153,21 +126,16 @@ export const contactFields: INodeProperties[] = [ displayName: 'Primary Company Name or ID', name: 'company', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCompanies', }, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['contact'], + operation: ['create'], + jsonParameters: [false], }, }, default: '', @@ -178,15 +146,9 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['contact'], + operation: ['create'], + jsonParameters: [false], }, }, default: '', @@ -197,15 +159,9 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['contact'], + operation: ['create'], + jsonParameters: [false], }, }, default: '', @@ -216,15 +172,9 @@ export const contactFields: INodeProperties[] = [ type: 'json', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], - jsonParameters: [ - true, - ], + operation: ['create'], + resource: ['contact'], + jsonParameters: [true], }, }, default: '', @@ -238,12 +188,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, options: [ @@ -346,7 +292,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactFields', }, default: '', - description: 'ID of the field to set. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Field Value', @@ -430,7 +377,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Stage Name or ID', name: 'stage', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getStages', }, @@ -440,7 +388,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getTags', }, @@ -518,12 +467,8 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'contact', - ], + operation: ['update'], + resource: ['contact'], }, }, default: '', @@ -535,12 +480,8 @@ export const contactFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'contact', - ], + operation: ['update'], + resource: ['contact'], }, }, }, @@ -552,12 +493,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, options: [ @@ -567,9 +504,7 @@ export const contactFields: INodeProperties[] = [ type: 'json', displayOptions: { show: { - '/jsonParameters': [ - true, - ], + '/jsonParameters': [true], }, }, default: '', @@ -585,9 +520,7 @@ export const contactFields: INodeProperties[] = [ }, displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: {}, @@ -642,9 +575,7 @@ export const contactFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, options: [ @@ -665,9 +596,7 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: '', @@ -695,7 +624,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactFields', }, default: '', - description: 'ID of the field to set. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Field Value', @@ -715,9 +645,7 @@ export const contactFields: INodeProperties[] = [ placeholder: 'name@email.com', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: '', @@ -729,9 +657,7 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: '', @@ -742,9 +668,7 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: '', @@ -755,9 +679,7 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: false, @@ -768,9 +690,7 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: '', @@ -782,9 +702,7 @@ export const contactFields: INodeProperties[] = [ type: 'dateTime', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: '', @@ -796,9 +714,7 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: '', @@ -810,9 +726,7 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: '', @@ -823,9 +737,7 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: '', @@ -837,9 +749,7 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: '', @@ -850,9 +760,7 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: '', @@ -861,15 +769,14 @@ export const contactFields: INodeProperties[] = [ displayName: 'Primary Company Name or ID', name: 'company', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCompanies', }, displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: '', @@ -880,9 +787,7 @@ export const contactFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, options: [ @@ -903,9 +808,7 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: false, @@ -914,12 +817,11 @@ export const contactFields: INodeProperties[] = [ displayName: 'Stage Name or ID', name: 'stage', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, typeOptions: { @@ -931,12 +833,11 @@ export const contactFields: INodeProperties[] = [ displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, typeOptions: { @@ -950,9 +851,7 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: '', @@ -964,9 +863,7 @@ export const contactFields: INodeProperties[] = [ type: 'fixedCollection', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, typeOptions: { @@ -1024,9 +921,7 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: '', @@ -1037,9 +932,7 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: '', @@ -1057,12 +950,8 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'editDoNotContactList', - ], - resource: [ - 'contact', - ], + operation: ['editDoNotContactList'], + resource: ['contact'], }, }, default: '', @@ -1073,12 +962,8 @@ export const contactFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - operation: [ - 'editDoNotContactList', - ], - resource: [ - 'contact', - ], + operation: ['editDoNotContactList'], + resource: ['contact'], }, }, options: [ @@ -1102,12 +987,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'editDoNotContactList', - ], + resource: ['contact'], + operation: ['editDoNotContactList'], }, }, options: [ @@ -1130,12 +1011,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'editDoNotContactList', - ], + resource: ['contact'], + operation: ['editDoNotContactList'], }, }, options: [ @@ -1177,12 +1054,8 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'editContactPoint', - ], - resource: [ - 'contact', - ], + operation: ['editContactPoint'], + resource: ['contact'], }, }, default: '', @@ -1193,12 +1066,8 @@ export const contactFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - operation: [ - 'editContactPoint', - ], - resource: [ - 'contact', - ], + operation: ['editContactPoint'], + resource: ['contact'], }, }, options: [ @@ -1221,12 +1090,8 @@ export const contactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'editContactPoint', - ], - resource: [ - 'contact', - ], + operation: ['editContactPoint'], + resource: ['contact'], }, }, default: 0, @@ -1240,12 +1105,8 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], + operation: ['get'], + resource: ['contact'], }, }, default: '', @@ -1260,12 +1121,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, default: false, @@ -1277,15 +1134,9 @@ export const contactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['contact'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -1305,12 +1156,8 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'contact', - ], + operation: ['delete'], + resource: ['contact'], }, }, default: '', @@ -1325,16 +1172,10 @@ export const contactFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - 'resource': [ - 'contact', - ], + resource: ['contact'], }, hide: { - operation: [ - 'sendEmail', - 'editDoNotContactList', - 'editContactPoint', - ], + operation: ['sendEmail', 'editDoNotContactList', 'editContactPoint'], }, }, placeholder: 'Add Option', @@ -1346,12 +1187,8 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/resource': [ - 'contact', - ], - '/operation': [ - 'getAll', - ], + '/resource': ['contact'], + '/operation': ['getAll'], }, }, default: '', @@ -1363,12 +1200,8 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/resource': [ - 'contact', - ], - '/operation': [ - 'getAll', - ], + '/resource': ['contact'], + '/operation': ['getAll'], }, }, default: '', @@ -1380,12 +1213,8 @@ export const contactFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - '/resource': [ - 'contact', - ], - '/operation': [ - 'getAll', - ], + '/resource': ['contact'], + '/operation': ['getAll'], }, }, default: '', @@ -1407,12 +1236,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - '/resource': [ - 'contact', - ], - '/operation': [ - 'getAll', - ], + '/resource': ['contact'], + '/operation': ['getAll'], }, }, default: false, @@ -1424,12 +1249,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - '/resource': [ - 'contact', - ], - '/operation': [ - 'getAll', - ], + '/resource': ['contact'], + '/operation': ['getAll'], }, }, default: false, @@ -1441,7 +1262,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default only the data of the fields get returned. If this options gets set the RAW response with all data gets returned.', + description: + 'By default only the data of the fields get returned. If this options gets set the RAW response with all data gets returned.', }, ], }, @@ -1452,16 +1274,13 @@ export const contactFields: INodeProperties[] = [ displayName: 'Campaign Email Name or ID', name: 'campaignEmailId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'sendEmail', - ], + resource: ['contact'], + operation: ['sendEmail'], }, }, typeOptions: { @@ -1476,12 +1295,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'sendEmail', - ], + resource: ['contact'], + operation: ['sendEmail'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Mautic/ContactSegmentDescription.ts b/packages/nodes-base/nodes/Mautic/ContactSegmentDescription.ts index 2e009300fb..a4ae14720d 100644 --- a/packages/nodes-base/nodes/Mautic/ContactSegmentDescription.ts +++ b/packages/nodes-base/nodes/Mautic/ContactSegmentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactSegmentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const contactSegmentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contactSegment', - ], + resource: ['contactSegment'], }, }, options: [ @@ -34,7 +30,6 @@ export const contactSegmentOperations: INodeProperties[] = [ ]; export const contactSegmentFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* contactSegment:add */ /* -------------------------------------------------------------------------- */ @@ -45,39 +40,28 @@ export const contactSegmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contactSegment', - ], - operation: [ - 'add', - 'remove', - ], + resource: ['contactSegment'], + operation: ['add', 'remove'], }, }, default: '', }, { - displayName: 'Segment Name or ID', name: 'segmentId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, displayOptions: { show: { - resource: [ - 'contactSegment', - ], - operation: [ - 'add', - 'remove', - ], + resource: ['contactSegment'], + operation: ['add', 'remove'], }, }, typeOptions: { loadOptionsMethod: 'getSegments', }, default: '', - }, ]; diff --git a/packages/nodes-base/nodes/Mautic/GenericFunctions.ts b/packages/nodes-base/nodes/Mautic/GenericFunctions.ts index 0ec61e7411..96b566282c 100644 --- a/packages/nodes-base/nodes/Mautic/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mautic/GenericFunctions.ts @@ -5,14 +5,19 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, - JsonObject, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, JsonObject, NodeApiError } from 'n8n-workflow'; import { OptionsWithUri } from 'request'; -export async function mauticApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query?: IDataObject, uri?: string): Promise { // tslint:disable-line:no-any +export async function mauticApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query?: IDataObject, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0, 'credentials') as string; const options: OptionsWithUri = { @@ -25,7 +30,6 @@ export async function mauticApiRequest(this: IHookFunctions | IExecuteFunctions }; try { - let returnData; if (authenticationMethod === 'credentials') { @@ -41,7 +45,9 @@ export async function mauticApiRequest(this: IHookFunctions | IExecuteFunctions options.uri = `${baseUrl.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl}${options.uri}`; //@ts-ignore - returnData = await this.helpers.requestOAuth2.call(this, 'mauticOAuth2Api', options, { includeCredentialsOnRefreshOnBody: true }); + returnData = await this.helpers.requestOAuth2.call(this, 'mauticOAuth2Api', options, { + includeCredentialsOnRefreshOnBody: true, + }); } if (returnData.errors) { @@ -59,8 +65,16 @@ export async function mauticApiRequest(this: IHookFunctions | IExecuteFunctions * Make an API request to paginated mautic endpoint * and return all results */ -export async function mauticApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function mauticApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -77,13 +91,14 @@ export async function mauticApiRequestAllItems(this: IHookFunctions | IExecuteFu data = []; } while ( responseData.total !== undefined && - (returnData.length - parseInt(responseData.total, 10)) < 0 + returnData.length - parseInt(responseData.total, 10) < 0 ); return returnData; } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); diff --git a/packages/nodes-base/nodes/Mautic/Mautic.node.ts b/packages/nodes-base/nodes/Mautic/Mautic.node.ts index ca2c9817b4..ed4a98049f 100644 --- a/packages/nodes-base/nodes/Mautic/Mautic.node.ts +++ b/packages/nodes-base/nodes/Mautic/Mautic.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -14,45 +12,21 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - mauticApiRequest, - mauticApiRequestAllItems, - validateJSON, -} from './GenericFunctions'; +import { mauticApiRequest, mauticApiRequestAllItems, validateJSON } from './GenericFunctions'; -import { - contactFields, - contactOperations, -} from './ContactDescription'; +import { contactFields, contactOperations } from './ContactDescription'; -import { - segmentEmailFields, - segmentEmailOperations, -} from './SegmentEmailDescription'; +import { segmentEmailFields, segmentEmailOperations } from './SegmentEmailDescription'; -import { - companyFields, - companyOperations, -} from './CompanyDescription'; +import { companyFields, companyOperations } from './CompanyDescription'; -import { - companyContactFields, - companyContactOperations, -} from './CompanyContactDescription'; +import { companyContactFields, companyContactOperations } from './CompanyContactDescription'; -import { - contactSegmentFields, - contactSegmentOperations, -} from './ContactSegmentDescription'; +import { contactSegmentFields, contactSegmentOperations } from './ContactSegmentDescription'; -import { - campaignContactFields, - campaignContactOperations, -} from './CampaignContactDescription'; +import { campaignContactFields, campaignContactOperations } from './CampaignContactDescription'; -import { - snakeCase, -} from 'change-case'; +import { snakeCase } from 'change-case'; export class Mautic implements INodeType { description: INodeTypeDescription = { @@ -75,9 +49,7 @@ export class Mautic implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'credentials', - ], + authentication: ['credentials'], }, }, }, @@ -86,9 +58,7 @@ export class Mautic implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -170,7 +140,12 @@ export class Mautic implements INodeType { // select them easily async getCompanies(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const companies = await mauticApiRequestAllItems.call(this, 'companies', 'GET', '/companies'); + const companies = await mauticApiRequestAllItems.call( + this, + 'companies', + 'GET', + '/companies', + ); for (const company of companies) { returnData.push({ name: company.fields.all.companyname, @@ -209,7 +184,12 @@ export class Mautic implements INodeType { // select them easily async getCompanyFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const fields = await mauticApiRequestAllItems.call(this, 'fields', 'GET', '/fields/company'); + const fields = await mauticApiRequestAllItems.call( + this, + 'fields', + 'GET', + '/fields/company', + ); for (const field of fields) { returnData.push({ name: field.label, @@ -220,7 +200,12 @@ export class Mautic implements INodeType { }, async getIndustries(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const fields = await mauticApiRequestAllItems.call(this, 'fields', 'GET', '/fields/company'); + const fields = await mauticApiRequestAllItems.call( + this, + 'fields', + 'GET', + '/fields/company', + ); for (const field of fields) { if (field.alias === 'companyindustry') { for (const { label, value } of field.properties.list) { @@ -237,7 +222,12 @@ export class Mautic implements INodeType { // select them easily async getContactFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const fields = await mauticApiRequestAllItems.call(this, 'fields', 'GET', '/fields/contact'); + const fields = await mauticApiRequestAllItems.call( + this, + 'fields', + 'GET', + '/fields/contact', + ); for (const field of fields) { returnData.push({ name: field.label, @@ -263,7 +253,12 @@ export class Mautic implements INodeType { // select them easily async getCampaigns(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const campaings = await mauticApiRequestAllItems.call(this, 'campaigns', 'GET', '/campaigns'); + const campaings = await mauticApiRequestAllItems.call( + this, + 'campaigns', + 'GET', + '/campaigns', + ); for (const campaign of campaings) { returnData.push({ name: campaign.name, @@ -331,7 +326,6 @@ export class Mautic implements INodeType { for (let i = 0; i < length; i++) { qs = {}; try { - if (resource === 'company') { //https://developer.mautic.org/#create-company if (operation === 'create') { @@ -354,24 +348,24 @@ export class Mautic implements INodeType { ...rest } = this.getNodeParameter('additionalFields', i) as { addressUi: { - addressValues: IDataObject, - }, + addressValues: IDataObject; + }; customFieldsUi: { customFieldValues: [ { - fieldId: string, - fieldValue: string, + fieldId: string; + fieldValue: string; }, - ], - } - companyEmail: string, - fax: string, - industry: string, - numberOfEmpoyees: number, - phone: string, - website: string, - annualRevenue: number, - description: string, + ]; + }; + companyEmail: string; + fax: string; + industry: string; + numberOfEmpoyees: number; + phone: string; + website: string; + annualRevenue: number; + description: string; }; if (addressUi?.addressValues) { const { addressValues } = addressUi; @@ -421,7 +415,10 @@ export class Mautic implements INodeType { if (customFieldsUi?.customFieldValues) { const { customFieldValues } = customFieldsUi; - const data = customFieldValues.reduce((obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), {}); + const data = customFieldValues.reduce( + (obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), + {}, + ); Object.assign(body, data); } @@ -452,25 +449,25 @@ export class Mautic implements INodeType { ...rest } = this.getNodeParameter('updateFields', i) as { addressUi: { - addressValues: IDataObject, - }, + addressValues: IDataObject; + }; customFieldsUi: { customFieldValues: [ { - fieldId: string, - fieldValue: string, + fieldId: string; + fieldValue: string; }, - ], - } - companyEmail: string, - name: string, - fax: string, - industry: string, - numberOfEmpoyees: number, - phone: string, - website: string, - annualRevenue: number, - description: string, + ]; + }; + companyEmail: string; + name: string; + fax: string; + industry: string; + numberOfEmpoyees: number; + phone: string; + website: string; + annualRevenue: number; + description: string; }; if (addressUi?.addressValues) { const { addressValues } = addressUi; @@ -524,13 +521,21 @@ export class Mautic implements INodeType { if (customFieldsUi?.customFieldValues) { const { customFieldValues } = customFieldsUi; - const data = customFieldValues.reduce((obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), {}); + const data = customFieldValues.reduce( + (obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), + {}, + ); Object.assign(body, data); } Object.assign(body, rest); - responseData = await mauticApiRequest.call(this, 'PATCH', `/companies/${companyId}/edit`, body); + responseData = await mauticApiRequest.call( + this, + 'PATCH', + `/companies/${companyId}/edit`, + body, + ); responseData = responseData.company; if (simple === true) { responseData = responseData.fields.all; @@ -553,7 +558,14 @@ export class Mautic implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; qs = Object.assign(qs, additionalFields); if (returnAll === true) { - responseData = await mauticApiRequestAllItems.call(this, 'companies', 'GET', '/companies', {}, qs); + responseData = await mauticApiRequestAllItems.call( + this, + 'companies', + 'GET', + '/companies', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; qs.start = 0; @@ -566,14 +578,18 @@ export class Mautic implements INodeType { } if (simple === true) { //@ts-ignore - responseData = responseData.map(item => item.fields.all); + responseData = responseData.map((item) => item.fields.all); } } //https://developer.mautic.org/#delete-company if (operation === 'delete') { const simple = this.getNodeParameter('simple', i) as boolean; const companyId = this.getNodeParameter('companyId', i) as string; - responseData = await mauticApiRequest.call(this, 'DELETE', `/companies/${companyId}/delete`); + responseData = await mauticApiRequest.call( + this, + 'DELETE', + `/companies/${companyId}/delete`, + ); responseData = responseData.company; if (simple === true) { responseData = responseData.fields.all; @@ -613,7 +629,8 @@ export class Mautic implements INodeType { body.ownerId = additionalFields.ownerId as string; } if (additionalFields.addressUi) { - const addressValues = (additionalFields.addressUi as IDataObject).addressValues as IDataObject; + const addressValues = (additionalFields.addressUi as IDataObject) + .addressValues as IDataObject; if (addressValues) { body.address1 = addressValues.address1 as string; body.address2 = addressValues.address2 as string; @@ -624,7 +641,8 @@ export class Mautic implements INodeType { } } if (additionalFields.socialMediaUi) { - const socialMediaValues = (additionalFields.socialMediaUi as IDataObject).socialMediaValues as IDataObject; + const socialMediaValues = (additionalFields.socialMediaUi as IDataObject) + .socialMediaValues as IDataObject; if (socialMediaValues) { body.facebook = socialMediaValues.facebook as string; body.foursquare = socialMediaValues.foursquare as string; @@ -635,9 +653,13 @@ export class Mautic implements INodeType { } } if (additionalFields.customFieldsUi) { - const customFields = (additionalFields.customFieldsUi as IDataObject).customFieldValues as IDataObject[]; + const customFields = (additionalFields.customFieldsUi as IDataObject) + .customFieldValues as IDataObject[]; if (customFields) { - const data = customFields.reduce((obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), {}); + const data = customFields.reduce( + (obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), + {}, + ); Object.assign(body, data); } } @@ -677,7 +699,7 @@ export class Mautic implements INodeType { responseData = await mauticApiRequest.call(this, 'POST', '/contacts/new', body); responseData = [responseData.contact]; if (options.rawData === false) { - responseData = responseData.map(item => item.fields.all); + responseData = responseData.map((item) => item.fields.all); } } //https://developer.mautic.org/?php#edit-contact @@ -722,7 +744,8 @@ export class Mautic implements INodeType { body.ownerId = updateFields.ownerId as string; } if (updateFields.addressUi) { - const addressValues = (updateFields.addressUi as IDataObject).addressValues as IDataObject; + const addressValues = (updateFields.addressUi as IDataObject) + .addressValues as IDataObject; if (addressValues) { body.address1 = addressValues.address1 as string; body.address2 = addressValues.address2 as string; @@ -733,7 +756,8 @@ export class Mautic implements INodeType { } } if (updateFields.socialMediaUi) { - const socialMediaValues = (updateFields.socialMediaUi as IDataObject).socialMediaValues as IDataObject; + const socialMediaValues = (updateFields.socialMediaUi as IDataObject) + .socialMediaValues as IDataObject; if (socialMediaValues) { body.facebook = socialMediaValues.facebook as string; body.foursquare = socialMediaValues.foursquare as string; @@ -744,9 +768,13 @@ export class Mautic implements INodeType { } } if (updateFields.customFieldsUi) { - const customFields = (updateFields.customFieldsUi as IDataObject).customFieldValues as IDataObject[]; + const customFields = (updateFields.customFieldsUi as IDataObject) + .customFieldValues as IDataObject[]; if (customFields) { - const data = customFields.reduce((obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), {}); + const data = customFields.reduce( + (obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), + {}, + ); Object.assign(body, data); } } @@ -783,10 +811,15 @@ export class Mautic implements INodeType { if (updateFields.website) { body.website = updateFields.website as string; } - responseData = await mauticApiRequest.call(this, 'PATCH', `/contacts/${contactId}/edit`, body); + responseData = await mauticApiRequest.call( + this, + 'PATCH', + `/contacts/${contactId}/edit`, + body, + ); responseData = [responseData.contact]; if (options.rawData === false) { - responseData = responseData.map(item => item.fields.all); + responseData = responseData.map((item) => item.fields.all); } } //https://developer.mautic.org/?php#get-contact @@ -796,7 +829,7 @@ export class Mautic implements INodeType { responseData = await mauticApiRequest.call(this, 'GET', `/contacts/${contactId}`); responseData = [responseData.contact]; if (options.rawData === false) { - responseData = responseData.map(item => item.fields.all); + responseData = responseData.map((item) => item.fields.all); } } //https://developer.mautic.org/?php#list-contacts @@ -812,7 +845,14 @@ export class Mautic implements INodeType { } if (returnAll === true) { - responseData = await mauticApiRequestAllItems.call(this, 'contacts', 'GET', '/contacts', {}, qs); + responseData = await mauticApiRequestAllItems.call( + this, + 'contacts', + 'GET', + '/contacts', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; qs.start = 0; @@ -825,24 +865,32 @@ export class Mautic implements INodeType { } if (options.rawData === false) { //@ts-ignore - responseData = responseData.map(item => item.fields.all); + responseData = responseData.map((item) => item.fields.all); } } //https://developer.mautic.org/?php#delete-contact if (operation === 'delete') { const options = this.getNodeParameter('options', i) as IDataObject; const contactId = this.getNodeParameter('contactId', i) as string; - responseData = await mauticApiRequest.call(this, 'DELETE', `/contacts/${contactId}/delete`); + responseData = await mauticApiRequest.call( + this, + 'DELETE', + `/contacts/${contactId}/delete`, + ); responseData = [responseData.contact]; if (options.rawData === false) { - responseData = responseData.map(item => item.fields.all); + responseData = responseData.map((item) => item.fields.all); } } //https://developer.mautic.org/#send-email-to-contact if (operation === 'sendEmail') { const contactId = this.getNodeParameter('contactId', i) as string; const campaignEmailId = this.getNodeParameter('campaignEmailId', i) as string; - responseData = await mauticApiRequest.call(this, 'POST', `/emails/${campaignEmailId}/contact/${contactId}/send`); + responseData = await mauticApiRequest.call( + this, + 'POST', + `/emails/${campaignEmailId}/contact/${contactId}/send`, + ); } //https://developer.mautic.org/#add-do-not-contact //https://developer.mautic.org/#remove-from-do-not-contact @@ -855,7 +903,12 @@ export class Mautic implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); } - responseData = await mauticApiRequest.call(this, 'POST', `/contacts/${contactId}/dnc/${channel}/${action}`, body); + responseData = await mauticApiRequest.call( + this, + 'POST', + `/contacts/${contactId}/dnc/${channel}/${action}`, + body, + ); responseData = responseData.contact; } @@ -865,8 +918,12 @@ export class Mautic implements INodeType { const contactId = this.getNodeParameter('contactId', i) as string; const action = this.getNodeParameter('action', i) as string; const points = this.getNodeParameter('points', i) as string; - const path = (action === 'add') ? 'plus' : 'minus'; - responseData = await mauticApiRequest.call(this, 'POST', `/contacts/${contactId}/points/${path}/${points}`); + const path = action === 'add' ? 'plus' : 'minus'; + responseData = await mauticApiRequest.call( + this, + 'POST', + `/contacts/${contactId}/points/${path}/${points}`, + ); } } @@ -875,13 +932,21 @@ export class Mautic implements INodeType { if (operation === 'add') { const contactId = this.getNodeParameter('contactId', i) as string; const segmentId = this.getNodeParameter('segmentId', i) as string; - responseData = await mauticApiRequest.call(this, 'POST', `/segments/${segmentId}/contact/${contactId}/add`); + responseData = await mauticApiRequest.call( + this, + 'POST', + `/segments/${segmentId}/contact/${contactId}/add`, + ); } //https://developer.mautic.org/#remove-contact-from-a-segment if (operation === 'remove') { const contactId = this.getNodeParameter('contactId', i) as string; const segmentId = this.getNodeParameter('segmentId', i) as string; - responseData = await mauticApiRequest.call(this, 'POST', `/segments/${segmentId}/contact/${contactId}/remove`); + responseData = await mauticApiRequest.call( + this, + 'POST', + `/segments/${segmentId}/contact/${contactId}/remove`, + ); } } @@ -890,13 +955,21 @@ export class Mautic implements INodeType { if (operation === 'add') { const contactId = this.getNodeParameter('contactId', i) as string; const campaignId = this.getNodeParameter('campaignId', i) as string; - responseData = await mauticApiRequest.call(this, 'POST', `/campaigns/${campaignId}/contact/${contactId}/add`); + responseData = await mauticApiRequest.call( + this, + 'POST', + `/campaigns/${campaignId}/contact/${contactId}/add`, + ); } //https://developer.mautic.org/#remove-contact-from-a-campaign if (operation === 'remove') { const contactId = this.getNodeParameter('contactId', i) as string; const campaignId = this.getNodeParameter('campaignId', i) as string; - responseData = await mauticApiRequest.call(this, 'POST', `/campaigns/${campaignId}/contact/${contactId}/remove`); + responseData = await mauticApiRequest.call( + this, + 'POST', + `/campaigns/${campaignId}/contact/${contactId}/remove`, + ); } } @@ -904,7 +977,11 @@ export class Mautic implements INodeType { //https://developer.mautic.org/#send-email-to-segment if (operation === 'send') { const segmentEmailId = this.getNodeParameter('segmentEmailId', i) as string; - responseData = await mauticApiRequest.call(this, 'POST', `/emails/${segmentEmailId}/send`); + responseData = await mauticApiRequest.call( + this, + 'POST', + `/emails/${segmentEmailId}/send`, + ); } } @@ -913,7 +990,12 @@ export class Mautic implements INodeType { if (operation === 'add') { const contactId = this.getNodeParameter('contactId', i) as string; const companyId = this.getNodeParameter('companyId', i) as string; - responseData = await mauticApiRequest.call(this, 'POST', `/companies/${companyId}/contact/${contactId}/add`, {}); + responseData = await mauticApiRequest.call( + this, + 'POST', + `/companies/${companyId}/contact/${contactId}/add`, + {}, + ); // responseData = responseData.company; // if (simple === true) { // responseData = responseData.fields.all; @@ -923,7 +1005,12 @@ export class Mautic implements INodeType { if (operation === 'remove') { const contactId = this.getNodeParameter('contactId', i) as string; const companyId = this.getNodeParameter('companyId', i) as string; - responseData = await mauticApiRequest.call(this, 'POST', `/companies/${companyId}/contact/${contactId}/remove`, {}); + responseData = await mauticApiRequest.call( + this, + 'POST', + `/companies/${companyId}/contact/${contactId}/remove`, + {}, + ); // responseData = responseData.company; // if (simple === true) { // responseData = responseData.fields.all; diff --git a/packages/nodes-base/nodes/Mautic/MauticTrigger.node.ts b/packages/nodes-base/nodes/Mautic/MauticTrigger.node.ts index 296fc0095a..697164b6e4 100644 --- a/packages/nodes-base/nodes/Mautic/MauticTrigger.node.ts +++ b/packages/nodes-base/nodes/Mautic/MauticTrigger.node.ts @@ -1,11 +1,6 @@ -import { - parse as urlParse, -} from 'url'; +import { parse as urlParse } from 'url'; -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -16,9 +11,7 @@ import { IWebhookResponseData, } from 'n8n-workflow'; -import { - mauticApiRequest, -} from './GenericFunctions'; +import { mauticApiRequest } from './GenericFunctions'; export class MauticTrigger implements INodeType { description: INodeTypeDescription = { @@ -39,9 +32,7 @@ export class MauticTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'credentials', - ], + authentication: ['credentials'], }, }, }, @@ -50,9 +41,7 @@ export class MauticTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -86,7 +75,8 @@ export class MauticTrigger implements INodeType { displayName: 'Event Names or IDs', name: 'events', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', required: true, typeOptions: { loadOptionsMethod: 'getEvents', @@ -183,9 +173,7 @@ export class MauticTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/Mautic/SegmentEmailDescription.ts b/packages/nodes-base/nodes/Mautic/SegmentEmailDescription.ts index 1b896fa949..f6b4ca3305 100644 --- a/packages/nodes-base/nodes/Mautic/SegmentEmailDescription.ts +++ b/packages/nodes-base/nodes/Mautic/SegmentEmailDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const segmentEmailOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const segmentEmailOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'segmentEmail', - ], + resource: ['segmentEmail'], }, }, options: [ @@ -27,7 +23,6 @@ export const segmentEmailOperations: INodeProperties[] = [ ]; export const segmentEmailFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* segmentEmail:send */ /* -------------------------------------------------------------------------- */ @@ -35,16 +30,13 @@ export const segmentEmailFields: INodeProperties[] = [ displayName: 'Segment Email Name or ID', name: 'segmentEmailId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, displayOptions: { show: { - resource: [ - 'segmentEmail', - ], - operation: [ - 'send', - ], + resource: ['segmentEmail'], + operation: ['send'], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Medium/GenericFunctions.ts b/packages/nodes-base/nodes/Medium/GenericFunctions.ts index 1d3fbcd14a..daae21f6ae 100644 --- a/packages/nodes-base/nodes/Medium/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Medium/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,18 +7,24 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; - -export async function mediumApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; +export async function mediumApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0); const options: OptionsWithUri = { method, headers: { - 'Accept': 'application/json', + Accept: 'application/json', 'Content-Type': 'application/json', 'Accept-Charset': 'utf-8', }, @@ -37,8 +41,7 @@ export async function mediumApiRequest(this: IHookFunctions | IExecuteFunctions options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`; return await this.helpers.request!(options); - } - else { + } else { return await this.helpers.requestOAuth2!.call(this, 'mediumOAuth2Api', options); } } catch (error) { diff --git a/packages/nodes-base/nodes/Medium/Medium.node.ts b/packages/nodes-base/nodes/Medium/Medium.node.ts index 3eaa8561c9..bd64e07bc9 100644 --- a/packages/nodes-base/nodes/Medium/Medium.node.ts +++ b/packages/nodes-base/nodes/Medium/Medium.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,9 +10,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - mediumApiRequest, -} from './GenericFunctions'; +import { mediumApiRequest } from './GenericFunctions'; export class Medium implements INodeType { description: INodeTypeDescription = { @@ -37,9 +33,7 @@ export class Medium implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -48,9 +42,7 @@ export class Medium implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -96,9 +88,7 @@ export class Medium implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'post', - ], + resource: ['post'], }, }, options: [ @@ -121,12 +111,8 @@ export class Medium implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], + resource: ['post'], + operation: ['create'], }, }, default: false, @@ -138,22 +124,17 @@ export class Medium implements INodeType { type: 'options', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], - publication: [ - true, - ], + resource: ['post'], + operation: ['create'], + publication: [true], }, }, typeOptions: { loadOptionsMethod: 'getPublications', }, default: '', - description: 'Publication IDs. Choose from the list, or specify an ID using an expression.', + description: + 'Publication IDs. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Title', @@ -164,12 +145,8 @@ export class Medium implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'post', - ], + operation: ['create'], + resource: ['post'], }, }, description: 'Title of the post. Max Length : 100 characters.', @@ -181,12 +158,8 @@ export class Medium implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'post', - ], + operation: ['create'], + resource: ['post'], }, }, type: 'options', @@ -214,12 +187,8 @@ export class Medium implements INodeType { }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'post', - ], + operation: ['create'], + resource: ['post'], }, }, description: 'The body of the post, in a valid semantic HTML fragment, or Markdown', @@ -231,12 +200,8 @@ export class Medium implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'post', - ], + operation: ['create'], + resource: ['post'], }, }, default: {}, @@ -246,7 +211,8 @@ export class Medium implements INodeType { name: 'canonicalUrl', type: 'string', default: '', - description: 'The original home of this content, if it was originally published elsewhere', + description: + 'The original home of this content, if it was originally published elsewhere', }, { displayName: 'License', @@ -327,7 +293,8 @@ export class Medium implements INodeType { type: 'string', default: '', placeholder: 'open-source,mlh,fellowship', - description: 'Comma-separated strings to be used as tags for post classification. Max allowed tags: 5. Max tag length: 25 characters.', + description: + 'Comma-separated strings to be used as tags for post classification. Max allowed tags: 5. Max tag length: 25 characters.', }, ], }, @@ -338,9 +305,7 @@ export class Medium implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'publication', - ], + resource: ['publication'], }, }, options: [ @@ -362,12 +327,8 @@ export class Medium implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'publication', - ], + operation: ['getAll'], + resource: ['publication'], }, }, default: false, @@ -379,15 +340,9 @@ export class Medium implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'publication', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['publication'], + returnAll: [false], }, }, typeOptions: { @@ -406,11 +361,7 @@ export class Medium implements INodeType { async getPublications(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; //Get the User Id - const user = await mediumApiRequest.call( - this, - 'GET', - `/me`, - ); + const user = await mediumApiRequest.call(this, 'GET', `/me`); const userId = user.data.id; //Get all publications of that user @@ -430,12 +381,10 @@ export class Medium implements INodeType { } return returnData; }, - }, }; async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -469,22 +418,29 @@ export class Medium implements INodeType { title, contentFormat, content, - }; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (additionalFields.tags) { const tags = additionalFields.tags as string; - bodyRequest.tags = tags.split(',').map(name => { + bodyRequest.tags = tags.split(',').map((name) => { const returnValue = name.trim(); if (returnValue.length > 25) { - throw new NodeOperationError(this.getNode(), `The tag "${returnValue}" is to long. Maximum lenght of a tag is 25 characters.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The tag "${returnValue}" is to long. Maximum lenght of a tag is 25 characters.`, + { itemIndex: i }, + ); } return returnValue; }); if ((bodyRequest.tags as string[]).length > 5) { - throw new NodeOperationError(this.getNode(), 'To many tags got used. Maximum 5 can be set.', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'To many tags got used. Maximum 5 can be set.', + { itemIndex: i }, + ); } } @@ -514,15 +470,8 @@ export class Medium implements INodeType { bodyRequest, qs, ); - } - else { - const responseAuthorId = await mediumApiRequest.call( - this, - 'GET', - '/me', - {}, - qs, - ); + } else { + const responseAuthorId = await mediumApiRequest.call(this, 'GET', '/me', {}, qs); const authorId = responseAuthorId.data.id; responseData = await mediumApiRequest.call( @@ -546,11 +495,7 @@ export class Medium implements INodeType { const returnAll = this.getNodeParameter('returnAll', i) as string; - const user = await mediumApiRequest.call( - this, - 'GET', - `/me`, - ); + const user = await mediumApiRequest.call(this, 'GET', `/me`); const userId = user.data.id; //Get all publications of that user diff --git a/packages/nodes-base/nodes/Merge/Merge.node.ts b/packages/nodes-base/nodes/Merge/Merge.node.ts index 49da370b32..6335240fef 100644 --- a/packages/nodes-base/nodes/Merge/Merge.node.ts +++ b/packages/nodes-base/nodes/Merge/Merge.node.ts @@ -9,7 +9,6 @@ import { IPairedItemData, } from 'n8n-workflow'; - export class Merge implements INodeType { description: INodeTypeDescription = { displayName: 'Merge', @@ -35,7 +34,8 @@ export class Merge implements INodeType { { name: 'Append', value: 'append', - description: 'Combines data of both inputs. The output will contain items of input 1 and input 2.', + description: + 'Combines data of both inputs. The output will contain items of input 1 and input 2.', }, { name: 'Keep Key Matches', @@ -45,22 +45,26 @@ export class Merge implements INodeType { { name: 'Merge By Index', value: 'mergeByIndex', - description: 'Merges data of both inputs. The output will contain items of input 1 merged with data of input 2. Merge happens depending on the index of the items. So first item of input 1 will be merged with first item of input 2 and so on.', + description: + 'Merges data of both inputs. The output will contain items of input 1 merged with data of input 2. Merge happens depending on the index of the items. So first item of input 1 will be merged with first item of input 2 and so on.', }, { name: 'Merge By Key', value: 'mergeByKey', - description: 'Merges data of both inputs. The output will contain items of input 1 merged with data of input 2. Merge happens depending on a defined key.', + description: + 'Merges data of both inputs. The output will contain items of input 1 merged with data of input 2. Merge happens depending on a defined key.', }, { name: 'Multiplex', value: 'multiplex', - description: 'Merges each value of one input with each value of the other input. The output will contain (m * n) items where (m) and (n) are lengths of the inputs.', + description: + 'Merges each value of one input with each value of the other input. The output will contain (m * n) items where (m) and (n) are lengths of the inputs.', }, { name: 'Pass-Through', value: 'passThrough', - description: 'Passes through data of one input. The output will contain only items of the defined input.', + description: + 'Passes through data of one input. The output will contain only items of the defined input.', }, { name: 'Remove Key Matches', @@ -70,7 +74,8 @@ export class Merge implements INodeType { { name: 'Wait', value: 'wait', - description: 'Waits till data of both inputs is available and will then output a single empty item. Source Nodes must connect to both Input 1 and 2. This node only supports 2 Sources, if you need more Sources, connect multiple Merge nodes in series. This node will not output any data.', + description: + 'Waits till data of both inputs is available and will then output a single empty item. Source Nodes must connect to both Input 1 and 2. This node only supports 2 Sources, if you need more Sources, connect multiple Merge nodes in series. This node will not output any data.', }, ], default: 'append', @@ -82,30 +87,32 @@ export class Merge implements INodeType { type: 'options', displayOptions: { show: { - mode: [ - 'mergeByIndex', - ], + mode: ['mergeByIndex'], }, }, options: [ { name: 'Inner Join', value: 'inner', - description: 'Merges as many items as both inputs contain. (Example: Input1 = 5 items, Input2 = 3 items | Output will contain 3 items).', + description: + 'Merges as many items as both inputs contain. (Example: Input1 = 5 items, Input2 = 3 items | Output will contain 3 items).', }, { name: 'Left Join', value: 'left', - description: 'Merges as many items as first input contains. (Example: Input1 = 3 items, Input2 = 5 items | Output will contain 3 items).', + description: + 'Merges as many items as first input contains. (Example: Input1 = 3 items, Input2 = 5 items | Output will contain 3 items).', }, { name: 'Outer Join', value: 'outer', - description: 'Merges as many items as input contains with most items. (Example: Input1 = 3 items, Input2 = 5 items | Output will contain 5 items).', + description: + 'Merges as many items as input contains with most items. (Example: Input1 = 3 items, Input2 = 5 items | Output will contain 5 items).', }, ], default: 'left', - description: 'How many items the output will contain if inputs contain different amount of items', + description: + 'How many items the output will contain if inputs contain different amount of items', }, { displayName: 'Property Input 1', @@ -116,11 +123,7 @@ export class Merge implements INodeType { required: true, displayOptions: { show: { - mode: [ - 'keepKeyMatches', - 'mergeByKey', - 'removeKeyMatches', - ], + mode: ['keepKeyMatches', 'mergeByKey', 'removeKeyMatches'], }, }, description: 'Name of property which decides which items to merge of input 1', @@ -134,11 +137,7 @@ export class Merge implements INodeType { required: true, displayOptions: { show: { - mode: [ - 'keepKeyMatches', - 'mergeByKey', - 'removeKeyMatches', - ], + mode: ['keepKeyMatches', 'mergeByKey', 'removeKeyMatches'], }, }, description: 'Name of property which decides which items to merge of input 2', @@ -149,9 +148,7 @@ export class Merge implements INodeType { type: 'options', displayOptions: { show: { - mode: [ - 'passThrough', - ], + mode: ['passThrough'], }, }, options: [ @@ -173,9 +170,7 @@ export class Merge implements INodeType { type: 'options', displayOptions: { show: { - mode: [ - 'mergeByKey', - ], + mode: ['mergeByKey'], }, }, options: [ @@ -201,7 +196,6 @@ export class Merge implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { const returnData: INodeExecutionData[] = []; @@ -312,7 +306,8 @@ export class Merge implements INodeType { for (entry2 of dataInput2) { returnData.push({ json: { - ...(entry1.json), ...(entry2.json), + ...entry1.json, + ...entry2.json, }, pairedItem: [ entry1.pairedItem as IPairedItemData, @@ -462,7 +457,7 @@ export class Merge implements INodeType { if (output === 'input1') { returnData.push.apply(returnData, this.getInputData(0)); - } else { + } else { returnData.push.apply(returnData, this.getInputData(1)); } } else if (mode === 'wait') { diff --git a/packages/nodes-base/nodes/MessageBird/GenericFunctions.ts b/packages/nodes-base/nodes/MessageBird/GenericFunctions.ts index 9566789759..228f7a665d 100644 --- a/packages/nodes-base/nodes/MessageBird/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MessageBird/GenericFunctions.ts @@ -1,15 +1,8 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; /** * Make an API request to Message Bird @@ -26,7 +19,8 @@ export async function messageBirdApiRequest( resource: string, body: IDataObject, query: IDataObject = {}, -): Promise { // tslint:disable-line:no-any + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('messageBirdApi'); const options: OptionsWithUri = { diff --git a/packages/nodes-base/nodes/MessageBird/MessageBird.node.ts b/packages/nodes-base/nodes/MessageBird/MessageBird.node.ts index 75770630ef..760f6da004 100644 --- a/packages/nodes-base/nodes/MessageBird/MessageBird.node.ts +++ b/packages/nodes-base/nodes/MessageBird/MessageBird.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,9 +8,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - messageBirdApiRequest, -} from './GenericFunctions'; +import { messageBirdApiRequest } from './GenericFunctions'; export class MessageBird implements INodeType { description: INodeTypeDescription = { @@ -59,9 +55,7 @@ export class MessageBird implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'sms', - ], + resource: ['sms'], }, }, options: [ @@ -81,9 +75,7 @@ export class MessageBird implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'balance', - ], + resource: ['balance'], }, }, options: [ @@ -109,12 +101,8 @@ export class MessageBird implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - ], + operation: ['send'], + resource: ['sms'], }, }, description: 'The number from which to send the message', @@ -128,12 +116,8 @@ export class MessageBird implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - ], + operation: ['send'], + resource: ['sms'], }, }, description: 'All recipients separated by commas', @@ -146,12 +130,8 @@ export class MessageBird implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - ], + operation: ['send'], + resource: ['sms'], }, }, description: 'The message to be send', @@ -162,12 +142,8 @@ export class MessageBird implements INodeType { type: 'collection', displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - ], + operation: ['send'], + resource: ['sms'], }, }, placeholder: 'Add Fields', @@ -178,7 +154,8 @@ export class MessageBird implements INodeType { name: 'createdDatetime', type: 'dateTime', default: '', - description: 'The date and time of the creation of the message in RFC3339 format (Y-m-dTH:i:sP)', + description: + 'The date and time of the creation of the message in RFC3339 format (Y-m-dTH:i:sP)', }, { displayName: 'Datacoding', @@ -199,7 +176,8 @@ export class MessageBird implements INodeType { }, ], default: '', - description: 'Using unicode will limit the maximum number of characters to 70 instead of 160', + description: + 'Using unicode will limit the maximum number of characters to 70 instead of 160', }, { displayName: 'Gateway', @@ -246,14 +224,16 @@ export class MessageBird implements INodeType { name: 'reportUrl', type: 'string', default: '', - description: 'The status report URL to be used on a per-message basis. Reference is required for a status report webhook to be sent.', + description: + 'The status report URL to be used on a per-message basis. Reference is required for a status report webhook to be sent.', }, { displayName: 'Scheduled Date-Time', name: 'scheduledDatetime', type: 'dateTime', default: '', - description: 'The scheduled date and time of the message in RFC3339 format (Y-m-dTH:i:sP)', + description: + 'The scheduled date and time of the message in RFC3339 format (Y-m-dTH:i:sP)', }, { displayName: 'Type', @@ -281,7 +261,8 @@ export class MessageBird implements INodeType { name: 'typeDetails', type: 'string', default: '', - description: 'A hash with extra information. Is only used when a binary message is sent.', + description: + 'A hash with extra information. Is only used when a binary message is sent.', }, { displayName: 'Validity', @@ -336,10 +317,7 @@ export class MessageBird implements INodeType { originator, body, }; - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (additionalFields.groupIds) { bodyRequest.groupIds = additionalFields.groupIds as string; @@ -376,21 +354,23 @@ export class MessageBird implements INodeType { } const receivers = this.getNodeParameter('recipients', i) as string; - bodyRequest.recipients = receivers.split(',').map(item => { - + bodyRequest.recipients = receivers.split(',').map((item) => { return parseInt(item, 10); }); + } else { + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } - else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); - } - } else if (resource === 'balance') { requestMethod = 'GET'; requestPath = '/balance'; - } - else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + } else { + throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { + itemIndex: i, + }); } const responseData = await messageBirdApiRequest.call( diff --git a/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts index bfcb55e243..560a4651cc 100644 --- a/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts @@ -1,28 +1,30 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - INodeProperties, - INodePropertyOptions, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, INodeProperties, INodePropertyOptions, NodeApiError } from 'n8n-workflow'; -export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any - const credentials = await this.getCredentials('microsoftDynamicsOAuth2Api') as { subdomain: string, region: string }; +export async function microsoftApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { + const credentials = (await this.getCredentials('microsoftDynamicsOAuth2Api')) as { + subdomain: string; + region: string; + }; let options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', - 'accept': 'application/json', - 'Prefer': 'return=representation', + accept: 'application/json', + Prefer: 'return=representation', }, method, body, @@ -36,14 +38,24 @@ export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSing options = Object.assign({}, options, option); } //@ts-ignore - return await this.helpers.requestOAuth2.call(this, 'microsoftDynamicsOAuth2Api', options, { property: 'id_token' }); + return await this.helpers.requestOAuth2.call(this, 'microsoftDynamicsOAuth2Api', options, { + property: 'id_token', + }); } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function microsoftApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -54,17 +66,21 @@ export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoa responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri); uri = responseData['@odata.nextLink']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['@odata.nextLink'] !== undefined - ); + } while (responseData['@odata.nextLink'] !== undefined); return returnData; } -export async function getPicklistOptions(this: ILoadOptionsFunctions, entityName: string, attributeName: string): Promise { +export async function getPicklistOptions( + this: ILoadOptionsFunctions, + entityName: string, + attributeName: string, +): Promise { const returnData: INodePropertyOptions[] = []; const endpoint = `/EntityDefinitions(LogicalName='${entityName}')/Attributes(LogicalName='${attributeName}')/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet($select=Options),GlobalOptionSet($select=Options)`; - const { OptionSet: { Options: options } } = await microsoftApiRequest.call(this, 'GET', endpoint); + const { + OptionSet: { Options: options }, + } = await microsoftApiRequest.call(this, 'GET', endpoint); for (const option of options) { returnData.push({ name: option.Label.UserLocalizedLabel.Label, @@ -74,7 +90,10 @@ export async function getPicklistOptions(this: ILoadOptionsFunctions, entityName return returnData; } -export async function getEntityFields(this: ILoadOptionsFunctions, entityName: string): Promise { +export async function getEntityFields( + this: ILoadOptionsFunctions, + entityName: string, +): Promise { const endpoint = `/EntityDefinitions(LogicalName='${entityName}')/Attributes`; const { value } = await microsoftApiRequest.call(this, 'GET', endpoint); return value; @@ -103,13 +122,15 @@ export function getAccountFields(): INodeProperties[] { loadOptionsMethod: 'getAccountCategories', }, default: '', - description: 'Category to indicate whether the customer account is standard or preferred. Choose from the list, or specify an ID using an expression.', + description: + 'Category to indicate whether the customer account is standard or preferred. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Account Rating Name or ID', name: 'accountratingcode', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getAccountRatingCodes', }, @@ -133,7 +154,8 @@ export function getAccountFields(): INodeProperties[] { displayName: 'Address Type Name or ID', name: 'addresstypecode', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getAddressTypes', }, @@ -223,13 +245,15 @@ export function getAccountFields(): INodeProperties[] { loadOptionsMethod: 'getBusinessTypes', }, default: '', - description: 'The legal designation or other business type of the account for contracts or reporting purposes. Choose from the list, or specify an ID using an expression.', + description: + 'The legal designation or other business type of the account for contracts or reporting purposes. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Customer Size Name or ID', name: 'customersizecode', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCustomerSizeCodes', }, @@ -239,7 +263,8 @@ export function getAccountFields(): INodeProperties[] { displayName: 'Customer Type Name or ID', name: 'customertypecode', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCustomerTypeCodes', }, @@ -250,7 +275,8 @@ export function getAccountFields(): INodeProperties[] { name: 'description', type: 'string', default: '', - description: 'Additional information to describe the account, such as an excerpt from the company’s website', + description: + 'Additional information to describe the account, such as an excerpt from the company’s website', }, { displayName: 'Email Address 1', @@ -284,7 +310,8 @@ export function getAccountFields(): INodeProperties[] { name: 'ftpsiteurl', type: 'string', default: '', - description: 'URL for the account’s FTP site to enable users to access data and share documents', + description: + 'URL for the account’s FTP site to enable users to access data and share documents', }, { displayName: 'Industry Name or ID', @@ -294,7 +321,8 @@ export function getAccountFields(): INodeProperties[] { loadOptionsMethod: 'getIndustryCodes', }, default: '', - description: 'The account’s primary industry for use in marketing segmentation and demographic analysis. Choose from the list, or specify an ID using an expression.', + description: + 'The account’s primary industry for use in marketing segmentation and demographic analysis. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Name', @@ -303,12 +331,8 @@ export function getAccountFields(): INodeProperties[] { default: '', displayOptions: { show: { - '/resource': [ - 'account', - ], - '/operation': [ - 'update', - ], + '/resource': ['account'], + '/operation': ['update'], }, }, description: 'Company o business name', @@ -318,14 +342,16 @@ export function getAccountFields(): INodeProperties[] { name: 'creditlimit', type: 'number', default: '', - description: 'Credit limit of the account. This is a useful reference when you address invoice and accounting issues with the customer.', + description: + 'Credit limit of the account. This is a useful reference when you address invoice and accounting issues with the customer.', }, { displayName: 'Number Of Employees', name: 'numberofemployees', type: 'number', default: 0, - description: 'Number of employees that work at the account for use in marketing segmentation and demographic analysis', + description: + 'Number of employees that work at the account for use in marketing segmentation and demographic analysis', }, { displayName: 'Payment Terms Name or ID', @@ -335,7 +361,8 @@ export function getAccountFields(): INodeProperties[] { loadOptionsMethod: 'getPaymentTermsCodes', }, default: '', - description: 'The payment terms to indicate when the customer needs to pay the total amount. Choose from the list, or specify an ID using an expression.', + description: + 'The payment terms to indicate when the customer needs to pay the total amount. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Preferred Appointment Day Name or ID', @@ -345,7 +372,8 @@ export function getAccountFields(): INodeProperties[] { loadOptionsMethod: 'getPreferredAppointmentDayCodes', }, default: '', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', }, { displayName: 'Preferred Appointment Time Name or ID', @@ -355,7 +383,8 @@ export function getAccountFields(): INodeProperties[] { loadOptionsMethod: 'getPreferredAppointmentTimeCodes', }, default: '', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', }, { displayName: 'Preferred Contact Method Name or ID', @@ -365,7 +394,8 @@ export function getAccountFields(): INodeProperties[] { loadOptionsMethod: 'getPreferredContactMethodCodes', }, default: '', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', }, { displayName: 'Primary Satori ID', @@ -384,14 +414,16 @@ export function getAccountFields(): INodeProperties[] { name: 'revenue', type: 'number', default: '', - description: 'The annual revenue for the account, used as an indicator in financial performance analysis', + description: + 'The annual revenue for the account, used as an indicator in financial performance analysis', }, { displayName: 'Shares Outstanding', name: 'sharesoutstanding', type: 'number', default: '', - description: 'The number of shares available to the public for the account. This number is used as an indicator in financial performance analysis.', + description: + 'The number of shares available to the public for the account. This number is used as an indicator in financial performance analysis.', }, { displayName: 'Shipping Method Name or ID', @@ -401,14 +433,16 @@ export function getAccountFields(): INodeProperties[] { loadOptionsMethod: 'getShippingMethodCodes', }, default: '', - description: 'Shipping method for deliveries sent to the account’s address to designate the preferred carrier or other delivery option. Choose from the list, or specify an ID using an expression.', + description: + 'Shipping method for deliveries sent to the account’s address to designate the preferred carrier or other delivery option. Choose from the list, or specify an ID using an expression.', }, { displayName: 'SIC', name: 'sic', type: 'string', default: '', - description: 'The Standard Industrial Classification (SIC) code that indicates the account’s primary industry of business, for use in marketing segmentation and demographic analysis', + description: + 'The Standard Industrial Classification (SIC) code that indicates the account’s primary industry of business, for use in marketing segmentation and demographic analysis', }, { displayName: 'Stage ID', @@ -421,7 +455,8 @@ export function getAccountFields(): INodeProperties[] { name: 'stockexchange', type: 'string', default: '', - description: 'The stock exchange at which the account is listed to track their stock and financial performance of the company', + description: + 'The stock exchange at which the account is listed to track their stock and financial performance of the company', }, { displayName: 'Telephone 1', @@ -452,14 +487,16 @@ export function getAccountFields(): INodeProperties[] { loadOptionsMethod: 'getTerritoryCodes', }, default: '', - description: 'Region or territory for the account for use in segmentation and analysis. Choose from the list, or specify an ID using an expression.', + description: + 'Region or territory for the account for use in segmentation and analysis. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Ticker Symbol', name: 'tickersymbol', type: 'string', default: '', - description: 'Type the stock exchange symbol for the account to track financial performance of the company. You can click the code entered in this field to access the latest trading information from MSN Money.', + description: + 'Type the stock exchange symbol for the account to track financial performance of the company. You can click the code entered in this field to access the latest trading information from MSN Money.', }, { displayName: 'Website URL', @@ -473,14 +510,19 @@ export function getAccountFields(): INodeProperties[] { name: 'yominame', type: 'string', default: '', - description: 'The phonetic spelling of the company name, if specified in Japanese, to make sure the name is pronounced correctly in phone calls and other communications', + description: + 'The phonetic spelling of the company name, if specified in Japanese, to make sure the name is pronounced correctly in phone calls and other communications', }, ]; } export const sort = (a: { name: string }, b: { name: string }) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }; @@ -493,11 +535,11 @@ export interface IField { CanBeSecuredForRead: string; AttributeType: string; IsSortableEnabled: { - Value: boolean, + Value: boolean; }; DisplayName: { UserLocalizedLabel: { - Label: string - } + Label: string; + }; }; } diff --git a/packages/nodes-base/nodes/Microsoft/Dynamics/MicrosoftDynamicsCrm.node.ts b/packages/nodes-base/nodes/Microsoft/Dynamics/MicrosoftDynamicsCrm.node.ts index f3fa92919d..9ba08ba056 100644 --- a/packages/nodes-base/nodes/Microsoft/Dynamics/MicrosoftDynamicsCrm.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Dynamics/MicrosoftDynamicsCrm.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -21,10 +19,7 @@ import { sort, } from './GenericFunctions'; -import { - accountFields, - accountOperations, -} from './descriptions'; +import { accountFields, accountOperations } from './descriptions'; export class MicrosoftDynamicsCrm implements INodeType { description: INodeTypeDescription = { @@ -91,13 +86,19 @@ export class MicrosoftDynamicsCrm implements INodeType { async getPaymentTermsCodes(this: ILoadOptionsFunctions): Promise { return await getPicklistOptions.call(this, 'account', 'paymenttermscode'); }, - async getPreferredAppointmentDayCodes(this: ILoadOptionsFunctions): Promise { + async getPreferredAppointmentDayCodes( + this: ILoadOptionsFunctions, + ): Promise { return await getPicklistOptions.call(this, 'account', 'preferredappointmentdaycode'); }, - async getPreferredAppointmentTimeCodes(this: ILoadOptionsFunctions): Promise { + async getPreferredAppointmentTimeCodes( + this: ILoadOptionsFunctions, + ): Promise { return await getPicklistOptions.call(this, 'account', 'preferredappointmenttimecode'); }, - async getPreferredContactMethodCodes(this: ILoadOptionsFunctions): Promise { + async getPreferredContactMethodCodes( + this: ILoadOptionsFunctions, + ): Promise { return await getPicklistOptions.call(this, 'account', 'preferredcontactmethodcode'); }, async getShippingMethodCodes(this: ILoadOptionsFunctions): Promise { @@ -108,13 +109,37 @@ export class MicrosoftDynamicsCrm implements INodeType { }, async getAccountFields(this: ILoadOptionsFunctions): Promise { const fields = await getEntityFields.call(this, 'account'); - const isSelectable = (field: IField) => (field.IsValidForRead && field.CanBeSecuredForRead && field.IsValidODataAttribute && field.LogicalName !== 'slaid'); - return fields.filter(isSelectable).filter(field => field.DisplayName.UserLocalizedLabel?.Label).map(field => ({ name: field.DisplayName.UserLocalizedLabel.Label, value: field.LogicalName })).sort(sort); + const isSelectable = (field: IField) => + field.IsValidForRead && + field.CanBeSecuredForRead && + field.IsValidODataAttribute && + field.LogicalName !== 'slaid'; + return fields + .filter(isSelectable) + .filter((field) => field.DisplayName.UserLocalizedLabel?.Label) + .map((field) => ({ + name: field.DisplayName.UserLocalizedLabel.Label, + value: field.LogicalName, + })) + .sort(sort); }, - async getExpandableAccountFields(this: ILoadOptionsFunctions): Promise { + async getExpandableAccountFields( + this: ILoadOptionsFunctions, + ): Promise { const fields = await getEntityFields.call(this, 'account'); - const isSelectable = (field: IField) => (field.IsValidForRead && field.CanBeSecuredForRead && field.IsValidODataAttribute && field.AttributeType === 'Lookup' && field.LogicalName !== 'slaid'); - return fields.filter(isSelectable).map(field => ({ name: field.DisplayName.UserLocalizedLabel.Label, value: field.LogicalName })).sort(sort); + const isSelectable = (field: IField) => + field.IsValidForRead && + field.CanBeSecuredForRead && + field.IsValidODataAttribute && + field.AttributeType === 'Lookup' && + field.LogicalName !== 'slaid'; + return fields + .filter(isSelectable) + .map((field) => ({ + name: field.DisplayName.UserLocalizedLabel.Label, + value: field.LogicalName, + })) + .sort(sort); }, }, }; @@ -134,8 +159,10 @@ export class MicrosoftDynamicsCrm implements INodeType { //https://docs.microsoft.com/en-us/powerapps/developer/data-platform/webapi/create-entity-web-api if (operation === 'create') { const name = this.getNodeParameter('name', i) as string; - // tslint:disable-next-line: no-any - const additionalFields = this.getNodeParameter('additionalFields', i) as { addresses: { address: [{ [key: string]: any }] } }; + const additionalFields = this.getNodeParameter('additionalFields', i) as { + // tslint:disable-next-line: no-any + addresses: { address: [{ [key: string]: any }] }; + }; const options = this.getNodeParameter('options', i) as { returnFields: string[] }; const body = { @@ -176,7 +203,13 @@ export class MicrosoftDynamicsCrm implements INodeType { if (options.expandFields) { qs['$expand'] = (options.expandFields as string[]).join(','); } - responseData = await microsoftApiRequest.call(this, 'GET', `/accounts(${accountId})`, {}, qs); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/accounts(${accountId})`, + {}, + qs, + ); } if (operation === 'getAll') { @@ -194,7 +227,14 @@ export class MicrosoftDynamicsCrm implements INodeType { qs['$filter'] = filters.query as string; } if (returnAll) { - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/accounts`, {}, qs); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/accounts`, + {}, + qs, + ); } else { qs['$top'] = this.getNodeParameter('limit', 0) as number; responseData = await microsoftApiRequest.call(this, 'GET', `/accounts`, {}, qs); @@ -204,8 +244,10 @@ export class MicrosoftDynamicsCrm implements INodeType { if (operation === 'update') { const accountId = this.getNodeParameter('accountId', i) as string; - // tslint:disable-next-line: no-any - const updateFields = this.getNodeParameter('updateFields', i) as { addresses: { address: [{ [key: string]: any }] } }; + const updateFields = this.getNodeParameter('updateFields', i) as { + // tslint:disable-next-line: no-any + addresses: { address: [{ [key: string]: any }] }; + }; const options = this.getNodeParameter('options', i) as { returnFields: string[] }; const body = { @@ -225,7 +267,13 @@ export class MicrosoftDynamicsCrm implements INodeType { qs['$select'] = 'accountid'; } - responseData = await microsoftApiRequest.call(this, 'PATCH', `/accounts(${accountId})`, body, qs); + responseData = await microsoftApiRequest.call( + this, + 'PATCH', + `/accounts(${accountId})`, + body, + qs, + ); } } diff --git a/packages/nodes-base/nodes/Microsoft/Dynamics/descriptions/AccountDescription.ts b/packages/nodes-base/nodes/Microsoft/Dynamics/descriptions/AccountDescription.ts index 9cb1f3789c..0f919f61d9 100644 --- a/packages/nodes-base/nodes/Microsoft/Dynamics/descriptions/AccountDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/Dynamics/descriptions/AccountDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - getAccountFields, -} from '../GenericFunctions'; +import { getAccountFields } from '../GenericFunctions'; export const accountOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const accountOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'account', - ], + resource: ['account'], }, }, options: [ @@ -63,12 +57,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'create', - ], + resource: ['account'], + operation: ['create'], }, }, }, @@ -80,17 +70,11 @@ export const accountFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'create', - ], + resource: ['account'], + operation: ['create'], }, }, - options: [ - ...getAccountFields(), - ], + options: [...getAccountFields()], }, // ---------------------------------------- // account:get @@ -103,14 +87,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'delete', - 'get', - 'update', - ], + resource: ['account'], + operation: ['delete', 'get', 'update'], }, }, }, @@ -123,12 +101,8 @@ export const accountFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getAll', - ], + resource: ['account'], + operation: ['getAll'], }, }, default: false, @@ -140,15 +114,9 @@ export const accountFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['account'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -166,13 +134,8 @@ export const accountFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'get', - 'getAll', - ], + resource: ['account'], + operation: ['get', 'getAll'], }, }, options: [ @@ -180,7 +143,8 @@ export const accountFields: INodeProperties[] = [ displayName: 'Return Field Names or IDs', name: 'returnFields', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getAccountFields', }, @@ -190,7 +154,8 @@ export const accountFields: INodeProperties[] = [ displayName: 'Expand Field Names or IDs', name: 'expandFields', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getExpandableAccountFields', }, @@ -206,12 +171,8 @@ export const accountFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getAll', - ], + resource: ['account'], + operation: ['getAll'], }, }, options: [ @@ -220,7 +181,8 @@ export const accountFields: INodeProperties[] = [ name: 'query', type: 'string', default: '', - description: 'Query to filter the results. Check filters.', + description: + 'Query to filter the results. Check filters.', }, ], }, @@ -236,17 +198,11 @@ export const accountFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'update', - ], + resource: ['account'], + operation: ['update'], }, }, - options: [ - ...getAccountFields(), - ], + options: [...getAccountFields()], }, { displayName: 'Options', @@ -256,13 +212,8 @@ export const accountFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'create', - 'update', - ], + resource: ['account'], + operation: ['create', 'update'], }, }, options: [ @@ -274,7 +225,8 @@ export const accountFields: INodeProperties[] = [ loadOptionsMethod: 'getAccountFields', }, default: [], - description: 'Fields the response will include. Choose from the list, or specify IDs using an expression.', + description: + 'Fields the response will include. Choose from the list, or specify IDs using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/Microsoft/Dynamics/descriptions/index.ts b/packages/nodes-base/nodes/Microsoft/Dynamics/descriptions/index.ts index 6bd434939a..53aa67674d 100644 --- a/packages/nodes-base/nodes/Microsoft/Dynamics/descriptions/index.ts +++ b/packages/nodes-base/nodes/Microsoft/Dynamics/descriptions/index.ts @@ -1 +1 @@ -export * from './AccountDescription'; \ No newline at end of file +export * from './AccountDescription'; diff --git a/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts index 8dc0e4ee69..c8558f5240 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts @@ -1,14 +1,18 @@ import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; -import { - IDataObject, NodeApiError -} from 'n8n-workflow'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function microsoftApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -30,8 +34,16 @@ export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSing } } -export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function microsoftApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -42,15 +54,21 @@ export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoa responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri); uri = responseData['@odata.nextLink']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['@odata.nextLink'] !== undefined - ); + } while (responseData['@odata.nextLink'] !== undefined); return returnData; } -export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function microsoftApiRequestAllItemsSkip( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -61,9 +79,7 @@ export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions | responseData = await microsoftApiRequest.call(this, method, endpoint, body, query); query['$skip'] += query['$top']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['value'].length !== 0 - ); + } while (responseData['value'].length !== 0); return returnData; } diff --git a/packages/nodes-base/nodes/Microsoft/Excel/MicrosoftExcel.node.ts b/packages/nodes-base/nodes/Microsoft/Excel/MicrosoftExcel.node.ts index ebbd5ddedf..19ed434ccd 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/MicrosoftExcel.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/MicrosoftExcel.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -19,20 +17,11 @@ import { microsoftApiRequestAllItemsSkip, } from './GenericFunctions'; -import { - workbookFields, - workbookOperations, -} from './WorkbookDescription'; +import { workbookFields, workbookOperations } from './WorkbookDescription'; -import { - worksheetFields, - worksheetOperations, -} from './WorksheetDescription'; +import { worksheetFields, worksheetOperations } from './WorksheetDescription'; -import { - tableFields, - tableOperations, -} from './TableDescription'; +import { tableFields, tableOperations } from './TableDescription'; export class MicrosoftExcel implements INodeType { description: INodeTypeDescription = { @@ -69,12 +58,14 @@ export class MicrosoftExcel implements INodeType { { name: 'Workbook', value: 'workbook', - description: 'Workbook is the top level object which contains related workbook objects such as worksheets, tables, ranges, etc', + description: + 'Workbook is the top level object which contains related workbook objects such as worksheets, tables, ranges, etc', }, { name: 'Worksheet', value: 'worksheet', - description: 'An Excel worksheet is a grid of cells. It can contain data, tables, charts, etc.', + description: + 'An Excel worksheet is a grid of cells. It can contain data, tables, charts, etc.', }, ], default: 'workbook', @@ -97,7 +88,14 @@ export class MicrosoftExcel implements INodeType { select: 'id,name', }; const returnData: INodePropertyOptions[] = []; - const workbooks = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/root/search(q='.xlsx')`, {}, qs); + const workbooks = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/drive/root/search(q='.xlsx')`, + {}, + qs, + ); for (const workbook of workbooks) { const workbookName = workbook.name; const workbookId = workbook.id; @@ -116,7 +114,14 @@ export class MicrosoftExcel implements INodeType { select: 'id,name', }; const returnData: INodePropertyOptions[] = []; - const worksheets = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets`, {}, qs); + const worksheets = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/drive/items/${workbookId}/workbook/worksheets`, + {}, + qs, + ); for (const worksheet of worksheets) { const worksheetName = worksheet.name; const worksheetId = worksheet.id; @@ -136,7 +141,14 @@ export class MicrosoftExcel implements INodeType { select: 'id,name', }; const returnData: INodePropertyOptions[] = []; - const tables = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables`, {}, qs); + const tables = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables`, + {}, + qs, + ); for (const table of tables) { const tableName = table.name; const tableId = table.id; @@ -177,8 +189,14 @@ export class MicrosoftExcel implements INodeType { } // Get table columns to eliminate any columns not needed on the input - responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, {}, qs); - const columns = responseData.value.map((column: IDataObject) => (column.name)); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, + {}, + qs, + ); + const columns = responseData.value.map((column: IDataObject) => column.name); const rows: any[][] = []; // tslint:disable-line:no-any @@ -192,9 +210,30 @@ export class MicrosoftExcel implements INodeType { } body.values = rows; - const { id } = await microsoftApiRequest.call(this, 'POST', `/drive/items/${workbookId}/workbook/createSession`, { persistChanges: true }); - responseData = await microsoftApiRequest.call(this, 'POST', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows/add`, body, {}, '', { 'workbook-session-id': id }); - await microsoftApiRequest.call(this, 'POST', `/drive/items/${workbookId}/workbook/closeSession`, {}, {}, '', { 'workbook-session-id': id }); + const { id } = await microsoftApiRequest.call( + this, + 'POST', + `/drive/items/${workbookId}/workbook/createSession`, + { persistChanges: true }, + ); + responseData = await microsoftApiRequest.call( + this, + 'POST', + `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows/add`, + body, + {}, + '', + { 'workbook-session-id': id }, + ); + await microsoftApiRequest.call( + this, + 'POST', + `/drive/items/${workbookId}/workbook/closeSession`, + {}, + {}, + '', + { 'workbook-session-id': id }, + ); if (Array.isArray(responseData)) { returnData.push.apply(returnData, responseData as IDataObject[]); @@ -226,17 +265,30 @@ export class MicrosoftExcel implements INodeType { } } if (returnAll === true) { - responseData = await microsoftApiRequestAllItemsSkip.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, {}, qs); + responseData = await microsoftApiRequestAllItemsSkip.call( + this, + 'value', + 'GET', + `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, + {}, + qs, + ); } else { qs['$top'] = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, {}, qs); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, + {}, + qs, + ); responseData = responseData.value; } if (!rawData) { responseData = responseData.map((column: IDataObject) => ({ name: column.name })); } else { const dataProperty = this.getNodeParameter('dataProperty', i) as string; - responseData = { [dataProperty] : responseData }; + responseData = { [dataProperty]: responseData }; } if (Array.isArray(responseData)) { @@ -270,20 +322,40 @@ export class MicrosoftExcel implements INodeType { } } if (returnAll === true) { - responseData = await microsoftApiRequestAllItemsSkip.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows`, {}, qs); + responseData = await microsoftApiRequestAllItemsSkip.call( + this, + 'value', + 'GET', + `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows`, + {}, + qs, + ); } else { const rowsQs = { ...qs }; rowsQs['$top'] = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows`, {}, rowsQs); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows`, + {}, + rowsQs, + ); responseData = responseData.value; } if (!rawData) { const columnsQs = { ...qs }; columnsQs['$select'] = 'name'; // TODO: That should probably be cached in the future - let columns = await microsoftApiRequestAllItemsSkip.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, {}, columnsQs); + let columns = await microsoftApiRequestAllItemsSkip.call( + this, + 'value', + 'GET', + `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, + {}, + columnsQs, + ); //@ts-ignore - columns = columns.map(column => column.name); + columns = columns.map((column) => column.name); for (let i = 0; i < responseData.length; i++) { const object: IDataObject = {}; for (let y = 0; y < columns.length; y++) { @@ -315,15 +387,31 @@ export class MicrosoftExcel implements INodeType { const lookupValue = this.getNodeParameter('lookupValue', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; - responseData = await microsoftApiRequestAllItemsSkip.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows`, {}, {}); + responseData = await microsoftApiRequestAllItemsSkip.call( + this, + 'value', + 'GET', + `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/rows`, + {}, + {}, + ); qs['$select'] = 'name'; // TODO: That should probably be cached in the future - let columns = await microsoftApiRequestAllItemsSkip.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, {}, qs); + let columns = await microsoftApiRequestAllItemsSkip.call( + this, + 'value', + 'GET', + `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/tables/${tableId}/columns`, + {}, + qs, + ); columns = columns.map((column: IDataObject) => column.name); if (!columns.includes(lookupColumn)) { - throw new NodeApiError(this.getNode(), responseData, { message: `Column ${lookupColumn} does not exist on the table selected` }); + throw new NodeApiError(this.getNode(), responseData, { + message: `Column ${lookupColumn} does not exist on the table selected`, + }); } result.length = 0; @@ -337,12 +425,12 @@ export class MicrosoftExcel implements INodeType { if (options.returnAllMatches) { responseData = result.filter((data: IDataObject) => { - return (data[lookupColumn]?.toString() === lookupValue ); + return data[lookupColumn]?.toString() === lookupValue; }); returnData.push.apply(returnData, responseData as IDataObject[]); } else { responseData = result.find((data: IDataObject) => { - return (data[lookupColumn]?.toString() === lookupValue ); + return data[lookupColumn]?.toString() === lookupValue; }); returnData.push(responseData as IDataObject); } @@ -368,9 +456,30 @@ export class MicrosoftExcel implements INodeType { if (additionalFields.name) { body.name = additionalFields.name; } - const { id } = await microsoftApiRequest.call(this, 'POST', `/drive/items/${workbookId}/workbook/createSession`, { persistChanges: true }); - responseData = await microsoftApiRequest.call(this, 'POST', `/drive/items/${workbookId}/workbook/worksheets/add`, body, {}, '', { 'workbook-session-id': id }); - await microsoftApiRequest.call(this, 'POST', `/drive/items/${workbookId}/workbook/closeSession`, {}, {}, '', { 'workbook-session-id': id }); + const { id } = await microsoftApiRequest.call( + this, + 'POST', + `/drive/items/${workbookId}/workbook/createSession`, + { persistChanges: true }, + ); + responseData = await microsoftApiRequest.call( + this, + 'POST', + `/drive/items/${workbookId}/workbook/worksheets/add`, + body, + {}, + '', + { 'workbook-session-id': id }, + ); + await microsoftApiRequest.call( + this, + 'POST', + `/drive/items/${workbookId}/workbook/closeSession`, + {}, + {}, + '', + { 'workbook-session-id': id }, + ); } if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; @@ -379,10 +488,23 @@ export class MicrosoftExcel implements INodeType { qs['$select'] = filters.fields; } if (returnAll === true) { - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/root/search(q='.xlsx')`, {}, qs); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/drive/root/search(q='.xlsx')`, + {}, + qs, + ); } else { qs['$top'] = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequest.call(this, 'GET', `/drive/root/search(q='.xlsx')`, {}, qs); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/drive/root/search(q='.xlsx')`, + {}, + qs, + ); responseData = responseData.value; } } @@ -414,10 +536,23 @@ export class MicrosoftExcel implements INodeType { qs['$select'] = filters.fields; } if (returnAll === true) { - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/items/${workbookId}/workbook/worksheets`, {}, qs); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/drive/items/${workbookId}/workbook/worksheets`, + {}, + qs, + ); } else { qs['$top'] = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${workbookId}/workbook/worksheets`, {}, qs); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/drive/items/${workbookId}/workbook/worksheets`, + {}, + qs, + ); responseData = responseData.value; } } @@ -434,13 +569,21 @@ export class MicrosoftExcel implements INodeType { } } - responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/range(address='${range}')`, {}, qs); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/drive/items/${workbookId}/workbook/worksheets/${worksheetId}/range(address='${range}')`, + {}, + qs, + ); if (!rawData) { const keyRow = this.getNodeParameter('keyRow', i) as number; const dataStartRow = this.getNodeParameter('dataStartRow', i) as number; if (responseData.values === null) { - throw new NodeApiError(this.getNode(), responseData, { message: 'Range did not return data' }); + throw new NodeApiError(this.getNode(), responseData, { + message: 'Range did not return data', + }); } const keyValues = responseData.values[keyRow]; for (let i = dataStartRow; i < responseData.values.length; i++) { diff --git a/packages/nodes-base/nodes/Microsoft/Excel/TableDescription.ts b/packages/nodes-base/nodes/Microsoft/Excel/TableDescription.ts index ebb6d4cdd2..4a6b79eb14 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/TableDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/TableDescription.ts @@ -8,9 +8,7 @@ export const tableOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'table', - ], + resource: ['table'], }, }, options: [ @@ -44,26 +42,22 @@ export const tableOperations: INodeProperties[] = [ ]; export const tableFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* table:addRow */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* table:addRow */ + /* -------------------------------------------------------------------------- */ { displayName: 'Workbook Name or ID', name: 'workbook', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkbooks', }, displayOptions: { show: { - operation: [ - 'addRow', - ], - resource: [ - 'table', - ], + operation: ['addRow'], + resource: ['table'], }, }, default: '', @@ -72,22 +66,17 @@ export const tableFields: INodeProperties[] = [ displayName: 'Worksheet Name or ID', name: 'worksheet', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getworksheets', - loadOptionsDependsOn: [ - 'workbook', - ], + loadOptionsDependsOn: ['workbook'], }, displayOptions: { show: { - operation: [ - 'addRow', - ], - resource: [ - 'table', - ], + operation: ['addRow'], + resource: ['table'], }, }, default: '', @@ -96,22 +85,17 @@ export const tableFields: INodeProperties[] = [ displayName: 'Table Name or ID', name: 'table', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getTables', - loadOptionsDependsOn: [ - 'worksheet', - ], + loadOptionsDependsOn: ['worksheet'], }, displayOptions: { show: { - operation: [ - 'addRow', - ], - resource: [ - 'table', - ], + operation: ['addRow'], + resource: ['table'], }, }, default: '', @@ -124,12 +108,8 @@ export const tableFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'addRow', - ], - resource: [ - 'table', - ], + operation: ['addRow'], + resource: ['table'], }, }, options: [ @@ -141,29 +121,27 @@ export const tableFields: INodeProperties[] = [ typeOptions: { minValue: 0, }, - description: 'Specifies the relative position of the new row. If not defined, the addition happens at the end. Any rows below the inserted row are shifted downwards. Zero-indexed', + description: + 'Specifies the relative position of the new row. If not defined, the addition happens at the end. Any rows below the inserted row are shifted downwards. Zero-indexed', }, ], }, -/* -------------------------------------------------------------------------- */ -/* table:getRows */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* table:getRows */ + /* -------------------------------------------------------------------------- */ { displayName: 'Workbook Name or ID', name: 'workbook', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkbooks', }, displayOptions: { show: { - operation: [ - 'getRows', - ], - resource: [ - 'table', - ], + operation: ['getRows'], + resource: ['table'], }, }, default: '', @@ -172,22 +150,17 @@ export const tableFields: INodeProperties[] = [ displayName: 'Worksheet Name or ID', name: 'worksheet', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getworksheets', - loadOptionsDependsOn: [ - 'workbook', - ], + loadOptionsDependsOn: ['workbook'], }, displayOptions: { show: { - operation: [ - 'getRows', - ], - resource: [ - 'table', - ], + operation: ['getRows'], + resource: ['table'], }, }, default: '', @@ -196,22 +169,17 @@ export const tableFields: INodeProperties[] = [ displayName: 'Table Name or ID', name: 'table', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getTables', - loadOptionsDependsOn: [ - 'worksheet', - ], + loadOptionsDependsOn: ['worksheet'], }, displayOptions: { show: { - operation: [ - 'getRows', - ], - resource: [ - 'table', - ], + operation: ['getRows'], + resource: ['table'], }, }, default: '', @@ -222,12 +190,8 @@ export const tableFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getRows', - ], - resource: [ - 'table', - ], + operation: ['getRows'], + resource: ['table'], }, }, default: false, @@ -239,15 +203,9 @@ export const tableFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getRows', - ], - resource: [ - 'table', - ], - returnAll: [ - false, - ], + operation: ['getRows'], + resource: ['table'], + returnAll: [false], }, }, typeOptions: { @@ -263,16 +221,13 @@ export const tableFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getRows', - ], - resource: [ - 'table', - ], + operation: ['getRows'], + resource: ['table'], }, }, default: false, - description: 'Whether the data should be returned RAW instead of parsed into keys according to their header', + description: + 'Whether the data should be returned RAW instead of parsed into keys according to their header', }, { displayName: 'Data Property', @@ -281,15 +236,9 @@ export const tableFields: INodeProperties[] = [ default: 'data', displayOptions: { show: { - operation: [ - 'getRows', - ], - resource: [ - 'table', - ], - rawData: [ - true, - ], + operation: ['getRows'], + resource: ['table'], + rawData: [true], }, }, description: 'The name of the property into which to write the RAW data', @@ -302,15 +251,9 @@ export const tableFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getRows', - ], - resource: [ - 'table', - ], - rawData: [ - true, - ], + operation: ['getRows'], + resource: ['table'], + rawData: [true], }, }, options: [ @@ -323,25 +266,22 @@ export const tableFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* table:getColumns */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* table:getColumns */ + /* -------------------------------------------------------------------------- */ { displayName: 'Workbook Name or ID', name: 'workbook', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkbooks', }, displayOptions: { show: { - operation: [ - 'getColumns', - ], - resource: [ - 'table', - ], + operation: ['getColumns'], + resource: ['table'], }, }, default: '', @@ -350,22 +290,17 @@ export const tableFields: INodeProperties[] = [ displayName: 'Worksheet Name or ID', name: 'worksheet', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getworksheets', - loadOptionsDependsOn: [ - 'workbook', - ], + loadOptionsDependsOn: ['workbook'], }, displayOptions: { show: { - operation: [ - 'getColumns', - ], - resource: [ - 'table', - ], + operation: ['getColumns'], + resource: ['table'], }, }, default: '', @@ -374,22 +309,17 @@ export const tableFields: INodeProperties[] = [ displayName: 'Table Name or ID', name: 'table', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getTables', - loadOptionsDependsOn: [ - 'worksheet', - ], + loadOptionsDependsOn: ['worksheet'], }, displayOptions: { show: { - operation: [ - 'getColumns', - ], - resource: [ - 'table', - ], + operation: ['getColumns'], + resource: ['table'], }, }, default: '', @@ -400,12 +330,8 @@ export const tableFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getColumns', - ], - resource: [ - 'table', - ], + operation: ['getColumns'], + resource: ['table'], }, }, default: false, @@ -417,15 +343,9 @@ export const tableFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getColumns', - ], - resource: [ - 'table', - ], - returnAll: [ - false, - ], + operation: ['getColumns'], + resource: ['table'], + returnAll: [false], }, }, typeOptions: { @@ -441,16 +361,13 @@ export const tableFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getColumns', - ], - resource: [ - 'table', - ], + operation: ['getColumns'], + resource: ['table'], }, }, default: false, - description: 'Whether the data should be returned RAW instead of parsed into keys according to their header', + description: + 'Whether the data should be returned RAW instead of parsed into keys according to their header', }, { displayName: 'Data Property', @@ -459,15 +376,9 @@ export const tableFields: INodeProperties[] = [ default: 'data', displayOptions: { show: { - operation: [ - 'getColumns', - ], - resource: [ - 'table', - ], - rawData: [ - true, - ], + operation: ['getColumns'], + resource: ['table'], + rawData: [true], }, }, description: 'The name of the property into which to write the RAW data', @@ -480,15 +391,9 @@ export const tableFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getColumns', - ], - resource: [ - 'table', - ], - rawData: [ - true, - ], + operation: ['getColumns'], + resource: ['table'], + rawData: [true], }, }, options: [ @@ -501,26 +406,23 @@ export const tableFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* table:lookup */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* table:lookup */ + /* -------------------------------------------------------------------------- */ { displayName: 'Workbook Name or ID', name: 'workbook', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getWorkbooks', }, displayOptions: { show: { - operation: [ - 'lookup', - ], - resource: [ - 'table', - ], + operation: ['lookup'], + resource: ['table'], }, }, default: '', @@ -529,22 +431,17 @@ export const tableFields: INodeProperties[] = [ displayName: 'Worksheet Name or ID', name: 'worksheet', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getworksheets', - loadOptionsDependsOn: [ - 'workbook', - ], + loadOptionsDependsOn: ['workbook'], }, displayOptions: { show: { - operation: [ - 'lookup', - ], - resource: [ - 'table', - ], + operation: ['lookup'], + resource: ['table'], }, }, default: '', @@ -553,22 +450,17 @@ export const tableFields: INodeProperties[] = [ displayName: 'Table Name or ID', name: 'table', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getTables', - loadOptionsDependsOn: [ - 'worksheet', - ], + loadOptionsDependsOn: ['worksheet'], }, displayOptions: { show: { - operation: [ - 'lookup', - ], - resource: [ - 'table', - ], + operation: ['lookup'], + resource: ['table'], }, }, default: '', @@ -582,12 +474,8 @@ export const tableFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'lookup', - ], + resource: ['table'], + operation: ['lookup'], }, }, description: 'The name of the column in which to look for value', @@ -601,12 +489,8 @@ export const tableFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'lookup', - ], + resource: ['table'], + operation: ['lookup'], }, }, description: 'The value to look for in column', @@ -619,12 +503,8 @@ export const tableFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'lookup', - ], + resource: ['table'], + operation: ['lookup'], }, }, options: [ @@ -634,7 +514,8 @@ export const tableFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default only the first result gets returned. If options gets set all found matches get returned.', + description: + 'By default only the first result gets returned. If options gets set all found matches get returned.', }, ], }, diff --git a/packages/nodes-base/nodes/Microsoft/Excel/WorkbookDescription.ts b/packages/nodes-base/nodes/Microsoft/Excel/WorkbookDescription.ts index 73d89f29ae..1240b196cd 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/WorkbookDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/WorkbookDescription.ts @@ -8,9 +8,7 @@ export const workbookOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'workbook', - ], + resource: ['workbook'], }, }, options: [ @@ -32,27 +30,23 @@ export const workbookOperations: INodeProperties[] = [ ]; export const workbookFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* workbook:addWorksheet */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* workbook:addWorksheet */ + /* -------------------------------------------------------------------------- */ { displayName: 'Workbook Name or ID', name: 'workbook', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getWorkbooks', }, displayOptions: { show: { - operation: [ - 'addWorksheet', - ], - resource: [ - 'workbook', - ], + operation: ['addWorksheet'], + resource: ['workbook'], }, }, default: '', @@ -65,12 +59,8 @@ export const workbookFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'addWorksheet', - ], - resource: [ - 'workbook', - ], + operation: ['addWorksheet'], + resource: ['workbook'], }, }, options: [ @@ -79,25 +69,22 @@ export const workbookFields: INodeProperties[] = [ name: 'name', type: 'string', default: '', - description: 'The name of the worksheet to be added. If specified, name should be unqiue. If not specified, Excel determines the name of the new worksheet.', + description: + 'The name of the worksheet to be added. If specified, name should be unqiue. If not specified, Excel determines the name of the new worksheet.', }, ], }, -/* -------------------------------------------------------------------------- */ -/* workbook:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* workbook:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'workbook', - ], + operation: ['getAll'], + resource: ['workbook'], }, }, default: false, @@ -109,15 +96,9 @@ export const workbookFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'workbook', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['workbook'], + returnAll: [false], }, }, typeOptions: { @@ -135,12 +116,8 @@ export const workbookFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'workbook', - ], + operation: ['getAll'], + resource: ['workbook'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Microsoft/Excel/WorksheetDescription.ts b/packages/nodes-base/nodes/Microsoft/Excel/WorksheetDescription.ts index fdaaaf3b38..2f2410cfbc 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/WorksheetDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/WorksheetDescription.ts @@ -8,9 +8,7 @@ export const worksheetOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'worksheet', - ], + resource: ['worksheet'], }, }, options: [ @@ -32,26 +30,22 @@ export const worksheetOperations: INodeProperties[] = [ ]; export const worksheetFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* worksheet:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* worksheet:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Workbook Name or ID', name: 'workbook', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkbooks', }, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'worksheet', - ], + operation: ['getAll'], + resource: ['worksheet'], }, }, default: '', @@ -62,12 +56,8 @@ export const worksheetFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'worksheet', - ], + operation: ['getAll'], + resource: ['worksheet'], }, }, default: false, @@ -79,15 +69,9 @@ export const worksheetFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'worksheet', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['worksheet'], + returnAll: [false], }, }, typeOptions: { @@ -105,12 +89,8 @@ export const worksheetFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'worksheet', - ], + operation: ['getAll'], + resource: ['worksheet'], }, }, options: [ @@ -123,26 +103,23 @@ export const worksheetFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* worksheet:getContent */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* worksheet:getContent */ + /* -------------------------------------------------------------------------- */ { displayName: 'Workbook Name or ID', name: 'workbook', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getWorkbooks', }, displayOptions: { show: { - operation: [ - 'getContent', - ], - resource: [ - 'worksheet', - ], + operation: ['getContent'], + resource: ['worksheet'], }, }, default: '', @@ -151,22 +128,17 @@ export const worksheetFields: INodeProperties[] = [ displayName: 'Worksheet Name or ID', name: 'worksheet', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getworksheets', - loadOptionsDependsOn: [ - 'workbook', - ], + loadOptionsDependsOn: ['workbook'], }, displayOptions: { show: { - operation: [ - 'getContent', - ], - resource: [ - 'worksheet', - ], + operation: ['getContent'], + resource: ['worksheet'], }, }, default: '', @@ -177,17 +149,14 @@ export const worksheetFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'getContent', - ], - resource: [ - 'worksheet', - ], + operation: ['getContent'], + resource: ['worksheet'], }, }, default: 'A1:C3', required: true, - description: 'The address or the name of the range. If not specified, the entire worksheet range is returned.', + description: + 'The address or the name of the range. If not specified, the entire worksheet range is returned.', }, { displayName: 'RAW Data', @@ -195,16 +164,13 @@ export const worksheetFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getContent', - ], - resource: [ - 'worksheet', - ], + operation: ['getContent'], + resource: ['worksheet'], }, }, default: false, - description: 'Whether the data should be returned RAW instead of parsed into keys according to their header', + description: + 'Whether the data should be returned RAW instead of parsed into keys according to their header', }, { displayName: 'Data Property', @@ -213,15 +179,9 @@ export const worksheetFields: INodeProperties[] = [ default: 'data', displayOptions: { show: { - operation: [ - 'getContent', - ], - resource: [ - 'worksheet', - ], - rawData: [ - true, - ], + operation: ['getContent'], + resource: ['worksheet'], + rawData: [true], }, }, description: 'The name of the property into which to write the RAW data', @@ -236,20 +196,15 @@ export const worksheetFields: INodeProperties[] = [ default: 1, displayOptions: { show: { - operation: [ - 'getContent', - ], - resource: [ - 'worksheet', - ], + operation: ['getContent'], + resource: ['worksheet'], }, hide: { - rawData: [ - true, - ], + rawData: [true], }, }, - description: 'Index of the first row which contains the actual data and not the keys. Starts with 0.', + description: + 'Index of the first row which contains the actual data and not the keys. Starts with 0.', }, { displayName: 'Key Row', @@ -260,21 +215,16 @@ export const worksheetFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'getContent', - ], - resource: [ - 'worksheet', - ], + operation: ['getContent'], + resource: ['worksheet'], }, hide: { - rawData: [ - true, - ], + rawData: [true], }, }, default: 0, - description: 'Index of the row which contains the keys. Starts at 0. The incoming node data is matched to the keys for assignment. The matching is case sensitve.', + description: + 'Index of the row which contains the keys. Starts at 0. The incoming node data is matched to the keys for assignment. The matching is case sensitve.', }, { displayName: 'Filters', @@ -284,15 +234,9 @@ export const worksheetFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getContent', - ], - resource: [ - 'worksheet', - ], - rawData: [ - true, - ], + operation: ['getContent'], + resource: ['worksheet'], + rawData: [true], }, }, options: [ diff --git a/packages/nodes-base/nodes/Microsoft/GraphSecurity/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/GraphSecurity/GenericFunctions.ts index c3003ba827..0e31c79e00 100644 --- a/packages/nodes-base/nodes/Microsoft/GraphSecurity/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/GraphSecurity/GenericFunctions.ts @@ -1,16 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; export async function msGraphSecurityApiRequest( this: IExecuteFunctions, @@ -24,10 +16,10 @@ export async function msGraphSecurityApiRequest( oauthTokenData: { access_token, // tslint:disable-line variable-name }, - } = await this.getCredentials('microsoftGraphSecurityOAuth2Api') as { + } = (await this.getCredentials('microsoftGraphSecurityOAuth2Api')) as { oauthTokenData: { access_token: string; - } + }; }; const options: OptionsWithUri = { @@ -72,7 +64,8 @@ export async function msGraphSecurityApiRequest( } if (['Invalid filter clause', 'Invalid ODATA query filter'].includes(nestedMessage)) { - error.error.error.message += ' - Please check that your query parameter syntax is correct: https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter'; + error.error.error.message += + ' - Please check that your query parameter syntax is correct: https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter'; } throw new NodeApiError(this.getNode(), error); diff --git a/packages/nodes-base/nodes/Microsoft/GraphSecurity/MicrosoftGraphSecurity.node.ts b/packages/nodes-base/nodes/Microsoft/GraphSecurity/MicrosoftGraphSecurity.node.ts index 8238bdb511..1fb5e47a5e 100644 --- a/packages/nodes-base/nodes/Microsoft/GraphSecurity/MicrosoftGraphSecurity.node.ts +++ b/packages/nodes-base/nodes/Microsoft/GraphSecurity/MicrosoftGraphSecurity.node.ts @@ -1,13 +1,6 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; import { msGraphSecurityApiRequest, @@ -72,23 +65,21 @@ export class MicrosoftGraphSecurity implements INodeType { const items = this.getInputData(); const returnData: IDataObject[] = []; - const resource = this.getNodeParameter('resource', 0) as 'secureScore'| 'secureScoreControlProfile'; + const resource = this.getNodeParameter('resource', 0) as + | 'secureScore' + | 'secureScoreControlProfile'; const operation = this.getNodeParameter('operation', 0) as 'get' | 'getAll' | 'update'; let responseData; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'secureScore') { - // ********************************************************************** // secureScore // ********************************************************************** if (operation === 'get') { - // ---------------------------------------- // secureScore: get // ---------------------------------------- @@ -97,11 +88,13 @@ export class MicrosoftGraphSecurity implements INodeType { const secureScoreId = this.getNodeParameter('secureScoreId', i); - responseData = await msGraphSecurityApiRequest.call(this, 'GET', `/secureScores/${secureScoreId}`); + responseData = await msGraphSecurityApiRequest.call( + this, + 'GET', + `/secureScores/${secureScoreId}`, + ); delete responseData['@odata.context']; - } else if (operation === 'getAll') { - // ---------------------------------------- // secureScore: getAll // ---------------------------------------- @@ -110,10 +103,7 @@ export class MicrosoftGraphSecurity implements INodeType { const qs: IDataObject = {}; - const { - filter, - includeControlScores, - } = this.getNodeParameter('filters', i) as { + const { filter, includeControlScores } = this.getNodeParameter('filters', i) as { filter?: string; includeControlScores?: boolean; }; @@ -129,38 +119,35 @@ export class MicrosoftGraphSecurity implements INodeType { qs.$top = this.getNodeParameter('limit', 0); } - responseData = await msGraphSecurityApiRequest + responseData = (await msGraphSecurityApiRequest .call(this, 'GET', '/secureScores', {}, qs) - .then(response => response.value) as Array<{ controlScores: object[] }>; + .then((response) => response.value)) as Array<{ controlScores: object[] }>; if (!includeControlScores) { responseData = responseData.map(({ controlScores, ...rest }) => rest); } - } - } else if (resource === 'secureScoreControlProfile') { - // ********************************************************************** // secureScoreControlProfile // ********************************************************************** if (operation === 'get') { - // ---------------------------------------- // secureScoreControlProfile: get // ---------------------------------------- // https://docs.microsoft.com/en-us/graph/api/securescorecontrolprofile-get - const secureScoreControlProfileId = this.getNodeParameter('secureScoreControlProfileId', i); + const secureScoreControlProfileId = this.getNodeParameter( + 'secureScoreControlProfileId', + i, + ); const endpoint = `/secureScoreControlProfiles/${secureScoreControlProfileId}`; responseData = await msGraphSecurityApiRequest.call(this, 'GET', endpoint); delete responseData['@odata.context']; - } else if (operation === 'getAll') { - // ---------------------------------------- // secureScoreControlProfile: getAll // ---------------------------------------- @@ -184,10 +171,8 @@ export class MicrosoftGraphSecurity implements INodeType { responseData = await msGraphSecurityApiRequest .call(this, 'GET', '/secureScoreControlProfiles', {}, qs) - .then(response => response.value); - + .then((response) => response.value); } else if (operation === 'update') { - // ---------------------------------------- // secureScoreControlProfile: update // ---------------------------------------- @@ -215,13 +200,17 @@ export class MicrosoftGraphSecurity implements INodeType { const endpoint = `/secureScoreControlProfiles/${id}`; const headers = { Prefer: 'return=representation' }; - responseData = await msGraphSecurityApiRequest.call(this, 'PATCH', endpoint, body, {}, headers); + responseData = await msGraphSecurityApiRequest.call( + this, + 'PATCH', + endpoint, + body, + {}, + headers, + ); delete responseData['@odata.context']; - } - } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -233,7 +222,6 @@ export class MicrosoftGraphSecurity implements INodeType { Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Microsoft/GraphSecurity/descriptions/SecureScoreControlProfileDescription.ts b/packages/nodes-base/nodes/Microsoft/GraphSecurity/descriptions/SecureScoreControlProfileDescription.ts index f7b6d02e71..6dfa098bad 100644 --- a/packages/nodes-base/nodes/Microsoft/GraphSecurity/descriptions/SecureScoreControlProfileDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/GraphSecurity/descriptions/SecureScoreControlProfileDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const secureScoreControlProfileOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const secureScoreControlProfileOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'secureScoreControlProfile', - ], + resource: ['secureScoreControlProfile'], }, }, options: [ @@ -49,12 +45,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'secureScoreControlProfile', - ], - operation: [ - 'get', - ], + resource: ['secureScoreControlProfile'], + operation: ['get'], }, }, }, @@ -70,12 +62,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'secureScoreControlProfile', - ], - operation: [ - 'getAll', - ], + resource: ['secureScoreControlProfile'], + operation: ['getAll'], }, }, }, @@ -91,15 +79,9 @@ export const secureScoreControlProfileFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'secureScoreControlProfile', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['secureScoreControlProfile'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -111,23 +93,20 @@ export const secureScoreControlProfileFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'secureScoreControlProfile', - ], - operation: [ - 'getAll', - ], + resource: ['secureScoreControlProfile'], + operation: ['getAll'], }, }, options: [ { displayName: 'Filter Query Parameter', name: 'filter', - description: 'Query parameter to filter results by', + description: + 'Query parameter to filter results by', type: 'string', default: '', // eslint-disable-next-line n8n-nodes-base/node-param-placeholder-miscased-id - placeholder: 'startsWith(id, \'AATP\')', + placeholder: "startsWith(id, 'AATP')", }, ], }, @@ -144,12 +123,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'secureScoreControlProfile', - ], - operation: [ - 'update', - ], + resource: ['secureScoreControlProfile'], + operation: ['update'], }, }, }, @@ -163,12 +138,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'secureScoreControlProfile', - ], - operation: [ - 'update', - ], + resource: ['secureScoreControlProfile'], + operation: ['update'], }, }, }, @@ -182,12 +153,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'secureScoreControlProfile', - ], - operation: [ - 'update', - ], + resource: ['secureScoreControlProfile'], + operation: ['update'], }, }, }, @@ -199,12 +166,8 @@ export const secureScoreControlProfileFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'secureScoreControlProfile', - ], - operation: [ - 'update', - ], + resource: ['secureScoreControlProfile'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Microsoft/GraphSecurity/descriptions/SecureScoreDescription.ts b/packages/nodes-base/nodes/Microsoft/GraphSecurity/descriptions/SecureScoreDescription.ts index a1c7542db1..73d8d87377 100644 --- a/packages/nodes-base/nodes/Microsoft/GraphSecurity/descriptions/SecureScoreDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/GraphSecurity/descriptions/SecureScoreDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const secureScoreOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const secureScoreOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'secureScore', - ], + resource: ['secureScore'], }, }, options: [ @@ -44,12 +40,8 @@ export const secureScoreFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'secureScore', - ], - operation: [ - 'get', - ], + resource: ['secureScore'], + operation: ['get'], }, }, }, @@ -65,12 +57,8 @@ export const secureScoreFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'secureScore', - ], - operation: [ - 'getAll', - ], + resource: ['secureScore'], + operation: ['getAll'], }, }, }, @@ -86,15 +74,9 @@ export const secureScoreFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'secureScore', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['secureScore'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -106,19 +88,16 @@ export const secureScoreFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'secureScore', - ], - operation: [ - 'getAll', - ], + resource: ['secureScore'], + operation: ['getAll'], }, }, options: [ { displayName: 'Filter Query Parameter', name: 'filter', - description: 'Query parameter to filter results by', + description: + 'Query parameter to filter results by', type: 'string', default: '', placeholder: 'currentScore eq 13', diff --git a/packages/nodes-base/nodes/Microsoft/OneDrive/FileDescription.ts b/packages/nodes-base/nodes/Microsoft/OneDrive/FileDescription.ts index 06418cda5e..3348afb079 100644 --- a/packages/nodes-base/nodes/Microsoft/OneDrive/FileDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/OneDrive/FileDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const fileOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const fileOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'file', - ], + resource: ['file'], }, }, options: [ @@ -70,22 +66,17 @@ export const fileOperations: INodeProperties[] = [ ]; export const fileFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* file:copy */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* file:copy */ + /* -------------------------------------------------------------------------- */ { displayName: 'File ID', name: 'fileId', type: 'string', displayOptions: { show: { - operation: [ - 'copy', - ], - resource: [ - 'file', - ], + operation: ['copy'], + resource: ['file'], }, }, default: '', @@ -97,12 +88,8 @@ export const fileFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'copy', - ], - resource: [ - 'file', - ], + operation: ['copy'], + resource: ['file'], }, }, default: {}, @@ -112,7 +99,8 @@ export const fileFields: INodeProperties[] = [ name: 'name', type: 'string', default: '', - description: 'The new name for the copy. If this isn\'t provided, the same name will be used as the original.', + description: + "The new name for the copy. If this isn't provided, the same name will be used as the original.", }, ], }, @@ -121,15 +109,12 @@ export const fileFields: INodeProperties[] = [ name: 'parentReference', type: 'collection', placeholder: 'Add Parent Reference', - description: 'Reference to the parent item the copy will be created in Details ', + description: + 'Reference to the parent item the copy will be created in Details ', displayOptions: { show: { - operation: [ - 'copy', - ], - resource: [ - 'file', - ], + operation: ['copy'], + resource: ['file'], }, }, default: {}, @@ -192,41 +177,33 @@ export const fileFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* file:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* file:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'File ID', name: 'fileId', type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'file', - ], + operation: ['delete'], + resource: ['file'], }, }, default: '', description: 'Field ID', }, -/* -------------------------------------------------------------------------- */ -/* file:download */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* file:download */ + /* -------------------------------------------------------------------------- */ { displayName: 'File ID', name: 'fileId', type: 'string', displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'file', - ], + operation: ['download'], + resource: ['file'], }, }, default: '', @@ -239,108 +216,85 @@ export const fileFields: INodeProperties[] = [ default: 'data', displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'file', - ], + operation: ['download'], + resource: ['file'], }, }, description: 'Name of the binary property to which to write the data of the read file', }, -/* -------------------------------------------------------------------------- */ -/* file:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* file:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'File ID', name: 'fileId', type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'file', - ], + operation: ['get'], + resource: ['file'], }, }, default: '', description: 'Field ID', }, -/* -------------------------------------------------------------------------- */ -/* file:rename */ -/* -------------------------------------------------------------------------- */ -{ - displayName: 'Item ID', - name: 'itemId', - type: 'string', - displayOptions: { - show: { - operation: [ - 'rename', - ], - resource: [ - 'file', - ], + /* -------------------------------------------------------------------------- */ + /* file:rename */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'Item ID', + name: 'itemId', + type: 'string', + displayOptions: { + show: { + operation: ['rename'], + resource: ['file'], + }, }, + default: '', + description: 'ID of the file', }, - default: '', - description: 'ID of the file', -}, -{ - displayName: 'New Name', - name: 'newName', - type: 'string', - displayOptions: { - show: { - operation: [ - 'rename', - ], - resource: [ - 'file', - ], + { + displayName: 'New Name', + name: 'newName', + type: 'string', + displayOptions: { + show: { + operation: ['rename'], + resource: ['file'], + }, }, + default: '', + description: 'New name for file', }, - default: '', - description: 'New name for file', -}, -/* -------------------------------------------------------------------------- */ -/* file:search */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* file:search */ + /* -------------------------------------------------------------------------- */ { displayName: 'Query', name: 'query', type: 'string', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'file', - ], + operation: ['search'], + resource: ['file'], }, }, default: '', - description: 'The query text used to search for items. Values may be matched across several fields including filename, metadata, and file content.', + description: + 'The query text used to search for items. Values may be matched across several fields including filename, metadata, and file content.', }, -/* -------------------------------------------------------------------------- */ -/* file:share */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* file:share */ + /* -------------------------------------------------------------------------- */ { displayName: 'File ID', name: 'fileId', type: 'string', displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'file', - ], + operation: ['share'], + resource: ['file'], }, }, default: '', @@ -365,12 +319,8 @@ export const fileFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'file', - ], + operation: ['share'], + resource: ['file'], }, }, default: '', @@ -392,32 +342,24 @@ export const fileFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'file', - ], + operation: ['share'], + resource: ['file'], }, }, default: '', description: 'The type of sharing link to create', }, -/* -------------------------------------------------------------------------- */ -/* file:upload */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* file:upload */ + /* -------------------------------------------------------------------------- */ { displayName: 'File Name', name: 'fileName', type: 'string', displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, default: '', @@ -430,12 +372,8 @@ export const fileFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, default: '', @@ -449,12 +387,8 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, description: 'Whether the data to upload should be taken from binary field', @@ -467,17 +401,10 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - binaryData: [ - false, - ], - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + binaryData: [false], + operation: ['upload'], + resource: ['file'], }, - }, placeholder: '', description: 'The text content of the file', @@ -490,17 +417,10 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - binaryData: [ - true, - ], - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + binaryData: [true], + operation: ['upload'], + resource: ['file'], }, - }, placeholder: '', description: 'Name of the binary property which contains the data for the file', diff --git a/packages/nodes-base/nodes/Microsoft/OneDrive/FolderDescription.ts b/packages/nodes-base/nodes/Microsoft/OneDrive/FolderDescription.ts index 18a19ab94e..c6c3b28057 100644 --- a/packages/nodes-base/nodes/Microsoft/OneDrive/FolderDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/OneDrive/FolderDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const folderOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const folderOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'folder', - ], + resource: ['folder'], }, }, options: [ @@ -58,10 +54,9 @@ export const folderOperations: INodeProperties[] = [ ]; export const folderFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* folder:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* folder:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Name', name: 'name', @@ -70,12 +65,8 @@ export const folderFields: INodeProperties[] = [ placeholder: '/Pictures/2021', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'folder', - ], + operation: ['create'], + resource: ['folder'], }, }, default: '', @@ -87,12 +78,8 @@ export const folderFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'folder', - ], + operation: ['create'], + resource: ['folder'], }, }, default: {}, @@ -107,98 +94,78 @@ export const folderFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* folder:getChildren/delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* folder:getChildren/delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Folder ID', name: 'folderId', type: 'string', displayOptions: { show: { - operation: [ - 'delete', - 'getChildren', - ], - resource: [ - 'folder', - ], + operation: ['delete', 'getChildren'], + resource: ['folder'], }, }, default: '', }, -/* -------------------------------------------------------------------------- */ -/* folder:rename */ -/* -------------------------------------------------------------------------- */ -{ - displayName: 'Item ID', - name: 'itemId', - type: 'string', - displayOptions: { - show: { - operation: [ - 'rename', - ], - resource: [ - 'folder', - ], + /* -------------------------------------------------------------------------- */ + /* folder:rename */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'Item ID', + name: 'itemId', + type: 'string', + displayOptions: { + show: { + operation: ['rename'], + resource: ['folder'], + }, }, + default: '', + description: 'ID of the folder', }, - default: '', - description: 'ID of the folder', -}, -{ - displayName: 'New Name', - name: 'newName', - type: 'string', - displayOptions: { - show: { - operation: [ - 'rename', - ], - resource: [ - 'folder', - ], + { + displayName: 'New Name', + name: 'newName', + type: 'string', + displayOptions: { + show: { + operation: ['rename'], + resource: ['folder'], + }, }, + default: '', + description: 'New name for folder', }, - default: '', - description: 'New name for folder', -}, -/* -------------------------------------------------------------------------- */ -/* folder:search */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* folder:search */ + /* -------------------------------------------------------------------------- */ { displayName: 'Query', name: 'query', type: 'string', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'folder', - ], + operation: ['search'], + resource: ['folder'], }, }, default: '', - description: 'The query text used to search for items. Values may be matched across several fields including filename, metadata, and file content.', + description: + 'The query text used to search for items. Values may be matched across several fields including filename, metadata, and file content.', }, -/* -------------------------------------------------------------------------- */ -/* folder:share */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* folder:share */ + /* -------------------------------------------------------------------------- */ { displayName: 'Folder ID', name: 'folderId', type: 'string', displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'folder', - ], + operation: ['share'], + resource: ['folder'], }, }, default: '', @@ -224,12 +191,8 @@ export const folderFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'folder', - ], + operation: ['share'], + resource: ['folder'], }, }, default: '', @@ -251,12 +214,8 @@ export const folderFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'folder', - ], + operation: ['share'], + resource: ['folder'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts index 1bc70a06cc..ebdef13758 100644 --- a/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts @@ -1,18 +1,21 @@ -import { - OptionsWithUri - } from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, option: IDataObject = { json: true }): Promise { // tslint:disable-line:no-any +export async function microsoftApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + option: IDataObject = { json: true }, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -40,8 +43,16 @@ export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSing } } -export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function microsoftApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -55,15 +66,21 @@ export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoa delete query['$top']; } returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['@odata.nextLink'] !== undefined - ); + } while (responseData['@odata.nextLink'] !== undefined); return returnData; } -export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function microsoftApiRequestAllItemsSkip( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -74,9 +91,7 @@ export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions | responseData = await microsoftApiRequest.call(this, method, endpoint, body, query); query['$skip'] += query['$top']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['value'].length !== 0 - ); + } while (responseData['value'].length !== 0); return returnData; } diff --git a/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts b/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts index e821019970..070df98c7d 100644 --- a/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts +++ b/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryKeyData, @@ -12,20 +10,11 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - microsoftApiRequest, - microsoftApiRequestAllItems, -} from './GenericFunctions'; +import { microsoftApiRequest, microsoftApiRequestAllItems } from './GenericFunctions'; -import { - fileFields, - fileOperations, -} from './FileDescription'; +import { fileFields, fileOperations } from './FileDescription'; -import { - folderFields, - folderOperations, -} from './FolderDescription'; +import { folderFields, folderOperations } from './FolderDescription'; export class MicrosoftOneDrive implements INodeType { description: INodeTypeDescription = { @@ -95,7 +84,16 @@ export class MicrosoftOneDrive implements INodeType { if (additionalFields.name) { body.name = additionalFields.name as string; } - responseData = await microsoftApiRequest.call(this, 'POST', `/drive/items/${fileId}/copy`, body, {}, undefined, {}, { json: true, resolveWithFullResponse: true }); + responseData = await microsoftApiRequest.call( + this, + 'POST', + `/drive/items/${fileId}/copy`, + body, + {}, + undefined, + {}, + { json: true, resolveWithFullResponse: true }, + ); responseData = { location: responseData.headers.location }; returnData.push(responseData as IDataObject); } @@ -109,13 +107,18 @@ export class MicrosoftOneDrive implements INodeType { //https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_children?view=odsp-graph-online if (operation === 'download') { const fileId = this.getNodeParameter('fileId', i) as string; - const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string; + const dataPropertyNameDownload = this.getNodeParameter( + 'binaryPropertyName', + i, + ) as string; responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${fileId}`); const fileName = responseData.name; if (responseData.file === undefined) { - throw new NodeApiError(this.getNode(), responseData, { message: 'The ID you provided does not belong to a file.' }); + throw new NodeApiError(this.getNode(), responseData, { + message: 'The ID you provided does not belong to a file.', + }); } let mimeType: string | undefined; @@ -123,7 +126,16 @@ export class MicrosoftOneDrive implements INodeType { mimeType = responseData.file.mimeType; } - responseData = await microsoftApiRequest.call(this, 'GET', `/drive/items/${fileId}/content`, {}, {}, undefined, {}, { encoding: null, resolveWithFullResponse: true }); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/drive/items/${fileId}/content`, + {}, + {}, + undefined, + {}, + { encoding: null, resolveWithFullResponse: true }, + ); const newItem: INodeExecutionData = { json: items[i].json, @@ -145,7 +157,11 @@ export class MicrosoftOneDrive implements INodeType { const data = Buffer.from(responseData.body); - items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data as unknown as Buffer, fileName, mimeType); + items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( + data as unknown as Buffer, + fileName, + mimeType, + ); } //https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_get?view=odsp-graph-online if (operation === 'get') { @@ -156,7 +172,12 @@ export class MicrosoftOneDrive implements INodeType { //https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_search?view=odsp-graph-online if (operation === 'search') { const query = this.getNodeParameter('query', i) as string; - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/root/search(q='${query}')`); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/drive/root/search(q='${query}')`, + ); responseData = responseData.filter((item: IDataObject) => item.file); returnData.push.apply(returnData, responseData as IDataObject[]); } @@ -169,7 +190,12 @@ export class MicrosoftOneDrive implements INodeType { type, scope, }; - responseData = await microsoftApiRequest.call(this, 'POST', `/drive/items/${fileId}/createLink`, body); + responseData = await microsoftApiRequest.call( + this, + 'POST', + `/drive/items/${fileId}/createLink`, + body, + ); returnData.push(responseData); } //https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content?view=odsp-graph-online#example-upload-a-new-file @@ -182,18 +208,24 @@ export class MicrosoftOneDrive implements INodeType { const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string; if (items[i].binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } //@ts-ignore if (items[i].binary[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + { itemIndex: i }, + ); } const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName]; const body = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); let encodedFilename; - if(fileName !== '') { + if (fileName !== '') { encodedFilename = encodeURIComponent(fileName); } @@ -201,16 +233,35 @@ export class MicrosoftOneDrive implements INodeType { encodedFilename = encodeURIComponent(binaryData.fileName); } - responseData = await microsoftApiRequest.call(this, 'PUT', `/drive/items/${parentId}:/${encodedFilename}:/content`, body, {}, undefined, { 'Content-Type': binaryData.mimeType, 'Content-length': body.length }, {}); + responseData = await microsoftApiRequest.call( + this, + 'PUT', + `/drive/items/${parentId}:/${encodedFilename}:/content`, + body, + {}, + undefined, + { 'Content-Type': binaryData.mimeType, 'Content-length': body.length }, + {}, + ); returnData.push(JSON.parse(responseData) as IDataObject); } else { const body = this.getNodeParameter('fileContent', i) as string; if (fileName === '') { - throw new NodeOperationError(this.getNode(), 'File name must be set!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'File name must be set!', { + itemIndex: i, + }); } const encodedFilename = encodeURIComponent(fileName); - responseData = await microsoftApiRequest.call(this, 'PUT', `/drive/items/${parentId}:/${encodedFilename}:/content`, body, {}, undefined, { 'Content-Type': 'text/plain' }); + responseData = await microsoftApiRequest.call( + this, + 'PUT', + `/drive/items/${parentId}:/${encodedFilename}:/content`, + body, + {}, + undefined, + { 'Content-Type': 'text/plain' }, + ); returnData.push(responseData as IDataObject); } } @@ -218,7 +269,9 @@ export class MicrosoftOneDrive implements INodeType { if (resource === 'folder') { //https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_post_children?view=odsp-graph-online if (operation === 'create') { - const names = (this.getNodeParameter('name', i) as string).split('/').filter(s => s.trim() !== ''); + const names = (this.getNodeParameter('name', i) as string) + .split('/') + .filter((s) => s.trim() !== ''); const options = this.getNodeParameter('options', i) as IDataObject; let parentFolderId = options.parentFolderId ? options.parentFolderId : null; for (const name of names) { @@ -241,20 +294,34 @@ export class MicrosoftOneDrive implements INodeType { //https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_delete?view=odsp-graph-online if (operation === 'delete') { const folderId = this.getNodeParameter('folderId', i) as string; - responseData = await microsoftApiRequest.call(this, 'DELETE', `/drive/items/${folderId}`); + responseData = await microsoftApiRequest.call( + this, + 'DELETE', + `/drive/items/${folderId}`, + ); responseData = { success: true }; returnData.push(responseData as IDataObject); } //https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_list_children?view=odsp-graph-online if (operation === 'getChildren') { const folderId = this.getNodeParameter('folderId', i) as string; - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/items/${folderId}/children`); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/drive/items/${folderId}/children`, + ); returnData.push.apply(returnData, responseData as IDataObject[]); } //https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_search?view=odsp-graph-online if (operation === 'search') { const query = this.getNodeParameter('query', i) as string; - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/drive/root/search(q='${query}')`); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/drive/root/search(q='${query}')`, + ); responseData = responseData.filter((item: IDataObject) => item.folder); returnData.push.apply(returnData, responseData as IDataObject[]); } @@ -267,7 +334,12 @@ export class MicrosoftOneDrive implements INodeType { type, scope, }; - responseData = await microsoftApiRequest.call(this, 'POST', `/drive/items/${folderId}/createLink`, body); + responseData = await microsoftApiRequest.call( + this, + 'POST', + `/drive/items/${folderId}/createLink`, + body, + ); returnData.push(responseData); } } @@ -275,8 +347,13 @@ export class MicrosoftOneDrive implements INodeType { if (operation === 'rename') { const itemId = this.getNodeParameter('itemId', i) as string; const newName = this.getNodeParameter('newName', i) as string; - const body = {name: newName}; - responseData = await microsoftApiRequest.call(this, 'PATCH', `/drive/items/${itemId}`, body); + const body = { name: newName }; + responseData = await microsoftApiRequest.call( + this, + 'PATCH', + `/drive/items/${itemId}`, + body, + ); returnData.push(responseData as IDataObject); } } diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/DraftDescription.ts b/packages/nodes-base/nodes/Microsoft/Outlook/DraftDescription.ts index b1af282e1e..45b89a2038 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/DraftDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/DraftDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const draftOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const draftOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'draft', - ], + resource: ['draft'], }, }, options: [ @@ -60,15 +56,8 @@ export const draftFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'draft', - ], - operation: [ - 'delete', - 'get', - 'send', - 'update', - ], + resource: ['draft'], + operation: ['delete', 'get', 'send', 'update'], }, }, }, @@ -80,12 +69,8 @@ export const draftFields: INodeProperties[] = [ description: 'The subject of the message', displayOptions: { show: { - resource: [ - 'draft', - ], - operation: [ - 'create', - ], + resource: ['draft'], + operation: ['create'], }, }, type: 'string', @@ -98,12 +83,8 @@ export const draftFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'draft', - ], - operation: [ - 'create', - ], + resource: ['draft'], + operation: ['create'], }, }, default: '', @@ -116,12 +97,8 @@ export const draftFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'draft', - ], - operation: [ - 'create', - ], + resource: ['draft'], + operation: ['create'], }, }, options: [ @@ -144,12 +121,12 @@ export const draftFields: INodeProperties[] = [ name: 'binaryPropertyName', type: 'string', default: '', - description: 'Name of the binary property containing the data to be added to the email as an attachment', + description: + 'Name of the binary property containing the data to be added to the email as an attachment', }, ], }, ], - }, { displayName: 'BCC Recipients', @@ -179,7 +156,8 @@ export const draftFields: INodeProperties[] = [ displayName: 'Category Names or IDs', name: 'categories', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getCategories', }, @@ -227,7 +205,8 @@ export const draftFields: INodeProperties[] = [ { displayName: 'From', name: 'from', - description: 'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.', + description: + 'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.', type: 'string', default: '', }, @@ -285,12 +264,8 @@ export const draftFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'draft', - ], - operation: [ - 'send', - ], + resource: ['draft'], + operation: ['send'], }, }, options: [ @@ -303,7 +278,4 @@ export const draftFields: INodeProperties[] = [ }, ], }, - - - ]; diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/DraftMessageSharedDescription.ts b/packages/nodes-base/nodes/Microsoft/Outlook/DraftMessageSharedDescription.ts index 1f2ef57dc9..dcb3bfb1a6 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/DraftMessageSharedDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/DraftMessageSharedDescription.ts @@ -1,9 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const draftMessageSharedFields: INodeProperties[] = [ - // Get & Get All operations { displayName: 'Additional Fields', @@ -13,14 +10,8 @@ export const draftMessageSharedFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'draft', - 'message', - ], - operation: [ - 'get', - 'getAll', - ], + resource: ['draft', 'message'], + operation: ['get', 'getAll'], }, }, options: [ @@ -29,7 +20,8 @@ export const draftMessageSharedFields: INodeProperties[] = [ name: 'dataPropertyAttachmentsPrefixName', type: 'string', default: 'attachment_', - description: 'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"', + description: + 'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"', }, { displayName: 'Fields', @@ -44,7 +36,8 @@ export const draftMessageSharedFields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'isRead eq false', - description: 'Microsoft Graph API OData $filter query. Information about the syntax can be found here.', + description: + 'Microsoft Graph API OData $filter query. Information about the syntax can be found here.', }, ], }, @@ -58,13 +51,8 @@ export const draftMessageSharedFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'draft', - 'message', - ], - operation: [ - 'update', - ], + resource: ['draft', 'message'], + operation: ['update'], }, }, options: [ @@ -103,7 +91,8 @@ export const draftMessageSharedFields: INodeProperties[] = [ displayName: 'Category Names or IDs', name: 'categories', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getCategories', }, @@ -151,7 +140,8 @@ export const draftMessageSharedFields: INodeProperties[] = [ { displayName: 'From', name: 'from', - description: 'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.', + description: + 'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.', type: 'string', default: '', }, @@ -213,5 +203,4 @@ export const draftMessageSharedFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/FolderDescription.ts b/packages/nodes-base/nodes/Microsoft/Outlook/FolderDescription.ts index a267224c01..6f2c025aa2 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/FolderDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/FolderDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const folderOperations: INodeProperties[] = [ { @@ -10,16 +8,14 @@ export const folderOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'folder', - ], + resource: ['folder'], }, }, options: [ { name: 'Create', value: 'create', - description: 'Create a new mail folder in the root folder of the user\'s mailbox', + description: "Create a new mail folder in the root folder of the user's mailbox", action: 'Create a folder', }, { @@ -60,15 +56,8 @@ export const folderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'delete', - 'get', - 'getChildren', - 'update', - ], + resource: ['folder'], + operation: ['delete', 'get', 'getChildren', 'update'], }, }, }, @@ -79,13 +68,8 @@ export const folderFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'getAll', - 'getChildren', - ], + resource: ['folder'], + operation: ['getAll', 'getChildren'], }, }, default: false, @@ -97,13 +81,8 @@ export const folderFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'getAll', - 'getChildren', - ], + resource: ['folder'], + operation: ['getAll', 'getChildren'], returnAll: [false], }, }, @@ -132,12 +111,8 @@ export const folderFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'create', - ], + resource: ['folder'], + operation: ['create'], }, }, default: 'folder', @@ -151,12 +126,8 @@ export const folderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'create', - ], + resource: ['folder'], + operation: ['create'], }, }, }, @@ -168,15 +139,9 @@ export const folderFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'create', - ], - folderType: [ - 'searchFolder', - ], + resource: ['folder'], + operation: ['create'], + folderType: ['searchFolder'], }, }, }, @@ -191,15 +156,9 @@ export const folderFields: INodeProperties[] = [ default: [], displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'create', - ], - folderType: [ - 'searchFolder', - ], + resource: ['folder'], + operation: ['create'], + folderType: ['searchFolder'], }, }, }, @@ -212,15 +171,9 @@ export const folderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'create', - ], - folderType: [ - 'searchFolder', - ], + resource: ['folder'], + operation: ['create'], + folderType: ['searchFolder'], }, }, }, @@ -232,14 +185,8 @@ export const folderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'get', - 'getAll', - 'getChildren', - ], + resource: ['folder'], + operation: ['get', 'getAll', 'getChildren'], }, }, options: [ @@ -255,7 +202,8 @@ export const folderFields: INodeProperties[] = [ name: 'filter', type: 'string', default: '', - description: 'Microsoft Graph API OData $filter query. Information about the syntax can be found here.', + description: + 'Microsoft Graph API OData $filter query. Information about the syntax can be found here.', }, ], }, @@ -269,12 +217,8 @@ export const folderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'update', - ], + resource: ['folder'], + operation: ['update'], }, }, options: [ @@ -311,5 +255,4 @@ export const folderFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/FolderMessageDecription.ts b/packages/nodes-base/nodes/Microsoft/Outlook/FolderMessageDecription.ts index 394a84599f..0ab8cd9b9d 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/FolderMessageDecription.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/FolderMessageDecription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const folderMessageOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const folderMessageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'folderMessage', - ], + resource: ['folderMessage'], }, }, options: [ @@ -36,12 +32,8 @@ export const folderMessageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'folderMessage', - ], - operation: [ - 'getAll', - ], + resource: ['folderMessage'], + operation: ['getAll'], }, }, }, @@ -51,12 +43,8 @@ export const folderMessageFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'folderMessage', - ], - operation: [ - 'getAll', - ], + resource: ['folderMessage'], + operation: ['getAll'], }, }, default: false, @@ -68,15 +56,9 @@ export const folderMessageFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'folderMessage', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['folderMessage'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -94,12 +76,8 @@ export const folderMessageFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'folderMessage', - ], - operation: [ - 'getAll', - ], + resource: ['folderMessage'], + operation: ['getAll'], }, }, options: [ @@ -115,7 +93,8 @@ export const folderMessageFields: INodeProperties[] = [ name: 'filter', type: 'string', default: '', - description: 'Microsoft Graph API OData $filter query. Information about the syntax can be found here.', + description: + 'Microsoft Graph API OData $filter query. Information about the syntax can be found here.', }, ], }, diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts index 7fa84ef473..6b0056aed5 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts @@ -1,20 +1,21 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, NodeApiError } from 'n8n-workflow'; -export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, option: IDataObject = { json: true }): Promise { // tslint:disable-line:no-any +export async function microsoftApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + option: IDataObject = { json: true }, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('microsoftOutlookOAuth2Api'); let apiUrl = `https://graph.microsoft.com/v1.0/me${resource}`; @@ -50,8 +51,17 @@ export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSing } } -export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function microsoftApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -59,18 +69,33 @@ export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoa query['$top'] = 100; do { - responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri, headers); + responseData = await microsoftApiRequest.call( + this, + method, + endpoint, + body, + query, + uri, + headers, + ); uri = responseData['@odata.nextLink']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['@odata.nextLink'] !== undefined - ); + } while (responseData['@odata.nextLink'] !== undefined); return returnData; } -export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function microsoftApiRequestAllItemsSkip( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -78,12 +103,18 @@ export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions | query['$skip'] = 0; do { - responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, undefined, headers); + responseData = await microsoftApiRequest.call( + this, + method, + endpoint, + body, + query, + undefined, + headers, + ); query['$skip'] += query['$top']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['value'].length !== 0 - ); + } while (responseData['value'].length !== 0); return returnData; } @@ -112,32 +143,40 @@ export function createMessage(fields: IDataObject) { } // Handle custom headers - if ('internetMessageHeaders' in fields && 'headers' in (fields.internetMessageHeaders as IDataObject)) { + if ( + 'internetMessageHeaders' in fields && + 'headers' in (fields.internetMessageHeaders as IDataObject) + ) { fields.internetMessageHeaders = (fields.internetMessageHeaders as IDataObject).headers; } // Handle recipient fields - ['bccRecipients', 'ccRecipients', 'replyTo', 'sender', 'toRecipients'].forEach(key => { + ['bccRecipients', 'ccRecipients', 'replyTo', 'sender', 'toRecipients'].forEach((key) => { if (Array.isArray(fields[key])) { - fields[key] = (fields[key] as string[]).map(email => makeRecipient(email)); + fields[key] = (fields[key] as string[]).map((email) => makeRecipient(email)); } else if (fields[key] !== undefined) { - fields[key] = (fields[key] as string).split(',').map((recipient: string) => makeRecipient(recipient)); + fields[key] = (fields[key] as string) + .split(',') + .map((recipient: string) => makeRecipient(recipient)); } }); - ['from', 'sender'].forEach(key => { + ['from', 'sender'].forEach((key) => { if (fields[key] !== undefined) { fields[key] = makeRecipient(fields[key] as string); } }); - Object.assign(message, fields); return message; } -export async function downloadAttachments(this: IExecuteFunctions, messages: IDataObject[] | IDataObject, prefix: string) { +export async function downloadAttachments( + this: IExecuteFunctions, + messages: IDataObject[] | IDataObject, + prefix: string, +) { const elements: INodeExecutionData[] = []; if (!Array.isArray(messages)) { messages = [messages]; @@ -168,7 +207,11 @@ export async function downloadAttachments(this: IExecuteFunctions, messages: IDa ); const data = Buffer.from(response.body as string, 'utf8'); - element.binary![`${prefix}${index}`] = await this.helpers.prepareBinaryData(data as unknown as Buffer, attachment.name, attachment.contentType); + element.binary![`${prefix}${index}`] = await this.helpers.prepareBinaryData( + data as unknown as Buffer, + attachment.name, + attachment.contentType, + ); } } if (Object.keys(element.binary!).length === 0) { diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/MessageAttachmentDescription.ts b/packages/nodes-base/nodes/Microsoft/Outlook/MessageAttachmentDescription.ts index c003bc010e..1fe7c0b476 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/MessageAttachmentDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/MessageAttachmentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const messageAttachmentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const messageAttachmentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'messageAttachment', - ], + resource: ['messageAttachment'], }, }, options: [ @@ -37,7 +33,7 @@ export const messageAttachmentOperations: INodeProperties[] = [ { name: 'Get All', value: 'getAll', - description: 'Get all the message\'s attachments', + description: "Get all the message's attachments", action: 'Get all message attachments', }, ], @@ -54,15 +50,8 @@ export const messageAttachmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'messageAttachment', - ], - operation: [ - 'add', - 'download', - 'get', - 'getAll', - ], + resource: ['messageAttachment'], + operation: ['add', 'download', 'get', 'getAll'], }, }, }, @@ -74,13 +63,8 @@ export const messageAttachmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'messageAttachment', - ], - operation: [ - 'download', - 'get', - ], + resource: ['messageAttachment'], + operation: ['download', 'get'], }, }, }, @@ -92,12 +76,8 @@ export const messageAttachmentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'messageAttachment', - ], - operation: [ - 'getAll', - ], + resource: ['messageAttachment'], + operation: ['getAll'], }, }, default: false, @@ -109,15 +89,9 @@ export const messageAttachmentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'messageAttachment', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['messageAttachment'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -128,7 +102,6 @@ export const messageAttachmentFields: INodeProperties[] = [ description: 'Max number of results to return', }, - // messageAttachment:create, messageAttachment:update, messageAttachment:send // File operations @@ -141,13 +114,8 @@ export const messageAttachmentFields: INodeProperties[] = [ default: 'data', displayOptions: { show: { - resource: [ - 'messageAttachment', - ], - operation: [ - 'add', - 'download', - ], + resource: ['messageAttachment'], + operation: ['add', 'download'], }, }, }, @@ -161,19 +129,16 @@ export const messageAttachmentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'messageAttachment', - ], - operation: [ - 'add', - ], + resource: ['messageAttachment'], + operation: ['add'], }, }, options: [ { displayName: 'File Name', name: 'fileName', - description: 'Filename of the attachment. If not set will the file-name of the binary property be used, if it exists.', + description: + 'Filename of the attachment. If not set will the file-name of the binary property be used, if it exists.', type: 'string', default: '', }, @@ -189,13 +154,8 @@ export const messageAttachmentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'messageAttachment', - ], - operation: [ - 'get', - 'getAll', - ], + resource: ['messageAttachment'], + operation: ['get', 'getAll'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/MessageDescription.ts b/packages/nodes-base/nodes/Microsoft/Outlook/MessageDescription.ts index 35266e5040..ce6821382d 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/MessageDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/MessageDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const messageOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const messageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'message', - ], + resource: ['message'], }, }, options: [ @@ -31,7 +27,7 @@ export const messageOperations: INodeProperties[] = [ { name: 'Get All', value: 'getAll', - description: 'Get all messages in the signed-in user\'s mailbox', + description: "Get all messages in the signed-in user's mailbox", action: 'Get all messages', }, { @@ -78,9 +74,7 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], + resource: ['message'], operation: [ 'addAttachment', 'delete', @@ -114,12 +108,8 @@ export const messageFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'reply', - ], + resource: ['message'], + operation: ['reply'], }, }, }, @@ -129,12 +119,8 @@ export const messageFields: INodeProperties[] = [ description: 'A comment to include. Can be an empty string.', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'reply', - ], + resource: ['message'], + operation: ['reply'], }, }, type: 'string', @@ -143,15 +129,12 @@ export const messageFields: INodeProperties[] = [ { displayName: 'Send', name: 'send', - description: 'Whether to send the reply message directly. If not set, it will be saved as draft.', + description: + 'Whether to send the reply message directly. If not set, it will be saved as draft.', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'reply', - ], + resource: ['message'], + operation: ['reply'], }, }, type: 'boolean', @@ -165,15 +148,9 @@ export const messageFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'reply', - ], - replyType: [ - 'reply', - ], + resource: ['message'], + operation: ['reply'], + replyType: ['reply'], }, }, options: [ @@ -196,12 +173,12 @@ export const messageFields: INodeProperties[] = [ name: 'binaryPropertyName', type: 'string', default: '', - description: 'Name of the binary property containing the data to be added to the email as an attachment', + description: + 'Name of the binary property containing the data to be added to the email as an attachment', }, ], }, ], - }, { displayName: 'BCC Recipients', @@ -276,7 +253,8 @@ export const messageFields: INodeProperties[] = [ { displayName: 'From', name: 'from', - description: 'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.', + description: + 'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.', type: 'string', default: '', }, @@ -339,12 +317,8 @@ export const messageFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'getAll', - ], + resource: ['message'], + operation: ['getAll'], }, }, default: false, @@ -356,15 +330,9 @@ export const messageFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['message'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -382,13 +350,8 @@ export const messageFields: INodeProperties[] = [ description: 'The subject of the message', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - 'send', - ], + resource: ['message'], + operation: ['create', 'send'], }, }, type: 'string', @@ -401,13 +364,8 @@ export const messageFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - 'send', - ], + resource: ['message'], + operation: ['create', 'send'], }, }, default: '', @@ -419,12 +377,8 @@ export const messageFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'send', - ], + resource: ['message'], + operation: ['send'], }, }, required: true, @@ -438,12 +392,8 @@ export const messageFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'send', - ], + resource: ['message'], + operation: ['send'], }, }, options: [ @@ -466,12 +416,12 @@ export const messageFields: INodeProperties[] = [ name: 'binaryPropertyName', type: 'string', default: '', - description: 'Name of the binary property containing the data to be added to the email as an attachment', + description: + 'Name of the binary property containing the data to be added to the email as an attachment', }, ], }, ], - }, { displayName: 'BCC Recipients', @@ -501,7 +451,8 @@ export const messageFields: INodeProperties[] = [ displayName: 'Category Names or IDs', name: 'categories', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getCategories', }, @@ -549,7 +500,8 @@ export const messageFields: INodeProperties[] = [ { displayName: 'From', name: 'from', - description: 'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.', + description: + 'The owner of the mailbox which the message is sent. Must correspond to the actual mailbox used.', type: 'string', default: '', }, @@ -615,12 +567,8 @@ export const messageFields: INodeProperties[] = [ default: 'data', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'getMime', - ], + resource: ['message'], + operation: ['getMime'], }, }, }, @@ -635,12 +583,8 @@ export const messageFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'move', - ], + resource: ['message'], + operation: ['move'], }, }, }, diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlook.node.ts b/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlook.node.ts index 90e0062226..3db94d95f4 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlook.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlook.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryKeyData, @@ -19,37 +17,23 @@ import { downloadAttachments, makeRecipient, microsoftApiRequest, - microsoftApiRequestAllItems + microsoftApiRequestAllItems, } from './GenericFunctions'; -import { - draftFields, - draftOperations, -} from './DraftDescription'; +import { draftFields, draftOperations } from './DraftDescription'; -import { - draftMessageSharedFields, -} from './DraftMessageSharedDescription'; +import { draftMessageSharedFields } from './DraftMessageSharedDescription'; -import { - messageFields, - messageOperations, -} from './MessageDescription'; +import { messageFields, messageOperations } from './MessageDescription'; import { messageAttachmentFields, messageAttachmentOperations, } from './MessageAttachmentDescription'; -import { - folderFields, - folderOperations, -} from './FolderDescription'; +import { folderFields, folderOperations } from './FolderDescription'; -import { - folderMessageFields, - folderMessageOperations, -} from './FolderMessageDecription'; +import { folderMessageFields, folderMessageOperations } from './FolderMessageDecription'; export class MicrosoftOutlook implements INodeType { description: INodeTypeDescription = { @@ -128,7 +112,12 @@ export class MicrosoftOutlook implements INodeType { // select them easily async getCategories(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const categories = await microsoftApiRequestAllItems.call(this, 'value', 'GET', '/outlook/masterCategories'); + const categories = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + '/outlook/masterCategories', + ); for (const category of categories) { returnData.push({ name: category.displayName as string, @@ -155,11 +144,7 @@ export class MicrosoftOutlook implements INodeType { for (let i = 0; i < length; i++) { try { const messageId = this.getNodeParameter('messageId', i) as string; - responseData = await microsoftApiRequest.call( - this, - 'DELETE', - `/messages/${messageId}`, - ); + responseData = await microsoftApiRequest.call(this, 'DELETE', `/messages/${messageId}`); returnData.push({ success: true }); } catch (error) { @@ -245,7 +230,6 @@ export class MicrosoftOutlook implements INodeType { } if (resource === 'draft') { - if (operation === 'create') { for (let i = 0; i < length; i++) { try { @@ -263,18 +247,25 @@ export class MicrosoftOutlook implements INodeType { const body: IDataObject = createMessage(additionalFields); if (additionalFields.attachments) { - const attachments = (additionalFields.attachments as IDataObject).attachments as IDataObject[]; + const attachments = (additionalFields.attachments as IDataObject) + .attachments as IDataObject[]; // // Handle attachments - body['attachments'] = attachments.map(attachment => { + body['attachments'] = attachments.map((attachment) => { const binaryPropertyName = attachment.binaryPropertyName as string; if (items[i].binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } //@ts-ignore if (items[i].binary[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + { itemIndex: i }, + ); } const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName]; @@ -286,13 +277,7 @@ export class MicrosoftOutlook implements INodeType { }); } - responseData = await microsoftApiRequest.call( - this, - 'POST', - `/messages`, - body, - {}, - ); + responseData = await microsoftApiRequest.call(this, 'POST', `/messages`, body, {}); returnData.push(responseData); } catch (error) { @@ -309,17 +294,20 @@ export class MicrosoftOutlook implements INodeType { for (let i = 0; i < length; i++) { try { const messageId = this.getNodeParameter('messageId', i); - const additionalFields = this.getNodeParameter('additionalFields', i, {}) as IDataObject; + const additionalFields = this.getNodeParameter( + 'additionalFields', + i, + {}, + ) as IDataObject; if (additionalFields && additionalFields.recipients) { - const recipients = ((additionalFields.recipients as string).split(',') as string[]).filter(email => !!email); + const recipients = ( + (additionalFields.recipients as string).split(',') as string[] + ).filter((email) => !!email); if (recipients.length !== 0) { - await microsoftApiRequest.call( - this, - 'PATCH', - `/messages/${messageId}`, - { toRecipients: recipients.map((recipient: string) => makeRecipient(recipient)) }, - ); + await microsoftApiRequest.call(this, 'PATCH', `/messages/${messageId}`, { + toRecipients: recipients.map((recipient: string) => makeRecipient(recipient)), + }); } } @@ -342,7 +330,6 @@ export class MicrosoftOutlook implements INodeType { } if (resource === 'message') { - if (operation === 'reply') { for (let i = 0; i < length; i++) { try { @@ -350,7 +337,11 @@ export class MicrosoftOutlook implements INodeType { const replyType = this.getNodeParameter('replyType', i) as string; const comment = this.getNodeParameter('comment', i) as string; const send = this.getNodeParameter('send', i, false) as boolean; - const additionalFields = this.getNodeParameter('additionalFields', i, {}) as IDataObject; + const additionalFields = this.getNodeParameter( + 'additionalFields', + i, + {}, + ) as IDataObject; const body: IDataObject = {}; @@ -374,17 +365,24 @@ export class MicrosoftOutlook implements INodeType { ); if (additionalFields.attachments) { - const attachments = (additionalFields.attachments as IDataObject).attachments as IDataObject[]; + const attachments = (additionalFields.attachments as IDataObject) + .attachments as IDataObject[]; // // Handle attachments - const data = attachments.map(attachment => { + const data = attachments.map((attachment) => { const binaryPropertyName = attachment.binaryPropertyName as string; if (items[i].binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } //@ts-ignore if (items[i].binary[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + { itemIndex: i }, + ); } const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName]; @@ -407,11 +405,7 @@ export class MicrosoftOutlook implements INodeType { } if (send === true) { - await microsoftApiRequest.call( - this, - 'POST', - `/messages/${responseData.id}/send`, - ); + await microsoftApiRequest.call(this, 'POST', `/messages/${responseData.id}/send`); } returnData.push(responseData); @@ -429,7 +423,10 @@ export class MicrosoftOutlook implements INodeType { for (let i = 0; i < length; i++) { try { const messageId = this.getNodeParameter('messageId', i) as string; - const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string; + const dataPropertyNameDownload = this.getNodeParameter( + 'binaryPropertyName', + i, + ) as string; const response = await microsoftApiRequest.call( this, 'GET', @@ -460,10 +457,13 @@ export class MicrosoftOutlook implements INodeType { items[i] = newItem; - const fileName = `${messageId}.eml`; const data = Buffer.from(response.body as string, 'utf8'); - items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data as unknown as Buffer, fileName, mimeType); + items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( + data as unknown as Buffer, + fileName, + mimeType, + ); } catch (error) { if (this.continueOnFail()) { items[i].json = { error: error.message }; @@ -502,13 +502,7 @@ export class MicrosoftOutlook implements INodeType { ); } else { qs['$top'] = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequest.call( - this, - 'GET', - endpoint, - undefined, - qs, - ); + responseData = await microsoftApiRequest.call(this, 'GET', endpoint, undefined, qs); responseData = responseData.value; } @@ -576,25 +570,35 @@ export class MicrosoftOutlook implements INodeType { additionalFields.toRecipients = toRecipients; - const saveToSentItems = additionalFields.saveToSentItems === undefined ? true : additionalFields.saveToSentItems; + const saveToSentItems = + additionalFields.saveToSentItems === undefined + ? true + : additionalFields.saveToSentItems; delete additionalFields.saveToSentItems; // Create message object from optional fields const message: IDataObject = createMessage(additionalFields); if (additionalFields.attachments) { - const attachments = (additionalFields.attachments as IDataObject).attachments as IDataObject[]; + const attachments = (additionalFields.attachments as IDataObject) + .attachments as IDataObject[]; // // Handle attachments - message['attachments'] = attachments.map(attachment => { + message['attachments'] = attachments.map((attachment) => { const binaryPropertyName = attachment.binaryPropertyName as string; if (items[i].binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } //@ts-ignore if (items[i].binary[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + { itemIndex: i }, + ); } const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName]; @@ -611,13 +615,7 @@ export class MicrosoftOutlook implements INodeType { saveToSentItems, }; - responseData = await microsoftApiRequest.call( - this, - 'POST', - `/sendMail`, - body, - {}, - ); + responseData = await microsoftApiRequest.call(this, 'POST', `/sendMail`, body, {}); returnData.push({ success: true }); } catch (error) { if (this.continueOnFail()) { @@ -628,7 +626,6 @@ export class MicrosoftOutlook implements INodeType { } } } - } if (resource === 'messageAttachment') { @@ -644,16 +641,27 @@ export class MicrosoftOutlook implements INodeType { } //@ts-ignore if (items[i].binary[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + { itemIndex: i }, + ); } const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName]; const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); - const fileName = additionalFields.fileName === undefined ? binaryData.fileName : additionalFields.fileName; + const fileName = + additionalFields.fileName === undefined + ? binaryData.fileName + : additionalFields.fileName; if (!fileName) { - throw new NodeOperationError(this.getNode(), 'File name is not set. It has either to be set via "Additional Fields" or has to be set on the binary property!', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'File name is not set. It has either to be set via "Additional Fields" or has to be set on the binary property!', + { itemIndex: i }, + ); } // Check if the file is over 3MB big @@ -678,27 +686,31 @@ export class MicrosoftOutlook implements INodeType { const uploadUrl = responseData.uploadUrl; if (uploadUrl === undefined) { - throw new NodeApiError(this.getNode(), responseData, { message: 'Failed to get upload session' }); + throw new NodeApiError(this.getNode(), responseData, { + message: 'Failed to get upload session', + }); } - for (let bytesUploaded = 0; bytesUploaded < dataBuffer.length; bytesUploaded += chunkSize) { + for ( + let bytesUploaded = 0; + bytesUploaded < dataBuffer.length; + bytesUploaded += chunkSize + ) { // Upload the file chunk by chunk const nextChunk = Math.min(bytesUploaded + chunkSize, dataBuffer.length); const contentRange = `bytes ${bytesUploaded}-${nextChunk - 1}/${dataBuffer.length}`; const data = dataBuffer.subarray(bytesUploaded, nextChunk); - responseData = await this.helpers.request( - uploadUrl, - { - method: 'PUT', - headers: { - 'Content-Type': 'application/octet-stream', - 'Content-Length': data.length, - 'Content-Range': contentRange, - }, - body: data, - }); + responseData = await this.helpers.request(uploadUrl, { + method: 'PUT', + headers: { + 'Content-Type': 'application/octet-stream', + 'Content-Length': data.length, + 'Content-Range': contentRange, + }, + body: data, + }); } } else { const body: IDataObject = { @@ -731,7 +743,10 @@ export class MicrosoftOutlook implements INodeType { try { const messageId = this.getNodeParameter('messageId', i) as string; const attachmentId = this.getNodeParameter('attachmentId', i) as string; - const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string; + const dataPropertyNameDownload = this.getNodeParameter( + 'binaryPropertyName', + i, + ) as string; // Get attachment details first const attachmentDetails = await microsoftApiRequest.call( @@ -739,7 +754,7 @@ export class MicrosoftOutlook implements INodeType { 'GET', `/messages/${messageId}/attachments/${attachmentId}`, undefined, - { '$select': 'id,name,contentType' }, + { $select: 'id,name,contentType' }, ); let mimeType: string | undefined; @@ -773,7 +788,11 @@ export class MicrosoftOutlook implements INodeType { items[i] = newItem; const data = Buffer.from(response.body as string, 'utf8'); - items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data as unknown as Buffer, fileName, mimeType); + items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( + data as unknown as Buffer, + fileName, + mimeType, + ); } catch (error) { if (this.continueOnFail()) { items[i].json = { error: error.message }; @@ -844,13 +863,7 @@ export class MicrosoftOutlook implements INodeType { ); } else { qs['$top'] = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequest.call( - this, - 'GET', - endpoint, - undefined, - qs, - ); + responseData = await microsoftApiRequest.call(this, 'GET', endpoint, undefined, qs); responseData = responseData.value; } returnData.push.apply(returnData, responseData as IDataObject[]); @@ -890,12 +903,7 @@ export class MicrosoftOutlook implements INodeType { }); } - responseData = await microsoftApiRequest.call( - this, - 'POST', - endpoint, - body, - ); + responseData = await microsoftApiRequest.call(this, 'POST', endpoint, body); returnData.push(responseData); } catch (error) { if (this.continueOnFail()) { @@ -983,13 +991,7 @@ export class MicrosoftOutlook implements INodeType { ); } else { qs['$top'] = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequest.call( - this, - 'GET', - '/mailFolders', - {}, - qs, - ); + responseData = await microsoftApiRequest.call(this, 'GET', '/mailFolders', {}, qs); responseData = responseData.value; } returnData.push.apply(returnData, responseData as IDataObject[]); @@ -1101,31 +1103,27 @@ export class MicrosoftOutlook implements INodeType { endpoint, qs, ); - } - else { + } else { qs['$top'] = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequest.call( - this, - 'GET', - endpoint, - undefined, - qs, - ); + responseData = await microsoftApiRequest.call(this, 'GET', endpoint, undefined, qs); responseData = responseData.value; } returnData.push.apply(returnData, responseData as IDataObject[]); } } catch (error) { - if (this.continueOnFail()) { - returnData.push({ error: error.message }); - continue; - } - throw error; + if (this.continueOnFail()) { + returnData.push({ error: error.message }); + continue; } + throw error; + } } } - if ((resource === 'message' && operation === 'getMime') || (resource === 'messageAttachment' && operation === 'download')) { + if ( + (resource === 'message' && operation === 'getMime') || + (resource === 'messageAttachment' && operation === 'download') + ) { return this.prepareOutputData(items); } else { return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts index 23a929b3aa..045cdffc08 100644 --- a/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts @@ -9,10 +9,7 @@ import { ITables } from './TableInterface'; * @param {string[]} properties The properties it should include * @returns */ -export function copyInputItem( - item: INodeExecutionData, - properties: string[], -): IDataObject { +export function copyInputItem(item: INodeExecutionData, properties: string[]): IDataObject { // Prepare the data to insert and copy it to be returned const newItem: IDataObject = {}; for (const property of properties) { @@ -41,11 +38,9 @@ export function createTableStruct( return items.reduce((tables, item, index) => { const table = getNodeParam('table', index) as string; const columnString = getNodeParam('columns', index) as string; - const columns = columnString.split(',').map(column => column.trim()); + const columns = columnString.split(',').map((column) => column.trim()); const itemCopy = copyInputItem(item, columns.concat(additionalProperties)); - const keyParam = keyName - ? (getNodeParam(keyName, index) as string) - : undefined; + const keyParam = keyName ? (getNodeParam(keyName, index) as string) : undefined; if (tables[table] === undefined) { tables[table] = {}; } @@ -67,13 +62,11 @@ export function createTableStruct( * @param {function} buildQueryQueue function that builds the queue of promises * @returns {Promise} */ -export function executeQueryQueue( - tables: ITables, - buildQueryQueue: Function, -): Promise { // tslint:disable-line:no-any +// tslint:disable-next-line: no-any +export function executeQueryQueue(tables: ITables, buildQueryQueue: Function): Promise { return Promise.all( - Object.keys(tables).map(table => { - const columnsResults = Object.keys(tables[table]).map(columnString => { + Object.keys(tables).map((table) => { + const columnsResults = Object.keys(tables[table]).map((columnString) => { return Promise.all( buildQueryQueue({ table, @@ -95,13 +88,13 @@ export function executeQueryQueue( */ export function extractValues(item: IDataObject): string { return `(${Object.values(item as any) // tslint:disable-line:no-any - .map(val => { + .map((val) => { //the column cannot be found in the input //so, set it to null in the sql query if (val === null) { return 'NULL'; } else if (typeof val === 'string') { - return `'${val.replace(/'/g, '\'\'')}'`; + return `'${val.replace(/'/g, "''")}'`; } else if (typeof val === 'boolean') { return +!!val; } @@ -120,10 +113,8 @@ export function extractValues(item: IDataObject): string { export function extractUpdateSet(item: IDataObject, columns: string[]): string { return columns .map( - column => - `"${column}" = ${ - typeof item[column] === 'string' ? `'${item[column]}'` : item[column] - }`, + (column) => + `"${column}" = ${typeof item[column] === 'string' ? `'${item[column]}'` : item[column]}`, ) .join(','); } @@ -136,9 +127,7 @@ export function extractUpdateSet(item: IDataObject, columns: string[]): string { * @returns {string} id = '123' */ export function extractUpdateCondition(item: IDataObject, key: string): string { - return `${key} = ${ - typeof item[key] === 'string' ? `'${item[key]}'` : item[key] - }`; + return `${key} = ${typeof item[key] === 'string' ? `'${item[key]}'` : item[key]}`; } /** @@ -150,12 +139,13 @@ export function extractUpdateCondition(item: IDataObject, key: string): string { */ export function extractDeleteValues(items: IDataObject[], key: string): string { return `(${items - .map(item => (typeof item[key] === 'string' ? `'${item[key]}'` : item[key])) + .map((item) => (typeof item[key] === 'string' ? `'${item[key]}'` : item[key])) .join(',')})`; } - export function formatColumns(columns: string) { - return columns.split(',') - .map((column) => (`"${column.trim()}"`)).join(','); + return columns + .split(',') + .map((column) => `"${column.trim()}"`) + .join(','); } diff --git a/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts b/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts index 96ac1b1a20..df1326ec09 100644 --- a/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,16 +8,11 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - chunk, - flatten, -} from '../../utils/utilities'; +import { chunk, flatten } from '../../utils/utilities'; import mssql from 'mssql'; -import { - ITables, -} from './TableInterface'; +import { ITables } from './TableInterface'; import { copyInputItem, @@ -136,7 +129,8 @@ export class MicrosoftSql implements INodeType { default: '', // eslint-disable-next-line n8n-nodes-base/node-param-placeholder-miscased-id placeholder: 'id,name,description', - description: 'Comma-separated list of the properties which should used as columns for the new rows', + description: + 'Comma-separated list of the properties which should used as columns for the new rows', }, // ---------------------------------- @@ -167,7 +161,8 @@ export class MicrosoftSql implements INodeType { default: 'id', required: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id - description: 'Name of the property which decides which rows in the database should be updated. Normally that would be "id".', + description: + 'Name of the property which decides which rows in the database should be updated. Normally that would be "id".', }, { displayName: 'Columns', @@ -180,7 +175,8 @@ export class MicrosoftSql implements INodeType { }, default: '', placeholder: 'name,description', - description: 'Comma-separated list of the properties which should used as columns for rows to update', + description: + 'Comma-separated list of the properties which should used as columns for rows to update', }, // ---------------------------------- @@ -211,7 +207,8 @@ export class MicrosoftSql implements INodeType { default: 'id', required: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id - description: 'Name of the property which decides which rows in the database should be deleted. Normally that would be "id".', + description: + 'Name of the property which decides which rows in the database should be deleted. Normally that would be "id".', }, ], }; @@ -275,15 +272,11 @@ export class MicrosoftSql implements INodeType { columnString: string; items: IDataObject[]; }): Array> => { - return chunk(items, 1000).map(insertValues => { - const values = insertValues - .map((item: IDataObject) => extractValues(item)) - .join(','); + return chunk(items, 1000).map((insertValues) => { + const values = insertValues.map((item: IDataObject) => extractValues(item)).join(','); return pool .request() - .query( - `INSERT INTO ${table}(${formatColumns(columnString)}) VALUES ${values};`, - ); + .query(`INSERT INTO ${table}(${formatColumns(columnString)}) VALUES ${values};`); }); }, ); @@ -314,20 +307,13 @@ export class MicrosoftSql implements INodeType { columnString: string; items: IDataObject[]; }): Array> => { - return items.map(item => { - const columns = columnString - .split(',') - .map(column => column.trim()); + return items.map((item) => { + const columns = columnString.split(',').map((column) => column.trim()); const setValues = extractUpdateSet(item, columns); - const condition = extractUpdateCondition( - item, - item.updateKey as string, - ); + const condition = extractUpdateCondition(item, item.updateKey as string); - return pool - .request() - .query(`UPDATE ${table} SET ${setValues} WHERE ${condition};`); + return pool.request().query(`UPDATE ${table} SET ${setValues} WHERE ${condition};`); }); }, ); @@ -352,28 +338,26 @@ export class MicrosoftSql implements INodeType { }, {} as ITables); const queriesResults = await Promise.all( - Object.keys(tables).map(table => { - const deleteKeyResults = Object.keys(tables[table]).map( - deleteKey => { - const deleteItemsList = chunk( - tables[table][deleteKey].map(item => - copyInputItem(item as INodeExecutionData, [deleteKey]), - ), - 1000, - ); - const queryQueue = deleteItemsList.map(deleteValues => { - return pool - .request() - .query( - `DELETE FROM ${table} WHERE "${deleteKey}" IN ${extractDeleteValues( - deleteValues, - deleteKey, - )};`, - ); - }); - return Promise.all(queryQueue); - }, - ); + Object.keys(tables).map((table) => { + const deleteKeyResults = Object.keys(tables[table]).map((deleteKey) => { + const deleteItemsList = chunk( + tables[table][deleteKey].map((item) => + copyInputItem(item as INodeExecutionData, [deleteKey]), + ), + 1000, + ); + const queryQueue = deleteItemsList.map((deleteValues) => { + return pool + .request() + .query( + `DELETE FROM ${table} WHERE "${deleteKey}" IN ${extractDeleteValues( + deleteValues, + deleteKey, + )};`, + ); + }); + return Promise.all(queryQueue); + }); return Promise.all(deleteKeyResults); }), ); @@ -389,7 +373,10 @@ export class MicrosoftSql implements INodeType { } as IDataObject); } else { await pool.close(); - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not supported!`, + ); } } catch (error) { if (this.continueOnFail() === true) { diff --git a/packages/nodes-base/nodes/Microsoft/Teams/ChannelDescription.ts b/packages/nodes-base/nodes/Microsoft/Teams/ChannelDescription.ts index d79eb38c62..e8ddd7876c 100644 --- a/packages/nodes-base/nodes/Microsoft/Teams/ChannelDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/Teams/ChannelDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const channelOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const channelOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'channel', - ], + resource: ['channel'], }, }, options: [ @@ -52,7 +48,6 @@ export const channelOperations: INodeProperties[] = [ ]; export const channelFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* channel:create */ /* -------------------------------------------------------------------------- */ @@ -61,18 +56,15 @@ export const channelFields: INodeProperties[] = [ name: 'teamId', required: true, type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTeams', }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'channel', - ], + operation: ['create'], + resource: ['channel'], }, }, default: '', @@ -84,12 +76,8 @@ export const channelFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'channel', - ], + operation: ['create'], + resource: ['channel'], }, }, default: '', @@ -101,12 +89,8 @@ export const channelFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'channel', - ], + operation: ['create'], + resource: ['channel'], }, }, default: {}, @@ -120,7 +104,7 @@ export const channelFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'Channel\'s description', + description: "Channel's description", }, { displayName: 'Type', @@ -150,18 +134,15 @@ export const channelFields: INodeProperties[] = [ name: 'teamId', required: true, type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTeams', }, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'channel', - ], + operation: ['delete'], + resource: ['channel'], }, }, default: '', @@ -170,21 +151,16 @@ export const channelFields: INodeProperties[] = [ displayName: 'Channel Name or ID', name: 'channelId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getChannels', - loadOptionsDependsOn: [ - 'teamId', - ], + loadOptionsDependsOn: ['teamId'], }, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'channel', - ], + operation: ['delete'], + resource: ['channel'], }, }, default: '', @@ -198,18 +174,15 @@ export const channelFields: INodeProperties[] = [ name: 'teamId', required: true, type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTeams', }, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'channel', - ], + operation: ['get'], + resource: ['channel'], }, }, default: '', @@ -218,21 +191,16 @@ export const channelFields: INodeProperties[] = [ displayName: 'Channel Name or ID', name: 'channelId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getChannels', - loadOptionsDependsOn: [ - 'teamId', - ], + loadOptionsDependsOn: ['teamId'], }, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'channel', - ], + operation: ['get'], + resource: ['channel'], }, }, default: '', @@ -246,18 +214,15 @@ export const channelFields: INodeProperties[] = [ name: 'teamId', required: true, type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTeams', }, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'channel', - ], + operation: ['getAll'], + resource: ['channel'], }, }, default: '', @@ -268,12 +233,8 @@ export const channelFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'channel', - ], + operation: ['getAll'], + resource: ['channel'], }, }, default: false, @@ -285,15 +246,9 @@ export const channelFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'channel', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['channel'], + returnAll: [false], }, }, typeOptions: { @@ -312,18 +267,15 @@ export const channelFields: INodeProperties[] = [ name: 'teamId', required: true, type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTeams', }, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'channel', - ], + operation: ['update'], + resource: ['channel'], }, }, default: '', @@ -332,21 +284,16 @@ export const channelFields: INodeProperties[] = [ displayName: 'Channel Name or ID', name: 'channelId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getChannels', - loadOptionsDependsOn: [ - 'teamId', - ], + loadOptionsDependsOn: ['teamId'], }, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'channel', - ], + operation: ['update'], + resource: ['channel'], }, }, default: '', @@ -357,12 +304,8 @@ export const channelFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'channel', - ], + operation: ['update'], + resource: ['channel'], }, }, default: {}, @@ -383,7 +326,7 @@ export const channelFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'Channel\'s description', + description: "Channel's description", }, ], }, diff --git a/packages/nodes-base/nodes/Microsoft/Teams/ChannelMessageDescription.ts b/packages/nodes-base/nodes/Microsoft/Teams/ChannelMessageDescription.ts index 9ab36f4d59..48603b3667 100644 --- a/packages/nodes-base/nodes/Microsoft/Teams/ChannelMessageDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/Teams/ChannelMessageDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const channelMessageOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const channelMessageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'channelMessage', - ], + resource: ['channelMessage'], }, }, options: [ @@ -34,7 +30,6 @@ export const channelMessageOperations: INodeProperties[] = [ ]; export const channelMessageFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* channelMessage:create */ /* -------------------------------------------------------------------------- */ @@ -43,18 +38,15 @@ export const channelMessageFields: INodeProperties[] = [ name: 'teamId', required: true, type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTeams', }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'channelMessage', - ], + operation: ['create'], + resource: ['channelMessage'], }, }, default: '', @@ -63,21 +55,16 @@ export const channelMessageFields: INodeProperties[] = [ displayName: 'Channel Name or ID', name: 'channelId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getChannels', - loadOptionsDependsOn: [ - 'teamId', - ], + loadOptionsDependsOn: ['teamId'], }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'channelMessage', - ], + operation: ['create'], + resource: ['channelMessage'], }, }, default: '', @@ -99,12 +86,8 @@ export const channelMessageFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'channelMessage', - ], + operation: ['create'], + resource: ['channelMessage'], }, }, default: 'text', @@ -120,12 +103,8 @@ export const channelMessageFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'channelMessage', - ], + operation: ['create'], + resource: ['channelMessage'], }, }, default: '', @@ -139,12 +118,8 @@ export const channelMessageFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'channelMessage', - ], - operation: [ - 'create', - ], + resource: ['channelMessage'], + operation: ['create'], }, }, options: [ @@ -165,18 +140,15 @@ export const channelMessageFields: INodeProperties[] = [ name: 'teamId', required: true, type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTeams', }, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'channelMessage', - ], + operation: ['getAll'], + resource: ['channelMessage'], }, }, default: '', @@ -185,21 +157,16 @@ export const channelMessageFields: INodeProperties[] = [ displayName: 'Channel Name or ID', name: 'channelId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getChannels', - loadOptionsDependsOn: [ - 'teamId', - ], + loadOptionsDependsOn: ['teamId'], }, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'channelMessage', - ], + operation: ['getAll'], + resource: ['channelMessage'], }, }, default: '', @@ -210,12 +177,8 @@ export const channelMessageFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'channelMessage', - ], + operation: ['getAll'], + resource: ['channelMessage'], }, }, default: false, @@ -227,15 +190,9 @@ export const channelMessageFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'channelMessage', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['channelMessage'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Microsoft/Teams/ChatMessageDescription.ts b/packages/nodes-base/nodes/Microsoft/Teams/ChatMessageDescription.ts index acf06d9302..f8fac69c6b 100644 --- a/packages/nodes-base/nodes/Microsoft/Teams/ChatMessageDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/Teams/ChatMessageDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const chatMessageOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const chatMessageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'chatMessage', - ], + resource: ['chatMessage'], }, }, options: [ @@ -40,7 +36,6 @@ export const chatMessageOperations: INodeProperties[] = [ ]; export const chatMessageFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* chatMessage:create */ /* -------------------------------------------------------------------------- */ @@ -49,19 +44,15 @@ export const chatMessageFields: INodeProperties[] = [ name: 'chatId', required: true, type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getChats', }, displayOptions: { show: { - operation: [ - 'create', - 'get', - ], - resource: [ - 'chatMessage', - ], + operation: ['create', 'get'], + resource: ['chatMessage'], }, }, default: '', @@ -83,12 +74,8 @@ export const chatMessageFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'chatMessage', - ], + operation: ['create'], + resource: ['chatMessage'], }, }, default: 'text', @@ -104,12 +91,8 @@ export const chatMessageFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'chatMessage', - ], + operation: ['create'], + resource: ['chatMessage'], }, }, default: '', @@ -126,12 +109,8 @@ export const chatMessageFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'chatMessage', - ], + operation: ['get'], + resource: ['chatMessage'], }, }, default: '', @@ -144,18 +123,15 @@ export const chatMessageFields: INodeProperties[] = [ name: 'chatId', required: true, type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getChats', }, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'chatMessage', - ], + operation: ['getAll'], + resource: ['chatMessage'], }, }, default: '', @@ -166,12 +142,8 @@ export const chatMessageFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'chatMessage', - ], + operation: ['getAll'], + resource: ['chatMessage'], }, }, default: false, @@ -183,15 +155,9 @@ export const chatMessageFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'chatMessage', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['chatMessage'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts index 1baab4f292..b7040fd4b8 100644 --- a/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts @@ -1,18 +1,20 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function microsoftApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -34,8 +36,16 @@ export async function microsoftApiRequest(this: IExecuteFunctions | IExecuteSing } } -export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function microsoftApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -48,15 +58,21 @@ export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoa if (query.limit && query.limit <= returnData.length) { return returnData; } - } while ( - responseData['@odata.nextLink'] !== undefined - ); + } while (responseData['@odata.nextLink'] !== undefined); return returnData; } -export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function microsoftApiRequestAllItemsSkip( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -67,9 +83,7 @@ export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions | responseData = await microsoftApiRequest.call(this, method, endpoint, body, query); query['$skip'] += query['$top']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['value'].length !== 0 - ); + } while (responseData['value'].length !== 0); return returnData; } diff --git a/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeams.node.ts b/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeams.node.ts index 73a41ca292..447253832a 100644 --- a/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeams.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeams.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,30 +10,15 @@ import { JsonObject, } from 'n8n-workflow'; -import { - microsoftApiRequest, - microsoftApiRequestAllItems, -} from './GenericFunctions'; +import { microsoftApiRequest, microsoftApiRequestAllItems } from './GenericFunctions'; -import { - channelFields, - channelOperations, -} from './ChannelDescription'; +import { channelFields, channelOperations } from './ChannelDescription'; -import { - channelMessageFields, - channelMessageOperations, -} from './ChannelMessageDescription'; +import { channelMessageFields, channelMessageOperations } from './ChannelMessageDescription'; -import { - chatMessageFields, - chatMessageOperations, -} from './ChatMessageDescription'; +import { chatMessageFields, chatMessageOperations } from './ChatMessageDescription'; -import { - taskFields, - taskOperations, -} from './TaskDescription'; +import { taskFields, taskOperations } from './TaskDescription'; export class MicrosoftTeams implements INodeType { description: INodeTypeDescription = { @@ -104,7 +87,11 @@ export class MicrosoftTeams implements INodeType { async getChannels(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const teamId = this.getCurrentNodeParameter('teamId') as string; - const { value } = await microsoftApiRequest.call(this, 'GET', `/v1.0/teams/${teamId}/channels`); + const { value } = await microsoftApiRequest.call( + this, + 'GET', + `/v1.0/teams/${teamId}/channels`, + ); for (const channel of value) { const channelName = channel.displayName; const channelId = channel.id; @@ -159,7 +146,11 @@ export class MicrosoftTeams implements INodeType { // groupId not found at base, check updateFields for the groupId groupId = this.getCurrentNodeParameter('updateFields.groupId') as string; } - const { value } = await microsoftApiRequest.call(this, 'GET', `/v1.0/groups/${groupId}/planner/plans`); + const { value } = await microsoftApiRequest.call( + this, + 'GET', + `/v1.0/groups/${groupId}/planner/plans`, + ); for (const plan of value) { returnData.push({ name: plan.title, @@ -178,7 +169,11 @@ export class MicrosoftTeams implements INodeType { // planId not found at base, check updateFields for the planId planId = this.getCurrentNodeParameter('updateFields.planId') as string; } - const { value } = await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/plans/${planId}/buckets`); + const { value } = await microsoftApiRequest.call( + this, + 'GET', + `/v1.0/planner/plans/${planId}/buckets`, + ); for (const bucket of value) { returnData.push({ name: bucket.name, @@ -197,7 +192,11 @@ export class MicrosoftTeams implements INodeType { // groupId not found at base, check updateFields for the groupId groupId = this.getCurrentNodeParameter('updateFields.groupId') as string; } - const { value } = await microsoftApiRequest.call(this, 'GET', `/v1.0/groups/${groupId}/members`); + const { value } = await microsoftApiRequest.call( + this, + 'GET', + `/v1.0/groups/${groupId}/members`, + ); for (const member of value) { returnData.push({ name: member.displayName, @@ -217,7 +216,11 @@ export class MicrosoftTeams implements INodeType { // planId not found at base, check updateFields for the planId planId = this.getCurrentNodeParameter('updateFields.planId') as string; } - const { categoryDescriptions } = await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/plans/${planId}/details`); + const { categoryDescriptions } = await microsoftApiRequest.call( + this, + 'GET', + `/v1.0/planner/plans/${planId}/details`, + ); for (const key of Object.keys(categoryDescriptions)) { if (categoryDescriptions[key] !== null) { returnData.push({ @@ -239,8 +242,9 @@ export class MicrosoftTeams implements INodeType { for (const chat of value) { if (!chat.topic) { chat.topic = chat.members - .filter((member: IDataObject) => member.displayName) - .map((member: IDataObject) => member.displayName).join(', '); + .filter((member: IDataObject) => member.displayName) + .map((member: IDataObject) => member.displayName) + .join(', '); } const chatName = `${chat.topic || '(no title) - ' + chat.id} (${chat.chatType})`; const chatId = chat.id; @@ -279,30 +283,54 @@ export class MicrosoftTeams implements INodeType { if (options.type) { body.membershipType = options.type as string; } - responseData = await microsoftApiRequest.call(this, 'POST', `/v1.0/teams/${teamId}/channels`, body); + responseData = await microsoftApiRequest.call( + this, + 'POST', + `/v1.0/teams/${teamId}/channels`, + body, + ); } //https://docs.microsoft.com/en-us/graph/api/channel-delete?view=graph-rest-beta&tabs=http if (operation === 'delete') { const teamId = this.getNodeParameter('teamId', i) as string; const channelId = this.getNodeParameter('channelId', i) as string; - responseData = await microsoftApiRequest.call(this, 'DELETE', `/v1.0/teams/${teamId}/channels/${channelId}`); + responseData = await microsoftApiRequest.call( + this, + 'DELETE', + `/v1.0/teams/${teamId}/channels/${channelId}`, + ); responseData = { success: true }; } //https://docs.microsoft.com/en-us/graph/api/channel-get?view=graph-rest-beta&tabs=http if (operation === 'get') { const teamId = this.getNodeParameter('teamId', i) as string; const channelId = this.getNodeParameter('channelId', i) as string; - responseData = await microsoftApiRequest.call(this, 'GET', `/v1.0/teams/${teamId}/channels/${channelId}`); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/v1.0/teams/${teamId}/channels/${channelId}`, + ); } //https://docs.microsoft.com/en-us/graph/api/channel-list?view=graph-rest-beta&tabs=http if (operation === 'getAll') { const teamId = this.getNodeParameter('teamId', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll) { - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/teams/${teamId}/channels`); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/v1.0/teams/${teamId}/channels`, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/teams/${teamId}/channels`, {}); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/v1.0/teams/${teamId}/channels`, + {}, + ); responseData = responseData.splice(0, qs.limit); } } @@ -318,7 +346,12 @@ export class MicrosoftTeams implements INodeType { if (updateFields.description) { body.description = updateFields.description as string; } - responseData = await microsoftApiRequest.call(this, 'PATCH', `/v1.0/teams/${teamId}/channels/${channelId}`, body); + responseData = await microsoftApiRequest.call( + this, + 'PATCH', + `/v1.0/teams/${teamId}/channels/${channelId}`, + body, + ); responseData = { success: true }; } } @@ -341,9 +374,19 @@ export class MicrosoftTeams implements INodeType { if (options.makeReply) { const replyToId = options.makeReply as string; - responseData = await microsoftApiRequest.call(this, 'POST', `/beta/teams/${teamId}/channels/${channelId}/messages/${replyToId}/replies`, body); + responseData = await microsoftApiRequest.call( + this, + 'POST', + `/beta/teams/${teamId}/channels/${channelId}/messages/${replyToId}/replies`, + body, + ); } else { - responseData = await microsoftApiRequest.call(this, 'POST', `/beta/teams/${teamId}/channels/${channelId}/messages`, body); + responseData = await microsoftApiRequest.call( + this, + 'POST', + `/beta/teams/${teamId}/channels/${channelId}/messages`, + body, + ); } } //https://docs.microsoft.com/en-us/graph/api/channel-list-messages?view=graph-rest-beta&tabs=http @@ -352,10 +395,21 @@ export class MicrosoftTeams implements INodeType { const channelId = this.getNodeParameter('channelId', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll) { - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/beta/teams/${teamId}/channels/${channelId}/messages`); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/beta/teams/${teamId}/channels/${channelId}/messages`, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/beta/teams/${teamId}/channels/${channelId}/messages`, {}); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/beta/teams/${teamId}/channels/${channelId}/messages`, + {}, + ); responseData = responseData.splice(0, qs.limit); } } @@ -372,23 +426,43 @@ export class MicrosoftTeams implements INodeType { content: message, }, }; - responseData = await microsoftApiRequest.call(this, 'POST', `/v1.0/chats/${chatId}/messages`, body); + responseData = await microsoftApiRequest.call( + this, + 'POST', + `/v1.0/chats/${chatId}/messages`, + body, + ); } // https://docs.microsoft.com/en-us/graph/api/chat-list-messages?view=graph-rest-1.0&tabs=http if (operation === 'get') { const chatId = this.getNodeParameter('chatId', i) as string; const messageId = this.getNodeParameter('messageId', i) as string; - responseData = await microsoftApiRequest.call(this, 'GET', `/v1.0/chats/${chatId}/messages/${messageId}`); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/v1.0/chats/${chatId}/messages/${messageId}`, + ); } // https://docs.microsoft.com/en-us/graph/api/chat-list-messages?view=graph-rest-1.0&tabs=http if (operation === 'getAll') { const chatId = this.getNodeParameter('chatId', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll) { - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/chats/${chatId}/messages`); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/v1.0/chats/${chatId}/messages`, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/chats/${chatId}/messages`, {}); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/v1.0/chats/${chatId}/messages`, + {}, + ); responseData = responseData.splice(0, qs.limit); } } @@ -411,29 +485,52 @@ export class MicrosoftTeams implements INodeType { body.assignments = { [body.assignedTo as string]: { '@odata.type': 'microsoft.graph.plannerAssignment', - 'orderHint': ' !', + orderHint: ' !', }, }; delete body.assignedTo; } if (Array.isArray(body.labels)) { - body.appliedCategories = (body.labels as string[]).map((label) => ({ [label]: true })); + body.appliedCategories = (body.labels as string[]).map((label) => ({ + [label]: true, + })); } - responseData = await microsoftApiRequest.call(this, 'POST', `/v1.0/planner/tasks`, body); + responseData = await microsoftApiRequest.call( + this, + 'POST', + `/v1.0/planner/tasks`, + body, + ); } //https://docs.microsoft.com/en-us/graph/api/plannertask-delete?view=graph-rest-1.0&tabs=http if (operation === 'delete') { const taskId = this.getNodeParameter('taskId', i) as string; - const task = await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/tasks/${taskId}`); - responseData = await microsoftApiRequest.call(this, 'DELETE', `/v1.0/planner/tasks/${taskId}`, {}, {}, undefined, { 'If-Match': task['@odata.etag'] }); + const task = await microsoftApiRequest.call( + this, + 'GET', + `/v1.0/planner/tasks/${taskId}`, + ); + responseData = await microsoftApiRequest.call( + this, + 'DELETE', + `/v1.0/planner/tasks/${taskId}`, + {}, + {}, + undefined, + { 'If-Match': task['@odata.etag'] }, + ); responseData = { success: true }; } //https://docs.microsoft.com/en-us/graph/api/plannertask-get?view=graph-rest-1.0&tabs=http if (operation === 'get') { const taskId = this.getNodeParameter('taskId', i) as string; - responseData = await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/tasks/${taskId}`); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/v1.0/planner/tasks/${taskId}`, + ); } if (operation === 'getAll') { const tasksFor = this.getNodeParameter('tasksFor', i) as string; @@ -442,20 +539,42 @@ export class MicrosoftTeams implements INodeType { //https://docs.microsoft.com/en-us/graph/api/planneruser-list-tasks?view=graph-rest-1.0&tabs=http const memberId = this.getNodeParameter('memberId', i) as string; if (returnAll) { - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/users/${memberId}/planner/tasks`); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/v1.0/users/${memberId}/planner/tasks`, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/users/${memberId}/planner/tasks`, {}); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/v1.0/users/${memberId}/planner/tasks`, + {}, + ); responseData = responseData.splice(0, qs.limit); } } else { //https://docs.microsoft.com/en-us/graph/api/plannerplan-list-tasks?view=graph-rest-1.0&tabs=http const planId = this.getNodeParameter('planId', i) as string; if (returnAll) { - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/planner/plans/${planId}/tasks`); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/v1.0/planner/plans/${planId}/tasks`, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/v1.0/planner/plans/${planId}/tasks`, {}); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/v1.0/planner/plans/${planId}/tasks`, + {}, + ); responseData = responseData.splice(0, qs.limit); } } @@ -471,7 +590,7 @@ export class MicrosoftTeams implements INodeType { body.assignments = { [body.assignedTo as string]: { '@odata.type': 'microsoft.graph.plannerAssignment', - 'orderHint': ' !', + orderHint: ' !', }, }; delete body.assignedTo; @@ -483,12 +602,26 @@ export class MicrosoftTeams implements INodeType { } if (Array.isArray(body.labels)) { - body.appliedCategories = (body.labels as string[]).map((label) => ({ [label]: true })); + body.appliedCategories = (body.labels as string[]).map((label) => ({ + [label]: true, + })); } - const task = await microsoftApiRequest.call(this, 'GET', `/v1.0/planner/tasks/${taskId}`); + const task = await microsoftApiRequest.call( + this, + 'GET', + `/v1.0/planner/tasks/${taskId}`, + ); - responseData = await microsoftApiRequest.call(this, 'PATCH', `/v1.0/planner/tasks/${taskId}`, body, {}, undefined, { 'If-Match': task['@odata.etag'] }); + responseData = await microsoftApiRequest.call( + this, + 'PATCH', + `/v1.0/planner/tasks/${taskId}`, + body, + {}, + undefined, + { 'If-Match': task['@odata.etag'] }, + ); responseData = { success: true }; } diff --git a/packages/nodes-base/nodes/Microsoft/Teams/TaskDescription.ts b/packages/nodes-base/nodes/Microsoft/Teams/TaskDescription.ts index 23400b585f..8d2f8cb50b 100644 --- a/packages/nodes-base/nodes/Microsoft/Teams/TaskDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/Teams/TaskDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const taskOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const taskOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'task', - ], + resource: ['task'], }, }, options: [ @@ -60,14 +56,8 @@ export const taskFields: INodeProperties[] = [ default: 'all', displayOptions: { show: { - operation: [ - 'getAll', - 'create', - 'update', - ], - resource: [ - 'task', - ], + operation: ['getAll', 'create', 'update'], + resource: ['task'], }, }, options: [ @@ -84,7 +74,6 @@ export const taskFields: INodeProperties[] = [ ], }, - /* -------------------------------------------------------------------------- */ /* task:create */ /* -------------------------------------------------------------------------- */ @@ -94,21 +83,16 @@ export const taskFields: INodeProperties[] = [ name: 'groupId', required: true, type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getGroups', - loadOptionsDependsOn: [ - 'groupSource', - ], + loadOptionsDependsOn: ['groupSource'], }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'task', - ], + operation: ['create'], + resource: ['task'], }, }, default: '', @@ -120,22 +104,17 @@ export const taskFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getPlans', - loadOptionsDependsOn: [ - 'groupId', - ], + loadOptionsDependsOn: ['groupId'], }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'task', - ], + operation: ['create'], + resource: ['task'], }, }, default: '', - description: 'The plan for the task to belong to. Choose from the list, or specify an ID using an expression.', + description: + 'The plan for the task to belong to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Bucket Name or ID', @@ -144,22 +123,17 @@ export const taskFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getBuckets', - loadOptionsDependsOn: [ - 'planId', - ], + loadOptionsDependsOn: ['planId'], }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'task', - ], + operation: ['create'], + resource: ['task'], }, }, default: '', - description: 'The bucket for the task to belong to. Choose from the list, or specify an ID using an expression.', + description: + 'The bucket for the task to belong to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Title', @@ -168,12 +142,8 @@ export const taskFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'task', - ], + operation: ['create'], + resource: ['task'], }, }, default: '', @@ -185,12 +155,8 @@ export const taskFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'task', - ], + operation: ['create'], + resource: ['task'], }, }, default: {}, @@ -202,19 +168,19 @@ export const taskFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getMembers', - loadOptionsDependsOn: [ - 'groupId', - ], + loadOptionsDependsOn: ['groupId'], }, default: '', - description: 'Who the task should be assigned to. Choose from the list, or specify an ID using an expression.', + description: + 'Who the task should be assigned to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Due Date Time', name: 'dueDateTime', type: 'dateTime', default: '', - description: 'Date and time at which the task is due. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.', + description: + 'Date and time at which the task is due. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.', }, { displayName: 'Label Names or IDs', @@ -222,12 +188,11 @@ export const taskFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getLabels', - loadOptionsDependsOn: [ - 'planId', - ], + loadOptionsDependsOn: ['planId'], }, default: [], - description: 'Labels to assign to the task. Choose from the list, or specify IDs using an expression.', + description: + 'Labels to assign to the task. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Percent Complete', @@ -238,7 +203,8 @@ export const taskFields: INodeProperties[] = [ maxValue: 100, }, default: 0, - description: 'Percentage of task completion. When set to 100, the task is considered completed.', + description: + 'Percentage of task completion. When set to 100, the task is considered completed.', }, ], }, @@ -253,12 +219,8 @@ export const taskFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'task', - ], + operation: ['delete'], + resource: ['task'], }, }, default: '', @@ -274,12 +236,8 @@ export const taskFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'task', - ], + operation: ['get'], + resource: ['task'], }, }, default: '', @@ -297,12 +255,8 @@ export const taskFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], + operation: ['getAll'], + resource: ['task'], }, }, options: [ @@ -323,21 +277,16 @@ export const taskFields: INodeProperties[] = [ name: 'groupId', required: true, type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getGroups', - loadOptionsDependsOn: [ - 'groupSource', - ], + loadOptionsDependsOn: ['groupSource'], }, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], + operation: ['getAll'], + resource: ['task'], }, }, default: '', @@ -346,24 +295,17 @@ export const taskFields: INodeProperties[] = [ displayName: 'Member Name or ID', name: 'memberId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getMembers', - loadOptionsDependsOn: [ - 'groupId', - ], + loadOptionsDependsOn: ['groupId'], }, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], - tasksFor: [ - 'member', - ], + operation: ['getAll'], + resource: ['task'], + tasksFor: ['member'], }, }, default: '', @@ -372,24 +314,17 @@ export const taskFields: INodeProperties[] = [ displayName: 'Plan Name or ID', name: 'planId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getPlans', - loadOptionsDependsOn: [ - 'groupId', - ], + loadOptionsDependsOn: ['groupId'], }, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], - tasksFor: [ - 'plan', - ], + operation: ['getAll'], + resource: ['task'], + tasksFor: ['plan'], }, }, default: '', @@ -400,12 +335,8 @@ export const taskFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], + operation: ['getAll'], + resource: ['task'], }, }, default: false, @@ -417,15 +348,9 @@ export const taskFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['task'], + returnAll: [false], }, }, typeOptions: { @@ -446,12 +371,8 @@ export const taskFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'task', - ], + operation: ['update'], + resource: ['task'], }, }, default: '', @@ -463,12 +384,8 @@ export const taskFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'task', - ], + operation: ['update'], + resource: ['task'], }, }, default: {}, @@ -480,12 +397,11 @@ export const taskFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getMembers', - loadOptionsDependsOn: [ - 'groupId', - ], + loadOptionsDependsOn: ['groupId'], }, default: '', - description: 'Who the task should be assigned to. Choose from the list, or specify an ID using an expression.', + description: + 'Who the task should be assigned to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Bucket Name or ID', @@ -493,30 +409,29 @@ export const taskFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getBuckets', - loadOptionsDependsOn: [ - 'updateFields.planId', - ], + loadOptionsDependsOn: ['updateFields.planId'], }, default: '', - description: 'The bucket for the task to belong to. Choose from the list, or specify an ID using an expression.', + description: + 'The bucket for the task to belong to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Due Date Time', name: 'dueDateTime', type: 'dateTime', default: '', - description: 'Date and time at which the task is due. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.', + description: + 'Date and time at which the task is due. The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.', }, { displayName: 'Group Name or ID', name: 'groupId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getGroups', - loadOptionsDependsOn: [ - 'groupSource', - ], + loadOptionsDependsOn: ['groupSource'], }, default: '', }, @@ -526,12 +441,11 @@ export const taskFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getLabels', - loadOptionsDependsOn: [ - 'updateFields.planId', - ], + loadOptionsDependsOn: ['updateFields.planId'], }, default: [], - description: 'Labels to assign to the task. Choose from the list, or specify IDs using an expression.', + description: + 'Labels to assign to the task. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Percent Complete', @@ -542,7 +456,8 @@ export const taskFields: INodeProperties[] = [ maxValue: 100, }, default: 0, - description: 'Percentage of task completion. When set to 100, the task is considered completed.', + description: + 'Percentage of task completion. When set to 100, the task is considered completed.', }, { displayName: 'Plan Name or ID', @@ -550,12 +465,11 @@ export const taskFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getPlans', - loadOptionsDependsOn: [ - 'groupId', - ], + loadOptionsDependsOn: ['groupId'], }, default: '', - description: 'The plan for the task to belong to. Choose from the list, or specify an ID using an expression.', + description: + 'The plan for the task to belong to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Title', diff --git a/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts index d98e01f497..6c76383aa6 100644 --- a/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts @@ -1,18 +1,19 @@ -import { - OptionsWithUri -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - ILoadOptionsFunctions, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, ILoadOptionsFunctions, NodeApiError } from 'n8n-workflow'; -export async function microsoftApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: IDataObject = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, option: IDataObject = { json: true }) { +export async function microsoftApiRequest( + this: IExecuteFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + body: IDataObject = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + option: IDataObject = { json: true }, +) { const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -37,8 +38,14 @@ export async function microsoftApiRequest(this: IExecuteFunctions | ILoadOptions } } -export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: IDataObject = {}, query: IDataObject = {}) { - +export async function microsoftApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + body: IDataObject = {}, + query: IDataObject = {}, +) { const returnData: IDataObject[] = []; let responseData; @@ -49,15 +56,19 @@ export async function microsoftApiRequestAllItems(this: IExecuteFunctions | ILoa responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri); uri = responseData['@odata.nextLink']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['@odata.nextLink'] !== undefined - ); + } while (responseData['@odata.nextLink'] !== undefined); return returnData; } -export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions, propertyName: string, method: string, endpoint: string, body: IDataObject = {}, query: IDataObject = {}) { - +export async function microsoftApiRequestAllItemsSkip( + this: IExecuteFunctions, + propertyName: string, + method: string, + endpoint: string, + body: IDataObject = {}, + query: IDataObject = {}, +) { const returnData: IDataObject[] = []; let responseData; @@ -68,9 +79,7 @@ export async function microsoftApiRequestAllItemsSkip(this: IExecuteFunctions, p responseData = await microsoftApiRequest.call(this, method, endpoint, body, query); query['$skip'] += query['$top']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['value'].length !== 0 - ); + } while (responseData['value'].length !== 0); return returnData; } diff --git a/packages/nodes-base/nodes/Microsoft/ToDo/LinkedResourceDescription.ts b/packages/nodes-base/nodes/Microsoft/ToDo/LinkedResourceDescription.ts index e1371aedee..3707d3e6e3 100644 --- a/packages/nodes-base/nodes/Microsoft/ToDo/LinkedResourceDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/ToDo/LinkedResourceDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const linkedResourceOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const linkedResourceOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'linkedResource', - ], + resource: ['linkedResource'], }, }, options: [ @@ -54,22 +50,15 @@ export const linkedResourceFields: INodeProperties[] = [ displayName: 'Task List Name or ID', name: 'taskListId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTaskLists', }, displayOptions: { show: { - operation: [ - 'create', - 'delete', - 'get', - 'getAll', - 'update', - ], - resource: [ - 'linkedResource', - ], + operation: ['create', 'delete', 'get', 'getAll', 'update'], + resource: ['linkedResource'], }, }, required: true, @@ -81,16 +70,8 @@ export const linkedResourceFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - 'delete', - 'get', - 'getAll', - 'update', - ], - resource: [ - 'linkedResource', - ], + operation: ['create', 'delete', 'get', 'getAll', 'update'], + resource: ['linkedResource'], }, }, required: true, @@ -107,12 +88,8 @@ export const linkedResourceFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'linkedResource', - ], + operation: ['create'], + resource: ['linkedResource'], }, }, description: 'Field indicating title of the linked entity', @@ -123,12 +100,8 @@ export const linkedResourceFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'linkedResource', - ], + operation: ['create'], + resource: ['linkedResource'], }, }, required: true, @@ -143,12 +116,8 @@ export const linkedResourceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'linkedResource', - ], - operation: [ - 'create', - ], + resource: ['linkedResource'], + operation: ['create'], }, }, options: [ @@ -157,7 +126,8 @@ export const linkedResourceFields: INodeProperties[] = [ name: 'externalId', type: 'string', default: '', - description: 'ID of the object that is associated with this task on the third-party/partner system', + description: + 'ID of the object that is associated with this task on the third-party/partner system', }, { displayName: 'Web URL', @@ -178,14 +148,8 @@ export const linkedResourceFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'linkedResource', - ], - operation: [ - 'delete', - 'get', - 'update', - ], + resource: ['linkedResource'], + operation: ['delete', 'get', 'update'], }, }, default: '', @@ -201,12 +165,8 @@ export const linkedResourceFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'linkedResource', - ], - operation: [ - 'getAll', - ], + resource: ['linkedResource'], + operation: ['getAll'], }, }, default: false, @@ -218,12 +178,8 @@ export const linkedResourceFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'linkedResource', - ], - operation: [ - 'getAll', - ], + resource: ['linkedResource'], + operation: ['getAll'], returnAll: [false], }, }, @@ -246,12 +202,8 @@ export const linkedResourceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'linkedResource', - ], - operation: [ - 'update', - ], + resource: ['linkedResource'], + operation: ['update'], }, }, options: [ @@ -274,7 +226,8 @@ export const linkedResourceFields: INodeProperties[] = [ name: 'externalId', type: 'string', default: '', - description: 'ID of the object that is associated with this task on the third-party/partner system', + description: + 'ID of the object that is associated with this task on the third-party/partner system', }, { displayName: 'Web URL', diff --git a/packages/nodes-base/nodes/Microsoft/ToDo/ListDescription.ts b/packages/nodes-base/nodes/Microsoft/ToDo/ListDescription.ts index dc2b37a2b0..e05d87c212 100644 --- a/packages/nodes-base/nodes/Microsoft/ToDo/ListDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/ToDo/ListDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const listOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const listOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'list', - ], + resource: ['list'], }, }, options: [ @@ -56,12 +52,8 @@ export const listFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'list', - ], + operation: ['create'], + resource: ['list'], }, }, required: true, @@ -78,19 +70,13 @@ export const listFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'delete', - 'get', - 'update', - ], - resource: [ - 'list', - ], + operation: ['delete', 'get', 'update'], + resource: ['list'], }, }, required: true, default: '', - description: 'The identifier of the list, unique in the user\'s mailbox', + description: "The identifier of the list, unique in the user's mailbox", }, /* -------------------------------------------------------------------------- */ @@ -102,12 +88,8 @@ export const listFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], + resource: ['list'], + operation: ['getAll'], }, }, default: false, @@ -119,12 +101,8 @@ export const listFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], + resource: ['list'], + operation: ['getAll'], returnAll: [false], }, }, @@ -145,12 +123,8 @@ export const listFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'list', - ], + operation: ['update'], + resource: ['list'], }, }, required: true, diff --git a/packages/nodes-base/nodes/Microsoft/ToDo/MicrosoftToDo.node.ts b/packages/nodes-base/nodes/Microsoft/ToDo/MicrosoftToDo.node.ts index ea663be2ed..24579c948c 100644 --- a/packages/nodes-base/nodes/Microsoft/ToDo/MicrosoftToDo.node.ts +++ b/packages/nodes-base/nodes/Microsoft/ToDo/MicrosoftToDo.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,25 +10,13 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - microsoftApiRequest, - microsoftApiRequestAllItems, -} from './GenericFunctions'; +import { microsoftApiRequest, microsoftApiRequestAllItems } from './GenericFunctions'; -import { - linkedResourceFields, - linkedResourceOperations, -} from './LinkedResourceDescription'; +import { linkedResourceFields, linkedResourceOperations } from './LinkedResourceDescription'; -import { - taskFields, - taskOperations, -} from './TaskDescription'; +import { taskFields, taskOperations } from './TaskDescription'; -import { - listFields, - listOperations, -} from './ListDescription'; +import { listFields, listOperations } from './ListDescription'; import moment from 'moment-timezone'; @@ -114,81 +100,112 @@ export class MicrosoftToDo implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < length; i++) { try { - if (resource === 'linkedResource') { // https://docs.microsoft.com/en-us/graph/api/todotask-post-linkedresources?view=graph-rest-1.0&tabs=http if (operation === 'create') { - const taskListId = this.getNodeParameter('taskListId', i) as string; const taskId = this.getNodeParameter('taskId', i) as string; const body: IDataObject = { applicationName: this.getNodeParameter('applicationName', i) as string, displayName: this.getNodeParameter('displayName', i) as string, - ...this.getNodeParameter('additionalFields', i) as IDataObject[], + ...(this.getNodeParameter('additionalFields', i) as IDataObject[]), }; - responseData = await microsoftApiRequest.call(this, 'POST', `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources`, body, qs); + responseData = await microsoftApiRequest.call( + this, + 'POST', + `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources`, + body, + qs, + ); // https://docs.microsoft.com/en-us/graph/api/linkedresource-delete?view=graph-rest-1.0&tabs=http } else if (operation === 'delete') { - const taskListId = this.getNodeParameter('taskListId', i) as string; const taskId = this.getNodeParameter('taskId', i) as string; const linkedResourceId = this.getNodeParameter('linkedResourceId', i) as string; - responseData = await microsoftApiRequest.call(this, 'DELETE', `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources/${linkedResourceId}`, undefined, qs); + responseData = await microsoftApiRequest.call( + this, + 'DELETE', + `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources/${linkedResourceId}`, + undefined, + qs, + ); responseData = { success: true }; // https://docs.microsoft.com/en-us/graph/api/linkedresource-get?view=graph-rest-1.0&tabs=http } else if (operation === 'get') { - const taskListId = this.getNodeParameter('taskListId', i) as string; const taskId = this.getNodeParameter('taskId', i) as string; const linkedResourceId = this.getNodeParameter('linkedResourceId', i) as string; - responseData = await microsoftApiRequest.call(this, 'GET', `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources/${linkedResourceId}`, undefined, qs); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources/${linkedResourceId}`, + undefined, + qs, + ); // https://docs.microsoft.com/en-us/graph/api/todotask-list-linkedresources?view=graph-rest-1.0&tabs=http } else if (operation === 'getAll') { - const taskListId = this.getNodeParameter('taskListId', i) as string; const taskId = this.getNodeParameter('taskId', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll === true) { - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources`, undefined, qs); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources`, + undefined, + qs, + ); } else { qs['$top'] = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequest.call(this, 'GET', `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources`, undefined, qs); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources`, + undefined, + qs, + ); responseData = responseData.value; } // https://docs.microsoft.com/en-us/graph/api/linkedresource-update?view=graph-rest-1.0&tabs=http } else if (operation === 'update') { - const taskListId = this.getNodeParameter('taskListId', i) as string; const taskId = this.getNodeParameter('taskId', i) as string; const linkedResourceId = this.getNodeParameter('linkedResourceId', i) as string; const body: IDataObject = { - ...this.getNodeParameter('updateFields', i) as IDataObject[], + ...(this.getNodeParameter('updateFields', i) as IDataObject[]), }; - responseData = await microsoftApiRequest.call(this, 'PATCH', `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources/${linkedResourceId}`, body, qs); - - + responseData = await microsoftApiRequest.call( + this, + 'PATCH', + `/todo/lists/${taskListId}/tasks/${taskId}/linkedResources/${linkedResourceId}`, + body, + qs, + ); } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not supported!`, + { itemIndex: i }, + ); } } else if (resource === 'task') { - // https://docs.microsoft.com/en-us/graph/api/todotasklist-post-tasks?view=graph-rest-1.0&tabs=http if (operation === 'create') { - const taskListId = this.getNodeParameter('taskListId', i) as string; const body: IDataObject = { title: this.getNodeParameter('title', i) as string, - ...this.getNodeParameter('additionalFields', i) as IDataObject[], + ...(this.getNodeParameter('additionalFields', i) as IDataObject[]), }; if (body.content) { @@ -205,46 +222,73 @@ export class MicrosoftToDo implements INodeType { }; } - responseData = await microsoftApiRequest.call(this, 'POST', `/todo/lists/${taskListId}/tasks`, body, qs); + responseData = await microsoftApiRequest.call( + this, + 'POST', + `/todo/lists/${taskListId}/tasks`, + body, + qs, + ); // https://docs.microsoft.com/en-us/graph/api/todotask-delete?view=graph-rest-1.0&tabs=http } else if (operation === 'delete') { - const taskListId = this.getNodeParameter('taskListId', i) as string; const taskId = this.getNodeParameter('taskId', i) as string; - responseData = await microsoftApiRequest.call(this, 'DELETE', `/todo/lists/${taskListId}/tasks/${taskId}`, undefined, qs); + responseData = await microsoftApiRequest.call( + this, + 'DELETE', + `/todo/lists/${taskListId}/tasks/${taskId}`, + undefined, + qs, + ); responseData = { success: true }; // https://docs.microsoft.com/en-us/graph/api/todotask-get?view=graph-rest-1.0&tabs=http } else if (operation === 'get') { - const taskListId = this.getNodeParameter('taskListId', i) as string; const taskId = this.getNodeParameter('taskId', i) as string; - responseData = await microsoftApiRequest.call(this, 'GET', `/todo/lists/${taskListId}/tasks/${taskId}`, undefined, qs); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/todo/lists/${taskListId}/tasks/${taskId}`, + undefined, + qs, + ); // https://docs.microsoft.com/en-us/graph/api/todotasklist-list-tasks?view=graph-rest-1.0&tabs=http } else if (operation === 'getAll') { - const taskListId = this.getNodeParameter('taskListId', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll === true) { - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', `/todo/lists/${taskListId}/tasks/`, undefined, qs); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + `/todo/lists/${taskListId}/tasks/`, + undefined, + qs, + ); } else { qs['$top'] = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequest.call(this, 'GET', `/todo/lists/${taskListId}/tasks/`, undefined, qs); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/todo/lists/${taskListId}/tasks/`, + undefined, + qs, + ); responseData = responseData.value; } // https://docs.microsoft.com/en-us/graph/api/todotask-update?view=graph-rest-1.0&tabs=http } else if (operation === 'update') { - const taskListId = this.getNodeParameter('taskListId', i) as string; const taskId = this.getNodeParameter('taskId', i) as string; const body: IDataObject = { - ...this.getNodeParameter('updateFields', i) as IDataObject[], + ...(this.getNodeParameter('updateFields', i) as IDataObject[]), }; if (body.content) { @@ -261,17 +305,23 @@ export class MicrosoftToDo implements INodeType { }; } - responseData = await microsoftApiRequest.call(this, 'PATCH', `/todo/lists/${taskListId}/tasks/${taskId}`, body, qs); - + responseData = await microsoftApiRequest.call( + this, + 'PATCH', + `/todo/lists/${taskListId}/tasks/${taskId}`, + body, + qs, + ); } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not supported!`, + { itemIndex: i }, + ); } - } else if (resource === 'list') { - // https://docs.microsoft.com/en-us/graph/api/todo-post-lists?view=graph-rest-1.0&tabs=http if (operation === 'create') { - const body = { displayName: this.getNodeParameter('displayName', i) as string, }; @@ -280,41 +330,71 @@ export class MicrosoftToDo implements INodeType { // https://docs.microsoft.com/en-us/graph/api/todotasklist-delete?view=graph-rest-1.0&tabs=http } else if (operation === 'delete') { - const listId = this.getNodeParameter('listId', i) as string; - responseData = await microsoftApiRequest.call(this, 'DELETE', `/todo/lists/${listId}`, undefined, qs); + responseData = await microsoftApiRequest.call( + this, + 'DELETE', + `/todo/lists/${listId}`, + undefined, + qs, + ); responseData = { success: true }; //https://docs.microsoft.com/en-us/graph/api/todotasklist-get?view=graph-rest-1.0&tabs=http } else if (operation === 'get') { - const listId = this.getNodeParameter('listId', i) as string; - responseData = await microsoftApiRequest.call(this, 'GET', `/todo/lists/${listId}`, undefined, qs); + responseData = await microsoftApiRequest.call( + this, + 'GET', + `/todo/lists/${listId}`, + undefined, + qs, + ); // https://docs.microsoft.com/en-us/graph/api/todo-list-lists?view=graph-rest-1.0&tabs=http } else if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll === true) { - responseData = await microsoftApiRequestAllItems.call(this, 'value', 'GET', '/todo/lists', undefined, qs); + responseData = await microsoftApiRequestAllItems.call( + this, + 'value', + 'GET', + '/todo/lists', + undefined, + qs, + ); } else { qs['$top'] = this.getNodeParameter('limit', i) as number; - responseData = await microsoftApiRequest.call(this, 'GET', '/todo/lists', undefined, qs); + responseData = await microsoftApiRequest.call( + this, + 'GET', + '/todo/lists', + undefined, + qs, + ); responseData = responseData.value; } // https://docs.microsoft.com/en-us/graph/api/todotasklist-update?view=graph-rest-1.0&tabs=http } else if (operation === 'update') { - const listId = this.getNodeParameter('listId', i) as string; const body = { displayName: this.getNodeParameter('displayName', i) as string, }; - responseData = await microsoftApiRequest.call(this, 'PATCH', `/todo/lists/${listId}`, body, qs); - + responseData = await microsoftApiRequest.call( + this, + 'PATCH', + `/todo/lists/${listId}`, + body, + qs, + ); } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not supported!`, + { itemIndex: i }, + ); } } } catch (error) { diff --git a/packages/nodes-base/nodes/Microsoft/ToDo/TaskDescription.ts b/packages/nodes-base/nodes/Microsoft/ToDo/TaskDescription.ts index 3489bf6bed..a6fd2435da 100644 --- a/packages/nodes-base/nodes/Microsoft/ToDo/TaskDescription.ts +++ b/packages/nodes-base/nodes/Microsoft/ToDo/TaskDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const taskOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const taskOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'task', - ], + resource: ['task'], }, }, options: [ @@ -59,17 +55,14 @@ export const taskFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'task', - ], + operation: ['create'], + resource: ['task'], }, }, required: true, default: '', - description: 'The identifier of the list, unique in the user\'s mailbox. Choose from the list, or specify an ID using an expression.', + description: + 'The identifier of the list, unique in the user\'s mailbox. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Subject', @@ -77,12 +70,8 @@ export const taskFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'task', - ], + operation: ['create'], + resource: ['task'], }, }, required: true, @@ -97,12 +86,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, options: [ @@ -186,20 +171,14 @@ export const taskFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'delete', - 'get', - 'getAll', - 'update', - ], - resource: [ - 'task', - ], + operation: ['delete', 'get', 'getAll', 'update'], + resource: ['task'], }, }, required: true, default: '', - description: 'The identifier of the list, unique in the user\'s mailbox. Choose from the list, or specify an ID using an expression.', + description: + 'The identifier of the list, unique in the user\'s mailbox. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Task ID', @@ -207,14 +186,8 @@ export const taskFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'delete', - 'get', - 'update', - ], - resource: [ - 'task', - ], + operation: ['delete', 'get', 'update'], + resource: ['task'], }, }, required: true, @@ -230,12 +203,8 @@ export const taskFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, default: false, @@ -247,12 +216,8 @@ export const taskFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], returnAll: [false], }, }, @@ -275,12 +240,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Mindee/GenericFunctions.ts b/packages/nodes-base/nodes/Mindee/GenericFunctions.ts index 503bd1c2e0..e6fa518e3c 100644 --- a/packages/nodes-base/nodes/Mindee/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mindee/GenericFunctions.ts @@ -11,9 +11,8 @@ export async function mindeeApiRequest( body: any = {}, // tslint:disable-line:no-any qs: IDataObject = {}, option = {}, -): Promise {// tslint:disable-line:no-any - - + // tslint:disable-next-line:no-any +): Promise { const resource = this.getNodeParameter('resource', 0) as string; let service; @@ -73,7 +72,6 @@ export function cleanDataPreviousApiVersions(predictions: IDataObject[]) { //@ts-ignore newData['locale'] = data.value; } else { - newData[key] = //@ts-ignore data.value || data.name || data.raw || data.degrees || data.amount || data.iban; @@ -104,7 +102,6 @@ export function cleanData(document: IDataObject) { //@ts-ignore newData['locale'] = data.value; } else { - newData[key] = //@ts-ignore data.value || data.name || data.raw || data.degrees || data.amount || data.iban; diff --git a/packages/nodes-base/nodes/Mindee/Mindee.node.ts b/packages/nodes-base/nodes/Mindee/Mindee.node.ts index 34f38b56ce..bb93f2e26f 100644 --- a/packages/nodes-base/nodes/Mindee/Mindee.node.ts +++ b/packages/nodes-base/nodes/Mindee/Mindee.node.ts @@ -167,7 +167,9 @@ export class Mindee implements INodeType { const rawData = this.getNodeParameter('rawData', i) as boolean; if (items[i].binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const item = items[i].binary as IBinaryKeyData; @@ -236,7 +238,9 @@ export class Mindee implements INodeType { const rawData = this.getNodeParameter('rawData', i) as boolean; if (items[i].binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const item = items[i].binary as IBinaryKeyData; diff --git a/packages/nodes-base/nodes/Misp/GenericFunctions.ts b/packages/nodes-base/nodes/Misp/GenericFunctions.ts index 83f6227a3e..ad7c5c85b0 100644 --- a/packages/nodes-base/nodes/Misp/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Misp/GenericFunctions.ts @@ -1,21 +1,10 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - ILoadOptionsFunctions, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, ILoadOptionsFunctions, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - MispCredentials, -} from './types'; +import { MispCredentials } from './types'; import { URL } from 'url'; @@ -26,11 +15,9 @@ export async function mispApiRequest( body: IDataObject = {}, qs: IDataObject = {}, ) { - const { - baseUrl, - apiKey, - allowUnauthorizedCerts, - } = await this.getCredentials('mispApi') as MispCredentials; + const { baseUrl, apiKey, allowUnauthorizedCerts } = (await this.getCredentials( + 'mispApi', + )) as MispCredentials; const options: OptionsWithUri = { headers: { @@ -55,7 +42,6 @@ export async function mispApiRequest( try { return await this.helpers.request!(options); } catch (error) { - // MISP API wrongly returns 403 for malformed requests if (error.statusCode === 403) { error.statusCode = 400; @@ -81,10 +67,7 @@ export async function mispApiRequest( } } -export async function mispApiRequestAllItems( - this: IExecuteFunctions, - endpoint: string, -) { +export async function mispApiRequestAllItems(this: IExecuteFunctions, endpoint: string) { const responseData = await mispApiRequest.call(this, 'GET', endpoint); const returnAll = this.getNodeParameter('returnAll', 0) as boolean; @@ -111,14 +94,8 @@ export function throwOnEmptyUpdate( const SHARING_GROUP_OPTION_ID = 4; -export function throwOnMissingSharingGroup( - this: IExecuteFunctions, - fields: IDataObject, -) { - if ( - fields.distribution === SHARING_GROUP_OPTION_ID && - !fields.sharing_group_id - ) { +export function throwOnMissingSharingGroup(this: IExecuteFunctions, fields: IDataObject) { + if (fields.distribution === SHARING_GROUP_OPTION_ID && !fields.sharing_group_id) { throw new NodeOperationError(this.getNode(), 'Please specify a sharing group'); } } @@ -132,10 +109,7 @@ const isValidUrl = (str: string) => { } }; -export function throwOnInvalidUrl( - this: IExecuteFunctions, - str: string, -) { +export function throwOnInvalidUrl(this: IExecuteFunctions, str: string) { if (!isValidUrl(str)) { throw new NodeOperationError( this.getNode(), diff --git a/packages/nodes-base/nodes/Misp/Misp.node.ts b/packages/nodes-base/nodes/Misp/Misp.node.ts index fbee596389..33bdad94c6 100644 --- a/packages/nodes-base/nodes/Misp/Misp.node.ts +++ b/packages/nodes-base/nodes/Misp/Misp.node.ts @@ -1,14 +1,6 @@ -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; import { mispApiRequest, @@ -41,12 +33,7 @@ import { warninglistOperations, } from './descriptions'; -import { - LoadedOrgs, - LoadedSharingGroups, - LoadedTags, - LoadedUsers, -} from './types'; +import { LoadedOrgs, LoadedSharingGroups, LoadedTags, LoadedUsers } from './types'; export class Misp implements INodeType { description: INodeTypeDescription = { @@ -144,22 +131,37 @@ export class Misp implements INodeType { methods = { loadOptions: { async getOrgs(this: ILoadOptionsFunctions) { - const responseData = await mispApiRequest.call(this, 'GET', '/organisations') as LoadedOrgs; + const responseData = (await mispApiRequest.call( + this, + 'GET', + '/organisations', + )) as LoadedOrgs; return responseData.map((i) => ({ name: i.Organisation.name, value: i.Organisation.id })); }, async getSharingGroups(this: ILoadOptionsFunctions) { - const responseData = await mispApiRequest.call(this, 'GET', '/sharing_groups') as LoadedSharingGroups; - return responseData.response.map((i) => ({ name: i.SharingGroup.name, value: i.SharingGroup.id })); + const responseData = (await mispApiRequest.call( + this, + 'GET', + '/sharing_groups', + )) as LoadedSharingGroups; + return responseData.response.map((i) => ({ + name: i.SharingGroup.name, + value: i.SharingGroup.id, + })); }, async getTags(this: ILoadOptionsFunctions) { - const responseData = await mispApiRequest.call(this, 'GET', '/tags') as LoadedTags; + const responseData = (await mispApiRequest.call(this, 'GET', '/tags')) as LoadedTags; return responseData.Tag.map((i) => ({ name: i.name, value: i.id })); }, async getUsers(this: ILoadOptionsFunctions) { - const responseData = await mispApiRequest.call(this, 'GET', '/admin/users') as LoadedUsers; + const responseData = (await mispApiRequest.call( + this, + 'GET', + '/admin/users', + )) as LoadedUsers; return responseData.map((i) => ({ name: i.User.email, value: i.User.id })); }, }, @@ -175,17 +177,13 @@ export class Misp implements INodeType { let responseData; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'attribute') { - // ********************************************************************** // attribute // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // attribute: create // ---------------------------------------- @@ -207,9 +205,7 @@ export class Misp implements INodeType { const endpoint = `/attributes/add/${eventId}`; responseData = await mispApiRequest.call(this, 'POST', endpoint, body); responseData = responseData.Attribute; - } else if (operation === 'delete') { - // ---------------------------------------- // attribute: delete // ---------------------------------------- @@ -217,9 +213,7 @@ export class Misp implements INodeType { const attributeId = this.getNodeParameter('attributeId', i); const endpoint = `/attributes/delete/${attributeId}`; responseData = await mispApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // attribute: get // ---------------------------------------- @@ -228,17 +222,13 @@ export class Misp implements INodeType { const endpoint = `/attributes/view/${attributeId}`; responseData = await mispApiRequest.call(this, 'GET', endpoint); responseData = responseData.Attribute; - } else if (operation === 'getAll') { - // ---------------------------------------- // attribute: getAll // ---------------------------------------- responseData = await mispApiRequestAllItems.call(this, '/attributes'); - } else if (operation === 'update') { - // ---------------------------------------- // attribute: update // ---------------------------------------- @@ -256,15 +246,12 @@ export class Misp implements INodeType { responseData = await mispApiRequest.call(this, 'PUT', endpoint, body); responseData = responseData.Attribute; } - } else if (resource === 'event') { - // ********************************************************************** // event // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // event: create // ---------------------------------------- @@ -284,9 +271,7 @@ export class Misp implements INodeType { responseData = await mispApiRequest.call(this, 'POST', '/events', body); responseData = responseData.Event; - } else if (operation === 'delete') { - // ---------------------------------------- // event: delete // ---------------------------------------- @@ -294,9 +279,7 @@ export class Misp implements INodeType { const eventId = this.getNodeParameter('eventId', i); const endpoint = `/events/delete/${eventId}`; responseData = await mispApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // event: get // ---------------------------------------- @@ -306,17 +289,13 @@ export class Misp implements INodeType { responseData = await mispApiRequest.call(this, 'GET', endpoint); responseData = responseData.Event; delete responseData.Attribute; // prevent excessive payload size - } else if (operation === 'getAll') { - // ---------------------------------------- // event: getAll // ---------------------------------------- responseData = await mispApiRequestAllItems.call(this, '/events'); - } else if (operation === 'publish') { - // ---------------------------------------- // event: publish // ---------------------------------------- @@ -324,9 +303,7 @@ export class Misp implements INodeType { const eventId = this.getNodeParameter('eventId', i); const endpoint = `/events/publish/${eventId}`; responseData = await mispApiRequest.call(this, 'POST', endpoint); - } else if (operation === 'unpublish') { - // ---------------------------------------- // event: unpublish // ---------------------------------------- @@ -335,9 +312,7 @@ export class Misp implements INodeType { const endpoint = `/events/unpublish/${eventId}`; responseData = await mispApiRequest.call(this, 'POST', endpoint); - } else if (operation === 'update') { - // ---------------------------------------- // event: update // ---------------------------------------- @@ -355,13 +330,9 @@ export class Misp implements INodeType { responseData = await mispApiRequest.call(this, 'PUT', endpoint, body); responseData = responseData.Event; delete responseData.Attribute; // prevent excessive payload size - } - } else if (resource === 'eventTag') { - if (operation === 'add') { - // ---------------------------------------- // eventTag: add // ---------------------------------------- @@ -373,9 +344,7 @@ export class Misp implements INodeType { const endpoint = `/events/addTag`; responseData = await mispApiRequest.call(this, 'POST', endpoint, body); - } else if (operation === 'remove') { - // ---------------------------------------- // eventTag: remove // ---------------------------------------- @@ -385,17 +354,13 @@ export class Misp implements INodeType { const endpoint = `/events/removeTag/${eventId}/${tagId}`; responseData = await mispApiRequest.call(this, 'POST', endpoint); - } - } else if (resource === 'feed') { - // ********************************************************************** // feed // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // feed: create // ---------------------------------------- @@ -418,9 +383,7 @@ export class Misp implements INodeType { responseData = await mispApiRequest.call(this, 'POST', '/feeds/add', body); responseData = responseData.Feed; - } else if (operation === 'disable') { - // ---------------------------------------- // feed: disable // ---------------------------------------- @@ -429,9 +392,7 @@ export class Misp implements INodeType { const endpoint = `/feeds/disable/${feedId}`; responseData = await mispApiRequest.call(this, 'POST', endpoint); - } else if (operation === 'enable') { - // ---------------------------------------- // feed: enable // ---------------------------------------- @@ -439,9 +400,7 @@ export class Misp implements INodeType { const feedId = this.getNodeParameter('feedId', i); const endpoint = `/feeds/enable/${feedId}`; responseData = await mispApiRequest.call(this, 'POST', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // feed: get // ---------------------------------------- @@ -449,24 +408,24 @@ export class Misp implements INodeType { const feedId = this.getNodeParameter('feedId', i); responseData = await mispApiRequest.call(this, 'GET', `/feeds/view/${feedId}`); responseData = responseData.Feed; - } else if (operation === 'getAll') { - // ---------------------------------------- // feed: getAll // ---------------------------------------- - responseData = await mispApiRequestAllItems.call(this, '/feeds') as Array<{ Feed: unknown }>; - responseData = responseData.map(i => i.Feed); - + responseData = (await mispApiRequestAllItems.call(this, '/feeds')) as Array<{ + Feed: unknown; + }>; + responseData = responseData.map((i) => i.Feed); } else if (operation === 'update') { - // ---------------------------------------- // feed: update // ---------------------------------------- const body = {}; - const updateFields = this.getNodeParameter('updateFields', i) as IDataObject & { url: string }; + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject & { + url: string; + }; throwOnEmptyUpdate.call(this, resource, updateFields); @@ -479,17 +438,13 @@ export class Misp implements INodeType { const feedId = this.getNodeParameter('feedId', i); responseData = await mispApiRequest.call(this, 'PUT', `/feeds/edit/${feedId}`, body); responseData = responseData.Feed; - } - } else if (resource === 'galaxy') { - // ********************************************************************** // galaxy // ********************************************************************** if (operation === 'delete') { - // ---------------------------------------- // galaxy: delete // ---------------------------------------- @@ -497,9 +452,7 @@ export class Misp implements INodeType { const galaxyId = this.getNodeParameter('galaxyId', i); const endpoint = `/galaxies/delete/${galaxyId}`; responseData = await mispApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // galaxy: get // ---------------------------------------- @@ -508,26 +461,22 @@ export class Misp implements INodeType { const endpoint = `/galaxies/view/${galaxyId}`; responseData = await mispApiRequest.call(this, 'GET', endpoint); responseData = responseData.Galaxy; - } else if (operation === 'getAll') { - // ---------------------------------------- // galaxy: getAll // ---------------------------------------- - responseData = await mispApiRequestAllItems.call(this, '/galaxies') as Array<{ Galaxy: unknown }>; - responseData = responseData.map(i => i.Galaxy); - + responseData = (await mispApiRequestAllItems.call(this, '/galaxies')) as Array<{ + Galaxy: unknown; + }>; + responseData = responseData.map((i) => i.Galaxy); } - } else if (resource === 'noticelist') { - // ********************************************************************** // noticelist // ********************************************************************** if (operation === 'get') { - // ---------------------------------------- // noticelist: get // ---------------------------------------- @@ -536,26 +485,22 @@ export class Misp implements INodeType { const endpoint = `/noticelists/view/${noticelistId}`; responseData = await mispApiRequest.call(this, 'GET', endpoint); responseData = responseData.Noticelist; - } else if (operation === 'getAll') { - // ---------------------------------------- // noticelist: getAll // ---------------------------------------- - responseData = await mispApiRequestAllItems.call(this, '/noticelists') as Array<{ Noticelist: unknown }>; - responseData = responseData.map(i => i.Noticelist); - + responseData = (await mispApiRequestAllItems.call(this, '/noticelists')) as Array<{ + Noticelist: unknown; + }>; + responseData = responseData.map((i) => i.Noticelist); } - } else if (resource === 'organisation') { - // ********************************************************************** // organisation // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // organisation: create // ---------------------------------------- @@ -573,9 +518,7 @@ export class Misp implements INodeType { const endpoint = '/admin/organisations/add'; responseData = await mispApiRequest.call(this, 'POST', endpoint, body); responseData = responseData.Organisation; - } else if (operation === 'delete') { - // ---------------------------------------- // organisation: delete // ---------------------------------------- @@ -583,9 +526,7 @@ export class Misp implements INodeType { const organisationId = this.getNodeParameter('organisationId', i); const endpoint = `/admin/organisations/delete/${organisationId}`; responseData = await mispApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // organisation: get // ---------------------------------------- @@ -594,18 +535,16 @@ export class Misp implements INodeType { const endpoint = `/organisations/view/${organisationId}`; responseData = await mispApiRequest.call(this, 'GET', endpoint); responseData = responseData.Organisation; - } else if (operation === 'getAll') { - // ---------------------------------------- // organisation: getAll // ---------------------------------------- - responseData = await mispApiRequestAllItems.call(this, '/organisations') as Array<{ Organisation: unknown }>; - responseData = responseData.map(i => i.Organisation); - + responseData = (await mispApiRequestAllItems.call(this, '/organisations')) as Array<{ + Organisation: unknown; + }>; + responseData = responseData.map((i) => i.Organisation); } else if (operation === 'update') { - // ---------------------------------------- // organisation: update // ---------------------------------------- @@ -619,17 +558,13 @@ export class Misp implements INodeType { const endpoint = `/admin/organisations/edit/${organisationId}`; responseData = await mispApiRequest.call(this, 'PUT', endpoint, body); responseData = responseData.Organisation; - } - } else if (resource === 'tag') { - // ********************************************************************** // tag // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // tag: create // ---------------------------------------- @@ -638,7 +573,10 @@ export class Misp implements INodeType { name: this.getNodeParameter('name', i), }; - const { colour } = this.getNodeParameter('additionalFields', i) as { name?: string; colour?: string }; + const { colour } = this.getNodeParameter('additionalFields', i) as { + name?: string; + colour?: string; + }; if (colour) { Object.assign(body, { @@ -648,23 +586,19 @@ export class Misp implements INodeType { responseData = await mispApiRequest.call(this, 'POST', '/tags/add', body); responseData = responseData.Tag; - } else if (operation === 'delete') { - // ---------------------------------------- // tag: delete // ---------------------------------------- const tagId = this.getNodeParameter('tagId', i); responseData = await mispApiRequest.call(this, 'POST', `/tags/delete/${tagId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // tag: getAll // ---------------------------------------- - responseData = await mispApiRequest.call(this, 'GET', '/tags') as LoadedTags; + responseData = (await mispApiRequest.call(this, 'GET', '/tags')) as LoadedTags; const returnAll = this.getNodeParameter('returnAll', 0) as boolean; @@ -672,39 +606,36 @@ export class Misp implements INodeType { const limit = this.getNodeParameter('limit', 0) as number; responseData = responseData.Tag.slice(0, limit); } - } else if (operation === 'update') { - // ---------------------------------------- // tag: update // ---------------------------------------- const body = {}; - const updateFields = this.getNodeParameter('updateFields', i) as { colour?: string; name?: string; }; + const updateFields = this.getNodeParameter('updateFields', i) as { + colour?: string; + name?: string; + }; throwOnEmptyUpdate.call(this, resource, updateFields); Object.assign(body, updateFields); const { colour, name } = updateFields; Object.assign(body, { - ...name && { name }, - ...colour && { colour: !colour.startsWith('#') ? `#${colour}` : colour }, + ...(name && { name }), + ...(colour && { colour: !colour.startsWith('#') ? `#${colour}` : colour }), }); const tagId = this.getNodeParameter('tagId', i); responseData = await mispApiRequest.call(this, 'POST', `/tags/edit/${tagId}`, body); responseData = responseData.Tag; - } - } else if (resource === 'user') { - // ********************************************************************** // user // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // user: create // ---------------------------------------- @@ -722,9 +653,7 @@ export class Misp implements INodeType { responseData = await mispApiRequest.call(this, 'POST', '/admin/users/add', body); responseData = responseData.User; - } else if (operation === 'delete') { - // ---------------------------------------- // user: delete // ---------------------------------------- @@ -732,9 +661,7 @@ export class Misp implements INodeType { const userId = this.getNodeParameter('userId', i); const endpoint = `/admin/users/delete/${userId}`; responseData = await mispApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // user: get // ---------------------------------------- @@ -743,18 +670,16 @@ export class Misp implements INodeType { const endpoint = `/admin/users/view/${userId}`; responseData = await mispApiRequest.call(this, 'GET', endpoint); responseData = responseData.User; - } else if (operation === 'getAll') { - // ---------------------------------------- // user: getAll // ---------------------------------------- - responseData = await mispApiRequestAllItems.call(this, '/admin/users') as Array<{ User: unknown }>; - responseData = responseData.map(i => i.User); - + responseData = (await mispApiRequestAllItems.call(this, '/admin/users')) as Array<{ + User: unknown; + }>; + responseData = responseData.map((i) => i.User); } else if (operation === 'update') { - // ---------------------------------------- // user: update // ---------------------------------------- @@ -768,17 +693,13 @@ export class Misp implements INodeType { const endpoint = `/admin/users/edit/${userId}`; responseData = await mispApiRequest.call(this, 'PUT', endpoint, body); responseData = responseData.User; - } - } else if (resource === 'warninglist') { - // ********************************************************************** // warninglist // ********************************************************************** if (operation === 'get') { - // ---------------------------------------- // warninglist: get // ---------------------------------------- @@ -787,28 +708,25 @@ export class Misp implements INodeType { const endpoint = `/warninglists/view/${warninglistId}`; responseData = await mispApiRequest.call(this, 'GET', endpoint); responseData = responseData.Warninglist; - } else if (operation === 'getAll') { - // ---------------------------------------- // warninglist: getAll // ---------------------------------------- - responseData = await mispApiRequest.call(this, 'GET', '/warninglists') as { Warninglists: Array<{ Warninglist: unknown }> }; + responseData = (await mispApiRequest.call(this, 'GET', '/warninglists')) as { + Warninglists: Array<{ Warninglist: unknown }>; + }; const returnAll = this.getNodeParameter('returnAll', 0) as boolean; if (!returnAll) { const limit = this.getNodeParameter('limit', 0) as number; - responseData = responseData.Warninglists.slice(0, limit).map(i => i.Warninglist); + responseData = responseData.Warninglists.slice(0, limit).map((i) => i.Warninglist); } else { - responseData = responseData.Warninglists.map(i => i.Warninglist); + responseData = responseData.Warninglists.map((i) => i.Warninglist); } - } - } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -820,7 +738,6 @@ export class Misp implements INodeType { Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Misp/descriptions/AttributeDescription.ts b/packages/nodes-base/nodes/Misp/descriptions/AttributeDescription.ts index 805eb03c3f..0779835291 100644 --- a/packages/nodes-base/nodes/Misp/descriptions/AttributeDescription.ts +++ b/packages/nodes-base/nodes/Misp/descriptions/AttributeDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const attributeOperations: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const attributeOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'attribute', - ], + resource: ['attribute'], }, }, noDataExpression: true, @@ -59,12 +55,8 @@ export const attributeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'attribute', - ], - operation: [ - 'create', - ], + resource: ['attribute'], + operation: ['create'], }, }, }, @@ -90,16 +82,12 @@ export const attributeFields: INodeProperties[] = [ default: 'text', displayOptions: { show: { - resource: [ - 'attribute', - ], - operation: [ - 'create', - ], + resource: ['attribute'], + operation: ['create'], }, }, }, - { + { displayName: 'Value', name: 'value', type: 'string', @@ -107,12 +95,8 @@ export const attributeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'attribute', - ], - operation: [ - 'create', - ], + resource: ['attribute'], + operation: ['create'], }, }, }, @@ -124,12 +108,8 @@ export const attributeFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'attribute', - ], - operation: [ - 'create', - ], + resource: ['attribute'], + operation: ['create'], }, }, options: [ @@ -171,7 +151,8 @@ export const attributeFields: INodeProperties[] = [ name: 'sharing_group_id', type: 'options', default: '', - description: 'Use only for when Sharing Group is selected in Distribution. Choose from the list, or specify an ID using an expression.', + description: + 'Use only for when Sharing Group is selected in Distribution. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getSharingGroups', }, @@ -191,12 +172,8 @@ export const attributeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'attribute', - ], - operation: [ - 'delete', - ], + resource: ['attribute'], + operation: ['delete'], }, }, }, @@ -213,12 +190,8 @@ export const attributeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'attribute', - ], - operation: [ - 'get', - ], + resource: ['attribute'], + operation: ['get'], }, }, }, @@ -230,12 +203,8 @@ export const attributeFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'attribute', - ], - operation: [ - 'getAll', - ], + resource: ['attribute'], + operation: ['getAll'], }, }, }, @@ -250,15 +219,9 @@ export const attributeFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'attribute', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['attribute'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -275,12 +238,8 @@ export const attributeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'attribute', - ], - operation: [ - 'update', - ], + resource: ['attribute'], + operation: ['update'], }, }, }, @@ -292,12 +251,8 @@ export const attributeFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'attribute', - ], - operation: [ - 'update', - ], + resource: ['attribute'], + operation: ['update'], }, }, options: [ @@ -340,7 +295,8 @@ export const attributeFields: INodeProperties[] = [ type: 'options', default: '', // eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-dynamic-options - description: 'Choose from the list, or specify an ID using an expression. Use only for when Sharing Group is selected in Distribution.', + description: + 'Choose from the list, or specify an ID using an expression. Use only for when Sharing Group is selected in Distribution.', typeOptions: { loadOptionsMethod: 'getSharingGroups', }, diff --git a/packages/nodes-base/nodes/Misp/descriptions/EventDescription.ts b/packages/nodes-base/nodes/Misp/descriptions/EventDescription.ts index 7934fa41d0..d83dbfe11b 100644 --- a/packages/nodes-base/nodes/Misp/descriptions/EventDescription.ts +++ b/packages/nodes-base/nodes/Misp/descriptions/EventDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const eventOperations: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const eventOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'event', - ], + resource: ['event'], }, }, noDataExpression: true, @@ -66,18 +62,15 @@ export const eventFields: INodeProperties[] = [ type: 'options', default: '', required: true, - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getOrgs', }, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'create', - ], + resource: ['event'], + operation: ['create'], }, }, }, @@ -90,12 +83,8 @@ export const eventFields: INodeProperties[] = [ description: 'Information on the event - max 65535 characters', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'create', - ], + resource: ['event'], + operation: ['create'], }, }, }, @@ -107,12 +96,8 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'create', - ], + resource: ['event'], + operation: ['create'], }, }, options: [ @@ -175,7 +160,8 @@ export const eventFields: INodeProperties[] = [ name: 'sharing_group_id', type: 'options', default: '', - description: 'Use only for when Sharing Group is selected in Distribution. Choose from the list, or specify an ID using an expression.', + description: + 'Use only for when Sharing Group is selected in Distribution. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getSharingGroups', }, @@ -219,12 +205,8 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'delete', - ], + resource: ['event'], + operation: ['delete'], }, }, }, @@ -241,12 +223,8 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'get', - ], + resource: ['event'], + operation: ['get'], }, }, }, @@ -258,12 +236,8 @@ export const eventFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'getAll', - ], + resource: ['event'], + operation: ['getAll'], }, }, }, @@ -278,15 +252,9 @@ export const eventFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['event'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -303,12 +271,8 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'publish', - ], + resource: ['event'], + operation: ['publish'], }, }, }, @@ -325,12 +289,8 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'unpublish', - ], + resource: ['event'], + operation: ['unpublish'], }, }, }, @@ -347,12 +307,8 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'update', - ], + resource: ['event'], + operation: ['update'], }, }, }, @@ -364,12 +320,8 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'update', - ], + resource: ['event'], + operation: ['update'], }, }, options: [ @@ -440,7 +392,8 @@ export const eventFields: INodeProperties[] = [ type: 'options', default: '', // eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-dynamic-options - description: 'Choose from the list, or specify an ID using an expression. Use only for when Sharing Group is selected in Distribution.', + description: + 'Choose from the list, or specify an ID using an expression. Use only for when Sharing Group is selected in Distribution.', typeOptions: { loadOptionsMethod: 'getSharingGroups', }, diff --git a/packages/nodes-base/nodes/Misp/descriptions/EventTagDescription.ts b/packages/nodes-base/nodes/Misp/descriptions/EventTagDescription.ts index 88a60dc906..05fd432089 100644 --- a/packages/nodes-base/nodes/Misp/descriptions/EventTagDescription.ts +++ b/packages/nodes-base/nodes/Misp/descriptions/EventTagDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const eventTagOperations: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const eventTagOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'eventTag', - ], + resource: ['eventTag'], }, }, noDataExpression: true, @@ -44,19 +40,16 @@ export const eventTagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'eventTag', - ], - operation: [ - 'add', - ], + resource: ['eventTag'], + operation: ['add'], }, }, }, { displayName: 'Tag Name or ID', name: 'tagId', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', type: 'options', required: true, default: '', @@ -65,12 +58,8 @@ export const eventTagFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'eventTag', - ], - operation: [ - 'add', - ], + resource: ['eventTag'], + operation: ['add'], }, }, }, @@ -87,19 +76,16 @@ export const eventTagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'eventTag', - ], - operation: [ - 'remove', - ], + resource: ['eventTag'], + operation: ['remove'], }, }, }, { displayName: 'Tag Name or ID', name: 'tagId', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', type: 'options', required: true, default: '', @@ -108,12 +94,8 @@ export const eventTagFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'eventTag', - ], - operation: [ - 'remove', - ], + resource: ['eventTag'], + operation: ['remove'], }, }, }, diff --git a/packages/nodes-base/nodes/Misp/descriptions/FeedDescription.ts b/packages/nodes-base/nodes/Misp/descriptions/FeedDescription.ts index d1093ba820..0253cb2069 100644 --- a/packages/nodes-base/nodes/Misp/descriptions/FeedDescription.ts +++ b/packages/nodes-base/nodes/Misp/descriptions/FeedDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const feedOperations: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const feedOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'feed', - ], + resource: ['feed'], }, }, noDataExpression: true, @@ -63,12 +59,8 @@ export const feedFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'feed', - ], - operation: [ - 'create', - ], + resource: ['feed'], + operation: ['create'], }, }, }, @@ -80,12 +72,8 @@ export const feedFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'feed', - ], - operation: [ - 'create', - ], + resource: ['feed'], + operation: ['create'], }, }, }, @@ -98,12 +86,8 @@ export const feedFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'feed', - ], - operation: [ - 'create', - ], + resource: ['feed'], + operation: ['create'], }, }, }, @@ -115,12 +99,8 @@ export const feedFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'feed', - ], - operation: [ - 'create', - ], + resource: ['feed'], + operation: ['create'], }, }, options: [ @@ -179,12 +159,8 @@ export const feedFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'feed', - ], - operation: [ - 'disable', - ], + resource: ['feed'], + operation: ['disable'], }, }, }, @@ -201,12 +177,8 @@ export const feedFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'feed', - ], - operation: [ - 'enable', - ], + resource: ['feed'], + operation: ['enable'], }, }, }, @@ -223,12 +195,8 @@ export const feedFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'feed', - ], - operation: [ - 'get', - ], + resource: ['feed'], + operation: ['get'], }, }, }, @@ -240,12 +208,8 @@ export const feedFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'feed', - ], - operation: [ - 'getAll', - ], + resource: ['feed'], + operation: ['getAll'], }, }, }, @@ -260,15 +224,9 @@ export const feedFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'feed', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['feed'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -285,12 +243,8 @@ export const feedFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'feed', - ], - operation: [ - 'update', - ], + resource: ['feed'], + operation: ['update'], }, }, }, @@ -302,12 +256,8 @@ export const feedFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'feed', - ], - operation: [ - 'update', - ], + resource: ['feed'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Misp/descriptions/GalaxyDescription.ts b/packages/nodes-base/nodes/Misp/descriptions/GalaxyDescription.ts index 60832fc920..744f46a937 100644 --- a/packages/nodes-base/nodes/Misp/descriptions/GalaxyDescription.ts +++ b/packages/nodes-base/nodes/Misp/descriptions/GalaxyDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const galaxyOperations: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const galaxyOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'galaxy', - ], + resource: ['galaxy'], }, }, noDataExpression: true, @@ -49,12 +45,8 @@ export const galaxyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'galaxy', - ], - operation: [ - 'delete', - ], + resource: ['galaxy'], + operation: ['delete'], }, }, }, @@ -71,12 +63,8 @@ export const galaxyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'galaxy', - ], - operation: [ - 'get', - ], + resource: ['galaxy'], + operation: ['get'], }, }, }, @@ -92,12 +80,8 @@ export const galaxyFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'galaxy', - ], - operation: [ - 'getAll', - ], + resource: ['galaxy'], + operation: ['getAll'], }, }, }, @@ -112,15 +96,9 @@ export const galaxyFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'galaxy', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['galaxy'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Misp/descriptions/NoticelistDescription.ts b/packages/nodes-base/nodes/Misp/descriptions/NoticelistDescription.ts index e15215152e..9716f1b9ed 100644 --- a/packages/nodes-base/nodes/Misp/descriptions/NoticelistDescription.ts +++ b/packages/nodes-base/nodes/Misp/descriptions/NoticelistDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const noticelistOperations: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const noticelistOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'noticelist', - ], + resource: ['noticelist'], }, }, noDataExpression: true, @@ -44,12 +40,8 @@ export const noticelistFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'noticelist', - ], - operation: [ - 'get', - ], + resource: ['noticelist'], + operation: ['get'], }, }, }, @@ -61,12 +53,8 @@ export const noticelistFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'noticelist', - ], - operation: [ - 'getAll', - ], + resource: ['noticelist'], + operation: ['getAll'], }, }, }, @@ -81,15 +69,9 @@ export const noticelistFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'noticelist', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['noticelist'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Misp/descriptions/OrganisationDescription.ts b/packages/nodes-base/nodes/Misp/descriptions/OrganisationDescription.ts index e16222797c..fe6caeacc5 100644 --- a/packages/nodes-base/nodes/Misp/descriptions/OrganisationDescription.ts +++ b/packages/nodes-base/nodes/Misp/descriptions/OrganisationDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const organisationOperations: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const organisationOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'organisation', - ], + resource: ['organisation'], }, }, noDataExpression: true, @@ -58,12 +54,8 @@ export const organisationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'organisation', - ], - operation: [ - 'create', - ], + resource: ['organisation'], + operation: ['create'], }, }, }, @@ -75,12 +67,8 @@ export const organisationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'organisation', - ], - operation: [ - 'create', - ], + resource: ['organisation'], + operation: ['create'], }, }, options: [ @@ -138,12 +126,8 @@ export const organisationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'organisation', - ], - operation: [ - 'delete', - ], + resource: ['organisation'], + operation: ['delete'], }, }, }, @@ -160,12 +144,8 @@ export const organisationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'organisation', - ], - operation: [ - 'get', - ], + resource: ['organisation'], + operation: ['get'], }, }, }, @@ -177,12 +157,8 @@ export const organisationFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'organisation', - ], - operation: [ - 'getAll', - ], + resource: ['organisation'], + operation: ['getAll'], }, }, }, @@ -197,15 +173,9 @@ export const organisationFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'organisation', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['organisation'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -222,12 +192,8 @@ export const organisationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'organisation', - ], - operation: [ - 'update', - ], + resource: ['organisation'], + operation: ['update'], }, }, }, @@ -239,12 +205,8 @@ export const organisationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'organisation', - ], - operation: [ - 'update', - ], + resource: ['organisation'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Misp/descriptions/TagDescription.ts b/packages/nodes-base/nodes/Misp/descriptions/TagDescription.ts index 2d70fe0003..ca1bda654f 100644 --- a/packages/nodes-base/nodes/Misp/descriptions/TagDescription.ts +++ b/packages/nodes-base/nodes/Misp/descriptions/TagDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const tagOperations: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const tagOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'tag', - ], + resource: ['tag'], }, }, noDataExpression: true, @@ -53,12 +49,8 @@ export const tagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'create', - ], + resource: ['tag'], + operation: ['create'], }, }, }, @@ -70,12 +62,8 @@ export const tagFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'create', - ], + resource: ['tag'], + operation: ['create'], }, }, options: [ @@ -101,12 +89,8 @@ export const tagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'delete', - ], + resource: ['tag'], + operation: ['delete'], }, }, }, @@ -122,12 +106,8 @@ export const tagFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'getAll', - ], + resource: ['tag'], + operation: ['getAll'], }, }, }, @@ -142,15 +122,9 @@ export const tagFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['tag'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -167,12 +141,8 @@ export const tagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'update', - ], + resource: ['tag'], + operation: ['update'], }, }, }, @@ -184,12 +154,8 @@ export const tagFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'update', - ], + resource: ['tag'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Misp/descriptions/UserDescription.ts b/packages/nodes-base/nodes/Misp/descriptions/UserDescription.ts index b2adb5e759..f75d48878a 100644 --- a/packages/nodes-base/nodes/Misp/descriptions/UserDescription.ts +++ b/packages/nodes-base/nodes/Misp/descriptions/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const userOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, noDataExpression: true, @@ -59,12 +55,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, }, @@ -77,12 +69,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, }, @@ -94,12 +82,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, options: [ @@ -115,7 +99,8 @@ export const userFields: INodeProperties[] = [ name: 'invited_by', type: 'options', default: '', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getUsers', }, @@ -124,7 +109,8 @@ export const userFields: INodeProperties[] = [ displayName: 'Organization Name or ID', name: 'org_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getOrgs', @@ -145,12 +131,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'delete', - ], + resource: ['user'], + operation: ['delete'], }, }, }, @@ -167,12 +149,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, }, @@ -184,12 +162,8 @@ export const userFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, }, @@ -204,15 +178,9 @@ export const userFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['user'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -229,12 +197,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, }, @@ -246,12 +210,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, options: [ @@ -272,7 +232,8 @@ export const userFields: INodeProperties[] = [ displayName: 'Inviter Name or ID', name: 'invited_by', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getUsers', @@ -282,7 +243,8 @@ export const userFields: INodeProperties[] = [ displayName: 'Organization Name or ID', name: 'org_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getOrgs', diff --git a/packages/nodes-base/nodes/Misp/descriptions/WarninglistDescription.ts b/packages/nodes-base/nodes/Misp/descriptions/WarninglistDescription.ts index 527c58eec5..29f59b8cb3 100644 --- a/packages/nodes-base/nodes/Misp/descriptions/WarninglistDescription.ts +++ b/packages/nodes-base/nodes/Misp/descriptions/WarninglistDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const warninglistOperations: INodeProperties[] = [ { @@ -9,9 +7,7 @@ export const warninglistOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'warninglist', - ], + resource: ['warninglist'], }, }, noDataExpression: true, @@ -44,12 +40,8 @@ export const warninglistFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'warninglist', - ], - operation: [ - 'get', - ], + resource: ['warninglist'], + operation: ['get'], }, }, }, @@ -65,12 +57,8 @@ export const warninglistFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'warninglist', - ], - operation: [ - 'getAll', - ], + resource: ['warninglist'], + operation: ['getAll'], }, }, }, @@ -85,15 +73,9 @@ export const warninglistFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'warninglist', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['warninglist'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Misp/types.d.ts b/packages/nodes-base/nodes/Misp/types.d.ts index 3a4fb35ab3..313f877e8e 100644 --- a/packages/nodes-base/nodes/Misp/types.d.ts +++ b/packages/nodes-base/nodes/Misp/types.d.ts @@ -20,4 +20,4 @@ export type LoadedSharingGroups = { response: Array<{ SharingGroup: { id: string; name: string }; }>; -} +}; diff --git a/packages/nodes-base/nodes/Mocean/GenericFunctions.ts b/packages/nodes-base/nodes/Mocean/GenericFunctions.ts index e0dd2a6d7d..de72c9eb7a 100644 --- a/packages/nodes-base/nodes/Mocean/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mocean/GenericFunctions.ts @@ -1,11 +1,6 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - IDataObject, JsonObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, JsonObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; /** * Make an API request to Twilio @@ -16,7 +11,14 @@ import { * @param {object} body * @returns {Promise} */ -export async function moceanApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject): Promise { // tslint:disable-line:no-any +export async function moceanApiRequest( + this: IHookFunctions | IExecuteFunctions, + method: string, + endpoint: string, + body: IDataObject, + query?: IDataObject, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('moceanApi'); if (query === undefined) { @@ -44,6 +46,6 @@ export async function moceanApiRequest(this: IHookFunctions | IExecuteFunctions, try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), (error as JsonObject)); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Mocean/Mocean.node.ts b/packages/nodes-base/nodes/Mocean/Mocean.node.ts index b06eeb24e1..aad4d65be5 100644 --- a/packages/nodes-base/nodes/Mocean/Mocean.node.ts +++ b/packages/nodes-base/nodes/Mocean/Mocean.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -14,9 +12,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - moceanApiRequest, -} from './GenericFunctions'; +import { moceanApiRequest } from './GenericFunctions'; export class Mocean implements INodeType { description: INodeTypeDescription = { @@ -66,10 +62,7 @@ export class Mocean implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'sms', - 'voice', - ], + resource: ['sms', 'voice'], }, }, options: [ @@ -91,13 +84,8 @@ export class Mocean implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - 'voice', - ], + operation: ['send'], + resource: ['sms', 'voice'], }, }, description: 'Number to which to send the message', @@ -112,13 +100,8 @@ export class Mocean implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - 'voice', - ], + operation: ['send'], + resource: ['sms', 'voice'], }, }, description: 'Number from which to send the message', @@ -152,12 +135,8 @@ export class Mocean implements INodeType { ], displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'voice', - ], + operation: ['send'], + resource: ['voice'], }, }, default: 'en-US', @@ -172,13 +151,8 @@ export class Mocean implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - 'voice', - ], + operation: ['send'], + resource: ['sms', 'voice'], }, }, description: 'Message to send', @@ -190,12 +164,8 @@ export class Mocean implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - ], + operation: ['send'], + resource: ['sms'], }, }, default: {}, @@ -214,7 +184,10 @@ export class Mocean implements INodeType { methods = { credentialTest: { - async moceanApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { + async moceanApiTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { const credentials = credential.data; const query: IDataObject = {}; query['mocean-api-key'] = credentials!['mocean-api-key']; @@ -242,7 +215,6 @@ export class Mocean implements INodeType { }, }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -293,19 +265,28 @@ export class Mocean implements INodeType { } endpoint = '/rest/2/sms'; } else { - throw new NodeOperationError(this.getNode(), `Unknown resource ${resource}`, { itemIndex }); + throw new NodeOperationError(this.getNode(), `Unknown resource ${resource}`, { + itemIndex, + }); } if (operation === 'send') { - const responseData = await moceanApiRequest.call(this, requesetMethod, endpoint, body, qs); + const responseData = await moceanApiRequest.call( + this, + requesetMethod, + endpoint, + body, + qs, + ); for (const item of responseData[dataKey] as IDataObject[]) { item.type = resource; returnData.push(item); } - } else { - throw new NodeOperationError(this.getNode(), `Unknown operation ${operation}`, { itemIndex }); + throw new NodeOperationError(this.getNode(), `Unknown operation ${operation}`, { + itemIndex, + }); } } catch (error) { if (this.continueOnFail()) { diff --git a/packages/nodes-base/nodes/MondayCom/BoardColumnDescription.ts b/packages/nodes-base/nodes/MondayCom/BoardColumnDescription.ts index e09696f216..0aab2e6e82 100644 --- a/packages/nodes-base/nodes/MondayCom/BoardColumnDescription.ts +++ b/packages/nodes-base/nodes/MondayCom/BoardColumnDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const boardColumnOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const boardColumnOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'boardColumn', - ], + resource: ['boardColumn'], }, }, options: [ @@ -34,14 +30,15 @@ export const boardColumnOperations: INodeProperties[] = [ ]; export const boardColumnFields: INodeProperties[] = [ -/* -------------------------------------------------------------------------- */ -/* boardColumn:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* boardColumn:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Board Name or ID', name: 'boardId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getBoards', @@ -49,12 +46,8 @@ export const boardColumnFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardColumn', - ], - operation: [ - 'create', - ], + resource: ['boardColumn'], + operation: ['create'], }, }, }, @@ -66,12 +59,8 @@ export const boardColumnFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardColumn', - ], - operation: [ - 'create', - ], + resource: ['boardColumn'], + operation: ['create'], }, }, }, @@ -169,12 +158,8 @@ export const boardColumnFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardColumn', - ], - operation: [ - 'create', - ], + resource: ['boardColumn'], + operation: ['create'], }, }, }, @@ -185,12 +170,8 @@ export const boardColumnFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'boardColumn', - ], - operation: [ - 'create', - ], + resource: ['boardColumn'], + operation: ['create'], }, }, default: {}, @@ -203,18 +184,19 @@ export const boardColumnFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'The new column\'s defaults', + description: "The new column's defaults", }, ], }, -/* -------------------------------------------------------------------------- */ -/* boardColumn:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* boardColumn:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Board Name or ID', name: 'boardId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getBoards', @@ -222,12 +204,8 @@ export const boardColumnFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardColumn', - ], - operation: [ - 'getAll', - ], + resource: ['boardColumn'], + operation: ['getAll'], }, }, }, diff --git a/packages/nodes-base/nodes/MondayCom/BoardDescription.ts b/packages/nodes-base/nodes/MondayCom/BoardDescription.ts index 9997e94a2a..e33739378d 100644 --- a/packages/nodes-base/nodes/MondayCom/BoardDescription.ts +++ b/packages/nodes-base/nodes/MondayCom/BoardDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const boardOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const boardOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'board', - ], + resource: ['board'], }, }, options: [ @@ -46,10 +42,9 @@ export const boardOperations: INodeProperties[] = [ ]; export const boardFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* board:archive */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* board:archive */ + /* -------------------------------------------------------------------------- */ { displayName: 'Board Name or ID', name: 'boardId', @@ -61,19 +56,16 @@ export const boardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'board', - ], - operation: [ - 'archive', - ], + resource: ['board'], + operation: ['archive'], }, }, - description: 'Board unique identifiers. Choose from the list, or specify an ID using an expression.', + description: + 'Board unique identifiers. Choose from the list, or specify an ID using an expression.', }, -/* -------------------------------------------------------------------------- */ -/* board:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* board:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Name', name: 'name', @@ -81,16 +73,12 @@ export const boardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'board', - ], + operation: ['create'], + resource: ['board'], }, }, default: '', - description: 'The board\'s name', + description: "The board's name", }, { displayName: 'Kind', @@ -113,16 +101,12 @@ export const boardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'board', - ], + operation: ['create'], + resource: ['board'], }, }, default: '', - description: 'The board\'s kind (public / private / share)', + description: "The board's kind (public / private / share)", }, { displayName: 'Additional Fields', @@ -131,12 +115,8 @@ export const boardFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'board', - ], + operation: ['create'], + resource: ['board'], }, }, default: {}, @@ -153,9 +133,9 @@ export const boardFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* board:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* board:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Board Name or ID', name: 'boardId', @@ -167,31 +147,24 @@ export const boardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'board', - ], - operation: [ - 'get', - ], + resource: ['board'], + operation: ['get'], }, }, - description: 'Board unique identifiers. Choose from the list, or specify an ID using an expression.', + description: + 'Board unique identifiers. Choose from the list, or specify an ID using an expression.', }, -/* -------------------------------------------------------------------------- */ -/* board:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* board:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'board', - ], - operation: [ - 'getAll', - ], + resource: ['board'], + operation: ['getAll'], }, }, default: false, @@ -203,15 +176,9 @@ export const boardFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'board', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['board'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/MondayCom/BoardGroupDescription.ts b/packages/nodes-base/nodes/MondayCom/BoardGroupDescription.ts index a6196f7f3b..663774aa62 100644 --- a/packages/nodes-base/nodes/MondayCom/BoardGroupDescription.ts +++ b/packages/nodes-base/nodes/MondayCom/BoardGroupDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const boardGroupOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const boardGroupOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'boardGroup', - ], + resource: ['boardGroup'], }, }, options: [ @@ -40,15 +36,15 @@ export const boardGroupOperations: INodeProperties[] = [ ]; export const boardGroupFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* boardGroup:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* boardGroup:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Board Name or ID', name: 'boardId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getBoards', @@ -56,12 +52,8 @@ export const boardGroupFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardGroup', - ], - operation: [ - 'create', - ], + resource: ['boardGroup'], + operation: ['create'], }, }, }, @@ -72,25 +64,22 @@ export const boardGroupFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'boardGroup', - ], + operation: ['create'], + resource: ['boardGroup'], }, }, default: '', description: 'The group name', }, -/* -------------------------------------------------------------------------- */ -/* boardGroup:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* boardGroup:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Board Name or ID', name: 'boardId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getBoards', }, @@ -98,12 +87,8 @@ export const boardGroupFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardGroup', - ], - operation: [ - 'delete', - ], + resource: ['boardGroup'], + operation: ['delete'], }, }, }, @@ -111,34 +96,30 @@ export const boardGroupFields: INodeProperties[] = [ displayName: 'Group Name or ID', name: 'groupId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getGroups', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, required: true, displayOptions: { show: { - resource: [ - 'boardGroup', - ], - operation: [ - 'delete', - ], + resource: ['boardGroup'], + operation: ['delete'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* boardGroup:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* boardGroup:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Board Name or ID', name: 'boardId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getBoards', @@ -146,12 +127,8 @@ export const boardGroupFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardGroup', - ], - operation: [ - 'getAll', - ], + resource: ['boardGroup'], + operation: ['getAll'], }, }, }, diff --git a/packages/nodes-base/nodes/MondayCom/BoardItemDescription.ts b/packages/nodes-base/nodes/MondayCom/BoardItemDescription.ts index 96f9f93bd1..7c798d1649 100644 --- a/packages/nodes-base/nodes/MondayCom/BoardItemDescription.ts +++ b/packages/nodes-base/nodes/MondayCom/BoardItemDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const boardItemOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const boardItemOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], + resource: ['boardItem'], }, }, options: [ @@ -37,8 +33,8 @@ export const boardItemOperations: INodeProperties[] = [ { name: 'Create', value: 'create', - description: 'Create an item in a board\'s group', - action: 'Create an item in a board\'s group', + description: "Create an item in a board's group", + action: "Create an item in a board's group", }, { name: 'Delete', @@ -76,7 +72,6 @@ export const boardItemOperations: INodeProperties[] = [ ]; export const boardItemFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* boardItem:addUpdate */ /* -------------------------------------------------------------------------- */ @@ -88,12 +83,8 @@ export const boardItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'addUpdate', - ], + resource: ['boardItem'], + operation: ['addUpdate'], }, }, description: 'The unique identifier of the item to add update to', @@ -106,12 +97,8 @@ export const boardItemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'addUpdate', - ], + resource: ['boardItem'], + operation: ['addUpdate'], }, }, description: 'The update text to add', @@ -130,15 +117,12 @@ export const boardItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'changeColumnValue', - ], + resource: ['boardItem'], + operation: ['changeColumnValue'], }, }, - description: 'The unique identifier of the board. Choose from the list, or specify an ID using an expression.', + description: + 'The unique identifier of the board. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Item ID', @@ -148,12 +132,8 @@ export const boardItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'changeColumnValue', - ], + resource: ['boardItem'], + operation: ['changeColumnValue'], }, }, description: 'The unique identifier of the item to to change column of', @@ -164,23 +144,18 @@ export const boardItemFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getColumns', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'changeColumnValue', - ], + resource: ['boardItem'], + operation: ['changeColumnValue'], }, }, - description: 'The column\'s unique identifier. Choose from the list, or specify an ID using an expression.', + description: + 'The column\'s unique identifier. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -190,15 +165,12 @@ export const boardItemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'changeColumnValue', - ], + resource: ['boardItem'], + operation: ['changeColumnValue'], }, }, - description: 'The column value in JSON format. Documentation can be found here.', + description: + 'The column value in JSON format. Documentation can be found here.', }, /* -------------------------------------------------------------------------- */ /* boardItem:changeMultipleColumnValues */ @@ -214,15 +186,12 @@ export const boardItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'changeMultipleColumnValues', - ], + resource: ['boardItem'], + operation: ['changeMultipleColumnValues'], }, }, - description: 'The unique identifier of the board. Choose from the list, or specify an ID using an expression.', + description: + 'The unique identifier of the board. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Item ID', @@ -232,15 +201,11 @@ export const boardItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'changeMultipleColumnValues', - ], + resource: ['boardItem'], + operation: ['changeMultipleColumnValues'], }, }, - description: 'Item\'s ID', + description: "Item's ID", }, { displayName: 'Column Values', @@ -250,15 +215,12 @@ export const boardItemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'changeMultipleColumnValues', - ], + resource: ['boardItem'], + operation: ['changeMultipleColumnValues'], }, }, - description: 'The column fields and values in JSON format. Documentation can be found here.', + description: + 'The column fields and values in JSON format. Documentation can be found here.', typeOptions: { alwaysOpenEditWindow: true, }, @@ -270,7 +232,8 @@ export const boardItemFields: INodeProperties[] = [ displayName: 'Board Name or ID', name: 'boardId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getBoards', }, @@ -278,12 +241,8 @@ export const boardItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'create', - ], + resource: ['boardItem'], + operation: ['create'], }, }, }, @@ -291,23 +250,18 @@ export const boardItemFields: INodeProperties[] = [ displayName: 'Group Name or ID', name: 'groupId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getGroups', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'create', - ], + resource: ['boardItem'], + operation: ['create'], }, }, }, @@ -318,16 +272,12 @@ export const boardItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'boardItem', - ], + operation: ['create'], + resource: ['boardItem'], }, }, default: '', - description: 'The new item\'s name', + description: "The new item's name", }, { displayName: 'Additional Fields', @@ -336,12 +286,8 @@ export const boardItemFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'boardItem', - ], + operation: ['create'], + resource: ['boardItem'], }, }, default: {}, @@ -369,15 +315,11 @@ export const boardItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'delete', - ], + resource: ['boardItem'], + operation: ['delete'], }, }, - description: 'Item\'s ID', + description: "Item's ID", }, /* -------------------------------------------------------------------------- */ /* boardItem:get */ @@ -390,15 +332,11 @@ export const boardItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'get', - ], + resource: ['boardItem'], + operation: ['get'], }, }, - description: 'Item\'s ID (Multiple can be added separated by comma)', + description: "Item's ID (Multiple can be added separated by comma)", }, /* -------------------------------------------------------------------------- */ /* boardItem:getAll */ @@ -407,7 +345,8 @@ export const boardItemFields: INodeProperties[] = [ displayName: 'Board Name or ID', name: 'boardId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getBoards', @@ -415,12 +354,8 @@ export const boardItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'getAll', - ], + resource: ['boardItem'], + operation: ['getAll'], }, }, }, @@ -429,22 +364,17 @@ export const boardItemFields: INodeProperties[] = [ name: 'groupId', default: '', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getGroups', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'getAll', - ], + resource: ['boardItem'], + operation: ['getAll'], }, }, }, @@ -454,12 +384,8 @@ export const boardItemFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'getAll', - ], + resource: ['boardItem'], + operation: ['getAll'], }, }, default: false, @@ -471,15 +397,9 @@ export const boardItemFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['boardItem'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -503,15 +423,12 @@ export const boardItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'getByColumnValue', - ], + resource: ['boardItem'], + operation: ['getByColumnValue'], }, }, - description: 'The unique identifier of the board. Choose from the list, or specify an ID using an expression.', + description: + 'The unique identifier of the board. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Column Name or ID', @@ -519,23 +436,18 @@ export const boardItemFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getColumns', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'getByColumnValue', - ], + resource: ['boardItem'], + operation: ['getByColumnValue'], }, }, - description: 'The column\'s unique identifier. Choose from the list, or specify an ID using an expression.', + description: + 'The column\'s unique identifier. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Column Value', @@ -545,12 +457,8 @@ export const boardItemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'getByColumnValue', - ], + resource: ['boardItem'], + operation: ['getByColumnValue'], }, }, description: 'The column value to search items by', @@ -561,12 +469,8 @@ export const boardItemFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'getByColumnValue', - ], + resource: ['boardItem'], + operation: ['getByColumnValue'], }, }, default: false, @@ -578,15 +482,9 @@ export const boardItemFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'getByColumnValue', - ], - returnAll: [ - false, - ], + resource: ['boardItem'], + operation: ['getByColumnValue'], + returnAll: [false], }, }, typeOptions: { @@ -603,7 +501,8 @@ export const boardItemFields: INodeProperties[] = [ displayName: 'Board Name or ID', name: 'boardId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getBoards', }, @@ -611,12 +510,8 @@ export const boardItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'move', - ], + resource: ['boardItem'], + operation: ['move'], }, }, }, @@ -627,38 +522,29 @@ export const boardItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'move', - ], - resource: [ - 'boardItem', - ], + operation: ['move'], + resource: ['boardItem'], }, }, default: '', - description: 'The item\'s ID', + description: "The item's ID", }, { displayName: 'Group Name or ID', name: 'groupId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getGroups', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, required: true, displayOptions: { show: { - resource: [ - 'boardItem', - ], - operation: [ - 'move', - ], + resource: ['boardItem'], + operation: ['move'], }, }, }, diff --git a/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts b/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts index 1cf694df8d..2adbc2a6b9 100644 --- a/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts @@ -1,11 +1,6 @@ -import { - OptionsWithUri, - } from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject, @@ -15,12 +10,15 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - get, -} from 'lodash'; - -export async function mondayComApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, body: any = {}, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { get } from 'lodash'; +export async function mondayComApiRequest( + this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, + // tslint:disable-next-line:no-any + body: any = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0) as string; const endpoint = 'https://api.monday.com/v2/'; @@ -43,7 +41,6 @@ export async function mondayComApiRequest(this: IExecuteFunctions | IWebhookFunc return await this.helpers.request!(options); } else { - return await this.helpers.requestOAuth2!.call(this, 'mondayComOAuth2Api', options); } } catch (error) { @@ -51,8 +48,13 @@ export async function mondayComApiRequest(this: IExecuteFunctions | IWebhookFunc } } -export async function mondayComApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, body: any = {}): Promise { // tslint:disable-line:no-any - +export async function mondayComApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + // tslint:disable-next-line:no-any + body: any = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -63,8 +65,6 @@ export async function mondayComApiRequestAllItems(this: IHookFunctions | IExecut responseData = await mondayComApiRequest.call(this, body); returnData.push.apply(returnData, get(responseData, propertyName)); body.variables.page++; - } while ( - get(responseData, propertyName).length > 0 - ); + } while (get(responseData, propertyName).length > 0); return returnData; } diff --git a/packages/nodes-base/nodes/MondayCom/MondayCom.node.ts b/packages/nodes-base/nodes/MondayCom/MondayCom.node.ts index 9f7a64bbfd..41464e37f2 100644 --- a/packages/nodes-base/nodes/MondayCom/MondayCom.node.ts +++ b/packages/nodes-base/nodes/MondayCom/MondayCom.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,34 +10,17 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - mondayComApiRequest, - mondayComApiRequestAllItems, -} from './GenericFunctions'; +import { mondayComApiRequest, mondayComApiRequestAllItems } from './GenericFunctions'; -import { - boardFields, - boardOperations, -} from './BoardDescription'; +import { boardFields, boardOperations } from './BoardDescription'; -import { - boardColumnFields, - boardColumnOperations, -} from './BoardColumnDescription'; +import { boardColumnFields, boardColumnOperations } from './BoardColumnDescription'; -import { - boardGroupFields, - boardGroupOperations, -} from './BoardGroupDescription'; +import { boardGroupFields, boardGroupOperations } from './BoardGroupDescription'; -import { - boardItemFields, - boardItemOperations, -} from './BoardItemDescription'; +import { boardItemFields, boardItemOperations } from './BoardItemDescription'; -import { - snakeCase, -} from 'change-case'; +import { snakeCase } from 'change-case'; interface IGraphqlBody { query: string; @@ -66,9 +47,7 @@ export class MondayCom implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -77,9 +56,7 @@ export class MondayCom implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -148,8 +125,7 @@ export class MondayCom implements INodeType { async getBoards(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const body = { - query: - `query ($page: Int, $limit: Int) { + query: `query ($page: Int, $limit: Int) { boards (page: $page, limit: $limit){ id description @@ -183,8 +159,7 @@ export class MondayCom implements INodeType { const returnData: INodePropertyOptions[] = []; const boardId = parseInt(this.getCurrentNodeParameter('boardId') as string, 10); const body: IGraphqlBody = { - query: - `query ($boardId: [Int]) { + query: `query ($boardId: [Int]) { boards (ids: $boardId){ columns() { id @@ -219,8 +194,7 @@ export class MondayCom implements INodeType { const returnData: INodePropertyOptions[] = []; const boardId = parseInt(this.getCurrentNodeParameter('boardId') as string, 10); const body = { - query: - `query ($boardId: Int!) { + query: `query ($boardId: Int!) { boards ( ids: [$boardId]){ groups () { id @@ -266,8 +240,7 @@ export class MondayCom implements INodeType { const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10); const body: IGraphqlBody = { - query: - `mutation ($id: Int!) { + query: `mutation ($id: Int!) { archive_board (board_id: $id) { id } @@ -286,8 +259,7 @@ export class MondayCom implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body: IGraphqlBody = { - query: - `mutation ($name: String!, $kind: BoardKind!, $templateId: Int) { + query: `mutation ($name: String!, $kind: BoardKind!, $templateId: Int) { create_board (board_name: $name, board_kind: $kind, template_id: $templateId) { id } @@ -309,8 +281,7 @@ export class MondayCom implements INodeType { const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10); const body: IGraphqlBody = { - query: - `query ($id: [Int]) { + query: `query ($id: [Int]) { boards (ids: $id){ id name @@ -335,8 +306,7 @@ export class MondayCom implements INodeType { const returnAll = this.getNodeParameter('returnAll', i) as boolean; const body: IGraphqlBody = { - query: - `query ($page: Int, $limit: Int) { + query: `query ($page: Int, $limit: Int) { boards (page: $page, limit: $limit){ id name @@ -371,8 +341,7 @@ export class MondayCom implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body: IGraphqlBody = { - query: - `mutation ($boardId: Int!, $title: String!, $columnType: ColumnType, $defaults: JSON ) { + query: `mutation ($boardId: Int!, $title: String!, $columnType: ColumnType, $defaults: JSON ) { create_column (board_id: $boardId, title: $title, column_type: $columnType, defaults: $defaults) { id } @@ -388,9 +357,13 @@ export class MondayCom implements INodeType { try { JSON.parse(additionalFields.defaults as string); } catch (error) { - throw new NodeOperationError(this.getNode(), 'Defauls must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Defauls must be a valid JSON', { + itemIndex: i, + }); } - body.variables.defaults = JSON.stringify(JSON.parse(additionalFields.defaults as string)); + body.variables.defaults = JSON.stringify( + JSON.parse(additionalFields.defaults as string), + ); } responseData = await mondayComApiRequest.call(this, body); @@ -400,8 +373,7 @@ export class MondayCom implements INodeType { const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10); const body: IGraphqlBody = { - query: - `query ($boardId: [Int]) { + query: `query ($boardId: [Int]) { boards (ids: $boardId){ columns() { id @@ -428,8 +400,7 @@ export class MondayCom implements INodeType { const name = this.getNodeParameter('name', i) as string; const body: IGraphqlBody = { - query: - `mutation ($boardId: Int!, $groupName: String!) { + query: `mutation ($boardId: Int!, $groupName: String!) { create_group (board_id: $boardId, group_name: $groupName) { id } @@ -448,8 +419,7 @@ export class MondayCom implements INodeType { const groupId = this.getNodeParameter('groupId', i) as string; const body: IGraphqlBody = { - query: - `mutation ($boardId: Int!, $groupId: String!) { + query: `mutation ($boardId: Int!, $groupId: String!) { delete_group (board_id: $boardId, group_id: $groupId) { id } @@ -467,8 +437,7 @@ export class MondayCom implements INodeType { const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10); const body: IGraphqlBody = { - query: - `query ($boardId: [Int]) { + query: `query ($boardId: [Int]) { boards (ids: $boardId, ){ id groups() { @@ -491,12 +460,11 @@ export class MondayCom implements INodeType { } if (resource === 'boardItem') { if (operation === 'addUpdate') { - const itemId = parseInt((this.getNodeParameter('itemId', i) as string), 10); + const itemId = parseInt(this.getNodeParameter('itemId', i) as string, 10); const value = this.getNodeParameter('value', i) as string; const body: IGraphqlBody = { - query: - `mutation ($itemId: Int!, $value: String!) { + query: `mutation ($itemId: Int!, $value: String!) { create_update (item_id: $itemId, body: $value) { id } @@ -512,13 +480,12 @@ export class MondayCom implements INodeType { } if (operation === 'changeColumnValue') { const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10); - const itemId = parseInt((this.getNodeParameter('itemId', i) as string), 10); + const itemId = parseInt(this.getNodeParameter('itemId', i) as string, 10); const columnId = this.getNodeParameter('columnId', i) as string; const value = this.getNodeParameter('value', i) as string; const body: IGraphqlBody = { - query: - `mutation ($boardId: Int!, $itemId: Int!, $columnId: String!, $value: JSON!) { + query: `mutation ($boardId: Int!, $itemId: Int!, $columnId: String!, $value: JSON!) { change_column_value (board_id: $boardId, item_id: $itemId, column_id: $columnId, value: $value) { id } @@ -533,7 +500,9 @@ export class MondayCom implements INodeType { try { JSON.parse(value); } catch (error) { - throw new NodeOperationError(this.getNode(), 'Custom Values must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Custom Values must be a valid JSON', { + itemIndex: i, + }); } body.variables.value = JSON.stringify(JSON.parse(value)); @@ -542,12 +511,11 @@ export class MondayCom implements INodeType { } if (operation === 'changeMultipleColumnValues') { const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10); - const itemId = parseInt((this.getNodeParameter('itemId', i) as string), 10); + const itemId = parseInt(this.getNodeParameter('itemId', i) as string, 10); const columnValues = this.getNodeParameter('columnValues', i) as string; const body: IGraphqlBody = { - query: - `mutation ($boardId: Int!, $itemId: Int!, $columnValues: JSON!) { + query: `mutation ($boardId: Int!, $itemId: Int!, $columnValues: JSON!) { change_multiple_column_values (board_id: $boardId, item_id: $itemId, column_values: $columnValues) { id } @@ -561,7 +529,9 @@ export class MondayCom implements INodeType { try { JSON.parse(columnValues); } catch (error) { - throw new NodeOperationError(this.getNode(), 'Custom Values must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Custom Values must be a valid JSON', { + itemIndex: i, + }); } body.variables.columnValues = JSON.stringify(JSON.parse(columnValues)); @@ -575,8 +545,7 @@ export class MondayCom implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body: IGraphqlBody = { - query: - `mutation ($boardId: Int!, $groupId: String!, $itemName: String!, $columnValues: JSON) { + query: `mutation ($boardId: Int!, $groupId: String!, $itemName: String!, $columnValues: JSON) { create_item (board_id: $boardId, group_id: $groupId, item_name: $itemName, column_values: $columnValues) { id } @@ -592,20 +561,23 @@ export class MondayCom implements INodeType { try { JSON.parse(additionalFields.columnValues as string); } catch (error) { - throw new NodeOperationError(this.getNode(), 'Custom Values must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Custom Values must be a valid JSON', { + itemIndex: i, + }); } - body.variables.columnValues = JSON.stringify(JSON.parse(additionalFields.columnValues as string)); + body.variables.columnValues = JSON.stringify( + JSON.parse(additionalFields.columnValues as string), + ); } responseData = await mondayComApiRequest.call(this, body); responseData = responseData.data.create_item; } if (operation === 'delete') { - const itemId = parseInt((this.getNodeParameter('itemId', i) as string), 10); + const itemId = parseInt(this.getNodeParameter('itemId', i) as string, 10); const body: IGraphqlBody = { - query: - `mutation ($itemId: Int!) { + query: `mutation ($itemId: Int!) { delete_item (item_id: $itemId) { id } @@ -618,11 +590,12 @@ export class MondayCom implements INodeType { responseData = responseData.data.delete_item; } if (operation === 'get') { - const itemIds = ((this.getNodeParameter('itemId', i) as string).split(',') as string[]).map((n) => parseInt(n, 10)); + const itemIds = ( + (this.getNodeParameter('itemId', i) as string).split(',') as string[] + ).map((n) => parseInt(n, 10)); const body: IGraphqlBody = { - query: - `query ($itemId: [Int!]){ + query: `query ($itemId: [Int!]){ items (ids: $itemId) { id name @@ -651,8 +624,7 @@ export class MondayCom implements INodeType { const returnAll = this.getNodeParameter('returnAll', i) as boolean; const body: IGraphqlBody = { - query: - `query ($boardId: [Int], $groupId: [String], $page: Int, $limit: Int) { + query: `query ($boardId: [Int], $groupId: [String], $page: Int, $limit: Int) { boards (ids: $boardId) { groups (ids: $groupId) { id @@ -680,13 +652,16 @@ export class MondayCom implements INodeType { }; if (returnAll) { - responseData = await mondayComApiRequestAllItems.call(this, 'data.boards[0].groups[0].items', body); + responseData = await mondayComApiRequestAllItems.call( + this, + 'data.boards[0].groups[0].items', + body, + ); } else { body.variables.limit = this.getNodeParameter('limit', i) as number; responseData = await mondayComApiRequest.call(this, body); responseData = responseData.data.boards[0].groups[0].items; } - } if (operation === 'getByColumnValue') { const boardId = parseInt(this.getNodeParameter('boardId', i) as string, 10); @@ -695,8 +670,7 @@ export class MondayCom implements INodeType { const returnAll = this.getNodeParameter('returnAll', i) as boolean; const body: IGraphqlBody = { - query: - `query ($boardId: Int!, $columnId: String!, $columnValue: String!, $page: Int, $limit: Int ){ + query: `query ($boardId: Int!, $columnId: String!, $columnValue: String!, $page: Int, $limit: Int ){ items_by_column_values (board_id: $boardId, column_id: $columnId, column_value: $columnValue, page: $page, limit: $limit) { id name @@ -723,7 +697,11 @@ export class MondayCom implements INodeType { }; if (returnAll) { - responseData = await mondayComApiRequestAllItems.call(this, 'data.items_by_column_values', body); + responseData = await mondayComApiRequestAllItems.call( + this, + 'data.items_by_column_values', + body, + ); } else { body.variables.limit = this.getNodeParameter('limit', i) as number; responseData = await mondayComApiRequest.call(this, body); @@ -735,8 +713,7 @@ export class MondayCom implements INodeType { const itemId = parseInt(this.getNodeParameter('itemId', i) as string, 10); const body: IGraphqlBody = { - query: - `mutation ($groupId: String!, $itemId: Int!) { + query: `mutation ($groupId: String!, $itemId: Int!) { move_item_to_group (group_id: $groupId, item_id: $itemId) { id } diff --git a/packages/nodes-base/nodes/MongoDb/MongoDb.node.ts b/packages/nodes-base/nodes/MongoDb/MongoDb.node.ts index ac9ad9af95..79664d8fc4 100644 --- a/packages/nodes-base/nodes/MongoDb/MongoDb.node.ts +++ b/packages/nodes-base/nodes/MongoDb/MongoDb.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -8,23 +6,18 @@ import { INodeType, INodeTypeDescription, JsonObject, - NodeOperationError + NodeOperationError, } from 'n8n-workflow'; -import { - nodeDescription, -} from './mongo.node.options'; +import { nodeDescription } from './mongo.node.options'; -import { - MongoClient, - ObjectID, -} from 'mongodb'; +import { MongoClient, ObjectID } from 'mongodb'; import { getItemCopy, handleDateFields, handleDateFieldsWithDotNotation, - validateAndResolveMongoCredentials + validateAndResolveMongoCredentials, } from './mongo.node.utils'; export class MongoDb implements INodeType { @@ -69,7 +62,7 @@ export class MongoDb implements INodeType { returnItems = this.helpers.returnJsonArray(queryResult as IDataObject[]); } catch (error) { if (this.continueOnFail()) { - returnItems = this.helpers.returnJsonArray({ error: (error as JsonObject).message } ); + returnItems = this.helpers.returnJsonArray({ error: (error as JsonObject).message }); } else { throw error; } @@ -92,7 +85,6 @@ export class MongoDb implements INodeType { throw error; } } - } else if (operation === 'find') { // ---------------------------------- // find @@ -127,7 +119,7 @@ export class MongoDb implements INodeType { returnItems = this.helpers.returnJsonArray(queryResult as IDataObject[]); } catch (error) { if (this.continueOnFail()) { - returnItems = this.helpers.returnJsonArray({ error: (error as JsonObject).message } ); + returnItems = this.helpers.returnJsonArray({ error: (error as JsonObject).message }); } else { throw error; } @@ -140,8 +132,8 @@ export class MongoDb implements INodeType { // Prepare the data to insert and copy it to be returned const fields = (this.getNodeParameter('fields', 0) as string) .split(',') - .map(f => f.trim()) - .filter(f => !!f); + .map((f) => f.trim()) + .filter((f) => !!f); const options = this.getNodeParameter('options', 0) as IDataObject; const insertItems = getItemCopy(items, fields); @@ -179,8 +171,8 @@ export class MongoDb implements INodeType { const fields = (this.getNodeParameter('fields', 0) as string) .split(',') - .map(f => f.trim()) - .filter(f => !!f); + .map((f) => f.trim()) + .filter((f) => !!f); const options = this.getNodeParameter('options', 0) as IDataObject; @@ -188,7 +180,8 @@ export class MongoDb implements INodeType { updateKey = updateKey.trim(); const updateOptions = (this.getNodeParameter('upsert', 0) as boolean) - ? { upsert: true } : undefined; + ? { upsert: true } + : undefined; if (!fields.includes(updateKey)) { fields.push(updateKey); @@ -229,9 +222,14 @@ export class MongoDb implements INodeType { returnItems = this.helpers.returnJsonArray(updateItems as IDataObject[]); } else { if (this.continueOnFail()) { - returnItems = this.helpers.returnJsonArray({ json: { error: `The operation "${operation}" is not supported!` } }); + returnItems = this.helpers.returnJsonArray({ + json: { error: `The operation "${operation}" is not supported!` }, + }); } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not supported!`, + ); } } diff --git a/packages/nodes-base/nodes/MongoDb/mongo.node.options.ts b/packages/nodes-base/nodes/MongoDb/mongo.node.options.ts index 3940633e80..d97e40ae27 100644 --- a/packages/nodes-base/nodes/MongoDb/mongo.node.options.ts +++ b/packages/nodes-base/nodes/MongoDb/mongo.node.options.ts @@ -1,7 +1,5 @@ /* eslint-disable n8n-nodes-base/node-filename-against-convention */ -import { - INodeTypeDescription, -} from 'n8n-workflow'; +import { INodeTypeDescription } from 'n8n-workflow'; /** * Options to be displayed @@ -86,9 +84,7 @@ export const nodeDescription: INodeTypeDescription = { }, displayOptions: { show: { - operation: [ - 'aggregate', - ], + operation: ['aggregate'], }, }, default: '', @@ -110,9 +106,7 @@ export const nodeDescription: INodeTypeDescription = { }, displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], }, }, default: '{}', @@ -146,7 +140,8 @@ export const nodeDescription: INodeTypeDescription = { }, default: 0, // eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-limit - description: 'Use limit to specify the maximum number of documents or 0 for unlimited documents', + description: + 'Use limit to specify the maximum number of documents or 0 for unlimited documents', }, { displayName: 'Skip', @@ -177,9 +172,7 @@ export const nodeDescription: INodeTypeDescription = { }, displayOptions: { show: { - operation: [ - 'find', - ], + operation: ['find'], }, }, default: '{}', @@ -197,9 +190,7 @@ export const nodeDescription: INodeTypeDescription = { type: 'string', displayOptions: { show: { - operation: [ - 'insert', - ], + operation: ['insert'], }, }, default: '', @@ -216,15 +207,14 @@ export const nodeDescription: INodeTypeDescription = { type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: 'id', required: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id - description: 'Name of the property which decides which rows in the database should be updated. Normally that would be "id".', + description: + 'Name of the property which decides which rows in the database should be updated. Normally that would be "id".', }, { displayName: 'Fields', @@ -232,9 +222,7 @@ export const nodeDescription: INodeTypeDescription = { type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: '', @@ -259,10 +247,7 @@ export const nodeDescription: INodeTypeDescription = { type: 'collection', displayOptions: { show: { - operation: [ - 'update', - 'insert', - ], + operation: ['update', 'insert'], }, }, placeholder: 'Add Option', @@ -276,7 +261,7 @@ export const nodeDescription: INodeTypeDescription = { description: 'Comma separeted list of fields that will be parse as Mongo Date type', }, { - displayName:'Use Dot Notation', + displayName: 'Use Dot Notation', name: 'useDotNotation', type: 'boolean', default: false, diff --git a/packages/nodes-base/nodes/MongoDb/mongo.node.types.ts b/packages/nodes-base/nodes/MongoDb/mongo.node.types.ts index 212ebc159d..f1a7db0044 100644 --- a/packages/nodes-base/nodes/MongoDb/mongo.node.types.ts +++ b/packages/nodes-base/nodes/MongoDb/mongo.node.types.ts @@ -34,9 +34,7 @@ export interface IMongoOverrideCredentials { /** * Unified credential object type (whether params are overridden with a connection string or not) */ -export type IMongoCredentialsType = - | IMongoParametricCredentials - | IMongoOverrideCredentials; +export type IMongoCredentialsType = IMongoParametricCredentials | IMongoOverrideCredentials; /** * Resolve the database and connection string from input credentials diff --git a/packages/nodes-base/nodes/MongoDb/mongo.node.utils.ts b/packages/nodes-base/nodes/MongoDb/mongo.node.utils.ts index be09378b09..60828d9ab6 100644 --- a/packages/nodes-base/nodes/MongoDb/mongo.node.utils.ts +++ b/packages/nodes-base/nodes/MongoDb/mongo.node.utils.ts @@ -18,9 +18,7 @@ import { get, set } from 'lodash'; * * @param {ICredentialDataDecryptedObject} credentials MongoDB credentials to use, unless conn string is overridden */ -function buildParameterizedConnString( - credentials: IMongoParametricCredentials, -): string { +function buildParameterizedConnString(credentials: IMongoParametricCredentials): string { if (credentials.port) { return `mongodb://${credentials.user}:${credentials.password}@${credentials.host}:${credentials.port}`; } else { @@ -44,16 +42,16 @@ export function buildMongoConnectionParams( ? credentials.database.trim() : ''; if (credentials.configurationType === 'connectionString') { - if ( - credentials.connectionString && - credentials.connectionString.trim().length > 0 - ) { + if (credentials.connectionString && credentials.connectionString.trim().length > 0) { return { connectionString: credentials.connectionString.trim(), database: sanitizedDbName, }; } else { - throw new NodeOperationError(self.getNode(), 'Cannot override credentials: valid MongoDB connection string not provided '); + throw new NodeOperationError( + self.getNode(), + 'Cannot override credentials: valid MongoDB connection string not provided ', + ); } } else { return { @@ -76,10 +74,7 @@ export function validateAndResolveMongoCredentials( if (credentials === undefined) { throw new NodeOperationError(self.getNode(), 'No credentials got returned!'); } else { - return buildMongoConnectionParams( - self, - credentials as unknown as IMongoCredentialsType, - ); + return buildMongoConnectionParams(self, credentials as unknown as IMongoCredentialsType); } } @@ -91,13 +86,10 @@ export function validateAndResolveMongoCredentials( * @param {string[]} properties The properties it should include * @returns */ -export function getItemCopy( - items: INodeExecutionData[], - properties: string[], -): IDataObject[] { +export function getItemCopy(items: INodeExecutionData[], properties: string[]): IDataObject[] { // Prepare the data to insert and copy it to be returned let newItem: IDataObject; - return items.map(item => { + return items.map((item) => { newItem = {}; for (const property of properties) { if (item.json[property] === undefined) { @@ -122,7 +114,7 @@ export function handleDateFields(insertItems: IDataObject[], fields: string) { } export function handleDateFieldsWithDotNotation(insertItems: IDataObject[], fields: string) { - const dateFields = fields.split(',').map(field => field.trim()); + const dateFields = fields.split(',').map((field) => field.trim()); for (let i = 0; i < insertItems.length; i++) { for (const field of dateFields) { diff --git a/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts b/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts index 2d06b12d6c..ad1bb13e8d 100644 --- a/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts @@ -1,22 +1,10 @@ -import { - Credentials, - IExecuteFunctions, -} from 'n8n-core'; +import { Credentials, IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - ILoadOptionsFunctions, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, ILoadOptionsFunctions, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - LoaderGetResponse, -} from './types'; +import { LoaderGetResponse } from './types'; export async function monicaCrmApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, @@ -25,7 +13,11 @@ export async function monicaCrmApiRequest( body: IDataObject = {}, qs: IDataObject = {}, ) { - const credentials = await this.getCredentials('monicaCrmApi') as { apiToken: string, environment: string, domain: string }; + const credentials = (await this.getCredentials('monicaCrmApi')) as { + apiToken: string; + environment: string; + domain: string; + }; if (credentials === undefined) { throw new NodeOperationError(this.getNode(), 'No credentials got returned!'); @@ -96,8 +88,7 @@ export async function monicaCrmApiRequestAllItems( /** * Get day, month, and year from the n8n UI datepicker. */ -export const getDateParts = (date: string) => - date.split('T')[0].split('-').map(Number).reverse(); +export const getDateParts = (date: string) => date.split('T')[0].split('-').map(Number).reverse(); export const toOptions = (response: LoaderGetResponse) => response.data.map(({ id, name }) => ({ value: id, name })); diff --git a/packages/nodes-base/nodes/MonicaCrm/MonicaCrm.node.ts b/packages/nodes-base/nodes/MonicaCrm/MonicaCrm.node.ts index 29e0b09a91..a549bf8121 100644 --- a/packages/nodes-base/nodes/MonicaCrm/MonicaCrm.node.ts +++ b/packages/nodes-base/nodes/MonicaCrm/MonicaCrm.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -44,10 +42,7 @@ import { taskOperations, } from './descriptions'; -import { - LoaderGetResponse, - Option, -} from './types'; +import { LoaderGetResponse, Option } from './types'; export class MonicaCrm implements INodeType { description: INodeTypeDescription = { @@ -158,13 +153,22 @@ export class MonicaCrm implements INodeType { methods = { loadOptions: { async getActivityTypes(this: ILoadOptionsFunctions) { - const responseData = await monicaCrmApiRequest.call(this, 'GET', '/activitytypes') as LoaderGetResponse; + const responseData = (await monicaCrmApiRequest.call( + this, + 'GET', + '/activitytypes', + )) as LoaderGetResponse; return toOptions(responseData); }, async getTagsToAdd(this: ILoadOptionsFunctions) { const responseData = await monicaCrmApiRequestAllItems.call( - this, 'GET', '/tags', {}, {}, { forLoader: true }, + this, + 'GET', + '/tags', + {}, + {}, + { forLoader: true }, ); // intentional, name required when adding @@ -173,18 +177,31 @@ export class MonicaCrm implements INodeType { async getTagsToRemove(this: ILoadOptionsFunctions) { const responseData = await monicaCrmApiRequestAllItems.call( - this, 'GET', '/tags', {}, {}, { forLoader: true }, + this, + 'GET', + '/tags', + {}, + {}, + { forLoader: true }, ); return responseData.map(({ id, name }) => ({ value: id, name })) as Option[]; }, async getContactFieldTypes(this: ILoadOptionsFunctions) { - const responseData = await monicaCrmApiRequest.call(this, 'GET', '/contactfieldtypes') as LoaderGetResponse; + const responseData = (await monicaCrmApiRequest.call( + this, + 'GET', + '/contactfieldtypes', + )) as LoaderGetResponse; return toOptions(responseData); }, async getGenders(this: ILoadOptionsFunctions) { - const responseData = await monicaCrmApiRequest.call(this, 'GET', '/genders') as LoaderGetResponse; + const responseData = (await monicaCrmApiRequest.call( + this, + 'GET', + '/genders', + )) as LoaderGetResponse; return toOptions(responseData); }, }, @@ -200,17 +217,13 @@ export class MonicaCrm implements INodeType { let responseData; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'activity') { - // ********************************************************************** // activity // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // activity: create // ---------------------------------------- @@ -234,9 +247,7 @@ export class MonicaCrm implements INodeType { } responseData = await monicaCrmApiRequest.call(this, 'POST', '/activities', body); - } else if (operation === 'delete') { - // ---------------------------------------- // activity: delete // ---------------------------------------- @@ -248,9 +259,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/activities/${activityId}`; await monicaCrmApiRequest.call(this, 'DELETE', endpoint); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // activity: get // ---------------------------------------- @@ -261,9 +270,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/activities/${activityId}`; responseData = await monicaCrmApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // activity: getAll // ---------------------------------------- @@ -272,9 +279,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/activities`; responseData = await monicaCrmApiRequestAllItems.call(this, 'GET', endpoint); - } else if (operation === 'update') { - // ---------------------------------------- // activity: update // ---------------------------------------- @@ -283,7 +288,11 @@ export class MonicaCrm implements INodeType { const activityId = this.getNodeParameter('activityId', i); - const { data } = await monicaCrmApiRequest.call(this, 'GET', `/activities/${activityId}`); + const { data } = await monicaCrmApiRequest.call( + this, + 'GET', + `/activities/${activityId}`, + ); const body = { activity_type_id: data.activity_type.id, @@ -306,17 +315,13 @@ export class MonicaCrm implements INodeType { const endpoint = `/activities/${activityId}`; responseData = await monicaCrmApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'call') { - // ********************************************************************** // call // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // call: create // ---------------------------------------- @@ -330,9 +335,7 @@ export class MonicaCrm implements INodeType { } as IDataObject; responseData = await monicaCrmApiRequest.call(this, 'POST', '/calls', body); - } else if (operation === 'delete') { - // ---------------------------------------- // call: delete // ---------------------------------------- @@ -343,9 +346,7 @@ export class MonicaCrm implements INodeType { responseData = await monicaCrmApiRequest.call(this, 'DELETE', `/calls/${callId}`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // call: get // ---------------------------------------- @@ -355,9 +356,7 @@ export class MonicaCrm implements INodeType { const callId = this.getNodeParameter('callId', i); responseData = await monicaCrmApiRequest.call(this, 'GET', `/calls/${callId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // call: getAll // ---------------------------------------- @@ -366,9 +365,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/calls`; responseData = await monicaCrmApiRequestAllItems.call(this, 'GET', endpoint); - } else if (operation === 'update') { - // ---------------------------------------- // call: update // ---------------------------------------- @@ -390,17 +387,13 @@ export class MonicaCrm implements INodeType { } responseData = await monicaCrmApiRequest.call(this, 'PUT', `/calls/${callId}`, body); - } - } else if (resource === 'contact') { - // ********************************************************************** // contact // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // contact: create // ---------------------------------------- @@ -451,9 +444,7 @@ export class MonicaCrm implements INodeType { } responseData = await monicaCrmApiRequest.call(this, 'POST', '/contacts', body); - } else if (operation === 'delete') { - // ---------------------------------------- // contact: delete // ---------------------------------------- @@ -465,9 +456,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/contacts/${contactId}`; await monicaCrmApiRequest.call(this, 'DELETE', endpoint); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // contact: get // ---------------------------------------- @@ -478,9 +467,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/contacts/${contactId}`; responseData = await monicaCrmApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // contact: getAll // ---------------------------------------- @@ -495,9 +482,7 @@ export class MonicaCrm implements INodeType { } responseData = await monicaCrmApiRequestAllItems.call(this, 'GET', '/contacts', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // contact: update // ---------------------------------------- @@ -550,17 +535,13 @@ export class MonicaCrm implements INodeType { const endpoint = `/contacts/${contactId}`; responseData = await monicaCrmApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'contactField') { - // ********************************************************************** // contactField // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // contactField: create // ---------------------------------------- @@ -574,9 +555,7 @@ export class MonicaCrm implements INodeType { } as IDataObject; responseData = await monicaCrmApiRequest.call(this, 'POST', '/contactfields', body); - } else if (operation === 'delete') { - // ---------------------------------------- // contactField: delete // ---------------------------------------- @@ -588,9 +567,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/contactfields/${contactFieldId}`; await monicaCrmApiRequest.call(this, 'DELETE', endpoint); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // contactField: get // ---------------------------------------- @@ -601,9 +578,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/contactfields/${contactFieldId}`; responseData = await monicaCrmApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // contactField: getAll // ---------------------------------------- @@ -614,9 +589,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/contact/${contactId}/contactfields`; responseData = await monicaCrmApiRequestAllItems.call(this, 'GET', endpoint); - } else if (operation === 'update') { - // ---------------------------------------- // contactField: update // ---------------------------------------- @@ -633,17 +606,13 @@ export class MonicaCrm implements INodeType { const endpoint = `/contactfields/${contactFieldId}`; responseData = await monicaCrmApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'contactTag') { - // ********************************************************************** // contactTag // ********************************************************************** if (operation === 'add') { - // ---------------------------------------- // contactTag: add // ---------------------------------------- @@ -658,9 +627,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/contacts/${contactId}/setTags`; responseData = await monicaCrmApiRequest.call(this, 'POST', endpoint, body); - } else if (operation === 'remove') { - // ---------------------------------------- // tag: remove // ---------------------------------------- @@ -675,19 +642,13 @@ export class MonicaCrm implements INodeType { const endpoint = `/contacts/${contactId}/unsetTag`; responseData = await monicaCrmApiRequest.call(this, 'POST', endpoint, body); - } - } else if (resource === 'conversation') { - // ********************************************************************** // conversation // ********************************************************************** - - if (operation === 'create') { - // ---------------------------------------- // conversation: create // ---------------------------------------- @@ -701,9 +662,7 @@ export class MonicaCrm implements INodeType { } as IDataObject; responseData = await monicaCrmApiRequest.call(this, 'POST', '/conversations', body); - } else if (operation === 'delete') { - // ---------------------------------------- // conversation: delete // ---------------------------------------- @@ -715,9 +674,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/conversations/${conversationId}`; await monicaCrmApiRequest.call(this, 'DELETE', endpoint); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // conversation: get // ---------------------------------------- @@ -728,9 +685,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/conversations/${conversationId}`; responseData = await monicaCrmApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'update') { - // ---------------------------------------- // conversation: update // ---------------------------------------- @@ -746,11 +701,9 @@ export class MonicaCrm implements INodeType { const endpoint = `/conversations/${conversationId}`; responseData = await monicaCrmApiRequest.call(this, 'PUT', endpoint, body); - } } else if (resource === 'conversationMessage') { if (operation === 'add') { - // ---------------------------------------- // conversationMessage: add // ---------------------------------------- @@ -761,7 +714,11 @@ export class MonicaCrm implements INodeType { const endpoint = `/conversations/${conversationId}/messages`; - const { data } = await monicaCrmApiRequest.call(this, 'GET', `/conversations/${conversationId}`); + const { data } = await monicaCrmApiRequest.call( + this, + 'GET', + `/conversations/${conversationId}`, + ); const body = { contact_id: data.contact.id, @@ -771,9 +728,7 @@ export class MonicaCrm implements INodeType { } as IDataObject; responseData = await monicaCrmApiRequest.call(this, 'POST', endpoint, body); - } else if (operation === 'update') { - // ---------------------------------------- // conversationMessage: update // ---------------------------------------- @@ -785,9 +740,15 @@ export class MonicaCrm implements INodeType { const updateFields = this.getNodeParameter('updateFields', i, {}) as IDataObject; - const { data } = await monicaCrmApiRequest.call(this, 'GET', `/conversations/${conversationId}`); + const { data } = await monicaCrmApiRequest.call( + this, + 'GET', + `/conversations/${conversationId}`, + ); - const message = data.messages.filter((message: IDataObject) => message.id === parseInt(messageId, 10))[0]; + const message = data.messages.filter( + (message: IDataObject) => message.id === parseInt(messageId, 10), + )[0]; const body = { contact_id: data.contact.id, @@ -802,15 +763,12 @@ export class MonicaCrm implements INodeType { responseData = await monicaCrmApiRequest.call(this, 'PUT', endpoint, body); } - } else if (resource === 'journalEntry') { - // ********************************************************************** // journalEntry // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // journalEntry: create // ---------------------------------------- @@ -823,9 +781,7 @@ export class MonicaCrm implements INodeType { } as IDataObject; responseData = await monicaCrmApiRequest.call(this, 'POST', '/journal', body); - } else if (operation === 'delete') { - // ---------------------------------------- // journalEntry: delete // ---------------------------------------- @@ -836,9 +792,7 @@ export class MonicaCrm implements INodeType { await monicaCrmApiRequest.call(this, 'DELETE', `/journal/${journalId}`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // journalEntry: get // ---------------------------------------- @@ -848,9 +802,7 @@ export class MonicaCrm implements INodeType { const journalId = this.getNodeParameter('journalId', i); responseData = await monicaCrmApiRequest.call(this, 'GET', `/journal/${journalId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // journalEntry: getAll // ---------------------------------------- @@ -858,9 +810,7 @@ export class MonicaCrm implements INodeType { // https://www.monicahq.com/api/journal#list-all-the-entries-in-your-journal responseData = await monicaCrmApiRequestAllItems.call(this, 'GET', '/journal'); - } else if (operation === 'update') { - // ---------------------------------------- // journalEntry: update // ---------------------------------------- @@ -882,18 +832,19 @@ export class MonicaCrm implements INodeType { Object.assign(body, updateFields); } - responseData = await monicaCrmApiRequest.call(this, 'PUT', `/journal/${journalId}`, body); - + responseData = await monicaCrmApiRequest.call( + this, + 'PUT', + `/journal/${journalId}`, + body, + ); } - } else if (resource === 'note') { - // ********************************************************************** // note // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // note: create // ---------------------------------------- @@ -908,9 +859,7 @@ export class MonicaCrm implements INodeType { body.is_favorited = this.getNodeParameter('additionalFields.isFavorited', i, false); responseData = await monicaCrmApiRequest.call(this, 'POST', '/notes', body); - } else if (operation === 'delete') { - // ---------------------------------------- // note: delete // ---------------------------------------- @@ -921,9 +870,7 @@ export class MonicaCrm implements INodeType { await monicaCrmApiRequest.call(this, 'DELETE', `/notes/${noteId}`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // note: get // ---------------------------------------- @@ -933,9 +880,7 @@ export class MonicaCrm implements INodeType { const noteId = this.getNodeParameter('noteId', i); responseData = await monicaCrmApiRequest.call(this, 'GET', `/notes/${noteId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // note: getAll // ---------------------------------------- @@ -944,9 +889,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/notes`; responseData = await monicaCrmApiRequestAllItems.call(this, 'GET', endpoint); - } else if (operation === 'update') { - // ---------------------------------------- // note: update // ---------------------------------------- @@ -964,23 +907,18 @@ export class MonicaCrm implements INodeType { contact_id: data.contact.id, } as IDataObject; - if (Object.keys(updateFields).length) { Object.assign(body, updateFields); } responseData = await monicaCrmApiRequest.call(this, 'PUT', `/notes/${noteId}`, body); - } - } else if (resource === 'reminder') { - // ********************************************************************** // reminder // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // reminder: create // ---------------------------------------- @@ -1004,9 +942,7 @@ export class MonicaCrm implements INodeType { } responseData = await monicaCrmApiRequest.call(this, 'POST', '/reminders', body); - } else if (operation === 'delete') { - // ---------------------------------------- // reminder: delete // ---------------------------------------- @@ -1018,9 +954,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/reminders/${reminderId}`; await monicaCrmApiRequest.call(this, 'DELETE', endpoint); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // reminder: get // ---------------------------------------- @@ -1031,9 +965,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/reminders/${reminderId}`; responseData = await monicaCrmApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // reminder: getAll // ---------------------------------------- @@ -1041,9 +973,7 @@ export class MonicaCrm implements INodeType { // https://www.monicahq.com/api/reminders#list-all-the-reminders-in-your-account responseData = await monicaCrmApiRequestAllItems.call(this, 'GET', '/reminders'); - } else if (operation === 'update') { - // ---------------------------------------- // reminder: update // ---------------------------------------- @@ -1052,7 +982,11 @@ export class MonicaCrm implements INodeType { const reminderId = this.getNodeParameter('reminderId', i); - const { data } = await monicaCrmApiRequest.call(this, 'GET', `/reminders/${reminderId}`); + const { data } = await monicaCrmApiRequest.call( + this, + 'GET', + `/reminders/${reminderId}`, + ); const body = { contact_id: data.contact.id, @@ -1072,17 +1006,13 @@ export class MonicaCrm implements INodeType { const endpoint = `/reminders/${reminderId}`; responseData = await monicaCrmApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'tag') { - // ********************************************************************** // tag // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // tag: create // ---------------------------------------- @@ -1094,9 +1024,7 @@ export class MonicaCrm implements INodeType { } as IDataObject; responseData = await monicaCrmApiRequest.call(this, 'POST', '/tags', body); - } else if (operation === 'delete') { - // ---------------------------------------- // tag: delete // ---------------------------------------- @@ -1107,9 +1035,7 @@ export class MonicaCrm implements INodeType { await monicaCrmApiRequest.call(this, 'DELETE', `/tags/${tagId}`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // tag: get // ---------------------------------------- @@ -1119,9 +1045,7 @@ export class MonicaCrm implements INodeType { const tagId = this.getNodeParameter('tagId', i); responseData = await monicaCrmApiRequest.call(this, 'GET', `/tags/${tagId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // tag: getAll // ---------------------------------------- @@ -1129,9 +1053,7 @@ export class MonicaCrm implements INodeType { // https://www.monicahq.com/api/tags#list-all-your-tags responseData = await monicaCrmApiRequestAllItems.call(this, 'GET', '/tags'); - } else if (operation === 'update') { - // ---------------------------------------- // tag: update // ---------------------------------------- @@ -1145,17 +1067,13 @@ export class MonicaCrm implements INodeType { const tagId = this.getNodeParameter('tagId', i); responseData = await monicaCrmApiRequest.call(this, 'PUT', `/tags/${tagId}`, body); - } - } else if (resource === 'task') { - // ********************************************************************** // task // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // task: create // ---------------------------------------- @@ -1174,9 +1092,7 @@ export class MonicaCrm implements INodeType { } responseData = await monicaCrmApiRequest.call(this, 'POST', '/tasks', body); - } else if (operation === 'delete') { - // ---------------------------------------- // task: delete // ---------------------------------------- @@ -1187,9 +1103,7 @@ export class MonicaCrm implements INodeType { await monicaCrmApiRequest.call(this, 'DELETE', `/tasks/${taskId}`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // task: get // ---------------------------------------- @@ -1199,9 +1113,7 @@ export class MonicaCrm implements INodeType { const taskId = this.getNodeParameter('taskId', i); responseData = await monicaCrmApiRequest.call(this, 'GET', `/tasks/${taskId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // task: getAll // ---------------------------------------- @@ -1210,9 +1122,7 @@ export class MonicaCrm implements INodeType { const endpoint = `/tasks`; responseData = await monicaCrmApiRequestAllItems.call(this, 'GET', endpoint); - } else if (operation === 'update') { - // ---------------------------------------- // task: update // ---------------------------------------- @@ -1237,9 +1147,7 @@ export class MonicaCrm implements INodeType { responseData = await monicaCrmApiRequest.call(this, 'PUT', `/tasks/${taskId}`, body); } - } - } catch (error) { if (this.continueOnFail()) { returnData.push({ json: { error: error.message } }); @@ -1249,19 +1157,13 @@ export class MonicaCrm implements INodeType { throw error; } - if ([ - 'create', - 'get', - 'update', - 'add', - ].includes(operation)) { + if (['create', 'get', 'update', 'add'].includes(operation)) { responseData = responseData.data; } Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/MonicaCrm/descriptions/ActivityDescription.ts b/packages/nodes-base/nodes/MonicaCrm/descriptions/ActivityDescription.ts index dcda223af9..b436d0aeae 100644 --- a/packages/nodes-base/nodes/MonicaCrm/descriptions/ActivityDescription.ts +++ b/packages/nodes-base/nodes/MonicaCrm/descriptions/ActivityDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const activityOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const activityOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'activity', - ], + resource: ['activity'], }, }, options: [ @@ -59,7 +55,8 @@ export const activityFields: INodeProperties[] = [ displayName: 'Activity Type Name or ID', name: 'activityTypeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, default: '', typeOptions: { @@ -67,12 +64,8 @@ export const activityFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, }, @@ -85,12 +78,8 @@ export const activityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, }, @@ -103,12 +92,8 @@ export const activityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, }, @@ -121,12 +106,8 @@ export const activityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, }, @@ -138,12 +119,8 @@ export const activityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, options: [ @@ -172,12 +149,8 @@ export const activityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'delete', - ], + resource: ['activity'], + operation: ['delete'], }, }, }, @@ -194,12 +167,8 @@ export const activityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'get', - ], + resource: ['activity'], + operation: ['get'], }, }, }, @@ -215,12 +184,8 @@ export const activityFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getAll', - ], + resource: ['activity'], + operation: ['getAll'], }, }, }, @@ -235,15 +200,9 @@ export const activityFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['activity'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -260,12 +219,8 @@ export const activityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'update', - ], + resource: ['activity'], + operation: ['update'], }, }, }, @@ -277,12 +232,8 @@ export const activityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'update', - ], + resource: ['activity'], + operation: ['update'], }, }, options: [ @@ -290,7 +241,8 @@ export const activityFields: INodeProperties[] = [ displayName: 'Activity Type Name or ID', name: 'activity_type_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getActivityTypes', diff --git a/packages/nodes-base/nodes/MonicaCrm/descriptions/CallDescription.ts b/packages/nodes-base/nodes/MonicaCrm/descriptions/CallDescription.ts index ff29357df8..44b4ae8c1e 100644 --- a/packages/nodes-base/nodes/MonicaCrm/descriptions/CallDescription.ts +++ b/packages/nodes-base/nodes/MonicaCrm/descriptions/CallDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const callOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const callOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'call', - ], + resource: ['call'], }, }, options: [ @@ -64,12 +60,8 @@ export const callFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'call', - ], - operation: [ - 'create', - ], + resource: ['call'], + operation: ['create'], }, }, }, @@ -82,12 +74,8 @@ export const callFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'call', - ], - operation: [ - 'create', - ], + resource: ['call'], + operation: ['create'], }, }, }, @@ -103,12 +91,8 @@ export const callFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'call', - ], - operation: [ - 'create', - ], + resource: ['call'], + operation: ['create'], }, }, }, @@ -125,12 +109,8 @@ export const callFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'call', - ], - operation: [ - 'delete', - ], + resource: ['call'], + operation: ['delete'], }, }, }, @@ -147,12 +127,8 @@ export const callFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'call', - ], - operation: [ - 'get', - ], + resource: ['call'], + operation: ['get'], }, }, }, @@ -168,12 +144,8 @@ export const callFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'call', - ], - operation: [ - 'getAll', - ], + resource: ['call'], + operation: ['getAll'], }, }, }, @@ -188,15 +160,9 @@ export const callFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'call', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['call'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -213,12 +179,8 @@ export const callFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'call', - ], - operation: [ - 'update', - ], + resource: ['call'], + operation: ['update'], }, }, }, @@ -230,12 +192,8 @@ export const callFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'call', - ], - operation: [ - 'update', - ], + resource: ['call'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/MonicaCrm/descriptions/ContactDescription.ts b/packages/nodes-base/nodes/MonicaCrm/descriptions/ContactDescription.ts index fa3a0ee867..8565c6c92e 100644 --- a/packages/nodes-base/nodes/MonicaCrm/descriptions/ContactDescription.ts +++ b/packages/nodes-base/nodes/MonicaCrm/descriptions/ContactDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const contactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contact', - ], + resource: ['contact'], }, }, options: [ @@ -63,12 +59,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, }, @@ -76,7 +68,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Gender Name or ID', name: 'genderId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, default: '', typeOptions: { @@ -84,12 +77,8 @@ export const contactFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, }, @@ -101,12 +90,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, options: [ @@ -174,12 +159,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'delete', - ], + resource: ['contact'], + operation: ['delete'], }, }, }, @@ -196,12 +177,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], + resource: ['contact'], + operation: ['get'], }, }, }, @@ -217,12 +194,8 @@ export const contactFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, }, @@ -237,15 +210,9 @@ export const contactFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['contact'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -290,12 +257,8 @@ export const contactFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, }, @@ -312,12 +275,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, }, @@ -329,12 +288,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, options: [ @@ -360,7 +315,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Gender Name or ID', name: 'gender_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getGenders', diff --git a/packages/nodes-base/nodes/MonicaCrm/descriptions/ContactFieldDescription.ts b/packages/nodes-base/nodes/MonicaCrm/descriptions/ContactFieldDescription.ts index dca191dd85..b8b7b11aac 100644 --- a/packages/nodes-base/nodes/MonicaCrm/descriptions/ContactFieldDescription.ts +++ b/packages/nodes-base/nodes/MonicaCrm/descriptions/ContactFieldDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactFieldOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const contactFieldOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contactField', - ], + resource: ['contactField'], }, }, options: [ @@ -63,12 +59,8 @@ export const contactFieldFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contactField', - ], - operation: [ - 'create', - ], + resource: ['contactField'], + operation: ['create'], }, }, }, @@ -76,7 +68,8 @@ export const contactFieldFields: INodeProperties[] = [ displayName: 'Contact Field Type Name or ID', name: 'contactFieldTypeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getContactFieldTypes', @@ -84,12 +77,8 @@ export const contactFieldFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contactField', - ], - operation: [ - 'create', - ], + resource: ['contactField'], + operation: ['create'], }, }, }, @@ -102,12 +91,8 @@ export const contactFieldFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contactField', - ], - operation: [ - 'create', - ], + resource: ['contactField'], + operation: ['create'], }, }, }, @@ -124,12 +109,8 @@ export const contactFieldFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contactField', - ], - operation: [ - 'delete', - ], + resource: ['contactField'], + operation: ['delete'], }, }, }, @@ -146,12 +127,8 @@ export const contactFieldFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contactField', - ], - operation: [ - 'get', - ], + resource: ['contactField'], + operation: ['get'], }, }, }, @@ -168,12 +145,8 @@ export const contactFieldFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contactField', - ], - operation: [ - 'getAll', - ], + resource: ['contactField'], + operation: ['getAll'], }, }, }, @@ -185,12 +158,8 @@ export const contactFieldFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'contactField', - ], - operation: [ - 'getAll', - ], + resource: ['contactField'], + operation: ['getAll'], }, }, }, @@ -205,15 +174,9 @@ export const contactFieldFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'contactField', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['contactField'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -230,12 +193,8 @@ export const contactFieldFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contactField', - ], - operation: [ - 'update', - ], + resource: ['contactField'], + operation: ['update'], }, }, }, @@ -248,12 +207,8 @@ export const contactFieldFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contactField', - ], - operation: [ - 'update', - ], + resource: ['contactField'], + operation: ['update'], }, }, }, @@ -261,7 +216,8 @@ export const contactFieldFields: INodeProperties[] = [ displayName: 'Contact Field Type Name or ID', name: 'contactFieldTypeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getContactFieldTypes', }, @@ -269,12 +225,8 @@ export const contactFieldFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contactField', - ], - operation: [ - 'update', - ], + resource: ['contactField'], + operation: ['update'], }, }, }, @@ -287,12 +239,8 @@ export const contactFieldFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contactField', - ], - operation: [ - 'update', - ], + resource: ['contactField'], + operation: ['update'], }, }, }, diff --git a/packages/nodes-base/nodes/MonicaCrm/descriptions/ContactTagDescription.ts b/packages/nodes-base/nodes/MonicaCrm/descriptions/ContactTagDescription.ts index 9dbc98df38..60554f7e52 100644 --- a/packages/nodes-base/nodes/MonicaCrm/descriptions/ContactTagDescription.ts +++ b/packages/nodes-base/nodes/MonicaCrm/descriptions/ContactTagDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactTagOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const contactTagOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contactTag', - ], + resource: ['contactTag'], }, }, options: [ @@ -44,19 +40,16 @@ export const contactTagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contactTag', - ], - operation: [ - 'add', - ], + resource: ['contactTag'], + operation: ['add'], }, }, }, { displayName: 'Tag Names or IDs', name: 'tagsToAdd', - description: 'Tags to add to the contact. Choose from the list, or specify IDs using an expression.', + description: + 'Tags to add to the contact. Choose from the list, or specify IDs using an expression.', type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getTagsToAdd', @@ -65,12 +58,8 @@ export const contactTagFields: INodeProperties[] = [ default: [], displayOptions: { show: { - resource: [ - 'contactTag', - ], - operation: [ - 'add', - ], + resource: ['contactTag'], + operation: ['add'], }, }, }, @@ -87,19 +76,16 @@ export const contactTagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contactTag', - ], - operation: [ - 'remove', - ], + resource: ['contactTag'], + operation: ['remove'], }, }, }, { displayName: 'Tag Names or IDs', name: 'tagsToRemove', - description: 'Tags to remove from the contact. Choose from the list, or specify IDs using an expression.', + description: + 'Tags to remove from the contact. Choose from the list, or specify IDs using an expression.', type: 'multiOptions', required: true, typeOptions: { @@ -108,12 +94,8 @@ export const contactTagFields: INodeProperties[] = [ default: [], displayOptions: { show: { - resource: [ - 'contactTag', - ], - operation: [ - 'remove', - ], + resource: ['contactTag'], + operation: ['remove'], }, }, }, diff --git a/packages/nodes-base/nodes/MonicaCrm/descriptions/ConversationDescription.ts b/packages/nodes-base/nodes/MonicaCrm/descriptions/ConversationDescription.ts index 3f71c2c854..9c78c5306a 100644 --- a/packages/nodes-base/nodes/MonicaCrm/descriptions/ConversationDescription.ts +++ b/packages/nodes-base/nodes/MonicaCrm/descriptions/ConversationDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const conversationOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const conversationOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'conversation', - ], + resource: ['conversation'], }, }, options: [ @@ -58,12 +54,8 @@ export const conversationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'conversation', - ], - operation: [ - 'create', - ], + resource: ['conversation'], + operation: ['create'], }, }, }, @@ -71,7 +63,8 @@ export const conversationFields: INodeProperties[] = [ displayName: 'Contact Field Type Name or ID', name: 'contactFieldTypeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, default: '', typeOptions: { @@ -79,12 +72,8 @@ export const conversationFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'conversation', - ], - operation: [ - 'create', - ], + resource: ['conversation'], + operation: ['create'], }, }, }, @@ -97,12 +86,8 @@ export const conversationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'conversation', - ], - operation: [ - 'create', - ], + resource: ['conversation'], + operation: ['create'], }, }, }, @@ -119,12 +104,8 @@ export const conversationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'conversation', - ], - operation: [ - 'delete', - ], + resource: ['conversation'], + operation: ['delete'], }, }, }, @@ -141,12 +122,8 @@ export const conversationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'conversation', - ], - operation: [ - 'get', - ], + resource: ['conversation'], + operation: ['get'], }, }, }, @@ -163,12 +140,8 @@ export const conversationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'conversation', - ], - operation: [ - 'update', - ], + resource: ['conversation'], + operation: ['update'], }, }, }, @@ -176,7 +149,8 @@ export const conversationFields: INodeProperties[] = [ displayName: 'Contact Field Type Name or ID', name: 'contactFieldTypeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, default: '', typeOptions: { @@ -184,12 +158,8 @@ export const conversationFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'conversation', - ], - operation: [ - 'update', - ], + resource: ['conversation'], + operation: ['update'], }, }, }, @@ -202,12 +172,8 @@ export const conversationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'conversation', - ], - operation: [ - 'update', - ], + resource: ['conversation'], + operation: ['update'], }, }, }, diff --git a/packages/nodes-base/nodes/MonicaCrm/descriptions/ConversationMessageDescription.ts b/packages/nodes-base/nodes/MonicaCrm/descriptions/ConversationMessageDescription.ts index 72148a2a12..03a03f88a0 100644 --- a/packages/nodes-base/nodes/MonicaCrm/descriptions/ConversationMessageDescription.ts +++ b/packages/nodes-base/nodes/MonicaCrm/descriptions/ConversationMessageDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const conversationMessageOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const conversationMessageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'conversationMessage', - ], + resource: ['conversationMessage'], }, }, options: [ @@ -46,12 +42,8 @@ export const conversationMessageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'conversationMessage', - ], - operation: [ - 'add', - ], + resource: ['conversationMessage'], + operation: ['add'], }, }, }, @@ -64,12 +56,8 @@ export const conversationMessageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'conversationMessage', - ], - operation: [ - 'add', - ], + resource: ['conversationMessage'], + operation: ['add'], }, }, }, @@ -82,12 +70,8 @@ export const conversationMessageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'conversationMessage', - ], - operation: [ - 'add', - ], + resource: ['conversationMessage'], + operation: ['add'], }, }, }, @@ -110,12 +94,8 @@ export const conversationMessageFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'conversationMessage', - ], - operation: [ - 'add', - ], + resource: ['conversationMessage'], + operation: ['add'], }, }, }, @@ -132,12 +112,8 @@ export const conversationMessageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'conversationMessage', - ], - operation: [ - 'update', - ], + resource: ['conversationMessage'], + operation: ['update'], }, }, }, @@ -150,12 +126,8 @@ export const conversationMessageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'conversationMessage', - ], - operation: [ - 'update', - ], + resource: ['conversationMessage'], + operation: ['update'], }, }, }, @@ -167,12 +139,8 @@ export const conversationMessageFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'conversationMessage', - ], - operation: [ - 'update', - ], + resource: ['conversationMessage'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/MonicaCrm/descriptions/JournalEntryDescription.ts b/packages/nodes-base/nodes/MonicaCrm/descriptions/JournalEntryDescription.ts index f3a30dcf3a..302221546b 100644 --- a/packages/nodes-base/nodes/MonicaCrm/descriptions/JournalEntryDescription.ts +++ b/packages/nodes-base/nodes/MonicaCrm/descriptions/JournalEntryDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const journalEntryOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const journalEntryOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'journalEntry', - ], + resource: ['journalEntry'], }, }, options: [ @@ -64,12 +60,8 @@ export const journalEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'journalEntry', - ], - operation: [ - 'create', - ], + resource: ['journalEntry'], + operation: ['create'], }, }, }, @@ -85,12 +77,8 @@ export const journalEntryFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'journalEntry', - ], - operation: [ - 'create', - ], + resource: ['journalEntry'], + operation: ['create'], }, }, }, @@ -107,12 +95,8 @@ export const journalEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'journalEntry', - ], - operation: [ - 'delete', - ], + resource: ['journalEntry'], + operation: ['delete'], }, }, }, @@ -129,12 +113,8 @@ export const journalEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'journalEntry', - ], - operation: [ - 'get', - ], + resource: ['journalEntry'], + operation: ['get'], }, }, }, @@ -150,12 +130,8 @@ export const journalEntryFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'journalEntry', - ], - operation: [ - 'getAll', - ], + resource: ['journalEntry'], + operation: ['getAll'], }, }, }, @@ -170,15 +146,9 @@ export const journalEntryFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'journalEntry', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['journalEntry'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -195,12 +165,8 @@ export const journalEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'journalEntry', - ], - operation: [ - 'update', - ], + resource: ['journalEntry'], + operation: ['update'], }, }, }, @@ -212,12 +178,8 @@ export const journalEntryFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'journalEntry', - ], - operation: [ - 'update', - ], + resource: ['journalEntry'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/MonicaCrm/descriptions/NoteDescription.ts b/packages/nodes-base/nodes/MonicaCrm/descriptions/NoteDescription.ts index 668044226c..4e91d29ee6 100644 --- a/packages/nodes-base/nodes/MonicaCrm/descriptions/NoteDescription.ts +++ b/packages/nodes-base/nodes/MonicaCrm/descriptions/NoteDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const noteOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const noteOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'note', - ], + resource: ['note'], }, }, options: [ @@ -64,12 +60,8 @@ export const noteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'create', - ], + resource: ['note'], + operation: ['create'], }, }, }, @@ -85,12 +77,8 @@ export const noteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'create', - ], + resource: ['note'], + operation: ['create'], }, }, }, @@ -102,12 +90,8 @@ export const noteFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'create', - ], + resource: ['note'], + operation: ['create'], }, }, options: [ @@ -133,12 +117,8 @@ export const noteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'delete', - ], + resource: ['note'], + operation: ['delete'], }, }, }, @@ -155,12 +135,8 @@ export const noteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'get', - ], + resource: ['note'], + operation: ['get'], }, }, }, @@ -176,12 +152,8 @@ export const noteFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'getAll', - ], + resource: ['note'], + operation: ['getAll'], }, }, }, @@ -196,15 +168,9 @@ export const noteFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['note'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -221,12 +187,8 @@ export const noteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'update', - ], + resource: ['note'], + operation: ['update'], }, }, }, @@ -238,12 +200,8 @@ export const noteFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'update', - ], + resource: ['note'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/MonicaCrm/descriptions/ReminderDescription.ts b/packages/nodes-base/nodes/MonicaCrm/descriptions/ReminderDescription.ts index 25b46439be..1049371a3c 100644 --- a/packages/nodes-base/nodes/MonicaCrm/descriptions/ReminderDescription.ts +++ b/packages/nodes-base/nodes/MonicaCrm/descriptions/ReminderDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const reminderOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const reminderOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'reminder', - ], + resource: ['reminder'], }, }, options: [ @@ -63,12 +59,8 @@ export const reminderFields: INodeProperties[] = [ description: 'ID of the contact to associate the reminder with', displayOptions: { show: { - resource: [ - 'reminder', - ], - operation: [ - 'create', - ], + resource: ['reminder'], + operation: ['create'], }, }, }, @@ -99,12 +91,8 @@ export const reminderFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'reminder', - ], - operation: [ - 'create', - ], + resource: ['reminder'], + operation: ['create'], }, }, }, @@ -116,17 +104,9 @@ export const reminderFields: INodeProperties[] = [ description: 'Interval for the reminder', displayOptions: { show: { - resource: [ - 'reminder', - ], - operation: [ - 'create', - ], - frequencyType: [ - 'week', - 'month', - 'year', - ], + resource: ['reminder'], + operation: ['create'], + frequencyType: ['week', 'month', 'year'], }, }, }, @@ -139,12 +119,8 @@ export const reminderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'reminder', - ], - operation: [ - 'create', - ], + resource: ['reminder'], + operation: ['create'], }, }, }, @@ -157,12 +133,8 @@ export const reminderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'reminder', - ], - operation: [ - 'create', - ], + resource: ['reminder'], + operation: ['create'], }, }, }, @@ -174,12 +146,8 @@ export const reminderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'reminder', - ], - operation: [ - 'create', - ], + resource: ['reminder'], + operation: ['create'], }, }, options: [ @@ -208,12 +176,8 @@ export const reminderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'reminder', - ], - operation: [ - 'delete', - ], + resource: ['reminder'], + operation: ['delete'], }, }, }, @@ -230,12 +194,8 @@ export const reminderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'reminder', - ], - operation: [ - 'get', - ], + resource: ['reminder'], + operation: ['get'], }, }, }, @@ -251,12 +211,8 @@ export const reminderFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'reminder', - ], - operation: [ - 'getAll', - ], + resource: ['reminder'], + operation: ['getAll'], }, }, }, @@ -271,15 +227,9 @@ export const reminderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'reminder', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['reminder'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -296,12 +246,8 @@ export const reminderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'reminder', - ], - operation: [ - 'update', - ], + resource: ['reminder'], + operation: ['update'], }, }, }, @@ -313,12 +259,8 @@ export const reminderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'reminder', - ], - operation: [ - 'update', - ], + resource: ['reminder'], + operation: ['update'], }, }, options: [ @@ -379,11 +321,7 @@ export const reminderFields: INodeProperties[] = [ description: 'Interval for the reminder', displayOptions: { show: { - frequency_type: [ - 'week', - 'month', - 'year', - ], + frequency_type: ['week', 'month', 'year'], }, }, }, diff --git a/packages/nodes-base/nodes/MonicaCrm/descriptions/TagDescription.ts b/packages/nodes-base/nodes/MonicaCrm/descriptions/TagDescription.ts index 0fc3afbccd..bbf1790d8b 100644 --- a/packages/nodes-base/nodes/MonicaCrm/descriptions/TagDescription.ts +++ b/packages/nodes-base/nodes/MonicaCrm/descriptions/TagDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const tagOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const tagOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'tag', - ], + resource: ['tag'], }, }, options: [ @@ -64,12 +60,8 @@ export const tagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'create', - ], + resource: ['tag'], + operation: ['create'], }, }, }, @@ -86,12 +78,8 @@ export const tagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'delete', - ], + resource: ['tag'], + operation: ['delete'], }, }, }, @@ -108,12 +96,8 @@ export const tagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'get', - ], + resource: ['tag'], + operation: ['get'], }, }, }, @@ -129,12 +113,8 @@ export const tagFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'getAll', - ], + resource: ['tag'], + operation: ['getAll'], }, }, }, @@ -149,15 +129,9 @@ export const tagFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['tag'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -174,12 +148,8 @@ export const tagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'update', - ], + resource: ['tag'], + operation: ['update'], }, }, }, @@ -192,12 +162,8 @@ export const tagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'update', - ], + resource: ['tag'], + operation: ['update'], }, }, }, diff --git a/packages/nodes-base/nodes/MonicaCrm/descriptions/TaskDescription.ts b/packages/nodes-base/nodes/MonicaCrm/descriptions/TaskDescription.ts index cdf2e7d194..cafb168e93 100644 --- a/packages/nodes-base/nodes/MonicaCrm/descriptions/TaskDescription.ts +++ b/packages/nodes-base/nodes/MonicaCrm/descriptions/TaskDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const taskOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const taskOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'task', - ], + resource: ['task'], }, }, options: [ @@ -64,12 +60,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, }, @@ -82,12 +74,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, }, @@ -99,12 +87,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, options: [ @@ -133,12 +117,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'delete', - ], + resource: ['task'], + operation: ['delete'], }, }, }, @@ -155,12 +135,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'get', - ], + resource: ['task'], + operation: ['get'], }, }, }, @@ -176,12 +152,8 @@ export const taskFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, }, @@ -196,15 +168,9 @@ export const taskFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['task'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -221,12 +187,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, }, @@ -238,12 +200,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/MonicaCrm/types.d.ts b/packages/nodes-base/nodes/MonicaCrm/types.d.ts index 96361ec2f0..12a4499182 100644 --- a/packages/nodes-base/nodes/MonicaCrm/types.d.ts +++ b/packages/nodes-base/nodes/MonicaCrm/types.d.ts @@ -1,10 +1,10 @@ -import { IDataObject } from "n8n-workflow"; +import { IDataObject } from 'n8n-workflow'; export type LoaderGetResponse = { data: Array<{ id: string; name: string; - }> + }>; } & IDataObject; export type Option = { diff --git a/packages/nodes-base/nodes/MoveBinaryData/MoveBinaryData.node.ts b/packages/nodes-base/nodes/MoveBinaryData/MoveBinaryData.node.ts index f380f9c676..120dc7d3ca 100644 --- a/packages/nodes-base/nodes/MoveBinaryData/MoveBinaryData.node.ts +++ b/packages/nodes-base/nodes/MoveBinaryData/MoveBinaryData.node.ts @@ -1,12 +1,6 @@ -import { - get, - set, - unset, -} from 'lodash'; +import { get, set, unset } from 'lodash'; -import { - BINARY_ENCODING, -} from 'n8n-core'; +import { BINARY_ENCODING } from 'n8n-core'; import { IExecuteFunctions } from 'n8n-core'; import { @@ -26,8 +20,9 @@ iconv.encodingExists('utf8'); const bomAware: string[] = []; const encodeDecodeOptions: INodePropertyOptions[] = []; const encodings = (iconv as any).encodings; // tslint:disable-line:no-any -Object.keys(encodings).forEach(encoding => { - if (!(encoding.startsWith('_') || typeof encodings[encoding] === 'string')) { // only encodings without direct alias or internals +Object.keys(encodings).forEach((encoding) => { + if (!(encoding.startsWith('_') || typeof encodings[encoding] === 'string')) { + // only encodings without direct alias or internals if (encodings[encoding].bomAware) { bomAware.push(encoding); } @@ -36,8 +31,12 @@ Object.keys(encodings).forEach(encoding => { }); encodeDecodeOptions.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -77,7 +76,6 @@ export class MoveBinaryData implements INodeType { description: 'From and to where data should be moved', }, - // ---------------------------------- // binaryToJson // ---------------------------------- @@ -87,13 +85,12 @@ export class MoveBinaryData implements INodeType { type: 'boolean', displayOptions: { show: { - mode: [ - 'binaryToJson', - ], + mode: ['binaryToJson'], }, }, default: true, - description: 'Whether all JSON data should be replaced with the data retrieved from binary key. Else the data will be written to a single key.', + description: + 'Whether all JSON data should be replaced with the data retrieved from binary key. Else the data will be written to a single key.', }, { displayName: 'Source Key', @@ -101,15 +98,14 @@ export class MoveBinaryData implements INodeType { type: 'string', displayOptions: { show: { - mode: [ - 'binaryToJson', - ], + mode: ['binaryToJson'], }, }, default: 'data', required: true, placeholder: 'data', - description: 'The name of the binary key to get data from. It is also possible to define deep keys by using dot-notation like for example: "level1.level2.currentKey".', + description: + 'The name of the binary key to get data from. It is also possible to define deep keys by using dot-notation like for example: "level1.level2.currentKey".', }, { displayName: 'Destination Key', @@ -117,18 +113,15 @@ export class MoveBinaryData implements INodeType { type: 'string', displayOptions: { show: { - mode: [ - 'binaryToJson', - ], - setAllData: [ - false, - ], + mode: ['binaryToJson'], + setAllData: [false], }, }, default: 'data', required: true, placeholder: '', - description: 'The name the JSON key to copy data to. It is also possible to define deep keys by using dot-notation like for example: "level1.level2.newKey".', + description: + 'The name the JSON key to copy data to. It is also possible to define deep keys by using dot-notation like for example: "level1.level2.newKey".', }, // ---------------------------------- @@ -140,13 +133,12 @@ export class MoveBinaryData implements INodeType { type: 'boolean', displayOptions: { show: { - mode: [ - 'jsonToBinary', - ], + mode: ['jsonToBinary'], }, }, default: true, - description: 'Whether all JSON data should be converted to binary. Else only the data of one key will be converted.', + description: + 'Whether all JSON data should be converted to binary. Else only the data of one key will be converted.', }, { displayName: 'Source Key', @@ -154,18 +146,15 @@ export class MoveBinaryData implements INodeType { type: 'string', displayOptions: { show: { - convertAllData: [ - false, - ], - mode: [ - 'jsonToBinary', - ], + convertAllData: [false], + mode: ['jsonToBinary'], }, }, default: 'data', required: true, placeholder: 'data', - description: 'The name of the JSON key to get data from. It is also possible to define deep keys by using dot-notation like for example: "level1.level2.currentKey".', + description: + 'The name of the JSON key to get data from. It is also possible to define deep keys by using dot-notation like for example: "level1.level2.currentKey".', }, { displayName: 'Destination Key', @@ -173,15 +162,14 @@ export class MoveBinaryData implements INodeType { type: 'string', displayOptions: { show: { - mode: [ - 'jsonToBinary', - ], + mode: ['jsonToBinary'], }, }, default: 'data', required: true, placeholder: 'data', - description: 'The name the binary key to copy data to. It is also possible to define deep keys by using dot-notation like for example: "level1.level2.newKey".', + description: + 'The name the binary key to copy data to. It is also possible to define deep keys by using dot-notation like for example: "level1.level2.newKey".', }, { @@ -197,17 +185,11 @@ export class MoveBinaryData implements INodeType { type: 'boolean', displayOptions: { hide: { - 'useRawData': [ - true, - ], + useRawData: [true], }, show: { - '/mode': [ - 'jsonToBinary', - ], - '/convertAllData': [ - false, - ], + '/mode': ['jsonToBinary'], + '/convertAllData': [false], }, }, default: false, @@ -220,10 +202,7 @@ export class MoveBinaryData implements INodeType { options: encodeDecodeOptions, displayOptions: { show: { - '/mode': [ - 'binaryToJson', - 'jsonToBinary', - ], + '/mode': ['binaryToJson', 'jsonToBinary'], }, }, default: 'utf8', @@ -234,9 +213,7 @@ export class MoveBinaryData implements INodeType { name: 'stripBOM', displayOptions: { show: { - '/mode': [ - 'binaryToJson', - ], + '/mode': ['binaryToJson'], encoding: bomAware, }, }, @@ -248,9 +225,7 @@ export class MoveBinaryData implements INodeType { name: 'addBOM', displayOptions: { show: { - '/mode': [ - 'jsonToBinary', - ], + '/mode': ['jsonToBinary'], encoding: bomAware, }, }, @@ -263,9 +238,7 @@ export class MoveBinaryData implements INodeType { type: 'string', displayOptions: { show: { - '/mode': [ - 'jsonToBinary', - ], + '/mode': ['jsonToBinary'], }, }, default: '', @@ -278,17 +251,11 @@ export class MoveBinaryData implements INodeType { type: 'boolean', displayOptions: { hide: { - 'keepAsBase64': [ - true, - ], + keepAsBase64: [true], }, show: { - '/mode': [ - 'binaryToJson', - ], - '/setAllData': [ - false, - ], + '/mode': ['binaryToJson'], + '/setAllData': [false], }, }, default: false, @@ -307,17 +274,11 @@ export class MoveBinaryData implements INodeType { type: 'boolean', displayOptions: { hide: { - 'jsonParse': [ - true, - ], + jsonParse: [true], }, show: { - '/mode': [ - 'binaryToJson', - ], - '/setAllData': [ - false, - ], + '/mode': ['binaryToJson'], + '/setAllData': [false], }, }, default: false, @@ -329,9 +290,7 @@ export class MoveBinaryData implements INodeType { type: 'string', displayOptions: { show: { - '/mode': [ - 'jsonToBinary', - ], + '/mode': ['jsonToBinary'], }, }, default: 'application/json', @@ -344,14 +303,10 @@ export class MoveBinaryData implements INodeType { type: 'boolean', displayOptions: { hide: { - 'dataIsBase64': [ - true, - ], + dataIsBase64: [true], }, show: { - '/mode': [ - 'jsonToBinary', - ], + '/mode': ['jsonToBinary'], }, }, default: false, @@ -363,7 +318,6 @@ export class MoveBinaryData implements INodeType { }; async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); const mode = this.getNodeParameter('mode', 0) as string; @@ -404,14 +358,18 @@ export class MoveBinaryData implements INodeType { if (setAllData === true) { // Set the full data - convertedValue = iconv.decode(buffer, encoding, { stripBOM: options.stripBOM as boolean }); + convertedValue = iconv.decode(buffer, encoding, { + stripBOM: options.stripBOM as boolean, + }); newItem.json = JSON.parse(convertedValue); } else { // Does get added to existing data so copy it first newItem.json = JSON.parse(JSON.stringify(item.json)); if (options.keepAsBase64 !== true) { - convertedValue = iconv.decode(buffer, encoding, { stripBOM: options.stripBOM as boolean }); + convertedValue = iconv.decode(buffer, encoding, { + stripBOM: options.stripBOM as boolean, + }); } else { convertedValue = Buffer.from(buffer).toString(BINARY_ENCODING); } @@ -432,7 +390,6 @@ export class MoveBinaryData implements INodeType { newItem.binary = JSON.parse(JSON.stringify(item.binary)); unset(newItem.binary, sourceKey); } - } else if (mode === 'jsonToBinary') { const convertAllData = this.getNodeParameter('convertAllData', itemIndex) as boolean; const destinationKey = this.getNodeParameter('destinationKey', itemIndex) as string; @@ -462,7 +419,9 @@ export class MoveBinaryData implements INodeType { value = JSON.stringify(value); } - value = iconv.encode(value as string, encoding, { addBOM: options.addBOM as boolean }).toString(BINARY_ENCODING); + value = iconv + .encode(value as string, encoding, { addBOM: options.addBOM as boolean }) + .toString(BINARY_ENCODING); } const convertedValue: IBinaryData = { @@ -495,7 +454,9 @@ export class MoveBinaryData implements INodeType { } } } else { - throw new NodeOperationError(this.getNode(), `The operation "${mode}" is not known!`, { itemIndex }); + throw new NodeOperationError(this.getNode(), `The operation "${mode}" is not known!`, { + itemIndex, + }); } returnData.push(newItem); diff --git a/packages/nodes-base/nodes/Msg91/GenericFunctions.ts b/packages/nodes-base/nodes/Msg91/GenericFunctions.ts index 4bc6d1fd0b..dbe14f1a71 100644 --- a/packages/nodes-base/nodes/Msg91/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Msg91/GenericFunctions.ts @@ -1,11 +1,6 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; /** * Make an API request to MSG91 @@ -16,7 +11,14 @@ import { * @param {object} body * @returns {Promise} */ -export async function msg91ApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject): Promise { // tslint:disable-line:no-any +export async function msg91ApiRequest( + this: IHookFunctions | IExecuteFunctions, + method: string, + endpoint: string, + body: IDataObject, + query?: IDataObject, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('msg91Api'); if (query === undefined) { diff --git a/packages/nodes-base/nodes/Msg91/Msg91.node.ts b/packages/nodes-base/nodes/Msg91/Msg91.node.ts index 448bbf89be..162907617e 100644 --- a/packages/nodes-base/nodes/Msg91/Msg91.node.ts +++ b/packages/nodes-base/nodes/Msg91/Msg91.node.ts @@ -7,10 +7,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - msg91ApiRequest, -} from './GenericFunctions'; - +import { msg91ApiRequest } from './GenericFunctions'; export class Msg91 implements INodeType { description: INodeTypeDescription = { @@ -54,9 +51,7 @@ export class Msg91 implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'sms', - ], + resource: ['sms'], }, }, options: [ @@ -78,12 +73,8 @@ export class Msg91 implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - ], + operation: ['send'], + resource: ['sms'], }, }, description: 'The number from which to send the message', @@ -97,12 +88,8 @@ export class Msg91 implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - ], + operation: ['send'], + resource: ['sms'], }, }, description: 'The number, with coutry code, to which to send the message', @@ -115,12 +102,8 @@ export class Msg91 implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - ], + operation: ['send'], + resource: ['sms'], }, }, description: 'The message to send', @@ -128,9 +111,7 @@ export class Msg91 implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -167,12 +148,17 @@ export class Msg91 implements INodeType { qs.sender = this.getNodeParameter('from', i) as string; qs.mobiles = this.getNodeParameter('to', i) as string; qs.message = this.getNodeParameter('message', i) as string; - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { + itemIndex: i, + }); } const responseData = await msg91ApiRequest.call(this, requestMethod, endpoint, body, qs); @@ -181,6 +167,5 @@ export class Msg91 implements INodeType { } return [this.helpers.returnJsonArray(returnData)]; - } } diff --git a/packages/nodes-base/nodes/MySql/GenericFunctions.ts b/packages/nodes-base/nodes/MySql/GenericFunctions.ts index 2c6c3b01a6..df38f70f91 100644 --- a/packages/nodes-base/nodes/MySql/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MySql/GenericFunctions.ts @@ -1,7 +1,4 @@ -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; /** * Returns of copy of the items which only contains the json data and @@ -25,4 +22,4 @@ export function copyInputItems(items: INodeExecutionData[], properties: string[] } return newItem; }); -} \ No newline at end of file +} diff --git a/packages/nodes-base/nodes/MySql/MySql.node.ts b/packages/nodes-base/nodes/MySql/MySql.node.ts index a5a178cce8..b2d86c7c2a 100644 --- a/packages/nodes-base/nodes/MySql/MySql.node.ts +++ b/packages/nodes-base/nodes/MySql/MySql.node.ts @@ -71,9 +71,7 @@ export class MySql implements INodeType { }, displayOptions: { show: { - operation: [ - 'executeQuery', - ], + operation: ['executeQuery'], }, }, default: '', @@ -82,7 +80,6 @@ export class MySql implements INodeType { description: 'The SQL query to execute', }, - // ---------------------------------- // insert // ---------------------------------- @@ -92,9 +89,7 @@ export class MySql implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'insert', - ], + operation: ['insert'], }, }, default: '', @@ -107,14 +102,13 @@ export class MySql implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'insert', - ], + operation: ['insert'], }, }, default: '', placeholder: 'id,name,description', - description: 'Comma-separated list of the properties which should used as columns for the new rows', + description: + 'Comma-separated list of the properties which should used as columns for the new rows', }, { displayName: 'Options', @@ -122,9 +116,7 @@ export class MySql implements INodeType { type: 'collection', displayOptions: { show: { - operation: [ - 'insert', - ], + operation: ['insert'], }, }, default: {}, @@ -136,7 +128,8 @@ export class MySql implements INodeType { name: 'ignore', type: 'boolean', default: true, - description: 'Whether to ignore any ignorable errors that occur while executing the INSERT statement', + description: + 'Whether to ignore any ignorable errors that occur while executing the INSERT statement', }, { displayName: 'Priority', @@ -146,21 +139,23 @@ export class MySql implements INodeType { { name: 'Low Prioirity', value: 'LOW_PRIORITY', - description: 'Delays execution of the INSERT until no other clients are reading from the table', + description: + 'Delays execution of the INSERT until no other clients are reading from the table', }, { name: 'High Priority', value: 'HIGH_PRIORITY', - description: 'Overrides the effect of the --low-priority-updates option if the server was started with that option. It also causes concurrent inserts not to be used.', + description: + 'Overrides the effect of the --low-priority-updates option if the server was started with that option. It also causes concurrent inserts not to be used.', }, ], default: 'LOW_PRIORITY', - description: 'Ignore any ignorable errors that occur while executing the INSERT statement', + description: + 'Ignore any ignorable errors that occur while executing the INSERT statement', }, ], }, - // ---------------------------------- // update // ---------------------------------- @@ -170,9 +165,7 @@ export class MySql implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: '', @@ -185,15 +178,14 @@ export class MySql implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: 'id', required: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id - description: 'Name of the property which decides which rows in the database should be updated. Normally that would be "id".', + description: + 'Name of the property which decides which rows in the database should be updated. Normally that would be "id".', }, { displayName: 'Columns', @@ -201,31 +193,23 @@ export class MySql implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: '', placeholder: 'name,description', - description: 'Comma-separated list of the properties which should used as columns for rows to update', + description: + 'Comma-separated list of the properties which should used as columns for rows to update', }, - ], }; - async execute(this: IExecuteFunctions): Promise { const credentials = await this.getCredentials('mySql'); // Destructuring SSL configuration - const { - ssl, - caCertificate, - clientCertificate, - clientPrivateKey, - ...baseCredentials - } = credentials; + const { ssl, caCertificate, clientCertificate, clientPrivateKey, ...baseCredentials } = + credentials; if (ssl) { baseCredentials.ssl = {}; @@ -258,20 +242,22 @@ export class MySql implements INodeType { return connection.query(rawQuery); }); - const queryResult = (await Promise.all(queryQueue) as mysql2.OkPacket[][]).reduce((collection, result) => { - const [rows, fields] = result; + const queryResult = ((await Promise.all(queryQueue)) as mysql2.OkPacket[][]).reduce( + (collection, result) => { + const [rows, fields] = result; - if (Array.isArray(rows)) { - return collection.concat(rows); - } + if (Array.isArray(rows)) { + return collection.concat(rows); + } - collection.push(rows); + collection.push(rows); - return collection; - }, []); + return collection; + }, + [], + ); returnItems = this.helpers.returnJsonArray(queryResult as unknown as IDataObject[]); - } catch (error) { if (this.continueOnFail()) { returnItems = this.helpers.returnJsonArray({ error: error.message }); @@ -288,15 +274,22 @@ export class MySql implements INodeType { try { const table = this.getNodeParameter('table', 0) as string; const columnString = this.getNodeParameter('columns', 0) as string; - const columns = columnString.split(',').map(column => column.trim()); + const columns = columnString.split(',').map((column) => column.trim()); const insertItems = copyInputItems(items, columns); - const insertPlaceholder = `(${columns.map(column => '?').join(',')})`; + const insertPlaceholder = `(${columns.map((column) => '?').join(',')})`; const options = this.getNodeParameter('options', 0) as IDataObject; const insertIgnore = options.ignore as boolean; const insertPriority = options.priority as string; - const insertSQL = `INSERT ${insertPriority || ''} ${insertIgnore ? 'IGNORE' : ''} INTO ${table}(${columnString}) VALUES ${items.map(item => insertPlaceholder).join(',')};`; - const queryItems = insertItems.reduce((collection, item) => collection.concat(Object.values(item as any)), []); // tslint:disable-line:no-any + const insertSQL = `INSERT ${insertPriority || ''} ${ + insertIgnore ? 'IGNORE' : '' + } INTO ${table}(${columnString}) VALUES ${items + .map((item) => insertPlaceholder) + .join(',')};`; + const queryItems = insertItems.reduce( + (collection, item) => collection.concat(Object.values(item as any)), // tslint:disable-line:no-any + [], + ); const queryResult = await connection.query(insertSQL, queryItems); @@ -309,7 +302,6 @@ export class MySql implements INodeType { throw error; } } - } else if (operation === 'update') { // ---------------------------------- // update @@ -319,18 +311,23 @@ export class MySql implements INodeType { const table = this.getNodeParameter('table', 0) as string; const updateKey = this.getNodeParameter('updateKey', 0) as string; const columnString = this.getNodeParameter('columns', 0) as string; - const columns = columnString.split(',').map(column => column.trim()); + const columns = columnString.split(',').map((column) => column.trim()); if (!columns.includes(updateKey)) { columns.unshift(updateKey); } const updateItems = copyInputItems(items, columns); - const updateSQL = `UPDATE ${table} SET ${columns.map(column => `${column} = ?`).join(',')} WHERE ${updateKey} = ?;`; - const queryQueue = updateItems.map((item) => connection.query(updateSQL, Object.values(item).concat(item[updateKey]))); + const updateSQL = `UPDATE ${table} SET ${columns + .map((column) => `${column} = ?`) + .join(',')} WHERE ${updateKey} = ?;`; + const queryQueue = updateItems.map((item) => + connection.query(updateSQL, Object.values(item).concat(item[updateKey])), + ); const queryResult = await Promise.all(queryQueue); - returnItems = this.helpers.returnJsonArray(queryResult.map(result => result[0]) as unknown as IDataObject[]); - + returnItems = this.helpers.returnJsonArray( + queryResult.map((result) => result[0]) as unknown as IDataObject[], + ); } catch (error) { if (this.continueOnFail()) { returnItems = this.helpers.returnJsonArray({ error: error.message }); @@ -341,10 +338,15 @@ export class MySql implements INodeType { } } else { if (this.continueOnFail()) { - returnItems = this.helpers.returnJsonArray({ error: `The operation "${operation}" is not supported!` }); + returnItems = this.helpers.returnJsonArray({ + error: `The operation "${operation}" is not supported!`, + }); } else { await connection.end(); - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not supported!`, + ); } } diff --git a/packages/nodes-base/nodes/N8nTrainingCustomerDatastore/N8nTrainingCustomerDatastore.node.ts b/packages/nodes-base/nodes/N8nTrainingCustomerDatastore/N8nTrainingCustomerDatastore.node.ts index 4169642940..1495feaeab 100644 --- a/packages/nodes-base/nodes/N8nTrainingCustomerDatastore/N8nTrainingCustomerDatastore.node.ts +++ b/packages/nodes-base/nodes/N8nTrainingCustomerDatastore/N8nTrainingCustomerDatastore.node.ts @@ -1,13 +1,6 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; const data = [ { @@ -90,9 +83,7 @@ export class N8nTrainingCustomerDatastore implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'getAllPeople', - ], + operation: ['getAllPeople'], }, }, default: false, @@ -104,12 +95,8 @@ export class N8nTrainingCustomerDatastore implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'getAllPeople', - ], - returnAll: [ - false, - ], + operation: ['getAllPeople'], + returnAll: [false], }, }, typeOptions: { @@ -130,14 +117,11 @@ export class N8nTrainingCustomerDatastore implements INodeType { let responseData; for (let i = 0; i < length; i++) { - if (operation === 'getOnePerson') { - responseData = data[0]; } if (operation === 'getAllPeople') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll === true) { diff --git a/packages/nodes-base/nodes/N8nTrainingCustomerMessenger/N8nTrainingCustomerMessenger.node.ts b/packages/nodes-base/nodes/N8nTrainingCustomerMessenger/N8nTrainingCustomerMessenger.node.ts index b0cd4113e7..0d20f74129 100644 --- a/packages/nodes-base/nodes/N8nTrainingCustomerMessenger/N8nTrainingCustomerMessenger.node.ts +++ b/packages/nodes-base/nodes/N8nTrainingCustomerMessenger/N8nTrainingCustomerMessenger.node.ts @@ -1,13 +1,6 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; export class N8nTrainingCustomerMessenger implements INodeType { description: INodeTypeDescription = { @@ -50,7 +43,6 @@ export class N8nTrainingCustomerMessenger implements INodeType { let responseData; for (let i = 0; i < length; i++) { - const customerId = this.getNodeParameter('customerId', i) as string; const message = this.getNodeParameter('message', i) as string; diff --git a/packages/nodes-base/nodes/N8nTrigger/N8nTrigger.node.ts b/packages/nodes-base/nodes/N8nTrigger/N8nTrigger.node.ts index 54ff049239..1685f06b05 100644 --- a/packages/nodes-base/nodes/N8nTrigger/N8nTrigger.node.ts +++ b/packages/nodes-base/nodes/N8nTrigger/N8nTrigger.node.ts @@ -1,9 +1,5 @@ import { ITriggerFunctions } from 'n8n-core'; -import { - INodeType, - INodeTypeDescription, - ITriggerResponse, -} from 'n8n-workflow'; +import { INodeType, INodeTypeDescription, ITriggerResponse } from 'n8n-workflow'; type eventType = 'Instance started' | undefined; @@ -29,7 +25,8 @@ export class N8nTrigger implements INodeType { type: 'multiOptions', required: true, default: [], - description: 'Specifies under which conditions an execution should happen: Instance started: Triggers when this n8n instance is started or re-started', + description: + 'Specifies under which conditions an execution should happen: Instance started: Triggers when this n8n instance is started or re-started', options: [ { name: 'Instance Started', @@ -41,7 +38,6 @@ export class N8nTrigger implements INodeType { ], }; - async trigger(this: ITriggerFunctions): Promise { const events = this.getNodeParameter('events', []) as string[]; @@ -54,14 +50,22 @@ export class N8nTrigger implements INodeType { } this.emit([ this.helpers.returnJsonArray([ - { event, timestamp: (new Date()).toISOString(), workflow_id: this.getWorkflow().id }, + { event, timestamp: new Date().toISOString(), workflow_id: this.getWorkflow().id }, ]), ]); } const self = this; async function manualTriggerFunction() { - self.emit([self.helpers.returnJsonArray([{ event: 'Manual execution', timestamp: (new Date()).toISOString(), workflow_id: self.getWorkflow().id }])]); + self.emit([ + self.helpers.returnJsonArray([ + { + event: 'Manual execution', + timestamp: new Date().toISOString(), + workflow_id: self.getWorkflow().id, + }, + ]), + ]); } return { diff --git a/packages/nodes-base/nodes/Nasa/GenericFunctions.ts b/packages/nodes-base/nodes/Nasa/GenericFunctions.ts index 8a1b9ef6d6..1f9d758a15 100644 --- a/packages/nodes-base/nodes/Nasa/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Nasa/GenericFunctions.ts @@ -1,18 +1,18 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; - -export async function nasaApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, qs: IDataObject, option: IDataObject = {}, uri?: string | undefined): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError } from 'n8n-workflow'; +export async function nasaApiRequest( + this: IHookFunctions | IExecuteFunctions, + method: string, + endpoint: string, + qs: IDataObject, + option: IDataObject = {}, + uri?: string | undefined, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('nasaApi'); qs.api_key = credentials['api_key'] as string; @@ -30,14 +30,19 @@ export async function nasaApiRequest(this: IHookFunctions | IExecuteFunctions, m try { return await this.helpers.request(options); - } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function nasaApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, propertyName: string, method: string, resource: string, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function nasaApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions, + propertyName: string, + method: string, + resource: string, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -50,11 +55,7 @@ export async function nasaApiRequestAllItems(this: IHookFunctions | IExecuteFunc responseData = await nasaApiRequest.call(this, method, resource, query, {}, uri); uri = responseData.links.next; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData.links.next !== undefined - ); + } while (responseData.links.next !== undefined); return returnData; } - - diff --git a/packages/nodes-base/nodes/Nasa/Nasa.node.ts b/packages/nodes-base/nodes/Nasa/Nasa.node.ts index 479d0c1d2f..b5c6c7a471 100644 --- a/packages/nodes-base/nodes/Nasa/Nasa.node.ts +++ b/packages/nodes-base/nodes/Nasa/Nasa.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,10 +8,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - nasaApiRequest, - nasaApiRequestAllItems, -} from './GenericFunctions'; +import { nasaApiRequest, nasaApiRequestAllItems } from './GenericFunctions'; import moment from 'moment'; @@ -125,9 +120,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'astronomyPictureOfTheDay', - ], + resource: ['astronomyPictureOfTheDay'], }, }, options: [ @@ -147,16 +140,15 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'asteroidNeoFeed', - ], + resource: ['asteroidNeoFeed'], }, }, options: [ { name: 'Get', value: 'get', - description: 'Retrieve a list of asteroids based on their closest approach date to Earth', + description: + 'Retrieve a list of asteroids based on their closest approach date to Earth', action: 'Get an asteroid neo feed', }, ], @@ -169,9 +161,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'asteroidNeoLookup', - ], + resource: ['asteroidNeoLookup'], }, }, options: [ @@ -191,9 +181,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'asteroidNeoBrowse', - ], + resource: ['asteroidNeoBrowse'], }, }, options: [ @@ -213,9 +201,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'donkiCoronalMassEjection', - ], + resource: ['donkiCoronalMassEjection'], }, }, options: [ @@ -235,9 +221,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'donkiGeomagneticStorm', - ], + resource: ['donkiGeomagneticStorm'], }, }, options: [ @@ -257,9 +241,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'donkiInterplanetaryShock', - ], + resource: ['donkiInterplanetaryShock'], }, }, options: [ @@ -279,9 +261,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'donkiSolarFlare', - ], + resource: ['donkiSolarFlare'], }, }, options: [ @@ -301,9 +281,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'donkiSolarEnergeticParticle', - ], + resource: ['donkiSolarEnergeticParticle'], }, }, options: [ @@ -323,9 +301,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'donkiMagnetopauseCrossing', - ], + resource: ['donkiMagnetopauseCrossing'], }, }, options: [ @@ -345,9 +321,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'donkiRadiationBeltEnhancement', - ], + resource: ['donkiRadiationBeltEnhancement'], }, }, options: [ @@ -367,9 +341,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'donkiHighSpeedStream', - ], + resource: ['donkiHighSpeedStream'], }, }, options: [ @@ -389,9 +361,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'donkiWsaEnlilSimulation', - ], + resource: ['donkiWsaEnlilSimulation'], }, }, options: [ @@ -411,9 +381,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'donkiNotifications', - ], + resource: ['donkiNotifications'], }, }, options: [ @@ -433,9 +401,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'earthImagery', - ], + resource: ['earthImagery'], }, }, options: [ @@ -455,9 +421,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'earthAssets', - ], + resource: ['earthAssets'], }, }, options: [ @@ -477,9 +441,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'inSightMarsWeatherService', - ], + resource: ['inSightMarsWeatherService'], }, }, options: [ @@ -499,9 +461,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'imageAndVideoLibrary', - ], + resource: ['imageAndVideoLibrary'], }, }, options: [ @@ -521,9 +481,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'techTransfer', - ], + resource: ['techTransfer'], }, }, options: [ @@ -543,9 +501,7 @@ export class Nasa implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'twoLineElementSet', - ], + resource: ['twoLineElementSet'], }, }, options: [ @@ -574,12 +530,8 @@ export class Nasa implements INodeType { description: 'The ID of the asteroid to be returned', displayOptions: { show: { - resource: [ - 'asteroidNeoLookup', - ], - operation: [ - 'get', - ], + resource: ['asteroidNeoLookup'], + operation: ['get'], }, }, }, @@ -591,12 +543,8 @@ export class Nasa implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'asteroidNeoLookup', - ], - operation: [ - 'get', - ], + resource: ['asteroidNeoLookup'], + operation: ['get'], }, }, options: [ @@ -615,14 +563,13 @@ export class Nasa implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'astronomyPictureOfTheDay', - ], + resource: ['astronomyPictureOfTheDay'], }, }, default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default just the URL of the image is returned. When set to true the image will be downloaded.', + description: + 'By default just the URL of the image is returned. When set to true the image will be downloaded.', }, { displayName: 'Binary Property', @@ -632,15 +579,9 @@ export class Nasa implements INodeType { default: 'data', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'astronomyPictureOfTheDay', - ], - download: [ - true, - ], + operation: ['get'], + resource: ['astronomyPictureOfTheDay'], + download: [true], }, }, description: 'Name of the binary property to which to write to', @@ -655,12 +596,8 @@ export class Nasa implements INodeType { placeholder: 'Add field', displayOptions: { show: { - resource: [ - 'astronomyPictureOfTheDay', - ], - operation: [ - 'get', - ], + resource: ['astronomyPictureOfTheDay'], + operation: ['get'], }, }, options: [ @@ -674,7 +611,6 @@ export class Nasa implements INodeType { ], }, - /* startDate and endDate for various resources */ { displayName: 'Additional Fields', @@ -696,9 +632,7 @@ export class Nasa implements INodeType { 'donkiWsaEnlilSimulation', 'donkiNotifications', ], - operation: [ - 'get', - ], + operation: ['get'], }, }, options: [ @@ -732,12 +666,8 @@ export class Nasa implements INodeType { placeholder: 'Add field', displayOptions: { show: { - resource: [ - 'donkiInterplanetaryShock', - ], - operation: [ - 'get', - ], + resource: ['donkiInterplanetaryShock'], + operation: ['get'], }, }, options: [ @@ -818,13 +748,8 @@ export class Nasa implements INodeType { description: 'Latitude for the location of the image', displayOptions: { show: { - resource: [ - 'earthImagery', - 'earthAssets', - ], - operation: [ - 'get', - ], + resource: ['earthImagery', 'earthAssets'], + operation: ['get'], }, }, }, @@ -837,13 +762,8 @@ export class Nasa implements INodeType { description: 'Longitude for the location of the image', displayOptions: { show: { - resource: [ - 'earthImagery', - 'earthAssets', - ], - operation: [ - 'get', - ], + resource: ['earthImagery', 'earthAssets'], + operation: ['get'], }, }, }, @@ -855,18 +775,13 @@ export class Nasa implements INodeType { default: 'data', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'earthImagery', - ], + operation: ['get'], + resource: ['earthImagery'], }, }, description: 'Name of the binary property to which to write to', }, - //aqui { displayName: 'Additional Fields', @@ -876,13 +791,8 @@ export class Nasa implements INodeType { placeholder: 'Add field', displayOptions: { show: { - resource: [ - 'earthImagery', - 'earthAssets', - ], - operation: [ - 'get', - ], + resource: ['earthImagery', 'earthAssets'], + operation: ['get'], }, }, options: [ @@ -911,9 +821,7 @@ export class Nasa implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: false, @@ -930,19 +838,14 @@ export class Nasa implements INodeType { default: 20, displayOptions: { show: { - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, }, ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -957,7 +860,6 @@ export class Nasa implements INodeType { let download = false; for (let i = 0; i < items.length; i++) { - try { let endpoint = ''; let includeCloseApproachData = false; @@ -973,49 +875,45 @@ export class Nasa implements INodeType { } if (resource === 'astronomyPictureOfTheDay') { - if (operation === 'get') { - endpoint = '/planetary/apod'; - qs.date = moment(additionalFields.date as string).format('YYYY-MM-DD') || moment().format('YYYY-MM-DD'); - + qs.date = + moment(additionalFields.date as string).format('YYYY-MM-DD') || + moment().format('YYYY-MM-DD'); } } if (resource === 'asteroidNeoFeed') { - if (operation === 'get') { - endpoint = '/neo/rest/v1/feed'; propertyName = 'near_earth_objects'; // The range defaults to the current date to reduce the number of results. const currentDate = moment().format('YYYY-MM-DD'); - qs.start_date = moment(additionalFields.startDate as string).format('YYYY-MM-DD') || currentDate; - qs.end_date = moment(additionalFields.endDate as string).format('YYYY-MM-DD') || currentDate; - + qs.start_date = + moment(additionalFields.startDate as string).format('YYYY-MM-DD') || currentDate; + qs.end_date = + moment(additionalFields.endDate as string).format('YYYY-MM-DD') || currentDate; } } if (resource === 'asteroidNeoLookup') { - if (operation === 'get') { - const asteroidId = this.getNodeParameter('asteroidId', i) as IDataObject; includeCloseApproachData = additionalFields.includeCloseApproachData as boolean; endpoint = `/neo/rest/v1/neo/${asteroidId}`; - } else { - throw new NodeOperationError(this.getNode(), `The operation '${operation}' is unknown!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation '${operation}' is unknown!`, + { itemIndex: i }, + ); } - } if (resource === 'asteroidNeoBrowse') { - if (operation === 'getAll') { - returnAll = this.getNodeParameter('returnAll', 0) as boolean; if (returnAll === false) { @@ -1025,14 +923,15 @@ export class Nasa implements INodeType { propertyName = 'near_earth_objects'; endpoint = `/neo/rest/v1/neo/browse`; - } else { - throw new NodeOperationError(this.getNode(), `The operation '${operation}' is unknown!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation '${operation}' is unknown!`, + { itemIndex: i }, + ); } - } if (resource.startsWith('donki')) { - if (additionalFields.startDate) { qs.startDate = moment(additionalFields.startDate as string).format('YYYY-MM-DD'); } else { @@ -1046,101 +945,60 @@ export class Nasa implements INodeType { } if (resource === 'donkiCoronalMassEjection') { - if (operation === 'get') { - endpoint = '/DONKI/CME'; - } - } else if (resource === 'donkiGeomagneticStorm') { - if (operation === 'get') { - endpoint = '/DONKI/GST'; - } - } else if (resource === 'donkiInterplanetaryShock') { - if (operation === 'get') { - endpoint = '/DONKI/IPS'; - qs.location = additionalFields.location as string || 'ALL'; // default per API - qs.catalog = additionalFields.catalog as string || 'ALL'; // default per API - + qs.location = (additionalFields.location as string) || 'ALL'; // default per API + qs.catalog = (additionalFields.catalog as string) || 'ALL'; // default per API } - } else if (resource === 'donkiSolarFlare') { - if (operation === 'get') { - endpoint = '/DONKI/FLR'; - } - } else if (resource === 'donkiSolarEnergeticParticle') { - if (operation === 'get') { - endpoint = '/DONKI/SEP'; - } - } else if (resource === 'donkiMagnetopauseCrossing') { - if (operation === 'get') { - endpoint = '/DONKI/MPC'; - } - } else if (resource === 'donkiRadiationBeltEnhancement') { - if (operation === 'get') { - endpoint = '/DONKI/RBE'; - } - } else if (resource === 'donkiHighSpeedStream') { - if (operation === 'get') { - endpoint = '/DONKI/HSS'; - } - } else if (resource === 'donkiWsaEnlilSimulation') { - if (operation === 'get') { - endpoint = '/DONKI/WSAEnlilSimulations'; - } } else if (resource === 'donkiNotifications') { - if (operation === 'get') { - endpoint = '/DONKI/notifications'; - qs.type = additionalFields.type as string || 'all'; // default per API - + qs.type = (additionalFields.type as string) || 'all'; // default per API } } - } if (resource === 'earthImagery') { - if (operation === 'get') { - endpoint = '/planetary/earth/imagery'; qs.lat = this.getNodeParameter('lat', i) as IDataObject; qs.lon = this.getNodeParameter('lon', i) as IDataObject; - qs.dim = additionalFields.dim as string || 0.025; // default per API + qs.dim = (additionalFields.dim as string) || 0.025; // default per API if (additionalFields.date) { qs.date = moment(additionalFields.date as string).format('YYYY-MM-DD'); @@ -1148,18 +1006,15 @@ export class Nasa implements INodeType { qs.date = moment().format('YYYY-MM-DD'); } } - } if (resource === 'earthAssets') { - if (operation === 'get') { - endpoint = '/planetary/earth/assets'; qs.lat = this.getNodeParameter('lat', i) as IDataObject; qs.lon = this.getNodeParameter('lon', i) as IDataObject; - qs.dim = additionalFields.dim as string || 0.025; // default per API + qs.dim = (additionalFields.dim as string) || 0.025; // default per API if (additionalFields.date) { qs.date = moment(additionalFields.date as string).format('YYYY-MM-DD'); @@ -1167,13 +1022,11 @@ export class Nasa implements INodeType { } if (operation === 'get') { - endpoint = '/insight_weather/earth/imagery'; // Hardcoded because these are the only options available right now. qs.feedtype = 'json'; qs.ver = '1.0'; - } } @@ -1197,7 +1050,6 @@ export class Nasa implements INodeType { } if (resource === 'earthImagery') { - const binaryProperty = this.getNodeParameter('binaryPropertyName', i) as string; const data = await nasaApiRequest.call(this, 'GET', endpoint, qs, { encoding: null }); @@ -1220,10 +1072,16 @@ export class Nasa implements INodeType { download = this.getNodeParameter('download', 0) as boolean; if (download === true) { - const binaryProperty = this.getNodeParameter('binaryPropertyName', i) as string; - const data = await nasaApiRequest.call(this, 'GET', endpoint, qs, { encoding: null }, responseData.hdurl); + const data = await nasaApiRequest.call( + this, + 'GET', + endpoint, + qs, + { encoding: null }, + responseData.hdurl, + ); const filename = (responseData.hdurl as string).split('/'); @@ -1240,7 +1098,10 @@ export class Nasa implements INodeType { items[i] = newItem; - items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData(data, filename[filename.length - 1]); + items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData( + data, + filename[filename.length - 1], + ); } } @@ -1253,7 +1114,11 @@ export class Nasa implements INodeType { if (this.continueOnFail()) { if (resource === 'earthImagery' && operation === 'get') { items[i].json = { error: error.message }; - } else if (resource === 'astronomyPictureOfTheDay' && operation === 'get' && download === true) { + } else if ( + resource === 'astronomyPictureOfTheDay' && + operation === 'get' && + download === true + ) { items[i].json = { error: error.message }; } else { returnData.push({ error: error.message }); @@ -1266,7 +1131,11 @@ export class Nasa implements INodeType { if (resource === 'earthImagery' && operation === 'get') { return this.prepareOutputData(items); - } else if (resource === 'astronomyPictureOfTheDay' && operation === 'get' && download === true) { + } else if ( + resource === 'astronomyPictureOfTheDay' && + operation === 'get' && + download === true + ) { return this.prepareOutputData(items); } else { return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Netlify/DeployDescription.ts b/packages/nodes-base/nodes/Netlify/DeployDescription.ts index 024db9c455..7177bf538f 100644 --- a/packages/nodes-base/nodes/Netlify/DeployDescription.ts +++ b/packages/nodes-base/nodes/Netlify/DeployDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const deployOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const deployOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'deploy', - ], + resource: ['deploy'], }, }, options: [ @@ -55,17 +51,12 @@ export const deployFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getSites', }, - description: 'Enter the Site ID. Choose from the list, or specify an ID using an expression.', - displayOptions:{ + description: + 'Enter the Site ID. Choose from the list, or specify an ID using an expression.', + displayOptions: { show: { - resource: [ - 'deploy', - ], - operation: [ - 'get', - 'create', - 'getAll', - ], + resource: ['deploy'], + operation: ['get', 'create', 'getAll'], }, }, }, @@ -75,31 +66,22 @@ export const deployFields: INodeProperties[] = [ required: true, type: 'string', default: '', - displayOptions:{ + displayOptions: { show: { - resource: [ - 'deploy', - ], - operation: [ - 'get', - 'cancel', - ], + resource: ['deploy'], + operation: ['get', 'cancel'], }, }, }, - // ----- Get All Deploys ------ // + // ----- Get All Deploys ------ // { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'deploy', - ], + operation: ['getAll'], + resource: ['deploy'], }, }, default: false, @@ -111,15 +93,9 @@ export const deployFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'deploy', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['deploy'], + returnAll: [false], }, }, typeOptions: { @@ -138,12 +114,8 @@ export const deployFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deploy', - ], - operation: [ - 'create', - ], + resource: ['deploy'], + operation: ['create'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Netlify/GenericFunctions.ts b/packages/nodes-base/nodes/Netlify/GenericFunctions.ts index dfa6bb831e..834d9de2a0 100644 --- a/packages/nodes-base/nodes/Netlify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Netlify/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,12 +7,19 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; - -export async function netlifyApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; +export async function netlifyApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { method, headers: { @@ -45,8 +50,15 @@ export async function netlifyApiRequest(this: IHookFunctions | IExecuteFunctions } } -export async function netlifyRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function netlifyRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -54,12 +66,12 @@ export async function netlifyRequestAllItems(this: IExecuteFunctions | ILoadOpti query.per_page = 100; do { - responseData = await netlifyApiRequest.call(this, method, endpoint, body, query, undefined, { resolveWithFullResponse: true }); + responseData = await netlifyApiRequest.call(this, method, endpoint, body, query, undefined, { + resolveWithFullResponse: true, + }); query.page++; returnData.push.apply(returnData, responseData.body); - } while ( - responseData.headers.link.includes('next') - ); + } while (responseData.headers.link.includes('next')); return returnData; } diff --git a/packages/nodes-base/nodes/Netlify/Netlify.node.ts b/packages/nodes-base/nodes/Netlify/Netlify.node.ts index 14f23f7196..c700069bbd 100644 --- a/packages/nodes-base/nodes/Netlify/Netlify.node.ts +++ b/packages/nodes-base/nodes/Netlify/Netlify.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,20 +9,11 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - netlifyApiRequest, - netlifyRequestAllItems, -} from './GenericFunctions'; +import { netlifyApiRequest, netlifyRequestAllItems } from './GenericFunctions'; -import { - deployFields, - deployOperations -} from './DeployDescription'; +import { deployFields, deployOperations } from './DeployDescription'; -import { - siteFields, - siteOperations -} from './SiteDescription'; +import { siteFields, siteOperations } from './SiteDescription'; export class Netlify implements INodeType { description: INodeTypeDescription = { @@ -76,11 +65,7 @@ export class Netlify implements INodeType { loadOptions: { async getSites(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const sites = await netlifyApiRequest.call( - this, - 'GET', - '/sites', - ); + const sites = await netlifyApiRequest.call(this, 'GET', '/sites'); for (const site of sites) { returnData.push({ name: site.name, @@ -105,10 +90,15 @@ export class Netlify implements INodeType { for (let i = 0; i < length; i++) { try { if (resource === 'deploy') { - if (operation === 'cancel') { const deployId = this.getNodeParameter('deployId', i); - responseData = await netlifyApiRequest.call(this, 'POST', `/deploys/${deployId}/cancel`, body, qs); + responseData = await netlifyApiRequest.call( + this, + 'POST', + `/deploys/${deployId}/cancel`, + body, + qs, + ); } if (operation === 'create') { @@ -122,28 +112,49 @@ export class Netlify implements INodeType { delete body.title; } - responseData = await netlifyApiRequest.call(this, 'POST', `/sites/${siteId}/deploys`, body, qs); + responseData = await netlifyApiRequest.call( + this, + 'POST', + `/sites/${siteId}/deploys`, + body, + qs, + ); } if (operation === 'get') { const siteId = this.getNodeParameter('siteId', i); const deployId = this.getNodeParameter('deployId', i); - responseData = await netlifyApiRequest.call(this, 'GET', `/sites/${siteId}/deploys/${deployId}`, body, qs); + responseData = await netlifyApiRequest.call( + this, + 'GET', + `/sites/${siteId}/deploys/${deployId}`, + body, + qs, + ); } if (operation === 'getAll') { const siteId = this.getNodeParameter('siteId', i); const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll === true) { - responseData = await netlifyRequestAllItems.call(this, 'GET', `/sites/${siteId}/deploys`); + responseData = await netlifyRequestAllItems.call( + this, + 'GET', + `/sites/${siteId}/deploys`, + ); } else { const limit = this.getNodeParameter('limit', i) as number; - responseData = await netlifyApiRequest.call(this, 'GET', `/sites/${siteId}/deploys`, {}, { per_page: limit }); + responseData = await netlifyApiRequest.call( + this, + 'GET', + `/sites/${siteId}/deploys`, + {}, + { per_page: limit }, + ); } } } if (resource === 'site') { - if (operation === 'delete') { const siteId = this.getNodeParameter('siteId', i); responseData = await netlifyApiRequest.call(this, 'DELETE', `/sites/${siteId}`); @@ -157,10 +168,22 @@ export class Netlify implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll === true) { - responseData = await netlifyRequestAllItems.call(this, 'GET', `/sites`, {}, { filter: 'all' }); + responseData = await netlifyRequestAllItems.call( + this, + 'GET', + `/sites`, + {}, + { filter: 'all' }, + ); } else { const limit = this.getNodeParameter('limit', i) as number; - responseData = await netlifyApiRequest.call(this, 'GET', `/sites`, {}, { filter: 'all', per_page: limit }); + responseData = await netlifyApiRequest.call( + this, + 'GET', + `/sites`, + {}, + { filter: 'all', per_page: limit }, + ); } } } @@ -180,4 +203,4 @@ export class Netlify implements INodeType { return [this.helpers.returnJsonArray(returnData)]; } -} \ No newline at end of file +} diff --git a/packages/nodes-base/nodes/Netlify/NetlifyTrigger.node.ts b/packages/nodes-base/nodes/Netlify/NetlifyTrigger.node.ts index 74bea488e0..ddc9963667 100644 --- a/packages/nodes-base/nodes/Netlify/NetlifyTrigger.node.ts +++ b/packages/nodes-base/nodes/Netlify/NetlifyTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -12,14 +9,9 @@ import { IWebhookResponseData, } from 'n8n-workflow'; +import { netlifyApiRequest } from './GenericFunctions'; -import { - netlifyApiRequest, -} from './GenericFunctions'; - -import { - snakeCase, -} from 'change-case'; +import { snakeCase } from 'change-case'; export class NetlifyTrigger implements INodeType { description: INodeTypeDescription = { @@ -59,7 +51,8 @@ export class NetlifyTrigger implements INodeType { typeOptions: { loadOptionsMethod: 'getSites', }, - description: 'Select the Site ID. Choose from the list, or specify an ID using an expression.', + description: + 'Select the Site ID. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Event', @@ -93,16 +86,15 @@ export class NetlifyTrigger implements INodeType { required: true, displayOptions: { show: { - event: [ - 'submissionCreated', - ], + event: ['submissionCreated'], }, }, default: '', typeOptions: { loadOptionsMethod: 'getForms', }, - description: 'Select a form. Choose from the list, or specify an ID using an expression.', + description: + 'Select a form. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Simplify', @@ -110,13 +102,12 @@ export class NetlifyTrigger implements INodeType { type: 'boolean', displayOptions: { show: { - event: [ - 'submissionCreated', - ], + event: ['submissionCreated'], }, }, default: true, - description: 'Whether to return a simplified version of the response instead of the raw data', + description: + 'Whether to return a simplified version of the response instead of the raw data', }, ], }; @@ -179,11 +170,7 @@ export class NetlifyTrigger implements INodeType { loadOptions: { async getSites(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const sites = await netlifyApiRequest.call( - this, - 'GET', - '/sites', - ); + const sites = await netlifyApiRequest.call(this, 'GET', '/sites'); for (const site of sites) { returnData.push({ name: site.name, @@ -196,11 +183,7 @@ export class NetlifyTrigger implements INodeType { async getForms(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const siteId = this.getNodeParameter('siteId'); - const forms = await netlifyApiRequest.call( - this, - 'GET', - `/sites/${siteId}/forms`, - ); + const forms = await netlifyApiRequest.call(this, 'GET', `/sites/${siteId}/forms`); for (const form of forms) { returnData.push({ name: form.name, @@ -224,9 +207,7 @@ export class NetlifyTrigger implements INodeType { } return { - workflowData: [ - this.helpers.returnJsonArray(response), - ], + workflowData: [this.helpers.returnJsonArray(response)], }; } } diff --git a/packages/nodes-base/nodes/Netlify/SiteDescription.ts b/packages/nodes-base/nodes/Netlify/SiteDescription.ts index 6e40d714e3..b57aa3c009 100644 --- a/packages/nodes-base/nodes/Netlify/SiteDescription.ts +++ b/packages/nodes-base/nodes/Netlify/SiteDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const siteOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const siteOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'site', - ], + resource: ['site'], }, }, options: [ @@ -48,13 +44,8 @@ export const siteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'site', - ], - operation: [ - 'get', - 'delete', - ], + resource: ['site'], + operation: ['get', 'delete'], }, }, }, @@ -64,12 +55,8 @@ export const siteFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'site', - ], + operation: ['getAll'], + resource: ['site'], }, }, default: false, @@ -81,15 +68,9 @@ export const siteFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'site', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['site'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts b/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts index 443f67cb16..d8636d7c94 100644 --- a/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts +++ b/packages/nodes-base/nodes/NextCloud/GenericFunctions.ts @@ -1,16 +1,8 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - JsonObject, - NodeApiError, - } from 'n8n-workflow'; +import { JsonObject, NodeApiError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; /** * Make an API request to NextCloud @@ -21,7 +13,16 @@ import { * @param {object} body * @returns {Promise} */ -export async function nextCloudApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: object | string | Buffer, headers?: object, encoding?: null | undefined, query?: object): Promise { // tslint:disable-line:no-any +export async function nextCloudApiRequest( + this: IHookFunctions | IExecuteFunctions, + method: string, + endpoint: string, + body: object | string | Buffer, + headers?: object, + encoding?: null | undefined, + query?: object, + // tslint:disable-next-line:no-any +): Promise { const resource = this.getNodeParameter('resource', 0); const operation = this.getNodeParameter('operation', 0); const authenticationMethod = this.getNodeParameter('authentication', 0); @@ -29,9 +30,9 @@ export async function nextCloudApiRequest(this: IHookFunctions | IExecuteFunctio let credentials; if (authenticationMethod === 'accessToken') { - credentials = await this.getCredentials('nextCloudApi') as { webDavUrl: string }; + credentials = (await this.getCredentials('nextCloudApi')) as { webDavUrl: string }; } else { - credentials = await this.getCredentials('nextCloudOAuth2Api') as { webDavUrl: string }; + credentials = (await this.getCredentials('nextCloudOAuth2Api')) as { webDavUrl: string }; } const options: OptionsWithUri = { @@ -52,11 +53,12 @@ export async function nextCloudApiRequest(this: IHookFunctions | IExecuteFunctio options.uri = options.uri.replace('/remote.php/webdav', ''); } - const credentialType = authenticationMethod === 'accessToken' ? 'nextCloudApi' : 'nextCloudOAuth2Api'; + const credentialType = + authenticationMethod === 'accessToken' ? 'nextCloudApi' : 'nextCloudOAuth2Api'; try { return await this.helpers.requestWithAuthentication.call(this, credentialType, options); - } catch(error) { + } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts index 988b1462f4..a2a80f3bab 100644 --- a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts +++ b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts @@ -11,13 +11,9 @@ import { import { URLSearchParams } from 'url'; -import { - parseString, -} from 'xml2js'; +import { parseString } from 'xml2js'; -import { - nextCloudApiRequest, -} from './GenericFunctions'; +import { nextCloudApiRequest } from './GenericFunctions'; export class NextCloud implements INodeType { description: INodeTypeDescription = { @@ -39,9 +35,7 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -50,9 +44,7 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -96,8 +88,6 @@ export class NextCloud implements INodeType { default: 'file', }, - - // ---------------------------------- // operations // ---------------------------------- @@ -108,9 +98,7 @@ export class NextCloud implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'file', - ], + resource: ['file'], }, }, options: [ @@ -161,9 +149,7 @@ export class NextCloud implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'folder', - ], + resource: ['folder'], }, }, options: [ @@ -214,9 +200,7 @@ export class NextCloud implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -269,13 +253,8 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'copy', - ], - resource: [ - 'file', - 'folder', - ], + operation: ['copy'], + resource: ['file', 'folder'], }, }, placeholder: '/invoices/original.txt', @@ -289,13 +268,8 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'copy', - ], - resource: [ - 'file', - 'folder', - ], + operation: ['copy'], + resource: ['file', 'folder'], }, }, placeholder: '/invoices/copy.txt', @@ -313,17 +287,13 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'file', - 'folder', - ], + operation: ['delete'], + resource: ['file', 'folder'], }, }, placeholder: '/invoices/2019/invoice_1.pdf', - description: 'The path to delete. Can be a single file or a whole folder. The path should start with "/".', + description: + 'The path to delete. Can be a single file or a whole folder. The path should start with "/".', }, // ---------------------------------- @@ -337,13 +307,8 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'move', - ], - resource: [ - 'file', - 'folder', - ], + operation: ['move'], + resource: ['file', 'folder'], }, }, placeholder: '/invoices/old_name.txt', @@ -357,13 +322,8 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'move', - ], - resource: [ - 'file', - 'folder', - ], + operation: ['move'], + resource: ['file', 'folder'], }, }, placeholder: '/invoices/new_name.txt', @@ -381,16 +341,13 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'file', - ], + operation: ['download'], + resource: ['file'], }, }, placeholder: '/invoices/2019/invoice_1.pdf', - description: 'The file path of the file to download. Has to contain the full path. The path should start with "/".', + description: + 'The file path of the file to download. Has to contain the full path. The path should start with "/".', }, { displayName: 'Binary Property', @@ -400,12 +357,8 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'file', - ], + operation: ['download'], + resource: ['file'], }, }, description: 'Name of the binary property to which to write the data of the read file', @@ -422,16 +375,13 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, placeholder: '/invoices/2019/invoice_1.pdf', - description: 'The absolute file path of the file to upload. Has to contain the full path. The parent folder has to exist. Existing files get overwritten.', + description: + 'The absolute file path of the file to upload. Has to contain the full path. The parent folder has to exist. Existing files get overwritten.', }, { displayName: 'Binary Data', @@ -441,12 +391,8 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, }, @@ -457,17 +403,10 @@ export class NextCloud implements INodeType { default: '', displayOptions: { show: { - binaryDataUpload: [ - false, - ], - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + binaryDataUpload: [false], + operation: ['upload'], + resource: ['file'], }, - }, placeholder: '', description: 'The text content of the file to upload', @@ -480,20 +419,14 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - binaryDataUpload: [ - true, - ], - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + binaryDataUpload: [true], + operation: ['upload'], + resource: ['file'], }, - }, placeholder: '', - description: 'Name of the binary property which contains the data for the file to be uploaded', + description: + 'Name of the binary property which contains the data for the file to be uploaded', }, // ---------------------------------- @@ -507,17 +440,13 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'file', - 'folder', - ], + operation: ['share'], + resource: ['file', 'folder'], }, }, placeholder: '/invoices/2019/invoice_1.pdf', - description: 'The file path of the file to share. Has to contain the full path. The path should start with "/".', + description: + 'The file path of the file to share. Has to contain the full path. The path should start with "/".', }, { displayName: 'Share Type', @@ -525,13 +454,8 @@ export class NextCloud implements INodeType { type: 'options', displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'file', - 'folder', - ], + operation: ['share'], + resource: ['file', 'folder'], }, }, options: [ @@ -565,16 +489,9 @@ export class NextCloud implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'file', - 'folder', - ], - operation: [ - 'share', - ], - shareType: [ - 7, - ], + resource: ['file', 'folder'], + operation: ['share'], + shareType: [7], }, }, default: '', @@ -587,16 +504,9 @@ export class NextCloud implements INodeType { placeholder: 'name@email.com', displayOptions: { show: { - resource: [ - 'file', - 'folder', - ], - operation: [ - 'share', - ], - shareType: [ - 4, - ], + resource: ['file', 'folder'], + operation: ['share'], + shareType: [4], }, }, default: '', @@ -608,16 +518,9 @@ export class NextCloud implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'file', - 'folder', - ], - operation: [ - 'share', - ], - shareType: [ - 1, - ], + resource: ['file', 'folder'], + operation: ['share'], + shareType: [1], }, }, default: '', @@ -629,16 +532,9 @@ export class NextCloud implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'file', - 'folder', - ], - operation: [ - 'share', - ], - shareType: [ - 0, - ], + resource: ['file', 'folder'], + operation: ['share'], + shareType: [0], }, }, default: '', @@ -652,13 +548,8 @@ export class NextCloud implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'file', - 'folder', - ], - operation: [ - 'share', - ], + resource: ['file', 'folder'], + operation: ['share'], }, }, options: [ @@ -668,16 +559,9 @@ export class NextCloud implements INodeType { type: 'string', displayOptions: { show: { - '/resource': [ - 'file', - 'folder', - ], - '/operation': [ - 'share', - ], - '/shareType': [ - 3, - ], + '/resource': ['file', 'folder'], + '/operation': ['share'], + '/shareType': [3], }, }, default: '', @@ -730,16 +614,13 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'folder', - ], + operation: ['create'], + resource: ['folder'], }, }, placeholder: '/invoices/2019', - description: 'The folder to create. The parent folder has to exist. The path should start with "/".', + description: + 'The folder to create. The parent folder has to exist. The path should start with "/".', }, // ---------------------------------- @@ -752,12 +633,8 @@ export class NextCloud implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'list', - ], - resource: [ - 'folder', - ], + operation: ['list'], + resource: ['folder'], }, }, placeholder: '/invoices/2019/', @@ -779,12 +656,8 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, placeholder: 'john', @@ -798,12 +671,8 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, placeholder: 'john@email.com', @@ -817,12 +686,8 @@ export class NextCloud implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, options: [ @@ -846,14 +711,8 @@ export class NextCloud implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'delete', - 'get', - 'update', - ], + resource: ['user'], + operation: ['delete', 'get', 'update'], }, }, placeholder: 'john', @@ -868,12 +727,8 @@ export class NextCloud implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, default: false, @@ -885,15 +740,9 @@ export class NextCloud implements INodeType { type: 'number', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['user'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -911,12 +760,8 @@ export class NextCloud implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, options: [ @@ -950,12 +795,8 @@ export class NextCloud implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, options: [ @@ -968,39 +809,38 @@ export class NextCloud implements INodeType { name: 'key', type: 'options', default: 'email', - options: - [ - { - name: 'Address', - value: 'address', - description: 'The new address for the user', - }, - { - name: 'Display Name', - value: 'displayname', - description: 'The new display name for the user', - }, - { - name: 'Email', - value: 'email', - description: 'The new email for the user', - }, - { - name: 'Password', - value: 'password', - description: 'The new password for the user', - }, - { - name: 'Twitter', - value: 'twitter', - description: 'The new twitter handle for the user', - }, - { - name: 'Website', - value: 'website', - description: 'The new website for the user', - }, - ], + options: [ + { + name: 'Address', + value: 'address', + description: 'The new address for the user', + }, + { + name: 'Display Name', + value: 'displayname', + description: 'The new display name for the user', + }, + { + name: 'Email', + value: 'email', + description: 'The new email for the user', + }, + { + name: 'Password', + value: 'password', + description: 'The new password for the user', + }, + { + name: 'Twitter', + value: 'twitter', + description: 'The new twitter handle for the user', + }, + { + name: 'Website', + value: 'website', + description: 'The new website for the user', + }, + ], description: 'Key of the updated attribute', }, { @@ -1017,7 +857,6 @@ export class NextCloud implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData().slice(); const returnData: IDataObject[] = []; @@ -1052,7 +891,6 @@ export class NextCloud implements INodeType { requestMethod = 'GET'; endpoint = this.getNodeParameter('path', i) as string; - } else if (operation === 'upload') { // ---------------------------------- // upload @@ -1066,14 +904,19 @@ export class NextCloud implements INodeType { const item = items[i]; if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string; - if (item.binary[propertyNameUpload] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${propertyNameUpload}" does not exists on item!`, + { itemIndex: i }, + ); } body = await this.helpers.getBinaryDataBuffer(i, propertyNameUpload); @@ -1090,7 +933,6 @@ export class NextCloud implements INodeType { requestMethod = 'MKCOL'; endpoint = this.getNodeParameter('path', i) as string; - } else if (operation === 'list') { // ---------------------------------- // list @@ -1098,7 +940,6 @@ export class NextCloud implements INodeType { requestMethod = 'PROPFIND'; endpoint = this.getNodeParameter('path', i) as string; - } } @@ -1112,7 +953,6 @@ export class NextCloud implements INodeType { endpoint = this.getNodeParameter('path', i) as string; const toPath = this.getNodeParameter('toPath', i) as string; headers.Destination = `${credentials.webDavUrl}/${encodeURI(toPath)}`; - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -1120,7 +960,6 @@ export class NextCloud implements INodeType { requestMethod = 'DELETE'; endpoint = this.getNodeParameter('path', i) as string; - } else if (operation === 'move') { // ---------------------------------- // move @@ -1130,7 +969,6 @@ export class NextCloud implements INodeType { endpoint = this.getNodeParameter('path', i) as string; const toPath = this.getNodeParameter('toPath', i) as string; headers.Destination = `${credentials.webDavUrl}/${encodeURI(toPath)}`; - } else if (operation === 'share') { // ---------------------------------- // share @@ -1161,7 +999,6 @@ export class NextCloud implements INodeType { // @ts-ignore body = new URLSearchParams(bodyParameters).toString(); } - } else if (resource === 'user') { if (operation === 'create') { // ---------------------------------- @@ -1238,16 +1075,22 @@ export class NextCloud implements INodeType { const userid = this.getNodeParameter('userId', i) as string; endpoint = `ocs/v1.php/cloud/users/${userid}`; - body = Object.entries((this.getNodeParameter('updateFields', i) as IDataObject).field as IDataObject).map(entry => { - const [key, value] = entry; - return `${key}=${value}`; - }).join('&'); + body = Object.entries( + (this.getNodeParameter('updateFields', i) as IDataObject).field as IDataObject, + ) + .map((entry) => { + const [key, value] = entry; + return `${key}=${value}`; + }) + .join('&'); headers['OCS-APIRequest'] = true; headers['Content-Type'] = 'application/x-www-form-urlencoded'; } } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { + itemIndex: i, + }); } // Make sure that the webdav URL does never have a trailing slash because @@ -1264,7 +1107,15 @@ export class NextCloud implements INodeType { } try { - responseData = await nextCloudApiRequest.call(this, requestMethod, endpoint, body, headers, encoding, qs); + responseData = await nextCloudApiRequest.call( + this, + requestMethod, + endpoint, + body, + headers, + encoding, + qs, + ); } catch (error) { if (this.continueOnFail()) { if (resource === 'file' && operation === 'download') { @@ -1279,7 +1130,6 @@ export class NextCloud implements INodeType { } if (resource === 'file' && operation === 'download') { - const newItem: INodeExecutionData = { json: items[i].json, binary: {}, @@ -1296,29 +1146,30 @@ export class NextCloud implements INodeType { const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; - items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData(responseData, endpoint); - + items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData( + responseData, + endpoint, + ); } else if (['file', 'folder'].includes(resource) && operation === 'share') { - const jsonResponseData: IDataObject = await new Promise((resolve, reject) => { - parseString(responseData, { explicitArray: false }, (err, data) => { - if (err) { - return reject(err); - } + const jsonResponseData: IDataObject = await new Promise((resolve, reject) => { + parseString(responseData, { explicitArray: false }, (err, data) => { + if (err) { + return reject(err); + } - if (data.ocs.meta.status !== 'ok') { - return reject(new NodeApiError(this.getNode(), data.ocs.meta.message || data.ocs.meta.status)); - } + if (data.ocs.meta.status !== 'ok') { + return reject( + new NodeApiError(this.getNode(), data.ocs.meta.message || data.ocs.meta.status), + ); + } - resolve(data.ocs.data as IDataObject); - }); + resolve(data.ocs.data as IDataObject); }); + }); - returnData.push(jsonResponseData as IDataObject); - + returnData.push(jsonResponseData as IDataObject); } else if (resource === 'user') { - if (operation !== 'getAll') { - const jsonResponseData: IDataObject = await new Promise((resolve, reject) => { parseString(responseData, { explicitArray: false }, (err, data) => { if (err) { @@ -1326,7 +1177,9 @@ export class NextCloud implements INodeType { } if (data.ocs.meta.status !== 'ok') { - return reject(new NodeApiError(this.getNode(), data.ocs.meta.message || data.ocs.meta.status)); + return reject( + new NodeApiError(this.getNode(), data.ocs.meta.message || data.ocs.meta.status), + ); } if (operation === 'delete' || operation === 'update') { @@ -1339,7 +1192,6 @@ export class NextCloud implements INodeType { returnData.push(jsonResponseData as IDataObject); } else { - const jsonResponseData: IDataObject[] = await new Promise((resolve, reject) => { parseString(responseData, { explicitArray: false }, (err, data) => { if (err) { @@ -1350,7 +1202,7 @@ export class NextCloud implements INodeType { return reject(new NodeApiError(this.getNode(), data.ocs.meta.message)); } - if (typeof (data.ocs.data.users.element) === 'string') { + if (typeof data.ocs.data.users.element === 'string') { resolve([data.ocs.data.users.element] as IDataObject[]); } else { resolve(data.ocs.data.users.element as IDataObject[]); @@ -1358,13 +1210,11 @@ export class NextCloud implements INodeType { }); }); - jsonResponseData.forEach(value => { + jsonResponseData.forEach((value) => { returnData.push({ id: value } as IDataObject); }); } - } else if (resource === 'folder' && operation === 'list') { - const jsonResponseData: IDataObject = await new Promise((resolve, reject) => { parseString(responseData, { explicitArray: false }, (err, data) => { if (err) { @@ -1380,10 +1230,12 @@ export class NextCloud implements INodeType { 'd:getcontenttype': 'contentType', }; - if (jsonResponseData['d:multistatus'] !== undefined && + if ( + jsonResponseData['d:multistatus'] !== undefined && jsonResponseData['d:multistatus'] !== null && (jsonResponseData['d:multistatus'] as IDataObject)['d:response'] !== undefined && - (jsonResponseData['d:multistatus'] as IDataObject)['d:response'] !== null) { + (jsonResponseData['d:multistatus'] as IDataObject)['d:response'] !== null + ) { let skippedFirst = false; // @ts-ignore if (Array.isArray(jsonResponseData['d:multistatus']['d:response'])) { @@ -1423,7 +1275,6 @@ export class NextCloud implements INodeType { } } } - } else { returnData.push(responseData as IDataObject); } @@ -1438,7 +1289,6 @@ export class NextCloud implements INodeType { } throw error; } - } if (resource === 'file' && operation === 'download') { diff --git a/packages/nodes-base/nodes/NoOp/NoOp.node.ts b/packages/nodes-base/nodes/NoOp/NoOp.node.ts index 3c9a97af6a..2835a33781 100644 --- a/packages/nodes-base/nodes/NoOp/NoOp.node.ts +++ b/packages/nodes-base/nodes/NoOp/NoOp.node.ts @@ -1,10 +1,5 @@ import { IExecuteFunctions } from 'n8n-core'; -import { - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; - +import { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; export class NoOp implements INodeType { description: INodeTypeDescription = { @@ -20,8 +15,7 @@ export class NoOp implements INodeType { }, inputs: ['main'], outputs: ['main'], - properties: [ - ], + properties: [], }; execute(this: IExecuteFunctions): Promise { diff --git a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts index f2e64b3910..9dd32e55ef 100644 --- a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts @@ -1,12 +1,6 @@ -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IBinaryKeyData, @@ -17,7 +11,6 @@ import { NodeOperationError, } from 'n8n-workflow'; - interface IAttachment { url: string; title: string; @@ -34,7 +27,16 @@ interface IAttachment { * @param {object} body * @returns {Promise} */ -export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, method: string, endpoint: string, body: object, query?: IDataObject, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function apiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, + method: string, + endpoint: string, + body: object, + query?: IDataObject, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0) as string; const credentials = await this.getCredentials(authenticationMethod); @@ -50,9 +52,9 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa method, body, qs: query, - uri: uri || baseUrl.endsWith('/') ? `${baseUrl.slice(0, -1)}${endpoint}` : `${baseUrl}${endpoint}`, + uri: + uri || baseUrl.endsWith('/') ? `${baseUrl.slice(0, -1)}${endpoint}` : `${baseUrl}${endpoint}`, json: true, - }; if (Object.keys(option).length !== 0) { @@ -70,7 +72,6 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa } } - /** * Make an API request to paginated NocoDB endpoint * and return all results @@ -83,14 +84,21 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa * @param {IDataObject} [query] * @returns {Promise} */ -export async function apiRequestAllItems(this: IHookFunctions | IExecuteFunctions | IPollFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject): Promise { // tslint:disable-line:no-any +export async function apiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | IPollFunctions, + method: string, + endpoint: string, + body: IDataObject, + query?: IDataObject, + // tslint:disable-next-line:no-any +): Promise { const version = this.getNode().typeVersion as number; if (query === undefined) { query = {}; } query.limit = 100; - query.offset = query?.offset ? query.offset as number : 0; + query.offset = query?.offset ? (query.offset as number) : 0; const returnData: IDataObject[] = []; let responseData; @@ -100,15 +108,16 @@ export async function apiRequestAllItems(this: IHookFunctions | IExecuteFunction version === 1 ? returnData.push(...responseData) : returnData.push(...responseData.list); query.offset += query.limit; - - } while ( - version === 1 ? responseData.length !== 0 : responseData.pageInfo.isLastPage !== true - ); + } while (version === 1 ? responseData.length !== 0 : responseData.pageInfo.isLastPage !== true); return returnData; } -export async function downloadRecordAttachments(this: IExecuteFunctions | IPollFunctions, records: IDataObject[], fieldNames: string[]): Promise { +export async function downloadRecordAttachments( + this: IExecuteFunctions | IPollFunctions, + records: IDataObject[], + fieldNames: string[], +): Promise { const elements: INodeExecutionData[] = []; for (const record of records) { @@ -116,9 +125,18 @@ export async function downloadRecordAttachments(this: IExecuteFunctions | IPollF element.json = record as unknown as IDataObject; for (const fieldName of fieldNames) { if (record[fieldName]) { - for (const [index, attachment] of (JSON.parse(record[fieldName] as string) as IAttachment[]).entries()) { - const file = await apiRequest.call(this, 'GET', '', {}, {}, attachment.url, { json: false, encoding: null }); - element.binary![`${fieldName}_${index}`] = await this.helpers.prepareBinaryData(Buffer.from(file), attachment.title, attachment.mimetype); + for (const [index, attachment] of ( + JSON.parse(record[fieldName] as string) as IAttachment[] + ).entries()) { + const file = await apiRequest.call(this, 'GET', '', {}, {}, attachment.url, { + json: false, + encoding: null, + }); + element.binary![`${fieldName}_${index}`] = await this.helpers.prepareBinaryData( + Buffer.from(file), + attachment.title, + attachment.mimetype, + ); } } } diff --git a/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts b/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts index 35c0f60d38..9100150cdd 100644 --- a/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts +++ b/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts @@ -1,7 +1,5 @@ /* eslint-disable n8n-nodes-base/node-filename-against-convention */ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryData, @@ -14,15 +12,9 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - apiRequest, - apiRequestAllItems, - downloadRecordAttachments, -} from './GenericFunctions'; +import { apiRequest, apiRequestAllItems, downloadRecordAttachments } from './GenericFunctions'; -import { - operationFields -} from './OperationDescription'; +import { operationFields } from './OperationDescription'; export class NocoDB implements INodeType { description: INodeTypeDescription = { @@ -44,9 +36,7 @@ export class NocoDB implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'nocoDb', - ], + authentication: ['nocoDb'], }, }, }, @@ -55,9 +45,7 @@ export class NocoDB implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'nocoDbApiToken', - ], + authentication: ['nocoDbApiToken'], }, }, }, @@ -85,9 +73,7 @@ export class NocoDB implements INodeType { type: 'options', displayOptions: { show: { - '@version': [ - 1, - ], + '@version': [1], }, }, isNodeSetting: true, @@ -109,9 +95,7 @@ export class NocoDB implements INodeType { type: 'options', displayOptions: { show: { - '@version': [ - 2, - ], + '@version': [2], }, }, isNodeSetting: true, @@ -147,9 +131,7 @@ export class NocoDB implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'row', - ], + resource: ['row'], }, }, options: [ @@ -201,7 +183,6 @@ export class NocoDB implements INodeType { } catch (e) { throw new NodeOperationError(this.getNode(), `Error while fetching projects! (${e})`); } - }, // This only supports using the Project ID async getTables(this: ILoadOptionsFunctions) { @@ -248,19 +229,21 @@ export class NocoDB implements INodeType { if (version === 1) { endPoint = `/nc/${projectId}/api/v1/${table}/bulk`; } else if (version === 2) { - endPoint = `/api/v1/db/data/bulk/noco/${projectId}/${table}`; + endPoint = `/api/v1/db/data/bulk/noco/${projectId}/${table}`; } const body: IDataObject[] = []; for (let i = 0; i < items.length; i++) { const newItem: IDataObject = {}; - const dataToSend = this.getNodeParameter('dataToSend', i) as 'defineBelow' | 'autoMapInputData'; + const dataToSend = this.getNodeParameter('dataToSend', i) as + | 'defineBelow' + | 'autoMapInputData'; if (dataToSend === 'autoMapInputData') { const incomingKeys = Object.keys(items[i].json); const rawInputsToIgnore = this.getNodeParameter('inputsToIgnore', i) as string; - const inputDataToIgnore = rawInputsToIgnore.split(',').map(c => c.trim()); + const inputDataToIgnore = rawInputsToIgnore.split(',').map((c) => c.trim()); for (const key of incomingKeys) { if (inputDataToIgnore.includes(key)) continue; newItem[key] = items[i].json[key]; @@ -278,11 +261,17 @@ export class NocoDB implements INodeType { newItem[field.fieldName] = field.fieldValue; } else if (field.binaryProperty) { if (!items[i].binary) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const binaryPropertyName = field.binaryProperty; if (binaryPropertyName && !items[i].binary![binaryPropertyName]) { - throw new NodeOperationError(this.getNode(), `Binary property ${binaryPropertyName} does not exist on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Binary property ${binaryPropertyName} does not exist on item!`, + { itemIndex: i }, + ); } const binaryData = items[i].binary![binaryPropertyName] as IBinaryData; const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); @@ -311,7 +300,9 @@ export class NocoDB implements INodeType { postUrl = '/api/v1/db/storage/upload'; } - responseData = await apiRequest.call(this, 'POST', postUrl, {}, qs, undefined, { formData }); + responseData = await apiRequest.call(this, 'POST', postUrl, {}, qs, undefined, { + formData, + }); newItem[field.fieldName] = JSON.stringify([responseData]); } } @@ -354,21 +345,26 @@ export class NocoDB implements INodeType { try { responseData = await apiRequest.call(this, requestMethod, endPoint, body, qs); if (version === 1) { - returnData.push(...items.map(item => item.json)); - } else if (version === 2 ) { - - returnData.push(...responseData.map((result: number, index: number) => { - if (result === 0) { - const errorMessage = `The row with the ID "${body[index].id}" could not be deleted. It probably doesn't exist.`; - if (this.continueOnFail()) { - return { error: errorMessage }; + returnData.push(...items.map((item) => item.json)); + } else if (version === 2) { + returnData.push( + ...responseData.map((result: number, index: number) => { + if (result === 0) { + const errorMessage = `The row with the ID "${body[index].id}" could not be deleted. It probably doesn't exist.`; + if (this.continueOnFail()) { + return { error: errorMessage }; + } + throw new NodeApiError( + this.getNode(), + { message: errorMessage }, + { message: errorMessage, itemIndex: index }, + ); } - throw new NodeApiError(this.getNode(), { message: errorMessage }, { message: errorMessage, itemIndex: index }); - } - return { - success: true, - }; - })); + return { + success: true, + }; + }), + ); } } catch (error) { if (this.continueOnFail()) { @@ -387,7 +383,7 @@ export class NocoDB implements INodeType { if (version === 1) { endPoint = `/nc/${projectId}/api/v1/${table}`; - } else if (version === 2 ) { + } else if (version === 2) { endPoint = `/api/v1/db/data/noco/${projectId}/${table}`; } @@ -395,8 +391,13 @@ export class NocoDB implements INodeType { qs = this.getNodeParameter('options', i, {}) as IDataObject; if (qs.sort) { - const properties = (qs.sort as IDataObject).property as Array<{ field: string, direction: string }>; - qs.sort = properties.map(prop => `${prop.direction === 'asc' ? '' : '-'}${prop.field}`).join(','); + const properties = (qs.sort as IDataObject).property as Array<{ + field: string; + direction: string; + }>; + qs.sort = properties + .map((prop) => `${prop.direction === 'asc' ? '' : '-'}${prop.field}`) + .join(','); } if (qs.fields) { @@ -416,8 +417,14 @@ export class NocoDB implements INodeType { returnData.push.apply(returnData, responseData); if (downloadAttachments === true) { - const downloadFieldNames = (this.getNodeParameter('downloadFieldNames', 0) as string).split(','); - const response = await downloadRecordAttachments.call(this, responseData, downloadFieldNames); + const downloadFieldNames = ( + this.getNodeParameter('downloadFieldNames', 0) as string + ).split(','); + const response = await downloadRecordAttachments.call( + this, + responseData, + downloadFieldNames, + ); data.push(...response); } } @@ -425,8 +432,7 @@ export class NocoDB implements INodeType { if (downloadAttachments) { return [data]; } - - } catch (error) { + } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.toString() }); } @@ -444,7 +450,7 @@ export class NocoDB implements INodeType { if (version === 1) { endPoint = `/nc/${projectId}/api/v1/${table}/${id}`; - } else if (version === 2) { + } else if (version === 2) { endPoint = `/api/v1/db/data/noco/${projectId}/${table}/${id}`; } @@ -454,7 +460,7 @@ export class NocoDB implements INodeType { if (version === 1) { newItem = { json: responseData }; - } else if (version === 2 ) { + } else if (version === 2) { if (Object.keys(responseData).length === 0) { // Get did fail const errorMessage = `The row with the ID "${id}" could not be queried. It probably doesn't exist.`; @@ -463,7 +469,11 @@ export class NocoDB implements INodeType { json: { error: errorMessage }, }; } - throw new NodeApiError(this.getNode(), { message: errorMessage }, { message: errorMessage, itemIndex: i }); + throw new NodeApiError( + this.getNode(), + { message: errorMessage }, + { message: errorMessage, itemIndex: i }, + ); } else { // Get did work newItem = { json: responseData }; @@ -474,8 +484,14 @@ export class NocoDB implements INodeType { const downloadAttachments = this.getNodeParameter('downloadAttachments', i) as boolean; if (downloadAttachments === true) { - const downloadFieldNames = (this.getNodeParameter('downloadFieldNames', i) as string).split(','); - const data = await downloadRecordAttachments.call(this, [responseData], downloadFieldNames); + const downloadFieldNames = ( + this.getNodeParameter('downloadFieldNames', i) as string + ).split(','); + const data = await downloadRecordAttachments.call( + this, + [responseData], + downloadFieldNames, + ); newItem.binary = data[0].binary; } @@ -492,7 +508,6 @@ export class NocoDB implements INodeType { } if (operation === 'update') { - let requestMethod = 'PATCH'; if (version === 1) { @@ -504,15 +519,16 @@ export class NocoDB implements INodeType { const body: IDataObject[] = []; for (let i = 0; i < items.length; i++) { - const id = this.getNodeParameter('id', i) as string; const newItem: IDataObject = { id }; - const dataToSend = this.getNodeParameter('dataToSend', i) as 'defineBelow' | 'autoMapInputData'; + const dataToSend = this.getNodeParameter('dataToSend', i) as + | 'defineBelow' + | 'autoMapInputData'; if (dataToSend === 'autoMapInputData') { const incomingKeys = Object.keys(items[i].json); const rawInputsToIgnore = this.getNodeParameter('inputsToIgnore', i) as string; - const inputDataToIgnore = rawInputsToIgnore.split(',').map(c => c.trim()); + const inputDataToIgnore = rawInputsToIgnore.split(',').map((c) => c.trim()); for (const key of incomingKeys) { if (inputDataToIgnore.includes(key)) continue; newItem[key] = items[i].json[key]; @@ -530,11 +546,17 @@ export class NocoDB implements INodeType { newItem[field.fieldName] = field.fieldValue; } else if (field.binaryProperty) { if (!items[i].binary) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const binaryPropertyName = field.binaryProperty; if (binaryPropertyName && !items[i].binary![binaryPropertyName]) { - throw new NodeOperationError(this.getNode(), `Binary property ${binaryPropertyName} does not exist on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Binary property ${binaryPropertyName} does not exist on item!`, + { itemIndex: i }, + ); } const binaryData = items[i].binary![binaryPropertyName] as IBinaryData; const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); @@ -561,7 +583,9 @@ export class NocoDB implements INodeType { } else if (version === 2) { postUrl = '/api/v1/db/storage/upload'; } - responseData = await apiRequest.call(this, 'POST', postUrl, {}, qs, undefined, { formData }); + responseData = await apiRequest.call(this, 'POST', postUrl, {}, qs, undefined, { + formData, + }); newItem[field.fieldName] = JSON.stringify([responseData]); } } @@ -574,19 +598,25 @@ export class NocoDB implements INodeType { if (version === 1) { returnData.push(...body); - } else if (version === 2 ) { - returnData.push(...responseData.map((result: number, index: number) => { - if (result === 0) { - const errorMessage = `The row with the ID "${body[index].id}" could not be updated. It probably doesn't exist.`; - if (this.continueOnFail()) { - return { error: errorMessage }; + } else if (version === 2) { + returnData.push( + ...responseData.map((result: number, index: number) => { + if (result === 0) { + const errorMessage = `The row with the ID "${body[index].id}" could not be updated. It probably doesn't exist.`; + if (this.continueOnFail()) { + return { error: errorMessage }; + } + throw new NodeApiError( + this.getNode(), + { message: errorMessage }, + { message: errorMessage, itemIndex: index }, + ); } - throw new NodeApiError(this.getNode(), { message: errorMessage }, { message: errorMessage, itemIndex: index }); - } - return { - success: true, - }; - })); + return { + success: true, + }; + }), + ); } } catch (error) { if (this.continueOnFail()) { diff --git a/packages/nodes-base/nodes/NocoDB/OperationDescription.ts b/packages/nodes-base/nodes/NocoDB/OperationDescription.ts index 9e4d4f4c00..b62a583b9b 100644 --- a/packages/nodes-base/nodes/NocoDB/OperationDescription.ts +++ b/packages/nodes-base/nodes/NocoDB/OperationDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const operationFields: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const operationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - version: [ - 1, - ], + version: [1], }, }, required: true, @@ -28,13 +24,12 @@ export const operationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - version: [ - 2, - ], + version: [2], }, }, required: true, - description: 'Choose from the list, or specify an ID using an expression. Choose from the list, or specify an ID using an expression. Choose from the list, or specify an ID using an expression.', + description: + 'Choose from the list, or specify an ID using an expression. Choose from the list, or specify an ID using an expression. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getProjects', }, @@ -46,17 +41,14 @@ export const operationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - version: [ - 2, - ], + version: [2], }, }, required: true, - description: 'The table to operate on. Choose from the list, or specify an ID using an expression. Choose from the list, or specify an ID using an expression.', + description: + 'The table to operate on. Choose from the list, or specify an ID using an expression. Choose from the list, or specify an ID using an expression.', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTables', }, }, @@ -67,9 +59,7 @@ export const operationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - version: [ - 1, - ], + version: [1], }, }, required: true, @@ -84,9 +74,7 @@ export const operationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], }, }, default: '', @@ -102,9 +90,7 @@ export const operationFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: false, @@ -116,12 +102,8 @@ export const operationFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -137,13 +119,11 @@ export const operationFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: false, - description: 'Whether the attachment fields define in \'Download Fields\' will be downloaded', + description: "Whether the attachment fields define in 'Download Fields' will be downloaded", }, { displayName: 'Download Fields', @@ -152,16 +132,13 @@ export const operationFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - downloadAttachments: [ - true, - ], + operation: ['getAll'], + downloadAttachments: [true], }, }, default: '', - description: 'Name of the fields of type \'attachment\' that should be downloaded. Multiple ones can be defined separated by comma. Case sensitive.', + description: + "Name of the fields of type 'attachment' that should be downloaded. Multiple ones can be defined separated by comma. Case sensitive.", }, { displayName: 'Options', @@ -169,9 +146,7 @@ export const operationFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: {}, @@ -242,7 +217,6 @@ export const operationFields: INodeProperties[] = [ }, ], }, - ], }, // ---------------------------------- @@ -254,9 +228,7 @@ export const operationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], }, }, default: '', @@ -269,13 +241,11 @@ export const operationFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], }, }, default: false, - description: 'Whether the attachment fields define in \'Download Fields\' will be downloaded', + description: "Whether the attachment fields define in 'Download Fields' will be downloaded", }, { displayName: 'Download Fields', @@ -284,16 +254,13 @@ export const operationFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - downloadAttachments: [ - true, - ], + operation: ['get'], + downloadAttachments: [true], }, }, default: '', - description: 'Name of the fields of type \'attachment\' that should be downloaded. Multiple ones can be defined separated by comma. Case sensitive.', + description: + "Name of the fields of type 'attachment' that should be downloaded. Multiple ones can be defined separated by comma. Case sensitive.", }, // ---------------------------------- // update @@ -304,9 +271,7 @@ export const operationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: '', @@ -334,10 +299,7 @@ export const operationFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'create', - 'update', - ], + operation: ['create', 'update'], }, }, default: 'defineBelow', @@ -349,17 +311,13 @@ export const operationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - 'update', - ], - dataToSend: [ - 'autoMapInputData', - ], + operation: ['create', 'update'], + dataToSend: ['autoMapInputData'], }, }, default: '', - description: 'List of input properties to avoid sending, separated by commas. Leave empty to send all properties.', + description: + 'List of input properties to avoid sending, separated by commas. Leave empty to send all properties.', placeholder: 'Enter properties...', }, { @@ -373,13 +331,8 @@ export const operationFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - 'update', - ], - dataToSend: [ - 'defineBelow', - ], + operation: ['create', 'update'], + dataToSend: ['defineBelow'], }, }, default: {}, @@ -399,7 +352,8 @@ export const operationFields: INodeProperties[] = [ name: 'binaryData', type: 'boolean', default: false, - description: 'Whether the field data to set is binary and should be taken from a binary property', + description: + 'Whether the field data to set is binary and should be taken from a binary property', }, { displayName: 'Field Value', @@ -408,9 +362,7 @@ export const operationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - binaryData: [ - false, - ], + binaryData: [false], }, }, }, @@ -422,9 +374,7 @@ export const operationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - binaryData: [ - true, - ], + binaryData: [true], }, }, }, diff --git a/packages/nodes-base/nodes/Notion/BlockDescription.ts b/packages/nodes-base/nodes/Notion/BlockDescription.ts index 3aaf8db31a..bae7b1ff0b 100644 --- a/packages/nodes-base/nodes/Notion/BlockDescription.ts +++ b/packages/nodes-base/nodes/Notion/BlockDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - blocks, -} from './Blocks'; +import { blocks } from './Blocks'; export const blockOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const blockOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'block', - ], + resource: ['block'], }, }, options: [ @@ -39,7 +33,6 @@ export const blockOperations: INodeProperties[] = [ ]; export const blockFields = [ - /* -------------------------------------------------------------------------- */ /* block:append */ /* -------------------------------------------------------------------------- */ @@ -51,15 +44,12 @@ export const blockFields = [ required: true, displayOptions: { show: { - resource: [ - 'block', - ], - operation: [ - 'append', - ], + resource: ['block'], + operation: ['append'], }, }, - description: 'The Block URL from Notion\'s \'copy link\' functionality (or just the ID contained within the URL). Pages are also blocks, so you can use a page URL/ID here too.', + description: + "The Block URL from Notion's 'copy link' functionality (or just the ID contained within the URL). Pages are also blocks, so you can use a page URL/ID here too.", }, ...blocks('block', 'append'), /* -------------------------------------------------------------------------- */ @@ -73,15 +63,12 @@ export const blockFields = [ required: true, displayOptions: { show: { - resource: [ - 'block', - ], - operation: [ - 'getAll', - ], + resource: ['block'], + operation: ['getAll'], }, }, - description: 'The Block URL from Notion\'s \'copy link\' functionality (or just the ID contained within the URL). Pages are also blocks, so you can use a page URL/ID here too.', + description: + "The Block URL from Notion's 'copy link' functionality (or just the ID contained within the URL). Pages are also blocks, so you can use a page URL/ID here too.", }, { displayName: 'Return All', @@ -89,12 +76,8 @@ export const blockFields = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'block', - ], - operation: [ - 'getAll', - ], + resource: ['block'], + operation: ['getAll'], }, }, default: false, @@ -106,15 +89,9 @@ export const blockFields = [ type: 'number', displayOptions: { show: { - resource: [ - 'block', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['block'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Notion/Blocks.ts b/packages/nodes-base/nodes/Notion/Blocks.ts index d920a4493d..c1e9a872db 100644 --- a/packages/nodes-base/nodes/Notion/Blocks.ts +++ b/packages/nodes-base/nodes/Notion/Blocks.ts @@ -1,7 +1,4 @@ -import { - IDisplayOptions, - INodeProperties, -} from 'n8n-workflow'; +import { IDisplayOptions, INodeProperties } from 'n8n-workflow'; const colors = [ { @@ -145,9 +142,7 @@ const typeMention: INodeProperties[] = [ type: 'options', displayOptions: { show: { - textType: [ - 'mention', - ], + textType: ['mention'], }, }, options: [ @@ -169,7 +164,8 @@ const typeMention: INodeProperties[] = [ }, ], default: '', - description: 'An inline mention of a user, page, database, or date. In the app these are created by typing @ followed by the name of a user, page, database, or a date.', + description: + 'An inline mention of a user, page, database, or date. In the app these are created by typing @ followed by the name of a user, page, database, or a date.', }, { displayName: 'User Name or ID', @@ -180,13 +176,12 @@ const typeMention: INodeProperties[] = [ }, displayOptions: { show: { - mentionType: [ - 'user', - ], + mentionType: ['user'], }, }, default: '', - description: 'The ID of the user being mentioned. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the user being mentioned. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Page ID', @@ -194,9 +189,7 @@ const typeMention: INodeProperties[] = [ type: 'string', displayOptions: { show: { - mentionType: [ - 'page', - ], + mentionType: ['page'], }, }, default: '', @@ -211,22 +204,19 @@ const typeMention: INodeProperties[] = [ }, displayOptions: { show: { - mentionType: [ - 'database', - ], + mentionType: ['database'], }, }, default: '', - description: 'The ID of the database being mentioned. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the database being mentioned. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Range', name: 'range', displayOptions: { show: { - mentionType: [ - 'date', - ], + mentionType: ['date'], }, }, type: 'boolean', @@ -238,12 +228,8 @@ const typeMention: INodeProperties[] = [ name: 'date', displayOptions: { show: { - mentionType: [ - 'date', - ], - range: [ - false, - ], + mentionType: ['date'], + range: [false], }, }, type: 'dateTime', @@ -255,12 +241,8 @@ const typeMention: INodeProperties[] = [ name: 'dateStart', displayOptions: { show: { - mentionType: [ - 'date', - ], - range: [ - true, - ], + mentionType: ['date'], + range: [true], }, }, type: 'dateTime', @@ -272,17 +254,14 @@ const typeMention: INodeProperties[] = [ name: 'dateEnd', displayOptions: { show: { - range: [ - true, - ], - mentionType: [ - 'date', - ], + range: [true], + mentionType: ['date'], }, }, type: 'dateTime', default: '', - description: 'An ISO 8601 formatted date, with optional time. Represents the end of a date range.', + description: + 'An ISO 8601 formatted date, with optional time. Represents the end of a date range.', }, ]; @@ -293,9 +272,7 @@ const typeEquation: INodeProperties[] = [ type: 'string', displayOptions: { show: { - textType: [ - 'equation', - ], + textType: ['equation'], }, }, default: '', @@ -308,23 +285,20 @@ const typeText: INodeProperties[] = [ name: 'text', displayOptions: { show: { - textType: [ - 'text', - ], + textType: ['text'], }, }, type: 'string', default: '', - description: 'Text content. This field contains the actual content of your text and is probably the field you\'ll use most often.', + description: + "Text content. This field contains the actual content of your text and is probably the field you'll use most often.", }, { displayName: 'Is Link', name: 'isLink', displayOptions: { show: { - textType: [ - 'text', - ], + textType: ['text'], }, }, type: 'boolean', @@ -335,12 +309,8 @@ const typeText: INodeProperties[] = [ name: 'textLink', displayOptions: { show: { - textType: [ - 'text', - ], - isLink: [ - true, - ], + textType: ['text'], + isLink: [true], }, }, type: 'string', @@ -349,83 +319,86 @@ const typeText: INodeProperties[] = [ }, ]; -export const text = (displayOptions: IDisplayOptions): INodeProperties[] => [ - { - displayName: 'Text', - name: 'text', - placeholder: 'Add Text', - type: 'fixedCollection', - default: {}, - typeOptions: { - multipleValues: true, - }, - displayOptions, - options: [ - { - name: 'text', - displayName: 'Text', - values: [ - { - displayName: 'Type', - name: 'textType', - type: 'options', - options: [ - { - name: 'Equation', - value: 'equation', - }, - { - name: 'Mention', - value: 'mention', - }, - { - name: 'Text', - value: 'text', - }, - ], - default: 'text', - }, - ...typeText, - ...typeMention, - ...typeEquation, - - ...annotation, - ], +export const text = (displayOptions: IDisplayOptions): INodeProperties[] => + [ + { + displayName: 'Text', + name: 'text', + placeholder: 'Add Text', + type: 'fixedCollection', + default: {}, + typeOptions: { + multipleValues: true, }, - ], - description: 'Rich text in the block', - }] as INodeProperties[]; + displayOptions, + options: [ + { + name: 'text', + displayName: 'Text', + values: [ + { + displayName: 'Type', + name: 'textType', + type: 'options', + options: [ + { + name: 'Equation', + value: 'equation', + }, + { + name: 'Mention', + value: 'mention', + }, + { + name: 'Text', + value: 'text', + }, + ], + default: 'text', + }, + ...typeText, + ...typeMention, + ...typeEquation, - -const todo = (type: string): INodeProperties[] => [{ - displayName: 'Checked', - name: 'checked', - type: 'boolean', - default: false, - displayOptions: { - show: { - type: [ - type, + ...annotation, + ], + }, ], + description: 'Rich text in the block', }, - }, - description: 'Whether the to_do is checked or not', -}] as INodeProperties[]; + ] as INodeProperties[]; -const title = (type: string): INodeProperties[] => [{ - displayName: 'Title', - name: 'title', - type: 'string', - default: '', - displayOptions: { - show: { - type: [ - type, - ], +const todo = (type: string): INodeProperties[] => + [ + { + displayName: 'Checked', + name: 'checked', + type: 'boolean', + default: false, + displayOptions: { + show: { + type: [type], + }, + }, + description: 'Whether the to_do is checked or not', }, - }, - description: 'Plain text of page title', -}] as INodeProperties[]; + ] as INodeProperties[]; + +const title = (type: string): INodeProperties[] => + [ + { + displayName: 'Title', + name: 'title', + type: 'string', + default: '', + displayOptions: { + show: { + type: [type], + }, + }, + description: 'Plain text of page title', + }, + ] as INodeProperties[]; const richText = (displayOptions: IDisplayOptions): INodeProperties[] => [ { @@ -452,115 +425,105 @@ const block = (blockType: string): INodeProperties[] => { switch (blockType) { case 'to_do': data.push(...todo(blockType)); - data.push(...richText({ - show: { - type: [ - blockType, - ], - }, - })); - data.push(...textContent({ - show: { - type: [ - blockType, - ], - richText: [ - false, - ], - }, - })); - data.push(...text({ - show: { - type: [ - blockType, - ], - richText: [ - true, - ], - }, - })); + data.push( + ...richText({ + show: { + type: [blockType], + }, + }), + ); + data.push( + ...textContent({ + show: { + type: [blockType], + richText: [false], + }, + }), + ); + data.push( + ...text({ + show: { + type: [blockType], + richText: [true], + }, + }), + ); break; case 'child_page': data.push(...title(blockType)); break; default: - data.push(...richText({ - show: { - type: [ - blockType, - ], - }, - })); - data.push(...textContent({ - show: { - type: [ - blockType, - ], - richText: [ - false, - ], - }, - })); - data.push(...text({ - show: { - type: [ - blockType, - ], - richText: [ - true, - ], - }, - })); + data.push( + ...richText({ + show: { + type: [blockType], + }, + }), + ); + data.push( + ...textContent({ + show: { + type: [blockType], + richText: [false], + }, + }), + ); + data.push( + ...text({ + show: { + type: [blockType], + richText: [true], + }, + }), + ); break; } return data; }; -export const blocks = (resource: string, operation: string): INodeProperties[] => [{ - displayName: 'Blocks', - name: 'blockUi', - type: 'fixedCollection', - typeOptions: { - multipleValues: true, - }, - default: {}, - displayOptions: { - show: { - resource: [ - resource, - ], - operation: [ - operation, - ], +export const blocks = (resource: string, operation: string): INodeProperties[] => [ + { + displayName: 'Blocks', + name: 'blockUi', + type: 'fixedCollection', + typeOptions: { + multipleValues: true, }, - }, - placeholder: 'Add Block', - options: [ - { - name: 'blockValues', - displayName: 'Block', - values: [ - { - displayName: 'Type Name or ID', - name: 'type', - type: 'options', - description: 'Choose from the list, or specify an ID using an expression', - typeOptions: { - loadOptionsMethod: 'getBlockTypes', + default: {}, + displayOptions: { + show: { + resource: [resource], + operation: [operation], + }, + }, + placeholder: 'Add Block', + options: [ + { + name: 'blockValues', + displayName: 'Block', + values: [ + { + displayName: 'Type Name or ID', + name: 'type', + type: 'options', + description: + 'Choose from the list, or specify an ID using an expression', + typeOptions: { + loadOptionsMethod: 'getBlockTypes', + }, + default: 'paragraph', }, - default: 'paragraph', - }, - ...block('paragraph'), - ...block('heading_1'), - ...block('heading_2'), - ...block('heading_3'), - ...block('toggle'), - ...block('to_do'), - ...block('child_page'), - ...block('bulleted_list_item'), - ...block('numbered_list_item'), - ], - }, - ], -}, + ...block('paragraph'), + ...block('heading_1'), + ...block('heading_2'), + ...block('heading_3'), + ...block('toggle'), + ...block('to_do'), + ...block('child_page'), + ...block('bulleted_list_item'), + ...block('numbered_list_item'), + ], + }, + ], + }, ]; diff --git a/packages/nodes-base/nodes/Notion/DatabaseDescription.ts b/packages/nodes-base/nodes/Notion/DatabaseDescription.ts index d6d2bc7f63..b72db4eea8 100644 --- a/packages/nodes-base/nodes/Notion/DatabaseDescription.ts +++ b/packages/nodes-base/nodes/Notion/DatabaseDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const databaseOperations: INodeProperties[] = [ { @@ -10,12 +8,8 @@ export const databaseOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - version: [ - 2, - ], - resource: [ - 'database', - ], + version: [2], + resource: ['database'], }, }, options: [ @@ -47,12 +41,8 @@ export const databaseOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - version: [ - 1, - ], - resource: [ - 'database', - ], + version: [1], + resource: ['database'], }, }, options: [ @@ -74,7 +64,6 @@ export const databaseOperations: INodeProperties[] = [ ]; export const databaseFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* database:get */ /* -------------------------------------------------------------------------- */ @@ -86,15 +75,12 @@ export const databaseFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'database', - ], - operation: [ - 'get', - ], + resource: ['database'], + operation: ['get'], }, }, - description: 'The Database URL from Notion\'s \'copy link\' functionality (or just the ID contained within the URL)', + description: + "The Database URL from Notion's 'copy link' functionality (or just the ID contained within the URL)", }, /* -------------------------------------------------------------------------- */ /* database:getAll */ @@ -105,12 +91,8 @@ export const databaseFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'database', - ], - operation: [ - 'getAll', - ], + resource: ['database'], + operation: ['getAll'], }, }, default: false, @@ -122,15 +104,9 @@ export const databaseFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'database', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['database'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -146,16 +122,9 @@ export const databaseFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - version: [ - 2, - ], - resource: [ - 'database', - ], - operation: [ - 'getAll', - 'get', - ], + version: [2], + resource: ['database'], + operation: ['getAll', 'get'], }, }, default: true, @@ -171,12 +140,8 @@ export const databaseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'database', - ], - operation: [ - 'search', - ], + resource: ['database'], + operation: ['search'], }, }, description: 'The text to search for', @@ -187,12 +152,8 @@ export const databaseFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'database', - ], - operation: [ - 'search', - ], + resource: ['database'], + operation: ['search'], }, }, default: false, @@ -204,15 +165,9 @@ export const databaseFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'database', - ], - operation: [ - 'search', - ], - returnAll: [ - false, - ], + resource: ['database'], + operation: ['search'], + returnAll: [false], }, }, typeOptions: { @@ -228,12 +183,8 @@ export const databaseFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'database', - ], - operation: [ - 'search', - ], + resource: ['database'], + operation: ['search'], }, }, default: true, @@ -245,12 +196,8 @@ export const databaseFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - resource: [ - 'database', - ], - operation: [ - 'search', - ], + resource: ['database'], + operation: ['search'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/Notion/DatabasePageDescription.ts b/packages/nodes-base/nodes/Notion/DatabasePageDescription.ts index 6848f1087e..1e0064e7df 100644 --- a/packages/nodes-base/nodes/Notion/DatabasePageDescription.ts +++ b/packages/nodes-base/nodes/Notion/DatabasePageDescription.ts @@ -1,20 +1,10 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - getConditions, - getSearchFilters, -} from './GenericFunctions'; +import { getConditions, getSearchFilters } from './GenericFunctions'; -import { - blocks, - text, -} from './Blocks'; +import { blocks, text } from './Blocks'; -import { - filters, -} from './Filters'; +import { filters } from './Filters'; export const databasePageOperations: INodeProperties[] = [ { @@ -24,12 +14,8 @@ export const databasePageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - version: [ - 2, - ], - resource: [ - 'databasePage', - ], + version: [2], + resource: ['databasePage'], }, }, options: [ @@ -67,12 +53,8 @@ export const databasePageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - version: [ - 1, - ], - resource: [ - 'databasePage', - ], + version: [1], + resource: ['databasePage'], }, }, options: [ @@ -100,7 +82,6 @@ export const databasePageOperations: INodeProperties[] = [ ]; export const databasePageFields = [ - /* -------------------------------------------------------------------------- */ /* databasePage:create */ /* -------------------------------------------------------------------------- */ @@ -115,15 +96,12 @@ export const databasePageFields = [ required: true, displayOptions: { show: { - resource: [ - 'databasePage', - ], - operation: [ - 'create', - ], + resource: ['databasePage'], + operation: ['create'], }, }, - description: 'The Database Page URL from Notion\'s \'copy link\' functionality (or just the ID contained within the URL). Choose from the list, or specify an ID using an expression.', + description: + "The Database Page URL from Notion's 'copy link' functionality (or just the ID contained within the URL). Choose from the list, or specify an ID using an expression.", }, { displayName: 'Title', @@ -132,15 +110,9 @@ export const databasePageFields = [ default: '', displayOptions: { show: { - version: [ - 2, - ], - resource: [ - 'databasePage', - ], - operation: [ - 'create', - ], + version: [2], + resource: ['databasePage'], + operation: ['create'], }, }, description: 'Page title. Appears at the top of the page and can be found via Quick Find.', @@ -151,12 +123,8 @@ export const databasePageFields = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'databasePage', - ], - operation: [ - 'create', - ], + resource: ['databasePage'], + operation: ['create'], }, }, default: true, @@ -171,12 +139,8 @@ export const databasePageFields = [ }, displayOptions: { show: { - resource: [ - 'databasePage', - ], - operation: [ - 'create', - ], + resource: ['databasePage'], + operation: ['create'], }, }, default: {}, @@ -190,12 +154,11 @@ export const databasePageFields = [ displayName: 'Key Name or ID', name: 'key', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getDatabaseProperties', - loadOptionsDependsOn: [ - 'databaseId', - ], + loadOptionsDependsOn: ['databaseId'], }, default: '', }, @@ -211,9 +174,7 @@ export const databasePageFields = [ type: 'string', displayOptions: { show: { - type: [ - 'title', - ], + type: ['title'], }, }, default: '', @@ -224,9 +185,7 @@ export const databasePageFields = [ type: 'boolean', displayOptions: { show: { - type: [ - 'rich_text', - ], + type: ['rich_text'], }, }, default: false, @@ -237,24 +196,16 @@ export const databasePageFields = [ type: 'string', displayOptions: { show: { - type: [ - 'rich_text', - ], - richText: [ - false, - ], + type: ['rich_text'], + richText: [false], }, }, default: '', }, ...text({ show: { - type: [ - 'rich_text', - ], - richText: [ - true, - ], + type: ['rich_text'], + richText: [true], }, }), { @@ -263,9 +214,7 @@ export const databasePageFields = [ type: 'string', displayOptions: { show: { - type: [ - 'phone_number', - ], + type: ['phone_number'], }, }, default: '', @@ -280,13 +229,12 @@ export const databasePageFields = [ }, displayOptions: { show: { - type: [ - 'multi_select', - ], + type: ['multi_select'], }, }, default: [], - description: 'Name of the options you want to set. Multiples can be defined separated by comma. Choose from the list, or specify IDs using an expression.', + description: + 'Name of the options you want to set. Multiples can be defined separated by comma. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Option Name or ID', @@ -297,13 +245,12 @@ export const databasePageFields = [ }, displayOptions: { show: { - type: [ - 'select', - ], + type: ['select'], }, }, default: '', - description: 'Name of the option you want to set. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the option you want to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Email', @@ -311,9 +258,7 @@ export const databasePageFields = [ type: 'string', displayOptions: { show: { - type: [ - 'email', - ], + type: ['email'], }, }, default: '', @@ -325,9 +270,7 @@ export const databasePageFields = [ type: 'boolean', displayOptions: { show: { - type: [ - 'url', - ], + type: ['url'], }, }, default: false, @@ -338,9 +281,7 @@ export const databasePageFields = [ type: 'string', displayOptions: { show: { - type: [ - 'url', - ], + type: ['url'], }, }, default: '', @@ -355,13 +296,12 @@ export const databasePageFields = [ }, displayOptions: { show: { - type: [ - 'people', - ], + type: ['people'], }, }, default: [], - description: 'List of users. Multiples can be defined separated by comma. Choose from the list, or specify IDs using an expression.', + description: + 'List of users. Multiples can be defined separated by comma. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Relation IDs', @@ -372,36 +312,32 @@ export const databasePageFields = [ }, displayOptions: { show: { - type: [ - 'relation', - ], + type: ['relation'], }, }, default: [], - description: 'List of databases that belong to another database. Multiples can be defined separated by comma.', + description: + 'List of databases that belong to another database. Multiples can be defined separated by comma.', }, { displayName: 'Checked', name: 'checkboxValue', displayOptions: { show: { - type: [ - 'checkbox', - ], + type: ['checkbox'], }, }, type: 'boolean', default: false, - description: 'Whether or not the checkbox is checked. true represents checked. false represents unchecked.', + description: + 'Whether or not the checkbox is checked. true represents checked. false represents unchecked.', }, { displayName: 'Number', name: 'numberValue', displayOptions: { show: { - type: [ - 'number', - ], + type: ['number'], }, }, type: 'number', @@ -413,9 +349,7 @@ export const databasePageFields = [ name: 'range', displayOptions: { show: { - type: [ - 'date', - ], + type: ['date'], }, }, type: 'boolean', @@ -427,9 +361,7 @@ export const databasePageFields = [ name: 'includeTime', displayOptions: { show: { - type: [ - 'date', - ], + type: ['date'], }, }, type: 'boolean', @@ -441,12 +373,8 @@ export const databasePageFields = [ name: 'date', displayOptions: { show: { - range: [ - false, - ], - type: [ - 'date', - ], + range: [false], + type: ['date'], }, }, type: 'dateTime', @@ -458,12 +386,8 @@ export const databasePageFields = [ name: 'dateStart', displayOptions: { show: { - range: [ - true, - ], - type: [ - 'date', - ], + range: [true], + type: ['date'], }, }, type: 'dateTime', @@ -475,17 +399,14 @@ export const databasePageFields = [ name: 'dateEnd', displayOptions: { show: { - range: [ - true, - ], - type: [ - 'date', - ], + range: [true], + type: ['date'], }, }, type: 'dateTime', default: '', - description: 'An ISO 8601 formatted date, with optional time. Represents the end of a date range.', + description: + 'An ISO 8601 formatted date, with optional time. Represents the end of a date range.', }, { displayName: 'Timezone Name or ID', @@ -493,16 +414,15 @@ export const databasePageFields = [ type: 'options', displayOptions: { show: { - type: [ - 'date', - ], + type: ['date'], }, }, typeOptions: { loadOptionsMethod: 'getTimezones', }, default: 'default', - description: 'Time zone to use. By default n8n timezone is used. Choose from the list, or specify an ID using an expression.', + description: + 'Time zone to use. By default n8n timezone is used. Choose from the list, or specify an ID using an expression.', }, { displayName: 'File URLs', @@ -515,12 +435,8 @@ export const databasePageFields = [ }, displayOptions: { show: { - '/version': [ - 2, - ], - type: [ - 'files', - ], + '/version': [2], + type: ['files'], }, }, default: {}, @@ -562,15 +478,12 @@ export const databasePageFields = [ required: true, displayOptions: { show: { - resource: [ - 'databasePage', - ], - operation: [ - 'update', - ], + resource: ['databasePage'], + operation: ['update'], }, }, - description: 'The Database Page URL from Notion\'s \'copy link\' functionality (or just the ID contained within the URL)', + description: + "The Database Page URL from Notion's 'copy link' functionality (or just the ID contained within the URL)", }, { displayName: 'Simplify', @@ -578,12 +491,8 @@ export const databasePageFields = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'databasePage', - ], - operation: [ - 'update', - ], + resource: ['databasePage'], + operation: ['update'], }, }, default: true, @@ -598,12 +507,8 @@ export const databasePageFields = [ }, displayOptions: { show: { - resource: [ - 'databasePage', - ], - operation: [ - 'update', - ], + resource: ['databasePage'], + operation: ['update'], }, }, default: {}, @@ -617,12 +522,11 @@ export const databasePageFields = [ displayName: 'Key Name or ID', name: 'key', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getDatabaseIdFromPage', - loadOptionsDependsOn: [ - 'pageId', - ], + loadOptionsDependsOn: ['pageId'], }, default: '', }, @@ -638,9 +542,7 @@ export const databasePageFields = [ type: 'string', displayOptions: { show: { - type: [ - 'title', - ], + type: ['title'], }, }, default: '', @@ -651,9 +553,7 @@ export const databasePageFields = [ type: 'boolean', displayOptions: { show: { - type: [ - 'rich_text', - ], + type: ['rich_text'], }, }, default: false, @@ -664,24 +564,16 @@ export const databasePageFields = [ type: 'string', displayOptions: { show: { - type: [ - 'rich_text', - ], - richText: [ - false, - ], + type: ['rich_text'], + richText: [false], }, }, default: '', }, ...text({ show: { - type: [ - 'rich_text', - ], - richText: [ - true, - ], + type: ['rich_text'], + richText: [true], }, }), { @@ -690,9 +582,7 @@ export const databasePageFields = [ type: 'string', displayOptions: { show: { - type: [ - 'phone_number', - ], + type: ['phone_number'], }, }, default: '', @@ -702,15 +592,14 @@ export const databasePageFields = [ displayName: 'Option Names or IDs', name: 'multiSelectValue', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getDatabaseOptionsFromPage', }, displayOptions: { show: { - type: [ - 'multi_select', - ], + type: ['multi_select'], }, }, default: [], @@ -719,15 +608,14 @@ export const databasePageFields = [ displayName: 'Option Name or ID', name: 'selectValue', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getDatabaseOptionsFromPage', }, displayOptions: { show: { - type: [ - 'select', - ], + type: ['select'], }, }, default: '', @@ -738,9 +626,7 @@ export const databasePageFields = [ type: 'string', displayOptions: { show: { - type: [ - 'email', - ], + type: ['email'], }, }, default: '', @@ -751,9 +637,7 @@ export const databasePageFields = [ type: 'boolean', displayOptions: { show: { - type: [ - 'url', - ], + type: ['url'], }, }, default: false, @@ -764,9 +648,7 @@ export const databasePageFields = [ type: 'string', displayOptions: { show: { - type: [ - 'url', - ], + type: ['url'], }, }, default: '', @@ -781,13 +663,12 @@ export const databasePageFields = [ }, displayOptions: { show: { - type: [ - 'people', - ], + type: ['people'], }, }, default: [], - description: 'List of users. Multiples can be defined separated by comma. Choose from the list, or specify IDs using an expression.', + description: + 'List of users. Multiples can be defined separated by comma. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Relation IDs', @@ -798,36 +679,32 @@ export const databasePageFields = [ }, displayOptions: { show: { - type: [ - 'relation', - ], + type: ['relation'], }, }, default: [], - description: 'List of databases that belong to another database. Multiples can be defined separated by comma.', + description: + 'List of databases that belong to another database. Multiples can be defined separated by comma.', }, { displayName: 'Checked', name: 'checkboxValue', displayOptions: { show: { - type: [ - 'checkbox', - ], + type: ['checkbox'], }, }, type: 'boolean', default: false, - description: 'Whether or not the checkbox is checked. true represents checked. false represents unchecked.', + description: + 'Whether or not the checkbox is checked. true represents checked. false represents unchecked.', }, { displayName: 'Number', name: 'numberValue', displayOptions: { show: { - type: [ - 'number', - ], + type: ['number'], }, }, type: 'number', @@ -839,9 +716,7 @@ export const databasePageFields = [ name: 'range', displayOptions: { show: { - type: [ - 'date', - ], + type: ['date'], }, }, type: 'boolean', @@ -853,9 +728,7 @@ export const databasePageFields = [ name: 'includeTime', displayOptions: { show: { - type: [ - 'date', - ], + type: ['date'], }, }, type: 'boolean', @@ -867,12 +740,8 @@ export const databasePageFields = [ name: 'date', displayOptions: { show: { - range: [ - false, - ], - type: [ - 'date', - ], + range: [false], + type: ['date'], }, }, type: 'dateTime', @@ -884,12 +753,8 @@ export const databasePageFields = [ name: 'dateStart', displayOptions: { show: { - range: [ - true, - ], - type: [ - 'date', - ], + range: [true], + type: ['date'], }, }, type: 'dateTime', @@ -901,17 +766,14 @@ export const databasePageFields = [ name: 'dateEnd', displayOptions: { show: { - range: [ - true, - ], - type: [ - 'date', - ], + range: [true], + type: ['date'], }, }, type: 'dateTime', default: '', - description: 'An ISO 8601 formatted date, with optional time. Represents the end of a date range.', + description: + 'An ISO 8601 formatted date, with optional time. Represents the end of a date range.', }, { displayName: 'Timezone Name or ID', @@ -919,16 +781,15 @@ export const databasePageFields = [ type: 'options', displayOptions: { show: { - type: [ - 'date', - ], + type: ['date'], }, }, typeOptions: { loadOptionsMethod: 'getTimezones', }, default: 'default', - description: 'Time zone to use. By default n8n timezone is used. Choose from the list, or specify an ID using an expression.', + description: + 'Time zone to use. By default n8n timezone is used. Choose from the list, or specify an ID using an expression.', }, { displayName: 'File URLs', @@ -941,12 +802,8 @@ export const databasePageFields = [ }, displayOptions: { show: { - '/version': [ - 2, - ], - type: [ - 'files', - ], + '/version': [2], + type: ['files'], }, }, default: {}, @@ -987,18 +844,13 @@ export const databasePageFields = [ required: true, displayOptions: { show: { - version: [ - 2, - ], - resource: [ - 'databasePage', - ], - operation: [ - 'get', - ], + version: [2], + resource: ['databasePage'], + operation: ['get'], }, }, - description: 'The Database Page URL from Notion\'s \'copy link\' functionality (or just the ID contained within the URL)', + description: + "The Database Page URL from Notion's 'copy link' functionality (or just the ID contained within the URL)", }, { displayName: 'Simplify', @@ -1006,15 +858,9 @@ export const databasePageFields = [ type: 'boolean', displayOptions: { show: { - version: [ - 2, - ], - resource: [ - 'databasePage', - ], - operation: [ - 'get', - ], + version: [2], + resource: ['databasePage'], + operation: ['get'], }, }, default: true, @@ -1027,7 +873,8 @@ export const databasePageFields = [ displayName: 'Database Name or ID', name: 'databaseId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getDatabases', }, @@ -1035,12 +882,8 @@ export const databasePageFields = [ required: true, displayOptions: { show: { - resource: [ - 'databasePage', - ], - operation: [ - 'getAll', - ], + resource: ['databasePage'], + operation: ['getAll'], }, }, }, @@ -1050,12 +893,8 @@ export const databasePageFields = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'databasePage', - ], - operation: [ - 'getAll', - ], + resource: ['databasePage'], + operation: ['getAll'], }, }, default: false, @@ -1067,15 +906,9 @@ export const databasePageFields = [ type: 'number', displayOptions: { show: { - resource: [ - 'databasePage', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['databasePage'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -1091,12 +924,8 @@ export const databasePageFields = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'databasePage', - ], - operation: [ - 'getAll', - ], + resource: ['databasePage'], + operation: ['getAll'], }, }, default: true, @@ -1109,12 +938,8 @@ export const databasePageFields = [ type: 'collection', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'databasePage', - ], + operation: ['getAll'], + resource: ['databasePage'], }, }, default: {}, @@ -1126,19 +951,13 @@ export const databasePageFields = [ type: 'boolean', displayOptions: { show: { - '/version': [ - 2, - ], - '/resource': [ - 'databasePage', - ], - '/operation': [ - 'getAll', - ], + '/version': [2], + '/resource': ['databasePage'], + '/operation': ['getAll'], }, }, default: false, - description: 'Whether to download a file if a database\'s field contains it', + description: "Whether to download a file if a database's field contains it", }, { displayName: 'Filters', @@ -1150,9 +969,7 @@ export const databasePageFields = [ }, displayOptions: { show: { - '/version': [ - 1, - ], + '/version': [1], }, }, default: {}, @@ -1160,9 +977,7 @@ export const databasePageFields = [ { displayName: 'Single Condition', name: 'singleCondition', - values: [ - ...filters(getConditions()), - ], + values: [...filters(getConditions())], }, { displayName: 'Multiple Condition', @@ -1181,16 +996,12 @@ export const databasePageFields = [ { displayName: 'OR', name: 'or', - values: [ - ...filters(getConditions()), - ], + values: [...filters(getConditions())], }, { displayName: 'AND', name: 'and', - values: [ - ...filters(getConditions()), - ], + values: [...filters(getConditions())], }, ], }, @@ -1217,7 +1028,7 @@ export const databasePageFields = [ name: 'timestamp', type: 'boolean', default: false, - description: 'Whether or not to use the record\'s timestamp to sort the response', + description: "Whether or not to use the record's timestamp to sort the response", }, { displayName: 'Property Name or ID', @@ -1225,19 +1036,16 @@ export const databasePageFields = [ type: 'options', displayOptions: { show: { - timestamp: [ - false, - ], + timestamp: [false], }, }, typeOptions: { loadOptionsMethod: 'getFilterProperties', - loadOptionsDependsOn: [ - 'datatabaseId', - ], + loadOptionsDependsOn: ['datatabaseId'], }, default: '', - description: 'The name of the property to filter by. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the property to filter by. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Property Name', @@ -1255,9 +1063,7 @@ export const databasePageFields = [ ], displayOptions: { show: { - timestamp: [ - true, - ], + timestamp: [true], }, }, default: '', @@ -1269,9 +1075,7 @@ export const databasePageFields = [ type: 'hidden', displayOptions: { show: { - timestamp: [ - true, - ], + timestamp: [true], }, }, default: '={{$parameter["&key"].split("|")[1]}}', diff --git a/packages/nodes-base/nodes/Notion/Filters.ts b/packages/nodes-base/nodes/Notion/Filters.ts index 29ed2af335..bfde770052 100644 --- a/packages/nodes-base/nodes/Notion/Filters.ts +++ b/packages/nodes-base/nodes/Notion/Filters.ts @@ -1,459 +1,373 @@ - - // tslint:disable-next-line: no-any -export const filters = (conditions: any) => [{ - displayName: 'Property Name or ID', - name: 'key', - type: 'options', - typeOptions: { - loadOptionsMethod: 'getFilterProperties', - loadOptionsDependsOn: [ - 'datatabaseId', - ], +export const filters = (conditions: any) => [ + { + displayName: 'Property Name or ID', + name: 'key', + type: 'options', + typeOptions: { + loadOptionsMethod: 'getFilterProperties', + loadOptionsDependsOn: ['datatabaseId'], + }, + default: '', + description: + 'The name of the property to filter by. Choose from the list, or specify an ID using an expression.', }, - default: '', - description: 'The name of the property to filter by. Choose from the list, or specify an ID using an expression.', -}, -{ - displayName: 'Type', - name: 'type', - type: 'hidden', - default: '={{$parameter["&key"].split("|")[1]}}', -}, -...conditions, -{ - displayName: 'Title', - name: 'titleValue', - type: 'string', - displayOptions: { - show: { - type: [ - 'title', - ], - }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - ], - }, + { + displayName: 'Type', + name: 'type', + type: 'hidden', + default: '={{$parameter["&key"].split("|")[1]}}', }, - default: '', -}, -{ - displayName: 'Text', - name: 'richTextValue', - type: 'string', - displayOptions: { - show: { - type: [ - 'rich_text', - ], - }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - ], + ...conditions, + { + displayName: 'Title', + name: 'titleValue', + type: 'string', + displayOptions: { + show: { + type: ['title'], + }, + hide: { + condition: ['is_empty', 'is_not_empty'], + }, }, + default: '', }, - default: '', -}, -{ - displayName: 'Phone Number', - name: 'phoneNumberValue', - type: 'string', - displayOptions: { - show: { - type: [ - 'phone_number', - ], - }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - ], + { + displayName: 'Text', + name: 'richTextValue', + type: 'string', + displayOptions: { + show: { + type: ['rich_text'], + }, + hide: { + condition: ['is_empty', 'is_not_empty'], + }, }, + default: '', }, - default: '', - description: 'Phone number. No structure is enforced.', -}, -{ - displayName: 'Option Name or ID', - name: 'multiSelectValue', - type: 'options', - description: 'Choose from the list, or specify an ID using an expression', - typeOptions: { - loadOptionsMethod: 'getPropertySelectValues', + { + displayName: 'Phone Number', + name: 'phoneNumberValue', + type: 'string', + displayOptions: { + show: { + type: ['phone_number'], + }, + hide: { + condition: ['is_empty', 'is_not_empty'], + }, + }, + default: '', + description: 'Phone number. No structure is enforced.', }, - displayOptions: { - show: { - type: [ - 'multi_select', - ], + { + displayName: 'Option Name or ID', + name: 'multiSelectValue', + type: 'options', + description: + 'Choose from the list, or specify an ID using an expression', + typeOptions: { + loadOptionsMethod: 'getPropertySelectValues', }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - ], + displayOptions: { + show: { + type: ['multi_select'], + }, + hide: { + condition: ['is_empty', 'is_not_empty'], + }, }, + default: [], }, - default: [], -}, -{ - displayName: 'Option Name or ID', - name: 'selectValue', - type: 'options', - description: 'Choose from the list, or specify an ID using an expression', - typeOptions: { - loadOptionsMethod: 'getPropertySelectValues', + { + displayName: 'Option Name or ID', + name: 'selectValue', + type: 'options', + description: + 'Choose from the list, or specify an ID using an expression', + typeOptions: { + loadOptionsMethod: 'getPropertySelectValues', + }, + displayOptions: { + show: { + type: ['select'], + }, + hide: { + condition: ['is_empty', 'is_not_empty'], + }, + }, + default: '', }, - displayOptions: { - show: { - type: [ - 'select', - ], - }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - ], + { + displayName: 'Email', + name: 'emailValue', + type: 'string', + displayOptions: { + show: { + type: ['email'], + }, + hide: { + condition: ['is_empty', 'is_not_empty'], + }, }, + default: '', }, - default: '', -}, -{ - displayName: 'Email', - name: 'emailValue', - type: 'string', - displayOptions: { - show: { - type: [ - 'email', - ], - }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - ], + { + displayName: 'URL', + name: 'urlValue', + type: 'string', + displayOptions: { + show: { + type: ['url'], + }, + hide: { + condition: ['is_empty', 'is_not_empty'], + }, }, + default: '', }, - default: '', -}, -{ - displayName: 'URL', - name: 'urlValue', - type: 'string', - displayOptions: { - show: { - type: [ - 'url', - ], + { + displayName: 'User Name or ID', + name: 'peopleValue', + type: 'options', + typeOptions: { + loadOptionsMethod: 'getUsers', }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - ], + displayOptions: { + show: { + type: ['people'], + }, + hide: { + condition: ['is_empty', 'is_not_empty'], + }, }, + default: '', + description: + 'List of users. Multiples can be defined separated by comma. Choose from the list, or specify an ID using an expression.', }, - default: '', -}, -{ - displayName: 'User Name or ID', - name: 'peopleValue', - type: 'options', - typeOptions: { - loadOptionsMethod: 'getUsers', + { + displayName: 'User Name or ID', + name: 'createdByValue', + type: 'options', + typeOptions: { + loadOptionsMethod: 'getUsers', + }, + displayOptions: { + show: { + type: ['created_by'], + }, + hide: { + condition: ['is_empty', 'is_not_empty'], + }, + }, + default: '', + description: + 'List of users. Multiples can be defined separated by comma. Choose from the list, or specify an ID using an expression.', }, - displayOptions: { - show: { - type: [ - 'people', - ], + { + displayName: 'User Name or ID', + name: 'lastEditedByValue', + type: 'options', + typeOptions: { + loadOptionsMethod: 'getUsers', }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - ], + displayOptions: { + show: { + type: ['last_edited_by'], + }, + hide: { + condition: ['is_empty', 'is_not_empty'], + }, }, + default: '', + description: + 'List of users. Multiples can be defined separated by comma. Choose from the list, or specify an ID using an expression.', }, - default: '', - description: 'List of users. Multiples can be defined separated by comma. Choose from the list, or specify an ID using an expression.', -}, -{ - displayName: 'User Name or ID', - name: 'createdByValue', - type: 'options', - typeOptions: { - loadOptionsMethod: 'getUsers', + { + displayName: 'Relation ID', + name: 'relationValue', + type: 'string', + displayOptions: { + show: { + type: ['relation'], + }, + hide: { + condition: ['is_empty', 'is_not_empty'], + }, + }, + default: '', }, - displayOptions: { - show: { - type: [ - 'created_by', - ], - }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - ], + { + displayName: 'Checked', + name: 'checkboxValue', + displayOptions: { + show: { + type: ['checkbox'], + }, }, + type: 'boolean', + default: false, + description: + 'Whether or not the checkbox is checked. true represents checked. false represents unchecked', }, - default: '', - description: 'List of users. Multiples can be defined separated by comma. Choose from the list, or specify an ID using an expression.', -}, -{ - displayName: 'User Name or ID', - name: 'lastEditedByValue', - type: 'options', - typeOptions: { - loadOptionsMethod: 'getUsers', + { + displayName: 'Number', + name: 'numberValue', + displayOptions: { + show: { + type: ['number'], + }, + hide: { + condition: ['is_empty', 'is_not_empty'], + }, + }, + type: 'number', + default: 0, + description: 'Number value', }, - displayOptions: { - show: { - type: [ - 'last_edited_by', - ], - }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - ], + { + displayName: 'Date', + name: 'date', + displayOptions: { + show: { + type: ['date'], + }, + hide: { + condition: [ + 'is_empty', + 'is_not_empty', + 'past_week', + 'past_month', + 'past_year', + 'next_week', + 'next_month', + 'next_year', + ], + }, }, + type: 'dateTime', + default: '', + description: 'An ISO 8601 format date, with optional time', }, - default: '', - description: 'List of users. Multiples can be defined separated by comma. Choose from the list, or specify an ID using an expression.', -}, -{ - displayName: 'Relation ID', - name: 'relationValue', - type: 'string', - displayOptions: { - show: { - type: [ - 'relation', - ], - }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - ], + { + displayName: 'Created Time', + name: 'createdTimeValue', + displayOptions: { + show: { + type: ['created_time'], + }, + hide: { + condition: [ + 'is_empty', + 'is_not_empty', + 'past_week', + 'past_month', + 'past_year', + 'next_week', + 'next_month', + 'next_year', + ], + }, }, + type: 'dateTime', + default: '', + description: 'An ISO 8601 format date, with optional time', }, - default: '', -}, -{ - displayName: 'Checked', - name: 'checkboxValue', - displayOptions: { - show: { - type: [ - 'checkbox', - ], + { + displayName: 'Last Edited Time', + name: 'lastEditedTime', + displayOptions: { + show: { + type: ['last_edited_time'], + }, + hide: { + condition: [ + 'is_empty', + 'is_not_empty', + 'past_week', + 'past_month', + 'past_year', + 'next_week', + 'next_month', + 'next_year', + ], + }, }, + type: 'dateTime', + default: '', + description: 'An ISO 8601 format date, with optional time', }, - type: 'boolean', - default: false, - description: 'Whether or not the checkbox is checked. true represents checked. false represents unchecked', -}, -{ - displayName: 'Number', - name: 'numberValue', - displayOptions: { - show: { - type: [ - 'number', - ], - }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - ], + //formula types + { + displayName: 'Number', + name: 'numberValue', + displayOptions: { + show: { + type: ['formula'], + returnType: ['number'], + }, + hide: { + condition: ['is_empty', 'is_not_empty'], + }, }, + type: 'number', + default: 0, + description: 'Number value', }, - type: 'number', - default: 0, - description: 'Number value', -}, -{ - displayName: 'Date', - name: 'date', - displayOptions: { - show: { - type: [ - 'date', - ], - }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - 'past_week', - 'past_month', - 'past_year', - 'next_week', - 'next_month', - 'next_year', - ], + { + displayName: 'Text', + name: 'textValue', + type: 'string', + displayOptions: { + show: { + type: ['formula'], + returnType: ['text'], + }, + hide: { + condition: ['is_empty', 'is_not_empty'], + }, }, + default: '', }, - type: 'dateTime', - default: '', - description: 'An ISO 8601 format date, with optional time', -}, -{ - displayName: 'Created Time', - name: 'createdTimeValue', - displayOptions: { - show: { - type: [ - 'created_time', - ], - }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - 'past_week', - 'past_month', - 'past_year', - 'next_week', - 'next_month', - 'next_year', - ], + { + displayName: 'Boolean', + name: 'checkboxValue', + displayOptions: { + show: { + type: ['formula'], + returnType: ['checkbox'], + }, }, + type: 'boolean', + default: false, + description: + 'Whether or not the checkbox is checked. true represents checked. false represents unchecked', }, - type: 'dateTime', - default: '', - description: 'An ISO 8601 format date, with optional time', -}, -{ - displayName: 'Last Edited Time', - name: 'lastEditedTime', - displayOptions: { - show: { - type: [ - 'last_edited_time', - ], - }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - 'past_week', - 'past_month', - 'past_year', - 'next_week', - 'next_month', - 'next_year', - ], + { + displayName: 'Date', + name: 'dateValue', + displayOptions: { + show: { + type: ['formula'], + returnType: ['date'], + }, + hide: { + condition: [ + 'is_empty', + 'is_not_empty', + 'past_week', + 'past_month', + 'past_year', + 'next_week', + 'next_month', + 'next_year', + ], + }, }, + type: 'dateTime', + default: '', + description: 'An ISO 8601 format date, with optional time', }, - type: 'dateTime', - default: '', - description: 'An ISO 8601 format date, with optional time', -}, -//formula types -{ - displayName: 'Number', - name: 'numberValue', - displayOptions: { - show: { - type: [ - 'formula', - ], - returnType: [ - 'number', - ], - }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - ], - }, - }, - type: 'number', - default: 0, - description: 'Number value', -}, -{ - displayName: 'Text', - name: 'textValue', - type: 'string', - displayOptions: { - show: { - type: [ - 'formula', - ], - returnType: [ - 'text', - ], - }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - ], - }, - }, - default: '', -}, -{ - displayName: 'Boolean', - name: 'checkboxValue', - displayOptions: { - show: { - type: [ - 'formula', - ], - returnType: [ - 'checkbox', - ], - }, - }, - type: 'boolean', - default: false, - description: 'Whether or not the checkbox is checked. true represents checked. false represents unchecked', - -}, -{ - displayName: 'Date', - name: 'dateValue', - displayOptions: { - show: { - type: [ - 'formula', - ], - returnType: [ - 'date', - ], - }, - hide: { - condition: [ - 'is_empty', - 'is_not_empty', - 'past_week', - 'past_month', - 'past_year', - 'next_week', - 'next_month', - 'next_year', - ], - }, - }, - type: 'dateTime', - default: '', - description: 'An ISO 8601 format date, with optional time', -}, ]; diff --git a/packages/nodes-base/nodes/Notion/GenericFunctions.ts b/packages/nodes-base/nodes/Notion/GenericFunctions.ts index a6ab4c7894..d51bd83b4c 100644 --- a/packages/nodes-base/nodes/Notion/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Notion/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -21,14 +19,9 @@ import { NodeApiError, } from 'n8n-workflow'; -import { - camelCase, - capitalCase, -} from 'change-case'; +import { camelCase, capitalCase } from 'change-case'; -import { - filters, -} from './Filters'; +import { filters } from './Filters'; import moment from 'moment-timezone'; @@ -41,8 +34,22 @@ const apiVersion: { [key: number]: string } = { 2: '2021-08-16', }; -export async function notionApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IPollFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function notionApiRequest( + this: + | IHookFunctions + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IPollFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { try { let options: OptionsWithUri = { headers: { @@ -59,17 +66,24 @@ export async function notionApiRequest(this: IHookFunctions | IExecuteFunctions delete options.body; } if (!uri) { - return this.helpers.requestWithAuthentication.call(this,'notionApi', options ); + return this.helpers.requestWithAuthentication.call(this, 'notionApi', options); } return this.helpers.request!(options); - } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function notionApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function notionApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const resource = this.getNodeParameter('resource', 0) as string; const returnData: IDataObject[] = []; @@ -88,9 +102,7 @@ export async function notionApiRequestAllItems(this: IExecuteFunctions | ILoadOp if (query.limit && query.limit <= returnData.length) { return returnData; } - } while ( - responseData.has_more !== false - ); + } while (responseData.has_more !== false); return returnData; } @@ -146,21 +158,17 @@ function textContent(content: string) { export function formatTitle(content: string) { return { - title: [ - textContent(content), - ], + title: [textContent(content)], }; } export function formatText(content: string) { return { - text: [ - textContent(content), - ], + text: [textContent(content)], }; } -function getLink(text: { textLink: string, isLink: boolean }) { +function getLink(text: { textLink: string; isLink: boolean }) { if (text.isLink === true && text.textLink !== '') { return { link: { @@ -171,7 +179,23 @@ function getLink(text: { textLink: string, isLink: boolean }) { return {}; } -function getTexts(texts: [{ textType: string, text: string, isLink: boolean, range: boolean, textLink: string, mentionType: string, dateStart: string, dateEnd: string, date: string, annotationUi: IDataObject, expression: string }]) { +function getTexts( + texts: [ + { + textType: string; + text: string; + isLink: boolean; + range: boolean; + textLink: string; + mentionType: string; + dateStart: string; + dateEnd: string; + date: string; + annotationUi: IDataObject; + expression: string; + }, + ], +) { const results = []; for (const text of texts) { if (text.textType === 'text') { @@ -189,9 +213,10 @@ function getTexts(texts: [{ textType: string, text: string, isLink: boolean, ran type: 'mention', mention: { type: text.mentionType, - [text.mentionType]: (text.range === true) - ? { start: text.dateStart, end: text.dateEnd } - : { start: text.date, end: null }, + [text.mentionType]: + text.range === true + ? { start: text.dateStart, end: text.dateEnd } + : { start: text.date, end: null }, }, annotations: text.annotationUi, }); @@ -227,7 +252,8 @@ export function formatBlocks(blocks: IDataObject[]) { object: 'block', type: block.type, [block.type as string]: { - ...(block.type === 'to_do') ? { checked: block.checked } : {}, + ...(block.type === 'to_do' ? { checked: block.checked } : {}), + // prettier-ignore //@ts-expect-error // tslint:disable-next-line: no-any text: (block.richText === false) ? formatText(block.textContent).text : getTexts(block.text.text as any || []), @@ -239,7 +265,9 @@ export function formatBlocks(blocks: IDataObject[]) { // tslint:disable-next-line: no-any function getPropertyKeyValue(value: any, type: string, timezone: string, version = 1) { - const ignoreIfEmpty = (v: T, cb: (v: T) => any) => !v && value.ignoreIfEmpty ? undefined : cb(v); // tslint:disable-line: no-any + // tslint:disable-next-line: no-any + const ignoreIfEmpty = (v: T, cb: (v: T) => any) => + !v && value.ignoreIfEmpty ? undefined : cb(v); let result = {}; switch (type) { @@ -257,15 +285,16 @@ function getPropertyKeyValue(value: any, type: string, timezone: string, version result = { type: 'number', number: value.numberValue }; break; case 'url': - result = ignoreIfEmpty(value.urlValue, url => ({ type: 'url', url })); + result = ignoreIfEmpty(value.urlValue, (url) => ({ type: 'url', url })); break; case 'checkbox': result = { type: 'checkbox', checkbox: value.checkboxValue }; break; case 'relation': result = { + type: 'relation', // tslint:disable-next-line: no-any - type: 'relation', relation: (value.relationValue).reduce((acc: [], cur: any) => { + relation: value.relationValue.reduce((acc: [], cur: any) => { return acc.concat(cur.split(',').map((relation: string) => ({ id: relation.trim() }))); }, []), }; @@ -274,17 +303,19 @@ function getPropertyKeyValue(value: any, type: string, timezone: string, version const multiSelectValue = value.multiSelectValue; result = { type: 'multi_select', - // tslint:disable-next-line: no-any - multi_select: (Array.isArray(multiSelectValue) ? multiSelectValue : multiSelectValue.split(',').map((v: string) => v.trim())) + multi_select: (Array.isArray(multiSelectValue) + ? multiSelectValue + : multiSelectValue.split(',').map((v: string) => v.trim()) + ) // tslint:disable-next-line: no-any .filter((value: any) => value !== null) - .map((option: string) => - ((!uuidValidate(option)) ? { name: option } : { id: option })), + .map((option: string) => (!uuidValidate(option) ? { name: option } : { id: option })), }; break; case 'email': result = { - type: 'email', email: value.emailValue, + type: 'email', + email: value.emailValue, }; break; case 'people': @@ -294,22 +325,25 @@ function getPropertyKeyValue(value: any, type: string, timezone: string, version } result = { - type: 'people', people: value.peopleValue.map((option: string) => ({ id: option })), + type: 'people', + people: value.peopleValue.map((option: string) => ({ id: option })), }; break; case 'phone_number': result = { - type: 'phone_number', phone_number: value.phoneValue, + type: 'phone_number', + phone_number: value.phoneValue, }; break; case 'select': result = { - type: 'select', select: (version === 1) ? { id: value.selectValue } : { name: value.selectValue }, + type: 'select', + select: version === 1 ? { id: value.selectValue } : { name: value.selectValue }, }; break; case 'date': const format = getDateFormat(value.includeTime); - const timezoneValue = (value.timezone === 'default') ? timezone : value.timezone; + const timezoneValue = value.timezone === 'default' ? timezone : value.timezone; if (value.range === true) { result = { type: 'date', @@ -329,8 +363,7 @@ function getPropertyKeyValue(value: any, type: string, timezone: string, version } //if the date was left empty, set it to null so it resets the value in notion - if (value.date === '' || - (value.dateStart === '' && value.dateEnd === '')) { + if (value.date === '' || (value.dateStart === '' && value.dateEnd === '')) { //@ts-ignore result.date = null; } @@ -338,8 +371,12 @@ function getPropertyKeyValue(value: any, type: string, timezone: string, version break; case 'files': result = { - type: 'files', files: value.fileUrls.fileUrl - .map((file: { name: string, url: string }) => ({ name: file.name, type: 'external', external: { url: file.url } })), + type: 'files', + files: value.fileUrls.fileUrl.map((file: { name: string; url: string }) => ({ + name: file.name, + type: 'external', + external: { url: file.url }, + })), }; break; default: @@ -364,44 +401,65 @@ function getNameAndType(key: string) { export function mapProperties(properties: IDataObject[], timezone: string, version = 1) { return properties - .filter((property): property is Record => typeof property.key === 'string') // tslint:disable-line: no-any - .map(property => [`${property.key.split('|')[0]}`, getPropertyKeyValue(property, property.key.split('|')[1], timezone, version)] as const) + .filter( + // tslint:disable-next-line: no-any + (property): property is Record => + typeof property.key === 'string', + ) + .map( + (property) => + [ + `${property.key.split('|')[0]}`, + getPropertyKeyValue(property, property.key.split('|')[1], timezone, version), + ] as const, + ) .filter(([, value]) => value) - .reduce((obj, [key, value]) => Object.assign(obj, { - [key]: value, - }), {}); + .reduce( + (obj, [key, value]) => + Object.assign(obj, { + [key]: value, + }), + {}, + ); } -export function mapSorting(data: [{ key: string, type: string, direction: string, timestamp: boolean }]) { +export function mapSorting( + data: [{ key: string; type: string; direction: string; timestamp: boolean }], +) { return data.map((sort) => { return { direction: sort.direction, - [(sort.timestamp) ? 'timestamp' : 'property']: sort.key.split('|')[0], + [sort.timestamp ? 'timestamp' : 'property']: sort.key.split('|')[0], }; }); } export function mapFilters(filters: IDataObject[], timezone: string) { - // tslint:disable-next-line: no-any return filters.reduce((obj, value: { [key: string]: any }) => { let key = getNameAndType(value.key).type; - let valuePropertyName = key === 'last_edited_time' - ? value[camelCase(key)] - : value[`${camelCase(key)}Value`]; + let valuePropertyName = + key === 'last_edited_time' ? value[camelCase(key)] : value[`${camelCase(key)}Value`]; if (['is_empty', 'is_not_empty'].includes(value.condition as string)) { valuePropertyName = true; - } else if (['past_week', 'past_month', 'past_year', 'next_week', 'next_month', 'next_year'].includes(value.condition as string)) { + } else if ( + ['past_week', 'past_month', 'past_year', 'next_week', 'next_month', 'next_year'].includes( + value.condition as string, + ) + ) { valuePropertyName = {}; } if (key === 'rich_text' || key === 'text') { key = 'text'; } else if (key === 'phone_number') { key = 'phone'; - } else if (key === 'date' && !['is_empty', 'is_not_empty'].includes(value.condition as string)) { - valuePropertyName = (value.date === '') ? {} : moment.tz(value.date, timezone).utc().format(); + } else if ( + key === 'date' && + !['is_empty', 'is_not_empty'].includes(value.condition as string) + ) { + valuePropertyName = value.date === '' ? {} : moment.tz(value.date, timezone).utc().format(); } else if (key === 'boolean') { key = 'checkbox'; } @@ -436,11 +494,22 @@ function simplifyProperty(property: any) { } else { result = ''; } - } else if (['url', 'created_time', 'checkbox', 'number', 'last_edited_time', 'email', 'phone_number', 'date'].includes(property.type)) { + } else if ( + [ + 'url', + 'created_time', + 'checkbox', + 'number', + 'last_edited_time', + 'email', + 'phone_number', + 'date', + ].includes(property.type) + ) { // tslint:disable-next-line: no-any result = property[type] as any; } else if (['created_by', 'last_edited_by', 'select'].includes(property.type)) { - result = (property[type]) ? property[type].name : null; + result = property[type] ? property[type].name : null; } else if (['people'].includes(property.type)) { if (Array.isArray(property[type])) { // tslint:disable-next-line: no-any @@ -462,7 +531,6 @@ function simplifyProperty(property: any) { } } else if (['formula'].includes(property.type)) { result = property[type][property[type].type]; - } else if (['rollup'].includes(property.type)) { const rollupFunction = property[type].function as string; if (rollupFunction.startsWith('count') || rollupFunction.includes('empty')) { @@ -475,8 +543,10 @@ function simplifyProperty(property: any) { result = rollupFunction === 'show_unique' ? [...new Set(elements)] : elements; } } else if (['files'].includes(property.type)) { - // tslint:disable-next-line: no-any - result = property[type].map((file: { type: string, [key: string]: any }) => (file[file.type].url)); + result = property[type].map( + // tslint:disable-next-line: no-any + (file: { type: string; [key: string]: any }) => file[file.type].url, + ); } return result; } @@ -502,30 +572,36 @@ export function simplifyObjects(objects: any, download = false, version = 2) { results.push({ id, name: properties.title.title[0].plain_text, - ...version === 2 ? { url } : {}, + ...(version === 2 ? { url } : {}), }); } else if (object === 'page' && parent.type === 'database_id') { results.push({ id, - ...(version === 2) ? { name: getPropertyTitle(properties) } : {}, - ...(version === 2) ? { url } : {}, - ...(version === 2) ? { ...prepend('property', simplifyProperties(properties)) } : { ...simplifyProperties(properties) }, + ...(version === 2 ? { name: getPropertyTitle(properties) } : {}), + ...(version === 2 ? { url } : {}), + ...(version === 2 + ? { ...prepend('property', simplifyProperties(properties)) } + : { ...simplifyProperties(properties) }), }); } else if (download && json.object === 'page' && json.parent.type === 'database_id') { results.push({ json: { id: json.id, - ...(version === 2) ? { name: getPropertyTitle(json.properties) } : {}, - ...(version === 2) ? { url: json.url } : {}, - ...(version === 2) ? { ...prepend('property', simplifyProperties(json.properties)) } : { ...simplifyProperties(json.properties) }, + ...(version === 2 ? { name: getPropertyTitle(json.properties) } : {}), + ...(version === 2 ? { url: json.url } : {}), + ...(version === 2 + ? { ...prepend('property', simplifyProperties(json.properties)) } + : { ...simplifyProperties(json.properties) }), }, binary, }); } else if (object === 'database') { results.push({ id, - ...version === 2 ? { name: title[0]?.plain_text || '' } : { title: title[0]?.plain_text || '' }, - ...version === 2 ? { url } : {}, + ...(version === 2 + ? { name: title[0]?.plain_text || '' } + : { title: title[0]?.plain_text || '' }), + ...(version === 2 ? { url } : {}), }); } } @@ -542,7 +618,6 @@ export function getFormattedChildren(children: IDataObject[]) { } export function getConditions() { - const elements: INodeProperties[] = []; const types: { [key: string]: string } = { @@ -587,22 +662,9 @@ export function getConditions() { 'is_empty', 'is_not_empty', ], - checkbox: [ - 'equals', - 'does_not_equal', - ], - select: [ - 'equals', - 'does_not_equal', - 'is_empty', - 'is_not_empty', - ], - multi_select: [ - 'contains', - 'does_not_equal', - 'is_empty', - 'is_not_empty', - ], + checkbox: ['equals', 'does_not_equal'], + select: ['equals', 'does_not_equal', 'is_empty', 'is_not_empty'], + multi_select: ['contains', 'does_not_equal', 'is_empty', 'is_not_empty'], date: [ 'equals', 'before', @@ -618,105 +680,73 @@ export function getConditions() { 'next_month', 'next_year', ], - people: [ - 'contains', - 'does_not_contain', - 'is_empty', - 'is_not_empty', - ], - files: [ - 'is_empty', - 'is_not_empty', - ], - relation: [ - 'contains', - 'does_not_contain', - 'is_empty', - 'is_not_empty', - ], + people: ['contains', 'does_not_contain', 'is_empty', 'is_not_empty'], + files: ['is_empty', 'is_not_empty'], + relation: ['contains', 'does_not_contain', 'is_empty', 'is_not_empty'], }; const formula: { [key: string]: string[] } = { - text: [ - ...typeConditions.rich_text, - ], - checkbox: [ - ...typeConditions.checkbox, - ], - number: [ - ...typeConditions.number, - ], - date: [ - ...typeConditions.date, - ], + text: [...typeConditions.rich_text], + checkbox: [...typeConditions.checkbox], + number: [...typeConditions.number], + date: [...typeConditions.date], }; for (const type of Object.keys(types)) { - elements.push( - { - displayName: 'Condition', - name: 'condition', - type: 'options', - displayOptions: { - show: { - type: [ - type, - ], - }, - } as IDisplayOptions, - options: (typeConditions[types[type]] as string[]).map((type: string) => ({ name: capitalCase(type), value: type })), - default: '', - description: 'The value of the property to filter by', - } as INodeProperties, - ); - } - - elements.push( - { - displayName: 'Return Type', - name: 'returnType', + elements.push({ + displayName: 'Condition', + name: 'condition', type: 'options', displayOptions: { show: { - type: [ - 'formula', - ], + type: [type], }, } as IDisplayOptions, - options: Object.keys(formula).map((key: string) => ({ name: capitalCase(key), value: key })), + options: (typeConditions[types[type]] as string[]).map((type: string) => ({ + name: capitalCase(type), + value: type, + })), default: '', - description: 'The formula return type', - } as INodeProperties, - ); + description: 'The value of the property to filter by', + } as INodeProperties); + } + + elements.push({ + displayName: 'Return Type', + name: 'returnType', + type: 'options', + displayOptions: { + show: { + type: ['formula'], + }, + } as IDisplayOptions, + options: Object.keys(formula).map((key: string) => ({ name: capitalCase(key), value: key })), + default: '', + description: 'The formula return type', + } as INodeProperties); for (const key of Object.keys(formula)) { - elements.push( - { - displayName: 'Condition', - name: 'condition', - type: 'options', - displayOptions: { - show: { - type: [ - 'formula', - ], - returnType: [ - key, - ], - }, - } as IDisplayOptions, - options: formula[key].map((key: string) => ({ name: capitalCase(key), value: key })), - default: '', - description: 'The value of the property to filter by', - } as INodeProperties, - ); + elements.push({ + displayName: 'Condition', + name: 'condition', + type: 'options', + displayOptions: { + show: { + type: ['formula'], + returnType: [key], + }, + } as IDisplayOptions, + options: formula[key].map((key: string) => ({ name: capitalCase(key), value: key })), + default: '', + description: 'The value of the property to filter by', + } as INodeProperties); } return elements; } -// tslint:disable-next-line: no-any -export async function downloadFiles(this: IExecuteFunctions | IPollFunctions, records: [{ properties: { [key: string]: any | { id: string, type: string, files: [{ external: { url: string } } | { file: { url: string } }] } } }]): Promise { +// prettier-ignore +export async function downloadFiles(this: IExecuteFunctions | IPollFunctions, records: [{ properties: { [key: string]: any | { id: string, type: string, files: [{ external: { url: string } } | { file: { url: string } }] } } }]): Promise { // tslint:disable-line:no-any const elements: INodeExecutionData[] = []; for (const record of records) { const element: INodeExecutionData = { json: {}, binary: {} }; @@ -725,7 +755,15 @@ export async function downloadFiles(this: IExecuteFunctions | IPollFunctions, re if (record.properties[key].type === 'files') { if (record.properties[key].files.length) { for (const [index, file] of record.properties[key].files.entries()) { - const data = await notionApiRequest.call(this, 'GET', '', {}, {}, file?.file?.url || file?.external?.url, { json: false, encoding: null }); + const data = await notionApiRequest.call( + this, + 'GET', + '', + {}, + {}, + file?.file?.url || file?.external?.url, + { json: false, encoding: null }, + ); element.binary![`${key}_${index}`] = await this.helpers.prepareBinaryData(data); } } @@ -772,7 +810,10 @@ function prepend(stringKey: string, properties: { [key: string]: any }) { // tslint:disable-next-line: no-any export function getPropertyTitle(properties: { [key: string]: any }) { - return Object.values(properties).filter(property => property.type === 'title')[0].title[0]?.plain_text || ''; + return ( + Object.values(properties).filter((property) => property.type === 'title')[0].title[0] + ?.plain_text || '' + ); } export function getSearchFilters(resource: string) { @@ -797,15 +838,9 @@ export function getSearchFilters(resource: string) { ], displayOptions: { show: { - version: [ - 2, - ], - resource: [ - resource, - ], - operation: [ - 'getAll', - ], + version: [2], + resource: [resource], + operation: ['getAll'], }, }, default: 'none', @@ -826,18 +861,10 @@ export function getSearchFilters(resource: string) { ], displayOptions: { show: { - version: [ - 2, - ], - resource: [ - resource, - ], - operation: [ - 'getAll', - ], - filterType: [ - 'manual', - ], + version: [2], + resource: [resource], + operation: ['getAll'], + filterType: ['manual'], }, }, default: 'anyFilter', @@ -851,18 +878,10 @@ export function getSearchFilters(resource: string) { }, displayOptions: { show: { - version: [ - 2, - ], - resource: [ - resource, - ], - operation: [ - 'getAll', - ], - filterType: [ - 'manual', - ], + version: [2], + resource: [resource], + operation: ['getAll'], + filterType: ['manual'], }, }, default: {}, @@ -871,30 +890,21 @@ export function getSearchFilters(resource: string) { { displayName: 'Conditions', name: 'conditions', - values: [ - ...filters(getConditions()), - ], + values: [...filters(getConditions())], }, ], }, { - displayName: 'See Notion guide to creating filters', + displayName: + 'See Notion guide to creating filters', name: 'jsonNotice', type: 'notice', displayOptions: { show: { - version: [ - 2, - ], - resource: [ - resource, - ], - operation: [ - 'getAll', - ], - filterType: [ - 'json', - ], + version: [2], + resource: [resource], + operation: ['getAll'], + filterType: ['json'], }, }, default: '', @@ -908,18 +918,10 @@ export function getSearchFilters(resource: string) { }, displayOptions: { show: { - version: [ - 2, - ], - resource: [ - resource, - ], - operation: [ - 'getAll', - ], - filterType: [ - 'json', - ], + version: [2], + resource: [resource], + operation: ['getAll'], + filterType: ['json'], }, }, default: '', @@ -927,7 +929,8 @@ export function getSearchFilters(resource: string) { ]; } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); diff --git a/packages/nodes-base/nodes/Notion/Notion.node.ts b/packages/nodes-base/nodes/Notion/Notion.node.ts index 1c8970c081..4291116c31 100644 --- a/packages/nodes-base/nodes/Notion/Notion.node.ts +++ b/packages/nodes-base/nodes/Notion/Notion.node.ts @@ -1,19 +1,10 @@ -import { - INodeTypeBaseDescription, - INodeVersionedType, -} from 'n8n-workflow'; +import { INodeTypeBaseDescription, INodeVersionedType } from 'n8n-workflow'; -import { - NotionV1, -} from './v1/NotionV1.node'; +import { NotionV1 } from './v1/NotionV1.node'; -import { - NotionV2, -} from './v2/NotionV2.node'; +import { NotionV2 } from './v2/NotionV2.node'; -import { - NodeVersionedType, -} from '../../src/NodeVersionedType'; +import { NodeVersionedType } from '../../src/NodeVersionedType'; export class Notion extends NodeVersionedType { constructor() { @@ -34,4 +25,4 @@ export class Notion extends NodeVersionedType { super(nodeVersions, baseDescription); } -} \ No newline at end of file +} diff --git a/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts b/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts index ac39c805f2..885715152f 100644 --- a/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts +++ b/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts @@ -1,6 +1,4 @@ -import { - IPollFunctions, -} from 'n8n-core'; +import { IPollFunctions } from 'n8n-core'; import { IDataObject, @@ -11,10 +9,7 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - notionApiRequest, - simplifyObjects, -} from './GenericFunctions'; +import { notionApiRequest, simplifyObjects } from './GenericFunctions'; import moment from 'moment'; @@ -59,7 +54,8 @@ export class NotionTrigger implements INodeType { default: '', }, { - displayName: 'In Notion, make sure you share your database with your integration. Otherwise it won\'t be accessible, or listed here.', + displayName: + "In Notion, make sure you share your database with your integration. Otherwise it won't be accessible, or listed here.", name: 'notionNotice', type: 'notice', default: '', @@ -73,15 +69,13 @@ export class NotionTrigger implements INodeType { }, displayOptions: { show: { - event: [ - 'pageAddedToDatabase', - 'pagedUpdatedInDatabase', - ], + event: ['pageAddedToDatabase', 'pagedUpdatedInDatabase'], }, }, default: '', required: true, - description: 'The ID of this database. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of this database. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Simplify', @@ -89,14 +83,12 @@ export class NotionTrigger implements INodeType { type: 'boolean', displayOptions: { show: { - event: [ - 'pageAddedToDatabase', - 'pagedUpdatedInDatabase', - ], + event: ['pageAddedToDatabase', 'pagedUpdatedInDatabase'], }, }, default: true, - description: 'Whether to return a simplified version of the response instead of the raw data', + description: + 'Whether to return a simplified version of the response instead of the raw data', }, ], }; @@ -105,7 +97,10 @@ export class NotionTrigger implements INodeType { loadOptions: { async getDatabases(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { results: databases } = await notionApiRequest.call(this, 'POST', `/search`, { page_size: 100, filter: { property: 'object', value: 'database' } }); + const { results: databases } = await notionApiRequest.call(this, 'POST', `/search`, { + page_size: 100, + filter: { property: 'object', value: 'database' }, + }); for (const database of databases) { returnData.push({ name: database.title[0]?.plain_text || database.id, @@ -113,8 +108,12 @@ export class NotionTrigger implements INodeType { }); } returnData.sort((a, b) => { - if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { return -1; } - if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { return 1; } + if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { + return -1; + } + if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { + return 1; + } return 0; }); return returnData; @@ -130,13 +129,13 @@ export class NotionTrigger implements INodeType { const now = moment().utc().format(); - const startDate = webhookData.lastTimeChecked as string || now; + const startDate = (webhookData.lastTimeChecked as string) || now; const endDate = now; webhookData.lastTimeChecked = endDate; - const sortProperty = (event === 'pageAddedToDatabase') ? 'created_time' : 'last_edited_time'; + const sortProperty = event === 'pageAddedToDatabase' ? 'created_time' : 'last_edited_time'; const body: IDataObject = { page_size: 1, @@ -153,7 +152,12 @@ export class NotionTrigger implements INodeType { let hasMore = true; //get last record - let { results: data } = await notionApiRequest.call(this, 'POST', `/databases/${databaseId}/query`, body); + let { results: data } = await notionApiRequest.call( + this, + 'POST', + `/databases/${databaseId}/query`, + body, + ); if (this.getMode() === 'manual') { if (simple === true) { @@ -168,16 +172,26 @@ export class NotionTrigger implements INodeType { if (Object.keys(data[0]).length !== 0 && webhookData.lastRecordProccesed !== data[0].id) { do { body.page_size = 10; - const { results, has_more, next_cursor } = await notionApiRequest.call(this, 'POST', `/databases/${databaseId}/query`, body); + const { results, has_more, next_cursor } = await notionApiRequest.call( + this, + 'POST', + `/databases/${databaseId}/query`, + body, + ); records.push.apply(records, results); hasMore = has_more; if (next_cursor !== null) { body['start_cursor'] = next_cursor; } - } while (!moment(records[records.length - 1][sortProperty] as string).isSameOrBefore(startDate) && hasMore === true); + } while ( + !moment(records[records.length - 1][sortProperty] as string).isSameOrBefore(startDate) && + hasMore === true + ); if (this.getMode() !== 'manual') { - records = records.filter((record: IDataObject) => moment(record[sortProperty] as string).isBetween(startDate, endDate)); + records = records.filter((record: IDataObject) => + moment(record[sortProperty] as string).isBetween(startDate, endDate), + ); } if (simple === true) { diff --git a/packages/nodes-base/nodes/Notion/PageDescription.ts b/packages/nodes-base/nodes/Notion/PageDescription.ts index ed7af51f1e..064c7bb37d 100644 --- a/packages/nodes-base/nodes/Notion/PageDescription.ts +++ b/packages/nodes-base/nodes/Notion/PageDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - blocks, -} from './Blocks'; +import { blocks } from './Blocks'; export const pageOperations: INodeProperties[] = [ { @@ -14,12 +10,8 @@ export const pageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - version: [ - 1, - ], - resource: [ - 'page', - ], + version: [1], + resource: ['page'], }, }, options: [ @@ -51,12 +43,8 @@ export const pageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - version: [ - 2, - ], - resource: [ - 'page', - ], + version: [2], + resource: ['page'], }, }, options: [ @@ -84,7 +72,6 @@ export const pageOperations: INodeProperties[] = [ ]; export const pageFields = [ - /* -------------------------------------------------------------------------- */ /* page:archive */ /* -------------------------------------------------------------------------- */ @@ -96,18 +83,13 @@ export const pageFields = [ required: true, displayOptions: { show: { - version: [ - 2, - ], - resource: [ - 'page', - ], - operation: [ - 'archive', - ], + version: [2], + resource: ['page'], + operation: ['archive'], }, }, - description: 'The Page URL from Notion\'s \'copy link\' functionality (or just the ID contained within the URL)', + description: + "The Page URL from Notion's 'copy link' functionality (or just the ID contained within the URL)", }, { displayName: 'Simplify', @@ -115,15 +97,9 @@ export const pageFields = [ type: 'boolean', displayOptions: { show: { - version: [ - 2, - ], - resource: [ - 'page', - ], - operation: [ - 'archive', - ], + version: [2], + resource: ['page'], + operation: ['archive'], }, }, default: true, @@ -140,15 +116,12 @@ export const pageFields = [ required: true, displayOptions: { show: { - resource: [ - 'page', - ], - operation: [ - 'create', - ], + resource: ['page'], + operation: ['create'], }, }, - description: 'The URL from Notion\'s \'copy link\' functionality (or just the ID contained within the URL)', + description: + "The URL from Notion's 'copy link' functionality (or just the ID contained within the URL)", }, { displayName: 'Title', @@ -158,12 +131,8 @@ export const pageFields = [ required: true, displayOptions: { show: { - resource: [ - 'page', - ], - operation: [ - 'create', - ], + resource: ['page'], + operation: ['create'], }, }, description: 'Page title. Appears at the top of the page and can be found via Quick Find.', @@ -174,12 +143,8 @@ export const pageFields = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'page', - ], - operation: [ - 'create', - ], + resource: ['page'], + operation: ['create'], }, }, default: true, @@ -197,18 +162,13 @@ export const pageFields = [ required: true, displayOptions: { show: { - version: [ - 1, - ], - resource: [ - 'page', - ], - operation: [ - 'get', - ], + version: [1], + resource: ['page'], + operation: ['get'], }, }, - description: 'The Page URL from Notion\'s \'copy link\' functionality (or just the ID contained within the URL)', + description: + "The Page URL from Notion's 'copy link' functionality (or just the ID contained within the URL)", }, { displayName: 'Simplify', @@ -216,15 +176,9 @@ export const pageFields = [ type: 'boolean', displayOptions: { show: { - version: [ - 1, - ], - resource: [ - 'page', - ], - operation: [ - 'get', - ], + version: [1], + resource: ['page'], + operation: ['get'], }, }, default: true, @@ -240,12 +194,8 @@ export const pageFields = [ default: '', displayOptions: { show: { - resource: [ - 'page', - ], - operation: [ - 'search', - ], + resource: ['page'], + operation: ['search'], }, }, description: 'The text to search for', @@ -256,12 +206,8 @@ export const pageFields = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'page', - ], - operation: [ - 'search', - ], + resource: ['page'], + operation: ['search'], }, }, default: false, @@ -273,15 +219,9 @@ export const pageFields = [ type: 'number', displayOptions: { show: { - resource: [ - 'page', - ], - operation: [ - 'search', - ], - returnAll: [ - false, - ], + resource: ['page'], + operation: ['search'], + returnAll: [false], }, }, typeOptions: { @@ -297,12 +237,8 @@ export const pageFields = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'page', - ], - operation: [ - 'search', - ], + resource: ['page'], + operation: ['search'], }, }, default: true, @@ -314,12 +250,8 @@ export const pageFields = [ type: 'collection', displayOptions: { show: { - resource: [ - 'page', - ], - operation: [ - 'search', - ], + resource: ['page'], + operation: ['search'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/Notion/UserDescription.ts b/packages/nodes-base/nodes/Notion/UserDescription.ts index 63aa023400..ce5a2e1bfb 100644 --- a/packages/nodes-base/nodes/Notion/UserDescription.ts +++ b/packages/nodes-base/nodes/Notion/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -34,7 +30,6 @@ export const userOperations: INodeProperties[] = [ ]; export const userFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* user:get */ /* -------------------------------------------------------------------------- */ @@ -46,12 +41,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, }, @@ -64,12 +55,8 @@ export const userFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, default: false, @@ -81,15 +68,9 @@ export const userFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['user'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts b/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts index 26aff7ae2f..b2ce8dc7ac 100644 --- a/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts +++ b/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -28,12 +26,9 @@ import { import moment from 'moment-timezone'; -import { - versionDescription -} from './VersionDescription'; +import { versionDescription } from './VersionDescription'; export class NotionV1 implements INodeType { - description: INodeTypeDescription; constructor(baseDescription: INodeTypeBaseDescription) { @@ -51,7 +46,13 @@ export class NotionV1 implements INodeType { page_size: 100, filter: { property: 'object', value: 'database' }, }; - const databases = await notionApiRequestAllItems.call(this, 'results', 'POST', `/search`, body); + const databases = await notionApiRequestAllItems.call( + this, + 'results', + 'POST', + `/search`, + body, + ); for (const database of databases) { returnData.push({ name: database.title[0]?.plain_text || database.id, @@ -59,8 +60,12 @@ export class NotionV1 implements INodeType { }); } returnData.sort((a, b) => { - if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { return -1; } - if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { return 1; } + if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { + return -1; + } + if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { + return 1; + } return 0; }); return returnData; @@ -71,7 +76,17 @@ export class NotionV1 implements INodeType { const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); for (const key of Object.keys(properties)) { //remove parameters that cannot be set from the API. - if (!['created_time', 'last_edited_time', 'created_by', 'last_edited_by', 'formula', 'files', 'rollup'].includes(properties[key].type)) { + if ( + ![ + 'created_time', + 'last_edited_time', + 'created_by', + 'last_edited_by', + 'formula', + 'files', + 'rollup', + ].includes(properties[key].type) + ) { returnData.push({ name: `${key} - (${properties[key].type})`, value: `${key}|${properties[key].type}`, @@ -79,8 +94,12 @@ export class NotionV1 implements INodeType { } } returnData.sort((a, b) => { - if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { return -1; } - if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { return 1; } + if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { + return -1; + } + if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { + return 1; + } return 0; }); return returnData; @@ -96,8 +115,12 @@ export class NotionV1 implements INodeType { }); } returnData.sort((a, b) => { - if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { return -1; } - if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { return 1; } + if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { + return -1; + } + if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { + return 1; + } return 0; }); return returnData; @@ -113,14 +136,21 @@ export class NotionV1 implements INodeType { const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); if (resource === 'databasePage') { if (['multi_select', 'select'].includes(type) && operation === 'getAll') { - return (properties[name][type].options) - .map((option: IDataObject) => ({ name: option.name, value: option.name })); + return properties[name][type].options.map((option: IDataObject) => ({ + name: option.name, + value: option.name, + })); } else if (['multi_select'].includes(type) && ['create', 'update'].includes(operation)) { - return (properties[name][type].options) - .map((option: IDataObject) => ({ name: option.name, value: option.name })); + return properties[name][type].options.map((option: IDataObject) => ({ + name: option.name, + value: option.name, + })); } } - return (properties[name][type].options).map((option: IDataObject) => ({ name: option.name, value: option.id })); + return properties[name][type].options.map((option: IDataObject) => ({ + name: option.name, + value: option.id, + })); }, async getUsers(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; @@ -138,11 +168,22 @@ export class NotionV1 implements INodeType { async getDatabaseIdFromPage(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const pageId = this.getCurrentNodeParameter('pageId') as string; - const { parent: { database_id: databaseId } } = await notionApiRequest.call(this, 'GET', `/pages/${pageId}`); + const { + parent: { database_id: databaseId }, + } = await notionApiRequest.call(this, 'GET', `/pages/${pageId}`); const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); for (const key of Object.keys(properties)) { //remove parameters that cannot be set from the API. - if (!['created_time', 'last_edited_time', 'created_by', 'last_edited_by', 'formula', 'files'].includes(properties[key].type)) { + if ( + ![ + 'created_time', + 'last_edited_time', + 'created_by', + 'last_edited_by', + 'formula', + 'files', + ].includes(properties[key].type) + ) { returnData.push({ name: `${key} - (${properties[key].type})`, value: `${key}|${properties[key].type}`, @@ -150,26 +191,35 @@ export class NotionV1 implements INodeType { } } returnData.sort((a, b) => { - if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { return -1; } - if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { return 1; } + if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { + return -1; + } + if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { + return 1; + } return 0; }); return returnData; }, - async getDatabaseOptionsFromPage(this: ILoadOptionsFunctions): Promise { + async getDatabaseOptionsFromPage( + this: ILoadOptionsFunctions, + ): Promise { const pageId = this.getCurrentNodeParameter('pageId') as string; const [name, type] = (this.getCurrentNodeParameter('&key') as string).split('|'); - const { parent: { database_id: databaseId } } = await notionApiRequest.call(this, 'GET', `/pages/${pageId}`); + const { + parent: { database_id: databaseId }, + } = await notionApiRequest.call(this, 'GET', `/pages/${pageId}`); const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); - return (properties[name][type].options).map((option: IDataObject) => ({ name: option.name, value: option.id })); + return properties[name][type].options.map((option: IDataObject) => ({ + name: option.name, + value: option.id, + })); }, // Get all the timezones to display them to user so that he can // select them easily - async getTimezones( - this: ILoadOptionsFunctions, - ): Promise { + async getTimezones(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; for (const timezone of moment.tz.names()) { const timezoneName = timezone; @@ -201,14 +251,20 @@ export class NotionV1 implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; if (resource === 'block') { - if (operation === 'append') { for (let i = 0; i < length; i++) { const blockId = extractPageId(this.getNodeParameter('blockId', i) as string); const body: IDataObject = { - children: formatBlocks(this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[]), + children: formatBlocks( + this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[], + ), }; - const block = await notionApiRequest.call(this, 'PATCH', `/blocks/${blockId}/children`, body); + const block = await notionApiRequest.call( + this, + 'PATCH', + `/blocks/${blockId}/children`, + body, + ); returnData.push(block); } } @@ -218,10 +274,22 @@ export class NotionV1 implements INodeType { const blockId = extractPageId(this.getNodeParameter('blockId', i) as string); const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll) { - responseData = await notionApiRequestAllItems.call(this, 'results', 'GET', `/blocks/${blockId}/children`, {}); + responseData = await notionApiRequestAllItems.call( + this, + 'results', + 'GET', + `/blocks/${blockId}/children`, + {}, + ); } else { qs.page_size = this.getNodeParameter('limit', i) as number; - responseData = await notionApiRequest.call(this, 'GET', `/blocks/${blockId}/children`, {}, qs); + responseData = await notionApiRequest.call( + this, + 'GET', + `/blocks/${blockId}/children`, + {}, + qs, + ); responseData = responseData.results; } returnData.push.apply(returnData, responseData); @@ -229,10 +297,7 @@ export class NotionV1 implements INodeType { } } - - if (resource === 'database') { - if (operation === 'get') { for (let i = 0; i < length; i++) { const databaseId = extractDatabaseId(this.getNodeParameter('databaseId', i) as string); @@ -248,7 +313,13 @@ export class NotionV1 implements INodeType { }; const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll) { - responseData = await notionApiRequestAllItems.call(this, 'results', 'POST', `/search`, body); + responseData = await notionApiRequestAllItems.call( + this, + 'results', + 'POST', + `/search`, + body, + ); } else { body['page_size'] = this.getNodeParameter('limit', i) as number; responseData = await notionApiRequest.call(this, 'POST', `/search`, body); @@ -260,7 +331,6 @@ export class NotionV1 implements INodeType { } if (resource === 'databasePage') { - if (operation === 'create') { for (let i = 0; i < length; i++) { const simple = this.getNodeParameter('simple', i) as boolean; @@ -270,16 +340,25 @@ export class NotionV1 implements INodeType { properties: {}, }; body.parent['database_id'] = this.getNodeParameter('databaseId', i) as string; - const properties = this.getNodeParameter('propertiesUi.propertyValues', i, []) as IDataObject[]; + const properties = this.getNodeParameter( + 'propertiesUi.propertyValues', + i, + [], + ) as IDataObject[]; if (properties.length !== 0) { body.properties = mapProperties(properties, timezone) as IDataObject; } - body.children = formatBlocks(this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[]); + body.children = formatBlocks( + this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[], + ); responseData = await notionApiRequest.call(this, 'POST', '/pages', body); if (simple === true) { responseData = simplifyObjects(responseData, false, 1); } - returnData.push.apply(returnData, Array.isArray(responseData) ? responseData : [responseData]); + returnData.push.apply( + returnData, + Array.isArray(responseData) ? responseData : [responseData], + ); } } @@ -299,10 +378,14 @@ export class NotionV1 implements INodeType { if (filters.multipleCondition) { const { or, and } = (filters.multipleCondition as IDataObject).condition as IDataObject; if (Array.isArray(or) && or.length !== 0) { - Object.assign(body.filter, { or: (or as IDataObject[]).map((data) => mapFilters([data], timezone)) }); + Object.assign(body.filter, { + or: (or as IDataObject[]).map((data) => mapFilters([data], timezone)), + }); } if (Array.isArray(and) && and.length !== 0) { - Object.assign(body.filter, { and: (and as IDataObject[]).map((data) => mapFilters([data], timezone)) }); + Object.assign(body.filter, { + and: (and as IDataObject[]).map((data) => mapFilters([data], timezone)), + }); } } if (!Object.keys(body.filter as IDataObject).length) { @@ -313,10 +396,23 @@ export class NotionV1 implements INodeType { body['sorts'] = mapSorting(sort); } if (returnAll) { - responseData = await notionApiRequestAllItems.call(this, 'results', 'POST', `/databases/${databaseId}/query`, body, {}); + responseData = await notionApiRequestAllItems.call( + this, + 'results', + 'POST', + `/databases/${databaseId}/query`, + body, + {}, + ); } else { body.page_size = this.getNodeParameter('limit', i) as number; - responseData = await notionApiRequest.call(this, 'POST', `/databases/${databaseId}/query`, body, qs); + responseData = await notionApiRequest.call( + this, + 'POST', + `/databases/${databaseId}/query`, + body, + qs, + ); responseData = responseData.results; } if (simple === true) { @@ -330,7 +426,11 @@ export class NotionV1 implements INodeType { for (let i = 0; i < length; i++) { const pageId = extractPageId(this.getNodeParameter('pageId', i) as string); const simple = this.getNodeParameter('simple', i) as boolean; - const properties = this.getNodeParameter('propertiesUi.propertyValues', i, []) as IDataObject[]; + const properties = this.getNodeParameter( + 'propertiesUi.propertyValues', + i, + [], + ) as IDataObject[]; // tslint:disable-next-line: no-any const body: { [key: string]: any } = { properties: {}, @@ -342,13 +442,15 @@ export class NotionV1 implements INodeType { if (simple === true) { responseData = simplifyObjects(responseData, false, 1); } - returnData.push.apply(returnData, Array.isArray(responseData) ? responseData : [responseData]); + returnData.push.apply( + returnData, + Array.isArray(responseData) ? responseData : [responseData], + ); } } } if (resource === 'user') { - if (operation === 'get') { for (let i = 0; i < length; i++) { const userId = this.getNodeParameter('userId', i) as string; @@ -372,7 +474,6 @@ export class NotionV1 implements INodeType { } if (resource === 'page') { - if (operation === 'create') { for (let i = 0; i < length; i++) { const simple = this.getNodeParameter('simple', i) as boolean; @@ -383,12 +484,17 @@ export class NotionV1 implements INodeType { }; body.parent['page_id'] = extractPageId(this.getNodeParameter('pageId', i) as string); body.properties = formatTitle(this.getNodeParameter('title', i) as string); - body.children = formatBlocks(this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[]); + body.children = formatBlocks( + this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[], + ); responseData = await notionApiRequest.call(this, 'POST', '/pages', body); if (simple === true) { responseData = simplifyObjects(responseData, false, 1); } - returnData.push.apply(returnData, Array.isArray(responseData) ? responseData : [responseData]); + returnData.push.apply( + returnData, + Array.isArray(responseData) ? responseData : [responseData], + ); } } @@ -400,7 +506,10 @@ export class NotionV1 implements INodeType { if (simple === true) { responseData = simplifyObjects(responseData, false, 1); } - returnData.push.apply(returnData, Array.isArray(responseData) ? responseData : [responseData]); + returnData.push.apply( + returnData, + Array.isArray(responseData) ? responseData : [responseData], + ); } } @@ -417,19 +526,31 @@ export class NotionV1 implements INodeType { } if (options.filter) { - const filter = (options.filter as IDataObject || {}).filters as IDataObject[] || []; + const filter = (((options.filter as IDataObject) || {}).filters as IDataObject[]) || []; body['filter'] = filter; } if (options.sort) { - const sort = (options.sort as IDataObject || {}).sortValue as IDataObject || {}; + const sort = (((options.sort as IDataObject) || {}).sortValue as IDataObject) || {}; body['sort'] = sort; } if (returnAll) { - responseData = await notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body); + responseData = await notionApiRequestAllItems.call( + this, + 'results', + 'POST', + '/search', + body, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body); + responseData = await notionApiRequestAllItems.call( + this, + 'results', + 'POST', + '/search', + body, + ); responseData = responseData.splice(0, qs.limit); } diff --git a/packages/nodes-base/nodes/Notion/v1/VersionDescription.ts b/packages/nodes-base/nodes/Notion/v1/VersionDescription.ts index e1f7cd3725..c1d8027234 100644 --- a/packages/nodes-base/nodes/Notion/v1/VersionDescription.ts +++ b/packages/nodes-base/nodes/Notion/v1/VersionDescription.ts @@ -1,139 +1,122 @@ /* eslint-disable n8n-nodes-base/node-filename-against-convention */ -import { - databaseFields, - databaseOperations, -} from '../DatabaseDescription'; +import { databaseFields, databaseOperations } from '../DatabaseDescription'; -import { - userFields, - userOperations, -} from '../UserDescription'; +import { userFields, userOperations } from '../UserDescription'; -import { - pageFields, - pageOperations, -} from '../PageDescription'; +import { pageFields, pageOperations } from '../PageDescription'; -import { - blockFields, - blockOperations, -} from '../BlockDescription'; +import { blockFields, blockOperations } from '../BlockDescription'; -import { - databasePageFields, - databasePageOperations, -} from '../DatabasePageDescription'; +import { databasePageFields, databasePageOperations } from '../DatabasePageDescription'; -import { - INodeTypeDescription, -} from 'n8n-workflow'; +import { INodeTypeDescription } from 'n8n-workflow'; export const versionDescription: INodeTypeDescription = { - displayName: 'Notion (Beta)', - name: 'notion', - icon: 'file:notion.svg', - group: ['output'], - version: 1, - subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', - description: 'Consume Notion API (Beta)', - defaults: { - name: 'Notion', - color: '#000000', - }, - inputs: ['main'], - outputs: ['main'], - credentials: [ - { - name: 'notionApi', - required: true, - // displayOptions: { - // show: { - // authentication: [ - // 'apiKey', - // ], - // }, - // }, - }, - // { - // name: 'notionOAuth2Api', - // required: true, - // displayOptions: { - // show: { - // authentication: [ - // 'oAuth2', - // ], - // }, + displayName: 'Notion (Beta)', + name: 'notion', + icon: 'file:notion.svg', + group: ['output'], + version: 1, + subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', + description: 'Consume Notion API (Beta)', + defaults: { + name: 'Notion', + color: '#000000', + }, + inputs: ['main'], + outputs: ['main'], + credentials: [ + { + name: 'notionApi', + required: true, + // displayOptions: { + // show: { + // authentication: [ + // 'apiKey', + // ], // }, // }, - ], - properties: [ - // { - // displayName: 'Authentication', - // name: 'authentication', - // type: 'options', - // options: [ - // { - // name: 'API Key', - // value: 'apiKey', - // }, - // { - // name: 'OAuth2', - // value: 'oAuth2', - // }, - // ], - // default: 'apiKey', - // description: 'The resource to operate on.', - // }, - { - displayName: 'To access content, make sure it\'s shared with your integration in Notion', - name: 'notionNotice', - type: 'notice', - default: '', - }, - { - displayName: 'Version', - name: 'version', - type: 'hidden', - default: 1, - }, - { - displayName: 'Resource', - name: 'resource', - type: 'options', - noDataExpression: true, - options: [ - { - name: 'Block', - value: 'block', - }, - { - name: 'Database', - value: 'database', - }, - { - name: 'Database Page', - value: 'databasePage', - }, - { - name: 'Page', - value: 'page', - }, - { - name: 'User', - value: 'user', - }, - ], - default: 'page', - }, - ...blockOperations, - ...blockFields, - ...databaseOperations, - ...databaseFields, - ...databasePageOperations, - ...databasePageFields, - ...pageOperations, - ...pageFields, - ...userOperations, - ...userFields, - ], - }; + }, + // { + // name: 'notionOAuth2Api', + // required: true, + // displayOptions: { + // show: { + // authentication: [ + // 'oAuth2', + // ], + // }, + // }, + // }, + ], + properties: [ + // { + // displayName: 'Authentication', + // name: 'authentication', + // type: 'options', + // options: [ + // { + // name: 'API Key', + // value: 'apiKey', + // }, + // { + // name: 'OAuth2', + // value: 'oAuth2', + // }, + // ], + // default: 'apiKey', + // description: 'The resource to operate on.', + // }, + { + displayName: "To access content, make sure it's shared with your integration in Notion", + name: 'notionNotice', + type: 'notice', + default: '', + }, + { + displayName: 'Version', + name: 'version', + type: 'hidden', + default: 1, + }, + { + displayName: 'Resource', + name: 'resource', + type: 'options', + noDataExpression: true, + options: [ + { + name: 'Block', + value: 'block', + }, + { + name: 'Database', + value: 'database', + }, + { + name: 'Database Page', + value: 'databasePage', + }, + { + name: 'Page', + value: 'page', + }, + { + name: 'User', + value: 'user', + }, + ], + default: 'page', + }, + ...blockOperations, + ...blockFields, + ...databaseOperations, + ...databaseFields, + ...databasePageOperations, + ...databasePageFields, + ...pageOperations, + ...pageFields, + ...userOperations, + ...userFields, + ], +}; diff --git a/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts b/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts index c6c157877a..0a32df5f12 100644 --- a/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts +++ b/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -35,12 +33,9 @@ import { import moment from 'moment-timezone'; -import { - versionDescription -} from './VersionDescription'; +import { versionDescription } from './VersionDescription'; export class NotionV2 implements INodeType { - description: INodeTypeDescription; constructor(baseDescription: INodeTypeBaseDescription) { @@ -58,7 +53,13 @@ export class NotionV2 implements INodeType { page_size: 100, filter: { property: 'object', value: 'database' }, }; - const databases = await notionApiRequestAllItems.call(this, 'results', 'POST', `/search`, body); + const databases = await notionApiRequestAllItems.call( + this, + 'results', + 'POST', + `/search`, + body, + ); for (const database of databases) { returnData.push({ name: database.title[0]?.plain_text || database.id, @@ -66,8 +67,12 @@ export class NotionV2 implements INodeType { }); } returnData.sort((a, b) => { - if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { return -1; } - if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { return 1; } + if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { + return -1; + } + if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { + return 1; + } return 0; }); return returnData; @@ -78,7 +83,16 @@ export class NotionV2 implements INodeType { const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); for (const key of Object.keys(properties)) { //remove parameters that cannot be set from the API. - if (!['created_time', 'last_edited_time', 'created_by', 'last_edited_by', 'formula', 'rollup'].includes(properties[key].type)) { + if ( + ![ + 'created_time', + 'last_edited_time', + 'created_by', + 'last_edited_by', + 'formula', + 'rollup', + ].includes(properties[key].type) + ) { returnData.push({ name: `${key}`, value: `${key}|${properties[key].type}`, @@ -86,8 +100,12 @@ export class NotionV2 implements INodeType { } } returnData.sort((a, b) => { - if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { return -1; } - if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { return 1; } + if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { + return -1; + } + if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { + return 1; + } return 0; }); return returnData; @@ -103,8 +121,12 @@ export class NotionV2 implements INodeType { }); } returnData.sort((a, b) => { - if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { return -1; } - if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { return 1; } + if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { + return -1; + } + if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { + return 1; + } return 0; }); return returnData; @@ -120,14 +142,24 @@ export class NotionV2 implements INodeType { const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); if (resource === 'databasePage') { if (['multi_select', 'select'].includes(type) && operation === 'getAll') { - return (properties[name][type].options) - .map((option: IDataObject) => ({ name: option.name, value: option.name })); - } else if (['multi_select', 'select'].includes(type) && ['create', 'update'].includes(operation)) { - return (properties[name][type].options) - .map((option: IDataObject) => ({ name: option.name, value: option.name })); + return properties[name][type].options.map((option: IDataObject) => ({ + name: option.name, + value: option.name, + })); + } else if ( + ['multi_select', 'select'].includes(type) && + ['create', 'update'].includes(operation) + ) { + return properties[name][type].options.map((option: IDataObject) => ({ + name: option.name, + value: option.name, + })); } } - return (properties[name][type].options).map((option: IDataObject) => ({ name: option.name, value: option.id })); + return properties[name][type].options.map((option: IDataObject) => ({ + name: option.name, + value: option.id, + })); }, async getUsers(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; @@ -145,11 +177,22 @@ export class NotionV2 implements INodeType { async getDatabaseIdFromPage(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const pageId = extractPageId(this.getCurrentNodeParameter('pageId') as string); - const { parent: { database_id: databaseId } } = await notionApiRequest.call(this, 'GET', `/pages/${pageId}`); + const { + parent: { database_id: databaseId }, + } = await notionApiRequest.call(this, 'GET', `/pages/${pageId}`); const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); for (const key of Object.keys(properties)) { //remove parameters that cannot be set from the API. - if (!['created_time', 'last_edited_time', 'created_by', 'last_edited_by', 'formula', 'rollup'].includes(properties[key].type)) { + if ( + ![ + 'created_time', + 'last_edited_time', + 'created_by', + 'last_edited_by', + 'formula', + 'rollup', + ].includes(properties[key].type) + ) { returnData.push({ name: `${key}`, value: `${key}|${properties[key].type}`, @@ -157,26 +200,35 @@ export class NotionV2 implements INodeType { } } returnData.sort((a, b) => { - if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { return -1; } - if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { return 1; } + if (a.name.toLocaleLowerCase() < b.name.toLocaleLowerCase()) { + return -1; + } + if (a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase()) { + return 1; + } return 0; }); return returnData; }, - async getDatabaseOptionsFromPage(this: ILoadOptionsFunctions): Promise { + async getDatabaseOptionsFromPage( + this: ILoadOptionsFunctions, + ): Promise { const pageId = extractPageId(this.getCurrentNodeParameter('pageId') as string); const [name, type] = (this.getCurrentNodeParameter('&key') as string).split('|'); - const { parent: { database_id: databaseId } } = await notionApiRequest.call(this, 'GET', `/pages/${pageId}`); + const { + parent: { database_id: databaseId }, + } = await notionApiRequest.call(this, 'GET', `/pages/${pageId}`); const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); - return (properties[name][type].options).map((option: IDataObject) => ({ name: option.name, value: option.name })); + return properties[name][type].options.map((option: IDataObject) => ({ + name: option.name, + value: option.name, + })); }, // Get all the timezones to display them to user so that he can // select them easily - async getTimezones( - this: ILoadOptionsFunctions, - ): Promise { + async getTimezones(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; for (const timezone of moment.tz.names()) { const timezoneName = timezone; @@ -209,14 +261,20 @@ export class NotionV2 implements INodeType { let download = false; if (resource === 'block') { - if (operation === 'append') { for (let i = 0; i < length; i++) { const blockId = extractPageId(this.getNodeParameter('blockId', i) as string); const body: IDataObject = { - children: formatBlocks(this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[]), + children: formatBlocks( + this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[], + ), }; - const block = await notionApiRequest.call(this, 'PATCH', `/blocks/${blockId}/children`, body); + const block = await notionApiRequest.call( + this, + 'PATCH', + `/blocks/${blockId}/children`, + body, + ); returnData.push(block); } } @@ -227,14 +285,30 @@ export class NotionV2 implements INodeType { const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll) { - responseData = await notionApiRequestAllItems.call(this, 'results', 'GET', `/blocks/${blockId}/children`, {}); + responseData = await notionApiRequestAllItems.call( + this, + 'results', + 'GET', + `/blocks/${blockId}/children`, + {}, + ); } else { qs.page_size = this.getNodeParameter('limit', i) as number; - responseData = await notionApiRequest.call(this, 'GET', `/blocks/${blockId}/children`, {}, qs); + responseData = await notionApiRequest.call( + this, + 'GET', + `/blocks/${blockId}/children`, + {}, + qs, + ); responseData = responseData.results; } - responseData = responseData.map((_data: IDataObject) => ({ object: _data.object, parent_id: blockId, ..._data })); + responseData = responseData.map((_data: IDataObject) => ({ + object: _data.object, + parent_id: blockId, + ..._data, + })); returnData.push.apply(returnData, responseData); } @@ -242,7 +316,6 @@ export class NotionV2 implements INodeType { } if (resource === 'database') { - if (operation === 'get') { const simple = this.getNodeParameter('simple', 0) as boolean; for (let i = 0; i < length; i++) { @@ -263,7 +336,13 @@ export class NotionV2 implements INodeType { }; const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll) { - responseData = await notionApiRequestAllItems.call(this, 'results', 'POST', `/search`, body); + responseData = await notionApiRequestAllItems.call( + this, + 'results', + 'POST', + `/search`, + body, + ); } else { body['page_size'] = this.getNodeParameter('limit', i) as number; responseData = await notionApiRequest.call(this, 'POST', `/search`, body); @@ -293,14 +372,26 @@ export class NotionV2 implements INodeType { body['query'] = text; } if (options.sort) { - const sort = (options.sort as IDataObject || {}).sortValue as IDataObject || {}; + const sort = (((options.sort as IDataObject) || {}).sortValue as IDataObject) || {}; body['sort'] = sort; } if (returnAll) { - responseData = await notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body); + responseData = await notionApiRequestAllItems.call( + this, + 'results', + 'POST', + '/search', + body, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body); + responseData = await notionApiRequestAllItems.call( + this, + 'results', + 'POST', + '/search', + body, + ); responseData = responseData.splice(0, qs.limit); } @@ -314,7 +405,6 @@ export class NotionV2 implements INodeType { } if (resource === 'databasePage') { - if (operation === 'create') { const databaseId = this.getNodeParameter('databaseId', 0) as string; const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); @@ -344,16 +434,28 @@ export class NotionV2 implements INodeType { }; } body.parent['database_id'] = this.getNodeParameter('databaseId', i) as string; - const properties = this.getNodeParameter('propertiesUi.propertyValues', i, []) as IDataObject[]; + const properties = this.getNodeParameter( + 'propertiesUi.propertyValues', + i, + [], + ) as IDataObject[]; if (properties.length !== 0) { - body.properties = Object.assign(body.properties, mapProperties(properties, timezone, 2) as IDataObject); + body.properties = Object.assign( + body.properties, + mapProperties(properties, timezone, 2) as IDataObject, + ); } - body.children = formatBlocks(this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[]); + body.children = formatBlocks( + this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[], + ); responseData = await notionApiRequest.call(this, 'POST', '/pages', body); if (simple === true) { responseData = simplifyObjects(responseData); } - returnData.push.apply(returnData, Array.isArray(responseData) ? responseData : [responseData]); + returnData.push.apply( + returnData, + Array.isArray(responseData) ? responseData : [responseData], + ); } } @@ -365,7 +467,10 @@ export class NotionV2 implements INodeType { if (simple === true) { responseData = simplifyObjects(responseData, download); } - returnData.push.apply(returnData, Array.isArray(responseData) ? responseData : [responseData]); + returnData.push.apply( + returnData, + Array.isArray(responseData) ? responseData : [responseData], + ); } } @@ -385,16 +490,22 @@ export class NotionV2 implements INodeType { if (filterType === 'manual') { const matchType = this.getNodeParameter('matchType', 0) as string; if (matchType === 'anyFilter') { - Object.assign(body.filter, { or: conditions.map((data) => mapFilters([data], timezone)) }); + Object.assign(body.filter, { + or: conditions.map((data) => mapFilters([data], timezone)), + }); } else if (matchType === 'allFilters') { - Object.assign(body.filter, { and: conditions.map((data) => mapFilters([data], timezone)) }); + Object.assign(body.filter, { + and: conditions.map((data) => mapFilters([data], timezone)), + }); } } else if (filterType === 'json') { const filterJson = this.getNodeParameter('filterJson', i) as string; if (validateJSON(filterJson) !== undefined) { body.filter = JSON.parse(filterJson); } else { - throw new NodeApiError(this.getNode(), { message: 'Filters (JSON) must be a valid json' }); + throw new NodeApiError(this.getNode(), { + message: 'Filters (JSON) must be a valid json', + }); } } @@ -406,10 +517,23 @@ export class NotionV2 implements INodeType { body['sorts'] = mapSorting(sort); } if (returnAll) { - responseData = await notionApiRequestAllItems.call(this, 'results', 'POST', `/databases/${databaseId}/query`, body, {}); + responseData = await notionApiRequestAllItems.call( + this, + 'results', + 'POST', + `/databases/${databaseId}/query`, + body, + {}, + ); } else { body.page_size = this.getNodeParameter('limit', i) as number; - responseData = await notionApiRequest.call(this, 'POST', `/databases/${databaseId}/query`, body, qs); + responseData = await notionApiRequest.call( + this, + 'POST', + `/databases/${databaseId}/query`, + body, + qs, + ); responseData = responseData.results; } if (download === true) { @@ -426,7 +550,11 @@ export class NotionV2 implements INodeType { for (let i = 0; i < length; i++) { const pageId = extractPageId(this.getNodeParameter('pageId', i) as string); const simple = this.getNodeParameter('simple', i) as boolean; - const properties = this.getNodeParameter('propertiesUi.propertyValues', i, []) as IDataObject[]; + const properties = this.getNodeParameter( + 'propertiesUi.propertyValues', + i, + [], + ) as IDataObject[]; // tslint:disable-next-line: no-any const body: { [key: string]: any } = { properties: {}, @@ -438,13 +566,15 @@ export class NotionV2 implements INodeType { if (simple === true) { responseData = simplifyObjects(responseData, false); } - returnData.push.apply(returnData, Array.isArray(responseData) ? responseData : [responseData]); + returnData.push.apply( + returnData, + Array.isArray(responseData) ? responseData : [responseData], + ); } } } if (resource === 'user') { - if (operation === 'get') { for (let i = 0; i < length; i++) { const userId = this.getNodeParameter('userId', i) as string; @@ -468,16 +598,20 @@ export class NotionV2 implements INodeType { } if (resource === 'page') { - if (operation === 'archive') { for (let i = 0; i < length; i++) { const pageId = extractPageId(this.getNodeParameter('pageId', i) as string); const simple = this.getNodeParameter('simple', i) as boolean; - responseData = await notionApiRequest.call(this, 'PATCH', `/pages/${pageId}`, { archived: true }); + responseData = await notionApiRequest.call(this, 'PATCH', `/pages/${pageId}`, { + archived: true, + }); if (simple === true) { responseData = simplifyObjects(responseData, download); } - returnData.push.apply(returnData, Array.isArray(responseData) ? responseData : [responseData]); + returnData.push.apply( + returnData, + Array.isArray(responseData) ? responseData : [responseData], + ); } } @@ -491,12 +625,17 @@ export class NotionV2 implements INodeType { }; body.parent['page_id'] = extractPageId(this.getNodeParameter('pageId', i) as string); body.properties = formatTitle(this.getNodeParameter('title', i) as string); - body.children = formatBlocks(this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[]); + body.children = formatBlocks( + this.getNodeParameter('blockUi.blockValues', i, []) as IDataObject[], + ); responseData = await notionApiRequest.call(this, 'POST', '/pages', body); if (simple === true) { responseData = simplifyObjects(responseData, download); } - returnData.push.apply(returnData, Array.isArray(responseData) ? responseData : [responseData]); + returnData.push.apply( + returnData, + Array.isArray(responseData) ? responseData : [responseData], + ); } } @@ -512,18 +651,30 @@ export class NotionV2 implements INodeType { body['query'] = text; } if (options.filter) { - const filter = (options.filter as IDataObject || {}).filters as IDataObject[] || []; + const filter = (((options.filter as IDataObject) || {}).filters as IDataObject[]) || []; body['filter'] = filter; } if (options.sort) { - const sort = (options.sort as IDataObject || {}).sortValue as IDataObject || {}; + const sort = (((options.sort as IDataObject) || {}).sortValue as IDataObject) || {}; body['sort'] = sort; } if (returnAll) { - responseData = await notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body); + responseData = await notionApiRequestAllItems.call( + this, + 'results', + 'POST', + '/search', + body, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await notionApiRequestAllItems.call(this, 'results', 'POST', '/search', body); + responseData = await notionApiRequestAllItems.call( + this, + 'results', + 'POST', + '/search', + body, + ); responseData = responseData.splice(0, qs.limit); } diff --git a/packages/nodes-base/nodes/Notion/v2/VersionDescription.ts b/packages/nodes-base/nodes/Notion/v2/VersionDescription.ts index a6762efacb..3eb7363fa9 100644 --- a/packages/nodes-base/nodes/Notion/v2/VersionDescription.ts +++ b/packages/nodes-base/nodes/Notion/v2/VersionDescription.ts @@ -1,32 +1,15 @@ /* eslint-disable n8n-nodes-base/node-filename-against-convention */ -import { - databaseFields, - databaseOperations, -} from '../DatabaseDescription'; +import { databaseFields, databaseOperations } from '../DatabaseDescription'; -import { - userFields, - userOperations, -} from '../UserDescription'; +import { userFields, userOperations } from '../UserDescription'; -import { - pageFields, - pageOperations, -} from '../PageDescription'; +import { pageFields, pageOperations } from '../PageDescription'; -import { - blockFields, - blockOperations, -} from '../BlockDescription'; +import { blockFields, blockOperations } from '../BlockDescription'; -import { - databasePageFields, - databasePageOperations, -} from '../DatabasePageDescription'; +import { databasePageFields, databasePageOperations } from '../DatabasePageDescription'; -import { - INodeTypeDescription, -} from 'n8n-workflow'; +import { INodeTypeDescription } from 'n8n-workflow'; export const versionDescription: INodeTypeDescription = { displayName: 'Notion (Beta)', @@ -85,7 +68,7 @@ export const versionDescription: INodeTypeDescription = { // description: 'The resource to operate on.', // }, { - displayName: 'To access content, make sure it\'s shared with your integration in Notion', + displayName: "To access content, make sure it's shared with your integration in Notion", name: 'notionNotice', type: 'notice', default: '', diff --git a/packages/nodes-base/nodes/Odoo/GenericFunctions.ts b/packages/nodes-base/nodes/Odoo/GenericFunctions.ts index 8e69468105..f0be4288ff 100644 --- a/packages/nodes-base/nodes/Odoo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Odoo/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,11 +7,7 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, - JsonObject, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, JsonObject, NodeApiError } from 'n8n-workflow'; const serviceJSONRPC = 'object'; const methodJSONRPC = 'execute'; @@ -81,7 +75,7 @@ export interface IOdooResponceFields { type OdooCRUD = 'create' | 'update' | 'delete' | 'get' | 'getAll'; -export function odooGetDBName (databaseName: string | undefined, url: string) { +export function odooGetDBName(databaseName: string | undefined, url: string) { if (databaseName) return databaseName; const odooURL = new URL(url); const hostname = odooURL.hostname; diff --git a/packages/nodes-base/nodes/Odoo/Odoo.node.ts b/packages/nodes-base/nodes/Odoo/Odoo.node.ts index 86ff95dbd0..f8387834db 100644 --- a/packages/nodes-base/nodes/Odoo/Odoo.node.ts +++ b/packages/nodes-base/nodes/Odoo/Odoo.node.ts @@ -242,30 +242,34 @@ export class Odoo implements INodeType { const credentials = credential.data; try { - const body = { - jsonrpc: '2.0', - method: 'call', - params: { - service: 'common', - method: 'login', - args: [odooGetDBName(credentials?.db as string, credentials?.url as string), credentials?.username, credentials?.password], - }, - id: Math.floor(Math.random() * 100), - }; + const body = { + jsonrpc: '2.0', + method: 'call', + params: { + service: 'common', + method: 'login', + args: [ + odooGetDBName(credentials?.db as string, credentials?.url as string), + credentials?.username, + credentials?.password, + ], + }, + id: Math.floor(Math.random() * 100), + }; - const options: OptionsWithUri = { - headers: { - 'User-Agent': 'n8n', - Connection: 'keep-alive', - Accept: '*/*', - 'Content-Type': 'application/json', - }, - method: 'POST', - body, - uri: `${(credentials?.url as string).replace(/\/$/, '')}/jsonrpc`, - json: true, - }; - const result = await this.helpers.request!(options); + const options: OptionsWithUri = { + headers: { + 'User-Agent': 'n8n', + Connection: 'keep-alive', + Accept: '*/*', + 'Content-Type': 'application/json', + }, + method: 'POST', + body, + uri: `${(credentials?.url as string).replace(/\/$/, '')}/jsonrpc`, + json: true, + }; + const result = await this.helpers.request!(options); if (result.error || !result.result) { return { status: 'Error', @@ -362,7 +366,7 @@ export class Odoo implements INodeType { if (operation === 'get') { const contactId = this.getNodeParameter('contactId', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; - const fields = options.fieldsList as IDataObject[] || []; + const fields = (options.fieldsList as IDataObject[]) || []; responseData = await odooGet.call( this, db, @@ -379,7 +383,7 @@ export class Odoo implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; const options = this.getNodeParameter('options', i) as IDataObject; - const fields = options.fieldsList as IDataObject[] || []; + const fields = (options.fieldsList as IDataObject[]) || []; if (returnAll) { responseData = await odooGetAll.call( this, @@ -471,7 +475,7 @@ export class Odoo implements INodeType { if (operation === 'get') { const customResourceId = this.getNodeParameter('customResourceId', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; - const fields = options.fieldsList as IDataObject[] || []; + const fields = (options.fieldsList as IDataObject[]) || []; responseData = await odooGet.call( this, db, @@ -488,7 +492,7 @@ export class Odoo implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; const options = this.getNodeParameter('options', i) as IDataObject; - const fields = options.fieldsList as IDataObject[] || []; + const fields = (options.fieldsList as IDataObject[]) || []; const filter = this.getNodeParameter('filterRequest', i) as IOdooFilterOperations; if (returnAll) { responseData = await odooGetAll.call( @@ -573,7 +577,7 @@ export class Odoo implements INodeType { if (operation === 'get') { const noteId = this.getNodeParameter('noteId', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; - const fields = options.fieldsList as IDataObject[] || []; + const fields = (options.fieldsList as IDataObject[]) || []; responseData = await odooGet.call( this, db, @@ -590,7 +594,7 @@ export class Odoo implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; const options = this.getNodeParameter('options', i) as IDataObject; - const fields = options.fieldsList as IDataObject[] || []; + const fields = (options.fieldsList as IDataObject[]) || []; if (returnAll) { responseData = await odooGetAll.call( this, @@ -678,7 +682,7 @@ export class Odoo implements INodeType { if (operation === 'get') { const opportunityId = this.getNodeParameter('opportunityId', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; - const fields = options.fieldsList as IDataObject[] || []; + const fields = (options.fieldsList as IDataObject[]) || []; responseData = await odooGet.call( this, db, @@ -695,7 +699,7 @@ export class Odoo implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; const options = this.getNodeParameter('options', i) as IDataObject; - const fields = options.fieldsList as IDataObject[] || []; + const fields = (options.fieldsList as IDataObject[]) || []; if (returnAll) { responseData = await odooGetAll.call( this, diff --git a/packages/nodes-base/nodes/Odoo/descriptions/ContactDescription.ts b/packages/nodes-base/nodes/Odoo/descriptions/ContactDescription.ts index 7e44338b03..2b0843ec31 100644 --- a/packages/nodes-base/nodes/Odoo/descriptions/ContactDescription.ts +++ b/packages/nodes-base/nodes/Odoo/descriptions/ContactDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactOperations: INodeProperties[] = [ { @@ -11,9 +9,7 @@ export const contactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contact', - ], + resource: ['contact'], }, }, options: [ @@ -63,12 +59,8 @@ export const contactDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], + operation: ['create'], + resource: ['contact'], }, }, }, @@ -80,12 +72,8 @@ export const contactDescription: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], + operation: ['create'], + resource: ['contact'], }, }, options: [ @@ -113,7 +101,8 @@ export const contactDescription: INodeProperties[] = [ displayName: 'Country Name or ID', name: 'country_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getCountries', @@ -123,7 +112,8 @@ export const contactDescription: INodeProperties[] = [ displayName: 'State Name or ID', name: 'state_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getStates', @@ -208,13 +198,8 @@ export const contactDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - 'delete', - ], - resource: [ - 'contact', - ], + operation: ['get', 'delete'], + resource: ['contact'], }, }, }, @@ -229,12 +214,8 @@ export const contactDescription: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, default: false, @@ -248,15 +229,9 @@ export const contactDescription: INodeProperties[] = [ default: 50, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['contact'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -273,13 +248,8 @@ export const contactDescription: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - 'get', - ], - resource: [ - 'contact', - ], + operation: ['getAll', 'get'], + resource: ['contact'], }, }, options: [ @@ -288,7 +258,8 @@ export const contactDescription: INodeProperties[] = [ displayName: 'Fields to Include', name: 'fieldsList', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', default: [], typeOptions: { loadOptionsMethod: 'getModelFields', @@ -308,12 +279,8 @@ export const contactDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'contact', - ], + operation: ['update'], + resource: ['contact'], }, }, }, @@ -325,12 +292,8 @@ export const contactDescription: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'contact', - ], + operation: ['update'], + resource: ['contact'], }, }, options: [ @@ -358,7 +321,8 @@ export const contactDescription: INodeProperties[] = [ displayName: 'Country Name or ID', name: 'country_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getCountries', @@ -368,7 +332,8 @@ export const contactDescription: INodeProperties[] = [ displayName: 'State Name or ID', name: 'state_id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getStates', diff --git a/packages/nodes-base/nodes/Odoo/descriptions/CustomResourceDescription.ts b/packages/nodes-base/nodes/Odoo/descriptions/CustomResourceDescription.ts index 15836857e9..a7e76eac41 100644 --- a/packages/nodes-base/nodes/Odoo/descriptions/CustomResourceDescription.ts +++ b/packages/nodes-base/nodes/Odoo/descriptions/CustomResourceDescription.ts @@ -1,22 +1,19 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const customResourceOperations: INodeProperties[] = [ { displayName: 'Custom Resource Name or ID', name: 'customResource', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getModels', }, displayOptions: { show: { - resource: [ - 'custom', - ], + resource: ['custom'], }, }, }, @@ -28,9 +25,7 @@ export const customResourceOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'custom', - ], + resource: ['custom'], }, }, options: [ @@ -84,12 +79,8 @@ export const customResourceDescription: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'custom', - ], + operation: ['create'], + resource: ['custom'], }, }, options: [ @@ -101,7 +92,8 @@ export const customResourceDescription: INodeProperties[] = [ displayName: 'Field Name or ID', name: 'fieldName', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getModelFields', @@ -129,13 +121,8 @@ export const customResourceDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - 'delete', - ], - resource: [ - 'custom', - ], + operation: ['get', 'delete'], + resource: ['custom'], }, }, }, @@ -148,12 +135,8 @@ export const customResourceDescription: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'custom', - ], - operation: [ - 'getAll', - ], + resource: ['custom'], + operation: ['getAll'], }, }, default: false, @@ -167,15 +150,9 @@ export const customResourceDescription: INodeProperties[] = [ default: 50, displayOptions: { show: { - resource: [ - 'custom', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['custom'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -192,13 +169,8 @@ export const customResourceDescription: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - 'get', - ], - resource: [ - 'custom', - ], + operation: ['getAll', 'get'], + resource: ['custom'], }, }, options: [ @@ -207,13 +179,12 @@ export const customResourceDescription: INodeProperties[] = [ displayName: 'Fields to Include', name: 'fieldsList', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', default: [], typeOptions: { loadOptionsMethod: 'getModelFields', - loadOptionsDependsOn: [ - 'customResource', - ], + loadOptionsDependsOn: ['customResource'], }, }, ], @@ -231,12 +202,8 @@ export const customResourceDescription: INodeProperties[] = [ placeholder: 'Add condition', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'custom', - ], + operation: ['getAll'], + resource: ['custom'], }, }, options: [ @@ -248,12 +215,11 @@ export const customResourceDescription: INodeProperties[] = [ displayName: 'Field Name or ID', name: 'fieldName', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { - loadOptionsDependsOn: [ - 'customResource', - ], + loadOptionsDependsOn: ['customResource'], loadOptionsMethod: 'getModelFields', }, }, @@ -328,12 +294,8 @@ export const customResourceDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'custom', - ], + operation: ['update'], + resource: ['custom'], }, }, }, @@ -350,12 +312,8 @@ export const customResourceDescription: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'custom', - ], + operation: ['update'], + resource: ['custom'], }, }, options: [ @@ -367,7 +325,8 @@ export const customResourceDescription: INodeProperties[] = [ displayName: 'Field Name or ID', name: 'fieldName', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getModelFields', diff --git a/packages/nodes-base/nodes/Odoo/descriptions/NoteDescription.ts b/packages/nodes-base/nodes/Odoo/descriptions/NoteDescription.ts index 97f08e0403..2bf72ae855 100644 --- a/packages/nodes-base/nodes/Odoo/descriptions/NoteDescription.ts +++ b/packages/nodes-base/nodes/Odoo/descriptions/NoteDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const noteOperations: INodeProperties[] = [ { @@ -11,9 +9,7 @@ export const noteOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'note', - ], + resource: ['note'], }, }, options: [ @@ -63,12 +59,8 @@ export const noteDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'note', - ], + operation: ['create'], + resource: ['note'], }, }, }, @@ -109,13 +101,8 @@ export const noteDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - 'delete', - ], - resource: [ - 'note', - ], + operation: ['get', 'delete'], + resource: ['note'], }, }, }, @@ -129,12 +116,8 @@ export const noteDescription: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'getAll', - ], + resource: ['note'], + operation: ['getAll'], }, }, default: false, @@ -148,15 +131,9 @@ export const noteDescription: INodeProperties[] = [ default: 50, displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['note'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -173,13 +150,8 @@ export const noteDescription: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - 'get', - ], - resource: [ - 'note', - ], + operation: ['getAll', 'get'], + resource: ['note'], }, }, options: [ @@ -188,7 +160,8 @@ export const noteDescription: INodeProperties[] = [ displayName: 'Fields to Include', name: 'fieldsList', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', default: [], typeOptions: { loadOptionsMethod: 'getModelFields', @@ -207,12 +180,8 @@ export const noteDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'note', - ], + operation: ['update'], + resource: ['note'], }, }, }, @@ -224,12 +193,8 @@ export const noteDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'note', - ], + operation: ['update'], + resource: ['note'], }, }, }, diff --git a/packages/nodes-base/nodes/Odoo/descriptions/OpportunityDescription.ts b/packages/nodes-base/nodes/Odoo/descriptions/OpportunityDescription.ts index c4ad4b80fc..6304d07a03 100644 --- a/packages/nodes-base/nodes/Odoo/descriptions/OpportunityDescription.ts +++ b/packages/nodes-base/nodes/Odoo/descriptions/OpportunityDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const opportunityOperations: INodeProperties[] = [ { @@ -11,9 +9,7 @@ export const opportunityOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'opportunity', - ], + resource: ['opportunity'], }, }, options: [ @@ -63,12 +59,8 @@ export const opportunityDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'opportunity', - ], + operation: ['create'], + resource: ['opportunity'], }, }, }, @@ -81,12 +73,8 @@ export const opportunityDescription: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'opportunity', - ], + operation: ['create'], + resource: ['opportunity'], }, }, options: [ @@ -164,13 +152,8 @@ export const opportunityDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - 'delete', - ], - resource: [ - 'opportunity', - ], + operation: ['get', 'delete'], + resource: ['opportunity'], }, }, }, @@ -184,12 +167,8 @@ export const opportunityDescription: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'getAll', - ], + resource: ['opportunity'], + operation: ['getAll'], }, }, default: false, @@ -203,15 +182,9 @@ export const opportunityDescription: INodeProperties[] = [ default: 50, displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['opportunity'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -228,13 +201,8 @@ export const opportunityDescription: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - 'get', - ], - resource: [ - 'opportunity', - ], + operation: ['getAll', 'get'], + resource: ['opportunity'], }, }, options: [ @@ -243,7 +211,8 @@ export const opportunityDescription: INodeProperties[] = [ displayName: 'Fields to Include', name: 'fieldsList', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', default: [], typeOptions: { loadOptionsMethod: 'getModelFields', @@ -262,12 +231,8 @@ export const opportunityDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'opportunity', - ], + operation: ['update'], + resource: ['opportunity'], }, }, }, @@ -279,12 +244,8 @@ export const opportunityDescription: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'opportunity', - ], + operation: ['update'], + resource: ['opportunity'], }, }, options: [ diff --git a/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts b/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts index e816a28881..4cee639308 100644 --- a/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts @@ -1,18 +1,18 @@ -import { - OptionsWithUri -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function oneSimpleApiRequest(this: IExecuteFunctions, method: string, resource: string, body: IDataObject = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}) { +export async function oneSimpleApiRequest( + this: IExecuteFunctions, + method: string, + resource: string, + body: IDataObject = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, +) { const credentials = await this.getCredentials('oneSimpleApi'); const outputFormat = 'json'; @@ -20,7 +20,9 @@ export async function oneSimpleApiRequest(this: IExecuteFunctions, method: strin method, body, qs, - uri: uri || `https://onesimpleapi.com/api${resource}?token=${credentials.apiToken}&output=${outputFormat}`, + uri: + uri || + `https://onesimpleapi.com/api${resource}?token=${credentials.apiToken}&output=${outputFormat}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/OneSimpleApi/OneSimpleApi.node.ts b/packages/nodes-base/nodes/OneSimpleApi/OneSimpleApi.node.ts index 94c7aeca2b..ba0bafa848 100644 --- a/packages/nodes-base/nodes/OneSimpleApi/OneSimpleApi.node.ts +++ b/packages/nodes-base/nodes/OneSimpleApi/OneSimpleApi.node.ts @@ -1,17 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - oneSimpleApiRequest, -} from './GenericFunctions'; +import { oneSimpleApiRequest } from './GenericFunctions'; export class OneSimpleApi implements INodeType { description: INodeTypeDescription = { @@ -67,9 +58,7 @@ export class OneSimpleApi implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'website', - ], + resource: ['website'], }, }, options: [ @@ -102,9 +91,7 @@ export class OneSimpleApi implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'socialProfile', - ], + resource: ['socialProfile'], }, }, options: [ @@ -131,9 +118,7 @@ export class OneSimpleApi implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'information', - ], + resource: ['information'], }, }, options: [ @@ -160,9 +145,7 @@ export class OneSimpleApi implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'utility', - ], + resource: ['utility'], }, }, options: [ @@ -195,12 +178,8 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'pdf', - ], - resource: [ - 'website', - ], + operation: ['pdf'], + resource: ['website'], }, }, default: '', @@ -213,12 +192,8 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'pdf', - ], - resource: [ - 'website', - ], + operation: ['pdf'], + resource: ['website'], }, }, default: false, @@ -231,15 +206,9 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'pdf', - ], - resource: [ - 'website', - ], - download: [ - true, - ], + operation: ['pdf'], + resource: ['website'], + download: [true], }, }, default: 'data', @@ -253,12 +222,8 @@ export class OneSimpleApi implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'website', - ], - operation: [ - 'pdf', - ], + resource: ['website'], + operation: ['pdf'], }, }, options: [ @@ -320,7 +285,8 @@ export class OneSimpleApi implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Normally the API will reuse a previously taken screenshot of the URL to give a faster response. This option allows you to retake the screenshot at that exact time, for those times when it\'s necessary.', + description: + "Normally the API will reuse a previously taken screenshot of the URL to give a faster response. This option allows you to retake the screenshot at that exact time, for those times when it's necessary.", }, ], }, @@ -332,12 +298,8 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'qrCode', - ], - resource: [ - 'utility', - ], + operation: ['qrCode'], + resource: ['utility'], }, }, default: '', @@ -350,12 +312,8 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'qrCode', - ], - resource: [ - 'utility', - ], + operation: ['qrCode'], + resource: ['utility'], }, }, default: false, @@ -368,15 +326,9 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'qrCode', - ], - resource: [ - 'utility', - ], - download: [ - true, - ], + operation: ['qrCode'], + resource: ['utility'], + download: [true], }, }, default: 'data', @@ -390,12 +342,8 @@ export class OneSimpleApi implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'utility', - ], - operation: [ - 'qrCode', - ], + resource: ['utility'], + operation: ['qrCode'], }, }, options: [ @@ -447,12 +395,8 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'screenshot', - ], - resource: [ - 'website', - ], + operation: ['screenshot'], + resource: ['website'], }, }, default: '', @@ -465,12 +409,8 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'screenshot', - ], - resource: [ - 'website', - ], + operation: ['screenshot'], + resource: ['website'], }, }, default: false, @@ -483,15 +423,9 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'screenshot', - ], - resource: [ - 'website', - ], - download: [ - true, - ], + operation: ['screenshot'], + resource: ['website'], + download: [true], }, }, default: 'data', @@ -505,12 +439,8 @@ export class OneSimpleApi implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'website', - ], - operation: [ - 'screenshot', - ], + resource: ['website'], + operation: ['screenshot'], }, }, options: [ @@ -548,7 +478,8 @@ export class OneSimpleApi implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Normally the API will reuse a previously taken screenshot of the URL to give a faster response. This option allows you to retake the screenshot at that exact time, for those times when it\'s necessary.', + description: + "Normally the API will reuse a previously taken screenshot of the URL to give a faster response. This option allows you to retake the screenshot at that exact time, for those times when it's necessary.", }, { displayName: 'Full Page', @@ -556,7 +487,8 @@ export class OneSimpleApi implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'The API takes a screenshot of the viewable area for the desired screen size. If you need a screenshot of the whole length of the page, use this option.', + description: + 'The API takes a screenshot of the viewable area for the desired screen size. If you need a screenshot of the whole length of the page, use this option.', }, ], }, @@ -568,12 +500,8 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'instagramProfile', - ], - resource: [ - 'socialProfile', - ], + operation: ['instagramProfile'], + resource: ['socialProfile'], }, }, default: '', @@ -587,12 +515,8 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'spotifyArtistProfile', - ], - resource: [ - 'socialProfile', - ], + operation: ['spotifyArtistProfile'], + resource: ['socialProfile'], }, }, default: '', @@ -606,12 +530,8 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'exchangeRate', - ], - resource: [ - 'information', - ], + operation: ['exchangeRate'], + resource: ['information'], }, }, default: '', @@ -625,12 +545,8 @@ export class OneSimpleApi implements INodeType { placeholder: 'USD', displayOptions: { show: { - operation: [ - 'exchangeRate', - ], - resource: [ - 'information', - ], + operation: ['exchangeRate'], + resource: ['information'], }, }, default: '', @@ -643,12 +559,8 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'exchangeRate', - ], - resource: [ - 'information', - ], + operation: ['exchangeRate'], + resource: ['information'], }, }, default: '', @@ -661,12 +573,8 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'imageMetadata', - ], - resource: [ - 'information', - ], + operation: ['imageMetadata'], + resource: ['information'], }, }, default: '', @@ -680,12 +588,8 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'seo', - ], - resource: [ - 'website', - ], + operation: ['seo'], + resource: ['website'], }, }, default: '', @@ -699,12 +603,8 @@ export class OneSimpleApi implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'website', - ], - operation: [ - 'seo', - ], + resource: ['website'], + operation: ['seo'], }, }, options: [ @@ -724,12 +624,8 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'validateEmail', - ], - resource: [ - 'utility', - ], + operation: ['validateEmail'], + resource: ['utility'], }, }, default: '', @@ -742,12 +638,8 @@ export class OneSimpleApi implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'expandURL', - ], - resource: [ - 'utility', - ], + operation: ['expandURL'], + resource: ['utility'], }, }, default: '', @@ -789,7 +681,15 @@ export class OneSimpleApi implements INodeType { if (download) { const output = this.getNodeParameter('output', i) as string; - const buffer = await oneSimpleApiRequest.call(this, 'GET', '', {}, {}, response.url, { json: false, encoding: null }) as Buffer; + const buffer = (await oneSimpleApiRequest.call( + this, + 'GET', + '', + {}, + {}, + response.url, + { json: false, encoding: null }, + )) as Buffer; responseData = { json: response, binary: { @@ -828,7 +728,15 @@ export class OneSimpleApi implements INodeType { if (download) { const output = this.getNodeParameter('output', i) as string; - const buffer = await oneSimpleApiRequest.call(this, 'GET', '', {}, {}, response.url, { json: false, encoding: null }) as Buffer; + const buffer = (await oneSimpleApiRequest.call( + this, + 'GET', + '', + {}, + {}, + response.url, + { json: false, encoding: null }, + )) as Buffer; responseData = { json: response, binary: { @@ -857,7 +765,13 @@ export class OneSimpleApi implements INodeType { if (operation === 'instagramProfile') { const profileName = this.getNodeParameter('profileName', i) as string; qs.profile = profileName; - responseData = await oneSimpleApiRequest.call(this, 'GET', '/instagram_profile', {}, qs); + responseData = await oneSimpleApiRequest.call( + this, + 'GET', + '/instagram_profile', + {}, + qs, + ); } if (operation === 'spotifyArtistProfile') { @@ -919,7 +833,15 @@ export class OneSimpleApi implements INodeType { if (download) { const output = this.getNodeParameter('output', i) as string; - const buffer = await oneSimpleApiRequest.call(this, 'GET', '', {}, {}, response.url, { json: false, encoding: null }) as Buffer; + const buffer = (await oneSimpleApiRequest.call( + this, + 'GET', + '', + {}, + {}, + response.url, + { json: false, encoding: null }, + )) as Buffer; responseData = { json: response, binary: { @@ -937,7 +859,6 @@ export class OneSimpleApi implements INodeType { } else { returnData.push(responseData as IDataObject); } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -954,4 +875,3 @@ export class OneSimpleApi implements INodeType { return [this.helpers.returnJsonArray(returnData)]; } } - diff --git a/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts b/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts index cd9bc02379..8a1b1ed9d5 100644 --- a/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts @@ -7,12 +7,10 @@ import { INodePropertyOptions, IWebhookFunctions, JsonObject, - NodeApiError + NodeApiError, } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import moment from 'moment-timezone'; @@ -20,10 +18,13 @@ export async function onfleetApiRequest( this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, - body: any = {}, // tslint:disable-line:no-any - qs?: any, // tslint:disable-line:no-any - uri?: string): Promise { // tslint:disable-line:no-any - + // tslint:disable-next-line:no-any + body: any = {}, + // tslint:disable-next-line:no-any + qs?: any, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('onfleetApi'); const options: OptionsWithUri = { @@ -57,8 +58,8 @@ export async function onfleetApiRequestAllItems( // tslint:disable-next-line: no-any body: any = {}, query: IDataObject = {}, -): Promise { // tslint:disable-line:no-any - + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -67,17 +68,18 @@ export async function onfleetApiRequestAllItems( responseData = await onfleetApiRequest.call(this, method, endpoint, body, query); query.lastId = responseData['lastId']; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['lastId'] !== undefined - ); + } while (responseData['lastId'] !== undefined); return returnData; } export const resourceLoaders = { async getTeams(this: ILoadOptionsFunctions): Promise { try { - const teams = await onfleetApiRequest.call(this, 'GET', 'teams') as IDataObject[]; - return teams.map(({ name = '', id: value = '' }) => ({ name, value })) as INodePropertyOptions[]; + const teams = (await onfleetApiRequest.call(this, 'GET', 'teams')) as IDataObject[]; + return teams.map(({ name = '', id: value = '' }) => ({ + name, + value, + })) as INodePropertyOptions[]; } catch (error) { return []; } @@ -85,8 +87,11 @@ export const resourceLoaders = { async getWorkers(this: ILoadOptionsFunctions): Promise { try { - const workers = await onfleetApiRequest.call(this, 'GET', 'workers') as IDataObject[]; - return workers.map(({ name = '', id: value = '' }) => ({ name, value })) as INodePropertyOptions[]; + const workers = (await onfleetApiRequest.call(this, 'GET', 'workers')) as IDataObject[]; + return workers.map(({ name = '', id: value = '' }) => ({ + name, + value, + })) as INodePropertyOptions[]; } catch (error) { return []; } @@ -94,8 +99,11 @@ export const resourceLoaders = { async getAdmins(this: ILoadOptionsFunctions): Promise { try { - const admins = await onfleetApiRequest.call(this, 'GET', 'admins') as IDataObject[]; - return admins.map(({ name = '', id: value = '' }) => ({ name, value })) as INodePropertyOptions[]; + const admins = (await onfleetApiRequest.call(this, 'GET', 'admins')) as IDataObject[]; + return admins.map(({ name = '', id: value = '' }) => ({ + name, + value, + })) as INodePropertyOptions[]; } catch (error) { return []; } @@ -103,8 +111,11 @@ export const resourceLoaders = { async getHubs(this: ILoadOptionsFunctions): Promise { try { - const hubs = await onfleetApiRequest.call(this, 'GET', 'hubs') as IDataObject[]; - return hubs.map(({ name = '', id: value = '' }) => ({ name, value })) as INodePropertyOptions[]; + const hubs = (await onfleetApiRequest.call(this, 'GET', 'hubs')) as IDataObject[]; + return hubs.map(({ name = '', id: value = '' }) => ({ + name, + value, + })) as INodePropertyOptions[]; } catch (error) { return []; } diff --git a/packages/nodes-base/nodes/Onfleet/Onfleet.node.ts b/packages/nodes-base/nodes/Onfleet/Onfleet.node.ts index 7aa62ef457..66145f5bae 100644 --- a/packages/nodes-base/nodes/Onfleet/Onfleet.node.ts +++ b/packages/nodes-base/nodes/Onfleet/Onfleet.node.ts @@ -8,67 +8,34 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - taskFields, - taskOperations, -} from './descriptions/TaskDescription'; +import { taskFields, taskOperations } from './descriptions/TaskDescription'; -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - destinationFields, - destinationOperations, -} from './descriptions/DestinationDescription'; +import { destinationFields, destinationOperations } from './descriptions/DestinationDescription'; -import { - resourceLoaders, -} from './GenericFunctions'; +import { resourceLoaders } from './GenericFunctions'; -import { - recipientFields, - recipientOperations, -} from './descriptions/RecipientDescription'; +import { recipientFields, recipientOperations } from './descriptions/RecipientDescription'; -import { - organizationFields, - organizationOperations, -} from './descriptions/OrganizationDescription'; +import { organizationFields, organizationOperations } from './descriptions/OrganizationDescription'; -import { - adminFields, - adminOperations, -} from './descriptions/AdministratorDescription'; +import { adminFields, adminOperations } from './descriptions/AdministratorDescription'; -import { - hubFields, - hubOperations, -} from './descriptions/HubDescription'; +import { hubFields, hubOperations } from './descriptions/HubDescription'; -import { - workerFields, - workerOperations, -} from './descriptions/WorkerDescription'; +import { workerFields, workerOperations } from './descriptions/WorkerDescription'; // import { // webhookFields, // webhookOperations, // } from './descriptions/WebhookDescription'; -import { - containerFields, - containerOperations, -} from './descriptions/ContainerDescription'; +import { containerFields, containerOperations } from './descriptions/ContainerDescription'; -import { - teamFields, - teamOperations, -} from './descriptions/TeamDescription'; +import { teamFields, teamOperations } from './descriptions/TeamDescription'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { Onfleet as OnfleetMethods } from './Onfleet'; export class Onfleet implements INodeType { @@ -171,7 +138,10 @@ export class Onfleet implements INodeType { methods = { credentialTest: { - async onfleetApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { + async onfleetApiTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { const credentials = credential.data as IDataObject; const options: OptionsWithUri = { diff --git a/packages/nodes-base/nodes/Onfleet/Onfleet.ts b/packages/nodes-base/nodes/Onfleet/Onfleet.ts index 30bf7c48aa..28acc1d172 100644 --- a/packages/nodes-base/nodes/Onfleet/Onfleet.ts +++ b/packages/nodes-base/nodes/Onfleet/Onfleet.ts @@ -27,13 +27,10 @@ import { OnfleetWorkerEstimates, OnfleetWorkerFilter, OnfleetWorkerSchedule, - OnfleetWorkerScheduleEntry + OnfleetWorkerScheduleEntry, } from './interfaces'; -import { - onfleetApiRequest, - onfleetApiRequestAllItems, -} from './GenericFunctions'; +import { onfleetApiRequest, onfleetApiRequestAllItems } from './GenericFunctions'; import moment from 'moment-timezone'; @@ -80,7 +77,6 @@ const formatAddress = ( }; export class Onfleet { - /** * Returns a valid formatted destination object * @param unparsed Whether the address is parsed or not @@ -102,7 +98,9 @@ export class Onfleet { */ static getDestinationFields( this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - item: number, operation: string, shared: { parent: string } | boolean = false, + item: number, + operation: string, + shared: { parent: string } | boolean = false, ): OnfleetDestination | OnfleetDestination[] | null { if (['create', 'update'].includes(operation)) { /* -------------------------------------------------------------------------- */ @@ -111,19 +109,31 @@ export class Onfleet { if (shared !== false) { let destination; if (typeof shared === 'boolean' && shared) { - const { destinationProperties = {} } = this.getNodeParameter('destination', item) as IDataObject; + const { destinationProperties = {} } = this.getNodeParameter( + 'destination', + item, + ) as IDataObject; destination = destinationProperties; } else if (typeof shared !== 'boolean') { - const { destination: destinationCollection = {} } = this.getNodeParameter(shared.parent, item) as IDataObject; + const { destination: destinationCollection = {} } = this.getNodeParameter( + shared.parent, + item, + ) as IDataObject; destination = (destinationCollection as IDataObject).destinationProperties; } - if (!destination || Object.keys((destination) as IDataObject).length === 0) { + if (!destination || Object.keys(destination as IDataObject).length === 0) { return []; } const { - unparsed, address, addressNumber, addressStreet, addressCity, addressCountry, ...additionalFields + unparsed, + address, + addressNumber, + addressStreet, + addressCity, + addressCountry, + ...additionalFields } = destination as IDataObject; return formatAddress( unparsed as boolean, @@ -135,7 +145,13 @@ export class Onfleet { additionalFields as IDataObject, ) as OnfleetDestination; } else { - let unparsed, address, addressNumber, addressStreet, addressCity, addressCountry, additionalFields; + let unparsed, + address, + addressNumber, + addressStreet, + addressCity, + addressCountry, + additionalFields; unparsed = this.getNodeParameter('unparsed', item) as boolean; if (unparsed) { address = this.getNodeParameter('address', item) as string; @@ -148,10 +164,15 @@ export class Onfleet { additionalFields = this.getNodeParameter('additionalFields', item) as IDataObject; return formatAddress( - unparsed, address, addressNumber, addressStreet, addressCity, addressCountry, additionalFields, + unparsed, + address, + addressNumber, + addressStreet, + addressCity, + addressCountry, + additionalFields, ) as OnfleetDestination; } - } return null; } @@ -162,7 +183,11 @@ export class Onfleet { * @param operation Current administrator operation * @returns {OnfleetAdmins} Administrator information */ - static getAdminFields(this: IExecuteFunctions, item: number, operation: string): OnfleetAdmins | null { + static getAdminFields( + this: IExecuteFunctions, + item: number, + operation: string, + ): OnfleetAdmins | null { if (operation === 'create') { /* -------------------------------------------------------------------------- */ /* Get fields for create admin */ @@ -198,12 +223,21 @@ export class Onfleet { * @param operation Current hub operation * @returns {OnfleetHubs|null} Hub information */ - static getHubFields(this: IExecuteFunctions, item: number, operation: string): OnfleetHubs | null { + static getHubFields( + this: IExecuteFunctions, + item: number, + operation: string, + ): OnfleetHubs | null { if (operation === 'create') { /* -------------------------------------------------------------------------- */ /* Get fields for create hub */ /* -------------------------------------------------------------------------- */ - const destination = Onfleet.getDestinationFields.call(this, item, operation, true) as OnfleetDestination; + const destination = Onfleet.getDestinationFields.call( + this, + item, + operation, + true, + ) as OnfleetDestination; const name = this.getNodeParameter('name', item) as string; const additionalFields = this.getNodeParameter('additionalFields', item) as IDataObject; @@ -212,13 +246,14 @@ export class Onfleet { // Adding additional fields Object.assign(hubData, additionalFields); - return hubData; } else if (operation === 'update') { /* -------------------------------------------------------------------------- */ /* Get fields for update hub */ /* -------------------------------------------------------------------------- */ - const destination = Onfleet.getDestinationFields.call(this, item, operation, { parent: 'updateFields' }) as OnfleetDestination; + const destination = Onfleet.getDestinationFields.call(this, item, operation, { + parent: 'updateFields', + }) as OnfleetDestination; const hubData: OnfleetHubs = { ...destination }; // Adding additional fields @@ -240,7 +275,11 @@ export class Onfleet { * @param operation Current worker operation * @returns {OnfleetWorker|OnfleetWorkerFilter|OnfleetWorkerSchedule|null} Worker information */ - static getWorkerFields(this: IExecuteFunctions, item: number, operation: string): OnfleetWorker | OnfleetWorkerFilter | OnfleetWorkerSchedule | null { + static getWorkerFields( + this: IExecuteFunctions, + item: number, + operation: string, + ): OnfleetWorker | OnfleetWorkerFilter | OnfleetWorkerSchedule | null { if (operation === 'create') { /* -------------------------------------------------------------------------- */ /* Get fields for create worker */ @@ -289,7 +328,6 @@ export class Onfleet { } Object.assign(workerFilter, options); return workerFilter; - } else if (operation === 'getAll') { /* -------------------------------------------------------------------------- */ /* Get fields for get and getAll workers */ @@ -320,7 +358,7 @@ export class Onfleet { /* Set a worker schedule */ /* -------------------------------------------------------------------------- */ const { scheduleProperties } = this.getNodeParameter('schedule', item) as IDataObject; - const entries = (scheduleProperties as IDataObject[] || []).map(entry => { + const entries = ((scheduleProperties as IDataObject[]) || []).map((entry) => { const { timezone, date, shifts } = entry as IDataObject; const { shiftsProperties } = shifts as IDataObject; return { @@ -343,7 +381,11 @@ export class Onfleet { * @param operation Current webhooks operation * @returns {OnfleetWebhook} Webhooks information */ - static getWebhookFields(this: IExecuteFunctions, item: number, operation: string): OnfleetWebhook | null { + static getWebhookFields( + this: IExecuteFunctions, + item: number, + operation: string, + ): OnfleetWebhook | null { if (operation === 'create') { /* -------------------------------------------------------------------------- */ /* Get fields for create webhook */ @@ -370,7 +412,9 @@ export class Onfleet { * @returns */ static formatRecipient( - name: string, phone: string, additionalFields: IDataObject, + name: string, + phone: string, + additionalFields: IDataObject, options: IDataObject = {}, ): OnfleetRecipient { const recipient: OnfleetRecipient = { name, phone }; @@ -383,7 +427,8 @@ export class Onfleet { recipient.skipSMSNotifications = additionalFields.recipientSkipSMSNotifications as boolean; } if ('recipientSkipPhoneNumberValidation' in options) { - recipient.skipPhoneNumberValidation = options.recipientSkipPhoneNumberValidation as boolean || false; + recipient.skipPhoneNumberValidation = + (options.recipientSkipPhoneNumberValidation as boolean) || false; } return recipient; @@ -398,20 +443,30 @@ export class Onfleet { */ static getRecipientFields( this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - item: number, operation: string, shared = false, + item: number, + operation: string, + shared = false, ): OnfleetRecipient | OnfleetRecipient[] | null { if (operation === 'create') { /* -------------------------------------------------------------------------- */ /* Get fields to create recipient */ /* -------------------------------------------------------------------------- */ if (shared) { - const { recipient: recipientData = {} } = this.getNodeParameter('additionalFields', item, {}) as IDataObject; + const { recipient: recipientData = {} } = this.getNodeParameter( + 'additionalFields', + item, + {}, + ) as IDataObject; const options = this.getNodeParameter('options', item, {}) as IDataObject; const { recipientProperties: recipient = {} } = recipientData as IDataObject; if (!recipient || Object.keys(recipient).length === 0) { return null; } - const { recipientName: name, recipientPhone: phone, ...additionalFields } = recipient as IDataObject; + const { + recipientName: name, + recipientPhone: phone, + ...additionalFields + } = recipient as IDataObject; return Onfleet.formatRecipient( name as string, phone as string, @@ -430,7 +485,9 @@ export class Onfleet { /* Get fields to update recipient */ /* -------------------------------------------------------------------------- */ const { - recipientName: name = '', recipientPhone: phone = '', ...additionalFields + recipientName: name = '', + recipientPhone: phone = '', + ...additionalFields } = this.getNodeParameter('updateFields', item) as IDataObject; const recipientData: OnfleetRecipient = {}; @@ -454,18 +511,36 @@ export class Onfleet { * @param operation Current task operation * @returns {OnfleetListTaskFilters | OnfleetTask } Task information */ - static getTaskFields(this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, - item: number, operation: string): - OnfleetListTaskFilters | OnfleetTask | OnfleetCloneTask | OnfleetTaskComplete | OnfleetTaskUpdate | null { + static getTaskFields( + this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + item: number, + operation: string, + ): + | OnfleetListTaskFilters + | OnfleetTask + | OnfleetCloneTask + | OnfleetTaskComplete + | OnfleetTaskUpdate + | null { if (operation === 'create') { /* -------------------------------------------------------------------------- */ /* Get fields to create a task */ /* -------------------------------------------------------------------------- */ const additionalFields = this.getNodeParameter('additionalFields', item) as IDataObject; - const destination = Onfleet.getDestinationFields.call(this, item, operation, true) as OnfleetDestination; + const destination = Onfleet.getDestinationFields.call( + this, + item, + operation, + true, + ) as OnfleetDestination; // Adding recipients information - const recipient = Onfleet.getRecipientFields.call(this, item, operation, true) as OnfleetRecipient; + const recipient = Onfleet.getRecipientFields.call( + this, + item, + operation, + true, + ) as OnfleetRecipient; const taskData: OnfleetTask = { destination, recipients: [recipient] }; const { completeAfter = null, completeBefore = null, ...extraFields } = additionalFields; @@ -497,14 +572,21 @@ export class Onfleet { const overrideFields = this.getNodeParameter('overrideFields', item) as IDataObject; const options: OnfleetCloneTaskOptions = {}; - if (overrideFields.includeMetadata) options.includeMetadata = overrideFields.includeMetadata as boolean; - if (overrideFields.includeBarcodes) options.includeBarcodes = overrideFields.includeBarcodes as boolean; - if (overrideFields.includeDependencies) options.includeDependencies = overrideFields.includeDependencies as boolean; + if (overrideFields.includeMetadata) { + options.includeMetadata = overrideFields.includeMetadata as boolean; + } + + if (overrideFields.includeBarcodes) { + options.includeBarcodes = overrideFields.includeBarcodes as boolean; + } + + if (overrideFields.includeDependencies) { + options.includeDependencies = overrideFields.includeDependencies as boolean; + } // Adding overrides data - const { - notes, pickupTask, serviceTime, completeAfter, completeBefore, - } = overrideFields as IDataObject; + const { notes, pickupTask, serviceTime, completeAfter, completeBefore } = + overrideFields as IDataObject; const overridesData = {} as OnfleetCloneOverrideTaskOptions; if (notes) overridesData.notes = notes as string; @@ -527,7 +609,7 @@ export class Onfleet { const allStates = '0,1,2,3'; - const twoWeeksInMilisecods = () => (604800 * 1000); + const twoWeeksInMilisecods = () => 604800 * 1000; // Adding extra fields to search tasks if (filters.from) { @@ -553,7 +635,9 @@ export class Onfleet { const additionalFields = this.getNodeParameter('additionalFields', item) as IDataObject; const success = this.getNodeParameter('success', item) as boolean; const taskData: OnfleetTaskComplete = { completionDetails: { success } }; - if (additionalFields.notes) taskData.completionDetails.notes = additionalFields.notes as string; + if (additionalFields.notes) { + taskData.completionDetails.notes = additionalFields.notes as string; + } return taskData; } return null; @@ -565,7 +649,11 @@ export class Onfleet { * @param operation Current team operation * @returns {OnfleetTeams} Team information */ - static getTeamFields(this: IExecuteFunctions, item: number, operation: string): OnfleetTeams | OnfleetWorkerEstimates | OnfleetTeamAutoDispatch | null { + static getTeamFields( + this: IExecuteFunctions, + item: number, + operation: string, + ): OnfleetTeams | OnfleetWorkerEstimates | OnfleetTeamAutoDispatch | null { if (operation === 'create') { /* -------------------------------------------------------------------------- */ /* Get fields to create a team */ @@ -598,30 +686,41 @@ export class Onfleet { /* -------------------------------------------------------------------------- */ /* Get driver time estimates for tasks that haven't been created yet */ /* -------------------------------------------------------------------------- */ - const { dropOff = {}, pickUp = {}, ...additionalFields } = this.getNodeParameter('filters', item) as IDataObject; + const { + dropOff = {}, + pickUp = {}, + ...additionalFields + } = this.getNodeParameter('filters', item) as IDataObject; const { dropOffProperties = {} } = dropOff as IDataObject; const { pickUpProperties = {} } = pickUp as IDataObject; const hasPickUp = pickUp && Object.keys(pickUpProperties as IDataObject).length > 0; - const hasDropOff = dropOffProperties && Object.keys(dropOffProperties as IDataObject).length > 0; + const hasDropOff = + dropOffProperties && Object.keys(dropOffProperties as IDataObject).length > 0; if (!hasPickUp && !hasDropOff) { throw new NodeOperationError( - this.getNode(), 'At least 1 of Drop-Off location or Pick-Up location must be selected', + this.getNode(), + 'At least 1 of Drop-Off location or Pick-Up location must be selected', ); } const workerTimeEstimates = {} as OnfleetWorkerEstimates; if (hasPickUp) { const { - pickupLongitude: longitude, pickupLatitude: latitude, pickupTime, + pickupLongitude: longitude, + pickupLatitude: latitude, + pickupTime, } = pickUpProperties as IDataObject; workerTimeEstimates.pickupLocation = `${longitude},${latitude}`; if (pickupTime) { - workerTimeEstimates.pickupTime = moment(new Date(pickupTime as Date)).local().unix(); + workerTimeEstimates.pickupTime = moment(new Date(pickupTime as Date)) + .local() + .unix(); } } if (hasDropOff) { - const { dropOffLongitude: longitude, dropOffLatitude: latitude } = dropOffProperties as IDataObject; + const { dropOffLongitude: longitude, dropOffLatitude: latitude } = + dropOffProperties as IDataObject; workerTimeEstimates.dropoffLocation = `${longitude},${latitude}`; } @@ -633,33 +732,52 @@ export class Onfleet { /* -------------------------------------------------------------------------- */ const teamAutoDispatch = {} as OnfleetTeamAutoDispatch; const { - scheduleTimeWindow = {}, taskTimeWindow = {}, endingRoute = {}, ...additionalFields + scheduleTimeWindow = {}, + taskTimeWindow = {}, + endingRoute = {}, + ...additionalFields } = this.getNodeParameter('additionalFields', item) as IDataObject; const { endingRouteProperties = {} } = endingRoute as IDataObject; const { scheduleTimeWindowProperties = {} } = scheduleTimeWindow as IDataObject; const { taskTimeWindowProperties = {} } = taskTimeWindow as IDataObject; - if (scheduleTimeWindowProperties && Object.keys((scheduleTimeWindowProperties as IDataObject)).length > 0) { + if ( + scheduleTimeWindowProperties && + Object.keys(scheduleTimeWindowProperties as IDataObject).length > 0 + ) { const { startTime, endTime } = scheduleTimeWindowProperties as IDataObject; teamAutoDispatch.scheduleTimeWindow = [ - moment(new Date(startTime as Date)).local().unix(), moment(new Date(endTime as Date)).local().unix(), + moment(new Date(startTime as Date)) + .local() + .unix(), + moment(new Date(endTime as Date)) + .local() + .unix(), ]; } - if (endingRouteProperties && Object.keys((endingRouteProperties as IDataObject)).length > 0) { + if (endingRouteProperties && Object.keys(endingRouteProperties as IDataObject).length > 0) { const { routeEnd, hub } = endingRouteProperties as IDataObject; - teamAutoDispatch.routeEnd = ({ - 'anywhere': null, - 'hub': `hub://${hub}`, - 'team_hub': 'teams://DEFAULT', - 'worker_routing_address': 'workers://ROUTING_ADDRESS', - })[routeEnd as string] as string; + teamAutoDispatch.routeEnd = { + anywhere: null, + hub: `hub://${hub}`, + team_hub: 'teams://DEFAULT', + worker_routing_address: 'workers://ROUTING_ADDRESS', + }[routeEnd as string] as string; } - if (taskTimeWindowProperties && Object.keys((taskTimeWindowProperties as IDataObject)).length > 0) { + if ( + taskTimeWindowProperties && + Object.keys(taskTimeWindowProperties as IDataObject).length > 0 + ) { const { startTime, endTime } = taskTimeWindowProperties as IDataObject; teamAutoDispatch.taskTimeWindow = [ - moment(new Date(startTime as Date)).local().unix(), moment(new Date(endTime as Date)).local().unix(), + moment(new Date(startTime as Date)) + .local() + .unix(), + moment(new Date(endTime as Date)) + .local() + .unix(), ]; } @@ -687,7 +805,9 @@ export class Onfleet { /* Create multiple tasks by batch */ /* -------------------------------------------------------------------------- */ const path = `${resource}/batch`; - const tasksData = { tasks: items.map((_item, index) => Onfleet.getTaskFields.call(this, index, operation)) }; + const tasksData = { + tasks: items.map((_item, index) => Onfleet.getTaskFields.call(this, index, operation)), + }; //@ts-ignore const { tasks: tasksCreated } = await onfleetApiRequest.call(this, 'POST', path, tasksData); return tasksCreated; @@ -702,7 +822,9 @@ export class Onfleet { /* Create a new task */ /* -------------------------------------------------------------------------- */ const taskData = Onfleet.getTaskFields.call(this, index, operation); - if (!taskData) { continue; } + if (!taskData) { + continue; + } responseData.push(await onfleetApiRequest.call(this, 'POST', resource, taskData)); } else if (operation === 'get') { /* -------------------------------------------------------------------------- */ @@ -710,7 +832,7 @@ export class Onfleet { /* -------------------------------------------------------------------------- */ const id = this.getNodeParameter('id', index) as string; const shortId = String(id).length <= 8; - const path = `${resource}${(shortId ? '/shortId' : '')}/${id}`; + const path = `${resource}${shortId ? '/shortId' : ''}/${id}`; responseData.push(await onfleetApiRequest.call(this, 'GET', path)); } else if (operation === 'clone') { /* -------------------------------------------------------------------------- */ @@ -719,7 +841,9 @@ export class Onfleet { const id = this.getNodeParameter('id', index) as string; // tslint:disable-next-line: no-any const taskData = Onfleet.getTaskFields.call(this, index, operation) as any; - if (!taskData) { continue; } + if (!taskData) { + continue; + } const path = `${resource}/${id}/clone`; responseData.push(await onfleetApiRequest.call(this, 'POST', path, taskData)); } else if (operation === 'delete') { @@ -754,7 +878,9 @@ export class Onfleet { /* -------------------------------------------------------------------------- */ const id = this.getNodeParameter('id', index) as string; const taskData = Onfleet.getTaskFields.call(this, index, operation); - if (!taskData) { continue; } + if (!taskData) { + continue; + } const path = `${resource}/${id}/complete`; await onfleetApiRequest.call(this, 'POST', path, taskData); responseData.push({ success: true }); @@ -765,7 +891,9 @@ export class Onfleet { const id = this.getNodeParameter('id', 0) as string; const path = `${resource}/${id}`; const taskData = Onfleet.getTaskFields.call(this, index, operation); - if (!taskData) { continue; } + if (!taskData) { + continue; + } responseData.push(await onfleetApiRequest.call(this, 'PUT', path, taskData)); } } catch (error) { @@ -802,7 +930,9 @@ export class Onfleet { /* Create destination */ /* -------------------------------------------------------------------------- */ const destinationData = Onfleet.getDestinationFields.call(this, index, operation); - if (!destinationData) { continue; } + if (!destinationData) { + continue; + } responseData.push(await onfleetApiRequest.call(this, 'POST', resource, destinationData)); } else if (operation === 'get') { /* -------------------------------------------------------------------------- */ @@ -874,7 +1004,8 @@ export class Onfleet { * @param items Number of items to process by the node * @returns Recipient information */ - static async executeRecipientOperations(this: IExecuteFunctions, + static async executeRecipientOperations( + this: IExecuteFunctions, resource: string, operation: string, items: INodeExecutionData[], @@ -888,14 +1019,18 @@ export class Onfleet { /* Create a new recipient */ /* -------------------------------------------------------------------------- */ const recipientData = Onfleet.getRecipientFields.call(this, index, operation); - if (!recipientData) { continue; } + if (!recipientData) { + continue; + } responseData.push(await onfleetApiRequest.call(this, 'POST', resource, recipientData)); } else if (operation === 'update') { /* -------------------------------------------------------------------------- */ /* Update a recipient */ /* -------------------------------------------------------------------------- */ const recipientData = Onfleet.getRecipientFields.call(this, index, operation); - if (!recipientData) { continue; } + if (!recipientData) { + continue; + } const id = this.getNodeParameter('id', index) as string; const path = `${resource}/${id}`; responseData.push(await onfleetApiRequest.call(this, 'PUT', path, recipientData)); @@ -905,7 +1040,7 @@ export class Onfleet { /* -------------------------------------------------------------------------- */ const lookupBy = this.getNodeParameter('getBy', index) as string; const lookupByValue = this.getNodeParameter(lookupBy, index) as string; - const path = `${resource}${lookupBy === 'id' ? '' : ('/' + lookupBy)}/${lookupByValue}`; + const path = `${resource}${lookupBy === 'id' ? '' : '/' + lookupBy}/${lookupByValue}`; responseData.push(await onfleetApiRequest.call(this, 'GET', path)); } } catch (error) { @@ -1071,11 +1206,19 @@ export class Onfleet { const filters = this.getNodeParameter('filters', index) as IDataObject; const path = `${resource}/location`; workers = await onfleetApiRequest.call( - this, 'GET', path, {}, { longitude, latitude, ...filters }, + this, + 'GET', + path, + {}, + { longitude, latitude, ...filters }, ); workers = workers.workers; } else { - const workerFilters = Onfleet.getWorkerFields.call(this, 0, operation) as OnfleetWorkerFilter; + const workerFilters = Onfleet.getWorkerFields.call( + this, + 0, + operation, + ) as OnfleetWorkerFilter; workers = await onfleetApiRequest.call(this, 'GET', resource, {}, workerFilters); } @@ -1085,13 +1228,16 @@ export class Onfleet { } responseData.push(...workers); - } else if (operation === 'get') { /* -------------------------------------------------------------------------- */ /* Get a worker */ /* -------------------------------------------------------------------------- */ const id = this.getNodeParameter('id', index) as string; - const workerFilters = Onfleet.getWorkerFields.call(this, index, operation) as OnfleetWorkerFilter; + const workerFilters = Onfleet.getWorkerFields.call( + this, + index, + operation, + ) as OnfleetWorkerFilter; const path = `${resource}/${id}`; responseData.push(await onfleetApiRequest.call(this, 'GET', path, {}, workerFilters)); @@ -1129,7 +1275,11 @@ export class Onfleet { /* Set a worker schedule */ /* -------------------------------------------------------------------------- */ const id = this.getNodeParameter('id', index) as string; - const workerSchedule = Onfleet.getWorkerFields.call(this, index, operation) as OnfleetWorkerSchedule; + const workerSchedule = Onfleet.getWorkerFields.call( + this, + index, + operation, + ) as OnfleetWorkerSchedule; const path = `${resource}/${id}/schedule`; responseData.push(await onfleetApiRequest.call(this, 'POST', path, workerSchedule)); } @@ -1165,7 +1315,7 @@ export class Onfleet { /* -------------------------------------------------------------------------- */ /* Get all webhooks */ /* -------------------------------------------------------------------------- */ - responseData.push(...await onfleetApiRequest.call(this, 'GET', resource)); + responseData.push(...(await onfleetApiRequest.call(this, 'GET', resource))); } else if (operation === 'create') { /* -------------------------------------------------------------------------- */ /* Create a new webhook */ @@ -1238,9 +1388,7 @@ export class Onfleet { } const path = `${resource}/${containerType}/${containerId}`; - responseData.push( - await onfleetApiRequest.call(this, 'PUT', path, { tasks, ...options }), - ); + responseData.push(await onfleetApiRequest.call(this, 'PUT', path, { tasks, ...options })); } } catch (error) { if (this.continueOnFail()) { @@ -1317,15 +1465,25 @@ export class Onfleet { /* Get driver time estimates for tasks that haven't been created yet */ /* -------------------------------------------------------------------------- */ const id = this.getNodeParameter('id', index) as string; - const workerTimeEstimates = Onfleet.getTeamFields.call(this, index, operation) as OnfleetWorkerSchedule; + const workerTimeEstimates = Onfleet.getTeamFields.call( + this, + index, + operation, + ) as OnfleetWorkerSchedule; const path = `${resource}/${id}/estimate`; - responseData.push(await onfleetApiRequest.call(this, 'GET', path, {}, workerTimeEstimates)); + responseData.push( + await onfleetApiRequest.call(this, 'GET', path, {}, workerTimeEstimates), + ); } else if (operation === 'autoDispatch') { /* -------------------------------------------------------------------------- */ /* Dynamically dispatching tasks on the fly */ /* -------------------------------------------------------------------------- */ const id = this.getNodeParameter('id', index) as string; - const teamAutoDispatch = Onfleet.getTeamFields.call(this, index, operation) as OnfleetWorkerSchedule; + const teamAutoDispatch = Onfleet.getTeamFields.call( + this, + index, + operation, + ) as OnfleetWorkerSchedule; const path = `${resource}/${id}/dispatch`; responseData.push(await onfleetApiRequest.call(this, 'POST', path, teamAutoDispatch)); } diff --git a/packages/nodes-base/nodes/Onfleet/OnfleetTrigger.node.ts b/packages/nodes-base/nodes/Onfleet/OnfleetTrigger.node.ts index e5c143626c..31867aa7f3 100644 --- a/packages/nodes-base/nodes/Onfleet/OnfleetTrigger.node.ts +++ b/packages/nodes-base/nodes/Onfleet/OnfleetTrigger.node.ts @@ -4,26 +4,15 @@ import { INodeTypeDescription, IWebhookResponseData, NodeApiError, - NodeOperationError + NodeOperationError, } from 'n8n-workflow'; -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import { - eventDisplay, - eventNameField, -} from './descriptions/OnfleetWebhookDescription'; +import { eventDisplay, eventNameField } from './descriptions/OnfleetWebhookDescription'; -import { - onfleetApiRequest, -} from './GenericFunctions'; - -import { - webhookMapping, -} from './WebhookMapping'; +import { onfleetApiRequest } from './GenericFunctions'; +import { webhookMapping } from './WebhookMapping'; export class OnfleetTrigger implements INodeType { description: INodeTypeDescription = { @@ -61,10 +50,7 @@ export class OnfleetTrigger implements INodeType { path: 'webhook', }, ], - properties: [ - eventDisplay, - eventNameField, - ], + properties: [eventDisplay, eventNameField], }; // @ts-ignore (because of request) @@ -94,7 +80,10 @@ export class OnfleetTrigger implements INodeType { const webhookUrl = this.getNodeWebhookUrl('default') as string; if (webhookUrl.includes('//localhost')) { - throw new NodeOperationError(this.getNode(), 'The Webhook can not work on "localhost". Please, either setup n8n on a custom domain or start with "--tunnel"!'); + throw new NodeOperationError( + this.getNode(), + 'The Webhook can not work on "localhost". Please, either setup n8n on a custom domain or start with "--tunnel"!', + ); } // Webhook name according to the field let newWebhookName = `n8n-webhook:${webhookUrl}`; @@ -114,15 +103,19 @@ export class OnfleetTrigger implements INodeType { const webhook = await onfleetApiRequest.call(this, 'POST', path, body); if (webhook.id === undefined) { - throw new NodeApiError(this.getNode(), webhook, { message: 'Onfleet webhook creation response did not contain the expected data' }); + throw new NodeApiError(this.getNode(), webhook, { + message: 'Onfleet webhook creation response did not contain the expected data', + }); } webhookData.id = webhook.id as string; - } catch (error) { const { httpCode = '' } = error as { httpCode: string }; if (httpCode === '422') { - throw new NodeOperationError(this.getNode(), 'A webhook with the identical URL probably exists already. Please delete it manually in Onfleet!'); + throw new NodeOperationError( + this.getNode(), + 'A webhook with the identical URL probably exists already. Please delete it manually in Onfleet!', + ); } throw error; } @@ -156,9 +149,7 @@ export class OnfleetTrigger implements INodeType { const returnData: IDataObject = this.getBodyData(); return { - workflowData: [ - this.helpers.returnJsonArray(returnData), - ], + workflowData: [this.helpers.returnJsonArray(returnData)], }; } } diff --git a/packages/nodes-base/nodes/Onfleet/WebhookMapping.ts b/packages/nodes-base/nodes/Onfleet/WebhookMapping.ts index e785a4c092..e7c3492e34 100644 --- a/packages/nodes-base/nodes/Onfleet/WebhookMapping.ts +++ b/packages/nodes-base/nodes/Onfleet/WebhookMapping.ts @@ -1,6 +1,4 @@ -import { - OnfleetWebhooksMapping, -} from './interfaces'; +import { OnfleetWebhooksMapping } from './interfaces'; export const webhookMapping: OnfleetWebhooksMapping = { taskStarted: { diff --git a/packages/nodes-base/nodes/Onfleet/descriptions/AdministratorDescription.ts b/packages/nodes-base/nodes/Onfleet/descriptions/AdministratorDescription.ts index c8a65de28a..bdc99ea92b 100644 --- a/packages/nodes-base/nodes/Onfleet/descriptions/AdministratorDescription.ts +++ b/packages/nodes-base/nodes/Onfleet/descriptions/AdministratorDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const adminOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const adminOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'admin', - ], + resource: ['admin'], }, }, options: [ @@ -50,7 +46,7 @@ const adminNameField = { name: 'name', type: 'string', default: '', - description: 'The administrator\'s name', + description: "The administrator's name", } as INodeProperties; const adminEmailField = { @@ -59,7 +55,7 @@ const adminEmailField = { type: 'string', placeholder: 'name@email.com', default: '', - description: 'The administrator\'s email address', + description: "The administrator's email address", } as INodeProperties; const adminPhoneField = { @@ -67,7 +63,7 @@ const adminPhoneField = { name: 'phone', type: 'string', default: '', - description: 'The administrator\'s phone number', + description: "The administrator's phone number", } as INodeProperties; const adminReadOnlyField = { @@ -85,15 +81,10 @@ export const adminFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'admin', - ], + resource: ['admin'], }, hide: { - operation: [ - 'create', - 'getAll', - ], + operation: ['create', 'getAll'], }, }, default: '', @@ -106,12 +97,8 @@ export const adminFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'admin', - ], - operation: [ - 'getAll', - ], + resource: ['admin'], + operation: ['getAll'], }, }, default: false, @@ -123,15 +110,9 @@ export const adminFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'admin', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['admin'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -144,12 +125,8 @@ export const adminFields: INodeProperties[] = [ { displayOptions: { show: { - resource: [ - 'admin', - ], - operation: [ - 'create', - ], + resource: ['admin'], + operation: ['create'], }, }, required: true, @@ -158,12 +135,8 @@ export const adminFields: INodeProperties[] = [ { displayOptions: { show: { - resource: [ - 'admin', - ], - operation: [ - 'create', - ], + resource: ['admin'], + operation: ['create'], }, }, required: true, @@ -177,18 +150,11 @@ export const adminFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'admin', - ], - operation: [ - 'create', - ], + resource: ['admin'], + operation: ['create'], }, }, - options: [ - adminPhoneField, - adminReadOnlyField, - ], + options: [adminPhoneField, adminReadOnlyField], }, { displayName: 'Update Fields', @@ -198,18 +164,10 @@ export const adminFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'admin', - ], - operation: [ - 'update', - ], + resource: ['admin'], + operation: ['update'], }, }, - options: [ - adminNameField, - adminPhoneField, - adminReadOnlyField, - ], + options: [adminNameField, adminPhoneField, adminReadOnlyField], }, ]; diff --git a/packages/nodes-base/nodes/Onfleet/descriptions/ContainerDescription.ts b/packages/nodes-base/nodes/Onfleet/descriptions/ContainerDescription.ts index 8a212e14bb..f976cd66db 100644 --- a/packages/nodes-base/nodes/Onfleet/descriptions/ContainerDescription.ts +++ b/packages/nodes-base/nodes/Onfleet/descriptions/ContainerDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const containerOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const containerOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'container', - ], + resource: ['container'], }, }, options: [ @@ -31,7 +27,7 @@ export const containerOperations: INodeProperties[] = [ { name: 'Update Tasks', value: 'updateTask', - description: 'Fully replace a container\'s tasks', + description: "Fully replace a container's tasks", action: 'Update tasks', }, ], @@ -106,7 +102,7 @@ const tasksField = { multipleValueButtonText: 'Add Task', }, default: [], - description: 'Task\'s ID that are going to be used', + description: "Task's ID that are going to be used", } as INodeProperties; const considerDependenciesField = { @@ -114,7 +110,8 @@ const considerDependenciesField = { name: 'considerDependencies', type: 'boolean', default: false, - description: 'Whether to include the target task\'s dependency family (parent and child tasks) in the resulting assignment operation', + description: + "Whether to include the target task's dependency family (parent and child tasks) in the resulting assignment operation", } as INodeProperties; export const containerFields: INodeProperties[] = [ @@ -122,13 +119,8 @@ export const containerFields: INodeProperties[] = [ ...containerTypeField, displayOptions: { show: { - resource: [ - 'container', - ], - operation: [ - 'get', - 'addTask', - ], + resource: ['container'], + operation: ['get', 'addTask'], }, }, required: true, @@ -137,14 +129,8 @@ export const containerFields: INodeProperties[] = [ ...containerIdField, displayOptions: { show: { - resource: [ - 'container', - ], - operation: [ - 'get', - 'addTask', - 'updateTask', - ], + resource: ['container'], + operation: ['get', 'addTask', 'updateTask'], }, }, required: true, @@ -153,12 +139,8 @@ export const containerFields: INodeProperties[] = [ ...insertTypeField, displayOptions: { show: { - resource: [ - 'container', - ], - operation: [ - 'addTask', - ], + resource: ['container'], + operation: ['addTask'], }, }, required: true, @@ -167,15 +149,9 @@ export const containerFields: INodeProperties[] = [ ...indexField, displayOptions: { show: { - resource: [ - 'container', - ], - operation: [ - 'addTask', - ], - type: [ - 1, - ], + resource: ['container'], + operation: ['addTask'], + type: [1], }, }, required: true, @@ -184,13 +160,8 @@ export const containerFields: INodeProperties[] = [ ...tasksField, displayOptions: { show: { - resource: [ - 'container', - ], - operation: [ - 'addTask', - 'updateTask', - ], + resource: ['container'], + operation: ['addTask', 'updateTask'], }, }, required: true, @@ -203,13 +174,8 @@ export const containerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'container', - ], - operation: [ - 'addTask', - 'updateTask', - ], + resource: ['container'], + operation: ['addTask', 'updateTask'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Onfleet/descriptions/DestinationDescription.ts b/packages/nodes-base/nodes/Onfleet/descriptions/DestinationDescription.ts index 1fa3e89ce9..45ed3a6bc2 100644 --- a/packages/nodes-base/nodes/Onfleet/descriptions/DestinationDescription.ts +++ b/packages/nodes-base/nodes/Onfleet/descriptions/DestinationDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const destinationOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const destinationOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'destination', - ], + resource: ['destination'], }, }, options: [ @@ -28,7 +24,6 @@ export const destinationOperations: INodeProperties[] = [ description: 'Get a specific destination', action: 'Get a destination', }, - ], default: 'get', }, @@ -46,7 +41,7 @@ const unparsedAddressField = { displayName: 'Destination Address', name: 'address', type: 'string', - description: 'The destination\'s street address details', + description: "The destination's street address details", default: '', } as INodeProperties; @@ -141,9 +136,7 @@ export const destinationExternalField = { ...unparsedAddressField, displayOptions: { show: { - unparsed: [ - true, - ], + unparsed: [true], }, }, required: true, @@ -152,9 +145,7 @@ export const destinationExternalField = { ...unparsedAddressNumberField, displayOptions: { show: { - unparsed: [ - false, - ], + unparsed: [false], }, }, required: true, @@ -163,9 +154,7 @@ export const destinationExternalField = { ...unparsedAddressStreetField, displayOptions: { show: { - unparsed: [ - false, - ], + unparsed: [false], }, }, required: true, @@ -174,9 +163,7 @@ export const destinationExternalField = { ...unparsedAddressCityField, displayOptions: { show: { - unparsed: [ - false, - ], + unparsed: [false], }, }, required: true, @@ -185,9 +172,7 @@ export const destinationExternalField = { ...unparsedAddressStateField, displayOptions: { show: { - unparsed: [ - false, - ], + unparsed: [false], }, }, required: true, @@ -196,9 +181,7 @@ export const destinationExternalField = { ...unparsedAddressCountryField, displayOptions: { show: { - unparsed: [ - false, - ], + unparsed: [false], }, }, required: true, @@ -206,9 +189,7 @@ export const destinationExternalField = { { displayOptions: { show: { - unparsed: [ - false, - ], + unparsed: [false], }, }, ...addressPostalCodeField, @@ -238,14 +219,10 @@ export const destinationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'destination', - ], + resource: ['destination'], }, hide: { - operation: [ - 'create', - ], + operation: ['create'], }, }, default: '', @@ -256,12 +233,8 @@ export const destinationFields: INodeProperties[] = [ ...unparsedField, displayOptions: { show: { - resource: [ - 'destination', - ], - operation: [ - 'create', - ], + resource: ['destination'], + operation: ['create'], }, }, required: true, @@ -270,15 +243,9 @@ export const destinationFields: INodeProperties[] = [ ...unparsedAddressField, displayOptions: { show: { - resource: [ - 'destination', - ], - operation: [ - 'create', - ], - unparsed: [ - true, - ], + resource: ['destination'], + operation: ['create'], + unparsed: [true], }, }, required: true, @@ -287,15 +254,9 @@ export const destinationFields: INodeProperties[] = [ ...unparsedAddressNumberField, displayOptions: { show: { - resource: [ - 'destination', - ], - operation: [ - 'create', - ], - unparsed: [ - false, - ], + resource: ['destination'], + operation: ['create'], + unparsed: [false], }, }, required: true, @@ -304,15 +265,9 @@ export const destinationFields: INodeProperties[] = [ ...unparsedAddressStreetField, displayOptions: { show: { - resource: [ - 'destination', - ], - operation: [ - 'create', - ], - unparsed: [ - false, - ], + resource: ['destination'], + operation: ['create'], + unparsed: [false], }, }, required: true, @@ -321,15 +276,9 @@ export const destinationFields: INodeProperties[] = [ ...unparsedAddressCityField, displayOptions: { show: { - resource: [ - 'destination', - ], - operation: [ - 'create', - ], - unparsed: [ - false, - ], + resource: ['destination'], + operation: ['create'], + unparsed: [false], }, }, required: true, @@ -338,15 +287,9 @@ export const destinationFields: INodeProperties[] = [ ...unparsedAddressCountryField, displayOptions: { show: { - resource: [ - 'destination', - ], - operation: [ - 'create', - ], - unparsed: [ - false, - ], + resource: ['destination'], + operation: ['create'], + unparsed: [false], }, }, required: true, @@ -359,22 +302,12 @@ export const destinationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'destination', - ], - operation: [ - 'create', - ], - unparsed: [ - true, - ], + resource: ['destination'], + operation: ['create'], + unparsed: [true], }, }, - options: [ - addressApartmentField, - addressNameField, - addressNoteField, - ], + options: [addressApartmentField, addressNameField, addressNoteField], }, { displayName: 'Additional Fields', @@ -384,22 +317,11 @@ export const destinationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'destination', - ], - operation: [ - 'create', - ], - unparsed: [ - false, - ], + resource: ['destination'], + operation: ['create'], + unparsed: [false], }, }, - options: [ - addressApartmentField, - addressNameField, - addressNoteField, - addressPostalCodeField, - ], + options: [addressApartmentField, addressNameField, addressNoteField, addressPostalCodeField], }, ]; diff --git a/packages/nodes-base/nodes/Onfleet/descriptions/HubDescription.ts b/packages/nodes-base/nodes/Onfleet/descriptions/HubDescription.ts index 363284008a..5f9205e0dc 100644 --- a/packages/nodes-base/nodes/Onfleet/descriptions/HubDescription.ts +++ b/packages/nodes-base/nodes/Onfleet/descriptions/HubDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - destinationExternalField, -} from './DestinationDescription'; +import { destinationExternalField } from './DestinationDescription'; export const hubOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const hubOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'hub', - ], + resource: ['hub'], }, }, options: [ @@ -59,7 +53,8 @@ const teamsField = { loadOptionsMethod: 'getTeams', }, default: [], - description: 'These are the teams that this Hub will be assigned to. Choose from the list, or specify IDs using an expression.', + description: + 'These are the teams that this Hub will be assigned to. Choose from the list, or specify IDs using an expression.', } as INodeProperties; export const hubFields: INodeProperties[] = [ @@ -69,12 +64,8 @@ export const hubFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'hub', - ], - operation: [ - 'update', - ], + resource: ['hub'], + operation: ['update'], }, }, default: '', @@ -87,12 +78,8 @@ export const hubFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'hub', - ], - operation: [ - 'getAll', - ], + resource: ['hub'], + operation: ['getAll'], }, }, default: false, @@ -104,15 +91,9 @@ export const hubFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'hub', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['hub'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -126,12 +107,8 @@ export const hubFields: INodeProperties[] = [ ...nameField, displayOptions: { show: { - resource: [ - 'hub', - ], - operation: [ - 'create', - ], + resource: ['hub'], + operation: ['create'], }, }, required: true, @@ -140,12 +117,8 @@ export const hubFields: INodeProperties[] = [ ...destinationExternalField, displayOptions: { show: { - resource: [ - 'hub', - ], - operation: [ - 'create', - ], + resource: ['hub'], + operation: ['create'], }, }, }, @@ -157,12 +130,8 @@ export const hubFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'hub', - ], - operation: [ - 'create', - ], + resource: ['hub'], + operation: ['create'], }, }, options: [ @@ -180,12 +149,8 @@ export const hubFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'hub', - ], - operation: [ - 'update', - ], + resource: ['hub'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Onfleet/descriptions/OnfleetWebhookDescription.ts b/packages/nodes-base/nodes/Onfleet/descriptions/OnfleetWebhookDescription.ts index aa386420ee..17f5fab4d5 100644 --- a/packages/nodes-base/nodes/Onfleet/descriptions/OnfleetWebhookDescription.ts +++ b/packages/nodes-base/nodes/Onfleet/descriptions/OnfleetWebhookDescription.ts @@ -1,14 +1,14 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - webhookMapping, -} from '../WebhookMapping'; +import { webhookMapping } from '../WebhookMapping'; const sort = (a: { name: string }, b: { name: string }) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }; @@ -16,10 +16,12 @@ export const eventDisplay: INodeProperties = { displayName: 'Trigger On', name: 'triggerOn', type: 'options', - options: Object.keys(webhookMapping).map((webhook) => { - const { name, value } = webhookMapping[webhook]; - return { name, value }; - }).sort(sort), + options: Object.keys(webhookMapping) + .map((webhook) => { + const { name, value } = webhookMapping[webhook]; + return { name, value }; + }) + .sort(sort), required: true, default: [], }; diff --git a/packages/nodes-base/nodes/Onfleet/descriptions/OrganizationDescription.ts b/packages/nodes-base/nodes/Onfleet/descriptions/OrganizationDescription.ts index f9aa9b8e31..d4e7625ac2 100644 --- a/packages/nodes-base/nodes/Onfleet/descriptions/OrganizationDescription.ts +++ b/packages/nodes-base/nodes/Onfleet/descriptions/OrganizationDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const organizationOperations: INodeProperties[] = [ { @@ -10,25 +8,22 @@ export const organizationOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'organization', - ], + resource: ['organization'], }, }, options: [ { name: 'Get My Organization', value: 'get', - description: 'Retrieve your own organization\'s details', + description: "Retrieve your own organization's details", action: 'Get my organization', }, { name: 'Get Delegatee Details', value: 'getDelegatee', description: 'Retrieve the details of an organization with which you are connected', - action: 'Get a delegatee\'s details', + action: "Get a delegatee's details", }, - ], default: 'get', }, @@ -41,12 +36,8 @@ export const organizationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'getDelegatee', - ], + resource: ['organization'], + operation: ['getDelegatee'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Onfleet/descriptions/RecipientDescription.ts b/packages/nodes-base/nodes/Onfleet/descriptions/RecipientDescription.ts index 65608837a7..961b6f96c0 100644 --- a/packages/nodes-base/nodes/Onfleet/descriptions/RecipientDescription.ts +++ b/packages/nodes-base/nodes/Onfleet/descriptions/RecipientDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const recipientOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const recipientOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'recipient', - ], + resource: ['recipient'], }, }, options: [ @@ -45,7 +41,8 @@ const additionalRecipientFields: INodeProperties[] = [ name: 'recipientNotes', type: 'string', default: '', - description: 'Notes for this recipient: these are global notes that should not be task- or destination-specific', + description: + 'Notes for this recipient: these are global notes that should not be task- or destination-specific', }, { displayName: 'Skip Recipient SMS Notifications', @@ -60,7 +57,7 @@ const recipientName = { displayName: 'Recipient Name', name: 'recipientName', type: 'string', - description: 'The recipient\'s complete name', + description: "The recipient's complete name", default: '', } as INodeProperties; @@ -68,7 +65,8 @@ const recipientPhone = { displayName: 'Recipient Phone', name: 'recipientPhone', type: 'string', - description: 'A unique, valid phone number as per the organization\'s country if there\'s no leading + sign. If a phone number has a leading + sign, it will disregard the organization\'s country setting.', + description: + "A unique, valid phone number as per the organization's country if there's no leading + sign. If a phone number has a leading + sign, it will disregard the organization's country setting.", default: '', } as INodeProperties; @@ -82,7 +80,8 @@ const updateFields: INodeProperties[] = [ name: 'notes', type: 'string', default: '', - description: 'Notes for this recipient: these are global notes that should not be task- or destination-specific', + description: + 'Notes for this recipient: these are global notes that should not be task- or destination-specific', }, { ...recipientPhone, @@ -130,12 +129,8 @@ export const recipientFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'recipient', - ], - operation: [ - 'get', - ], + resource: ['recipient'], + operation: ['get'], }, }, options: [ @@ -162,15 +157,9 @@ export const recipientFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'recipient', - ], - operation: [ - 'get', - ], - getBy: [ - 'id', - ], + resource: ['recipient'], + operation: ['get'], + getBy: ['id'], }, }, default: '', @@ -183,12 +172,8 @@ export const recipientFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'recipient', - ], - operation: [ - 'update', - ], + resource: ['recipient'], + operation: ['update'], }, }, default: '', @@ -201,15 +186,9 @@ export const recipientFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'recipient', - ], - operation: [ - 'get', - ], - getBy: [ - 'name', - ], + resource: ['recipient'], + operation: ['get'], + getBy: ['name'], }, }, default: '', @@ -222,15 +201,9 @@ export const recipientFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'recipient', - ], - operation: [ - 'get', - ], - getBy: [ - 'phone', - ], + resource: ['recipient'], + operation: ['get'], + getBy: ['phone'], }, }, default: '', @@ -240,12 +213,8 @@ export const recipientFields: INodeProperties[] = [ { displayOptions: { show: { - resource: [ - 'recipient', - ], - operation: [ - 'create', - ], + resource: ['recipient'], + operation: ['create'], }, }, ...recipientName, @@ -254,12 +223,8 @@ export const recipientFields: INodeProperties[] = [ { displayOptions: { show: { - resource: [ - 'recipient', - ], - operation: [ - 'create', - ], + resource: ['recipient'], + operation: ['create'], }, }, ...recipientPhone, @@ -273,12 +238,8 @@ export const recipientFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'recipient', - ], - operation: [ - 'create', - ], + resource: ['recipient'], + operation: ['create'], }, }, options: additionalRecipientFields, @@ -291,12 +252,8 @@ export const recipientFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'recipient', - ], - operation: [ - 'update', - ], + resource: ['recipient'], + operation: ['update'], }, }, options: updateFields, @@ -309,12 +266,8 @@ export const recipientFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'recipient', - ], - operation: [ - 'create', - ], + resource: ['recipient'], + operation: ['create'], }, }, options: [ @@ -323,7 +276,7 @@ export const recipientFields: INodeProperties[] = [ name: 'recipientSkipPhoneNumberValidation', type: 'boolean', default: false, - description: 'Whether to skip validation for this recipient\'s phone number', + description: "Whether to skip validation for this recipient's phone number", }, ], }, diff --git a/packages/nodes-base/nodes/Onfleet/descriptions/TaskDescription.ts b/packages/nodes-base/nodes/Onfleet/descriptions/TaskDescription.ts index 4178fc9f48..7dac498f69 100644 --- a/packages/nodes-base/nodes/Onfleet/descriptions/TaskDescription.ts +++ b/packages/nodes-base/nodes/Onfleet/descriptions/TaskDescription.ts @@ -1,14 +1,8 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - destinationExternalField, -} from './DestinationDescription'; +import { destinationExternalField } from './DestinationDescription'; -import { - recipientExternalField, -} from './RecipientDescription'; +import { recipientExternalField } from './RecipientDescription'; export const taskOperations: INodeProperties[] = [ { @@ -18,9 +12,7 @@ export const taskOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'task', - ], + resource: ['task'], }, }, options: [ @@ -124,7 +116,8 @@ const quantityField = { name: 'quantity', type: 'number', default: 0, - description: 'The number of units to be dropped off while completing this task, for route optimization purposes', + description: + 'The number of units to be dropped off while completing this task, for route optimization purposes', } as INodeProperties; const serviceTimeField = { @@ -132,7 +125,8 @@ const serviceTimeField = { name: 'serviceTime', type: 'number', default: 0, - description: 'The number of minutes to be spent by the worker on arrival at this task\'s destination, for route optimization purposes', + description: + "The number of minutes to be spent by the worker on arrival at this task's destination, for route optimization purposes", } as INodeProperties; export const taskFields: INodeProperties[] = [ @@ -142,15 +136,10 @@ export const taskFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'task', - ], + resource: ['task'], }, hide: { - operation: [ - 'create', - 'getAll', - ], + operation: ['create', 'getAll'], }, }, default: '', @@ -163,12 +152,8 @@ export const taskFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, default: false, @@ -180,15 +165,9 @@ export const taskFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['task'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -202,12 +181,8 @@ export const taskFields: INodeProperties[] = [ ...destinationExternalField, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, default: {}, @@ -219,15 +194,11 @@ export const taskFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'complete', - ], + resource: ['task'], + operation: ['complete'], }, }, - description: 'Whether the task\'s completion was successful', + description: "Whether the task's completion was successful", required: true, default: true, }, @@ -239,12 +210,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, options: [ @@ -253,7 +220,8 @@ export const taskFields: INodeProperties[] = [ name: 'from', type: 'dateTime', default: '', - description: 'The starting time of the range. Tasks created or completed at or after this time will be included.', + description: + 'The starting time of the range. Tasks created or completed at or after this time will be included.', }, { displayName: 'State', @@ -301,12 +269,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'clone', - ], + resource: ['task'], + operation: ['clone'], }, }, options: [ @@ -356,12 +320,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, options: [ @@ -383,12 +343,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'complete', - ], + resource: ['task'], + operation: ['complete'], }, }, options: [ @@ -409,12 +365,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, options: [ @@ -453,7 +405,8 @@ export const taskFields: INodeProperties[] = [ name: 'useMerchantForProxy', type: 'boolean', default: false, - description: 'Whether to override the organization ID with the merchant\'s org ID for this task', + description: + "Whether to override the organization ID with the merchant's org ID for this task", }, ], }, diff --git a/packages/nodes-base/nodes/Onfleet/descriptions/TeamDescription.ts b/packages/nodes-base/nodes/Onfleet/descriptions/TeamDescription.ts index 9908f180ff..9f94fbe7bb 100644 --- a/packages/nodes-base/nodes/Onfleet/descriptions/TeamDescription.ts +++ b/packages/nodes-base/nodes/Onfleet/descriptions/TeamDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const teamOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const teamOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'team', - ], + resource: ['team'], }, }, options: [ @@ -79,7 +75,8 @@ const workersField = { loadOptionsMethod: 'getWorkers', }, default: [], - description: 'A list of workers. Choose from the list, or specify IDs using an expression.', + description: + 'A list of workers. Choose from the list, or specify IDs using an expression.', } as INodeProperties; const managersField = { @@ -90,7 +87,8 @@ const managersField = { loadOptionsMethod: 'getAdmins', }, default: [], - description: 'A list of managing administrators. Choose from the list, or specify IDs using an expression.', + description: + 'A list of managing administrators. Choose from the list, or specify IDs using an expression.', } as INodeProperties; const hubField = { @@ -101,7 +99,8 @@ const hubField = { loadOptionsMethod: 'getHubs', }, default: '', - description: 'The team\'s hub. Choose from the list, or specify an ID using an expression.', + description: + 'The team\'s hub. Choose from the list, or specify an ID using an expression.', } as INodeProperties; const enableSelfAssignmentField = { @@ -109,7 +108,8 @@ const enableSelfAssignmentField = { name: 'enableSelfAssignment', type: 'boolean', default: false, - description: 'Whether or not to allow drivers to self-assign tasks that are in the Team\'s unassigned container', + description: + "Whether or not to allow drivers to self-assign tasks that are in the Team's unassigned container", } as INodeProperties; const maxTasksPerRouteField = { @@ -132,7 +132,8 @@ const serviceTimeField = { typeOptions: { minValue: 0, }, - description: 'The default service time to apply in Minutes to the tasks when no task service time exists', + description: + 'The default service time to apply in Minutes to the tasks when no task service time exists', } as INodeProperties; const routeEndField = { @@ -221,7 +222,8 @@ const pickupTimeField = { name: 'pickupTime', type: 'dateTime', default: '', - description: 'If the request includes pickupLocation, pickupTime must be present if the time is fewer than 3 hours in the future', + description: + 'If the request includes pickupLocation, pickupTime must be present if the time is fewer than 3 hours in the future', } as INodeProperties; const restrictedVehicleTypesField = { @@ -258,7 +260,8 @@ const serviceTimeEstimateField = { typeOptions: { minValue: 0, }, - description: 'The expected time a worker will take at the pickupLocation, dropoffLocation, or both (as applicable) Unit: seconds', + description: + 'The expected time a worker will take at the pickupLocation, dropoffLocation, or both (as applicable) Unit: seconds', } as INodeProperties; export const teamFields: INodeProperties[] = [ @@ -268,16 +271,8 @@ export const teamFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'get', - 'update', - 'delete', - 'getTimeEstimates', - 'autoDispatch', - ], + resource: ['team'], + operation: ['get', 'update', 'delete', 'getTimeEstimates', 'autoDispatch'], }, }, default: '', @@ -288,12 +283,8 @@ export const teamFields: INodeProperties[] = [ ...nameField, displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'create', - ], + resource: ['team'], + operation: ['create'], }, }, required: true, @@ -302,12 +293,8 @@ export const teamFields: INodeProperties[] = [ ...workersField, displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'create', - ], + resource: ['team'], + operation: ['create'], }, }, required: true, @@ -316,12 +303,8 @@ export const teamFields: INodeProperties[] = [ ...managersField, displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'create', - ], + resource: ['team'], + operation: ['create'], }, }, required: true, @@ -334,18 +317,11 @@ export const teamFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'create', - ], + resource: ['team'], + operation: ['create'], }, }, - options: [ - hubField, - enableSelfAssignmentField, - ], + options: [hubField, enableSelfAssignmentField], }, { displayName: 'Return All', @@ -353,12 +329,8 @@ export const teamFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'getAll', - ], + resource: ['team'], + operation: ['getAll'], }, }, default: false, @@ -370,15 +342,9 @@ export const teamFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['team'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -396,21 +362,11 @@ export const teamFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'update', - ], + resource: ['team'], + operation: ['update'], }, }, - options: [ - managersField, - hubField, - nameField, - enableSelfAssignmentField, - workersField, - ], + options: [managersField, hubField, nameField, enableSelfAssignmentField, workersField], }, { displayName: 'Additional Fields', @@ -420,12 +376,8 @@ export const teamFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'autoDispatch', - ], + resource: ['team'], + operation: ['autoDispatch'], }, }, options: [ @@ -450,9 +402,7 @@ export const teamFields: INodeProperties[] = [ ...hubField, displayOptions: { show: { - routeEnd: [ - 'hub', - ], + routeEnd: ['hub'], }, }, required: false, @@ -532,12 +482,8 @@ export const teamFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'getTimeEstimates', - ], + resource: ['team'], + operation: ['getTimeEstimates'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Onfleet/descriptions/WebhookDescription.ts b/packages/nodes-base/nodes/Onfleet/descriptions/WebhookDescription.ts index fecbbf1c45..9795fe8e31 100644 --- a/packages/nodes-base/nodes/Onfleet/descriptions/WebhookDescription.ts +++ b/packages/nodes-base/nodes/Onfleet/descriptions/WebhookDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - webhookMapping, -} from '../WebhookMapping'; +import { webhookMapping } from '../WebhookMapping'; export const webhookOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const webhookOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'webhook', - ], + resource: ['webhook'], }, }, options: [ @@ -48,7 +42,8 @@ const urlField = { name: 'url', type: 'string', default: '', - description: 'The URL that Onfleet should issue a request against as soon as the trigger condition is met. It must be HTTPS and have a valid certificate.', + description: + 'The URL that Onfleet should issue a request against as soon as the trigger condition is met. It must be HTTPS and have a valid certificate.', } as INodeProperties; const nameField = { @@ -78,7 +73,8 @@ const thresholdField = { name: 'threshold', type: 'number', default: 0, - description: 'For trigger Task Eta, the time threshold in seconds; for trigger Task Arrival, the distance threshold in meters', + description: + 'For trigger Task Eta, the time threshold in seconds; for trigger Task Arrival, the distance threshold in meters', } as INodeProperties; export const webhookFields: INodeProperties[] = [ @@ -88,12 +84,8 @@ export const webhookFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'webhook', - ], - operation: [ - 'delete', - ], + resource: ['webhook'], + operation: ['delete'], }, }, default: '', @@ -104,12 +96,8 @@ export const webhookFields: INodeProperties[] = [ ...urlField, displayOptions: { show: { - resource: [ - 'webhook', - ], - operation: [ - 'create', - ], + resource: ['webhook'], + operation: ['create'], }, }, required: true, @@ -118,12 +106,8 @@ export const webhookFields: INodeProperties[] = [ ...nameField, displayOptions: { show: { - resource: [ - 'webhook', - ], - operation: [ - 'create', - ], + resource: ['webhook'], + operation: ['create'], }, }, required: true, @@ -132,12 +116,8 @@ export const webhookFields: INodeProperties[] = [ ...triggerField, displayOptions: { show: { - resource: [ - 'webhook', - ], - operation: [ - 'create', - ], + resource: ['webhook'], + operation: ['create'], }, }, required: true, @@ -150,16 +130,10 @@ export const webhookFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'webhook', - ], - operation: [ - 'create', - ], + resource: ['webhook'], + operation: ['create'], }, }, - options: [ - thresholdField, - ], + options: [thresholdField], }, ]; diff --git a/packages/nodes-base/nodes/Onfleet/descriptions/WorkerDescription.ts b/packages/nodes-base/nodes/Onfleet/descriptions/WorkerDescription.ts index 3cead558cb..4777aa06a1 100644 --- a/packages/nodes-base/nodes/Onfleet/descriptions/WorkerDescription.ts +++ b/packages/nodes-base/nodes/Onfleet/descriptions/WorkerDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const workerOperations: INodeProperties[] = [ { @@ -65,7 +63,8 @@ const byLocationField = { name: 'byLocation', type: 'boolean', default: false, - description: 'Whether to search for only those workers who are currently within a certain target area', + description: + 'Whether to search for only those workers who are currently within a certain target area', } as INodeProperties; const nameField = { @@ -73,7 +72,7 @@ const nameField = { name: 'name', type: 'string', default: '', - description: 'The worker\'s name', + description: "The worker's name", } as INodeProperties; const phoneField = { @@ -97,7 +96,8 @@ const displayNameField = { name: 'displayName', type: 'string', default: '', - description: 'This value is used in place of the worker\'s actual name within sms notifications, delivery tracking pages, and across organization boundaries', + description: + "This value is used in place of the worker's actual name within sms notifications, delivery tracking pages, and across organization boundaries", } as INodeProperties; const vehicleTypeField = { @@ -123,7 +123,8 @@ const vehicleTypeField = { }, ], default: '', - description: 'Whether the worker has vehicle or not. If it\'s not provided, this worker will be treated as if on foot.', + description: + "Whether the worker has vehicle or not. If it's not provided, this worker will be treated as if on foot.", } as INodeProperties; const vehicleDescriptionField = { @@ -131,7 +132,7 @@ const vehicleDescriptionField = { name: 'description', type: 'string', default: '', - description: 'The vehicle\'s make, model, year, or any other relevant identifying details', + description: "The vehicle's make, model, year, or any other relevant identifying details", } as INodeProperties; const vehicleLicensePlateField = { @@ -139,7 +140,7 @@ const vehicleLicensePlateField = { name: 'licensePlate', type: 'string', default: '', - description: 'The vehicle\'s license plate number', + description: "The vehicle's license plate number", } as INodeProperties; const vehicleColorField = { @@ -148,7 +149,7 @@ const vehicleColorField = { // eslint-disable-next-line n8n-nodes-base/node-param-color-type-unused type: 'string', default: '', - description: 'The vehicle\'s color', + description: "The vehicle's color", } as INodeProperties; const teamsField = { @@ -159,7 +160,8 @@ const teamsField = { loadOptionsMethod: 'getTeams', }, default: [], - description: 'One or more teams of which the worker is a member. Choose from the list, or specify IDs using an expression.', + description: + 'One or more teams of which the worker is a member. Choose from the list, or specify IDs using an expression.', } as INodeProperties; const teamsFilterField = { @@ -170,7 +172,8 @@ const teamsFilterField = { loadOptionsMethod: 'getTeams', }, default: [], - description: 'A list of the teams that workers must be part of. Choose from the list, or specify IDs using an expression.', + description: + 'A list of the teams that workers must be part of. Choose from the list, or specify IDs using an expression.', } as INodeProperties; const statesFilterField = { @@ -204,7 +207,7 @@ const phonesFilterField = { multipleValueButtonText: 'Add Phone', }, default: [], - description: 'A list of workers\' phone numbers', + description: "A list of workers' phone numbers", } as INodeProperties; const filterField = { @@ -328,7 +331,8 @@ const radiusFilterField = { minValue: 0, }, default: 1000, - description: 'The length in meters of the radius of the spherical area in which to look for workers. Defaults to 1000 if missing. Maximum value is 10000.', + description: + 'The length in meters of the radius of the spherical area in which to look for workers. Defaults to 1000 if missing. Maximum value is 10000.', } as INodeProperties; const scheduleDateField = { @@ -336,7 +340,7 @@ const scheduleDateField = { name: 'date', type: 'dateTime', default: '', - description: 'Schedule\'s date', + description: "Schedule's date", } as INodeProperties; const scheduleTimezoneField = { @@ -347,7 +351,8 @@ const scheduleTimezoneField = { loadOptionsMethod: 'getTimezones', }, default: '', - description: 'A valid timezone. Choose from the list, or specify an ID using an expression.', + description: + 'A valid timezone. Choose from the list, or specify an ID using an expression.', } as INodeProperties; const scheduleStartField = { @@ -372,12 +377,8 @@ export const workerFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'getAll', - ], + resource: ['worker'], + operation: ['getAll'], }, }, }, @@ -387,16 +388,8 @@ export const workerFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'get', - 'getSchedule', - 'setSchedule', - 'update', - 'delete', - ], + resource: ['worker'], + operation: ['get', 'getSchedule', 'setSchedule', 'update', 'delete'], }, }, default: '', @@ -407,12 +400,8 @@ export const workerFields: INodeProperties[] = [ ...nameField, displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'create', - ], + resource: ['worker'], + operation: ['create'], }, }, required: true, @@ -421,12 +410,8 @@ export const workerFields: INodeProperties[] = [ ...phoneField, displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'create', - ], + resource: ['worker'], + operation: ['create'], }, }, required: true, @@ -435,12 +420,8 @@ export const workerFields: INodeProperties[] = [ ...teamsField, displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'create', - ], + resource: ['worker'], + operation: ['create'], }, }, required: true, @@ -449,15 +430,9 @@ export const workerFields: INodeProperties[] = [ ...longitudeFilterField, displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'getAll', - ], - byLocation: [ - true, - ], + resource: ['worker'], + operation: ['getAll'], + byLocation: [true], }, }, required: true, @@ -466,15 +441,9 @@ export const workerFields: INodeProperties[] = [ ...latitudeFilterField, displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'getAll', - ], - byLocation: [ - true, - ], + resource: ['worker'], + operation: ['getAll'], + byLocation: [true], }, }, required: true, @@ -485,12 +454,8 @@ export const workerFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'getAll', - ], + resource: ['worker'], + operation: ['getAll'], }, }, default: false, @@ -502,15 +467,9 @@ export const workerFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['worker'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -528,12 +487,8 @@ export const workerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'create', - ], + resource: ['worker'], + operation: ['create'], }, }, options: [ @@ -580,20 +535,11 @@ export const workerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'update', - ], + resource: ['worker'], + operation: ['update'], }, }, - options: [ - capacityField, - displayNameField, - nameField, - teamsField, - ], + options: [capacityField, displayNameField, nameField, teamsField], }, { displayName: 'Filters', @@ -603,20 +549,12 @@ export const workerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'getAll', - ], - byLocation: [ - true, - ], + resource: ['worker'], + operation: ['getAll'], + byLocation: [true], }, }, - options: [ - radiusFilterField, - ], + options: [radiusFilterField], }, { displayName: 'Filters', @@ -626,22 +564,12 @@ export const workerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'getAll', - ], - byLocation: [ - false, - ], + resource: ['worker'], + operation: ['getAll'], + byLocation: [false], }, }, - options: [ - statesFilterField, - teamsFilterField, - phonesFilterField, - ], + options: [statesFilterField, teamsFilterField, phonesFilterField], }, { displayName: 'Options', @@ -651,17 +579,11 @@ export const workerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'getAll', - ], + resource: ['worker'], + operation: ['getAll'], }, }, - options: [ - filterField, - ], + options: [filterField], }, { displayName: 'Options', @@ -671,12 +593,8 @@ export const workerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'get', - ], + resource: ['worker'], + operation: ['get'], }, }, options: [ @@ -685,7 +603,8 @@ export const workerFields: INodeProperties[] = [ name: 'analytics', type: 'boolean', default: true, - description: 'Whether a more detailed response is needed, includes basic worker duty event, traveled distance (meters) and time analytics', + description: + 'Whether a more detailed response is needed, includes basic worker duty event, traveled distance (meters) and time analytics', }, { ...filterField, @@ -700,12 +619,8 @@ export const workerFields: INodeProperties[] = [ placeholder: 'Add Schedule', displayOptions: { show: { - resource: [ - 'worker', - ], - operation: [ - 'setSchedule', - ], + resource: ['worker'], + operation: ['setSchedule'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts b/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts index ffed2ecc22..21253a5053 100644 --- a/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts +++ b/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,11 +7,19 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function openThesaurusApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function openThesaurusApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { try { let options: OptionsWithUri = { headers: { diff --git a/packages/nodes-base/nodes/OpenThesaurus/OpenThesaurus.node.ts b/packages/nodes-base/nodes/OpenThesaurus/OpenThesaurus.node.ts index 2c4cee2aa8..bf27b12853 100644 --- a/packages/nodes-base/nodes/OpenThesaurus/OpenThesaurus.node.ts +++ b/packages/nodes-base/nodes/OpenThesaurus/OpenThesaurus.node.ts @@ -1,17 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - openThesaurusApiRequest, -} from './GenericFunctions'; +import { openThesaurusApiRequest } from './GenericFunctions'; export class OpenThesaurus implements INodeType { description: INodeTypeDescription = { @@ -53,9 +44,7 @@ export class OpenThesaurus implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'getSynonyms', - ], + operation: ['getSynonyms'], }, }, }, @@ -66,9 +55,7 @@ export class OpenThesaurus implements INodeType { placeholder: 'Add Options', displayOptions: { show: { - operation: [ - 'getSynonyms', - ], + operation: ['getSynonyms'], }, }, default: {}, @@ -79,7 +66,8 @@ export class OpenThesaurus implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Specifies the basic form for the search term if it is not already a basic form', + description: + 'Specifies the basic form for the search term if it is not already a basic form', }, { displayName: 'Similar', @@ -87,7 +75,8 @@ export class OpenThesaurus implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'This also returns up to five similarly written words for each answer. This is useful to be able to make a suggestion to the user in the event of a possible typing error.', + description: + 'This also returns up to five similarly written words for each answer. This is useful to be able to make a suggestion to the user in the event of a possible typing error.', }, { displayName: 'Starts With', @@ -95,21 +84,24 @@ export class OpenThesaurus implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Like substring = true, but only finds words that begin with the specified search term', + description: + 'Like substring = true, but only finds words that begin with the specified search term', }, { displayName: 'Substring', name: 'substring', type: 'boolean', default: false, - description: 'Whether up to ten words are returned for each answer that only contain the search term as a partial word', + description: + 'Whether up to ten words are returned for each answer that only contain the search term as a partial word', }, { displayName: 'Substring From Results', name: 'substringFromResults', type: 'number', default: 0, - description: 'Specifies from which entry the partial word hits are to be returned. Only works together with substring = true.', + description: + 'Specifies from which entry the partial word hits are to be returned. Only works together with substring = true.', }, { displayName: 'Substring Max Results', @@ -119,7 +111,8 @@ export class OpenThesaurus implements INodeType { maxValue: 250, }, default: 10, - description: 'Specifies how many partial word hits should be returned in total. Only works together with substring = true.', + description: + 'Specifies how many partial word hits should be returned in total. Only works together with substring = true.', }, { displayName: 'Subsynsets', @@ -158,7 +151,13 @@ export class OpenThesaurus implements INodeType { Object.assign(qs, options); - responseData = await openThesaurusApiRequest.call(this, 'GET', `/synonyme/search`, {}, qs); + responseData = await openThesaurusApiRequest.call( + this, + 'GET', + `/synonyme/search`, + {}, + qs, + ); responseData = responseData.synsets; } if (Array.isArray(responseData)) { diff --git a/packages/nodes-base/nodes/OpenWeatherMap/OpenWeatherMap.node.ts b/packages/nodes-base/nodes/OpenWeatherMap/OpenWeatherMap.node.ts index 35b646de29..30894e3486 100644 --- a/packages/nodes-base/nodes/OpenWeatherMap/OpenWeatherMap.node.ts +++ b/packages/nodes-base/nodes/OpenWeatherMap/OpenWeatherMap.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, INodeExecutionData, @@ -117,9 +115,7 @@ export class OpenWeatherMap implements INodeType { required: true, displayOptions: { show: { - locationSelection: [ - 'cityName', - ], + locationSelection: ['cityName'], }, }, description: 'The name of the city to return the weather of', @@ -133,12 +129,11 @@ export class OpenWeatherMap implements INodeType { required: true, displayOptions: { show: { - locationSelection: [ - 'cityId', - ], + locationSelection: ['cityId'], }, }, - description: 'The ID of city to return the weather of. List can be downloaded here: http://bulk.openweathermap.org/sample/.', + description: + 'The ID of city to return the weather of. List can be downloaded here: http://bulk.openweathermap.org/sample/.', }, { @@ -150,9 +145,7 @@ export class OpenWeatherMap implements INodeType { required: true, displayOptions: { show: { - locationSelection: [ - 'coordinates', - ], + locationSelection: ['coordinates'], }, }, description: 'The latitude of the location to return the weather of', @@ -167,9 +160,7 @@ export class OpenWeatherMap implements INodeType { required: true, displayOptions: { show: { - locationSelection: [ - 'coordinates', - ], + locationSelection: ['coordinates'], }, }, description: 'The longitude of the location to return the weather of', @@ -184,12 +175,11 @@ export class OpenWeatherMap implements INodeType { required: true, displayOptions: { show: { - locationSelection: [ - 'zipCode', - ], + locationSelection: ['zipCode'], }, }, - description: 'The ID of city to return the weather of. List can be downloaded here: http://bulk.openweathermap.org/sample/.', + description: + 'The ID of city to return the weather of. List can be downloaded here: http://bulk.openweathermap.org/sample/.', }, { @@ -200,11 +190,9 @@ export class OpenWeatherMap implements INodeType { placeholder: 'en', description: 'The two letter language code to get your output in (eg. en, de, ...).', }, - ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -220,9 +208,7 @@ export class OpenWeatherMap implements INodeType { let qs: IDataObject; for (let i = 0; i < items.length; i++) { - try { - // Set base data qs = { APPID: credentials.accessToken, @@ -241,7 +227,11 @@ export class OpenWeatherMap implements INodeType { } else if (locationSelection === 'zipCode') { qs.zip = this.getNodeParameter('zipCode', i) as string; } else { - throw new NodeOperationError(this.getNode(), `The locationSelection "${locationSelection}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The locationSelection "${locationSelection}" is not known!`, + { itemIndex: i }, + ); } // Get the language @@ -263,7 +253,11 @@ export class OpenWeatherMap implements INodeType { endpoint = 'forecast'; } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } const options: OptionsWithUri = { @@ -280,12 +274,10 @@ export class OpenWeatherMap implements INodeType { throw new NodeApiError(this.getNode(), error); } - returnData.push(responseData as IDataObject); - } catch (error) { if (this.continueOnFail()) { - returnData.push({json:{ error: error.message }}); + returnData.push({ json: { error: error.message } }); continue; } throw error; diff --git a/packages/nodes-base/nodes/Orbit/ActivityDescription.ts b/packages/nodes-base/nodes/Orbit/ActivityDescription.ts index 043843ebba..48b4b73b80 100644 --- a/packages/nodes-base/nodes/Orbit/ActivityDescription.ts +++ b/packages/nodes-base/nodes/Orbit/ActivityDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const activityOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const activityOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'activity', - ], + resource: ['activity'], }, }, options: [ @@ -34,7 +30,6 @@ export const activityOperations: INodeProperties[] = [ ]; export const activityFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* activity:create */ /* -------------------------------------------------------------------------- */ @@ -42,7 +37,8 @@ export const activityFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -50,12 +46,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, }, @@ -67,12 +59,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, }, @@ -84,12 +72,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, }, @@ -100,12 +84,8 @@ export const activityFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, default: {}, @@ -118,7 +98,8 @@ export const activityFields: INodeProperties[] = [ loadOptionsMethod: 'getActivityTypes', }, default: '', - description: 'A user-defined way to group activities of the same nature. Choose from the list, or specify an ID using an expression.', + description: + 'A user-defined way to group activities of the same nature. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Description', @@ -165,7 +146,8 @@ export const activityFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -173,12 +155,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getAll', - ], + resource: ['activity'], + operation: ['getAll'], }, }, }, @@ -188,12 +166,8 @@ export const activityFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'activity', - ], + operation: ['getAll'], + resource: ['activity'], }, }, default: false, @@ -205,15 +179,9 @@ export const activityFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'activity', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['activity'], + returnAll: [false], }, }, typeOptions: { @@ -231,12 +199,8 @@ export const activityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getAll', - ], + resource: ['activity'], + operation: ['getAll'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Orbit/GenericFunctions.ts b/packages/nodes-base/nodes/Orbit/GenericFunctions.ts index 8e63d753a2..e4d8a98437 100644 --- a/packages/nodes-base/nodes/Orbit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Orbit/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,15 +7,21 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - IRelation, -} from './Interfaces'; +import { IRelation } from './Interfaces'; -export async function orbitApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function orbitApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { try { const credentials = await this.getCredentials('orbitApi'); let options: OptionsWithUri = { @@ -43,8 +47,16 @@ export async function orbitApiRequest(this: IHookFunctions | IExecuteFunctions | * Make an API request to paginated flow endpoint * and return all results */ -export async function orbitApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function orbitApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -63,13 +75,10 @@ export async function orbitApiRequestAllItems(this: IHookFunctions | IExecuteFun } query.page++; - if (query.limit && (returnData.length >= query.limit)) { + if (query.limit && returnData.length >= query.limit) { return returnData; } - - } while ( - responseData.data.length !== 0 - ); + } while (responseData.data.length !== 0); return returnData; } @@ -86,7 +95,8 @@ export function resolveIdentities(responseData: IRelation) { for (let i = 0; i < responseData.data.length; i++) { for (let y = 0; y < responseData.data[i].relationships.identities.data.length; y++) { //@ts-ignore - responseData.data[i].relationships.identities.data[y] = identities[responseData.data[i].relationships.identities.data[y].id]; + responseData.data[i].relationships.identities.data[y] = + identities[responseData.data[i].relationships.identities.data[y].id]; } } } @@ -103,6 +113,8 @@ export function resolveMember(responseData: IRelation) { for (let i = 0; i < responseData.data.length; i++) { //@ts-ignore - responseData.data[i].relationships.member.data = members[responseData.data[i].relationships.member.data.id]; + responseData.data[i].relationships.member.data = + //@ts-ignore + members[responseData.data[i].relationships.member.data.id]; } } diff --git a/packages/nodes-base/nodes/Orbit/Interfaces.ts b/packages/nodes-base/nodes/Orbit/Interfaces.ts index 4e2a8fbb51..bb2468d343 100644 --- a/packages/nodes-base/nodes/Orbit/Interfaces.ts +++ b/packages/nodes-base/nodes/Orbit/Interfaces.ts @@ -1,11 +1,9 @@ -import { - IDataObject, -} from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export interface IData { data: [ { - id: string, + id: string; }, ]; } @@ -14,9 +12,9 @@ export interface IRelation { data: [ { relationships: { - identities: IData, - member: IData, - }, + identities: IData; + member: IData; + }; }, ]; included: IDataObject[]; diff --git a/packages/nodes-base/nodes/Orbit/MemberDescription.ts b/packages/nodes-base/nodes/Orbit/MemberDescription.ts index 53f977c824..5f6f518d7d 100644 --- a/packages/nodes-base/nodes/Orbit/MemberDescription.ts +++ b/packages/nodes-base/nodes/Orbit/MemberDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const memberOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const memberOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'member', - ], + resource: ['member'], }, }, options: [ @@ -58,7 +54,6 @@ export const memberOperations: INodeProperties[] = [ ]; export const memberFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* member:delete */ /* -------------------------------------------------------------------------- */ @@ -66,7 +61,8 @@ export const memberFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -74,12 +70,8 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'delete', - ], + resource: ['member'], + operation: ['delete'], }, }, }, @@ -91,17 +83,12 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'delete', - ], + resource: ['member'], + operation: ['delete'], }, }, }, - /* -------------------------------------------------------------------------- */ /* member:get */ /* -------------------------------------------------------------------------- */ @@ -109,7 +96,8 @@ export const memberFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -117,12 +105,8 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'get', - ], + resource: ['member'], + operation: ['get'], }, }, }, @@ -134,12 +118,8 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'get', - ], + resource: ['member'], + operation: ['get'], }, }, }, @@ -149,17 +129,14 @@ export const memberFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'member', - ], + operation: ['get'], + resource: ['member'], }, }, default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default, the response just includes the reference of the identity. When set to true the identities will be resolved automatically.', + description: + 'By default, the response just includes the reference of the identity. When set to true the identities will be resolved automatically.', }, /* -------------------------------------------------------------------------- */ @@ -169,7 +146,8 @@ export const memberFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -177,12 +155,8 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'getAll', - ], + resource: ['member'], + operation: ['getAll'], }, }, }, @@ -192,12 +166,8 @@ export const memberFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'member', - ], + operation: ['getAll'], + resource: ['member'], }, }, default: false, @@ -209,15 +179,9 @@ export const memberFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'member', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['member'], + returnAll: [false], }, }, typeOptions: { @@ -233,17 +197,14 @@ export const memberFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'member', - ], + operation: ['getAll'], + resource: ['member'], }, }, default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default, the response just includes the reference of the identity. When set to true the identities will be resolved automatically.', + description: + 'By default, the response just includes the reference of the identity. When set to true the identities will be resolved automatically.', }, { displayName: 'Options', @@ -253,12 +214,8 @@ export const memberFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'getAll', - ], + resource: ['member'], + operation: ['getAll'], }, }, options: [ @@ -295,7 +252,8 @@ export const memberFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -303,12 +261,8 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'lookup', - ], + resource: ['member'], + operation: ['lookup'], }, }, }, @@ -338,15 +292,12 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'lookup', - ], + resource: ['member'], + operation: ['lookup'], }, }, - description: 'Set to github, twitter, email, discourse or the source of any identities you\'ve manually created', + description: + "Set to github, twitter, email, discourse or the source of any identities you've manually created", }, { displayName: 'Search By', @@ -366,17 +317,9 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'lookup', - ], - source: [ - 'discourse', - 'github', - 'twitter', - ], + resource: ['member'], + operation: ['lookup'], + source: ['discourse', 'github', 'twitter'], }, }, }, @@ -388,20 +331,10 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'lookup', - ], - searchBy: [ - 'id', - ], - source: [ - 'discourse', - 'github', - 'twitter', - ], + resource: ['member'], + operation: ['lookup'], + searchBy: ['id'], + source: ['discourse', 'github', 'twitter'], }, }, description: 'The username at the source', @@ -414,20 +347,10 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'lookup', - ], - searchBy: [ - 'username', - ], - source: [ - 'discourse', - 'github', - 'twitter', - ], + resource: ['member'], + operation: ['lookup'], + searchBy: ['username'], + source: ['discourse', 'github', 'twitter'], }, }, description: 'The username at the source', @@ -441,15 +364,9 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'lookup', - ], - source: [ - 'email', - ], + resource: ['member'], + operation: ['lookup'], + source: ['email'], }, }, description: 'The email address', @@ -462,15 +379,9 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'lookup', - ], - source: [ - 'discourse', - ], + resource: ['member'], + operation: ['lookup'], + source: ['discourse'], }, }, }, @@ -482,7 +393,8 @@ export const memberFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -490,12 +402,8 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'update', - ], + resource: ['member'], + operation: ['update'], }, }, }, @@ -507,12 +415,8 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'update', - ], + resource: ['member'], + operation: ['update'], }, }, }, @@ -523,12 +427,8 @@ export const memberFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'update', - ], + resource: ['member'], + operation: ['update'], }, }, default: {}, @@ -623,7 +523,8 @@ export const memberFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -631,12 +532,8 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'upsert', - ], + resource: ['member'], + operation: ['upsert'], }, }, }, @@ -644,7 +541,8 @@ export const memberFields: INodeProperties[] = [ displayName: 'Identity', name: 'identityUi', type: 'fixedCollection', - description: 'The identity is used to find the member. If no member exists, a new member will be created and linked to the provided identity.', + description: + 'The identity is used to find the member. If no member exists, a new member will be created and linked to the provided identity.', typeOptions: { multipleValues: false, }, @@ -652,12 +550,8 @@ export const memberFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'upsert', - ], + resource: ['member'], + operation: ['upsert'], }, }, options: [ @@ -688,7 +582,8 @@ export const memberFields: INodeProperties[] = [ }, ], default: '', - description: 'Set to github, twitter, email, discourse or the source of any identities you\'ve manually created', + description: + "Set to github, twitter, email, discourse or the source of any identities you've manually created", }, { displayName: 'Search By', @@ -708,11 +603,7 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'discourse', - 'github', - 'twitter', - ], + source: ['discourse', 'github', 'twitter'], }, }, }, @@ -724,14 +615,8 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - searchBy: [ - 'id', - ], - source: [ - 'discourse', - 'github', - 'twitter', - ], + searchBy: ['id'], + source: ['discourse', 'github', 'twitter'], }, }, description: 'The username at the source', @@ -744,14 +629,8 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - searchBy: [ - 'username', - ], - source: [ - 'discourse', - 'github', - 'twitter', - ], + searchBy: ['username'], + source: ['discourse', 'github', 'twitter'], }, }, description: 'The username at the source', @@ -765,9 +644,7 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'email', - ], + source: ['email'], }, }, }, @@ -779,9 +656,7 @@ export const memberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'discourse', - ], + source: ['discourse'], }, }, }, @@ -796,12 +671,8 @@ export const memberFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'upsert', - ], + resource: ['member'], + operation: ['upsert'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/Orbit/NoteDescription.ts b/packages/nodes-base/nodes/Orbit/NoteDescription.ts index 4f718b980f..c7af2cae76 100644 --- a/packages/nodes-base/nodes/Orbit/NoteDescription.ts +++ b/packages/nodes-base/nodes/Orbit/NoteDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const noteOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const noteOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'note', - ], + resource: ['note'], }, }, options: [ @@ -40,7 +36,6 @@ export const noteOperations: INodeProperties[] = [ ]; export const noteFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* note:create */ /* -------------------------------------------------------------------------- */ @@ -48,7 +43,8 @@ export const noteFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -56,12 +52,8 @@ export const noteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'create', - ], + resource: ['note'], + operation: ['create'], }, }, }, @@ -73,12 +65,8 @@ export const noteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'create', - ], + resource: ['note'], + operation: ['create'], }, }, }, @@ -90,12 +78,8 @@ export const noteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'create', - ], + resource: ['note'], + operation: ['create'], }, }, }, @@ -107,7 +91,8 @@ export const noteFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -115,12 +100,8 @@ export const noteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'getAll', - ], + resource: ['note'], + operation: ['getAll'], }, }, }, @@ -132,12 +113,8 @@ export const noteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'getAll', - ], + resource: ['note'], + operation: ['getAll'], }, }, }, @@ -147,12 +124,8 @@ export const noteFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'note', - ], + operation: ['getAll'], + resource: ['note'], }, }, default: false, @@ -164,15 +137,9 @@ export const noteFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'note', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['note'], + returnAll: [false], }, }, typeOptions: { @@ -188,12 +155,8 @@ export const noteFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'note', - ], + operation: ['getAll'], + resource: ['note'], }, }, default: false, @@ -206,7 +169,8 @@ export const noteFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -214,12 +178,8 @@ export const noteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'update', - ], + resource: ['note'], + operation: ['update'], }, }, }, @@ -231,12 +191,8 @@ export const noteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'update', - ], + resource: ['note'], + operation: ['update'], }, }, }, @@ -248,12 +204,8 @@ export const noteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'update', - ], + resource: ['note'], + operation: ['update'], }, }, }, @@ -265,12 +217,8 @@ export const noteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'update', - ], + resource: ['note'], + operation: ['update'], }, }, }, diff --git a/packages/nodes-base/nodes/Orbit/Orbit.node.ts b/packages/nodes-base/nodes/Orbit/Orbit.node.ts index 1d55866662..5e8193627a 100644 --- a/packages/nodes-base/nodes/Orbit/Orbit.node.ts +++ b/packages/nodes-base/nodes/Orbit/Orbit.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,31 +9,15 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - orbitApiRequest, - orbitApiRequestAllItems, - resolveIdentities, -} from './GenericFunctions'; +import { orbitApiRequest, orbitApiRequestAllItems, resolveIdentities } from './GenericFunctions'; -import { - activityFields, - activityOperations, -} from './ActivityDescription'; +import { activityFields, activityOperations } from './ActivityDescription'; -import { - memberFields, - memberOperations, -} from './MemberDescription'; +import { memberFields, memberOperations } from './MemberDescription'; -import { - noteFields, - noteOperations, -} from './NoteDescription'; +import { noteFields, noteOperations } from './NoteDescription'; -import { - postFields, - postOperations, -} from './PostDescription'; +import { postFields, postOperations } from './PostDescription'; import moment from 'moment'; @@ -102,15 +84,9 @@ export class Orbit implements INodeType { methods = { loadOptions: { - async getWorkspaces( - this: ILoadOptionsFunctions, - ): Promise { + async getWorkspaces(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const workspaces = await orbitApiRequest.call( - this, - 'GET', - '/workspaces', - ); + const workspaces = await orbitApiRequest.call(this, 'GET', '/workspaces'); for (const workspace of workspaces.data) { returnData.push({ name: workspace.attributes.name, @@ -119,15 +95,9 @@ export class Orbit implements INodeType { } return returnData; }, - async getActivityTypes( - this: ILoadOptionsFunctions, - ): Promise { + async getActivityTypes(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { data } = await orbitApiRequest.call( - this, - 'GET', - '/activity_types', - ); + const { data } = await orbitApiRequest.call(this, 'GET', '/activity_types'); for (const activityType of data) { returnData.push({ name: activityType.attributes.short_name, @@ -177,7 +147,12 @@ export class Orbit implements INodeType { body.occurred_at = additionalFields.occurredAt as string; } - responseData = await orbitApiRequest.call(this, 'POST', `/${workspaceId}/members/${memberId}/activities`, body); + responseData = await orbitApiRequest.call( + this, + 'POST', + `/${workspaceId}/members/${memberId}/activities`, + body, + ); responseData = responseData.data; } if (operation === 'getAll') { @@ -189,10 +164,24 @@ export class Orbit implements INodeType { endpoint = `/${workspaceId}/members/${filters.memberId}/activities`; } if (returnAll === true) { - responseData = await orbitApiRequestAllItems.call(this, 'data', 'GET', endpoint, {}, qs); + responseData = await orbitApiRequestAllItems.call( + this, + 'data', + 'GET', + endpoint, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as boolean; - responseData = await orbitApiRequestAllItems.call(this, 'data', 'GET', endpoint, {}, qs); + responseData = await orbitApiRequestAllItems.call( + this, + 'data', + 'GET', + endpoint, + {}, + qs, + ); responseData = responseData.splice(0, qs.limit); } } @@ -246,7 +235,8 @@ export class Orbit implements INodeType { member.url = additionalFields.url as string; } - const data = (this.getNodeParameter('identityUi', i) as IDataObject).identityValue as IDataObject; + const data = (this.getNodeParameter('identityUi', i) as IDataObject) + .identityValue as IDataObject; if (data) { if (['github', 'twitter', 'discourse'].includes(data.source as string)) { identity.source = data.source as string; @@ -265,20 +255,31 @@ export class Orbit implements INodeType { } } - responseData = await orbitApiRequest.call(this, 'POST', `/${workspaceId}/members`, { member, identity }); + responseData = await orbitApiRequest.call(this, 'POST', `/${workspaceId}/members`, { + member, + identity, + }); responseData = responseData.data; } if (operation === 'delete') { const workspaceId = this.getNodeParameter('workspaceId', i) as string; const memberId = this.getNodeParameter('memberId', i) as string; - responseData = await orbitApiRequest.call(this, 'DELETE', `/${workspaceId}/members/${memberId}`); + responseData = await orbitApiRequest.call( + this, + 'DELETE', + `/${workspaceId}/members/${memberId}`, + ); responseData = { success: true }; } if (operation === 'get') { const workspaceId = this.getNodeParameter('workspaceId', i) as string; const memberId = this.getNodeParameter('memberId', i) as string; const resolve = this.getNodeParameter('resolveIdentities', 0) as boolean; - responseData = await orbitApiRequest.call(this, 'GET', `/${workspaceId}/members/${memberId}`); + responseData = await orbitApiRequest.call( + this, + 'GET', + `/${workspaceId}/members/${memberId}`, + ); if (resolve === true) { resolveIdentities(responseData); } @@ -291,10 +292,24 @@ export class Orbit implements INodeType { Object.assign(qs, options); qs.resolveIdentities = this.getNodeParameter('resolveIdentities', 0) as boolean; if (returnAll === true) { - responseData = await orbitApiRequestAllItems.call(this, 'data', 'GET', `/${workspaceId}/members`, {}, qs); + responseData = await orbitApiRequestAllItems.call( + this, + 'data', + 'GET', + `/${workspaceId}/members`, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as boolean; - responseData = await orbitApiRequestAllItems.call(this, 'data', 'GET', `/${workspaceId}/members`, {}, qs); + responseData = await orbitApiRequestAllItems.call( + this, + 'data', + 'GET', + `/${workspaceId}/members`, + {}, + qs, + ); responseData = responseData.splice(0, qs.limit); } } @@ -318,15 +333,20 @@ export class Orbit implements INodeType { qs.email = this.getNodeParameter('email', i) as string; } - responseData = await orbitApiRequest.call(this, 'GET', `/${workspaceId}/members/find`, {}, qs); + responseData = await orbitApiRequest.call( + this, + 'GET', + `/${workspaceId}/members/find`, + {}, + qs, + ); responseData = responseData.data; } if (operation === 'update') { const workspaceId = this.getNodeParameter('workspaceId', i) as string; const memberId = this.getNodeParameter('memberId', i) as string; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - const body: IDataObject = { - }; + const body: IDataObject = {}; if (updateFields.bio) { body.bio = updateFields.bio as string; } @@ -370,7 +390,12 @@ export class Orbit implements INodeType { body.url = updateFields.url as string; } - responseData = await orbitApiRequest.call(this, 'PUT', `/${workspaceId}/members/${memberId}`, body); + responseData = await orbitApiRequest.call( + this, + 'PUT', + `/${workspaceId}/members/${memberId}`, + body, + ); responseData = { success: true }; } } @@ -380,7 +405,12 @@ export class Orbit implements INodeType { const memberId = this.getNodeParameter('memberId', i) as string; const note = this.getNodeParameter('note', i) as string; - responseData = await orbitApiRequest.call(this, 'POST', `/${workspaceId}/members/${memberId}/notes`, { body: note }); + responseData = await orbitApiRequest.call( + this, + 'POST', + `/${workspaceId}/members/${memberId}/notes`, + { body: note }, + ); responseData = responseData.data; } if (operation === 'getAll') { @@ -389,10 +419,24 @@ export class Orbit implements INodeType { const returnAll = this.getNodeParameter('returnAll', i) as boolean; qs.resolveMember = this.getNodeParameter('resolveMember', 0) as boolean; if (returnAll === true) { - responseData = await orbitApiRequestAllItems.call(this, 'data', 'GET', `/${workspaceId}/members/${memberId}/notes`, {}, qs); + responseData = await orbitApiRequestAllItems.call( + this, + 'data', + 'GET', + `/${workspaceId}/members/${memberId}/notes`, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as boolean; - responseData = await orbitApiRequestAllItems.call(this, 'data', 'GET', `/${workspaceId}/members/${memberId}/notes`, {}, qs); + responseData = await orbitApiRequestAllItems.call( + this, + 'data', + 'GET', + `/${workspaceId}/members/${memberId}/notes`, + {}, + qs, + ); responseData = responseData.splice(0, qs.limit); } } @@ -402,7 +446,12 @@ export class Orbit implements INodeType { const noteId = this.getNodeParameter('noteId', i) as string; const note = this.getNodeParameter('note', i) as string; - responseData = await orbitApiRequest.call(this, 'PUT', `/${workspaceId}/members/${memberId}/notes/${noteId}`, { body: note }); + responseData = await orbitApiRequest.call( + this, + 'PUT', + `/${workspaceId}/members/${memberId}/notes/${noteId}`, + { body: note }, + ); responseData = { success: true }; } } @@ -422,7 +471,12 @@ export class Orbit implements INodeType { delete body.publishedAt; } - responseData = await orbitApiRequest.call(this, 'POST', `/${workspaceId}/members/${memberId}/activities/`, body); + responseData = await orbitApiRequest.call( + this, + 'POST', + `/${workspaceId}/members/${memberId}/activities/`, + body, + ); responseData = responseData.data; } if (operation === 'getAll') { @@ -435,10 +489,24 @@ export class Orbit implements INodeType { endpoint = `/${workspaceId}/members/${filters.memberId}/activities`; } if (returnAll === true) { - responseData = await orbitApiRequestAllItems.call(this, 'data', 'GET', endpoint, {}, qs); + responseData = await orbitApiRequestAllItems.call( + this, + 'data', + 'GET', + endpoint, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as boolean; - responseData = await orbitApiRequestAllItems.call(this, 'data', 'GET', endpoint, {}, qs); + responseData = await orbitApiRequestAllItems.call( + this, + 'data', + 'GET', + endpoint, + {}, + qs, + ); responseData = responseData.splice(0, qs.limit); } } @@ -447,7 +515,11 @@ export class Orbit implements INodeType { const memberId = this.getNodeParameter('memberId', i) as string; const postId = this.getNodeParameter('postId', i) as string; - responseData = await orbitApiRequest.call(this, 'DELETE', `/${workspaceId}/members/${memberId}/activities/${postId}`); + responseData = await orbitApiRequest.call( + this, + 'DELETE', + `/${workspaceId}/members/${memberId}/activities/${postId}`, + ); responseData = { success: true }; } } @@ -467,14 +539,3 @@ export class Orbit implements INodeType { return [this.helpers.returnJsonArray(returnData)]; } } - - - - - - - - - - - diff --git a/packages/nodes-base/nodes/Orbit/PostDescription.ts b/packages/nodes-base/nodes/Orbit/PostDescription.ts index cc5d0e4aa9..17d8232082 100644 --- a/packages/nodes-base/nodes/Orbit/PostDescription.ts +++ b/packages/nodes-base/nodes/Orbit/PostDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const postOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const postOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'post', - ], + resource: ['post'], }, }, options: [ @@ -40,7 +36,6 @@ export const postOperations: INodeProperties[] = [ ]; export const postFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* post:create */ /* -------------------------------------------------------------------------- */ @@ -48,7 +43,8 @@ export const postFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -56,12 +52,8 @@ export const postFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], + resource: ['post'], + operation: ['create'], }, }, }, @@ -73,12 +65,8 @@ export const postFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], + resource: ['post'], + operation: ['create'], }, }, }, @@ -90,15 +78,12 @@ export const postFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], + resource: ['post'], + operation: ['create'], }, }, - description: 'Supply any URL and Orbit will do its best job to parse out a title, description, and image', + description: + 'Supply any URL and Orbit will do its best job to parse out a title, description, and image', }, { displayName: 'Additional Fields', @@ -107,12 +92,8 @@ export const postFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], + resource: ['post'], + operation: ['create'], }, }, default: {}, @@ -133,7 +114,8 @@ export const postFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -141,12 +123,8 @@ export const postFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'getAll', - ], + resource: ['post'], + operation: ['getAll'], }, }, }, @@ -156,12 +134,8 @@ export const postFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'post', - ], + operation: ['getAll'], + resource: ['post'], }, }, default: false, @@ -173,15 +147,9 @@ export const postFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'post', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['post'], + returnAll: [false], }, }, typeOptions: { @@ -199,12 +167,8 @@ export const postFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'getAll', - ], + resource: ['post'], + operation: ['getAll'], }, }, options: [ @@ -225,7 +189,8 @@ export const postFields: INodeProperties[] = [ displayName: 'Workspace Name or ID', name: 'workspaceId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getWorkspaces', }, @@ -233,12 +198,8 @@ export const postFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'delete', - ], + resource: ['post'], + operation: ['delete'], }, }, }, @@ -250,12 +211,8 @@ export const postFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'delete', - ], + resource: ['post'], + operation: ['delete'], }, }, }, @@ -267,12 +224,8 @@ export const postFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'post', - ], + operation: ['delete'], + resource: ['post'], }, }, }, diff --git a/packages/nodes-base/nodes/Oura/GenericFunctions.ts b/packages/nodes-base/nodes/Oura/GenericFunctions.ts index 655dd273cc..0eefbd1041 100644 --- a/packages/nodes-base/nodes/Oura/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Oura/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,11 +7,7 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function ouraApiRequest( this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, @@ -24,7 +18,6 @@ export async function ouraApiRequest( uri?: string, option: IDataObject = {}, ) { - const credentials = await this.getCredentials('ouraApi'); let options: OptionsWithUri = { headers: { diff --git a/packages/nodes-base/nodes/Oura/Oura.node.ts b/packages/nodes-base/nodes/Oura/Oura.node.ts index fc5d37757d..343f1acf37 100644 --- a/packages/nodes-base/nodes/Oura/Oura.node.ts +++ b/packages/nodes-base/nodes/Oura/Oura.node.ts @@ -1,26 +1,12 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - ouraApiRequest, -} from './GenericFunctions'; +import { ouraApiRequest } from './GenericFunctions'; -import { - profileOperations, -} from './ProfileDescription'; +import { profileOperations } from './ProfileDescription'; -import { - summaryFields, - summaryOperations, -} from './SummaryDescription'; +import { summaryFields, summaryOperations } from './SummaryDescription'; import moment from 'moment'; @@ -79,9 +65,7 @@ export class Oura implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < length; i++) { - if (resource === 'profile') { - // ********************************************************************* // profile // ********************************************************************* @@ -89,17 +73,13 @@ export class Oura implements INodeType { // https://cloud.ouraring.com/docs/personal-info if (operation === 'get') { - // ---------------------------------- // profile: get // ---------------------------------- responseData = await ouraApiRequest.call(this, 'GET', '/userinfo'); - } - } else if (resource === 'summary') { - // ********************************************************************* // summary // ********************************************************************* @@ -108,7 +88,10 @@ export class Oura implements INodeType { const qs: IDataObject = {}; - const { start, end } = this.getNodeParameter('filters', i) as { start: string; end: string; }; + const { start, end } = this.getNodeParameter('filters', i) as { + start: string; + end: string; + }; const returnAll = this.getNodeParameter('returnAll', 0) as boolean; @@ -121,7 +104,6 @@ export class Oura implements INodeType { } if (operation === 'getActivity') { - // ---------------------------------- // profile: getActivity // ---------------------------------- @@ -133,9 +115,7 @@ export class Oura implements INodeType { const limit = this.getNodeParameter('limit', 0) as number; responseData = responseData.splice(0, limit); } - } else if (operation === 'getReadiness') { - // ---------------------------------- // profile: getReadiness // ---------------------------------- @@ -147,9 +127,7 @@ export class Oura implements INodeType { const limit = this.getNodeParameter('limit', 0) as number; responseData = responseData.splice(0, limit); } - } else if (operation === 'getSleep') { - // ---------------------------------- // profile: getSleep // ---------------------------------- @@ -161,15 +139,12 @@ export class Oura implements INodeType { const limit = this.getNodeParameter('limit', 0) as number; responseData = responseData.splice(0, limit); } - } - } Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Oura/ProfileDescription.ts b/packages/nodes-base/nodes/Oura/ProfileDescription.ts index 4ca4c0f597..616832afdc 100644 --- a/packages/nodes-base/nodes/Oura/ProfileDescription.ts +++ b/packages/nodes-base/nodes/Oura/ProfileDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const profileOperations: INodeProperties[] = [ { @@ -10,16 +8,14 @@ export const profileOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'profile', - ], + resource: ['profile'], }, }, options: [ { name: 'Get', value: 'get', - description: 'Get the user\'s personal information', + description: "Get the user's personal information", action: 'Get a profile', }, ], diff --git a/packages/nodes-base/nodes/Oura/SummaryDescription.ts b/packages/nodes-base/nodes/Oura/SummaryDescription.ts index d7e0b044f0..a02e045264 100644 --- a/packages/nodes-base/nodes/Oura/SummaryDescription.ts +++ b/packages/nodes-base/nodes/Oura/SummaryDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const summaryOperations: INodeProperties[] = [ { @@ -10,28 +8,26 @@ export const summaryOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'summary', - ], + resource: ['summary'], }, }, options: [ { name: 'Get Activity Summary', value: 'getActivity', - description: 'Get the user\'s activity summary', + description: "Get the user's activity summary", action: 'Get activity summary', }, { name: 'Get Readiness Summary', value: 'getReadiness', - description: 'Get the user\'s readiness summary', + description: "Get the user's readiness summary", action: 'Get readiness summary', }, { name: 'Get Sleep Periods', value: 'getSleep', - description: 'Get the user\'s sleep summary', + description: "Get the user's sleep summary", action: 'Get sleep summary', }, ], @@ -46,9 +42,7 @@ export const summaryFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'summary', - ], + resource: ['summary'], }, }, default: false, @@ -60,12 +54,8 @@ export const summaryFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'summary', - ], - returnAll: [ - false, - ], + resource: ['summary'], + returnAll: [false], }, }, typeOptions: { @@ -82,9 +72,7 @@ export const summaryFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'summary', - ], + resource: ['summary'], }, }, default: {}, @@ -94,7 +82,8 @@ export const summaryFields: INodeProperties[] = [ name: 'end', type: 'dateTime', default: '', - description: 'End date for the summary retrieval. If omitted, it defaults to the current day.', + description: + 'End date for the summary retrieval. If omitted, it defaults to the current day.', }, { displayName: 'Start Date', diff --git a/packages/nodes-base/nodes/Paddle/CouponDescription.ts b/packages/nodes-base/nodes/Paddle/CouponDescription.ts index 0aeed2eb36..4c89abe2a6 100644 --- a/packages/nodes-base/nodes/Paddle/CouponDescription.ts +++ b/packages/nodes-base/nodes/Paddle/CouponDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const couponOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const couponOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'coupon', - ], + resource: ['coupon'], }, }, options: [ @@ -49,19 +45,14 @@ export const couponFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - `create`, - ], - jsonParameters: [ - false, - ], + resource: ['coupon'], + operation: [`create`], + jsonParameters: [false], }, }, default: 'checkout', - description: 'Either product (valid for specified products or subscription plans) or checkout (valid for any checkout)', + description: + 'Either product (valid for specified products or subscription plans) or checkout (valid for any checkout)', options: [ { name: 'Checkout', @@ -82,22 +73,15 @@ export const couponFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - `create`, - ], - couponType: [ - 'product', - ], - jsonParameters: [ - false, - ], + resource: ['coupon'], + operation: [`create`], + couponType: ['product'], + jsonParameters: [false], }, }, default: [], - description: 'Comma-separated list of product IDs. Required if coupon_type is product. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated list of product IDs. Required if coupon_type is product. Choose from the list, or specify IDs using an expression.', required: true, }, { @@ -106,15 +90,9 @@ export const couponFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - `create`, - ], - jsonParameters: [ - false, - ], + resource: ['coupon'], + operation: [`create`], + jsonParameters: [false], }, }, default: 'flat', @@ -141,18 +119,10 @@ export const couponFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - `create`, - ], - discountType: [ - 'flat', - ], - jsonParameters: [ - false, - ], + resource: ['coupon'], + operation: [`create`], + discountType: ['flat'], + jsonParameters: [false], }, }, }, @@ -168,18 +138,10 @@ export const couponFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - `create`, - ], - discountType: [ - 'percentage', - ], - jsonParameters: [ - false, - ], + resource: ['coupon'], + operation: [`create`], + discountType: ['percentage'], + jsonParameters: [false], }, }, }, @@ -297,18 +259,10 @@ export const couponFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - `create`, - ], - discountType: [ - 'flat', - ], - jsonParameters: [ - false, - ], + resource: ['coupon'], + operation: [`create`], + discountType: ['flat'], + jsonParameters: [false], }, }, }, @@ -319,12 +273,8 @@ export const couponFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - 'create', - ], + resource: ['coupon'], + operation: ['create'], }, }, }, @@ -338,15 +288,9 @@ export const couponFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['coupon'], + operation: ['create'], + jsonParameters: [true], }, }, description: 'Attributes in JSON form', @@ -358,15 +302,9 @@ export const couponFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['coupon'], + operation: ['create'], + jsonParameters: [false], }, }, default: {}, @@ -376,7 +314,8 @@ export const couponFields: INodeProperties[] = [ name: 'allowedUses', type: 'number', default: 1, - description: 'Number of times a coupon can be used in a checkout. This will be set to 999,999 by default, if not specified.', + description: + 'Number of times a coupon can be used in a checkout. This will be set to 999,999 by default, if not specified.', }, { displayName: 'Coupon Code', @@ -430,7 +369,8 @@ export const couponFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'If the coupon is used on subscription products, this indicates whether the discount should apply to recurring payments after the initial purchase', + description: + 'If the coupon is used on subscription products, this indicates whether the discount should apply to recurring payments after the initial purchase', }, ], }, @@ -443,12 +383,8 @@ export const couponFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - `getAll`, - ], + resource: ['coupon'], + operation: [`getAll`], }, }, default: '', @@ -461,12 +397,8 @@ export const couponFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'coupon', - ], + operation: ['getAll'], + resource: ['coupon'], }, }, default: false, @@ -478,15 +410,9 @@ export const couponFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'coupon', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['coupon'], + returnAll: [false], }, }, typeOptions: { @@ -505,15 +431,9 @@ export const couponFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - `update`, - ], - jsonParameters: [ - false, - ], + resource: ['coupon'], + operation: [`update`], + jsonParameters: [false], }, }, default: 'couponCode', @@ -535,18 +455,10 @@ export const couponFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - 'update', - ], - updateBy: [ - 'couponCode', - ], - jsonParameters: [ - false, - ], + resource: ['coupon'], + operation: ['update'], + updateBy: ['couponCode'], + jsonParameters: [false], }, }, default: '', @@ -558,18 +470,10 @@ export const couponFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - 'update', - ], - updateBy: [ - 'group', - ], - jsonParameters: [ - false, - ], + resource: ['coupon'], + operation: ['update'], + updateBy: ['group'], + jsonParameters: [false], }, }, default: '', @@ -582,12 +486,8 @@ export const couponFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - 'update', - ], + resource: ['coupon'], + operation: ['update'], }, }, }, @@ -601,15 +501,9 @@ export const couponFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['coupon'], + operation: ['update'], + jsonParameters: [true], }, }, description: 'Attributes in JSON form', @@ -621,15 +515,9 @@ export const couponFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - 'update', - ], - jsonParameters: [ - false, - ], + resource: ['coupon'], + operation: ['update'], + jsonParameters: [false], }, }, default: {}, @@ -639,7 +527,8 @@ export const couponFields: INodeProperties[] = [ name: 'allowedUses', type: 'number', default: 1, - description: 'Number of times a coupon can be used in a checkout. This will be set to 999,999 by default, if not specified.', + description: + 'Number of times a coupon can be used in a checkout. This will be set to 999,999 by default, if not specified.', }, { displayName: 'Discount', @@ -656,12 +545,11 @@ export const couponFields: INodeProperties[] = [ name: 'currency', type: 'options', default: 'EUR', - description: 'The currency must match the balance currency specified in your account', + description: + 'The currency must match the balance currency specified in your account', displayOptions: { show: { - discountType: [ - 'flat', - ], + discountType: ['flat'], }, }, options: [ @@ -779,9 +667,7 @@ export const couponFields: INodeProperties[] = [ description: 'Discount amount', displayOptions: { show: { - discountType: [ - 'flat', - ], + discountType: ['flat'], }, }, typeOptions: { @@ -796,9 +682,7 @@ export const couponFields: INodeProperties[] = [ description: 'Discount amount', displayOptions: { show: { - discountType: [ - 'percentage', - ], + discountType: ['percentage'], }, }, typeOptions: { @@ -857,7 +741,8 @@ export const couponFields: INodeProperties[] = [ name: 'productIds', type: 'string', default: '', - description: 'Comma-separated list of products e.g. 499531,1234,123546. If blank then remove associated products.', + description: + 'Comma-separated list of products e.g. 499531,1234,123546. If blank then remove associated products.', }, { displayName: 'Recurring', @@ -865,9 +750,9 @@ export const couponFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'If the coupon is used on subscription products, this indicates whether the discount should apply to recurring payments after the initial purchase', + description: + 'If the coupon is used on subscription products, this indicates whether the discount should apply to recurring payments after the initial purchase', }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Paddle/GenericFunctions.ts b/packages/nodes-base/nodes/Paddle/GenericFunctions.ts index 114ee978cb..128bbb64d7 100644 --- a/packages/nodes-base/nodes/Paddle/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Paddle/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -10,11 +8,23 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function paddleApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, endpoint: string, method: string, body: any = {}, query?: IDataObject, uri?: string): Promise { // tslint:disable-line:no-any +export async function paddleApiRequest( + this: + | IHookFunctions + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IWebhookFunctions, + endpoint: string, + method: string, + // tslint:disable-next-line:no-any + body: any = {}, + query?: IDataObject, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('paddleApi'); const productionUrl = 'https://vendors.paddle.com/api'; const sandboxUrl = 'https://sandbox-vendors.paddle.com/api'; @@ -46,8 +56,16 @@ export async function paddleApiRequest(this: IHookFunctions | IExecuteFunctions } } -export async function paddleApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, propertyName: string, endpoint: string, method: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function paddleApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions, + propertyName: string, + endpoint: string, + method: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -60,13 +78,15 @@ export async function paddleApiRequestAllItems(this: IHookFunctions | IExecuteFu returnData.push.apply(returnData, responseData[propertyName]); body.page++; } while ( - responseData[propertyName].length !== 0 && responseData[propertyName].length === body.results_per_page + responseData[propertyName].length !== 0 && + responseData[propertyName].length === body.results_per_page ); return returnData; } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); diff --git a/packages/nodes-base/nodes/Paddle/OrderDescription.ts b/packages/nodes-base/nodes/Paddle/OrderDescription.ts index ee0b0e5034..93cbb7ba27 100644 --- a/packages/nodes-base/nodes/Paddle/OrderDescription.ts +++ b/packages/nodes-base/nodes/Paddle/OrderDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const orderOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const orderOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'order', - ], + resource: ['order'], }, }, options: [ @@ -28,7 +24,6 @@ export const orderOperations: INodeProperties[] = [ ]; export const orderFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* order:get */ /* -------------------------------------------------------------------------- */ @@ -40,12 +35,8 @@ export const orderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'get', - ], + resource: ['order'], + operation: ['get'], }, }, description: 'The identifier of the buyer’s checkout', diff --git a/packages/nodes-base/nodes/Paddle/Paddle.node.ts b/packages/nodes-base/nodes/Paddle/Paddle.node.ts index fdfa11e200..3bfcc3cd30 100644 --- a/packages/nodes-base/nodes/Paddle/Paddle.node.ts +++ b/packages/nodes-base/nodes/Paddle/Paddle.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -13,36 +11,17 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - couponFields, - couponOperations, -} from './CouponDescription'; +import { couponFields, couponOperations } from './CouponDescription'; -import { - paddleApiRequest, - paddleApiRequestAllItems, - validateJSON -} from './GenericFunctions'; +import { paddleApiRequest, paddleApiRequestAllItems, validateJSON } from './GenericFunctions'; -import { - paymentFields, - paymentOperations, -} from './PaymentDescription'; +import { paymentFields, paymentOperations } from './PaymentDescription'; -import { - planFields, - planOperations, -} from './PlanDescription'; +import { planFields, planOperations } from './PlanDescription'; -import { - productFields, - productOperations, -} from './ProductDescription'; +import { productFields, productOperations } from './ProductDescription'; -import { - userFields, - userOperations, -} from './UserDescription'; +import { userFields, userOperations } from './UserDescription'; // import { // orderOperations, @@ -141,7 +120,9 @@ export class Paddle implements INodeType { // Alert user if there's no payments present to be loaded into payments property if (paymentResponse.response === undefined || paymentResponse.response.length === 0) { - throw new NodeApiError(this.getNode(), paymentResponse, { message: 'No payments on account.' }); + throw new NodeApiError(this.getNode(), paymentResponse, { + message: 'No payments on account.', + }); } for (const payment of paymentResponse.response) { @@ -197,16 +178,22 @@ export class Paddle implements INodeType { const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean; if (jsonParameters) { - const additionalFieldsJson = this.getNodeParameter('additionalFieldsJson', i) as string; + const additionalFieldsJson = this.getNodeParameter( + 'additionalFieldsJson', + i, + ) as string; if (additionalFieldsJson !== '') { if (validateJSON(additionalFieldsJson) !== undefined) { Object.assign(body, JSON.parse(additionalFieldsJson)); } else { - throw new NodeOperationError(this.getNode(), 'Additional fields must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Additional fields must be a valid JSON', + { itemIndex: i }, + ); } } - } else { const discountType = this.getNodeParameter('discountType', i) as string; const couponType = this.getNodeParameter('couponType', i) as string; @@ -236,7 +223,9 @@ export class Paddle implements INodeType { body.coupon_prefix = additionalFields.couponPrefix as string; } if (additionalFields.expires) { - body.expires = moment(additionalFields.expires as Date).format('YYYY-MM-DD') as string; + body.expires = moment(additionalFields.expires as Date).format( + 'YYYY-MM-DD', + ) as string; } if (additionalFields.group) { body.group = additionalFields.group as string; @@ -256,7 +245,9 @@ export class Paddle implements INodeType { const endpoint = '/2.1/product/create_coupon'; responseData = await paddleApiRequest.call(this, endpoint, 'POST', body); - responseData = responseData.response.coupon_codes.map((coupon : string) => ({coupon})); + responseData = responseData.response.coupon_codes.map((coupon: string) => ({ + coupon, + })); } } @@ -278,20 +269,25 @@ export class Paddle implements INodeType { } if (operation === 'update') { - const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean; if (jsonParameters) { - const additionalFieldsJson = this.getNodeParameter('additionalFieldsJson', i) as string; + const additionalFieldsJson = this.getNodeParameter( + 'additionalFieldsJson', + i, + ) as string; if (additionalFieldsJson !== '') { if (validateJSON(additionalFieldsJson) !== undefined) { Object.assign(body, JSON.parse(additionalFieldsJson)); } else { - throw new NodeOperationError(this.getNode(), 'Additional fields must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Additional fields must be a valid JSON', + { itemIndex: i }, + ); } } - } else { const updateBy = this.getNodeParameter('updateBy', i) as string; @@ -313,7 +309,9 @@ export class Paddle implements INodeType { body.new_coupon_code = additionalFields.newCouponCode as string; } if (additionalFields.expires) { - body.expires = moment(additionalFields.expires as Date).format('YYYY-MM-DD') as string; + body.expires = moment(additionalFields.expires as Date).format( + 'YYYY-MM-DD', + ) as string; } if (additionalFields.newGroup) { body.new_group = additionalFields.newGroup as string; @@ -333,12 +331,14 @@ export class Paddle implements INodeType { //@ts-ignore if (additionalFields.discount.discountProperties.discountType === 'percentage') { // @ts-ignore - body.discount_amount = additionalFields.discount.discountProperties.discountAmount as number; + body.discount_amount = additionalFields.discount.discountProperties + .discountAmount as number; } else { //@ts-ignore body.currency = additionalFields.discount.discountProperties.currency as string; //@ts-ignore - body.discount_amount = additionalFields.discount.discountProperties.discountAmount as number; + body.discount_amount = additionalFields.discount.discountProperties + .discountAmount as number; } } } @@ -355,16 +355,22 @@ export class Paddle implements INodeType { const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean; if (jsonParameters) { - const additionalFieldsJson = this.getNodeParameter('additionalFieldsJson', i) as string; + const additionalFieldsJson = this.getNodeParameter( + 'additionalFieldsJson', + i, + ) as string; if (additionalFieldsJson !== '') { if (validateJSON(additionalFieldsJson) !== undefined) { Object.assign(body, JSON.parse(additionalFieldsJson)); } else { - throw new NodeOperationError(this.getNode(), 'Additional fields must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Additional fields must be a valid JSON', + { itemIndex: i }, + ); } } - } else { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; @@ -472,18 +478,23 @@ export class Paddle implements INodeType { const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean; if (jsonParameters) { - const additionalFieldsJson = this.getNodeParameter('additionalFieldsJson', i) as string; + const additionalFieldsJson = this.getNodeParameter( + 'additionalFieldsJson', + i, + ) as string; if (additionalFieldsJson !== '') { if (validateJSON(additionalFieldsJson) !== undefined) { Object.assign(body, JSON.parse(additionalFieldsJson)); } else { - throw new NodeOperationError(this.getNode(), 'Additional fields must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Additional fields must be a valid JSON', + { itemIndex: i }, + ); } } - } else { - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (additionalFields.state) { @@ -500,7 +511,13 @@ export class Paddle implements INodeType { const endpoint = '/2.0/subscription/users'; if (returnAll) { - responseData = await paddleApiRequestAllItems.call(this, 'response', endpoint, 'POST', body); + responseData = await paddleApiRequestAllItems.call( + this, + 'response', + endpoint, + 'POST', + body, + ); } else { body.results_per_page = this.getNodeParameter('limit', i) as number; responseData = await paddleApiRequest.call(this, endpoint, 'POST', body); diff --git a/packages/nodes-base/nodes/Paddle/PaymentDescription.ts b/packages/nodes-base/nodes/Paddle/PaymentDescription.ts index 820cbd1666..59885a37ab 100644 --- a/packages/nodes-base/nodes/Paddle/PaymentDescription.ts +++ b/packages/nodes-base/nodes/Paddle/PaymentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const paymentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const paymentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'payment', - ], + resource: ['payment'], }, }, options: [ @@ -43,12 +39,8 @@ export const paymentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'payment', - ], + operation: ['getAll'], + resource: ['payment'], }, }, default: false, @@ -60,15 +52,9 @@ export const paymentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'payment', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['payment'], + returnAll: [false], }, }, typeOptions: { @@ -85,12 +71,8 @@ export const paymentFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'getAll', - ], + resource: ['payment'], + operation: ['getAll'], }, }, }, @@ -104,15 +86,9 @@ export const paymentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'getAll', - ], - jsonParameters: [ - true, - ], + resource: ['payment'], + operation: ['getAll'], + jsonParameters: [true], }, }, description: 'Attributes in JSON form', @@ -124,15 +100,9 @@ export const paymentFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'getAll', - ], - jsonParameters: [ - false, - ], + resource: ['payment'], + operation: ['getAll'], + jsonParameters: [false], }, }, default: {}, @@ -177,7 +147,8 @@ export const paymentFields: INodeProperties[] = [ name: 'state', type: 'options', default: 'active', - description: 'Filter: The user subscription status. Returns all active, past_due, trialing and paused subscription plans if not specified.', + description: + 'Filter: The user subscription status. Returns all active, past_due, trialing and paused subscription plans if not specified.', options: [ { name: 'Active', @@ -219,15 +190,12 @@ export const paymentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'reschedule', - ], + resource: ['payment'], + operation: ['reschedule'], }, }, - description: 'The upcoming subscription payment ID. Choose from the list, or specify an ID using an expression.', + description: + 'The upcoming subscription payment ID. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Date', @@ -236,12 +204,8 @@ export const paymentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'reschedule', - ], + resource: ['payment'], + operation: ['reschedule'], }, }, description: 'Date you want to move the payment to', diff --git a/packages/nodes-base/nodes/Paddle/PlanDescription.ts b/packages/nodes-base/nodes/Paddle/PlanDescription.ts index 058203faf9..d1db878cb3 100644 --- a/packages/nodes-base/nodes/Paddle/PlanDescription.ts +++ b/packages/nodes-base/nodes/Paddle/PlanDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const planOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const planOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'plan', - ], + resource: ['plan'], }, }, options: [ @@ -34,7 +30,6 @@ export const planOperations: INodeProperties[] = [ ]; export const planFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* plan:get */ /* -------------------------------------------------------------------------- */ @@ -46,12 +41,8 @@ export const planFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'plan', - ], - operation: [ - 'get', - ], + resource: ['plan'], + operation: ['get'], }, }, description: 'Filter: The subscription plan ID', @@ -62,12 +53,8 @@ export const planFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'plan', - ], + operation: ['getAll'], + resource: ['plan'], }, }, default: false, @@ -79,15 +66,9 @@ export const planFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'plan', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['plan'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Paddle/ProductDescription.ts b/packages/nodes-base/nodes/Paddle/ProductDescription.ts index 7d2816e9e5..0a39295e18 100644 --- a/packages/nodes-base/nodes/Paddle/ProductDescription.ts +++ b/packages/nodes-base/nodes/Paddle/ProductDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const productOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const productOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'product', - ], + resource: ['product'], }, }, options: [ @@ -34,12 +30,8 @@ export const productFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'product', - ], + operation: ['getAll'], + resource: ['product'], }, }, default: false, @@ -51,15 +43,9 @@ export const productFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'product', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['product'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Paddle/UserDescription.ts b/packages/nodes-base/nodes/Paddle/UserDescription.ts index 044b58fe55..d13b26a7ac 100644 --- a/packages/nodes-base/nodes/Paddle/UserDescription.ts +++ b/packages/nodes-base/nodes/Paddle/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -37,12 +33,8 @@ export const userFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, default: false, @@ -60,15 +52,9 @@ export const userFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['user'], + operation: ['getAll'], + returnAll: [false], }, }, description: 'Max number of results to return', @@ -80,12 +66,8 @@ export const userFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, }, @@ -99,15 +81,9 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - jsonParameters: [ - true, - ], + resource: ['user'], + operation: ['getAll'], + jsonParameters: [true], }, }, description: 'Attributes in JSON form', @@ -119,15 +95,9 @@ export const userFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - jsonParameters: [ - false, - ], + resource: ['user'], + operation: ['getAll'], + jsonParameters: [false], }, }, default: {}, @@ -151,7 +121,8 @@ export const userFields: INodeProperties[] = [ name: 'state', type: 'options', default: 'active', - description: 'Filter: The user subscription status. Returns all active, past_due, trialing and paused subscription plans if not specified.', + description: + 'Filter: The user subscription status. Returns all active, past_due, trialing and paused subscription plans if not specified.', options: [ { name: 'Active', diff --git a/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts b/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts index 629c6d83a7..969409ea3e 100644 --- a/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts @@ -1,11 +1,6 @@ -import { - OptionsWithUri, - } from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject, @@ -15,12 +10,19 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - snakeCase, -} from 'change-case'; - -export async function pagerDutyApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { snakeCase } from 'change-case'; +export async function pagerDutyApiRequest( + this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0); const options: OptionsWithUri = { @@ -61,8 +63,16 @@ export async function pagerDutyApiRequest(this: IExecuteFunctions | IWebhookFunc } } -export async function pagerDutyApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function pagerDutyApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -73,14 +83,12 @@ export async function pagerDutyApiRequestAllItems(this: IExecuteFunctions | ILoa responseData = await pagerDutyApiRequest.call(this, method, endpoint, body, query); query.offset++; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData.more - ); + } while (responseData.more); return returnData; } -export function keysToSnakeCase(elements: IDataObject[] | IDataObject) : IDataObject[] { +export function keysToSnakeCase(elements: IDataObject[] | IDataObject): IDataObject[] { if (!Array.isArray(elements)) { elements = [elements]; } diff --git a/packages/nodes-base/nodes/PagerDuty/IncidentDescription.ts b/packages/nodes-base/nodes/PagerDuty/IncidentDescription.ts index 0d18f81fa5..8ecb32219c 100644 --- a/packages/nodes-base/nodes/PagerDuty/IncidentDescription.ts +++ b/packages/nodes-base/nodes/PagerDuty/IncidentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const incidentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const incidentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'incident', - ], + resource: ['incident'], }, }, options: [ @@ -46,10 +42,9 @@ export const incidentOperations: INodeProperties[] = [ ]; export const incidentFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* incident:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* incident:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Title', name: 'title', @@ -58,12 +53,8 @@ export const incidentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'create', - ], + resource: ['incident'], + operation: ['create'], }, }, description: 'A succinct description of the nature, symptoms, cause, or effect of the incident', @@ -79,15 +70,12 @@ export const incidentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'create', - ], + resource: ['incident'], + operation: ['create'], }, }, - description: 'The incident will be created on this service. Choose from the list, or specify an ID using an expression.', + description: + 'The incident will be created on this service. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Email', @@ -98,12 +86,8 @@ export const incidentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'create', - ], + resource: ['incident'], + operation: ['create'], }, }, description: 'The email address of a valid user associated with the account making the request', @@ -115,12 +99,8 @@ export const incidentFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'create', - ], + resource: ['incident'], + operation: ['create'], }, }, default: {}, @@ -133,7 +113,8 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getEscalationPolicies', }, default: '', - description: 'Delegate this incident to the specified escalation policy. Cannot be specified if an assignee is given. Choose from the list, or specify an ID using an expression.', + description: + 'Delegate this incident to the specified escalation policy. Cannot be specified if an assignee is given. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Incident Details', @@ -147,7 +128,8 @@ export const incidentFields: INodeProperties[] = [ name: 'incidentKey', type: 'string', default: '', - description: 'Sending subsequent requests referencing the same service and with the same incident_key will result in those requests being rejected if an open incident matches that incident_key', + description: + 'Sending subsequent requests referencing the same service and with the same incident_key will result in those requests being rejected if an open incident matches that incident_key', }, { displayName: 'Priority Name or ID', @@ -157,7 +139,8 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getPriorities', }, default: '', - description: 'The incident will be created on this service. Choose from the list, or specify an ID using an expression.', + description: + 'The incident will be created on this service. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Urgency', @@ -188,12 +171,8 @@ export const incidentFields: INodeProperties[] = [ placeholder: 'Add Conference Bridge', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'create', - ], + resource: ['incident'], + operation: ['create'], }, }, default: {}, @@ -207,22 +186,24 @@ export const incidentFields: INodeProperties[] = [ name: 'conferenceNumber', type: 'string', default: '', - description: 'Phone numbers should be formatted like +1 415-555-1212,,,,1234#, where a comma (,) represents a one-second wait and pound (#) completes access code input', + description: + 'Phone numbers should be formatted like +1 415-555-1212,,,,1234#, where a comma (,) represents a one-second wait and pound (#) completes access code input', }, { displayName: 'Conference URL', name: 'conferenceUrl', type: 'string', default: '', - description: 'An URL for the conference bridge. This could be a link to a web conference or Slack channel.', + description: + 'An URL for the conference bridge. This could be a link to a web conference or Slack channel.', }, ], }, ], }, -/* -------------------------------------------------------------------------- */ -/* incident:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* incident:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Incident ID', name: 'incidentId', @@ -231,31 +212,23 @@ export const incidentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'get', - ], + resource: ['incident'], + operation: ['get'], }, }, description: 'Unique identifier for the incident', }, -/* -------------------------------------------------------------------------- */ -/* incident:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* incident:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'incident', - ], + operation: ['getAll'], + resource: ['incident'], }, }, default: false, @@ -267,15 +240,9 @@ export const incidentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'incident', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['incident'], + returnAll: [false], }, }, typeOptions: { @@ -293,12 +260,8 @@ export const incidentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'getAll', - ], + resource: ['incident'], + operation: ['getAll'], }, }, options: [ @@ -320,7 +283,8 @@ export const incidentFields: INodeProperties[] = [ name: 'incidentKey', type: 'string', default: '', - description: 'Incident de-duplication key. Incidents with child alerts do not have an incident key; querying by incident key will return incidents whose alerts have alert_key matching the given incident key.', + description: + 'Incident de-duplication key. Incidents with child alerts do not have an incident key; querying by incident key will return incidents whose alerts have alert_key matching the given incident key.', }, { displayName: 'Include', @@ -375,14 +339,16 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getServices', }, default: [], - description: 'Returns only the incidents associated with the passed service(s). Choose from the list, or specify IDs using an expression.', + description: + 'Returns only the incidents associated with the passed service(s). Choose from the list, or specify IDs using an expression.', }, { displayName: 'Since', name: 'since', type: 'dateTime', default: '', - description: 'The start of the date range over which you want to search. (the limit on date ranges is 6 months).', + description: + 'The start of the date range over which you want to search. (the limit on date ranges is 6 months).', }, { displayName: 'Sort By', @@ -390,7 +356,8 @@ export const incidentFields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'created_at:asc,resolved_at:desc', - description: 'Used to specify both the field you wish to sort the results on (incident_number/created_at/resolved_at/urgency), as well as the direction (asc/desc) of the results. The sort_by field and direction should be separated by a colon. A maximum of two fields can be included, separated by a comma.', + description: + 'Used to specify both the field you wish to sort the results on (incident_number/created_at/resolved_at/urgency), as well as the direction (asc/desc) of the results. The sort_by field and direction should be separated by a colon. A maximum of two fields can be included, separated by a comma.', }, { displayName: 'Statuses', @@ -418,7 +385,8 @@ export const incidentFields: INodeProperties[] = [ name: 'teamIds', type: 'string', default: '', - description: 'Team IDs. Only results related to these teams will be returned. Account must have the teams ability to use this parameter. (multiples IDs can be added separated by comma)', + description: + 'Team IDs. Only results related to these teams will be returned. Account must have the teams ability to use this parameter. (multiples IDs can be added separated by comma)', }, { displayName: 'Timezone Name or ID', @@ -428,14 +396,16 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getTimezones', }, default: '', - description: 'Time zone in which dates in the result will be rendered. If not set dates will return UTC. Choose from the list, or specify an ID using an expression.', + description: + 'Time zone in which dates in the result will be rendered. If not set dates will return UTC. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Until', name: 'until', type: 'dateTime', default: '', - description: 'The end of the date range over which you want to search. (the limit on date ranges is 6 months).', + description: + 'The end of the date range over which you want to search. (the limit on date ranges is 6 months).', }, { displayName: 'Urgencies', @@ -452,20 +422,22 @@ export const incidentFields: INodeProperties[] = [ }, ], default: [], - description: 'Urgencies of the incidents to be returned. Defaults to all urgencies. Account must have the urgencies ability to do this', + description: + 'Urgencies of the incidents to be returned. Defaults to all urgencies. Account must have the urgencies ability to do this', }, { displayName: 'User IDs', name: 'userIds', type: 'string', default: '', - description: 'Returns only the incidents currently assigned to the passed user(s). This expects one or more user IDs (multiple IDs can be added separated by comma).', + description: + 'Returns only the incidents currently assigned to the passed user(s). This expects one or more user IDs (multiple IDs can be added separated by comma).', }, ], }, -/* -------------------------------------------------------------------------- */ -/* incident:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* incident:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'Incident ID', name: 'incidentId', @@ -474,12 +446,8 @@ export const incidentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'update', - ], + resource: ['incident'], + operation: ['update'], }, }, description: 'Unique identifier for the incident', @@ -493,12 +461,8 @@ export const incidentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'update', - ], + resource: ['incident'], + operation: ['update'], }, }, description: 'The email address of a valid user associated with the account making the request', @@ -510,12 +474,8 @@ export const incidentFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'update', - ], + resource: ['incident'], + operation: ['update'], }, }, default: {}, @@ -538,7 +498,8 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getEscalationPolicies', }, default: '', - description: 'Delegate this incident to the specified escalation policy. Cannot be specified if an assignee is given. Choose from the list, or specify an ID using an expression.', + description: + 'Delegate this incident to the specified escalation policy. Cannot be specified if an assignee is given. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Priority Name or ID', @@ -548,7 +509,8 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getPriorities', }, default: '', - description: 'The incident will be created on this service. Choose from the list, or specify an ID using an expression.', + description: + 'The incident will be created on this service. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Resolution', @@ -582,7 +544,8 @@ export const incidentFields: INodeProperties[] = [ name: 'title', type: 'string', default: '', - description: 'A succinct description of the nature, symptoms, cause, or effect of the incident', + description: + 'A succinct description of the nature, symptoms, cause, or effect of the incident', }, { displayName: 'Urgency', @@ -613,12 +576,8 @@ export const incidentFields: INodeProperties[] = [ placeholder: 'Add Conference Bridge', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'update', - ], + resource: ['incident'], + operation: ['update'], }, }, default: {}, @@ -632,14 +591,16 @@ export const incidentFields: INodeProperties[] = [ name: 'conferenceNumber', type: 'string', default: '', - description: 'Phone numbers should be formatted like +1 415-555-1212,,,,1234#, where a comma (,) represents a one-second wait and pound (#) completes access code input', + description: + 'Phone numbers should be formatted like +1 415-555-1212,,,,1234#, where a comma (,) represents a one-second wait and pound (#) completes access code input', }, { displayName: 'Conference URL', name: 'conferenceUrl', type: 'string', default: '', - description: 'An URL for the conference bridge. This could be a link to a web conference or Slack channel.', + description: + 'An URL for the conference bridge. This could be a link to a web conference or Slack channel.', }, ], }, diff --git a/packages/nodes-base/nodes/PagerDuty/IncidentInterface.ts b/packages/nodes-base/nodes/PagerDuty/IncidentInterface.ts index d8dc0082ca..f6ff8eed30 100644 --- a/packages/nodes-base/nodes/PagerDuty/IncidentInterface.ts +++ b/packages/nodes-base/nodes/PagerDuty/IncidentInterface.ts @@ -1,6 +1,4 @@ -import { - IDataObject, -} from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export interface IIncident { assignments?: IDataObject[]; diff --git a/packages/nodes-base/nodes/PagerDuty/IncidentNoteDescription.ts b/packages/nodes-base/nodes/PagerDuty/IncidentNoteDescription.ts index ebce7c3c55..a7d0af4b52 100644 --- a/packages/nodes-base/nodes/PagerDuty/IncidentNoteDescription.ts +++ b/packages/nodes-base/nodes/PagerDuty/IncidentNoteDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const incidentNoteOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const incidentNoteOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'incidentNote', - ], + resource: ['incidentNote'], }, }, options: [ @@ -25,7 +21,7 @@ export const incidentNoteOperations: INodeProperties[] = [ { name: 'Get All', value: 'getAll', - description: 'Get all incident\'s notes', + description: "Get all incident's notes", action: 'Get all incident notes', }, ], @@ -34,10 +30,9 @@ export const incidentNoteOperations: INodeProperties[] = [ ]; export const incidentNoteFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* incidentNote:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* incidentNote:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Incident ID', name: 'incidentId', @@ -46,12 +41,8 @@ export const incidentNoteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'incidentNote', - ], - operation: [ - 'create', - ], + resource: ['incidentNote'], + operation: ['create'], }, }, description: 'Unique identifier for the incident', @@ -67,12 +58,8 @@ export const incidentNoteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'incidentNote', - ], - operation: [ - 'create', - ], + resource: ['incidentNote'], + operation: ['create'], }, }, description: 'The note content', @@ -86,19 +73,15 @@ export const incidentNoteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'incidentNote', - ], - operation: [ - 'create', - ], + resource: ['incidentNote'], + operation: ['create'], }, }, description: 'The email address of a valid user associated with the account making the request', }, -/* -------------------------------------------------------------------------- */ -/* incidentNote:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* incidentNote:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Incident ID', name: 'incidentId', @@ -107,12 +90,8 @@ export const incidentNoteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'incidentNote', - ], - operation: [ - 'getAll', - ], + resource: ['incidentNote'], + operation: ['getAll'], }, }, description: 'Unique identifier for the incident', @@ -123,12 +102,8 @@ export const incidentNoteFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'incidentNote', - ], + operation: ['getAll'], + resource: ['incidentNote'], }, }, default: false, @@ -140,15 +115,9 @@ export const incidentNoteFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'incidentNote', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['incidentNote'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/PagerDuty/LogEntryDescription.ts b/packages/nodes-base/nodes/PagerDuty/LogEntryDescription.ts index 3419ef8241..cce6155887 100644 --- a/packages/nodes-base/nodes/PagerDuty/LogEntryDescription.ts +++ b/packages/nodes-base/nodes/PagerDuty/LogEntryDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, - } from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const logEntryOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const logEntryOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'logEntry', - ], + resource: ['logEntry'], }, }, options: [ @@ -34,9 +30,9 @@ export const logEntryOperations: INodeProperties[] = [ ]; export const logEntryFields: INodeProperties[] = [ -/* -------------------------------------------------------------------------- */ -/* logEntry:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* logEntry:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Log Entry ID', name: 'logEntryId', @@ -45,31 +41,23 @@ export const logEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'logEntry', - ], - operation: [ - 'get', - ], + resource: ['logEntry'], + operation: ['get'], }, }, description: 'Unique identifier for the log entry', }, -/* -------------------------------------------------------------------------- */ -/* logEntry:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* logEntry:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'logEntry', - ], + operation: ['getAll'], + resource: ['logEntry'], }, }, default: false, @@ -81,15 +69,9 @@ export const logEntryFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'logEntry', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['logEntry'], + returnAll: [false], }, }, typeOptions: { @@ -107,12 +89,8 @@ export const logEntryFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'logEntry', - ], - operation: [ - 'getAll', - ], + resource: ['logEntry'], + operation: ['getAll'], }, }, options: [ @@ -146,14 +124,16 @@ export const logEntryFields: INodeProperties[] = [ name: 'isOverview', type: 'boolean', default: false, - description: 'Whether to return a subset of log entries that show only the most important changes to the incident', + description: + 'Whether to return a subset of log entries that show only the most important changes to the incident', }, { displayName: 'Since', name: 'since', type: 'dateTime', default: '', - description: 'The start of the date range over which you want to search. (the limit on date ranges is 6 months).', + description: + 'The start of the date range over which you want to search. (the limit on date ranges is 6 months).', }, { displayName: 'Timezone Name or ID', @@ -163,14 +143,16 @@ export const logEntryFields: INodeProperties[] = [ loadOptionsMethod: 'getTimezones', }, default: '', - description: 'Time zone in which dates in the result will be rendered. If not set dates will return UTC. Choose from the list, or specify an ID using an expression.', + description: + 'Time zone in which dates in the result will be rendered. If not set dates will return UTC. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Until', name: 'until', type: 'dateTime', default: '', - description: 'The end of the date range over which you want to search. (the limit on date ranges is 6 months).', + description: + 'The end of the date range over which you want to search. (the limit on date ranges is 6 months).', }, ], }, diff --git a/packages/nodes-base/nodes/PagerDuty/PagerDuty.node.ts b/packages/nodes-base/nodes/PagerDuty/PagerDuty.node.ts index 0752068b5f..cc9c7d0e5c 100644 --- a/packages/nodes-base/nodes/PagerDuty/PagerDuty.node.ts +++ b/packages/nodes-base/nodes/PagerDuty/PagerDuty.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -17,33 +15,17 @@ import { pagerDutyApiRequestAllItems, } from './GenericFunctions'; -import { - incidentFields, - incidentOperations, -} from './IncidentDescription'; +import { incidentFields, incidentOperations } from './IncidentDescription'; -import { - incidentNoteFields, - incidentNoteOperations, -} from './IncidentNoteDescription'; +import { incidentNoteFields, incidentNoteOperations } from './IncidentNoteDescription'; -import { - logEntryFields, - logEntryOperations, -} from './LogEntryDescription'; +import { logEntryFields, logEntryOperations } from './LogEntryDescription'; -import { - userFields, - userOperations, -} from './UserDescription'; +import { userFields, userOperations } from './UserDescription'; -import { - IIncident, -} from './IncidentInterface'; +import { IIncident } from './IncidentInterface'; -import { - snakeCase, -} from 'change-case'; +import { snakeCase } from 'change-case'; import moment from 'moment-timezone'; @@ -67,9 +49,7 @@ export class PagerDuty implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'apiToken', - ], + authentication: ['apiToken'], }, }, }, @@ -78,9 +58,7 @@ export class PagerDuty implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -148,7 +126,12 @@ export class PagerDuty implements INodeType { // select them easily async getEscalationPolicies(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const escalationPolicies = await pagerDutyApiRequestAllItems.call(this, 'escalation_policies', 'GET', '/escalation_policies'); + const escalationPolicies = await pagerDutyApiRequestAllItems.call( + this, + 'escalation_policies', + 'GET', + '/escalation_policies', + ); for (const escalationPolicy of escalationPolicies) { const escalationPolicyName = escalationPolicy.name; const escalationPolicyId = escalationPolicy.id; @@ -163,7 +146,12 @@ export class PagerDuty implements INodeType { // select them easily async getPriorities(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const priorities = await pagerDutyApiRequestAllItems.call(this, 'priorities', 'GET', '/priorities'); + const priorities = await pagerDutyApiRequestAllItems.call( + this, + 'priorities', + 'GET', + '/priorities', + ); for (const priority of priorities) { const priorityName = priority.name; const priorityId = priority.id; @@ -180,7 +168,12 @@ export class PagerDuty implements INodeType { // select them easily async getServices(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const services = await pagerDutyApiRequestAllItems.call(this, 'services', 'GET', '/services'); + const services = await pagerDutyApiRequestAllItems.call( + this, + 'services', + 'GET', + '/services', + ); for (const service of services) { const serviceName = service.name; const serviceId = service.id; @@ -225,7 +218,8 @@ export class PagerDuty implements INodeType { const serviceId = this.getNodeParameter('serviceId', i) as string; const email = this.getNodeParameter('email', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - const conferenceBridge = (this.getNodeParameter('conferenceBridgeUi', i) as IDataObject).conferenceBridgeValues as IDataObject; + const conferenceBridge = (this.getNodeParameter('conferenceBridgeUi', i) as IDataObject) + .conferenceBridgeValues as IDataObject; const body: IIncident = { type: 'incident', title, @@ -264,7 +258,15 @@ export class PagerDuty implements INodeType { conference_url: conferenceBridge.conferenceUrl, }; } - responseData = await pagerDutyApiRequest.call(this, 'POST', '/incidents', { incident: body }, {}, undefined, { from: email }); + responseData = await pagerDutyApiRequest.call( + this, + 'POST', + '/incidents', + { incident: body }, + {}, + undefined, + { from: email }, + ); responseData = responseData.incident; } //https://api-reference.pagerduty.com/#!/Incidents/get_incidents_id @@ -291,7 +293,14 @@ export class PagerDuty implements INodeType { } Object.assign(qs, keysToSnakeCase(options)[0]); if (returnAll) { - responseData = await pagerDutyApiRequestAllItems.call(this, 'incidents', 'GET', '/incidents', {}, qs); + responseData = await pagerDutyApiRequestAllItems.call( + this, + 'incidents', + 'GET', + '/incidents', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; responseData = await pagerDutyApiRequest.call(this, 'GET', '/incidents', {}, qs); @@ -302,7 +311,8 @@ export class PagerDuty implements INodeType { if (operation === 'update') { const incidentId = this.getNodeParameter('incidentId', i) as string; const email = this.getNodeParameter('email', i) as string; - const conferenceBridge = (this.getNodeParameter('conferenceBridgeUi', i) as IDataObject).conferenceBridgeValues as IDataObject; + const conferenceBridge = (this.getNodeParameter('conferenceBridgeUi', i) as IDataObject) + .conferenceBridgeValues as IDataObject; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const body: IIncident = { type: 'incident', @@ -346,7 +356,15 @@ export class PagerDuty implements INodeType { conference_url: conferenceBridge.conferenceUrl, }; } - responseData = await pagerDutyApiRequest.call(this, 'PUT', `/incidents/${incidentId}`, { incident: body }, {}, undefined, { from: email }); + responseData = await pagerDutyApiRequest.call( + this, + 'PUT', + `/incidents/${incidentId}`, + { incident: body }, + {}, + undefined, + { from: email }, + ); responseData = responseData.incident; } } @@ -359,17 +377,38 @@ export class PagerDuty implements INodeType { const body: IDataObject = { content, }; - responseData = await pagerDutyApiRequest.call(this, 'POST', `/incidents/${incidentId}/notes`, { note: body }, {}, undefined, { from: email }); + responseData = await pagerDutyApiRequest.call( + this, + 'POST', + `/incidents/${incidentId}/notes`, + { note: body }, + {}, + undefined, + { from: email }, + ); } //https://api-reference.pagerduty.com/#!/Incidents/get_incidents_id_notes if (operation === 'getAll') { const incidentId = this.getNodeParameter('incidentId', i) as string; const returnAll = this.getNodeParameter('returnAll', 0) as boolean; if (returnAll) { - responseData = await pagerDutyApiRequestAllItems.call(this, 'notes', 'GET', `/incidents/${incidentId}/notes`, {}, qs); + responseData = await pagerDutyApiRequestAllItems.call( + this, + 'notes', + 'GET', + `/incidents/${incidentId}/notes`, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; - responseData = await pagerDutyApiRequest.call(this, 'GET', `/incidents/${incidentId}/notes`, {}, qs); + responseData = await pagerDutyApiRequest.call( + this, + 'GET', + `/incidents/${incidentId}/notes`, + {}, + qs, + ); responseData = responseData.notes; } } @@ -378,7 +417,11 @@ export class PagerDuty implements INodeType { //https://api-reference.pagerduty.com/#!/Log_Entries/get_log_entries_id if (operation === 'get') { const logEntryId = this.getNodeParameter('logEntryId', i) as string; - responseData = await pagerDutyApiRequest.call(this, 'GET', `/log_entries/${logEntryId}`); + responseData = await pagerDutyApiRequest.call( + this, + 'GET', + `/log_entries/${logEntryId}`, + ); responseData = responseData.log_entry; } //https://api-reference.pagerduty.com/#!/Log_Entries/get_log_entries @@ -388,7 +431,14 @@ export class PagerDuty implements INodeType { keysToSnakeCase(qs); const returnAll = this.getNodeParameter('returnAll', 0) as boolean; if (returnAll) { - responseData = await pagerDutyApiRequestAllItems.call(this, 'log_entries', 'GET', '/log_entries', {}, qs); + responseData = await pagerDutyApiRequestAllItems.call( + this, + 'log_entries', + 'GET', + '/log_entries', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; responseData = await pagerDutyApiRequest.call(this, 'GET', '/log_entries', {}, qs); diff --git a/packages/nodes-base/nodes/PagerDuty/UserDescription.ts b/packages/nodes-base/nodes/PagerDuty/UserDescription.ts index ea5dc515c7..ae7fcfe57c 100644 --- a/packages/nodes-base/nodes/PagerDuty/UserDescription.ts +++ b/packages/nodes-base/nodes/PagerDuty/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, - } from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -28,9 +24,9 @@ export const userOperations: INodeProperties[] = [ ]; export const userFields: INodeProperties[] = [ -/* -------------------------------------------------------------------------- */ -/* user:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'User ID', name: 'userId', @@ -39,12 +35,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, description: 'Unique identifier for the user', diff --git a/packages/nodes-base/nodes/PayPal/GenericFunctions.ts b/packages/nodes-base/nodes/PayPal/GenericFunctions.ts index ce9b7b0e23..b17990f6f4 100644 --- a/packages/nodes-base/nodes/PayPal/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PayPal/GenericFunctions.ts @@ -9,17 +9,30 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; - -export async function payPalApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, endpoint: string, method: string, body: any = {}, query?: IDataObject, uri?: string): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; +export async function payPalApiRequest( + this: + | IHookFunctions + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IWebhookFunctions, + endpoint: string, + method: string, + // tslint:disable-next-line:no-any + body: any = {}, + query?: IDataObject, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('payPalApi'); const env = getEnvironment(credentials.env as string); - const tokenInfo = await getAccessToken.call(this); - const headerWithAuthentication = Object.assign({ }, - { Authorization: `Bearer ${tokenInfo.access_token}`, 'Content-Type': 'application/json' }); + const tokenInfo = await getAccessToken.call(this); + const headerWithAuthentication = Object.assign( + {}, + { Authorization: `Bearer ${tokenInfo.access_token}`, 'Content-Type': 'application/json' }, + ); const options = { headers: headerWithAuthentication, method, @@ -38,26 +51,38 @@ export async function payPalApiRequest(this: IHookFunctions | IExecuteFunctions function getEnvironment(env: string): string { // @ts-ignore return { - 'sanbox': 'https://api-m.sandbox.paypal.com', - 'live': 'https://api-m.paypal.com', + sanbox: 'https://api-m.sandbox.paypal.com', + live: 'https://api-m.paypal.com', }[env]; } -async function getAccessToken(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions): Promise { // tslint:disable-line:no-any +async function getAccessToken( + this: + | IHookFunctions + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IWebhookFunctions, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('payPalApi'); const env = getEnvironment(credentials!.env as string); - const data = Buffer.from(`${credentials!.clientId}:${credentials!.secret}`).toString(BINARY_ENCODING); - const headerWithAuthentication = Object.assign({}, - { Authorization: `Basic ${data}`, 'Content-Type': 'application/x-www-form-urlencoded' }); - const options: OptionsWithUri = { - headers: headerWithAuthentication, - method: 'POST', - form: { - grant_type: 'client_credentials', - }, - uri: `${env}/v1/oauth2/token`, - json: true, - }; + const data = Buffer.from(`${credentials!.clientId}:${credentials!.secret}`).toString( + BINARY_ENCODING, + ); + const headerWithAuthentication = Object.assign( + {}, + { Authorization: `Basic ${data}`, 'Content-Type': 'application/x-www-form-urlencoded' }, + ); + const options: OptionsWithUri = { + headers: headerWithAuthentication, + method: 'POST', + form: { + grant_type: 'client_credentials', + }, + uri: `${env}/v1/oauth2/token`, + json: true, + }; try { return await this.helpers.request!(options); } catch (error) { @@ -69,8 +94,17 @@ async function getAccessToken(this: IHookFunctions | IExecuteFunctions | IExecut * Make an API request to paginated paypal endpoint * and return all results */ -export async function payPalApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, propertyName: string, endpoint: string, method: string, body: any = {}, query?: IDataObject, uri?: string): Promise { // tslint:disable-line:no-any - +export async function payPalApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + propertyName: string, + endpoint: string, + method: string, + // tslint:disable-next-line:no-any + body: any = {}, + query?: IDataObject, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -81,9 +115,7 @@ export async function payPalApiRequestAllItems(this: IHookFunctions | IExecuteFu responseData = await payPalApiRequest.call(this, endpoint, method, body, query, uri); uri = getNext(responseData.links); returnData.push.apply(returnData, responseData[propertyName]); - } while ( - getNext(responseData.links) !== undefined - ); + } while (getNext(responseData.links) !== undefined); return returnData; } @@ -97,7 +129,8 @@ function getNext(links: IDataObject[]): string | undefined { return undefined; } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); @@ -108,7 +141,10 @@ export function validateJSON(json: string | undefined): any { // tslint:disable- } export function upperFist(s: string): string { - return s.split('.').map(e => { - return e.toLowerCase().charAt(0).toUpperCase() + e.toLowerCase().slice(1); - }).join(' '); + return s + .split('.') + .map((e) => { + return e.toLowerCase().charAt(0).toUpperCase() + e.toLowerCase().slice(1); + }) + .join(' '); } diff --git a/packages/nodes-base/nodes/PayPal/PayPal.node.ts b/packages/nodes-base/nodes/PayPal/PayPal.node.ts index e6ca3a5c56..6b6235292c 100644 --- a/packages/nodes-base/nodes/PayPal/PayPal.node.ts +++ b/packages/nodes-base/nodes/PayPal/PayPal.node.ts @@ -1,9 +1,5 @@ -import { - OptionsWithUri -} from 'request'; -import { - IExecuteFunctions, -} from 'n8n-core'; +import { OptionsWithUri } from 'request'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, ICredentialTestFunctions, @@ -27,12 +23,8 @@ import { ISenderBatchHeader, RecipientType, RecipientWallet, - } from './PaymentInteface'; -import { - payPalApiRequest, - payPalApiRequestAllItems, - validateJSON, - } from './GenericFunctions'; +} from './PaymentInteface'; +import { payPalApiRequest, payPalApiRequestAllItems, validateJSON } from './GenericFunctions'; export class PayPal implements INodeType { description: INodeTypeDescription = { @@ -84,7 +76,10 @@ export class PayPal implements INodeType { methods = { credentialTest: { - async payPalApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { + async payPalApiTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { const credentials = credential.data; const clientId = credentials!.clientId; const clientSecret = credentials!.secret; @@ -108,7 +103,7 @@ export class PayPal implements INodeType { const options: OptionsWithUri = { headers: { - 'Authorization': `Basic ${base64Key}`, + Authorization: `Basic ${base64Key}`, }, method: 'POST', uri: `${baseUrl}/v1/oauth2/token`, @@ -123,8 +118,7 @@ export class PayPal implements INodeType { status: 'OK', message: 'Authentication successful!', }; - } - catch (error) { + } catch (error) { return { status: 'Error', message: `Connection details not valid: ${error.message}`, @@ -166,51 +160,78 @@ export class PayPal implements INodeType { body.sender_batch_header = header; if (!jsonActive) { const payoutItems: IItem[] = []; - const itemsValues = (this.getNodeParameter('itemsUi', i) as IDataObject).itemsValues as IDataObject[]; + const itemsValues = (this.getNodeParameter('itemsUi', i) as IDataObject) + .itemsValues as IDataObject[]; if (itemsValues && itemsValues.length > 0) { - itemsValues.forEach(o => { + itemsValues.forEach((o) => { const payoutItem: IItem = {}; const amount: IAmount = {}; amount.currency = o.currency as string; amount.value = parseFloat(o.amount as string); payoutItem.amount = amount; - payoutItem.note = o.note as string || ''; + payoutItem.note = (o.note as string) || ''; payoutItem.receiver = o.receiverValue as string; payoutItem.recipient_type = o.recipientType as RecipientType; payoutItem.recipient_wallet = o.recipientWallet as RecipientWallet; - payoutItem.sender_item_id = o.senderItemId as string || ''; + payoutItem.sender_item_id = (o.senderItemId as string) || ''; payoutItems.push(payoutItem); }); body.items = payoutItems; } else { - throw new NodeOperationError(this.getNode(), 'You must have at least one item.', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'You must have at least one item.', { + itemIndex: i, + }); } } else { const itemsJson = validateJSON(this.getNodeParameter('itemsJson', i) as string); body.items = itemsJson; } responseData = await payPalApiRequest.call(this, '/payments/payouts', 'POST', body); - } if (operation === 'get') { const payoutBatchId = this.getNodeParameter('payoutBatchId', i) as string; const returnAll = this.getNodeParameter('returnAll', 0) as boolean; if (returnAll === true) { - responseData = await payPalApiRequestAllItems.call(this, 'items', `/payments/payouts/${payoutBatchId}`, 'GET', {}, qs); + responseData = await payPalApiRequestAllItems.call( + this, + 'items', + `/payments/payouts/${payoutBatchId}`, + 'GET', + {}, + qs, + ); } else { qs.page_size = this.getNodeParameter('limit', i) as number; - responseData = await payPalApiRequest.call(this, `/payments/payouts/${payoutBatchId}`, 'GET', {}, qs); + responseData = await payPalApiRequest.call( + this, + `/payments/payouts/${payoutBatchId}`, + 'GET', + {}, + qs, + ); responseData = responseData.items; } } } else if (resource === 'payoutItem') { if (operation === 'get') { const payoutItemId = this.getNodeParameter('payoutItemId', i) as string; - responseData = await payPalApiRequest.call(this,`/payments/payouts-item/${payoutItemId}`, 'GET', {}, qs); + responseData = await payPalApiRequest.call( + this, + `/payments/payouts-item/${payoutItemId}`, + 'GET', + {}, + qs, + ); } if (operation === 'cancel') { const payoutItemId = this.getNodeParameter('payoutItemId', i) as string; - responseData = await payPalApiRequest.call(this,`/payments/payouts-item/${payoutItemId}/cancel`, 'POST', {}, qs); + responseData = await payPalApiRequest.call( + this, + `/payments/payouts-item/${payoutItemId}/cancel`, + 'POST', + {}, + qs, + ); } } if (Array.isArray(responseData)) { @@ -227,6 +248,5 @@ export class PayPal implements INodeType { } } return [this.helpers.returnJsonArray(returnData)]; - } } diff --git a/packages/nodes-base/nodes/PayPal/PayPalTrigger.node.ts b/packages/nodes-base/nodes/PayPal/PayPalTrigger.node.ts index fa9e675e10..3db5263983 100644 --- a/packages/nodes-base/nodes/PayPal/PayPalTrigger.node.ts +++ b/packages/nodes-base/nodes/PayPal/PayPalTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -13,10 +10,7 @@ import { NodeApiError, NodeOperationError, } from 'n8n-workflow'; -import { - payPalApiRequest, - upperFist -} from './GenericFunctions'; +import { payPalApiRequest, upperFist } from './GenericFunctions'; export class PayPalTrigger implements INodeType { description: INodeTypeDescription = { @@ -52,7 +46,8 @@ export class PayPalTrigger implements INodeType { type: 'multiOptions', required: true, default: [], - description: 'The event to listen to. Choose from the list, or specify IDs using an expression.', + description: + 'The event to listen to. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getEvents', }, @@ -125,7 +120,7 @@ export class PayPalTrigger implements INodeType { const events = this.getNodeParameter('events', []) as string[]; const body = { url: webhookUrl, - event_types: events.map(event => { + event_types: events.map((event) => { return { name: event }; }), }; @@ -168,11 +163,13 @@ export class PayPalTrigger implements INodeType { const headerData = this.getHeaderData() as IDataObject; const endpoint = '/notifications/verify-webhook-signature'; - if (headerData['PAYPAL-AUTH-ALGO'] !== undefined - && headerData['PAYPAL-CERT-URL'] !== undefined - && headerData['PAYPAL-TRANSMISSION-ID'] !== undefined - && headerData['PAYPAL-TRANSMISSION-SIG'] !== undefined - && headerData['PAYPAL-TRANSMISSION-TIME'] !== undefined) { + if ( + headerData['PAYPAL-AUTH-ALGO'] !== undefined && + headerData['PAYPAL-CERT-URL'] !== undefined && + headerData['PAYPAL-TRANSMISSION-ID'] !== undefined && + headerData['PAYPAL-TRANSMISSION-SIG'] !== undefined && + headerData['PAYPAL-TRANSMISSION-TIME'] !== undefined + ) { const body = { auth_algo: headerData['PAYPAL-AUTH-ALGO'], cert_url: headerData['PAYPAL-CERT-URL'], @@ -194,9 +191,7 @@ export class PayPalTrigger implements INodeType { return {}; } return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/PayPal/PaymentDescription.ts b/packages/nodes-base/nodes/PayPal/PaymentDescription.ts index 16ef435531..73fa344377 100644 --- a/packages/nodes-base/nodes/PayPal/PaymentDescription.ts +++ b/packages/nodes-base/nodes/PayPal/PaymentDescription.ts @@ -8,9 +8,7 @@ export const payoutOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'payout', - ], + resource: ['payout'], }, }, options: [ @@ -32,10 +30,9 @@ export const payoutOperations: INodeProperties[] = [ ]; export const payoutFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* payout:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* payout:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Sender Batch ID', @@ -44,12 +41,8 @@ export const payoutFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'payout', - ], - operation: [ - 'create', - ], + resource: ['payout'], + operation: ['create'], }, }, default: '', @@ -62,12 +55,8 @@ export const payoutFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'payout', - ], - operation: [ - 'create', - ], + resource: ['payout'], + operation: ['create'], }, }, }, @@ -78,15 +67,9 @@ export const payoutFields: INodeProperties[] = [ type: 'fixedCollection', displayOptions: { show: { - resource: [ - 'payout', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['payout'], + operation: ['create'], + jsonParameters: [false], }, }, typeOptions: { @@ -128,7 +111,8 @@ export const payoutFields: INodeProperties[] = [ type: 'string', required: true, default: '', - description: 'The receiver of the payment. Corresponds to the recipient_type value in the request. Max length: 127 characters.', + description: + 'The receiver of the payment. Corresponds to the recipient_type value in the request. Max length: 127 characters.', }, { displayName: 'Currency', @@ -179,14 +163,16 @@ export const payoutFields: INodeProperties[] = [ name: 'note', type: 'string', default: '', - description: 'The sender-specified note for notifications. Supports up to 4000 ASCII characters and 1000 non-ASCII characters.', + description: + 'The sender-specified note for notifications. Supports up to 4000 ASCII characters and 1000 non-ASCII characters.', }, { displayName: 'Sender Item ID', name: 'senderItemId', type: 'string', default: '', - description: 'The sender-specified ID number. Tracks the payout in an accounting system.', + description: + 'The sender-specified ID number. Tracks the payout in an accounting system.', }, { displayName: 'Recipient Wallet', @@ -221,15 +207,9 @@ export const payoutFields: INodeProperties[] = [ description: 'An array of individual payout items', displayOptions: { show: { - resource: [ - 'payout', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['payout'], + operation: ['create'], + jsonParameters: [true], }, }, }, @@ -241,12 +221,8 @@ export const payoutFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'payout', - ], - operation: [ - 'create', - ], + resource: ['payout'], + operation: ['create'], }, }, options: [ @@ -255,21 +231,24 @@ export const payoutFields: INodeProperties[] = [ name: 'emailSubject', type: 'string', default: '', - description: 'The subject line for the email that PayPal sends when payment for a payout item completes. The subject line is the same for all recipients. Max length: 255 characters.', + description: + 'The subject line for the email that PayPal sends when payment for a payout item completes. The subject line is the same for all recipients. Max length: 255 characters.', }, { displayName: 'Email Message', name: 'emailMessage', type: 'string', default: '', - description: 'The email message that PayPal sends when the payout item completes. The message is the same for all recipients.', + description: + 'The email message that PayPal sends when the payout item completes. The message is the same for all recipients.', }, { displayName: 'Note', name: 'note', type: 'string', default: '', - description: 'The payouts and item-level notes are concatenated in the email. Max length: 1000 characters.', + description: + 'The payouts and item-level notes are concatenated in the email. Max length: 1000 characters.', }, ], }, @@ -286,12 +265,8 @@ export const payoutFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'payout', - ], - operation: [ - 'get', - ], + resource: ['payout'], + operation: ['get'], }, }, description: 'The ID of the payout for which to show details', @@ -303,12 +278,8 @@ export const payoutFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'payout', - ], - operation: [ - 'get', - ], + resource: ['payout'], + operation: ['get'], }, }, description: 'Whether to return all results or only up to a given limit', @@ -324,23 +295,15 @@ export const payoutFields: INodeProperties[] = [ default: 100, displayOptions: { show: { - resource: [ - 'payout', - ], - operation: [ - 'get', - ], - returnAll: [ - false, - ], + resource: ['payout'], + operation: ['get'], + returnAll: [false], }, }, description: 'Max number of results to return', }, - ]; - export const payoutItemOperations: INodeProperties[] = [ { displayName: 'Operation', @@ -349,9 +312,7 @@ export const payoutItemOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'payoutItem', - ], + resource: ['payoutItem'], }, }, options: [ @@ -373,7 +334,6 @@ export const payoutItemOperations: INodeProperties[] = [ ]; export const payoutItemFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* payoutItem:get */ /* -------------------------------------------------------------------------- */ @@ -385,12 +345,8 @@ export const payoutItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'payoutItem', - ], - operation: [ - 'get', - ], + resource: ['payoutItem'], + operation: ['get'], }, }, description: 'The ID of the payout item for which to show details', @@ -408,12 +364,8 @@ export const payoutItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'payoutItem', - ], - operation: [ - 'cancel', - ], + resource: ['payoutItem'], + operation: ['cancel'], }, }, description: 'The ID of the payout item to cancel', diff --git a/packages/nodes-base/nodes/Peekalink/GenericFunctions.ts b/packages/nodes-base/nodes/Peekalink/GenericFunctions.ts index 136568e034..633245fbac 100644 --- a/packages/nodes-base/nodes/Peekalink/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Peekalink/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,11 +7,19 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function peekalinkApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function peekalinkApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { try { const credentials = await this.getCredentials('peekalinkApi'); let options: OptionsWithUri = { diff --git a/packages/nodes-base/nodes/Peekalink/Peekalink.node.ts b/packages/nodes-base/nodes/Peekalink/Peekalink.node.ts index e1481b3e61..e602a54a37 100644 --- a/packages/nodes-base/nodes/Peekalink/Peekalink.node.ts +++ b/packages/nodes-base/nodes/Peekalink/Peekalink.node.ts @@ -1,17 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - peekalinkApiRequest, -} from './GenericFunctions'; +import { peekalinkApiRequest } from './GenericFunctions'; export class Peekalink implements INodeType { description: INodeTypeDescription = { diff --git a/packages/nodes-base/nodes/Phantombuster/AgentDescription.ts b/packages/nodes-base/nodes/Phantombuster/AgentDescription.ts index 3b75f77c97..014790a5a0 100644 --- a/packages/nodes-base/nodes/Phantombuster/AgentDescription.ts +++ b/packages/nodes-base/nodes/Phantombuster/AgentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const agentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const agentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'agent', - ], + resource: ['agent'], }, }, options: [ @@ -31,7 +27,7 @@ export const agentOperations: INodeProperties[] = [ { name: 'Get All', value: 'getAll', - description: 'Get all agents of the current user\'s organization', + description: "Get all agents of the current user's organization", action: 'Get all agents', }, { @@ -52,7 +48,6 @@ export const agentOperations: INodeProperties[] = [ ]; export const agentFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* agent:delete */ /* -------------------------------------------------------------------------- */ @@ -60,19 +55,16 @@ export const agentFields: INodeProperties[] = [ displayName: 'Agent Name or ID', name: 'agentId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getAgents', }, required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'agent', - ], + operation: ['delete'], + resource: ['agent'], }, }, default: '', @@ -88,12 +80,8 @@ export const agentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'agent', - ], + operation: ['get'], + resource: ['agent'], }, }, default: '', @@ -108,12 +96,8 @@ export const agentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'agent', - ], + operation: ['getAll'], + resource: ['agent'], }, }, default: false, @@ -125,15 +109,9 @@ export const agentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'agent', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['agent'], + returnAll: [false], }, }, typeOptions: { @@ -151,19 +129,16 @@ export const agentFields: INodeProperties[] = [ displayName: 'Agent Name or ID', name: 'agentId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getAgents', }, required: true, displayOptions: { show: { - operation: [ - 'getOutput', - ], - resource: [ - 'agent', - ], + operation: ['getOutput'], + resource: ['agent'], }, }, default: '', @@ -175,16 +150,13 @@ export const agentFields: INodeProperties[] = [ default: true, displayOptions: { show: { - operation: [ - 'getOutput', - ], - resource: [ - 'agent', - ], + operation: ['getOutput'], + resource: ['agent'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default the outpout is presented as string. If this option gets activated, it will resolve the data automatically.', + description: + 'By default the outpout is presented as string. If this option gets activated, it will resolve the data automatically.', }, { displayName: 'Additional Fields', @@ -193,12 +165,8 @@ export const agentFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'agent', - ], - operation: [ - 'getOutput', - ], + resource: ['agent'], + operation: ['getOutput'], }, }, default: {}, @@ -208,7 +176,8 @@ export const agentFields: INodeProperties[] = [ name: 'prevContainerId', type: 'string', default: '', - description: 'If set, the output will be retrieved from the container after the specified previous container ID', + description: + 'If set, the output will be retrieved from the container after the specified previous container ID', }, { displayName: 'Prev Status', @@ -248,7 +217,8 @@ export const agentFields: INodeProperties[] = [ name: 'prevRuntimeEventIndex', type: 'number', default: 0, - description: 'If set, the container\'s runtime events will be returned in the response starting from the provided previous runtime event index', + description: + "If set, the container's runtime events will be returned in the response starting from the provided previous runtime event index", }, ], }, @@ -260,19 +230,16 @@ export const agentFields: INodeProperties[] = [ displayName: 'Agent Name or ID', name: 'agentId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getAgents', }, required: true, displayOptions: { show: { - operation: [ - 'launch', - ], - resource: [ - 'agent', - ], + operation: ['launch'], + resource: ['agent'], }, }, default: '', @@ -284,16 +251,13 @@ export const agentFields: INodeProperties[] = [ default: true, displayOptions: { show: { - operation: [ - 'launch', - ], - resource: [ - 'agent', - ], + operation: ['launch'], + resource: ['agent'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default the launch just include the container ID. If this option gets activated, it will resolve the data automatically.', + description: + 'By default the launch just include the container ID. If this option gets activated, it will resolve the data automatically.', }, { displayName: 'JSON Parameters', @@ -302,12 +266,8 @@ export const agentFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'launch', - ], - resource: [ - 'agent', - ], + operation: ['launch'], + resource: ['agent'], }, }, }, @@ -318,12 +278,8 @@ export const agentFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'agent', - ], - operation: [ - 'launch', - ], + resource: ['agent'], + operation: ['launch'], }, }, default: {}, @@ -334,13 +290,12 @@ export const agentFields: INodeProperties[] = [ type: 'json', displayOptions: { show: { - '/jsonParameters': [ - true, - ], + '/jsonParameters': [true], }, }, default: '', - description: 'Agent argument. Can either be a JSON string or a plain object. The argument can be retrieved with buster.argument in the agent’s script.', + description: + 'Agent argument. Can either be a JSON string or a plain object. The argument can be retrieved with buster.argument in the agent’s script.', }, { displayName: 'Arguments', @@ -353,9 +308,7 @@ export const agentFields: INodeProperties[] = [ }, displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, options: [ @@ -392,9 +345,7 @@ export const agentFields: INodeProperties[] = [ }, displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, options: [ @@ -426,13 +377,12 @@ export const agentFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/jsonParameters': [ - true, - ], + '/jsonParameters': [true], }, }, default: '', - description: 'Agent bonus argument. Can either be a JSON string or a plain object. This bonus argument is single-use, it will only be used for the current launch. If present, it will be merged with the original argument, resulting in an effective argument that can be retrieved with buster.argument in the agent’s script.', + description: + 'Agent bonus argument. Can either be a JSON string or a plain object. This bonus argument is single-use, it will only be used for the current launch. If present, it will be merged with the original argument, resulting in an effective argument that can be retrieved with buster.argument in the agent’s script.', }, { displayName: 'Manual Launch', @@ -446,7 +396,8 @@ export const agentFields: INodeProperties[] = [ name: 'maxInstanceCount', type: 'number', default: 0, - description: 'If set, the agent will only be launched if the number of already running instances is below the specified number', + description: + 'If set, the agent will only be launched if the number of already running instances is below the specified number', }, { displayName: 'Save Argument', diff --git a/packages/nodes-base/nodes/Phantombuster/GenericFunctions.ts b/packages/nodes-base/nodes/Phantombuster/GenericFunctions.ts index 26e186e295..14a333e067 100644 --- a/packages/nodes-base/nodes/Phantombuster/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Phantombuster/GenericFunctions.ts @@ -1,19 +1,19 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; - -export async function phantombusterApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, option = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; +export async function phantombusterApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + path: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + option = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('phantombusterApi'); const options: OptionsWithUri = { diff --git a/packages/nodes-base/nodes/Phantombuster/Phantombuster.node.ts b/packages/nodes-base/nodes/Phantombuster/Phantombuster.node.ts index 5e830287a5..a5e865476d 100644 --- a/packages/nodes-base/nodes/Phantombuster/Phantombuster.node.ts +++ b/packages/nodes-base/nodes/Phantombuster/Phantombuster.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,15 +9,9 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - phantombusterApiRequest, - validateJSON, -} from './GenericFunctions'; +import { phantombusterApiRequest, validateJSON } from './GenericFunctions'; -import { - agentFields, - agentOperations, -} from './AgentDescription'; +import { agentFields, agentOperations } from './AgentDescription'; // import { // sentenceCase, @@ -67,15 +59,10 @@ export class Phantombuster implements INodeType { methods = { loadOptions: { - async getAgents(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const responseData = await phantombusterApiRequest.call( - this, - 'GET', - '/agents/fetch-all', - ); + const responseData = await phantombusterApiRequest.call(this, 'GET', '/agents/fetch-all'); for (const item of responseData) { returnData.push({ @@ -122,19 +109,15 @@ export class Phantombuster implements INodeType { const resource = this.getNodeParameter('resource', 0) as string; const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < length; i++) { - try { if (resource === 'agent') { //https://hub.phantombuster.com/reference#post_agents-delete-1 if (operation === 'delete') { const agentId = this.getNodeParameter('agentId', i) as string; - responseData = await phantombusterApiRequest.call( - this, - 'POST', - '/agents/delete', - { id: agentId }, - ); + responseData = await phantombusterApiRequest.call(this, 'POST', '/agents/delete', { + id: agentId, + }); responseData = { success: true }; } @@ -190,11 +173,7 @@ export class Phantombuster implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; - responseData = await phantombusterApiRequest.call( - this, - 'GET', - '/agents/fetch-all', - ); + responseData = await phantombusterApiRequest.call(this, 'GET', '/agents/fetch-all'); if (returnAll === false) { const limit = this.getNodeParameter('limit', 0) as number; @@ -217,23 +196,35 @@ export class Phantombuster implements INodeType { if (jsonParameters) { if (additionalFields.argumentsJson) { - body.arguments = validateJSON(this, additionalFields.argumentsJson as string, 'Arguments'); + body.arguments = validateJSON( + this, + additionalFields.argumentsJson as string, + 'Arguments', + ); delete additionalFields.argumentsJson; } if (additionalFields.bonusArgumentJson) { - body.bonusArgument = validateJSON(this, additionalFields.bonusArgumentJson as string, 'Bonus Argument'); + body.bonusArgument = validateJSON( + this, + additionalFields.bonusArgumentJson as string, + 'Bonus Argument', + ); delete additionalFields.bonusArgumentJson; } } else { - const argumentParameters = ((additionalFields.argumentsUi as IDataObject || {}).argumentValues as IDataObject[]) || []; + const argumentParameters = + (((additionalFields.argumentsUi as IDataObject) || {}) + .argumentValues as IDataObject[]) || []; body.arguments = argumentParameters.reduce((object, currentValue) => { object[currentValue.key as string] = currentValue.value; return object; }, {}); delete additionalFields.argumentsUi; - const bonusParameters = ((additionalFields.bonusArgumentUi as IDataObject || {}).bonusArgumentValue as IDataObject[]) || []; + const bonusParameters = + (((additionalFields.bonusArgumentUi as IDataObject) || {}) + .bonusArgumentValue as IDataObject[]) || []; body.bonusArgument = bonusParameters.reduce((object, currentValue) => { object[currentValue.key as string] = currentValue.value; return object; @@ -243,12 +234,7 @@ export class Phantombuster implements INodeType { Object.assign(body, additionalFields); - responseData = await phantombusterApiRequest.call( - this, - 'POST', - '/agents/launch', - body, - ); + responseData = await phantombusterApiRequest.call(this, 'POST', '/agents/launch', body); if (resolveData === true) { responseData = await phantombusterApiRequest.call( diff --git a/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts b/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts index 77987f40ef..297e39d25a 100644 --- a/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts @@ -1,17 +1,20 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function philipsHueApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function philipsHueApiRequest( + this: IExecuteFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -36,14 +39,18 @@ export async function philipsHueApiRequest(this: IExecuteFunctions | ILoadOption } //@ts-ignore - const response = await this.helpers.requestOAuth2.call(this, 'philipsHueOAuth2Api', options, { tokenType: 'Bearer' }); + const response = await this.helpers.requestOAuth2.call(this, 'philipsHueOAuth2Api', options, { + tokenType: 'Bearer', + }); return response; } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function getUser(this: IExecuteFunctions | ILoadOptionsFunctions): Promise { // tslint:disable-line:no-any +export async function getUser( + this: IExecuteFunctions | ILoadOptionsFunctions, // tslint:disable-next-line:no-any +): Promise { const { whitelist } = await philipsHueApiRequest.call(this, 'GET', '/api/0/config', {}, {}); //check if there is a n8n user for (const user of Object.keys(whitelist)) { diff --git a/packages/nodes-base/nodes/PhilipsHue/LightDescription.ts b/packages/nodes-base/nodes/PhilipsHue/LightDescription.ts index d4c531d6e4..14b1507cbf 100644 --- a/packages/nodes-base/nodes/PhilipsHue/LightDescription.ts +++ b/packages/nodes-base/nodes/PhilipsHue/LightDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const lightOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const lightOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'light', - ], + resource: ['light'], }, }, options: [ @@ -46,7 +42,6 @@ export const lightOperations: INodeProperties[] = [ ]; export const lightFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* light:delete */ /* -------------------------------------------------------------------------- */ @@ -57,12 +52,8 @@ export const lightFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'light', - ], + operation: ['delete'], + resource: ['light'], }, }, default: '', @@ -77,12 +68,8 @@ export const lightFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'light', - ], + operation: ['getAll'], + resource: ['light'], }, }, default: false, @@ -94,15 +81,9 @@ export const lightFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'light', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['light'], + returnAll: [false], }, }, typeOptions: { @@ -123,12 +104,8 @@ export const lightFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'light', - ], + operation: ['get'], + resource: ['light'], }, }, default: '', @@ -141,19 +118,16 @@ export const lightFields: INodeProperties[] = [ displayName: 'Light Name or ID', name: 'lightId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getLights', }, required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'light', - ], + operation: ['update'], + resource: ['light'], }, }, default: '', @@ -165,12 +139,8 @@ export const lightFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'light', - ], + operation: ['update'], + resource: ['light'], }, }, default: true, @@ -184,12 +154,8 @@ export const lightFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'light', - ], - operation: [ - 'update', - ], + resource: ['light'], + operation: ['update'], }, }, default: {}, @@ -212,7 +178,8 @@ export const lightFields: INodeProperties[] = [ { name: 'LSelect', value: 'lselect', - description: 'The light is performing breathe cycles for 15 seconds or until an "alert": "none" command is received', + description: + 'The light is performing breathe cycles for 15 seconds or until an "alert": "none" command is received', }, ], default: '', @@ -227,7 +194,8 @@ export const lightFields: INodeProperties[] = [ maxValue: 254, }, default: 100, - description: 'The brightness value to set the light to. Brightness is a scale from 1 (the minimum the light is capable of) to 254 (the maximum).', + description: + 'The brightness value to set the light to. Brightness is a scale from 1 (the minimum the light is capable of) to 254 (the maximum).', }, { displayName: 'Brightness Increments', @@ -238,14 +206,16 @@ export const lightFields: INodeProperties[] = [ maxValue: 254, }, default: 0, - description: 'Increments or decrements the value of the brightness. This value is ignored if the Brightness attribute is provided.', + description: + 'Increments or decrements the value of the brightness. This value is ignored if the Brightness attribute is provided.', }, { displayName: 'Color Temperature', name: 'ct', type: 'number', default: 0, - description: 'The Mired color temperature of the light. 2012 connected lights are capable of 153 (6500K) to 500 (2000K).', + description: + 'The Mired color temperature of the light. 2012 connected lights are capable of 153 (6500K) to 500 (2000K).', }, { displayName: 'Color Temperature Increments', @@ -256,7 +226,8 @@ export const lightFields: INodeProperties[] = [ maxValue: 65534, }, default: 0, - description: 'Increments or decrements the value of the ct. ct_inc is ignored if the ct attribute is provided.', + description: + 'Increments or decrements the value of the ct. ct_inc is ignored if the ct attribute is provided.', }, { displayName: 'Coordinates', @@ -264,7 +235,8 @@ export const lightFields: INodeProperties[] = [ type: 'string', default: '', placeholder: '0.64394,0.33069', - description: 'The x and y coordinates of a color in CIE color space. The first entry is the x coordinate and the second entry is the y coordinate. Both x and y are between 0 and 1', + description: + 'The x and y coordinates of a color in CIE color space. The first entry is the x coordinate and the second entry is the y coordinate. Both x and y are between 0 and 1', }, { displayName: 'Coordinates Increments', @@ -272,7 +244,8 @@ export const lightFields: INodeProperties[] = [ type: 'string', default: '', placeholder: '0.5,0.5', - description: 'Increments or decrements the value of the xy. This value is ignored if the Coordinates attribute is provided. Any ongoing color transition is stopped. Max value [0.5, 0.5]', + description: + 'Increments or decrements the value of the xy. This value is ignored if the Coordinates attribute is provided. Any ongoing color transition is stopped. Max value [0.5, 0.5]', }, { displayName: 'Dynamic Effect', @@ -300,7 +273,8 @@ export const lightFields: INodeProperties[] = [ maxValue: 65535, }, default: 0, - description: 'The hue value to set light to.The hue value is a wrapping value between 0 and 65535. Both 0 and 65535 are red, 25500 is green and 46920 is blue.', + description: + 'The hue value to set light to.The hue value is a wrapping value between 0 and 65535. Both 0 and 65535 are red, 25500 is green and 46920 is blue.', }, { displayName: 'Hue Increments', @@ -311,7 +285,8 @@ export const lightFields: INodeProperties[] = [ maxValue: 65534, }, default: 0, - description: 'Increments or decrements the value of the hue. Hue Increments is ignored if the Hue attribute is provided.', + description: + 'Increments or decrements the value of the hue. Hue Increments is ignored if the Hue attribute is provided.', }, { displayName: 'Saturation', @@ -322,7 +297,8 @@ export const lightFields: INodeProperties[] = [ maxValue: 254, }, default: 0, - description: 'Saturation of the light. 254 is the most saturated (colored) and 0 is the least saturated (white).', + description: + 'Saturation of the light. 254 is the most saturated (colored) and 0 is the least saturated (white).', }, { displayName: 'Saturation Increments', @@ -333,7 +309,8 @@ export const lightFields: INodeProperties[] = [ maxValue: 254, }, default: 0, - description: 'Increments or decrements the value of the sat. This value is ignored if the Saturation attribute is provided.', + description: + 'Increments or decrements the value of the sat. This value is ignored if the Saturation attribute is provided.', }, { displayName: 'Transition Time', @@ -343,7 +320,8 @@ export const lightFields: INodeProperties[] = [ minVale: 1, }, default: 4, - description: 'The duration in seconds of the transition from the light’s current state to the new state', + description: + 'The duration in seconds of the transition from the light’s current state to the new state', }, ], }, diff --git a/packages/nodes-base/nodes/PhilipsHue/PhilipsHue.node.ts b/packages/nodes-base/nodes/PhilipsHue/PhilipsHue.node.ts index b6c1093ff9..75e066d3be 100644 --- a/packages/nodes-base/nodes/PhilipsHue/PhilipsHue.node.ts +++ b/packages/nodes-base/nodes/PhilipsHue/PhilipsHue.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,15 +9,9 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - getUser, - philipsHueApiRequest, -} from './GenericFunctions'; +import { getUser, philipsHueApiRequest } from './GenericFunctions'; -import { - lightFields, - lightOperations, -} from './LightDescription'; +import { lightFields, lightOperations } from './LightDescription'; export class PhilipsHue implements INodeType { description: INodeTypeDescription = { @@ -65,31 +57,21 @@ export class PhilipsHue implements INodeType { loadOptions: { // Get all the lights to display them to user so that he can // select them easily - async getLights( - this: ILoadOptionsFunctions, - ): Promise { + async getLights(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const user = await getUser.call(this); - const lights = await philipsHueApiRequest.call( - this, - 'GET', - `/api/${user}/lights`, - ); + const lights = await philipsHueApiRequest.call(this, 'GET', `/api/${user}/lights`); - const groups = await philipsHueApiRequest.call( - this, - 'GET', - `/api/${user}/groups`, - ); + const groups = await philipsHueApiRequest.call(this, 'GET', `/api/${user}/groups`); for (const light of Object.keys(lights)) { let lightName = lights[light].name; const lightId = light; for (const groupId of Object.keys(groups)) { - if(groups[groupId].type === 'Room' && groups[groupId].lights.includes(lightId)) { + if (groups[groupId].type === 'Room' && groups[groupId].lights.includes(lightId)) { lightName = `${groups[groupId].name}: ${lightName}`; } } @@ -115,7 +97,6 @@ export class PhilipsHue implements INodeType { for (let i = 0; i < length; i++) { if (resource === 'light') { if (operation === 'update') { - const lightId = this.getNodeParameter('lightId', i) as string; const on = this.getNodeParameter('on', i) as boolean; @@ -127,15 +108,19 @@ export class PhilipsHue implements INodeType { }; if (additionalFields.transitiontime) { - additionalFields.transitiontime = (additionalFields.transitiontime as number * 100); + additionalFields.transitiontime = (additionalFields.transitiontime as number) * 100; } if (additionalFields.xy) { - additionalFields.xy = (additionalFields.xy as string).split(',').map((e: string) => parseFloat(e)); + additionalFields.xy = (additionalFields.xy as string) + .split(',') + .map((e: string) => parseFloat(e)); } if (additionalFields.xy_inc) { - additionalFields.xy_inc = (additionalFields.xy_inc as string).split(',').map((e: string) => parseFloat(e)); + additionalFields.xy_inc = (additionalFields.xy_inc as string) + .split(',') + .map((e: string) => parseFloat(e)); } Object.assign(body, additionalFields); @@ -154,16 +139,17 @@ export class PhilipsHue implements INodeType { for (const response of data) { Object.assign(responseData, response.success); } - } if (operation === 'delete') { - const lightId = this.getNodeParameter('lightId', i) as string; const user = await getUser.call(this); - responseData = await philipsHueApiRequest.call(this, 'DELETE', `/api/${user}/lights/${lightId}`); - + responseData = await philipsHueApiRequest.call( + this, + 'DELETE', + `/api/${user}/lights/${lightId}`, + ); } if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; @@ -184,7 +170,11 @@ export class PhilipsHue implements INodeType { const user = await getUser.call(this); - responseData = await philipsHueApiRequest.call(this, 'GET', `/api/${user}/lights/${lightId}`); + responseData = await philipsHueApiRequest.call( + this, + 'GET', + `/api/${user}/lights/${lightId}`, + ); } } } diff --git a/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts b/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts index a1719d03c2..3c3d4ada80 100644 --- a/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts @@ -1,19 +1,8 @@ -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - INodePropertyOptions, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, INodePropertyOptions, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; export interface ICustomInterface { name: string; @@ -38,7 +27,16 @@ export interface ICustomProperties { * @param {object} body * @returns {Promise} */ -export async function pipedriveApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: IDataObject, query: IDataObject = {}, formData?: IDataObject, downloadFile?: boolean): Promise { // tslint:disable-line:no-any +export async function pipedriveApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + body: IDataObject, + query: IDataObject = {}, + formData?: IDataObject, + downloadFile?: boolean, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0); const options: OptionsWithUri = { @@ -69,8 +67,13 @@ export async function pipedriveApiRequest(this: IHookFunctions | IExecuteFunctio } try { - const credentialType = authenticationMethod === 'apiToken' ? 'pipedriveApi' : 'pipedriveOAuth2Api'; - const responseData = await this.helpers.requestWithAuthentication.call(this, credentialType, options); + const credentialType = + authenticationMethod === 'apiToken' ? 'pipedriveApi' : 'pipedriveOAuth2Api'; + const responseData = await this.helpers.requestWithAuthentication.call( + this, + credentialType, + options, + ); if (downloadFile === true) { return { @@ -84,7 +87,7 @@ export async function pipedriveApiRequest(this: IHookFunctions | IExecuteFunctio return { additionalData: responseData.additional_data, - data: (responseData.data === null) ? [] : responseData.data, + data: responseData.data === null ? [] : responseData.data, }; } catch (error) { throw new NodeApiError(this.getNode(), error); @@ -103,8 +106,14 @@ export async function pipedriveApiRequest(this: IHookFunctions | IExecuteFunctio * @param {IDataObject} [query] * @returns {Promise} */ -export async function pipedriveApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject): Promise { // tslint:disable-line:no-any - +export async function pipedriveApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions, + method: string, + endpoint: string, + body: IDataObject, + query?: IDataObject, + // tslint:disable-next-line:no-any +): Promise { if (query === undefined) { query = {}; } @@ -136,8 +145,6 @@ export async function pipedriveApiRequestAllItems(this: IHookFunctions | IExecut }; } - - /** * Gets the custom properties from Pipedrive * @@ -146,18 +153,23 @@ export async function pipedriveApiRequestAllItems(this: IHookFunctions | IExecut * @param {string} resource * @returns {Promise} */ -export async function pipedriveGetCustomProperties(this: IHookFunctions | IExecuteFunctions, resource: string): Promise { - +export async function pipedriveGetCustomProperties( + this: IHookFunctions | IExecuteFunctions, + resource: string, +): Promise { const endpoints: { [key: string]: string } = { - 'activity': '/activityFields', - 'deal': '/dealFields', - 'organization': '/organizationFields', - 'person': '/personFields', - 'product': '/productFields', + activity: '/activityFields', + deal: '/dealFields', + organization: '/organizationFields', + person: '/personFields', + product: '/productFields', }; if (endpoints[resource] === undefined) { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not supported for resolving custom values!`); + throw new NodeOperationError( + this.getNode(), + `The resource "${resource}" is not supported for resolving custom values!`, + ); } const requestMethod = 'GET'; @@ -165,7 +177,13 @@ export async function pipedriveGetCustomProperties(this: IHookFunctions | IExecu const body = {}; const qs = {}; // Get the custom properties and their values - const responseData = await pipedriveApiRequest.call(this, requestMethod, endpoints[resource], body, qs); + const responseData = await pipedriveApiRequest.call( + this, + requestMethod, + endpoints[resource], + body, + qs, + ); const customProperties: ICustomProperties = {}; @@ -175,8 +193,6 @@ export async function pipedriveGetCustomProperties(this: IHookFunctions | IExecu return customProperties; } - - /** * Converts names and values of custom properties from their actual values to the * Pipedrive internal ones @@ -185,19 +201,31 @@ export async function pipedriveGetCustomProperties(this: IHookFunctions | IExecu * @param {ICustomProperties} customProperties * @param {IDataObject} item */ -export function pipedriveEncodeCustomProperties(customProperties: ICustomProperties, item: IDataObject): void { +export function pipedriveEncodeCustomProperties( + customProperties: ICustomProperties, + item: IDataObject, +): void { let customPropertyData; for (const key of Object.keys(item)) { - customPropertyData = Object.values(customProperties).find(customPropertyData => customPropertyData.name === key); + customPropertyData = Object.values(customProperties).find( + (customPropertyData) => customPropertyData.name === key, + ); if (customPropertyData !== undefined) { // Is a custom property // Check if also the value has to be resolved or just the key - if (item[key] !== null && item[key] !== undefined && customPropertyData.options !== undefined && Array.isArray(customPropertyData.options)) { + if ( + item[key] !== null && + item[key] !== undefined && + customPropertyData.options !== undefined && + Array.isArray(customPropertyData.options) + ) { // Has an option key so get the actual option-value - const propertyOption = customPropertyData.options.find(option => option.label.toString() === item[key]!.toString()); + const propertyOption = customPropertyData.options.find( + (option) => option.label.toString() === item[key]!.toString(), + ); if (propertyOption !== undefined) { item[customPropertyData.key as string] = propertyOption.id; @@ -212,8 +240,6 @@ export function pipedriveEncodeCustomProperties(customProperties: ICustomPropert } } - - /** * Converts names and values of custom properties to their actual values * @@ -221,12 +247,14 @@ export function pipedriveEncodeCustomProperties(customProperties: ICustomPropert * @param {ICustomProperties} customProperties * @param {IDataObject} item */ -export function pipedriveResolveCustomProperties(customProperties: ICustomProperties, item: IDataObject): void { +export function pipedriveResolveCustomProperties( + customProperties: ICustomProperties, + item: IDataObject, +): void { let customPropertyData; // Itterate over all keys and replace the custom ones for (const key of Object.keys(item)) { - if (customProperties[key] !== undefined) { // Is a custom property customPropertyData = customProperties[key]; @@ -238,28 +266,35 @@ export function pipedriveResolveCustomProperties(customProperties: ICustomProper continue; } - if ([ - 'date', - 'address', - 'double', - 'monetary', - 'org', - 'people', - 'phone', - 'text', - 'time', - 'user', - 'varchar', - 'varchar_auto', - 'int', - 'time', - 'timerange', - ].includes(customPropertyData.field_type)) { - item[customPropertyData.name as string] = item[key]; - delete item[key]; + if ( + [ + 'date', + 'address', + 'double', + 'monetary', + 'org', + 'people', + 'phone', + 'text', + 'time', + 'user', + 'varchar', + 'varchar_auto', + 'int', + 'time', + 'timerange', + ].includes(customPropertyData.field_type) + ) { + item[customPropertyData.name as string] = item[key]; + delete item[key]; // type options - } else if (['enum', 'visible_to'].includes(customPropertyData.field_type) && customPropertyData.options) { - const propertyOption = customPropertyData.options.find(option => option.id.toString() === item[key]!.toString()); + } else if ( + ['enum', 'visible_to'].includes(customPropertyData.field_type) && + customPropertyData.options + ) { + const propertyOption = customPropertyData.options.find( + (option) => option.id.toString() === item[key]!.toString(), + ); if (propertyOption !== undefined) { item[customPropertyData.name as string] = propertyOption.label; delete item[key]; @@ -267,9 +302,9 @@ export function pipedriveResolveCustomProperties(customProperties: ICustomProper // type multioptions } else if (['set'].includes(customPropertyData.field_type) && customPropertyData.options) { const selectedIds = (item[key] as string).split(','); - const selectedLabels = customPropertyData.options. - filter(option => selectedIds.includes(option.id.toString())). - map(option => option.label); + const selectedLabels = customPropertyData.options + .filter((option) => selectedIds.includes(option.id.toString())) + .map((option) => option.label); item[customPropertyData.name] = selectedLabels; delete item[key]; } @@ -277,12 +312,18 @@ export function pipedriveResolveCustomProperties(customProperties: ICustomProper } } -export function sortOptionParameters(optionParameters: INodePropertyOptions[]): INodePropertyOptions[] { +export function sortOptionParameters( + optionParameters: INodePropertyOptions[], +): INodePropertyOptions[] { optionParameters.sort((a, b) => { const aName = a.name.toLowerCase(); const bName = b.name.toLowerCase(); - if (aName < bName) { return -1; } - if (aName > bName) { return 1; } + if (aName < bName) { + return -1; + } + if (aName > bName) { + return 1; + } return 0; }); diff --git a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts index 33c6a938b5..80bc1be5ad 100644 --- a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts +++ b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts @@ -1,7 +1,4 @@ -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject, INodeExecutionData, @@ -21,9 +18,7 @@ import { sortOptionParameters, } from './GenericFunctions'; -import { - currencies, -} from './utils'; +import { currencies } from './utils'; interface CustomProperty { name: string; @@ -38,8 +33,12 @@ interface CustomProperty { */ function addAdditionalFields(body: IDataObject, additionalFields: IDataObject) { for (const key of Object.keys(additionalFields)) { - if (key === 'customProperties' && (additionalFields.customProperties as IDataObject).property !== undefined) { - for (const customProperty of (additionalFields.customProperties as IDataObject)!.property! as CustomProperty[]) { + if ( + key === 'customProperties' && + (additionalFields.customProperties as IDataObject).property !== undefined + ) { + for (const customProperty of (additionalFields.customProperties as IDataObject)! + .property! as CustomProperty[]) { body[customProperty.name] = customProperty.value; } } else { @@ -68,9 +67,7 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'apiToken', - ], + authentication: ['apiToken'], }, }, testedBy: { @@ -85,9 +82,7 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -163,8 +158,6 @@ export class Pipedrive implements INodeType { default: 'deal', }, - - // ---------------------------------- // operations // ---------------------------------- @@ -175,9 +168,7 @@ export class Pipedrive implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'activity', - ], + resource: ['activity'], }, }, options: [ @@ -222,9 +213,7 @@ export class Pipedrive implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'deal', - ], + resource: ['deal'], }, }, options: [ @@ -281,9 +270,7 @@ export class Pipedrive implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'dealActivity', - ], + resource: ['dealActivity'], }, }, options: [ @@ -304,9 +291,7 @@ export class Pipedrive implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'dealProduct', - ], + resource: ['dealProduct'], }, }, options: [ @@ -345,9 +330,7 @@ export class Pipedrive implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'file', - ], + resource: ['file'], }, }, options: [ @@ -396,9 +379,7 @@ export class Pipedrive implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'lead', - ], + resource: ['lead'], }, }, options: [ @@ -442,9 +423,7 @@ export class Pipedrive implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'note', - ], + resource: ['note'], }, }, options: [ @@ -489,9 +468,7 @@ export class Pipedrive implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'organization', - ], + resource: ['organization'], }, }, options: [ @@ -542,9 +519,7 @@ export class Pipedrive implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'person', - ], + resource: ['person'], }, }, options: [ @@ -595,9 +570,7 @@ export class Pipedrive implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'product', - ], + resource: ['product'], }, }, options: [ @@ -611,8 +584,6 @@ export class Pipedrive implements INodeType { default: 'getAll', }, - - // ---------------------------------- // Activity // ---------------------------------- @@ -628,12 +599,8 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'activity', - ], + operation: ['create'], + resource: ['activity'], }, }, description: 'The subject of the activity to create', @@ -644,12 +611,8 @@ export class Pipedrive implements INodeType { type: 'options', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'activity', - ], + operation: ['create'], + resource: ['activity'], }, }, options: [ @@ -673,12 +636,8 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'activity', - ], + operation: ['create'], + resource: ['activity'], }, }, placeholder: 'call', @@ -691,12 +650,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'activity', - ], + operation: ['create'], + resource: ['activity'], }, }, default: {}, @@ -734,7 +689,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getOrganizationIds', }, default: '', - description: 'ID of the organization this activity will be associated with. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the organization this activity will be associated with. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Person ID', @@ -751,7 +707,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getUserIds', }, default: '', - description: 'ID of the active user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the active user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Custom Properties', @@ -798,12 +755,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'activity', - ], + operation: ['delete'], + resource: ['activity'], }, }, default: 0, @@ -811,7 +764,6 @@ export class Pipedrive implements INodeType { description: 'ID of the activity to delete', }, - // ---------------------------------- // activity:get // ---------------------------------- @@ -821,12 +773,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'activity', - ], + operation: ['get'], + resource: ['activity'], }, }, default: 0, @@ -842,12 +790,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'activity', - ], + operation: ['update'], + resource: ['activity'], }, }, default: 0, @@ -861,12 +805,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'activity', - ], + operation: ['update'], + resource: ['activity'], }, }, default: {}, @@ -922,7 +862,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getOrganizationIds', }, default: '', - description: 'ID of the organization this activity will be associated with. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the organization this activity will be associated with. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Person ID', @@ -954,7 +895,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getUserIds', }, default: '', - description: 'ID of the active user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the active user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Custom Properties', @@ -992,8 +934,6 @@ export class Pipedrive implements INodeType { ], }, - - // ---------------------------------- // deal // ---------------------------------- @@ -1009,12 +949,8 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], + operation: ['create'], + resource: ['deal'], }, }, description: 'The title of the deal to create', @@ -1038,12 +974,8 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, }, @@ -1056,15 +988,9 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - associateWith: [ - 'organization', - ], + operation: ['create'], + resource: ['deal'], + associateWith: ['organization'], }, }, }, @@ -1076,15 +1002,9 @@ export class Pipedrive implements INodeType { description: 'ID of the person this deal will be associated with', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], - associateWith: [ - 'person', - ], + operation: ['create'], + resource: ['deal'], + associateWith: ['person'], }, }, }, @@ -1095,12 +1015,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], + operation: ['create'], + resource: ['deal'], }, }, default: {}, @@ -1110,7 +1026,8 @@ export class Pipedrive implements INodeType { name: 'currency', type: 'string', default: 'USD', - description: 'Currency of the deal. Accepts a 3-character currency code. Like EUR, USD, ...', + description: + 'Currency of the deal. Accepts a 3-character currency code. Like EUR, USD, ...', }, { displayName: 'Custom Properties', @@ -1135,7 +1052,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getDealCustomFields', }, default: '', - description: 'Name of the property to set. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the property to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Property Value', @@ -1152,7 +1070,8 @@ export class Pipedrive implements INodeType { displayName: 'Label Name or ID', name: 'label', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getDealLabels', }, @@ -1172,9 +1091,7 @@ export class Pipedrive implements INodeType { default: 0, displayOptions: { show: { - '/associateWith': [ - 'person', - ], + '/associateWith': ['person'], }, }, description: 'ID of the organization this deal will be associated with', @@ -1186,9 +1103,7 @@ export class Pipedrive implements INodeType { default: 0, displayOptions: { show: { - '/associateWith': [ - 'organization', - ], + '/associateWith': ['organization'], }, }, description: 'ID of the person this deal will be associated with', @@ -1212,7 +1127,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getStageIds', }, default: '', - description: 'ID of the stage this deal will be placed in a pipeline. If omitted, the deal will be placed in the first stage of the default pipeline. (PIPELINE > STAGE). Choose from the list, or specify an ID using an expression.', + description: + 'ID of the stage this deal will be placed in a pipeline. If omitted, the deal will be placed in the first stage of the default pipeline. (PIPELINE > STAGE). Choose from the list, or specify an ID using an expression.', }, { displayName: 'Status', @@ -1237,7 +1153,8 @@ export class Pipedrive implements INodeType { }, ], default: 'open', - description: 'The status of the deal. If not provided it will automatically be set to "open".', + description: + 'The status of the deal. If not provided it will automatically be set to "open".', }, { displayName: 'User Name or ID', @@ -1247,7 +1164,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getUserIds', }, default: '', - description: 'ID of the active user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the active user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -1271,7 +1189,8 @@ export class Pipedrive implements INodeType { }, ], default: '3', - description: 'Visibility of the deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.', + description: + 'Visibility of the deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.', }, ], }, @@ -1285,12 +1204,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'deal', - ], + operation: ['delete'], + resource: ['deal'], }, }, default: 0, @@ -1307,12 +1222,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'duplicate', - ], - resource: [ - 'deal', - ], + operation: ['duplicate'], + resource: ['deal'], }, }, default: 0, @@ -1329,12 +1240,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'deal', - ], + operation: ['get'], + resource: ['deal'], }, }, default: 0, @@ -1351,12 +1258,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'deal', - ], + operation: ['update'], + resource: ['deal'], }, }, default: 0, @@ -1370,12 +1273,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'deal', - ], + operation: ['update'], + resource: ['deal'], }, }, default: {}, @@ -1385,7 +1284,8 @@ export class Pipedrive implements INodeType { name: 'currency', type: 'string', default: 'USD', - description: 'Currency of the deal. Accepts a 3-character currency code. Like EUR, USD, ...', + description: + 'Currency of the deal. Accepts a 3-character currency code. Like EUR, USD, ...', }, { displayName: 'Custom Properties', @@ -1410,7 +1310,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getDealCustomFields', }, default: '', - description: 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Property Value', @@ -1431,13 +1332,15 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getUserIds', }, default: '', - description: 'ID of the active user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the active user whom the activity will be assigned to. If omitted, the activity will be assigned to the authorized user. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Label Name or ID', name: 'label', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getDealLabels', }, @@ -1458,7 +1361,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getOrganizationIds', }, default: '', - description: 'ID of the organization this deal will be associated with. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the organization this deal will be associated with. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Person ID', @@ -1486,7 +1390,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getStageIds', }, default: '', - description: 'ID of the stage this deal will be placed in a pipeline. If omitted, the deal will be placed in the first stage of the default pipeline. (PIPELINE > STAGE). Choose from the list, or specify an ID using an expression.', + description: + 'ID of the stage this deal will be placed in a pipeline. If omitted, the deal will be placed in the first stage of the default pipeline. (PIPELINE > STAGE). Choose from the list, or specify an ID using an expression.', }, { displayName: 'Status', @@ -1511,7 +1416,8 @@ export class Pipedrive implements INodeType { }, ], default: 'open', - description: 'The status of the deal. If not provided it will automatically be set to "open".', + description: + 'The status of the deal. If not provided it will automatically be set to "open".', }, { displayName: 'Title', @@ -1542,7 +1448,8 @@ export class Pipedrive implements INodeType { }, ], default: '3', - description: 'Visibility of the deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.', + description: + 'Visibility of the deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.', }, ], }, @@ -1560,15 +1467,12 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'dealProduct', - ], + operation: ['add'], + resource: ['dealProduct'], }, }, - description: 'The ID of the deal to add a product to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the deal to add a product to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Product Name or ID', @@ -1581,15 +1485,12 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'dealProduct', - ], + operation: ['add'], + resource: ['dealProduct'], }, }, - description: 'The ID of the product to add to a deal. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the product to add to a deal. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Item Price', @@ -1598,17 +1499,13 @@ export class Pipedrive implements INodeType { typeOptions: { numberPrecision: 2, }, - default: 0.00, + default: 0.0, required: true, description: 'Price at which to add or update this product in a deal', displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'dealProduct', - ], + operation: ['add'], + resource: ['dealProduct'], }, }, }, @@ -1624,12 +1521,8 @@ export class Pipedrive implements INodeType { description: 'How many items of this product to add/update in a deal', displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'dealProduct', - ], + operation: ['add'], + resource: ['dealProduct'], }, }, }, @@ -1640,12 +1533,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'dealProduct', - ], + operation: ['add'], + resource: ['dealProduct'], }, }, default: {}, @@ -1694,15 +1583,12 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'dealProduct', - ], + operation: ['update'], + resource: ['dealProduct'], }, }, - description: 'The ID of the deal whose product to update. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the deal whose product to update. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Product Attachment Name or ID', @@ -1711,22 +1597,17 @@ export class Pipedrive implements INodeType { default: '', typeOptions: { loadOptionsMethod: 'getProductsDeal', - loadOptionsDependsOn: [ - 'dealId', - ], + loadOptionsDependsOn: ['dealId'], }, required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'dealProduct', - ], + operation: ['update'], + resource: ['dealProduct'], }, }, - description: 'ID of the deal-product (the ID of the product attached to the deal). Choose from the list, or specify an ID using an expression.', + description: + 'ID of the deal-product (the ID of the product attached to the deal). Choose from the list, or specify an ID using an expression.', }, { displayName: 'Update Fields', @@ -1735,12 +1616,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'dealProduct', - ], + operation: ['update'], + resource: ['dealProduct'], }, }, default: {}, @@ -1773,7 +1650,7 @@ export class Pipedrive implements INodeType { typeOptions: { numberPrecision: 2, }, - default: 0.00, + default: 0.0, description: 'Price at which to add or update this product in a deal', }, { @@ -1809,15 +1686,12 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'remove', - ], - resource: [ - 'dealProduct', - ], + operation: ['remove'], + resource: ['dealProduct'], }, }, - description: 'The ID of the deal whose product to remove. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the deal whose product to remove. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Product Attachment Name or ID', @@ -1826,22 +1700,17 @@ export class Pipedrive implements INodeType { default: '', typeOptions: { loadOptionsMethod: 'getProductsDeal', - loadOptionsDependsOn: [ - 'dealId', - ], + loadOptionsDependsOn: ['dealId'], }, required: true, displayOptions: { show: { - operation: [ - 'remove', - ], - resource: [ - 'dealProduct', - ], + operation: ['remove'], + resource: ['dealProduct'], }, }, - description: 'ID of the deal-product (the ID of the product attached to the deal). Choose from the list, or specify an ID using an expression.', + description: + 'ID of the deal-product (the ID of the product attached to the deal). Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- // dealProduct:getAll @@ -1857,15 +1726,12 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'dealProduct', - ], + operation: ['getAll'], + resource: ['dealProduct'], }, }, - description: 'The ID of the deal whose products to retrieve. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the deal whose products to retrieve. Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- @@ -1878,16 +1744,13 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'deal', - ], + operation: ['search'], + resource: ['deal'], }, }, default: '', - description: 'The search term to look for. Minimum 2 characters (or 1 if using exact_match).', + description: + 'The search term to look for. Minimum 2 characters (or 1 if using exact_match).', }, { displayName: 'Exact Match', @@ -1895,16 +1758,13 @@ export class Pipedrive implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'deal', - ], + operation: ['search'], + resource: ['deal'], }, }, default: false, - description: 'Whether only full exact matches against the given term are returned. It is not case sensitive.', + description: + 'Whether only full exact matches against the given term are returned. It is not case sensitive.', }, { displayName: 'Return All', @@ -1912,9 +1772,7 @@ export class Pipedrive implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'search', - ], + operation: ['search'], }, }, default: false, @@ -1926,12 +1784,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'search', - ], - returnAll: [ - false, - ], + operation: ['search'], + returnAll: [false], }, }, typeOptions: { @@ -1948,12 +1802,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'deal', - ], + operation: ['search'], + resource: ['deal'], }, }, default: {}, @@ -1963,7 +1813,8 @@ export class Pipedrive implements INodeType { name: 'includeFields', type: 'string', default: '', - description: 'Supports including optional fields in the results which are not provided by default. Example: deal.cc_email.', + description: + 'Supports including optional fields in the results which are not provided by default. Example: deal.cc_email.', }, { displayName: 'Organization ID', @@ -1997,12 +1848,9 @@ export class Pipedrive implements INodeType { value: 'title', }, ], - default: [ - 'custom_fields', - 'notes', - 'title', - ], - description: 'A comma-separated string array. The fields to perform the search from. Defaults to all of them.', + default: ['custom_fields', 'notes', 'title'], + description: + 'A comma-separated string array. The fields to perform the search from. Defaults to all of them.', }, { displayName: 'Status', @@ -2023,12 +1871,12 @@ export class Pipedrive implements INodeType { }, ], default: 'open', - description: 'The status of the deal. If not provided it will automatically be set to "open".', + description: + 'The status of the deal. If not provided it will automatically be set to "open".', }, ], }, - // ---------------------------------- // file // ---------------------------------- @@ -2044,17 +1892,13 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'file', - ], + operation: ['create'], + resource: ['file'], }, - }, placeholder: '', - description: 'Name of the binary property which contains the data for the file to be created', + description: + 'Name of the binary property which contains the data for the file to be created', }, { displayName: 'Additional Fields', @@ -2063,12 +1907,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'file', - ], + operation: ['create'], + resource: ['file'], }, }, default: {}, @@ -2095,7 +1935,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getOrganizationIds', }, default: '', - description: 'ID of the organization this deal will be associated with. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the organization this deal will be associated with. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Person ID', @@ -2123,12 +1964,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'file', - ], + operation: ['delete'], + resource: ['file'], }, }, default: 0, @@ -2145,12 +1982,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'file', - ], + operation: ['download'], + resource: ['file'], }, }, default: 0, @@ -2165,15 +1998,12 @@ export class Pipedrive implements INodeType { default: 'data', displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'file', - ], + operation: ['download'], + resource: ['file'], }, }, - description: 'Name of the binary property to which to write the data of the downloaded file', + description: + 'Name of the binary property to which to write the data of the downloaded file', }, // ---------------------------------- @@ -2185,12 +2015,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'file', - ], + operation: ['get'], + resource: ['file'], }, }, default: 0, @@ -2210,12 +2036,8 @@ export class Pipedrive implements INodeType { default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - ], + resource: ['lead'], + operation: ['create'], }, }, }, @@ -2238,12 +2060,8 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - ], + resource: ['lead'], + operation: ['create'], }, }, }, @@ -2256,15 +2074,9 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - ], - associateWith: [ - 'organization', - ], + resource: ['lead'], + operation: ['create'], + associateWith: ['organization'], }, }, }, @@ -2277,15 +2089,9 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - ], - associateWith: [ - 'person', - ], + resource: ['lead'], + operation: ['create'], + associateWith: ['person'], }, }, }, @@ -2297,12 +2103,8 @@ export class Pipedrive implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - ], + resource: ['lead'], + operation: ['create'], }, }, options: [ @@ -2321,7 +2123,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getLeadLabels', }, default: [], - description: 'ID of the labels to attach to the lead to create. Choose from the list, or specify IDs using an expression.', + description: + 'ID of the labels to attach to the lead to create. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Organization ID', @@ -2331,9 +2134,7 @@ export class Pipedrive implements INodeType { description: 'ID of the organization to link to this lead', displayOptions: { show: { - '/associateWith': [ - 'person', - ], + '/associateWith': ['person'], }, }, }, @@ -2345,7 +2146,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getUserIds', }, default: '', - description: 'ID of the user who will own the lead to create. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user who will own the lead to create. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Person ID', @@ -2355,9 +2157,7 @@ export class Pipedrive implements INodeType { description: 'ID of the person to link to this lead', displayOptions: { show: { - '/associateWith': [ - 'organization', - ], + '/associateWith': ['organization'], }, }, }, @@ -2404,12 +2204,8 @@ export class Pipedrive implements INodeType { default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'delete', - ], + resource: ['lead'], + operation: ['delete'], }, }, }, @@ -2426,12 +2222,8 @@ export class Pipedrive implements INodeType { default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'get', - ], + resource: ['lead'], + operation: ['get'], }, }, }, @@ -2448,12 +2240,8 @@ export class Pipedrive implements INodeType { default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'update', - ], + resource: ['lead'], + operation: ['update'], }, }, }, @@ -2465,12 +2253,8 @@ export class Pipedrive implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'update', - ], + resource: ['lead'], + operation: ['update'], }, }, options: [ @@ -2489,7 +2273,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getUserIds', }, default: '', - description: 'ID of the user who will own the lead to update. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user who will own the lead to update. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Label Names or IDs', @@ -2499,7 +2284,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getLeadLabels', }, default: [], - description: 'ID of the labels to attach to the lead to update. Choose from the list, or specify IDs using an expression.', + description: + 'ID of the labels to attach to the lead to update. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Person Name or ID', @@ -2509,7 +2295,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getPersons', }, default: '', - description: 'ID of the person to link to this lead. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the person to link to this lead. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -2549,8 +2336,6 @@ export class Pipedrive implements INodeType { ], }, - - // ---------------------------------- // note // ---------------------------------- @@ -2569,12 +2354,8 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'note', - ], + operation: ['create'], + resource: ['note'], }, }, description: 'The content of the note to create', @@ -2633,12 +2414,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'note', - ], + operation: ['delete'], + resource: ['note'], }, }, default: 0, @@ -2655,12 +2432,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'note', - ], + operation: ['get'], + resource: ['note'], }, }, default: 0, @@ -2677,12 +2450,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'note', - ], + operation: ['update'], + resource: ['note'], }, }, default: 0, @@ -2696,12 +2465,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'note', - ], + operation: ['update'], + resource: ['note'], }, }, default: {}, @@ -2738,7 +2503,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getOrganizationIds', }, default: '', - description: 'ID of the organization this deal will be associated with. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the organization this deal will be associated with. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Person ID', @@ -2750,8 +2516,6 @@ export class Pipedrive implements INodeType { ], }, - - // ---------------------------------- // organization // ---------------------------------- @@ -2767,12 +2531,8 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'organization', - ], + operation: ['create'], + resource: ['organization'], }, }, description: 'The name of the organization to create', @@ -2784,12 +2544,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'organization', - ], + operation: ['create'], + resource: ['organization'], }, }, default: {}, @@ -2831,7 +2587,8 @@ export class Pipedrive implements INodeType { displayName: 'Label Name or ID', name: 'label', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getOrganizationLabels', }, @@ -2852,7 +2609,8 @@ export class Pipedrive implements INodeType { }, ], default: '3', - description: 'Visibility of the person. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.', + description: + 'Visibility of the person. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.', }, ], }, @@ -2866,12 +2624,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'organization', - ], + operation: ['delete'], + resource: ['organization'], }, }, default: 0, @@ -2888,12 +2642,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'organization', - ], + operation: ['get'], + resource: ['organization'], }, }, default: 0, @@ -2911,16 +2661,13 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'organization', - ], + operation: ['search'], + resource: ['organization'], }, }, default: '', - description: 'The search term to look for. Minimum 2 characters (or 1 if using exact_match).', + description: + 'The search term to look for. Minimum 2 characters (or 1 if using exact_match).', }, { displayName: 'Additional Fields', @@ -2929,12 +2676,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'organization', - ], + operation: ['search'], + resource: ['organization'], }, }, default: {}, @@ -2944,7 +2687,8 @@ export class Pipedrive implements INodeType { name: 'exactMatch', type: 'boolean', default: false, - description: 'Whether only full exact matches against the given term are returned. It is not case sensitive.', + description: + 'Whether only full exact matches against the given term are returned. It is not case sensitive.', }, { displayName: 'Fields', @@ -2976,7 +2720,8 @@ export class Pipedrive implements INodeType { name: 'rawData', type: 'boolean', default: false, - description: 'Whether to return the data exactly in the way it got received from the API', + description: + 'Whether to return the data exactly in the way it got received from the API', }, ], }, @@ -2991,12 +2736,8 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'organization', - ], + operation: ['update'], + resource: ['organization'], }, }, description: 'The ID of the organization to create', @@ -3008,12 +2749,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'organization', - ], + operation: ['update'], + resource: ['organization'], }, }, default: {}, @@ -3055,7 +2792,8 @@ export class Pipedrive implements INodeType { displayName: 'Label Name or ID', name: 'label', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getOrganizationLabels', }, @@ -3073,7 +2811,8 @@ export class Pipedrive implements INodeType { name: 'owner_id', type: 'number', default: 0, - description: 'The ID of the user who will be marked as the owner of this Organization. When omitted, the authorized User ID will be used.', + description: + 'The ID of the user who will be marked as the owner of this Organization. When omitted, the authorized User ID will be used.', }, { displayName: 'Visible To', @@ -3090,13 +2829,12 @@ export class Pipedrive implements INodeType { }, ], default: '3', - description: 'Visibility of the person. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.', + description: + 'Visibility of the person. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.', }, ], }, - - // ---------------------------------- // person // ---------------------------------- @@ -3112,12 +2850,8 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'person', - ], + operation: ['create'], + resource: ['person'], }, }, description: 'The name of the person to create', @@ -3129,12 +2863,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'person', - ], + operation: ['create'], + resource: ['person'], }, }, default: {}, @@ -3162,7 +2892,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getPersonCustomFields', }, default: '', - description: 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Property Value', @@ -3190,7 +2921,8 @@ export class Pipedrive implements INodeType { displayName: 'Label Name or ID', name: 'label', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getPersonLabels', }, @@ -3219,7 +2951,8 @@ export class Pipedrive implements INodeType { }, ], default: 'subscribed', - description: 'Please be aware that it is only allowed once to change the marketing status from an old status to a new one', + description: + 'Please be aware that it is only allowed once to change the marketing status from an old status to a new one', }, { displayName: 'Organization Name or ID', @@ -3229,7 +2962,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getOrganizationIds', }, default: '', - description: 'ID of the organization this deal will be associated with. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the organization this deal will be associated with. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Phone', @@ -3256,7 +2990,8 @@ export class Pipedrive implements INodeType { }, ], default: '3', - description: 'Visibility of the person. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.', + description: + 'Visibility of the person. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.', }, { displayName: 'User Name or ID', @@ -3266,7 +3001,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getUserIds', }, default: '', - description: 'ID of the User this deal will be associated with. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the User this deal will be associated with. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -3280,12 +3016,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'person', - ], + operation: ['delete'], + resource: ['person'], }, }, default: 0, @@ -3302,12 +3034,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'person', - ], + operation: ['get'], + resource: ['person'], }, }, default: 0, @@ -3324,12 +3052,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'person', - ], + operation: ['update'], + resource: ['person'], }, }, default: 0, @@ -3344,12 +3068,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'person', - ], + operation: ['update'], + resource: ['person'], }, }, default: {}, @@ -3377,7 +3097,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getPersonCustomFields', }, default: '', - description: 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Property Value', @@ -3405,7 +3126,8 @@ export class Pipedrive implements INodeType { displayName: 'Label Name or ID', name: 'label', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getPersonLabels', }, @@ -3434,7 +3156,8 @@ export class Pipedrive implements INodeType { }, ], default: 'subscribed', - description: 'Please be aware that it is only allowed once to change the marketing status from an old status to a new one', + description: + 'Please be aware that it is only allowed once to change the marketing status from an old status to a new one', }, { displayName: 'Name', @@ -3451,7 +3174,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getOrganizationIds', }, default: '', - description: 'ID of the organization this deal will be associated with. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the organization this deal will be associated with. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Phone', @@ -3471,7 +3195,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getUserIds', }, default: '', - description: 'ID of the User this person will be associated with. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the User this person will be associated with. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Visible To', @@ -3488,14 +3213,12 @@ export class Pipedrive implements INodeType { }, ], default: '3', - description: 'Visibility of the deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.', + description: + 'Visibility of the deal. If omitted, visibility will be set to the default visibility setting of this item type for the authorized user.', }, ], }, - - - // ---------------------------------- // activity / deal / note / organization / person / product // ---------------------------------- @@ -3505,22 +3228,14 @@ export class Pipedrive implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'activity', - 'deal', - 'organization', - 'person', - 'product', - ], - operation: [ - 'get', - 'getAll', - ], + resource: ['activity', 'deal', 'organization', 'person', 'product'], + operation: ['get', 'getAll'], }, }, default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default do custom properties get returned only as ID instead of their actual name. Also option fields contain only the ID instead of their actual value. If this option gets set they get automatically resolved.', + description: + 'By default do custom properties get returned only as ID instead of their actual name. Also option fields contain only the ID instead of their actual value. If this option gets set they get automatically resolved.', }, { displayName: 'Encode Properties', @@ -3528,21 +3243,14 @@ export class Pipedrive implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'activity', - 'deal', - 'organization', - 'person', - 'product', - ], - operation: [ - 'update', - ], + resource: ['activity', 'deal', 'organization', 'person', 'product'], + operation: ['update'], }, }, default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default do custom properties have to be set as ID instead of their actual name. Also option fields have to be set as ID instead of their actual value. If this option gets set they get automatically encoded.', + description: + 'By default do custom properties have to be set as ID instead of their actual name. Also option fields have to be set as ID instead of their actual value. If this option gets set they get automatically encoded.', }, { displayName: 'Return All', @@ -3550,9 +3258,7 @@ export class Pipedrive implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: false, @@ -3564,12 +3270,8 @@ export class Pipedrive implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -3594,15 +3296,12 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'dealActivity', - ], + operation: ['getAll'], + resource: ['dealActivity'], }, }, - description: 'The ID of the deal whose activity to retrieve. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the deal whose activity to retrieve. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Additional Fields', @@ -3611,12 +3310,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'dealActivity', - ], + operation: ['getAll'], + resource: ['dealActivity'], }, }, default: {}, @@ -3633,7 +3328,8 @@ export class Pipedrive implements INodeType { name: 'exclude', type: 'string', default: '', - description: 'A comma-separated Activity IDs, to exclude from result. Ex. 4, 9, 11, ...', + description: + 'A comma-separated Activity IDs, to exclude from result. Ex. 4, 9, 11, ...', }, ], }, @@ -3649,12 +3345,8 @@ export class Pipedrive implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'getAll', - ], + resource: ['lead'], + operation: ['getAll'], }, }, options: [ @@ -3691,12 +3383,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'organization', - ], + operation: ['getAll'], + resource: ['organization'], }, }, default: {}, @@ -3706,7 +3394,8 @@ export class Pipedrive implements INodeType { name: 'firstChar', type: 'string', default: '', - description: 'If supplied, only organizations whose name starts with the specified letter will be returned', + description: + 'If supplied, only organizations whose name starts with the specified letter will be returned', }, { displayName: 'Predefined Filter Name or ID', @@ -3716,7 +3405,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getFilters', }, default: '', - description: 'ID of the filter to use. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the filter to use. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -3731,12 +3421,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'person', - ], + operation: ['getAll'], + resource: ['person'], }, }, default: {}, @@ -3749,14 +3435,16 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getFilters', }, default: '', - description: 'ID of the filter to use. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the filter to use. Choose from the list, or specify an ID using an expression.', }, { displayName: 'First Char', name: 'firstChar', type: 'string', default: '', - description: 'If supplied, only persons whose name starts with the specified letter will be returned', + description: + 'If supplied, only persons whose name starts with the specified letter will be returned', }, ], }, @@ -3771,16 +3459,13 @@ export class Pipedrive implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'person', - ], + operation: ['search'], + resource: ['person'], }, }, default: '', - description: 'The search term to look for. Minimum 2 characters (or 1 if using exact_match).', + description: + 'The search term to look for. Minimum 2 characters (or 1 if using exact_match).', }, { displayName: 'Additional Fields', @@ -3789,12 +3474,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'person', - ], + operation: ['search'], + resource: ['person'], }, }, default: {}, @@ -3804,21 +3485,24 @@ export class Pipedrive implements INodeType { name: 'exactMatch', type: 'boolean', default: false, - description: 'Whether only full exact matches against the given term are returned. It is not case sensitive.', + description: + 'Whether only full exact matches against the given term are returned. It is not case sensitive.', }, { displayName: 'Fields', name: 'fields', type: 'string', default: '', - description: 'A comma-separated string array. The fields to perform the search from. Defaults to all of them.', + description: + 'A comma-separated string array. The fields to perform the search from. Defaults to all of them.', }, { displayName: 'Include Fields', name: 'includeFields', type: 'string', default: '', - description: 'Supports including optional fields in the results which are not provided by default', + description: + 'Supports including optional fields in the results which are not provided by default', }, { displayName: 'Organization ID', @@ -3832,7 +3516,8 @@ export class Pipedrive implements INodeType { name: 'rawData', type: 'boolean', default: false, - description: 'Whether to return the data exactly in the way it got received from the API', + description: + 'Whether to return the data exactly in the way it got received from the API', }, ], }, @@ -3847,13 +3532,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - 'getAll', - ], - resource: [ - 'note', - ], + operation: ['create', 'getAll'], + resource: ['note'], }, }, default: {}, @@ -3880,7 +3560,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getOrganizationIds', }, default: '', - description: 'ID of the organization this deal will be associated with. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the organization this deal will be associated with. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Person ID', @@ -3901,12 +3582,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'activity', - ], + operation: ['getAll'], + resource: ['activity'], }, }, default: {}, @@ -3916,14 +3593,16 @@ export class Pipedrive implements INodeType { name: 'done', type: 'boolean', default: false, - description: 'Whether the Activity is done or not. 0 = Not done, 1 = Done. If omitted returns both Done and Not done activities.', + description: + 'Whether the Activity is done or not. 0 = Not done, 1 = Done. If omitted returns both Done and Not done activities.', }, { displayName: 'End Date', name: 'end_date', type: 'dateTime', default: '', - description: 'Use the Activity due date where you wish to stop fetching Activities from. Insert due date in YYYY-MM-DD format.', + description: + 'Use the Activity due date where you wish to stop fetching Activities from. Insert due date in YYYY-MM-DD format.', }, { displayName: 'Predefined Filter Name or ID', @@ -3933,14 +3612,16 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getFilters', }, default: '', - description: 'The ID of the Filter to use (will narrow down results if used together with user_id parameter). Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the Filter to use (will narrow down results if used together with user_id parameter). Choose from the list, or specify an ID using an expression.', }, { displayName: 'Star Date', name: 'start_date', type: 'dateTime', default: '', - description: 'Use the Activity due date where you wish to begin fetching Activities from. Insert due date in YYYY-MM-DD format.', + description: + 'Use the Activity due date where you wish to begin fetching Activities from. Insert due date in YYYY-MM-DD format.', }, { displayName: 'Type Names or IDs', @@ -3950,7 +3631,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getActivityTypes', }, default: [], - description: 'Type of the Activity. Choose from the list, or specify IDs using an expression.', + description: + 'Type of the Activity. Choose from the list, or specify IDs using an expression.', }, { displayName: 'User Name or ID', @@ -3960,7 +3642,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getUserIds', }, default: '', - description: 'The ID of the User whose Activities will be fetched. If omitted, the User associated with the API token will be used. If 0, Activities for all company Users will be fetched based on the permission sets. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the User whose Activities will be fetched. If omitted, the User associated with the API token will be used. If 0, Activities for all company Users will be fetched based on the permission sets. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -3974,12 +3657,8 @@ export class Pipedrive implements INodeType { placeholder: 'Add Filter', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'deal', - ], + operation: ['getAll'], + resource: ['deal'], }, }, default: {}, @@ -3992,7 +3671,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getFilters', }, default: '', - description: 'Predefined filter to apply to the deals to retrieve. Choose from the list, or specify an ID using an expression.', + description: + 'Predefined filter to apply to the deals to retrieve. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Stage Name or ID', @@ -4002,7 +3682,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getStageIds', }, default: '', - description: 'ID of the stage to filter deals by. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the stage to filter deals by. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Status', @@ -4041,7 +3722,8 @@ export class Pipedrive implements INodeType { loadOptionsMethod: 'getUserIds', }, default: '', - description: 'ID of the user to filter deals by. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to filter deals by. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -4070,13 +3752,19 @@ export class Pipedrive implements INodeType { const returnData: INodePropertyOptions[] = []; const resource = this.getNodeParameter('resource') as string; const type = { - 'deal': 'deals', - 'activity': 'activity', - 'person': 'people', - 'organization': 'org', + deal: 'deals', + activity: 'activity', + person: 'people', + organization: 'org', } as { [id: string]: string }; - const { data } = await pipedriveApiRequest.call(this, 'GET', '/filters', {}, { type: type[resource] as string }); + const { data } = await pipedriveApiRequest.call( + this, + 'GET', + '/filters', + {}, + { type: type[resource] as string }, + ); for (const filter of data) { returnData.push({ name: filter.name, @@ -4115,7 +3803,7 @@ export class Pipedrive implements INodeType { } } - if(resource === 'activity'){ + if (resource === 'activity') { returnData.push({ name: 'All Users', value: 0, @@ -4127,26 +3815,30 @@ export class Pipedrive implements INodeType { // Get all Deals to display them to user so that he can // select them easily async getDeals(this: ILoadOptionsFunctions): Promise { - const { data } = await pipedriveApiRequest.call(this, 'GET', '/deals', {}) as { - data: Array<{ id: string; title: string; }> + const { data } = (await pipedriveApiRequest.call(this, 'GET', '/deals', {})) as { + data: Array<{ id: string; title: string }>; }; return sortOptionParameters(data.map(({ id, title }) => ({ value: id, name: title }))); }, // Get all Products to display them to user so that he can // select them easily async getProducts(this: ILoadOptionsFunctions): Promise { - const { data } = await pipedriveApiRequest.call(this, 'GET', '/products', {}) as { - data: Array<{ id: string; name: string; }> + const { data } = (await pipedriveApiRequest.call(this, 'GET', '/products', {})) as { + data: Array<{ id: string; name: string }>; }; return sortOptionParameters(data.map(({ id, name }) => ({ value: id, name }))); }, // Get all Products related to a deal and display them to user so that he can // select them easily async getProductsDeal(this: ILoadOptionsFunctions): Promise { - const dealId = this.getCurrentNodeParameter('dealId'); - const { data } = await pipedriveApiRequest.call(this, 'GET', `/deals/${dealId}/products`, {}) as { - data: Array<{ id: string; name: string; }> + const { data } = (await pipedriveApiRequest.call( + this, + 'GET', + `/deals/${dealId}/products`, + {}, + )) as { + data: Array<{ id: string; name: string }>; }; return sortOptionParameters(data.map(({ id, name }) => ({ value: id, name }))); }, @@ -4166,7 +3858,9 @@ export class Pipedrive implements INodeType { }, // Get all the Organization Custom Fields to display them to user so that he can // select them easily - async getOrganizationCustomFields(this: ILoadOptionsFunctions): Promise { + async getOrganizationCustomFields( + this: ILoadOptionsFunctions, + ): Promise { const returnData: INodePropertyOptions[] = []; const { data } = await pipedriveApiRequest.call(this, 'GET', '/organizationFields', {}); for (const field of data) { @@ -4274,8 +3968,8 @@ export class Pipedrive implements INodeType { // Get all the persons to display them to user so that he can // select them easily async getPersons(this: ILoadOptionsFunctions): Promise { - const { data } = await pipedriveApiRequest.call(this, 'GET', '/persons', {}) as { - data: Array<{ id: string; name: string; }> + const { data } = (await pipedriveApiRequest.call(this, 'GET', '/persons', {})) as { + data: Array<{ id: string; name: string }>; }; return sortOptionParameters(data.map(({ id, name }) => ({ value: id, name }))); @@ -4284,8 +3978,8 @@ export class Pipedrive implements INodeType { // Get all the lead labels to display them to user so that he can // select them easily async getLeadLabels(this: ILoadOptionsFunctions): Promise { - const { data } = await pipedriveApiRequest.call(this, 'GET', '/leadLabels', {}) as { - data: Array<{ id: string; name: string; }> + const { data } = (await pipedriveApiRequest.call(this, 'GET', '/leadLabels', {})) as { + data: Array<{ id: string; name: string }>; }; return sortOptionParameters(data.map(({ id, name }) => ({ value: id, name }))); @@ -4323,7 +4017,6 @@ export class Pipedrive implements INodeType { }, }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -4345,7 +4038,10 @@ export class Pipedrive implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; let customProperties: ICustomProperties | undefined; - if (['get', 'getAll', 'update'].includes(operation) && ['activity', 'deal', 'organization', 'person', 'product'].includes(resource)) { + if ( + ['get', 'getAll', 'update'].includes(operation) && + ['activity', 'deal', 'organization', 'person', 'product'].includes(resource) + ) { // Request the custom properties once in the beginning to not query it multiple // times if multiple items get updated @@ -4362,7 +4058,6 @@ export class Pipedrive implements INodeType { } for (let i = 0; i < items.length; i++) { - requestMethod = 'GET'; endpoint = ''; downloadFile = false; @@ -4384,7 +4079,6 @@ export class Pipedrive implements INodeType { body.type = this.getNodeParameter('type', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body, additionalFields); - } else if (operation === 'delete') { // ---------------------------------- // activity:delete @@ -4394,7 +4088,6 @@ export class Pipedrive implements INodeType { const activityId = this.getNodeParameter('activityId', i) as number; endpoint = `/activities/${activityId}`; - } else if (operation === 'get') { // ---------------------------------- // activity:get @@ -4405,7 +4098,6 @@ export class Pipedrive implements INodeType { const activityId = this.getNodeParameter('activityId', i) as number; endpoint = `/activities/${activityId}`; - } else if (operation === 'getAll') { // ---------------------------------- // activity:getAll @@ -4431,7 +4123,6 @@ export class Pipedrive implements INodeType { } endpoint = `/activities`; - } else if (operation === 'update') { // ---------------------------------- // activity:update @@ -4444,7 +4135,6 @@ export class Pipedrive implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; addAdditionalFields(body, updateFields); - } } else if (resource === 'deal') { if (operation === 'create') { @@ -4457,7 +4147,9 @@ export class Pipedrive implements INodeType { body.title = this.getNodeParameter('title', i) as string; - const associateWith = this.getNodeParameter('associateWith', i) as 'organization' | 'person'; + const associateWith = this.getNodeParameter('associateWith', i) as + | 'organization' + | 'person'; if (associateWith === 'organization') { body.org_id = this.getNodeParameter('org_id', i) as string; @@ -4467,7 +4159,6 @@ export class Pipedrive implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body, additionalFields); - } else if (operation === 'delete') { // ---------------------------------- // deal:delete @@ -4477,7 +4168,6 @@ export class Pipedrive implements INodeType { const dealId = this.getNodeParameter('dealId', i) as number; endpoint = `/deals/${dealId}`; - } else if (operation === 'duplicate') { // ---------------------------------- // deal:duplicate @@ -4487,7 +4177,6 @@ export class Pipedrive implements INodeType { const dealId = this.getNodeParameter('dealId', i) as number; endpoint = `/deals/${dealId}/duplicate`; - } else if (operation === 'get') { // ---------------------------------- // deal:get @@ -4497,7 +4186,6 @@ export class Pipedrive implements INodeType { const dealId = this.getNodeParameter('dealId', i) as number; endpoint = `/deals/${dealId}`; - } else if (operation === 'getAll') { // ---------------------------------- // deal:getAll @@ -4513,7 +4201,6 @@ export class Pipedrive implements INodeType { addAdditionalFields(qs, filters); endpoint = `/deals`; - } else if (operation === 'update') { // ---------------------------------- // deal:update @@ -4566,12 +4253,9 @@ export class Pipedrive implements INodeType { } endpoint = `/deals/search`; - } - } else if (resource === 'dealActivity') { - - if (operation === 'getAll') { + if (operation === 'getAll') { // ---------------------------------- // dealActivity: getAll // ---------------------------------- @@ -4588,7 +4272,7 @@ export class Pipedrive implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (additionalFields.exclude) { - qs.exclude = (additionalFields.exclude as string); + qs.exclude = additionalFields.exclude as string; } if (additionalFields && additionalFields.done !== undefined) { @@ -4596,10 +4280,8 @@ export class Pipedrive implements INodeType { } endpoint = `/deals/${dealId}/activities`; - } } else if (resource === 'dealProduct') { - if (operation === 'add') { // ---------------------------------- // dealProduct: add @@ -4610,13 +4292,12 @@ export class Pipedrive implements INodeType { endpoint = `/deals/${dealId}/products`; - body.product_id = this.getNodeParameter('productId', i) as string; + body.product_id = this.getNodeParameter('productId', i) as string; body.item_price = this.getNodeParameter('item_price', i) as string; body.quantity = this.getNodeParameter('quantity', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body, additionalFields); - } else if (operation === 'getAll') { // ---------------------------------- // dealProduct: getAll @@ -4626,7 +4307,6 @@ export class Pipedrive implements INodeType { const dealId = this.getNodeParameter('dealId', i) as string; endpoint = `/deals/${dealId}/products`; - } else if (operation === 'remove') { // ---------------------------------- // dealProduct: remove @@ -4637,7 +4317,6 @@ export class Pipedrive implements INodeType { const productAttachmentId = this.getNodeParameter('productAttachmentId', i) as string; endpoint = `/deals/${dealId}/products/${productAttachmentId}`; - } else if (operation === 'update') { // ---------------------------------- // dealProduct: update @@ -4652,7 +4331,6 @@ export class Pipedrive implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; addAdditionalFields(body, updateFields); } - } else if (resource === 'file') { if (operation === 'create') { // ---------------------------------- @@ -4664,13 +4342,19 @@ export class Pipedrive implements INodeType { const item = items[i]; if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; if (item.binary[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + { itemIndex: i }, + ); } const fileBufferData = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); @@ -4685,7 +4369,6 @@ export class Pipedrive implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(formData, additionalFields); - } else if (operation === 'delete') { // ---------------------------------- // file:delete @@ -4695,7 +4378,6 @@ export class Pipedrive implements INodeType { const fileId = this.getNodeParameter('fileId', i) as number; endpoint = `/files/${fileId}`; - } else if (operation === 'download') { // ---------------------------------- // file:download @@ -4706,7 +4388,6 @@ export class Pipedrive implements INodeType { const fileId = this.getNodeParameter('fileId', i) as number; endpoint = `/files/${fileId}/download`; - } else if (operation === 'get') { // ---------------------------------- // file:get @@ -4716,7 +4397,6 @@ export class Pipedrive implements INodeType { const fileId = this.getNodeParameter('fileId', i) as number; endpoint = `/files/${fileId}`; - } } else if (resource === 'note') { if (operation === 'create') { @@ -4730,7 +4410,6 @@ export class Pipedrive implements INodeType { body.content = this.getNodeParameter('content', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body, additionalFields); - } else if (operation === 'delete') { // ---------------------------------- // note:delete @@ -4740,7 +4419,6 @@ export class Pipedrive implements INodeType { const noteId = this.getNodeParameter('noteId', i) as number; endpoint = `/notes/${noteId}`; - } else if (operation === 'get') { // ---------------------------------- // note:get @@ -4750,7 +4428,6 @@ export class Pipedrive implements INodeType { const noteId = this.getNodeParameter('noteId', i) as number; endpoint = `/notes/${noteId}`; - } else if (operation === 'getAll') { // ---------------------------------- // note:getAll @@ -4765,7 +4442,6 @@ export class Pipedrive implements INodeType { } const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(qs, additionalFields); - } else if (operation === 'update') { // ---------------------------------- // note:update @@ -4778,13 +4454,9 @@ export class Pipedrive implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; addAdditionalFields(body, updateFields); - } - } else if (resource === 'lead') { - if (operation === 'create') { - // ---------------------------------------- // lead: create // ---------------------------------------- @@ -4795,7 +4467,9 @@ export class Pipedrive implements INodeType { title: this.getNodeParameter('title', i), } as IDataObject; - const associateWith = this.getNodeParameter('associateWith', i) as 'organization' | 'person'; + const associateWith = this.getNodeParameter('associateWith', i) as + | 'organization' + | 'person'; if (associateWith === 'organization') { body.organization_id = this.getNodeParameter('organization_id', i) as number; @@ -4803,16 +4477,19 @@ export class Pipedrive implements INodeType { body.person_id = this.getNodeParameter('person_id', i) as number; } - const { value, expected_close_date, ...rest } = this.getNodeParameter('additionalFields', i) as { + const { value, expected_close_date, ...rest } = this.getNodeParameter( + 'additionalFields', + i, + ) as { value: { valueProperties: { amount: number; currency: string; - } + }; }; expected_close_date: string; - person_id: number, - organization_id: number, + person_id: number; + organization_id: number; }; if (Object.keys(rest).length) { @@ -4829,9 +4506,7 @@ export class Pipedrive implements INodeType { requestMethod = 'POST'; endpoint = '/leads'; - } else if (operation === 'delete') { - // ---------------------------------------- // lead: delete // ---------------------------------------- @@ -4842,9 +4517,7 @@ export class Pipedrive implements INodeType { requestMethod = 'DELETE'; endpoint = `/leads/${leadId}`; - } else if (operation === 'get') { - // ---------------------------------------- // lead: get // ---------------------------------------- @@ -4855,9 +4528,7 @@ export class Pipedrive implements INodeType { requestMethod = 'GET'; endpoint = `/leads/${leadId}`; - } else if (operation === 'getAll') { - // ---------------------------------------- // lead: getAll // ---------------------------------------- @@ -4877,21 +4548,22 @@ export class Pipedrive implements INodeType { requestMethod = 'GET'; endpoint = '/leads'; - } else if (operation === 'update') { - // ---------------------------------------- // lead: update // ---------------------------------------- // https://developers.pipedrive.com/docs/api/v1/Leads#updateLead - const { value, expected_close_date, ...rest } = this.getNodeParameter('updateFields', i) as { + const { value, expected_close_date, ...rest } = this.getNodeParameter( + 'updateFields', + i, + ) as { value: { valueProperties: { amount: number; currency: string; - } + }; }; expected_close_date: string; }; @@ -4916,9 +4588,7 @@ export class Pipedrive implements INodeType { requestMethod = 'PATCH'; endpoint = `/leads/${leadId}`; - } - } else if (resource === 'organization') { if (operation === 'create') { // ---------------------------------- @@ -4931,7 +4601,6 @@ export class Pipedrive implements INodeType { body.name = this.getNodeParameter('name', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body, additionalFields); - } else if (operation === 'delete') { // ---------------------------------- // organization:delete @@ -4941,7 +4610,6 @@ export class Pipedrive implements INodeType { const organizationId = this.getNodeParameter('organizationId', i) as number; endpoint = `/organizations/${organizationId}`; - } else if (operation === 'get') { // ---------------------------------- // organization:get @@ -4951,7 +4619,6 @@ export class Pipedrive implements INodeType { const organizationId = this.getNodeParameter('organizationId', i) as number; endpoint = `/organizations/${organizationId}`; - } else if (operation === 'getAll') { // ---------------------------------- // organization:getAll @@ -4976,7 +4643,6 @@ export class Pipedrive implements INodeType { } endpoint = `/organizations`; - } else if (operation === 'update') { // ---------------------------------- // organization:update @@ -4993,7 +4659,6 @@ export class Pipedrive implements INodeType { if (body.label === 'null') { body.label = null; } - } else if (operation === 'search') { // ---------------------------------- // organization:search @@ -5033,7 +4698,6 @@ export class Pipedrive implements INodeType { body.name = this.getNodeParameter('name', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body, additionalFields); - } else if (operation === 'delete') { // ---------------------------------- // person:delete @@ -5043,7 +4707,6 @@ export class Pipedrive implements INodeType { const personId = this.getNodeParameter('personId', i) as number; endpoint = `/persons/${personId}`; - } else if (operation === 'get') { // ---------------------------------- // person:get @@ -5053,7 +4716,6 @@ export class Pipedrive implements INodeType { const personId = this.getNodeParameter('personId', i) as number; endpoint = `/persons/${personId}`; - } else if (operation === 'getAll') { // ---------------------------------- // person:getAll @@ -5077,7 +4739,6 @@ export class Pipedrive implements INodeType { } endpoint = `/persons`; - } else if (operation === 'search') { // ---------------------------------- // persons:search @@ -5110,7 +4771,6 @@ export class Pipedrive implements INodeType { } endpoint = `/persons/search`; - } else if (operation === 'update') { // ---------------------------------- // person:update @@ -5127,7 +4787,6 @@ export class Pipedrive implements INodeType { if (body.label === 'null') { body.label = null; } - } } else if (resource === 'product') { if (operation === 'getAll') { @@ -5143,25 +4802,36 @@ export class Pipedrive implements INodeType { } endpoint = `/products`; - } } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { + itemIndex: i, + }); } let responseData; if (returnAll === true) { - - responseData = await pipedriveApiRequestAllItems.call(this, requestMethod, endpoint, body, qs); - + responseData = await pipedriveApiRequestAllItems.call( + this, + requestMethod, + endpoint, + body, + qs, + ); } else { - if (customProperties !== undefined) { pipedriveEncodeCustomProperties(customProperties!, body); } - responseData = await pipedriveApiRequest.call(this, requestMethod, endpoint, body, qs, formData, downloadFile); - + responseData = await pipedriveApiRequest.call( + this, + requestMethod, + endpoint, + body, + qs, + formData, + downloadFile, + ); } if (resource === 'file' && operation === 'download') { @@ -5181,9 +4851,10 @@ export class Pipedrive implements INodeType { const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; - items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData(responseData.data); + items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData( + responseData.data, + ); } else { - if (responseData.data === null) { responseData.data = []; } @@ -5192,12 +4863,14 @@ export class Pipedrive implements INodeType { responseData.data = responseData.data.items; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (additionalFields.rawData !== true) { - responseData.data = responseData.data.map((item: { result_score: number, item: object }) => { - return { - result_score: item.result_score, - ...item.item, - }; - }); + responseData.data = responseData.data.map( + (item: { result_score: number; item: object }) => { + return { + result_score: item.result_score, + ...item.item, + }; + }, + ); } } diff --git a/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts b/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts index 7ef3643c4e..8bed90aee6 100644 --- a/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts +++ b/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -10,15 +7,11 @@ import { IWebhookResponseData, } from 'n8n-workflow'; -import { - pipedriveApiRequest, -} from './GenericFunctions'; +import { pipedriveApiRequest } from './GenericFunctions'; import basicAuth from 'basic-auth'; -import { - Response, -} from 'express'; +import { Response } from 'express'; function authorizationError(resp: Response, realm: string, responseCode: number, message?: string) { if (message === undefined) { @@ -56,9 +49,7 @@ export class PipedriveTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'apiToken', - ], + authentication: ['apiToken'], }, }, }, @@ -67,9 +58,7 @@ export class PipedriveTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -78,9 +67,7 @@ export class PipedriveTrigger implements INodeType { required: true, displayOptions: { show: { - incomingAuthentication: [ - 'basicAuth', - ], + incomingAuthentication: ['basicAuth'], }, }, }, @@ -244,9 +231,11 @@ export class PipedriveTrigger implements INodeType { } for (const existingData of responseData.data) { - if (existingData.subscription_url === webhookUrl - && existingData.event_action === eventAction - && existingData.event_object === eventObject) { + if ( + existingData.subscription_url === webhookUrl && + existingData.event_action === eventAction && + existingData.event_object === eventObject + ) { // The webhook exists already webhookData.webhookId = existingData.id; return true; @@ -354,16 +343,17 @@ export class PipedriveTrigger implements INodeType { return authorizationError(resp, realm, 401); } - if (basicAuthData.name !== httpBasicAuth!.user || basicAuthData.pass !== httpBasicAuth!.password) { + if ( + basicAuthData.name !== httpBasicAuth!.user || + basicAuthData.pass !== httpBasicAuth!.password + ) { // Provided authentication data is wrong return authorizationError(resp, realm, 403); } } return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/Plivo/CallDescription.ts b/packages/nodes-base/nodes/Plivo/CallDescription.ts index 0ab03a9483..d5d0b2314f 100644 --- a/packages/nodes-base/nodes/Plivo/CallDescription.ts +++ b/packages/nodes-base/nodes/Plivo/CallDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const callOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const callOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'call', - ], + resource: ['call'], }, }, options: [ @@ -41,12 +37,8 @@ export const callFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'call', - ], - operation: [ - 'make', - ], + resource: ['call'], + operation: ['make'], }, }, }, @@ -60,12 +52,8 @@ export const callFields: INodeProperties[] = [ description: 'Phone number to make the call to', displayOptions: { show: { - resource: [ - 'call', - ], - operation: [ - 'make', - ], + resource: ['call'], + operation: ['make'], }, }, }, @@ -88,12 +76,8 @@ export const callFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'call', - ], - operation: [ - 'make', - ], + resource: ['call'], + operation: ['make'], }, }, }, @@ -102,16 +86,13 @@ export const callFields: INodeProperties[] = [ name: 'answer_url', type: 'string', default: '', - description: 'URL to be invoked by Plivo once the call is answered. It should return the XML to handle the call once answered.', + description: + 'URL to be invoked by Plivo once the call is answered. It should return the XML to handle the call once answered.', required: true, displayOptions: { show: { - resource: [ - 'call', - ], - operation: [ - 'make', - ], + resource: ['call'], + operation: ['make'], }, }, }, diff --git a/packages/nodes-base/nodes/Plivo/GenericFunctions.ts b/packages/nodes-base/nodes/Plivo/GenericFunctions.ts index 00433769a5..940ab5fb87 100644 --- a/packages/nodes-base/nodes/Plivo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Plivo/GenericFunctions.ts @@ -1,17 +1,8 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - IDataObject, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; /** * Make an API request to Plivo. @@ -29,8 +20,10 @@ export async function plivoApiRequest( body: IDataObject = {}, qs: IDataObject = {}, ) { - - const credentials = await this.getCredentials('plivoApi') as { authId: string, authToken: string }; + const credentials = (await this.getCredentials('plivoApi')) as { + authId: string; + authToken: string; + }; const options: OptionsWithUri = { headers: { diff --git a/packages/nodes-base/nodes/Plivo/MmsDescription.ts b/packages/nodes-base/nodes/Plivo/MmsDescription.ts index 54a437cb4b..63cbb64e27 100644 --- a/packages/nodes-base/nodes/Plivo/MmsDescription.ts +++ b/packages/nodes-base/nodes/Plivo/MmsDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const mmsOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const mmsOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'mms', - ], + resource: ['mms'], }, }, options: [ @@ -41,12 +37,8 @@ export const mmsFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'mms', - ], - operation: [ - 'send', - ], + resource: ['mms'], + operation: ['send'], }, }, }, @@ -60,12 +52,8 @@ export const mmsFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'mms', - ], + operation: ['send'], + resource: ['mms'], }, }, }, @@ -77,12 +65,8 @@ export const mmsFields: INodeProperties[] = [ description: 'Message to send', displayOptions: { show: { - resource: [ - 'mms', - ], - operation: [ - 'send', - ], + resource: ['mms'], + operation: ['send'], }, }, }, @@ -93,12 +77,8 @@ export const mmsFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'mms', - ], - operation: [ - 'send', - ], + resource: ['mms'], + operation: ['send'], }, }, description: 'Comma-separated list of media URLs of the files from your file server', diff --git a/packages/nodes-base/nodes/Plivo/Plivo.node.ts b/packages/nodes-base/nodes/Plivo/Plivo.node.ts index 659a4ee5a4..8fa16224b4 100644 --- a/packages/nodes-base/nodes/Plivo/Plivo.node.ts +++ b/packages/nodes-base/nodes/Plivo/Plivo.node.ts @@ -1,32 +1,14 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - smsFields, - smsOperations, -} from './SmsDescription'; +import { smsFields, smsOperations } from './SmsDescription'; -import { - mmsFields, - mmsOperations, -} from './MmsDescription'; +import { mmsFields, mmsOperations } from './MmsDescription'; -import { - callFields, - callOperations, -} from './CallDescription'; +import { callFields, callOperations } from './CallDescription'; -import { - plivoApiRequest, -} from './GenericFunctions'; +import { plivoApiRequest } from './GenericFunctions'; export class Plivo implements INodeType { description: INodeTypeDescription = { @@ -89,17 +71,14 @@ export class Plivo implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < items.length; i++) { - let responseData; if (resource === 'sms') { - // ********************************************************************* // sms // ********************************************************************* if (operation === 'send') { - // ---------------------------------- // sms: send // ---------------------------------- @@ -111,17 +90,13 @@ export class Plivo implements INodeType { } as IDataObject; responseData = await plivoApiRequest.call(this, 'POST', '/Message', body); - } - } else if (resource === 'call') { - // ********************************************************************* // call // ********************************************************************* if (operation === 'make') { - // ---------------------------------- // call: make // ---------------------------------- @@ -136,17 +111,13 @@ export class Plivo implements INodeType { } as IDataObject; responseData = await plivoApiRequest.call(this, 'POST', '/Call', body); - } - } else if (resource === 'mms') { - // ********************************************************************* // mms // ********************************************************************* if (operation === 'send') { - // ---------------------------------- // mss: send // ---------------------------------- @@ -162,15 +133,12 @@ export class Plivo implements INodeType { } as IDataObject; responseData = await plivoApiRequest.call(this, 'POST', '/Message', body); - } - } Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Plivo/SmsDescription.ts b/packages/nodes-base/nodes/Plivo/SmsDescription.ts index a180b33cb5..5c4d2d2063 100644 --- a/packages/nodes-base/nodes/Plivo/SmsDescription.ts +++ b/packages/nodes-base/nodes/Plivo/SmsDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const smsOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const smsOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'sms', - ], + resource: ['sms'], }, }, options: [ @@ -41,12 +37,8 @@ export const smsFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'sms', - ], - operation: [ - 'send', - ], + resource: ['sms'], + operation: ['send'], }, }, }, @@ -60,12 +52,8 @@ export const smsFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'sms', - ], - operation: [ - 'send', - ], + resource: ['sms'], + operation: ['send'], }, }, }, @@ -78,12 +66,8 @@ export const smsFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - ], + operation: ['send'], + resource: ['sms'], }, }, }, diff --git a/packages/nodes-base/nodes/PostBin/BinDescription.ts b/packages/nodes-base/nodes/PostBin/BinDescription.ts index dda2da7371..ea9a5c6255 100644 --- a/packages/nodes-base/nodes/PostBin/BinDescription.ts +++ b/packages/nodes-base/nodes/PostBin/BinDescription.ts @@ -1,12 +1,6 @@ -import { - INodeProperties -} from 'n8n-workflow'; - -import { - buildBinAPIURL, - transformBinReponse, -} from './GenericFunctions'; +import { INodeProperties } from 'n8n-workflow'; +import { buildBinAPIURL, transformBinReponse } from './GenericFunctions'; // Operations for the `Bin` resource: export const binOperations: INodeProperties[] = [ @@ -16,11 +10,9 @@ export const binOperations: INodeProperties[] = [ type: 'options', noDataExpression: true, displayOptions: { - show: { - resource: [ - 'bin', - ], - }, + show: { + resource: ['bin'], + }, }, options: [ { @@ -33,9 +25,7 @@ export const binOperations: INodeProperties[] = [ url: '/developers/postbin/api/bin', }, output: { - postReceive: [ - transformBinReponse, - ], + postReceive: [transformBinReponse], }, }, action: 'Create a bin', @@ -49,9 +39,7 @@ export const binOperations: INodeProperties[] = [ method: 'GET', }, output: { - postReceive: [ - transformBinReponse, - ], + postReceive: [transformBinReponse], }, send: { preSend: [ @@ -94,13 +82,8 @@ export const binFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'bin', - ], - operation: [ - 'get', - 'delete', - ], + resource: ['bin'], + operation: ['get', 'delete'], }, }, description: 'Unique identifier for each bin', diff --git a/packages/nodes-base/nodes/PostBin/GenericFunctions.ts b/packages/nodes-base/nodes/PostBin/GenericFunctions.ts index 9bfe65e0f7..2426a439d1 100644 --- a/packages/nodes-base/nodes/PostBin/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PostBin/GenericFunctions.ts @@ -19,7 +19,10 @@ const BIN_ID_REGEX = /\b\d{13}-\d{13}\b/g; * @param {IHttpRequestOptions} requestOptions * @returns {Promise} requestOptions */ -export async function buildBinAPIURL(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise { +export async function buildBinAPIURL( + this: IExecuteSingleFunctions, + requestOptions: IHttpRequestOptions, +): Promise { const binId = parseBinId(this); // Assemble the PostBin API URL and put it back to requestOptions requestOptions.url = `/developers/postbin/api/bin/${binId}`; @@ -37,7 +40,10 @@ export async function buildBinAPIURL(this: IExecuteSingleFunctions, requestOptio * @param {IHttpRequestOptions} requestOptions * @returns {Promise} requestOptions */ -export async function buildBinTestURL(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise { +export async function buildBinTestURL( + this: IExecuteSingleFunctions, + requestOptions: IHttpRequestOptions, +): Promise { const binId = parseBinId(this); // Assemble the PostBin API URL and put it back to requestOptions @@ -55,7 +61,10 @@ export async function buildBinTestURL(this: IExecuteSingleFunctions, requestOpti * @param {IHttpRequestOptions} requestOptions * @returns {Promise} requestOptions */ -export async function buildRequestURL(this: IExecuteSingleFunctions, requestOptions: IHttpRequestOptions): Promise { +export async function buildRequestURL( + this: IExecuteSingleFunctions, + requestOptions: IHttpRequestOptions, +): Promise { const reqId = this.getNodeParameter('requestId', 'shift') as string; const binId = parseBinId(this); @@ -80,16 +89,20 @@ function parseBinId(context: IExecuteSingleFunctions) { const idMatch = BIN_ID_REGEX.exec(binId); // Return what is matched - if(idMatch) { + if (idMatch) { return idMatch[0]; } // If it's not recognized, error out - throw new NodeApiError(context.getNode(), {}, { - message: 'Bin ID format is not valid', - description: 'Please check the provided Bin ID and try again.', - parseXml: false, - }); + throw new NodeApiError( + context.getNode(), + {}, + { + message: 'Bin ID format is not valid', + description: 'Please check the provided Bin ID and try again.', + parseXml: false, + }, + ); } /** @@ -100,15 +113,22 @@ function parseBinId(context: IExecuteSingleFunctions) { * @param {IN8nHttpFullResponse} response * @returns {Promise} */ - export async function transformBinReponse(this: IExecuteSingleFunctions, items: INodeExecutionData[], response: IN8nHttpFullResponse): Promise { - items.forEach(item => item.json = { - 'binId': item.json.binId, - 'nowTimestamp': item.json.now, - 'nowIso': new Date(item.json.now as string).toISOString(), - 'expiresTimestamp': item.json.expires, - 'expiresIso': new Date(item.json.expires as string).toISOString(), - 'requestUrl': 'https://www.toptal.com/developers/postbin/' + item.json.binId, - 'viewUrl': 'https://www.toptal.com/developers/postbin/b/' + item.json.binId, - }); +export async function transformBinReponse( + this: IExecuteSingleFunctions, + items: INodeExecutionData[], + response: IN8nHttpFullResponse, +): Promise { + items.forEach( + (item) => + (item.json = { + binId: item.json.binId, + nowTimestamp: item.json.now, + nowIso: new Date(item.json.now as string).toISOString(), + expiresTimestamp: item.json.expires, + expiresIso: new Date(item.json.expires as string).toISOString(), + requestUrl: 'https://www.toptal.com/developers/postbin/' + item.json.binId, + viewUrl: 'https://www.toptal.com/developers/postbin/b/' + item.json.binId, + }), + ); return items; } diff --git a/packages/nodes-base/nodes/PostBin/PostBin.node.ts b/packages/nodes-base/nodes/PostBin/PostBin.node.ts index 60a6d68988..d23c1f7c03 100644 --- a/packages/nodes-base/nodes/PostBin/PostBin.node.ts +++ b/packages/nodes-base/nodes/PostBin/PostBin.node.ts @@ -1,17 +1,8 @@ -import { - INodeType, - INodeTypeDescription -} from 'n8n-workflow'; +import { INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - binFields, - binOperations, -} from './BinDescription'; +import { binFields, binOperations } from './BinDescription'; -import { - requestFields, - requestOperations, -} from './RequestDescription'; +import { requestFields, requestOperations } from './RequestDescription'; export class PostBin implements INodeType { description: INodeTypeDescription = { diff --git a/packages/nodes-base/nodes/PostBin/RequestDescription.ts b/packages/nodes-base/nodes/PostBin/RequestDescription.ts index 9c4892de78..b0765a0e5d 100644 --- a/packages/nodes-base/nodes/PostBin/RequestDescription.ts +++ b/packages/nodes-base/nodes/PostBin/RequestDescription.ts @@ -1,11 +1,6 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - buildBinTestURL, - buildRequestURL -} from './GenericFunctions'; +import { buildBinTestURL, buildRequestURL } from './GenericFunctions'; // Operations for the `Request` resource export const requestOperations: INodeProperties[] = [ @@ -16,9 +11,7 @@ export const requestOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'request', - ], + resource: ['request'], }, }, options: [ @@ -100,14 +93,8 @@ export const requestFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'request', - ], - operation: [ - 'get', - 'removeFirst', - 'send', - ], + resource: ['request'], + operation: ['get', 'removeFirst', 'send'], }, }, description: 'Unique identifier for each bin', @@ -118,26 +105,22 @@ export const requestFields: INodeProperties[] = [ type: 'string', default: '', typeOptions: { - rows: 5, + rows: 5, }, displayOptions: { - show: { - resource: [ - 'request', - ], - operation: [ - 'send', - ], - }, + show: { + resource: ['request'], + operation: ['send'], + }, }, // Content is sent in the body of POST requests routing: { - send: { - property: 'content', - type: 'body', - }, + send: { + property: 'content', + type: 'body', + }, }, - }, + }, { name: 'requestId', displayName: 'Request ID', @@ -146,12 +129,8 @@ export const requestFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'request', - ], - operation: [ - 'get', - ], + resource: ['request'], + operation: ['get'], }, }, description: 'Unique identifier for each request', diff --git a/packages/nodes-base/nodes/PostHog/AliasDescription.ts b/packages/nodes-base/nodes/PostHog/AliasDescription.ts index 841302c8aa..5c1fca1dfe 100644 --- a/packages/nodes-base/nodes/PostHog/AliasDescription.ts +++ b/packages/nodes-base/nodes/PostHog/AliasDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const aliasOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const aliasOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'alias', - ], + resource: ['alias'], }, }, options: [ @@ -28,7 +24,6 @@ export const aliasOperations: INodeProperties[] = [ ]; export const aliasFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* alias:create */ /* -------------------------------------------------------------------------- */ @@ -39,12 +34,8 @@ export const aliasFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'alias', - ], - operation: [ - 'create', - ], + resource: ['alias'], + operation: ['create'], }, }, default: '', @@ -57,16 +48,12 @@ export const aliasFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'alias', - ], - operation: [ - 'create', - ], + resource: ['alias'], + operation: ['create'], }, }, default: '', - description: 'The user\'s distinct ID', + description: "The user's distinct ID", }, { displayName: 'Additional Fields', @@ -75,12 +62,8 @@ export const aliasFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'alias', - ], - operation: [ - 'create', - ], + resource: ['alias'], + operation: ['create'], }, }, default: {}, @@ -120,7 +103,7 @@ export const aliasFields: INodeProperties[] = [ name: 'timestamp', type: 'dateTime', default: '', - description: 'If not set, it\'ll automatically be set to the current time', + description: "If not set, it'll automatically be set to the current time", }, ], }, diff --git a/packages/nodes-base/nodes/PostHog/EventDescription.ts b/packages/nodes-base/nodes/PostHog/EventDescription.ts index f0d4a24984..d74763c27c 100644 --- a/packages/nodes-base/nodes/PostHog/EventDescription.ts +++ b/packages/nodes-base/nodes/PostHog/EventDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const eventOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const eventOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'event', - ], + resource: ['event'], }, }, options: [ @@ -28,7 +24,6 @@ export const eventOperations: INodeProperties[] = [ ]; export const eventFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* event:create */ /* -------------------------------------------------------------------------- */ @@ -39,12 +34,8 @@ export const eventFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'create', - ], + resource: ['event'], + operation: ['create'], }, }, default: '', @@ -57,16 +48,12 @@ export const eventFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'create', - ], + resource: ['event'], + operation: ['create'], }, }, default: '', - description: 'The user\'s distinct ID', + description: "The user's distinct ID", }, { displayName: 'Additional Fields', @@ -75,12 +62,8 @@ export const eventFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'create', - ], + resource: ['event'], + operation: ['create'], }, }, default: {}, @@ -120,7 +103,7 @@ export const eventFields: INodeProperties[] = [ name: 'timestamp', type: 'dateTime', default: '', - description: 'If not set, it\'ll automatically be set to the current time', + description: "If not set, it'll automatically be set to the current time", }, ], }, diff --git a/packages/nodes-base/nodes/PostHog/GenericFunctions.ts b/packages/nodes-base/nodes/PostHog/GenericFunctions.ts index 352c4fc0c2..fdc8f330ff 100644 --- a/packages/nodes-base/nodes/PostHog/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PostHog/GenericFunctions.ts @@ -1,18 +1,19 @@ -import { - OptionsWithUrl, -} from 'request'; +import { OptionsWithUrl } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; - -export async function posthogApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, option = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError } from 'n8n-workflow'; +export async function posthogApiRequest( + this: IExecuteFunctions | ILoadOptionsFunctions, + method: string, + path: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + option = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('postHogApi'); const base = credentials.url as string; @@ -63,7 +64,6 @@ export interface ITrack { context: { [key: string]: any }; // tslint:disable-line:no-any } - export interface IIdentity { event: string; messageId?: string; diff --git a/packages/nodes-base/nodes/PostHog/IdentityDescription.ts b/packages/nodes-base/nodes/PostHog/IdentityDescription.ts index de3283ec44..92623ddb89 100644 --- a/packages/nodes-base/nodes/PostHog/IdentityDescription.ts +++ b/packages/nodes-base/nodes/PostHog/IdentityDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const identityOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const identityOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'identity', - ], + resource: ['identity'], }, }, options: [ @@ -27,7 +23,6 @@ export const identityOperations: INodeProperties[] = [ ]; export const identityFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* identity:create */ /* -------------------------------------------------------------------------- */ @@ -38,16 +33,12 @@ export const identityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'identity', - ], - operation: [ - 'create', - ], + resource: ['identity'], + operation: ['create'], }, }, default: '', - description: 'The identity\'s distinct ID', + description: "The identity's distinct ID", }, { displayName: 'Additional Fields', @@ -56,12 +47,8 @@ export const identityFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'identity', - ], - operation: [ - 'create', - ], + resource: ['identity'], + operation: ['create'], }, }, default: {}, @@ -107,7 +94,7 @@ export const identityFields: INodeProperties[] = [ name: 'timestamp', type: 'dateTime', default: '', - description: 'If not set, it\'ll automatically be set to the current time', + description: "If not set, it'll automatically be set to the current time", }, ], }, diff --git a/packages/nodes-base/nodes/PostHog/PostHog.node.ts b/packages/nodes-base/nodes/PostHog/PostHog.node.ts index 7e65d9ede4..58efb13d50 100644 --- a/packages/nodes-base/nodes/PostHog/PostHog.node.ts +++ b/packages/nodes-base/nodes/PostHog/PostHog.node.ts @@ -1,41 +1,16 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - IAlias, - IEvent, - IIdentity, - ITrack, - posthogApiRequest, -} from './GenericFunctions'; +import { IAlias, IEvent, IIdentity, ITrack, posthogApiRequest } from './GenericFunctions'; -import { - aliasFields, - aliasOperations, -} from './AliasDescription'; +import { aliasFields, aliasOperations } from './AliasDescription'; -import { - eventFields, - eventOperations, -} from './EventDescription'; +import { eventFields, eventOperations } from './EventDescription'; -import { - trackFields, - trackOperations, -} from './TrackDescription'; +import { trackFields, trackOperations } from './TrackDescription'; -import { - identityFields, - identityOperations, -} from './IdentityDescription'; +import { identityFields, identityOperations } from './IdentityDescription'; import moment from 'moment-timezone'; @@ -115,12 +90,17 @@ export class PostHog implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - const context = (additionalFields.contextUi as IDataObject || {}).contextValues as IDataObject[] || []; + const context = + (((additionalFields.contextUi as IDataObject) || {}) + .contextValues as IDataObject[]) || []; const event: IAlias = { type: 'alias', event: '$create_alias', - context: context.reduce((obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), {}), + context: context.reduce( + (obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), + {}, + ), properties: { distinct_id: distinctId, alias, @@ -130,7 +110,9 @@ export class PostHog implements INodeType { Object.assign(event, additionalFields); if (additionalFields.timestamp) { - additionalFields.timestamp = moment(additionalFields.timestamp as string).toISOString(); + additionalFields.timestamp = moment( + additionalFields.timestamp as string, + ).toISOString(); } responseData = await posthogApiRequest.call(this, 'POST', '/batch', event); @@ -158,11 +140,16 @@ export class PostHog implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - const properties = (additionalFields.propertiesUi as IDataObject || {}).propertyValues as IDataObject[] || []; + const properties = + (((additionalFields.propertiesUi as IDataObject) || {}) + .propertyValues as IDataObject[]) || []; const event: IEvent = { event: eventName, - properties: properties.reduce((obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), {}), + properties: properties.reduce( + (obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), + {}, + ), }; event.properties['distinct_id'] = distinctId; @@ -170,7 +157,9 @@ export class PostHog implements INodeType { Object.assign(event, additionalFields); if (additionalFields.timestamp) { - additionalFields.timestamp = moment(additionalFields.timestamp as string).toISOString(); + additionalFields.timestamp = moment( + additionalFields.timestamp as string, + ).toISOString(); } //@ts-ignore delete event.propertiesUi; @@ -199,18 +188,25 @@ export class PostHog implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - const properties = (additionalFields.propertiesUi as IDataObject || {}).propertyValues as IDataObject[] || []; + const properties = + (((additionalFields.propertiesUi as IDataObject) || {}) + .propertyValues as IDataObject[]) || []; const event: IIdentity = { event: '$identify', - properties: properties.reduce((obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), {}), + properties: properties.reduce( + (obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), + {}, + ), distinct_id: distinctId, }; Object.assign(event, additionalFields); if (additionalFields.timestamp) { - additionalFields.timestamp = moment(additionalFields.timestamp as string).toISOString(); + additionalFields.timestamp = moment( + additionalFields.timestamp as string, + ).toISOString(); } //@ts-ignore delete event.propertiesUi; @@ -239,23 +235,35 @@ export class PostHog implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - const context = (additionalFields.contextUi as IDataObject || {}).contextValues as IDataObject[] || []; + const context = + (((additionalFields.contextUi as IDataObject) || {}) + .contextValues as IDataObject[]) || []; - const properties = (additionalFields.propertiesUi as IDataObject || {}).propertyValues as IDataObject[] || []; + const properties = + (((additionalFields.propertiesUi as IDataObject) || {}) + .propertyValues as IDataObject[]) || []; const event: ITrack = { name, type: operation, event: `$${operation}`, - context: context.reduce((obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), {}), + context: context.reduce( + (obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), + {}, + ), distinct_id: distinctId, - properties: properties.reduce((obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), {}), + properties: properties.reduce( + (obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), + {}, + ), }; Object.assign(event, additionalFields); if (additionalFields.timestamp) { - additionalFields.timestamp = moment(additionalFields.timestamp as string).toISOString(); + additionalFields.timestamp = moment( + additionalFields.timestamp as string, + ).toISOString(); } //@ts-ignore delete event.propertiesUi; diff --git a/packages/nodes-base/nodes/PostHog/TrackDescription.ts b/packages/nodes-base/nodes/PostHog/TrackDescription.ts index 0424e8a949..c996adb39f 100644 --- a/packages/nodes-base/nodes/PostHog/TrackDescription.ts +++ b/packages/nodes-base/nodes/PostHog/TrackDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const trackOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const trackOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'track', - ], + resource: ['track'], }, }, options: [ @@ -34,7 +30,6 @@ export const trackOperations: INodeProperties[] = [ ]; export const trackFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* track:page */ /* -------------------------------------------------------------------------- */ @@ -45,13 +40,8 @@ export const trackFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'track', - ], - operation: [ - 'page', - 'screen', - ], + resource: ['track'], + operation: ['page', 'screen'], }, }, default: '', @@ -63,17 +53,12 @@ export const trackFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'track', - ], - operation: [ - 'page', - 'screen', - ], + resource: ['track'], + operation: ['page', 'screen'], }, }, default: '', - description: 'The user\'s distinct ID', + description: "The user's distinct ID", }, { displayName: 'Additional Fields', @@ -82,13 +67,8 @@ export const trackFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'track', - ], - operation: [ - 'page', - 'screen', - ], + resource: ['track'], + operation: ['page', 'screen'], }, }, default: {}, @@ -170,7 +150,7 @@ export const trackFields: INodeProperties[] = [ name: 'timestamp', type: 'dateTime', default: '', - description: 'If not set, it\'ll automatically be set to the current time', + description: "If not set, it'll automatically be set to the current time", }, ], }, diff --git a/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts b/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts index 26007788cd..361bec8ac8 100644 --- a/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts +++ b/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts @@ -10,12 +10,16 @@ import pg from 'pg-promise/typescript/pg-subset'; * @param {string[]} properties The properties it should include * @returns */ -export function getItemsCopy(items: INodeExecutionData[], properties: string[], guardedColumns?: {[key: string]: string}): IDataObject[] { +export function getItemsCopy( + items: INodeExecutionData[], + properties: string[], + guardedColumns?: { [key: string]: string }, +): IDataObject[] { let newItem: IDataObject; - return items.map(item => { + return items.map((item) => { newItem = {}; if (guardedColumns) { - Object.keys(guardedColumns).forEach( column => { + Object.keys(guardedColumns).forEach((column) => { newItem[column] = item.json[guardedColumns[column]]; }); } else { @@ -35,10 +39,14 @@ export function getItemsCopy(items: INodeExecutionData[], properties: string[], * @param {string[]} properties The properties it should include * @returns */ -export function getItemCopy(item: INodeExecutionData, properties: string[], guardedColumns?: {[key: string]: string}): IDataObject { +export function getItemCopy( + item: INodeExecutionData, + properties: string[], + guardedColumns?: { [key: string]: string }, +): IDataObject { const newItem: IDataObject = {}; if (guardedColumns) { - Object.keys(guardedColumns).forEach( column => { + Object.keys(guardedColumns).forEach((column) => { newItem[column] = item.json[guardedColumns[column]]; }); } else { @@ -56,7 +64,13 @@ export function getItemCopy(item: INodeExecutionData, properties: string[], guar * @returns string */ export function generateReturning(pgp: pgPromise.IMain<{}, pg.IClient>, returning: string): string { - return ' RETURNING ' + returning.split(',').map(returnedField => pgp.as.name(returnedField.trim())).join(', '); + return ( + ' RETURNING ' + + returning + .split(',') + .map((returnedField) => pgp.as.name(returnedField.trim())) + .join(', ') + ); } /** @@ -81,12 +95,12 @@ export async function pgQuery( let valuesArray = [] as string[][]; if (additionalFields.queryParams) { const propertiesString = additionalFields.queryParams as string; - const properties = propertiesString.split(',').map(column => column.trim()); + const properties = propertiesString.split(',').map((column) => column.trim()); const paramsItems = getItemsCopy(items, properties); - valuesArray = paramsItems.map((row) => properties.map(col => row[col])) as string[][]; + valuesArray = paramsItems.map((row) => properties.map((col) => row[col])) as string[][]; } - const allQueries = [] as Array<{query: string, values?: string[]}>; + const allQueries = [] as Array<{ query: string; values?: string[] }>; for (let i = 0; i < items.length; i++) { const query = getNodeParam('query', i) as string; const values = valuesArray[i]; @@ -94,32 +108,46 @@ export async function pgQuery( allQueries.push(queryFormat); } - const mode = overrideMode ? overrideMode : (additionalFields.mode ?? 'multiple') as string; + const mode = overrideMode ? overrideMode : ((additionalFields.mode ?? 'multiple') as string); if (mode === 'multiple') { return (await db.multi(pgp.helpers.concat(allQueries))).flat(1); } else if (mode === 'transaction') { - return db.tx(async t => { + return db.tx(async (t) => { const result: IDataObject[] = []; for (let i = 0; i < allQueries.length; i++) { try { - Array.prototype.push.apply(result, await t.any(allQueries[i].query, allQueries[i].values)); + Array.prototype.push.apply( + result, + await t.any(allQueries[i].query, allQueries[i].values), + ); } catch (err) { if (continueOnFail === false) throw err; - result.push({ ...items[i].json, code: (err as JsonObject).code, message: (err as JsonObject).message }); + result.push({ + ...items[i].json, + code: (err as JsonObject).code, + message: (err as JsonObject).message, + }); return result; } } return result; }); } else if (mode === 'independently') { - return db.task(async t => { + return db.task(async (t) => { const result: IDataObject[] = []; for (let i = 0; i < allQueries.length; i++) { try { - Array.prototype.push.apply(result, await t.any(allQueries[i].query, allQueries[i].values)); + Array.prototype.push.apply( + result, + await t.any(allQueries[i].query, allQueries[i].values), + ); } catch (err) { if (continueOnFail === false) throw err; - result.push({ ...items[i].json, code: (err as JsonObject).code, message: (err as JsonObject).message }); + result.push({ + ...items[i].json, + code: (err as JsonObject).code, + message: (err as JsonObject).message, + }); } } return result; @@ -148,28 +176,30 @@ export async function pgInsert( const table = getNodeParam('table', 0) as string; const schema = getNodeParam('schema', 0) as string; const columnString = getNodeParam('columns', 0) as string; - const guardedColumns: {[key: string]: string} = {}; + const guardedColumns: { [key: string]: string } = {}; - const columns = columnString.split(',') - .map(column => column.trim().split(':')) + const columns = columnString + .split(',') + .map((column) => column.trim().split(':')) .map(([name, cast], i) => { guardedColumns[`column${i}`] = name; return { name, cast, prop: `column${i}` }; }); - const columnNames = columns.map(column => column.name); + const columnNames = columns.map((column) => column.name); const cs = new pgp.helpers.ColumnSet(columns, { table: { table, schema } }); const additionalFields = getNodeParam('additionalFields', 0) as IDataObject; - const mode = overrideMode ? overrideMode : (additionalFields.mode ?? 'multiple') as string; + const mode = overrideMode ? overrideMode : ((additionalFields.mode ?? 'multiple') as string); const returning = generateReturning(pgp, getNodeParam('returnFields', 0) as string); if (mode === 'multiple') { - const query = pgp.helpers.insert(getItemsCopy(items, columnNames, guardedColumns), cs) + returning; + const query = + pgp.helpers.insert(getItemsCopy(items, columnNames, guardedColumns), cs) + returning; return db.any(query); } else if (mode === 'transaction') { - return db.tx(async t => { + return db.tx(async (t) => { const result: IDataObject[] = []; for (let i = 0; i < items.length; i++) { const itemCopy = getItemCopy(items[i], columnNames, guardedColumns); @@ -177,14 +207,18 @@ export async function pgInsert( result.push(await t.one(pgp.helpers.insert(itemCopy, cs) + returning)); } catch (err) { if (continueOnFail === false) throw err; - result.push({ ...itemCopy, code: (err as JsonObject).code, message: (err as JsonObject).message }); + result.push({ + ...itemCopy, + code: (err as JsonObject).code, + message: (err as JsonObject).message, + }); return result; } } return result; }); } else if (mode === 'independently') { - return db.task(async t => { + return db.task(async (t) => { const result: IDataObject[] = []; for (let i = 0; i < items.length; i++) { const itemCopy = getItemCopy(items[i], columnNames, guardedColumns); @@ -197,7 +231,11 @@ export async function pgInsert( if (continueOnFail === false) { throw err; } - result.push({ ...itemCopy, code: (err as JsonObject).code, message: (err as JsonObject).message }); + result.push({ + ...itemCopy, + code: (err as JsonObject).code, + message: (err as JsonObject).message, + }); } } return result; @@ -227,10 +265,11 @@ export async function pgUpdate( const schema = getNodeParam('schema', 0) as string; const updateKey = getNodeParam('updateKey', 0) as string; const columnString = getNodeParam('columns', 0) as string; - const guardedColumns: {[key: string]: string} = {}; + const guardedColumns: { [key: string]: string } = {}; - const columns: Array<{name:string, cast: string, prop:string}> = columnString.split(',') - .map(column => column.trim().split(':')) + const columns: Array<{ name: string; cast: string; prop: string }> = columnString + .split(',') + .map((column) => column.trim().split(':')) .map(([name, cast], i) => { guardedColumns[`column${i}`] = name; return { name, cast, prop: `column${i}` }; @@ -243,61 +282,83 @@ export async function pgUpdate( if (!targetCol) { guardedColumns[updateColumn.prop] = name; columns.unshift(updateColumn); - } - else if (!targetCol.cast) { + } else if (!targetCol.cast) { targetCol.cast = updateColumn.cast || targetCol.cast; } return updateColumn; }); const additionalFields = getNodeParam('additionalFields', 0) as IDataObject; - const mode = additionalFields.mode ?? 'multiple' as string; + const mode = additionalFields.mode ?? ('multiple' as string); const cs = new pgp.helpers.ColumnSet(columns, { table: { table, schema } }); // Prepare the data to update and copy it to be returned - const columnNames = columns.map(column => column.name); + const columnNames = columns.map((column) => column.name); const updateItems = getItemsCopy(items, columnNames, guardedColumns); const returning = generateReturning(pgp, getNodeParam('returnFields', 0) as string); if (mode === 'multiple') { const query = - pgp.helpers.update(updateItems, cs) - + ' WHERE ' + updateKeys.map(updateKey => { - const key = pgp.as.name(updateKey.name); - return 'v.' + key + ' = t.' + key; - }).join(' AND ') - + returning; + pgp.helpers.update(updateItems, cs) + + ' WHERE ' + + updateKeys + .map((updateKey) => { + const key = pgp.as.name(updateKey.name); + return 'v.' + key + ' = t.' + key; + }) + .join(' AND ') + + returning; return await db.any(query); } else { - const where = ' WHERE ' + - updateKeys.map(updateKey => pgp.as.name(updateKey.name) + - ' = ${' + updateKey.prop + '}').join(' AND '); + const where = + ' WHERE ' + + updateKeys + .map((updateKey) => pgp.as.name(updateKey.name) + ' = ${' + updateKey.prop + '}') + .join(' AND '); if (mode === 'transaction') { - return db.tx(async t => { + return db.tx(async (t) => { const result: IDataObject[] = []; for (let i = 0; i < items.length; i++) { const itemCopy = getItemCopy(items[i], columnNames, guardedColumns); try { - Array.prototype.push.apply(result, await t.any(pgp.helpers.update(itemCopy, cs) + pgp.as.format(where, itemCopy) + returning)); + Array.prototype.push.apply( + result, + await t.any( + pgp.helpers.update(itemCopy, cs) + pgp.as.format(where, itemCopy) + returning, + ), + ); } catch (err) { if (continueOnFail === false) throw err; - result.push({ ...itemCopy, code: (err as JsonObject).code, message: (err as JsonObject).message }); + result.push({ + ...itemCopy, + code: (err as JsonObject).code, + message: (err as JsonObject).message, + }); return result; } } return result; }); } else if (mode === 'independently') { - return db.task(async t => { + return db.task(async (t) => { const result: IDataObject[] = []; for (let i = 0; i < items.length; i++) { const itemCopy = getItemCopy(items[i], columnNames, guardedColumns); try { - Array.prototype.push.apply(result, await t.any(pgp.helpers.update(itemCopy, cs) + pgp.as.format(where, itemCopy) + returning)); + Array.prototype.push.apply( + result, + await t.any( + pgp.helpers.update(itemCopy, cs) + pgp.as.format(where, itemCopy) + returning, + ), + ); } catch (err) { if (continueOnFail === false) throw err; - result.push({ ...itemCopy, code: (err as JsonObject).code, message: (err as JsonObject).message }); + result.push({ + ...itemCopy, + code: (err as JsonObject).code, + message: (err as JsonObject).message, + }); } } return result; diff --git a/packages/nodes-base/nodes/Postgres/Postgres.node.ts b/packages/nodes-base/nodes/Postgres/Postgres.node.ts index cda8198cdc..582aa9ecdd 100644 --- a/packages/nodes-base/nodes/Postgres/Postgres.node.ts +++ b/packages/nodes-base/nodes/Postgres/Postgres.node.ts @@ -77,7 +77,8 @@ export class Postgres implements INodeType { default: '', placeholder: 'SELECT id, name FROM product WHERE quantity > $1 AND price <= $2', required: true, - description: 'The SQL query to execute. You can use n8n expressions or $1 and $2 in conjunction with query parameters.', + description: + 'The SQL query to execute. You can use n8n expressions or $1 and $2 in conjunction with query parameters.', }, // ---------------------------------- @@ -122,7 +123,8 @@ export class Postgres implements INodeType { // eslint-disable-next-line n8n-nodes-base/node-param-placeholder-miscased-id placeholder: 'id:int,name:text,description', // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id - description: 'Comma-separated list of the properties which should used as columns for the new rows. You can use type casting with colons (:) like id:int.', + description: + 'Comma-separated list of the properties which should used as columns for the new rows. You can use type casting with colons (:) like id:int.', }, // ---------------------------------- @@ -165,7 +167,8 @@ export class Postgres implements INodeType { default: 'id', required: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id - description: 'Comma-separated list of the properties which decides which rows in the database should be updated. Normally that would be "id".', + description: + 'Comma-separated list of the properties which decides which rows in the database should be updated. Normally that would be "id".', }, { displayName: 'Columns', @@ -179,7 +182,8 @@ export class Postgres implements INodeType { default: '', placeholder: 'name:text,description', // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id - description: 'Comma-separated list of the properties which should used as columns for rows to update. You can use type casting with colons (:) like id:int.', + description: + 'Comma-separated list of the properties which should used as columns for rows to update. You can use type casting with colons (:) like id:int.', }, // ---------------------------------- @@ -229,7 +233,8 @@ export class Postgres implements INodeType { }, ], default: 'multiple', - description: 'The way queries should be sent to database. Can be used in conjunction with Continue on Fail. See the docs for more examples', + description: + 'The way queries should be sent to database. Can be used in conjunction with Continue on Fail. See the docs for more examples', }, { displayName: 'Output Large-Format Numbers As', @@ -243,7 +248,8 @@ export class Postgres implements INodeType { { name: 'Text', value: 'text', - description: 'Use this if you expect numbers longer than 16 digits (otherwise numbers may be incorrect)', + description: + 'Use this if you expect numbers longer than 16 digits (otherwise numbers may be incorrect)', }, ], hint: 'Applies to NUMERIC and BIGINT columns only', @@ -255,14 +261,13 @@ export class Postgres implements INodeType { type: 'string', displayOptions: { show: { - '/operation': [ - 'executeQuery', - ], + '/operation': ['executeQuery'], }, }, default: '', placeholder: 'quantity,price', - description: 'Comma-separated list of properties which should be used as query parameters', + description: + 'Comma-separated list of properties which should be used as query parameters', }, ], }, @@ -271,7 +276,11 @@ export class Postgres implements INodeType { async execute(this: IExecuteFunctions): Promise { const credentials = await this.getCredentials('postgres'); - const largeNumbersOutput = this.getNodeParameter('additionalFields.largeNumbersOutput', 0, '') as string; + const largeNumbersOutput = this.getNodeParameter( + 'additionalFields.largeNumbersOutput', + 0, + '', + ) as string; const pgp = pgPromise(); @@ -313,7 +322,13 @@ export class Postgres implements INodeType { // executeQuery // ---------------------------------- - const queryResult = await pgQuery(this.getNodeParameter, pgp, db, items, this.continueOnFail()); + const queryResult = await pgQuery( + this.getNodeParameter, + pgp, + db, + items, + this.continueOnFail(), + ); returnItems = this.helpers.returnJsonArray(queryResult); } else if (operation === 'insert') { @@ -321,7 +336,13 @@ export class Postgres implements INodeType { // insert // ---------------------------------- - const insertData = await pgInsert(this.getNodeParameter, pgp, db, items, this.continueOnFail()); + const insertData = await pgInsert( + this.getNodeParameter, + pgp, + db, + items, + this.continueOnFail(), + ); for (let i = 0; i < insertData.length; i++) { returnItems.push({ @@ -333,12 +354,21 @@ export class Postgres implements INodeType { // update // ---------------------------------- - const updateItems = await pgUpdate(this.getNodeParameter, pgp, db, items, this.continueOnFail()); + const updateItems = await pgUpdate( + this.getNodeParameter, + pgp, + db, + items, + this.continueOnFail(), + ); returnItems = this.helpers.returnJsonArray(updateItems); } else { await pgp.end(); - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not supported!`, + ); } // Close the connection diff --git a/packages/nodes-base/nodes/Postmark/GenericFunctions.ts b/packages/nodes-base/nodes/Postmark/GenericFunctions.ts index 8d68a891d1..ac29d087bc 100644 --- a/packages/nodes-base/nodes/Postmark/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Postmark/GenericFunctions.ts @@ -1,11 +1,6 @@ -import { - OptionsWithUri, - } from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject, @@ -15,15 +10,22 @@ import { NodeOperationError, } from 'n8n-workflow'; - -export async function postmarkApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method : string, endpoint : string, body: any = {}, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function postmarkApiRequest( + this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('postmarkApi'); let options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', - 'Accept': 'application/json', - 'X-Postmark-Server-Token' : credentials.serverToken, + Accept: 'application/json', + 'X-Postmark-Server-Token': credentials.serverToken, }, method, body, @@ -43,9 +45,9 @@ export async function postmarkApiRequest(this: IExecuteFunctions | IWebhookFunct } // tslint:disable-next-line: no-any -export function convertTriggerObjectToStringArray (webhookObject : any) : string[] { +export function convertTriggerObjectToStringArray(webhookObject: any): string[] { const triggers = webhookObject.Triggers; - const webhookEvents : string[] = []; + const webhookEvents: string[] = []; // Translate Webhook trigger settings to string array if (triggers.Open.Enabled) { @@ -81,7 +83,7 @@ export function convertTriggerObjectToStringArray (webhookObject : any) : string return webhookEvents; } -export function eventExists (currentEvents : string[], webhookEvents: string[]) { +export function eventExists(currentEvents: string[], webhookEvents: string[]) { for (const currentEvent of currentEvents) { if (!webhookEvents.includes(currentEvent)) { return false; diff --git a/packages/nodes-base/nodes/Postmark/PostmarkTrigger.node.ts b/packages/nodes-base/nodes/Postmark/PostmarkTrigger.node.ts index d7e0e124b0..7d49c8ba6a 100644 --- a/packages/nodes-base/nodes/Postmark/PostmarkTrigger.node.ts +++ b/packages/nodes-base/nodes/Postmark/PostmarkTrigger.node.ts @@ -1,18 +1,11 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import { - INodeType, - INodeTypeDescription, - IWebhookResponseData, -} from 'n8n-workflow'; +import { INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; import { convertTriggerObjectToStringArray, eventExists, - postmarkApiRequest + postmarkApiRequest, } from './GenericFunctions'; export class PostmarkTrigger implements INodeType { @@ -93,9 +86,7 @@ export class PostmarkTrigger implements INodeType { default: false, displayOptions: { show: { - events: [ - 'open', - ], + events: ['open'], }, }, }, @@ -107,15 +98,11 @@ export class PostmarkTrigger implements INodeType { default: false, displayOptions: { show: { - events: [ - 'bounce', - 'spamComplaint', - ], + events: ['bounce', 'spamComplaint'], }, }, }, ], - }; // @ts-ignore (because of request) @@ -150,7 +137,10 @@ export class PostmarkTrigger implements INodeType { // If webhooks exist, check if any match current settings for (const webhook of responseData.Webhooks) { - if (webhook.Url === webhookUrl && eventExists(events, convertTriggerObjectToStringArray(webhook))) { + if ( + webhook.Url === webhookUrl && + eventExists(events, convertTriggerObjectToStringArray(webhook)) + ) { webhookData.webhookId = webhook.ID; // webhook identical to current settings. re-assign webhook id to found webhook. return true; @@ -165,24 +155,24 @@ export class PostmarkTrigger implements INodeType { const endpoint = `/webhooks`; // tslint:disable-next-line: no-any - const body : any = { + const body: any = { Url: webhookUrl, Triggers: { - Open:{ + Open: { Enabled: false, PostFirstOpenOnly: false, }, - Click:{ + Click: { Enabled: false, }, - Delivery:{ + Delivery: { Enabled: false, }, - Bounce:{ + Bounce: { Enabled: false, IncludeContent: false, }, - SpamComplaint:{ + SpamComplaint: { Enabled: false, IncludeContent: false, }, @@ -210,7 +200,9 @@ export class PostmarkTrigger implements INodeType { } if (events.includes('spamComplaint')) { body.Triggers.SpamComplaint.Enabled = true; - body.Triggers.SpamComplaint.IncludeContent = this.getNodeParameter('includeContent') as boolean; + body.Triggers.SpamComplaint.IncludeContent = this.getNodeParameter( + 'includeContent', + ) as boolean; } if (events.includes('subscriptionChange')) { body.Triggers.SubscriptionChange.Enabled = true; @@ -255,9 +247,7 @@ export class PostmarkTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/ProfitWell/CompanyDescription.ts b/packages/nodes-base/nodes/ProfitWell/CompanyDescription.ts index 1b907be129..6cc37c1a02 100644 --- a/packages/nodes-base/nodes/ProfitWell/CompanyDescription.ts +++ b/packages/nodes-base/nodes/ProfitWell/CompanyDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const companyOperations: INodeProperties[] = [ { @@ -10,16 +8,14 @@ export const companyOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'company', - ], + resource: ['company'], }, }, options: [ { name: 'Get Settings', value: 'getSetting', - description: 'Get your company\'s ProfitWell account settings', + description: "Get your company's ProfitWell account settings", action: 'Get settings for your company', }, ], diff --git a/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts b/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts index ce21b545ba..4278e1e386 100644 --- a/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,16 +7,24 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function profitWellApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function profitWellApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { try { const credentials = await this.getCredentials('profitWellApi'); let options: OptionsWithUri = { headers: { - 'Authorization': credentials.accessToken, + Authorization: credentials.accessToken, }, method, qs, @@ -35,10 +41,12 @@ export async function profitWellApiRequest(this: IHookFunctions | IExecuteFuncti } } -export function simplifyDailyMetrics(responseData: { [key: string]: [{ date: string, value: number | null }] }) { +export function simplifyDailyMetrics(responseData: { + [key: string]: [{ date: string; value: number | null }]; +}) { const data: IDataObject[] = []; const keys = Object.keys(responseData); - const dates = responseData[keys[0]].map(e => e.date); + const dates = responseData[keys[0]].map((e) => e.date); for (const [index, date] of dates.entries()) { const element: IDataObject = { date, @@ -51,7 +59,9 @@ export function simplifyDailyMetrics(responseData: { [key: string]: [{ date: str return data; } -export function simplifyMontlyMetrics(responseData: { [key: string]: [{ date: string, value: number | null }] }) { +export function simplifyMontlyMetrics(responseData: { + [key: string]: [{ date: string; value: number | null }]; +}) { const data: IDataObject = {}; for (const key of Object.keys(responseData)) { for (const [index] of responseData[key].entries()) { diff --git a/packages/nodes-base/nodes/ProfitWell/MetricDescription.ts b/packages/nodes-base/nodes/ProfitWell/MetricDescription.ts index 20e9e4d1d9..f411ffa29c 100644 --- a/packages/nodes-base/nodes/ProfitWell/MetricDescription.ts +++ b/packages/nodes-base/nodes/ProfitWell/MetricDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const metricOperations: INodeProperties[] = [ { @@ -10,16 +8,15 @@ export const metricOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'metric', - ], + resource: ['metric'], }, }, options: [ { name: 'Get', value: 'get', - description: 'Retrieve financial metric broken down by day for either the current month or the last', + description: + 'Retrieve financial metric broken down by day for either the current month or the last', action: 'Get a metric', }, ], @@ -28,7 +25,6 @@ export const metricOperations: INodeProperties[] = [ ]; export const metricFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* metric:get */ /* -------------------------------------------------------------------------- */ @@ -41,7 +37,8 @@ export const metricFields: INodeProperties[] = [ { name: 'Daily', value: 'daily', - description: 'Retrieve financial metric broken down by day for either the current month or the last', + description: + 'Retrieve financial metric broken down by day for either the current month or the last', }, { name: 'Monthly', @@ -53,12 +50,8 @@ export const metricFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'metric', - ], - operation: [ - 'get', - ], + resource: ['metric'], + operation: ['get'], }, }, }, @@ -71,15 +64,9 @@ export const metricFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'metric', - ], - operation: [ - 'get', - ], - type: [ - 'daily', - ], + resource: ['metric'], + operation: ['get'], + type: ['daily'], }, }, description: 'Can only be the current or previous month. Format should be YYYY-MM.', @@ -91,12 +78,8 @@ export const metricFields: INodeProperties[] = [ default: true, displayOptions: { show: { - resource: [ - 'metric', - ], - operation: [ - 'get', - ], + resource: ['metric'], + operation: ['get'], }, }, description: 'Whether to return a simplified version of the response instead of the raw data', @@ -108,12 +91,8 @@ export const metricFields: INodeProperties[] = [ placeholder: 'Add Option', displayOptions: { show: { - resource: [ - 'metric', - ], - operation: [ - 'get', - ], + resource: ['metric'], + operation: ['get'], }, }, default: {}, @@ -126,7 +105,8 @@ export const metricFields: INodeProperties[] = [ loadOptionsMethod: 'getPlanIds', }, default: '', - description: 'Only return the metric for this Plan ID. Choose from the list, or specify an ID using an expression.', + description: + 'Only return the metric for this Plan ID. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Metrics', @@ -134,9 +114,7 @@ export const metricFields: INodeProperties[] = [ type: 'multiOptions', displayOptions: { show: { - '/type': [ - 'daily', - ], + '/type': ['daily'], }, }, options: [ @@ -158,12 +136,14 @@ export const metricFields: INodeProperties[] = [ { name: 'Cumulative Net New MRR', value: 'cumulative_net_new_mrr', - description: 'New + Upgrades - Downgrades - Churn MRR, cumulative for the month up through the given day', + description: + 'New + Upgrades - Downgrades - Churn MRR, cumulative for the month up through the given day', }, { name: 'Cumulative New Trialing Customers', value: 'cumulative_new_trialing_customers', - description: 'Number of new trialing customers, cumulative for the month up through the given day', + description: + 'Number of new trialing customers, cumulative for the month up through the given day', }, { name: 'Downgraded Customers', @@ -178,7 +158,8 @@ export const metricFields: INodeProperties[] = [ { name: 'Future Churn MRR', value: 'future_churn_mrr', - description: 'MRR that will be lost when users who are currently cancelled actually churn', + description: + 'MRR that will be lost when users who are currently cancelled actually churn', }, { name: 'New Customers', @@ -203,7 +184,7 @@ export const metricFields: INodeProperties[] = [ { name: 'Recurring Revenue', value: 'recurring_revenue', - description: 'Your company\'s MRR', + description: "Your company's MRR", }, { name: 'Upgraded Customers', @@ -217,7 +198,8 @@ export const metricFields: INodeProperties[] = [ }, ], default: [], - description: 'Comma-separated list of metric trends to return (the default is to return all metric)', + description: + 'Comma-separated list of metric trends to return (the default is to return all metric)', }, { displayName: 'Metrics', @@ -225,9 +207,7 @@ export const metricFields: INodeProperties[] = [ type: 'multiOptions', displayOptions: { show: { - '/type': [ - 'monthly', - ], + '/type': ['monthly'], }, }, options: [ @@ -269,7 +249,8 @@ export const metricFields: INodeProperties[] = [ { name: 'Churned Recurring Revenue Cancellations', value: 'churned_recurring_revenue_cancellations', - description: 'Revenue lost to customers who churned by cancelling their subscription(s)', + description: + 'Revenue lost to customers who churned by cancelling their subscription(s)', }, { name: 'Churned Recurring Revenue Delinquent', @@ -294,12 +275,14 @@ export const metricFields: INodeProperties[] = [ { name: 'Customer Churn Cancellations Rate', value: 'customers_churn_cancellations_rate', - description: 'Percentage of paying customers who churned by cancelling their subscription(s)', + description: + 'Percentage of paying customers who churned by cancelling their subscription(s)', }, { name: 'Customer Churn Delinquent Rate', value: 'customers_churn_delinquent_rate', - description: 'Percentage of paying customers who churned because they failed to pay you', + description: + 'Percentage of paying customers who churned because they failed to pay you', }, { name: 'Customer Churn Rate', @@ -339,7 +322,7 @@ export const metricFields: INodeProperties[] = [ { name: 'Existing Recurring Revenue', value: 'existing_recurring_revenue', - description: 'Your company\'s MRR at the start of the given month', + description: "Your company's MRR at the start of the given month", }, { name: 'Existing Trialing Customers', @@ -349,7 +332,7 @@ export const metricFields: INodeProperties[] = [ { name: 'Growth_Rate', value: 'growth_rate', - description: 'Rate at which your company\'s MRR has grown over the previous month', + description: "Rate at which your company's MRR has grown over the previous month", }, { name: 'Lifetime Value', @@ -394,17 +377,17 @@ export const metricFields: INodeProperties[] = [ { name: 'Recurring Revenue', value: 'recurring_revenue', - description: 'Your company\'s MRR', + description: "Your company's MRR", }, { name: 'Revenue Churn Cancellations Rate', value: 'revenue_churn_cancellations_rate', - description: 'Voluntary churn revenue as a percent of the month\'s starting revenue', + description: "Voluntary churn revenue as a percent of the month's starting revenue", }, { name: 'Revenue Churn Delinquent_ Rate', value: 'revenue_churn_delinquent_rate', - description: 'Delinquent churn revenue as a percent of the month\'s starting revenue', + description: "Delinquent churn revenue as a percent of the month's starting revenue", }, { name: 'Revenue Churn Rate', @@ -414,7 +397,8 @@ export const metricFields: INodeProperties[] = [ { name: 'Revenue Retention Rate', value: 'revenue_retention_rate', - description: 'Percent of revenue coming from existing customers that was retained by the end of the month', + description: + 'Percent of revenue coming from existing customers that was retained by the end of the month', }, { name: 'Upgrade Rate', @@ -433,7 +417,8 @@ export const metricFields: INodeProperties[] = [ }, ], default: [], - description: 'Comma-separated list of metric trends to return (the default is to return all metric)', + description: + 'Comma-separated list of metric trends to return (the default is to return all metric)', }, ], }, diff --git a/packages/nodes-base/nodes/ProfitWell/ProfitWell.node.ts b/packages/nodes-base/nodes/ProfitWell/ProfitWell.node.ts index 90a40b8d45..89951f01b9 100644 --- a/packages/nodes-base/nodes/ProfitWell/ProfitWell.node.ts +++ b/packages/nodes-base/nodes/ProfitWell/ProfitWell.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -17,14 +15,9 @@ import { simplifyMontlyMetrics, } from './GenericFunctions'; -import { - companyOperations, -} from './CompanyDescription'; +import { companyOperations } from './CompanyDescription'; -import { - metricFields, - metricOperations, -} from './MetricDescription'; +import { metricFields, metricOperations } from './MetricDescription'; export class ProfitWell implements INodeType { description: INodeTypeDescription = { @@ -75,15 +68,9 @@ export class ProfitWell implements INodeType { methods = { loadOptions: { - async getPlanIds( - this: ILoadOptionsFunctions, - ): Promise { + async getPlanIds(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const planIds = await profitWellApiRequest.call( - this, - 'GET', - '/metrics/plans', - ); + const planIds = await profitWellApiRequest.call(this, 'GET', '/metrics/plans'); for (const planId of planIds.plan_ids) { returnData.push({ name: planId, diff --git a/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts b/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts index 6b152f5d34..2f075bf895 100644 --- a/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts @@ -1,18 +1,20 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; - -export async function pushbulletApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, uri?: string | undefined, option = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError } from 'n8n-workflow'; +export async function pushbulletApiRequest( + this: IExecuteFunctions | ILoadOptionsFunctions, + method: string, + path: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string | undefined, + option = {}, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { method, body, @@ -34,8 +36,16 @@ export async function pushbulletApiRequest(this: IExecuteFunctions | ILoadOption } } -export async function pushbulletApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function pushbulletApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -43,9 +53,7 @@ export async function pushbulletApiRequestAllItems(this: IExecuteFunctions | ILo do { responseData = await pushbulletApiRequest.call(this, method, endpoint, body, query); returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData.cursor !== undefined - ); + } while (responseData.cursor !== undefined); return returnData; } diff --git a/packages/nodes-base/nodes/Pushbullet/Pushbullet.node.ts b/packages/nodes-base/nodes/Pushbullet/Pushbullet.node.ts index f439bb1939..8eca14132f 100644 --- a/packages/nodes-base/nodes/Pushbullet/Pushbullet.node.ts +++ b/packages/nodes-base/nodes/Pushbullet/Pushbullet.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryKeyData, @@ -13,10 +11,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - pushbulletApiRequest, - pushbulletApiRequestAllItems, -} from './GenericFunctions'; +import { pushbulletApiRequest, pushbulletApiRequestAllItems } from './GenericFunctions'; import moment from 'moment-timezone'; @@ -61,9 +56,7 @@ export class Pushbullet implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'push', - ], + resource: ['push'], }, }, options: [ @@ -115,12 +108,8 @@ export class Pushbullet implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'push', - ], - operation: [ - 'create', - ], + resource: ['push'], + operation: ['create'], }, }, default: 'note', @@ -132,16 +121,9 @@ export class Pushbullet implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'push', - ], - operation: [ - 'create', - ], - type: [ - 'note', - 'link', - ], + resource: ['push'], + operation: ['create'], + type: ['note', 'link'], }, }, default: '', @@ -154,17 +136,9 @@ export class Pushbullet implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'push', - ], - operation: [ - 'create', - ], - type: [ - 'note', - 'link', - 'file', - ], + resource: ['push'], + operation: ['create'], + type: ['note', 'link', 'file'], }, }, default: '', @@ -177,15 +151,9 @@ export class Pushbullet implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'push', - ], - operation: [ - 'create', - ], - type: [ - 'link', - ], + resource: ['push'], + operation: ['create'], + type: ['link'], }, }, default: '', @@ -199,19 +167,14 @@ export class Pushbullet implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'push', - ], - operation: [ - 'create', - ], - type: [ - 'file', - ], + resource: ['push'], + operation: ['create'], + type: ['file'], }, }, placeholder: '', - description: 'Name of the binary property which contains the data for the file to be created', + description: + 'Name of the binary property which contains the data for the file to be created', }, { displayName: 'Target', @@ -226,7 +189,7 @@ export class Pushbullet implements INodeType { { name: 'Default', value: 'default', - description: 'Broadcast it to all of the user\'s devices', + description: "Broadcast it to all of the user's devices", }, { name: 'Device ID', @@ -242,12 +205,8 @@ export class Pushbullet implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'push', - ], - operation: [ - 'create', - ], + resource: ['push'], + operation: ['create'], }, }, default: 'default', @@ -260,22 +219,16 @@ export class Pushbullet implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'push', - ], - operation: [ - 'create', - ], + resource: ['push'], + operation: ['create'], }, hide: { - target: [ - 'default', - 'device_iden', - ], + target: ['default', 'device_iden'], }, }, default: '', - description: 'The value to be set depending on the target selected. For example, if the target selected is email then this field would take the email address of the person you are trying to send the push to.', + description: + 'The value to be set depending on the target selected. For example, if the target selected is email then this field would take the email address of the person you are trying to send the push to.', }, { displayName: 'Value Name or ID', @@ -287,19 +240,14 @@ export class Pushbullet implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'push', - ], - operation: [ - 'create', - ], - target: [ - 'device_iden', - ], + resource: ['push'], + operation: ['create'], + target: ['device_iden'], }, }, default: '', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', }, { displayName: 'Push ID', @@ -308,12 +256,8 @@ export class Pushbullet implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'push', - ], - operation: [ - 'delete', - ], + resource: ['push'], + operation: ['delete'], }, }, default: '', @@ -324,12 +268,8 @@ export class Pushbullet implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'push', - ], + operation: ['getAll'], + resource: ['push'], }, }, default: false, @@ -341,15 +281,9 @@ export class Pushbullet implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'push', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['push'], + returnAll: [false], }, }, typeOptions: { @@ -367,12 +301,8 @@ export class Pushbullet implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'push', - ], - operation: [ - 'getAll', - ], + resource: ['push'], + operation: ['getAll'], }, }, options: [ @@ -382,7 +312,7 @@ export class Pushbullet implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Don\'t return deleted pushes', + description: "Don't return deleted pushes", }, { displayName: 'Modified After', @@ -400,12 +330,8 @@ export class Pushbullet implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'push', - ], - operation: [ - 'update', - ], + resource: ['push'], + operation: ['update'], }, }, default: '', @@ -417,16 +343,13 @@ export class Pushbullet implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'push', - ], - operation: [ - 'update', - ], + resource: ['push'], + operation: ['update'], }, }, default: false, - description: 'Whether to mark a push as having been dismissed by the user, will cause any notifications for the push to be hidden if possible', + description: + 'Whether to mark a push as having been dismissed by the user, will cause any notifications for the push to be hidden if possible', }, ], }; @@ -447,7 +370,6 @@ export class Pushbullet implements INodeType { }, }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -492,7 +414,11 @@ export class Pushbullet implements INodeType { } //@ts-ignore if (items[i].binary[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + { itemIndex: i }, + ); } const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName]; @@ -504,48 +430,30 @@ export class Pushbullet implements INodeType { file_name, file_type, file_url, - } = await pushbulletApiRequest.call( - this, - 'POST', - `/upload-request`, - { - file_name: binaryData.fileName, - file_type: binaryData.mimeType, - }, - ); + } = await pushbulletApiRequest.call(this, 'POST', `/upload-request`, { + file_name: binaryData.fileName, + file_type: binaryData.mimeType, + }); //upload the file - await pushbulletApiRequest.call( - this, - 'POST', - '', - {}, - {}, - uploadUrl, - { - formData: { - file: { - value: dataBuffer, - options: { - filename: binaryData.fileName, - }, + await pushbulletApiRequest.call(this, 'POST', '', {}, {}, uploadUrl, { + formData: { + file: { + value: dataBuffer, + options: { + filename: binaryData.fileName, }, }, - json: false, }, - ); + json: false, + }); body.file_name = file_name; body.file_type = file_type; body.file_url = file_url; } - responseData = await pushbulletApiRequest.call( - this, - 'POST', - `/pushes`, - body, - ); + responseData = await pushbulletApiRequest.call(this, 'POST', `/pushes`, body); } if (operation === 'getAll') { @@ -560,8 +468,14 @@ export class Pushbullet implements INodeType { } if (returnAll) { - responseData = await pushbulletApiRequestAllItems.call(this, 'pushes', 'GET', '/pushes', {}, qs); - + responseData = await pushbulletApiRequestAllItems.call( + this, + 'pushes', + 'GET', + '/pushes', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; @@ -574,11 +488,7 @@ export class Pushbullet implements INodeType { if (operation === 'delete') { const pushId = this.getNodeParameter('pushId', i) as string; - responseData = await pushbulletApiRequest.call( - this, - 'DELETE', - `/pushes/${pushId}`, - ); + responseData = await pushbulletApiRequest.call(this, 'DELETE', `/pushes/${pushId}`); responseData = { success: true }; } @@ -588,22 +498,15 @@ export class Pushbullet implements INodeType { const dismissed = this.getNodeParameter('dismissed', i) as boolean; - responseData = await pushbulletApiRequest.call( - this, - 'POST', - `/pushes/${pushId}`, - { - dismissed, - }, - ); + responseData = await pushbulletApiRequest.call(this, 'POST', `/pushes/${pushId}`, { + dismissed, + }); } } if (Array.isArray(responseData)) { returnData.push.apply(returnData, responseData as IDataObject[]); - } else if (responseData !== undefined) { returnData.push(responseData as IDataObject); - } } catch (error) { if (this.continueOnFail()) { diff --git a/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts b/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts index ee2c2937c0..b3830146ff 100644 --- a/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts @@ -1,20 +1,20 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - IHookFunctions, - NodeApiError, -} from 'n8n-workflow'; - -export async function pushcutApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, uri?: string | undefined, option = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, IHookFunctions, NodeApiError } from 'n8n-workflow'; +export async function pushcutApiRequest( + this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, + method: string, + path: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string | undefined, + option = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('pushcutApi'); const options: OptionsWithUri = { diff --git a/packages/nodes-base/nodes/Pushcut/Pushcut.node.ts b/packages/nodes-base/nodes/Pushcut/Pushcut.node.ts index dcb5efc9e0..7afcdfb3c9 100644 --- a/packages/nodes-base/nodes/Pushcut/Pushcut.node.ts +++ b/packages/nodes-base/nodes/Pushcut/Pushcut.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,9 +9,7 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - pushcutApiRequest, -} from './GenericFunctions'; +import { pushcutApiRequest } from './GenericFunctions'; export class Pushcut implements INodeType { description: INodeTypeDescription = { @@ -57,9 +53,7 @@ export class Pushcut implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'notification', - ], + resource: ['notification'], }, }, options: [ @@ -76,18 +70,15 @@ export class Pushcut implements INodeType { displayName: 'Notification Name or ID', name: 'notificationName', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getNotifications', }, displayOptions: { show: { - resource: [ - 'notification', - ], - operation: [ - 'send', - ], + resource: ['notification'], + operation: ['send'], }, }, default: '', @@ -99,12 +90,8 @@ export class Pushcut implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'notification', - ], + operation: ['send'], + resource: ['notification'], }, }, default: {}, @@ -117,7 +104,8 @@ export class Pushcut implements INodeType { loadOptionsMethod: 'getDevices', }, default: [], - description: 'List of devices this notification is sent to. (default is all devices). Choose from the list, or specify IDs using an expression.', + description: + 'List of devices this notification is sent to. (default is all devices). Choose from the list, or specify IDs using an expression.', }, { displayName: 'Input', @@ -185,7 +173,6 @@ export class Pushcut implements INodeType { const resource = this.getNodeParameter('resource', 0) as string; const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < length; i++) { - if (resource === 'notification') { if (operation === 'send') { const notificationName = this.getNodeParameter('notificationName', i) as string; @@ -207,10 +194,8 @@ export class Pushcut implements INodeType { } if (Array.isArray(responseData)) { returnData.push.apply(returnData, responseData as IDataObject[]); - } else if (responseData !== undefined) { returnData.push(responseData as IDataObject); - } return [this.helpers.returnJsonArray(returnData)]; } diff --git a/packages/nodes-base/nodes/Pushcut/PushcutTrigger.node.ts b/packages/nodes-base/nodes/Pushcut/PushcutTrigger.node.ts index 256d32f28a..65349a1ef3 100644 --- a/packages/nodes-base/nodes/Pushcut/PushcutTrigger.node.ts +++ b/packages/nodes-base/nodes/Pushcut/PushcutTrigger.node.ts @@ -1,18 +1,8 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import { - IDataObject, - INodeType, - INodeTypeDescription, - IWebhookResponseData, -} from 'n8n-workflow'; +import { IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; -import { - pushcutApiRequest, -} from './GenericFunctions'; +import { pushcutApiRequest } from './GenericFunctions'; export class PushcutTrigger implements INodeType { description: INodeTypeDescription = { @@ -47,7 +37,8 @@ export class PushcutTrigger implements INodeType { displayName: 'Action Name', name: 'actionName', type: 'string', - description: 'Choose any name you would like. It will show up as a server action in the app.', + description: + 'Choose any name you would like. It will show up as a server action in the app.', default: '', }, ], @@ -66,8 +57,7 @@ export class PushcutTrigger implements INodeType { const webhooks = await pushcutApiRequest.call(this, 'GET', endpoint, {}); for (const webhook of webhooks) { - if (webhook.url === webhookUrl && - webhook.actionName === actionName) { + if (webhook.url === webhookUrl && webhook.actionName === actionName) { webhookData.webhookId = webhook.id; return true; } @@ -100,7 +90,6 @@ export class PushcutTrigger implements INodeType { async delete(this: IHookFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); if (webhookData.webhookId !== undefined) { - const endpoint = `/subscriptions/${webhookData.webhookId}`; try { @@ -122,9 +111,7 @@ export class PushcutTrigger implements INodeType { const body = this.getBodyData() as IDataObject; return { - workflowData: [ - this.helpers.returnJsonArray(body), - ], + workflowData: [this.helpers.returnJsonArray(body)], }; } } diff --git a/packages/nodes-base/nodes/Pushover/GenericFunctions.ts b/packages/nodes-base/nodes/Pushover/GenericFunctions.ts index 421a7bd9ed..f404c7123c 100644 --- a/packages/nodes-base/nodes/Pushover/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Pushover/GenericFunctions.ts @@ -1,19 +1,19 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, IHttpRequestMethods, IHttpRequestOptions, NodeApiError, -} from 'n8n-workflow'; - -export async function pushoverApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: IHttpRequestMethods, path: string, body: any = {}, qs: IDataObject = {}, option = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, IHttpRequestMethods, IHttpRequestOptions, NodeApiError } from 'n8n-workflow'; +export async function pushoverApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: IHttpRequestMethods, + path: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + option = {}, + // tslint:disable-next-line:no-any +): Promise { const options: IHttpRequestOptions = { headers: { 'Content-Type': 'multipart/form-data', diff --git a/packages/nodes-base/nodes/Pushover/Pushover.node.ts b/packages/nodes-base/nodes/Pushover/Pushover.node.ts index 6d4fb85839..a5fee3a1d3 100644 --- a/packages/nodes-base/nodes/Pushover/Pushover.node.ts +++ b/packages/nodes-base/nodes/Pushover/Pushover.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryData, @@ -14,9 +12,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - pushoverApiRequest, -} from './GenericFunctions'; +import { pushoverApiRequest } from './GenericFunctions'; export class Pushover implements INodeType { description: INodeTypeDescription = { @@ -59,9 +55,7 @@ export class Pushover implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'message', - ], + resource: ['message'], }, }, options: [ @@ -80,16 +74,13 @@ export class Pushover implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'push', - ], + resource: ['message'], + operation: ['push'], }, }, default: '', - description: 'The user/group key (not e-mail address) of your user (or you), viewable when logged into the dashboard (often referred to as USER_KEY in the libraries and code examples)', + description: + 'The user/group key (not e-mail address) of your user (or you), viewable when logged into the dashboard (often referred to as USER_KEY in the libraries and code examples)', }, { displayName: 'Message', @@ -98,12 +89,8 @@ export class Pushover implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'push', - ], + resource: ['message'], + operation: ['push'], }, }, default: '', @@ -116,12 +103,8 @@ export class Pushover implements INodeType { type: 'options', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'push', - ], + resource: ['message'], + operation: ['push'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items @@ -148,7 +131,8 @@ export class Pushover implements INodeType { }, ], default: -2, - description: 'Send as -2 to generate no notification/alert, -1 to always send as a quiet notification, 1 to display as high-priority and bypass the user\'s quiet hours, or 2 to also require confirmation from the user', + description: + "Send as -2 to generate no notification/alert, -1 to always send as a quiet notification, 1 to display as high-priority and bypass the user's quiet hours, or 2 to also require confirmation from the user", }, { displayName: 'Retry (Seconds)', @@ -160,19 +144,14 @@ export class Pushover implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'push', - ], - priority: [ - 2, - ], + resource: ['message'], + operation: ['push'], + priority: [2], }, }, default: 30, - description: 'Specifies how often (in seconds) the Pushover servers will send the same notification to the user. This parameter must have a value of at least 30 seconds between retries.', + description: + 'Specifies how often (in seconds) the Pushover servers will send the same notification to the user. This parameter must have a value of at least 30 seconds between retries.', }, { displayName: 'Expire (Seconds)', @@ -185,19 +164,14 @@ export class Pushover implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'push', - ], - priority: [ - 2, - ], + resource: ['message'], + operation: ['push'], + priority: [2], }, }, default: 30, - description: 'Specifies how many seconds your notification will continue to be retried for (every retry seconds)', + description: + 'Specifies how many seconds your notification will continue to be retried for (every retry seconds)', }, { displayName: 'Additional Fields', @@ -206,12 +180,8 @@ export class Pushover implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'push', - ], + resource: ['message'], + operation: ['push'], }, }, default: {}, @@ -235,7 +205,8 @@ export class Pushover implements INodeType { type: 'string', default: '', placeholder: 'data', - description: 'Name of the binary properties which contain data which should be added to email as attachment', + description: + 'Name of the binary properties which contain data which should be added to email as attachment', }, ], }, @@ -247,7 +218,8 @@ export class Pushover implements INodeType { name: 'device', type: 'string', default: '', - description: 'Your user\'s device name to send the message directly to that device, rather than all of the user\'s devices (multiple devices may be separated by a comma)', + description: + "Your user's device name to send the message directly to that device, rather than all of the user's devices (multiple devices may be separated by a comma)", }, { displayName: 'HTML Formatting', @@ -264,28 +236,31 @@ export class Pushover implements INodeType { loadOptionsMethod: 'getSounds', }, default: '', - description: 'The name of one of the sounds supported by device clients to override the user\'s default sound choice. Choose from the list, or specify an ID using an expression.', + description: + 'The name of one of the sounds supported by device clients to override the user\'s default sound choice. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Timestamp', name: 'timestamp', type: 'dateTime', default: '', - description: 'A Unix timestamp of your message\'s date and time to display to the user, rather than the time your message is received by our API', + description: + "A Unix timestamp of your message's date and time to display to the user, rather than the time your message is received by our API", }, { displayName: 'Title', name: 'title', type: 'string', default: '', - description: 'Your message\'s title, otherwise your app\'s name is used', + description: "Your message's title, otherwise your app's name is used", }, { displayName: 'Timestamp', name: 'timestamp', type: 'dateTime', default: '', - description: 'A Unix timestamp of your message\'s date and time to display to the user, rather than the time your message is received by our API', + description: + "A Unix timestamp of your message's date and time to display to the user, rather than the time your message is received by our API", }, { displayName: 'URL', @@ -361,14 +336,16 @@ export class Pushover implements INodeType { Object.assign(body, additionalFields); if (body.attachmentsUi) { - const attachment = (body.attachmentsUi as IDataObject).attachmentsValues as IDataObject; + const attachment = (body.attachmentsUi as IDataObject) + .attachmentsValues as IDataObject; if (attachment) { - const binaryPropertyName = attachment.binaryPropertyName as string; if (items[i].binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const item = items[i].binary as IBinaryKeyData; @@ -376,7 +353,11 @@ export class Pushover implements INodeType { const binaryData = item[binaryPropertyName] as IBinaryData; if (binaryData === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + { itemIndex: i }, + ); } const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); @@ -392,12 +373,7 @@ export class Pushover implements INodeType { } } - responseData = await pushoverApiRequest.call( - this, - 'POST', - `/messages.json`, - body, - ); + responseData = await pushoverApiRequest.call(this, 'POST', `/messages.json`, body); } } } catch (error) { diff --git a/packages/nodes-base/nodes/QuestDb/QuestDb.node.ts b/packages/nodes-base/nodes/QuestDb/QuestDb.node.ts index 18952b3296..3435d34351 100644 --- a/packages/nodes-base/nodes/QuestDb/QuestDb.node.ts +++ b/packages/nodes-base/nodes/QuestDb/QuestDb.node.ts @@ -9,10 +9,7 @@ import { import pgPromise from 'pg-promise'; -import { - pgInsert, - pgQuery, -} from '../Postgres/Postgres.node.functions'; +import { pgInsert, pgQuery } from '../Postgres/Postgres.node.functions'; export class QuestDb implements INodeType { description: INodeTypeDescription = { @@ -69,15 +66,14 @@ export class QuestDb implements INodeType { }, displayOptions: { show: { - operation: [ - 'executeQuery', - ], + operation: ['executeQuery'], }, }, default: '', placeholder: 'SELECT id, name FROM product WHERE quantity > $1 AND price <= $2', required: true, - description: 'The SQL query to execute. You can use n8n expressions or $1 and $2 in conjunction with query parameters.', + description: + 'The SQL query to execute. You can use n8n expressions or $1 and $2 in conjunction with query parameters.', }, // ---------------------------------- @@ -89,9 +85,7 @@ export class QuestDb implements INodeType { type: 'hidden', // Schema is used by pgInsert displayOptions: { show: { - operation: [ - 'insert', - ], + operation: ['insert'], }, }, default: '', @@ -103,9 +97,7 @@ export class QuestDb implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'insert', - ], + operation: ['insert'], }, }, default: '', @@ -123,7 +115,8 @@ export class QuestDb implements INodeType { }, default: '', placeholder: 'id,name,description', - description: 'Comma-separated list of the properties which should used as columns for the new rows', + description: + 'Comma-separated list of the properties which should used as columns for the new rows', }, { displayName: 'Return Fields', @@ -148,9 +141,7 @@ export class QuestDb implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'executeQuery', - ], + operation: ['executeQuery'], }, }, options: [ @@ -171,7 +162,8 @@ export class QuestDb implements INodeType { }, ], default: 'independently', - description: 'The way queries should be sent to database. Can be used in conjunction with Continue on Fail. See the docs for more examples.', + description: + 'The way queries should be sent to database. Can be used in conjunction with Continue on Fail. See the docs for more examples.', }, { displayName: 'Query Parameters', @@ -179,14 +171,13 @@ export class QuestDb implements INodeType { type: 'string', displayOptions: { show: { - '/operation': [ - 'executeQuery', - ], + '/operation': ['executeQuery'], }, }, default: '', placeholder: 'quantity,price', - description: 'Comma-separated list of properties which should be used as query parameters', + description: + 'Comma-separated list of properties which should be used as query parameters', }, ], }, @@ -197,9 +188,7 @@ export class QuestDb implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'insert', - ], + operation: ['insert'], }, }, }, @@ -236,7 +225,14 @@ export class QuestDb implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', 0) as IDataObject; const mode = (additionalFields.mode || 'independently') as string; - const queryResult = await pgQuery(this.getNodeParameter, pgp, db, items, this.continueOnFail(), mode); + const queryResult = await pgQuery( + this.getNodeParameter, + pgp, + db, + items, + this.continueOnFail(), + mode, + ); returnItems = this.helpers.returnJsonArray(queryResult); } else if (operation === 'insert') { @@ -252,14 +248,20 @@ export class QuestDb implements INodeType { const table = this.getNodeParameter('table', 0) as string; const insertData = await db.any('SELECT ${columns:name} from ${table:name}', { - columns: returnFields.split(',').map(value => value.trim()).filter(value => !!value), + columns: returnFields + .split(',') + .map((value) => value.trim()) + .filter((value) => !!value), table, }); returnItems = this.helpers.returnJsonArray(insertData); } else { await pgp.end(); - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not supported!`, + ); } // Close the connection diff --git a/packages/nodes-base/nodes/QuickBase/FieldDescription.ts b/packages/nodes-base/nodes/QuickBase/FieldDescription.ts index ceac817fd0..b4d295701c 100644 --- a/packages/nodes-base/nodes/QuickBase/FieldDescription.ts +++ b/packages/nodes-base/nodes/QuickBase/FieldDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const fieldOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const fieldOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'field', - ], + resource: ['field'], }, }, options: [ @@ -39,12 +35,8 @@ export const fieldFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'field', - ], - operation: [ - 'getAll', - ], + resource: ['field'], + operation: ['getAll'], }, }, description: 'The table identifier', @@ -55,12 +47,8 @@ export const fieldFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'field', - ], - operation: [ - 'getAll', - ], + resource: ['field'], + operation: ['getAll'], }, }, default: false, @@ -72,15 +60,9 @@ export const fieldFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'field', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['field'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -98,12 +80,8 @@ export const fieldFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'field', - ], - operation: [ - 'getAll', - ], + resource: ['field'], + operation: ['getAll'], }, }, options: [ diff --git a/packages/nodes-base/nodes/QuickBase/FileDescription.ts b/packages/nodes-base/nodes/QuickBase/FileDescription.ts index 0f88afb10a..6dc28edb65 100644 --- a/packages/nodes-base/nodes/QuickBase/FileDescription.ts +++ b/packages/nodes-base/nodes/QuickBase/FileDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const fileOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const fileOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'file', - ], + resource: ['file'], }, }, options: [ @@ -45,13 +41,8 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'download', - 'delete', - ], + resource: ['file'], + operation: ['download', 'delete'], }, }, description: 'The table identifier', @@ -64,13 +55,8 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'download', - 'delete', - ], + resource: ['file'], + operation: ['download', 'delete'], }, }, description: 'The unique identifier of the record', @@ -83,13 +69,8 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'download', - 'delete', - ], + resource: ['file'], + operation: ['download', 'delete'], }, }, description: 'The unique identifier of the field', @@ -102,13 +83,8 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'download', - 'delete', - ], + resource: ['file'], + operation: ['download', 'delete'], }, }, description: 'The file attachment version number', @@ -117,12 +93,8 @@ export const fileFields: INodeProperties[] = [ displayName: 'Binary Property', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'download', - ], + resource: ['file'], + operation: ['download'], }, }, name: 'binaryPropertyName', diff --git a/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts b/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts index f8b6abdf39..d4aa1ac6bb 100644 --- a/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts +++ b/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,12 +7,18 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; - -export async function quickbaseApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; +export async function quickbaseApiRequest( + this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('quickbaseApi'); if (!credentials.hostname) { @@ -30,7 +34,7 @@ export async function quickbaseApiRequest(this: IExecuteFunctions | ILoadOptions headers: { 'QB-Realm-Hostname': credentials.hostname, 'User-Agent': 'n8n', - 'Authorization': `QB-USER-TOKEN ${credentials.userToken}`, + Authorization: `QB-USER-TOKEN ${credentials.userToken}`, 'Content-Type': 'application/json', }, method, @@ -40,7 +44,6 @@ export async function quickbaseApiRequest(this: IExecuteFunctions | ILoadOptions json: true, }; - if (Object.keys(body).length === 0) { delete options.body; } @@ -60,6 +63,7 @@ export async function quickbaseApiRequest(this: IExecuteFunctions | ILoadOptions } //@ts-ignore +// prettier-ignore export async function getFieldsObject(this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, tableId: string): any { // tslint:disable-line:no-any const fieldsLabelKey: { [key: string]: number } = {}; const fieldsIdKey: { [key: number]: string } = {}; @@ -71,8 +75,15 @@ export async function getFieldsObject(this: IHookFunctions | ILoadOptionsFunctio return { fieldsLabelKey, fieldsIdKey }; } -export async function quickbaseApiRequestAllItems(this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function quickbaseApiRequestAllItems( + this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData = []; @@ -90,7 +101,11 @@ export async function quickbaseApiRequestAllItems(this: IHookFunctions | ILoadOp let metadata; do { - const { data, fields, metadata: meta } = await quickbaseApiRequest.call(this, method, resource, body, query); + const { + data, + fields, + metadata: meta, + } = await quickbaseApiRequest.call(this, method, resource, body, query); metadata = meta; @@ -116,9 +131,7 @@ export async function quickbaseApiRequestAllItems(this: IHookFunctions | ILoadOp } returnData.push.apply(returnData, responseData); responseData = []; - } while ( - returnData.length < metadata.totalRecords - ); + } while (returnData.length < metadata.totalRecords); return returnData; } diff --git a/packages/nodes-base/nodes/QuickBase/QuickBase.node.ts b/packages/nodes-base/nodes/QuickBase/QuickBase.node.ts index f9e3755bc6..7c8f15fcb6 100644 --- a/packages/nodes-base/nodes/QuickBase/QuickBase.node.ts +++ b/packages/nodes-base/nodes/QuickBase/QuickBase.node.ts @@ -1,7 +1,5 @@ /* eslint-disable n8n-nodes-base/node-filename-against-convention */ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -19,25 +17,13 @@ import { quickbaseApiRequestAllItems, } from './GenericFunctions'; -import { - fieldFields, - fieldOperations, -} from './FieldDescription'; +import { fieldFields, fieldOperations } from './FieldDescription'; -import { - fileFields, - fileOperations, -} from './FileDescription'; +import { fileFields, fileOperations } from './FileDescription'; -import { - recordFields, - recordOperations, -} from './RecordDescription'; +import { recordFields, recordOperations } from './RecordDescription'; -import { - reportFields, - reportOperations, -} from './ReportDescription'; +import { reportFields, reportOperations } from './ReportDescription'; export class QuickBase implements INodeType { description: INodeTypeDescription = { @@ -142,7 +128,6 @@ export class QuickBase implements INodeType { if (resource === 'field') { if (operation === 'getAll') { for (let i = 0; i < length; i++) { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; const tableId = this.getNodeParameter('tableId', i) as string; @@ -179,16 +164,18 @@ export class QuickBase implements INodeType { const versionNumber = this.getNodeParameter('versionNumber', i) as string; - responseData = await quickbaseApiRequest.call(this, 'DELETE', `/files/${tableId}/${recordId}/${fieldId}/${versionNumber}`); + responseData = await quickbaseApiRequest.call( + this, + 'DELETE', + `/files/${tableId}/${recordId}/${fieldId}/${versionNumber}`, + ); returnData.push(responseData); } } if (operation === 'download') { - for (let i = 0; i < length; i++) { - const tableId = this.getNodeParameter('tableId', i) as string; const recordId = this.getNodeParameter('recordId', i) as string; @@ -213,14 +200,24 @@ export class QuickBase implements INodeType { const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string; - responseData = await quickbaseApiRequest.call(this, 'GET', `/files/${tableId}/${recordId}/${fieldId}/${versionNumber}`, {}, {}, { json: false, resolveWithFullResponse: true }); + responseData = await quickbaseApiRequest.call( + this, + 'GET', + `/files/${tableId}/${recordId}/${fieldId}/${versionNumber}`, + {}, + {}, + { json: false, resolveWithFullResponse: true }, + ); //content-disposition': 'attachment; filename="dog-puppy-on-garden-royalty-free-image-1586966191.jpg"', const contentDisposition = responseData.headers['content-disposition']; const data = Buffer.from(responseData.body as string, 'base64'); - items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data as unknown as Buffer, contentDisposition.split('=')[1]); + items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( + data as unknown as Buffer, + contentDisposition.split('=')[1], + ); } return this.prepareOutputData(items); @@ -242,7 +239,7 @@ export class QuickBase implements INodeType { const columns = this.getNodeParameter('columns', i) as string; - const columnList = columns.split(',').map(column => column.trim()); + const columnList = columns.split(',').map((column) => column.trim()); if (options.useFieldIDs === true) { for (const key of Object.keys(items[i].json)) { record[key] = { value: items[i].json[key] }; @@ -313,7 +310,6 @@ export class QuickBase implements INodeType { if (operation === 'getAll') { for (let i = 0; i < length; i++) { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; const tableId = this.getNodeParameter('tableId', i) as string; @@ -339,7 +335,13 @@ export class QuickBase implements INodeType { // } if (returnAll) { - responseData = await quickbaseApiRequestAllItems.call(this, 'POST', '/records/query', body, qs); + responseData = await quickbaseApiRequestAllItems.call( + this, + 'POST', + '/records/query', + body, + qs, + ); } else { body.options = { top: this.getNodeParameter('limit', i) as number }; @@ -384,7 +386,7 @@ export class QuickBase implements INodeType { const columns = this.getNodeParameter('columns', i) as string; - const columnList = columns.split(',').map(column => column.trim()); + const columnList = columns.split(',').map((column) => column.trim()); if (options.useFieldIDs === true) { for (const key of Object.keys(items[i].json)) { @@ -400,7 +402,11 @@ export class QuickBase implements INodeType { } if (items[i].json[updateKey] === undefined) { - throw new NodeOperationError(this.getNode(), `The update key ${updateKey} could not be found in the input`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The update key ${updateKey} could not be found in the input`, + { itemIndex: i }, + ); } data.push(record); @@ -459,7 +465,7 @@ export class QuickBase implements INodeType { const columns = this.getNodeParameter('columns', i) as string; - const columnList = columns.split(',').map(column => column.trim()); + const columnList = columns.split(',').map((column) => column.trim()); if (options.useFieldIDs === true) { for (const key of Object.keys(items[i].json)) { @@ -475,7 +481,11 @@ export class QuickBase implements INodeType { } if (items[i].json[updateKey] === undefined) { - throw new NodeOperationError(this.getNode(), `The update key ${updateKey} could not be found in the input`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The update key ${updateKey} could not be found in the input`, + { itemIndex: i }, + ); } record[mergeFieldId] = { value: items[i].json[updateKey] }; @@ -521,10 +531,8 @@ export class QuickBase implements INodeType { } if (resource === 'report') { - if (operation === 'run') { for (let i = 0; i < length; i++) { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; const tableId = this.getNodeParameter('tableId', i) as string; @@ -534,11 +542,23 @@ export class QuickBase implements INodeType { qs.tableId = tableId; if (returnAll) { - responseData = await quickbaseApiRequestAllItems.call(this, 'POST', `/reports/${reportId}/run`, {}, qs); + responseData = await quickbaseApiRequestAllItems.call( + this, + 'POST', + `/reports/${reportId}/run`, + {}, + qs, + ); } else { qs.top = this.getNodeParameter('limit', i) as number; - responseData = await quickbaseApiRequest.call(this, 'POST', `/reports/${reportId}/run`, {}, qs); + responseData = await quickbaseApiRequest.call( + this, + 'POST', + `/reports/${reportId}/run`, + {}, + qs, + ); const { data: records, fields } = responseData; responseData = []; @@ -563,14 +583,19 @@ export class QuickBase implements INodeType { if (operation === 'get') { for (let i = 0; i < length; i++) { - const reportId = this.getNodeParameter('reportId', i) as string; const tableId = this.getNodeParameter('tableId', i) as string; qs.tableId = tableId; - responseData = await quickbaseApiRequest.call(this, 'GET', `/reports/${reportId}`, {}, qs); + responseData = await quickbaseApiRequest.call( + this, + 'GET', + `/reports/${reportId}`, + {}, + qs, + ); returnData.push(responseData); } diff --git a/packages/nodes-base/nodes/QuickBase/RecordDescription.ts b/packages/nodes-base/nodes/QuickBase/RecordDescription.ts index b5a069928b..dca0e85138 100644 --- a/packages/nodes-base/nodes/QuickBase/RecordDescription.ts +++ b/packages/nodes-base/nodes/QuickBase/RecordDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const recordOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const recordOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'record', - ], + resource: ['record'], }, }, options: [ @@ -63,12 +59,8 @@ export const recordFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'create', - ], + resource: ['record'], + operation: ['create'], }, }, description: 'The table identifier', @@ -79,18 +71,15 @@ export const recordFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'create', - ], + resource: ['record'], + operation: ['create'], }, }, default: '', required: true, placeholder: 'Select Fields...', - description: 'Comma-separated list of the properties which should used as columns for the new rows', + description: + 'Comma-separated list of the properties which should used as columns for the new rows', }, { displayName: 'Simplify', @@ -98,12 +87,8 @@ export const recordFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'create', - ], + resource: ['record'], + operation: ['create'], }, }, default: true, @@ -117,12 +102,8 @@ export const recordFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'create', - ], + resource: ['record'], + operation: ['create'], }, }, options: [ @@ -132,12 +113,11 @@ export const recordFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getTableFields', - loadOptionsDependsOn: [ - 'tableId', - ], + loadOptionsDependsOn: ['tableId'], }, default: [], - description: 'Specify an array of field IDs that will return data for any updates or added record. Record ID (FID 3) is always returned if any field ID is requested. Choose from the list, or specify IDs using an expression.', + description: + 'Specify an array of field IDs that will return data for any updates or added record. Record ID (FID 3) is always returned if any field ID is requested. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Use Field IDs', @@ -159,12 +139,8 @@ export const recordFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'delete', - ], + resource: ['record'], + operation: ['delete'], }, }, description: 'The table identifier', @@ -177,15 +153,12 @@ export const recordFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'delete', - ], + resource: ['record'], + operation: ['delete'], }, }, - description: 'The filter to delete records. To delete all records specify a filter that will include all records, for example {3.GT.0} where 3 is the ID of the Record ID field.', + description: + 'The filter to delete records. To delete all records specify a filter that will include all records, for example {3.GT.0} where 3 is the ID of the Record ID field.', }, /* -------------------------------------------------------------------------- */ /* record:getAll */ @@ -198,12 +171,8 @@ export const recordFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'getAll', - ], + resource: ['record'], + operation: ['getAll'], }, }, description: 'The table identifier', @@ -214,12 +183,8 @@ export const recordFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'getAll', - ], + resource: ['record'], + operation: ['getAll'], }, }, default: false, @@ -231,15 +196,9 @@ export const recordFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['record'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -257,12 +216,8 @@ export const recordFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'getAll', - ], + resource: ['record'], + operation: ['getAll'], }, }, options: [ @@ -275,7 +230,8 @@ export const recordFields: INodeProperties[] = [ loadOptionsMethod: 'getTableFields', }, default: [], - description: 'An array of field IDs for the fields that should be returned in the response. If empty, the default columns on the table will be returned. Choose from the list, or specify IDs using an expression.', + description: + 'An array of field IDs for the fields that should be returned in the response. If empty, the default columns on the table will be returned. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Sort By', @@ -299,7 +255,8 @@ export const recordFields: INodeProperties[] = [ loadOptionsMethod: 'getTableFields', }, default: '', - description: 'The unique identifier of a field in a table. Choose from the list, or specify an ID using an expression.', + description: + 'The unique identifier of a field in a table. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Order', @@ -320,14 +277,16 @@ export const recordFields: INodeProperties[] = [ ], }, ], - description: 'By default, queries will be sorted by the given sort fields or the default sort if the query does not provide any. Set to false to avoid sorting when the order of the data returned is not important. Returning data without sorting can improve performance.', + description: + 'By default, queries will be sorted by the given sort fields or the default sort if the query does not provide any. Set to false to avoid sorting when the order of the data returned is not important. Returning data without sorting can improve performance.', }, { displayName: 'Where', name: 'where', type: 'string', default: '', - description: 'The filter, using the Quick Base query language, which determines the records to return', + description: + 'The filter, using the Quick Base query language, which determines the records to return', }, ], }, @@ -342,12 +301,8 @@ export const recordFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'update', - ], + resource: ['record'], + operation: ['update'], }, }, description: 'The table identifier', @@ -358,18 +313,15 @@ export const recordFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'update', - ], + resource: ['record'], + operation: ['update'], }, }, default: '', required: true, placeholder: 'id,name,description', - description: 'Comma-separated list of the properties which should used as columns for the new rows', + description: + 'Comma-separated list of the properties which should used as columns for the new rows', }, { displayName: 'Update Key', @@ -377,12 +329,8 @@ export const recordFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'update', - ], + resource: ['record'], + operation: ['update'], }, }, default: '', @@ -394,12 +342,8 @@ export const recordFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'update', - ], + resource: ['record'], + operation: ['update'], }, }, default: true, @@ -413,12 +357,8 @@ export const recordFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'update', - ], + resource: ['record'], + operation: ['update'], }, }, options: [ @@ -428,12 +368,11 @@ export const recordFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getTableFields', - loadOptionsDependsOn: [ - 'tableId', - ], + loadOptionsDependsOn: ['tableId'], }, default: [], - description: 'Specify an array of field IDs that will return data for any updates or added record. Record ID (FID 3) is always returned if any field ID is requested. Choose from the list, or specify IDs using an expression.', + description: + 'Specify an array of field IDs that will return data for any updates or added record. Record ID (FID 3) is always returned if any field ID is requested. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Use Field IDs', @@ -467,12 +406,8 @@ export const recordFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'upsert', - ], + resource: ['record'], + operation: ['upsert'], }, }, description: 'The table identifier', @@ -483,18 +418,15 @@ export const recordFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'upsert', - ], + resource: ['record'], + operation: ['upsert'], }, }, default: '', required: true, placeholder: 'id,name,description', - description: 'Comma-separated list of the properties which should used as columns for the new rows', + description: + 'Comma-separated list of the properties which should used as columns for the new rows', }, { displayName: 'Update Key', @@ -502,12 +434,8 @@ export const recordFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'upsert', - ], + resource: ['record'], + operation: ['upsert'], }, }, default: '', @@ -522,16 +450,13 @@ export const recordFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'upsert', - ], + resource: ['record'], + operation: ['upsert'], }, }, default: '', - description: '

You\'re updating records in a Quick Base table with data from an external file. In order for a merge like this to work, Quick Base needs a way to match records in the source data with corresponding records in the destination table.

You make this possible by choosing the field in the app table that holds unique matching values. This is called a merge field.

. Choose from the list, or specify an ID using an expression.', + description: + '

You\'re updating records in a Quick Base table with data from an external file. In order for a merge like this to work, Quick Base needs a way to match records in the source data with corresponding records in the destination table.

You make this possible by choosing the field in the app table that holds unique matching values. This is called a merge field.

. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Simplify', @@ -539,12 +464,8 @@ export const recordFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'upsert', - ], + resource: ['record'], + operation: ['upsert'], }, }, default: true, @@ -558,12 +479,8 @@ export const recordFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'record', - ], - operation: [ - 'upsert', - ], + resource: ['record'], + operation: ['upsert'], }, }, options: [ @@ -573,12 +490,11 @@ export const recordFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getTableFields', - loadOptionsDependsOn: [ - 'tableId', - ], + loadOptionsDependsOn: ['tableId'], }, default: [], - description: 'Specify an array of field IDs that will return data for any updates or added record. Record ID (FID 3) is always returned if any field ID is requested. Choose from the list, or specify IDs using an expression.', + description: + 'Specify an array of field IDs that will return data for any updates or added record. Record ID (FID 3) is always returned if any field ID is requested. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Use Field IDs', diff --git a/packages/nodes-base/nodes/QuickBase/ReportDescription.ts b/packages/nodes-base/nodes/QuickBase/ReportDescription.ts index b7e2f4b905..50df34256e 100644 --- a/packages/nodes-base/nodes/QuickBase/ReportDescription.ts +++ b/packages/nodes-base/nodes/QuickBase/ReportDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const reportOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const reportOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'report', - ], + resource: ['report'], }, }, options: [ @@ -45,12 +41,8 @@ export const reportFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'get', - ], + resource: ['report'], + operation: ['get'], }, }, description: 'The table identifier', @@ -63,12 +55,8 @@ export const reportFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'get', - ], + resource: ['report'], + operation: ['get'], }, }, description: 'The identifier of the report, unique to the table', @@ -84,12 +72,8 @@ export const reportFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'run', - ], + resource: ['report'], + operation: ['run'], }, }, description: 'The table identifier', @@ -102,12 +86,8 @@ export const reportFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'run', - ], + resource: ['report'], + operation: ['run'], }, }, description: 'The identifier of the report, unique to the table', @@ -118,12 +98,8 @@ export const reportFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'run', - ], + resource: ['report'], + operation: ['run'], }, }, default: true, @@ -135,17 +111,11 @@ export const reportFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'run', - ], + resource: ['report'], + operation: ['run'], }, hide: { - returnAll: [ - true, - ], + returnAll: [true], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts b/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts index 3df51d7b47..1ac835b915 100644 --- a/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts +++ b/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts @@ -1,7 +1,4 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; import { IDataObject, @@ -11,31 +8,15 @@ import { NodeApiError, } from 'n8n-workflow'; -import { - CustomField, - GeneralAddress, - Ref, -} from './descriptions/Shared.interface'; +import { CustomField, GeneralAddress, Ref } from './descriptions/Shared.interface'; -import { - capitalCase, -} from 'change-case'; +import { capitalCase } from 'change-case'; -import { - omit, - pickBy, -} from 'lodash'; +import { omit, pickBy } from 'lodash'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - DateFieldsUi, - Option, - QuickBooksOAuth2Credentials, - TransactionReport, -} from './types'; +import { DateFieldsUi, Option, QuickBooksOAuth2Credentials, TransactionReport } from './types'; /** * Make an authenticated API request to QuickBooks. @@ -47,8 +28,8 @@ export async function quickBooksApiRequest( qs: IDataObject, body: IDataObject, option: IDataObject = {}, -): Promise { // tslint:disable-line:no-any - + // tslint:disable-next-line:no-any +): Promise { const resource = this.getNodeParameter('resource', 0) as string; const operation = this.getNodeParameter('operation', 0) as string; @@ -61,7 +42,9 @@ export async function quickBooksApiRequest( const productionUrl = 'https://quickbooks.api.intuit.com'; const sandboxUrl = 'https://sandbox-quickbooks.api.intuit.com'; - const credentials = await this.getCredentials('quickBooksOAuth2Api') as QuickBooksOAuth2Credentials; + const credentials = (await this.getCredentials( + 'quickBooksOAuth2Api', + )) as QuickBooksOAuth2Credentials; const options: OptionsWithUri = { headers: { @@ -118,8 +101,8 @@ export async function quickBooksApiRequestAllItems( qs: IDataObject, body: IDataObject, resource: string, -): Promise { // tslint:disable-line:no-any - + // tslint:disable-next-line:no-any +): Promise { let responseData; let startPosition = 1; const maxResults = 1000; @@ -148,7 +131,6 @@ export async function quickBooksApiRequestAllItems( } startPosition += maxResults; - } while (maxCount > returnData.length); return returnData; @@ -159,8 +141,8 @@ async function getCount( method: string, endpoint: string, qs: IDataObject, -): Promise { // tslint:disable-line:no-any - + // tslint:disable-next-line:no-any +): Promise { const responseData = await quickBooksApiRequest.call(this, method, endpoint, qs, {}); return responseData.QueryResponse.totalCount; @@ -174,7 +156,8 @@ export async function handleListing( i: number, endpoint: string, resource: string, -): Promise { // tslint:disable-line:no-any + // tslint:disable-next-line:no-any +): Promise { let responseData; const qs = { @@ -211,7 +194,9 @@ export async function getSyncToken( const resourceId = this.getNodeParameter(`${resource}Id`, i); const getEndpoint = `/v3/company/${companyId}/${resource}/${resourceId}`; const propertyName = capitalCase(resource); - const { [propertyName]: { SyncToken } } = await quickBooksApiRequest.call(this, 'GET', getEndpoint, {}, {}); + const { + [propertyName]: { SyncToken }, + } = await quickBooksApiRequest.call(this, 'GET', getEndpoint, {}, {}); return SyncToken; } @@ -234,7 +219,6 @@ export async function getRefAndSyncToken( ref: responseData[capitalCase(resource)][ref], syncToken: responseData[capitalCase(resource)].SyncToken, }; - } /** @@ -261,23 +245,35 @@ export async function handleBinaryData( return items; } -export async function loadResource( - this: ILoadOptionsFunctions, - resource: string, -) { +export async function loadResource(this: ILoadOptionsFunctions, resource: string) { const returnData: INodePropertyOptions[] = []; const qs = { query: `SELECT * FROM ${resource}`, } as IDataObject; - const { oauthTokenData: { callbackQueryString: { realmId } } } = await this.getCredentials('quickBooksOAuth2Api') as { oauthTokenData: { callbackQueryString: { realmId: string } } }; + const { + oauthTokenData: { + callbackQueryString: { realmId }, + }, + } = (await this.getCredentials('quickBooksOAuth2Api')) as { + oauthTokenData: { callbackQueryString: { realmId: string } }; + }; const endpoint = `/v3/company/${realmId}/query`; - const resourceItems = await quickBooksApiRequestAllItems.call(this, 'GET', endpoint, qs, {}, resource); + const resourceItems = await quickBooksApiRequestAllItems.call( + this, + 'GET', + endpoint, + qs, + {}, + resource, + ); if (resource === 'preferences') { - const { SalesFormsPrefs: { CustomField } } = resourceItems[0]; + const { + SalesFormsPrefs: { CustomField }, + } = resourceItems[0]; const customFields = CustomField[1].CustomField; for (const customField of customFields) { const length = customField.Name.length; @@ -289,7 +285,7 @@ export async function loadResource( return returnData; } - resourceItems.forEach((resourceItem: { DisplayName: string, Name: string, Id: string }) => { + resourceItems.forEach((resourceItem: { DisplayName: string; Name: string; Id: string }) => { returnData.push({ name: resourceItem.DisplayName || resourceItem.Name || `Memo ${resourceItem.Id}`, value: resourceItem.Id, @@ -308,10 +304,8 @@ export function processLines( lines: IDataObject[], resource: string, ) { - lines.forEach((line) => { if (resource === 'bill') { - if (line.DetailType === 'AccountBasedExpenseLineDetail') { line.AccountBasedExpenseLineDetail = { AccountRef: { @@ -327,29 +321,26 @@ export function processLines( }; delete line.itemId; } - } else if (resource === 'estimate') { if (line.DetailType === 'SalesItemLineDetail') { line.SalesItemLineDetail = { ItemRef: { value: line.itemId, }, - TaxCodeRef : { + TaxCodeRef: { value: line.TaxCodeRef, }, }; delete line.itemId; delete line.TaxCodeRef; } - - } else if (resource === 'invoice') { if (line.DetailType === 'SalesItemLineDetail') { line.SalesItemLineDetail = { ItemRef: { value: line.itemId, }, - TaxCodeRef : { + TaxCodeRef: { value: line.TaxCodeRef, }, }; @@ -357,7 +348,6 @@ export function processLines( delete line.TaxCodeRef; } } - }); return lines; @@ -372,53 +362,40 @@ export function populateFields( fields: IDataObject, resource: string, ) { - Object.entries(fields).forEach(([key, value]) => { - if (resource === 'bill') { - if (key.endsWith('Ref')) { const { details } = value as { details: Ref }; body[key] = { name: details.name, value: details.value, }; - } else { body[key] = value; } - } else if (['customer', 'employee', 'vendor'].includes(resource)) { - if (key === 'BillAddr') { const { details } = value as { details: GeneralAddress }; - body.BillAddr = pickBy(details, detail => detail !== ''); - + body.BillAddr = pickBy(details, (detail) => detail !== ''); } else if (key === 'PrimaryEmailAddr') { body.PrimaryEmailAddr = { Address: value, }; - } else if (key === 'PrimaryPhone') { body.PrimaryPhone = { FreeFormNumber: value, }; - } else { body[key] = value; } - } else if (resource === 'estimate' || resource === 'invoice') { - if (key === 'BillAddr' || key === 'ShipAddr') { const { details } = value as { details: GeneralAddress }; - body[key] = pickBy(details, detail => detail !== ''); - + body[key] = pickBy(details, (detail) => detail !== ''); } else if (key === 'BillEmail') { body.BillEmail = { Address: value, }; - } else if (key === 'CustomFields') { const { Field } = value as { Field: CustomField[] }; body.CustomField = Field; @@ -427,28 +404,23 @@ export function populateFields( //@ts-ignore body.CustomField[i]['Type'] = 'StringType'; } - } else if (key === 'CustomerMemo') { body.CustomerMemo = { value, }; - } else if (key.endsWith('Ref')) { const { details } = value as { details: Ref }; body[key] = { name: details.name, value: details.value, }; - } else if (key === 'TotalTax') { body.TxnTaxDetail = { TotalTax: value, }; - } else { body[key] = value; } - } else if (resource === 'payment') { body[key] = value; } @@ -466,9 +438,7 @@ export const splitPascalCase = (word: string) => { return word.match(/($[a-z])|[A-Z][^A-Z]+/g)!.join(' '); }; -export function adjustTransactionDates( - transactionFields: IDataObject & DateFieldsUi, -): IDataObject { +export function adjustTransactionDates(transactionFields: IDataObject & DateFieldsUi): IDataObject { const dateFieldKeys = [ 'dateRangeCustom', 'dateRangeDueCustom', @@ -476,18 +446,18 @@ export function adjustTransactionDates( 'dateRangeCreationCustom', ] as const; - if (dateFieldKeys.every(dateField => !transactionFields[dateField])) { + if (dateFieldKeys.every((dateField) => !transactionFields[dateField])) { return transactionFields; } let adjusted = omit(transactionFields, dateFieldKeys) as IDataObject; - dateFieldKeys.forEach(dateFieldKey => { + dateFieldKeys.forEach((dateFieldKey) => { const dateField = transactionFields[dateFieldKey]; if (dateField) { - Object.entries(dateField[`${dateFieldKey}Properties`]).map(([key, value]) => - dateField[`${dateFieldKey}Properties`][key] = value.split('T')[0], + Object.entries(dateField[`${dateFieldKey}Properties`]).map( + ([key, value]) => (dateField[`${dateFieldKey}Properties`][key] = value.split('T')[0]), ); adjusted = { @@ -502,7 +472,7 @@ export function adjustTransactionDates( export function simplifyTransactionReport(transactionReport: TransactionReport) { const columns = transactionReport.Columns.Column.map((column) => column.ColType); - const rows = transactionReport.Rows.Row.map((row) => row.ColData.map(i => i.value)); + const rows = transactionReport.Rows.Row.map((row) => row.ColData.map((i) => i.value)); const simplified = []; for (const row of rows) { diff --git a/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts b/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts index 18dd2488d9..60e7b0f5dc 100644 --- a/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts +++ b/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts @@ -1,7 +1,5 @@ /* eslint-disable n8n-nodes-base/node-filename-against-convention */ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -48,19 +46,11 @@ import { simplifyTransactionReport, } from './GenericFunctions'; -import { - capitalCase, -} from 'change-case'; +import { capitalCase } from 'change-case'; -import { - isEmpty, -} from 'lodash'; +import { isEmpty } from 'lodash'; -import { - DateFieldsUi, - QuickBooksOAuth2Credentials, - TransactionFields, -} from './types'; +import { DateFieldsUi, QuickBooksOAuth2Credentials, TransactionFields } from './types'; export class QuickBooks implements INodeType { description: INodeTypeDescription = { @@ -204,13 +194,14 @@ export class QuickBooks implements INodeType { let responseData; const returnData: IDataObject[] = []; - const { oauthTokenData } = await this.getCredentials('quickBooksOAuth2Api') as QuickBooksOAuth2Credentials; + const { oauthTokenData } = (await this.getCredentials( + 'quickBooksOAuth2Api', + )) as QuickBooksOAuth2Credentials; const companyId = oauthTokenData.callbackQueryString.realmId; for (let i = 0; i < items.length; i++) { try { if (resource === 'bill') { - // ********************************************************************* // bill // ********************************************************************* @@ -218,7 +209,6 @@ export class QuickBooks implements INodeType { // https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/bill if (operation === 'create') { - // ---------------------------------- // bill: create // ---------------------------------- @@ -226,18 +216,47 @@ export class QuickBooks implements INodeType { const lines = this.getNodeParameter('Line', i) as IDataObject[]; if (!lines.length) { - throw new NodeOperationError(this.getNode(), `Please enter at least one line for the ${resource}.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Please enter at least one line for the ${resource}.`, + { itemIndex: i }, + ); } - if (lines.some(line => line.DetailType === undefined || line.Amount === undefined || line.Description === undefined)) { - throw new NodeOperationError(this.getNode(), 'Please enter detail type, amount and description for every line.', { itemIndex: i }); + if ( + lines.some( + (line) => + line.DetailType === undefined || + line.Amount === undefined || + line.Description === undefined, + ) + ) { + throw new NodeOperationError( + this.getNode(), + 'Please enter detail type, amount and description for every line.', + { itemIndex: i }, + ); } - lines.forEach(line => { - if (line.DetailType === 'AccountBasedExpenseLineDetail' && line.accountId === undefined) { - throw new NodeOperationError(this.getNode(), 'Please enter an account ID for the associated line.', { itemIndex: i }); - } else if (line.DetailType === 'ItemBasedExpenseLineDetail' && line.itemId === undefined) { - throw new NodeOperationError(this.getNode(), 'Please enter an item ID for the associated line.', { itemIndex: i }); + lines.forEach((line) => { + if ( + line.DetailType === 'AccountBasedExpenseLineDetail' && + line.accountId === undefined + ) { + throw new NodeOperationError( + this.getNode(), + 'Please enter an account ID for the associated line.', + { itemIndex: i }, + ); + } else if ( + line.DetailType === 'ItemBasedExpenseLineDetail' && + line.itemId === undefined + ) { + throw new NodeOperationError( + this.getNode(), + 'Please enter an item ID for the associated line.', + { itemIndex: i }, + ); } }); @@ -256,9 +275,7 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, {}, body); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'delete') { - // ---------------------------------- // bill: delete // ---------------------------------- @@ -275,9 +292,7 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, qs, body); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'get') { - // ---------------------------------- // bill: get // ---------------------------------- @@ -286,23 +301,25 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}/${billId}`; responseData = await quickBooksApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'getAll') { - // ---------------------------------- // bill: getAll // ---------------------------------- const endpoint = `/v3/company/${companyId}/query`; responseData = await handleListing.call(this, i, endpoint, resource); - } else if (operation === 'update') { - // ---------------------------------- // bill: update // ---------------------------------- - const { ref, syncToken } = await getRefAndSyncToken.call(this, i, companyId, resource, 'VendorRef'); + const { ref, syncToken } = await getRefAndSyncToken.call( + this, + i, + companyId, + resource, + 'VendorRef', + ); let body = { Id: this.getNodeParameter('billId', i), @@ -317,7 +334,11 @@ export class QuickBooks implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; if (isEmpty(updateFields)) { - throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Please enter at least one field to update for the ${resource}.`, + { itemIndex: i }, + ); } body = populateFields.call(this, body, updateFields, resource); @@ -325,11 +346,8 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, {}, body); responseData = responseData[capitalCase(resource)]; - } - } else if (resource === 'customer') { - // ********************************************************************* // customer // ********************************************************************* @@ -337,7 +355,6 @@ export class QuickBooks implements INodeType { // https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/customer if (operation === 'create') { - // ---------------------------------- // customer: create // ---------------------------------- @@ -353,9 +370,7 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, {}, body); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'get') { - // ---------------------------------- // customer: get // ---------------------------------- @@ -364,18 +379,14 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}/${customerId}`; responseData = await quickBooksApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'getAll') { - // ---------------------------------- // customer: getAll // ---------------------------------- const endpoint = `/v3/company/${companyId}/query`; responseData = await handleListing.call(this, i, endpoint, resource); - } else if (operation === 'update') { - // ---------------------------------- // customer: update // ---------------------------------- @@ -389,7 +400,11 @@ export class QuickBooks implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; if (isEmpty(updateFields)) { - throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Please enter at least one field to update for the ${resource}.`, + { itemIndex: i }, + ); } body = populateFields.call(this, body, updateFields, resource); @@ -397,17 +412,13 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, {}, body); responseData = responseData[capitalCase(resource)]; - } - } else if (resource === 'employee') { - // ********************************************************************* // employee // ********************************************************************* if (operation === 'create') { - // ---------------------------------- // employee: create // ---------------------------------- @@ -424,9 +435,7 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, {}, body); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'get') { - // ---------------------------------- // employee: get // ---------------------------------- @@ -435,18 +444,14 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}/${employeeId}`; responseData = await quickBooksApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'getAll') { - // ---------------------------------- // employee: getAll // ---------------------------------- const endpoint = `/v3/company/${companyId}/query`; responseData = await handleListing.call(this, i, endpoint, resource); - } else if (operation === 'update') { - // ---------------------------------- // employee: update // ---------------------------------- @@ -460,7 +465,11 @@ export class QuickBooks implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; if (isEmpty(updateFields)) { - throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Please enter at least one field to update for the ${resource}.`, + { itemIndex: i }, + ); } body = populateFields.call(this, body, updateFields, resource); @@ -468,11 +477,8 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, {}, body); responseData = responseData[capitalCase(resource)]; - } - } else if (resource === 'estimate') { - // ********************************************************************* // estimate // ********************************************************************* @@ -480,7 +486,6 @@ export class QuickBooks implements INodeType { // https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/estimate if (operation === 'create') { - // ---------------------------------- // estimate: create // ---------------------------------- @@ -488,16 +493,35 @@ export class QuickBooks implements INodeType { const lines = this.getNodeParameter('Line', i) as IDataObject[]; if (!lines.length) { - throw new NodeOperationError(this.getNode(), `Please enter at least one line for the ${resource}.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Please enter at least one line for the ${resource}.`, + { itemIndex: i }, + ); } - if (lines.some(line => line.DetailType === undefined || line.Amount === undefined || line.Description === undefined)) { - throw new NodeOperationError(this.getNode(), 'Please enter detail type, amount and description for every line.', { itemIndex: i }); + if ( + lines.some( + (line) => + line.DetailType === undefined || + line.Amount === undefined || + line.Description === undefined, + ) + ) { + throw new NodeOperationError( + this.getNode(), + 'Please enter detail type, amount and description for every line.', + { itemIndex: i }, + ); } - lines.forEach(line => { + lines.forEach((line) => { if (line.DetailType === 'SalesItemLineDetail' && line.itemId === undefined) { - throw new NodeOperationError(this.getNode(), 'Please enter an item ID for the associated line.', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Please enter an item ID for the associated line.', + { itemIndex: i }, + ); } }); @@ -515,9 +539,7 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, {}, body); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'delete') { - // ---------------------------------- // estimate: delete // ---------------------------------- @@ -534,9 +556,7 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, qs, body); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'get') { - // ---------------------------------- // estimate: get // ---------------------------------- @@ -545,28 +565,27 @@ export class QuickBooks implements INodeType { const download = this.getNodeParameter('download', i) as boolean; if (download) { - - responseData = await handleBinaryData.call(this, items, i, companyId, resource, estimateId); - + responseData = await handleBinaryData.call( + this, + items, + i, + companyId, + resource, + estimateId, + ); } else { - const endpoint = `/v3/company/${companyId}/${resource}/${estimateId}`; responseData = await quickBooksApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData[capitalCase(resource)]; - } - } else if (operation === 'getAll') { - // ---------------------------------- // estimate: getAll // ---------------------------------- const endpoint = `/v3/company/${companyId}/query`; responseData = await handleListing.call(this, i, endpoint, resource); - } else if (operation === 'send') { - // ---------------------------------- // estimate: send // ---------------------------------- @@ -580,14 +599,18 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}/${estimateId}/send`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, qs, {}); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'update') { - // ---------------------------------- // estimate: update // ---------------------------------- - const { ref, syncToken } = await getRefAndSyncToken.call(this, i, companyId, resource, 'CustomerRef'); + const { ref, syncToken } = await getRefAndSyncToken.call( + this, + i, + companyId, + resource, + 'CustomerRef', + ); let body = { Id: this.getNodeParameter('estimateId', i), @@ -602,7 +625,11 @@ export class QuickBooks implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; if (isEmpty(updateFields)) { - throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Please enter at least one field to update for the ${resource}.`, + { itemIndex: i }, + ); } body = populateFields.call(this, body, updateFields, resource); @@ -610,11 +637,8 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, {}, body); responseData = responseData[capitalCase(resource)]; - } - } else if (resource === 'invoice') { - // ********************************************************************* // invoice // ********************************************************************* @@ -622,7 +646,6 @@ export class QuickBooks implements INodeType { // https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/invoice if (operation === 'create') { - // ---------------------------------- // invoice: create // ---------------------------------- @@ -630,16 +653,35 @@ export class QuickBooks implements INodeType { const lines = this.getNodeParameter('Line', i) as IDataObject[]; if (!lines.length) { - throw new NodeOperationError(this.getNode(), `Please enter at least one line for the ${resource}.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Please enter at least one line for the ${resource}.`, + { itemIndex: i }, + ); } - if (lines.some(line => line.DetailType === undefined || line.Amount === undefined || line.Description === undefined)) { - throw new NodeOperationError(this.getNode(), 'Please enter detail type, amount and description for every line.', { itemIndex: i }); + if ( + lines.some( + (line) => + line.DetailType === undefined || + line.Amount === undefined || + line.Description === undefined, + ) + ) { + throw new NodeOperationError( + this.getNode(), + 'Please enter detail type, amount and description for every line.', + { itemIndex: i }, + ); } - lines.forEach(line => { + lines.forEach((line) => { if (line.DetailType === 'SalesItemLineDetail' && line.itemId === undefined) { - throw new NodeOperationError(this.getNode(), 'Please enter an item ID for the associated line.', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Please enter an item ID for the associated line.', + { itemIndex: i }, + ); } }); @@ -658,9 +700,7 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, {}, body); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'delete') { - // ---------------------------------- // invoice: delete // ---------------------------------- @@ -677,9 +717,7 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, qs, body); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'get') { - // ---------------------------------- // invoice: get // ---------------------------------- @@ -688,28 +726,27 @@ export class QuickBooks implements INodeType { const download = this.getNodeParameter('download', i) as boolean; if (download) { - - responseData = await handleBinaryData.call(this, items, i, companyId, resource, invoiceId); - + responseData = await handleBinaryData.call( + this, + items, + i, + companyId, + resource, + invoiceId, + ); } else { - const endpoint = `/v3/company/${companyId}/${resource}/${invoiceId}`; responseData = await quickBooksApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData[capitalCase(resource)]; - } - } else if (operation === 'getAll') { - // ---------------------------------- // invoice: getAll // ---------------------------------- const endpoint = `/v3/company/${companyId}/query`; responseData = await handleListing.call(this, i, endpoint, resource); - } else if (operation === 'send') { - // ---------------------------------- // invoice: send // ---------------------------------- @@ -723,14 +760,18 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}/${invoiceId}/send`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, qs, {}); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'update') { - // ---------------------------------- // invoice: update // ---------------------------------- - const { ref, syncToken } = await getRefAndSyncToken.call(this, i, companyId, resource, 'CustomerRef'); + const { ref, syncToken } = await getRefAndSyncToken.call( + this, + i, + companyId, + resource, + 'CustomerRef', + ); let body = { Id: this.getNodeParameter('invoiceId', i), @@ -745,7 +786,11 @@ export class QuickBooks implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; if (isEmpty(updateFields)) { - throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Please enter at least one field to update for the ${resource}.`, + { itemIndex: i }, + ); } body = populateFields.call(this, body, updateFields, resource); @@ -753,9 +798,7 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, {}, body); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'void') { - // ---------------------------------- // invoice: void // ---------------------------------- @@ -769,11 +812,8 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, qs, {}); responseData = responseData[capitalCase(resource)]; - } - } else if (resource === 'item') { - // ********************************************************************* // item // ********************************************************************* @@ -781,7 +821,6 @@ export class QuickBooks implements INodeType { // https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/item if (operation === 'get') { - // ---------------------------------- // item: get // ---------------------------------- @@ -790,20 +829,15 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}/${item}`; responseData = await quickBooksApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'getAll') { - // ---------------------------------- // item: getAll // ---------------------------------- const endpoint = `/v3/company/${companyId}/query`; responseData = await handleListing.call(this, i, endpoint, resource); - } - } else if (resource === 'payment') { - // ********************************************************************* // payment // ********************************************************************* @@ -811,7 +845,6 @@ export class QuickBooks implements INodeType { // https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/payment if (operation === 'create') { - // ---------------------------------- // payment: create // ---------------------------------- @@ -830,9 +863,7 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, {}, body); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'delete') { - // ---------------------------------- // payment: delete // ---------------------------------- @@ -849,9 +880,7 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, qs, body); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'get') { - // ---------------------------------- // payment: get // ---------------------------------- @@ -860,28 +889,27 @@ export class QuickBooks implements INodeType { const download = this.getNodeParameter('download', i) as boolean; if (download) { - - responseData = await handleBinaryData.call(this, items, i, companyId, resource, paymentId); - + responseData = await handleBinaryData.call( + this, + items, + i, + companyId, + resource, + paymentId, + ); } else { - const endpoint = `/v3/company/${companyId}/${resource}/${paymentId}`; responseData = await quickBooksApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData[capitalCase(resource)]; - } - } else if (operation === 'getAll') { - // ---------------------------------- // payment: getAll // ---------------------------------- const endpoint = `/v3/company/${companyId}/query`; responseData = await handleListing.call(this, i, endpoint, resource); - } else if (operation === 'send') { - // ---------------------------------- // payment: send // ---------------------------------- @@ -895,14 +923,18 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}/${paymentId}/send`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, qs, {}); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'update') { - // ---------------------------------- // payment: update // ---------------------------------- - const { ref, syncToken } = await getRefAndSyncToken.call(this, i, companyId, resource, 'CustomerRef'); + const { ref, syncToken } = await getRefAndSyncToken.call( + this, + i, + companyId, + resource, + 'CustomerRef', + ); let body = { Id: this.getNodeParameter('paymentId', i), @@ -917,7 +949,11 @@ export class QuickBooks implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; if (isEmpty(updateFields)) { - throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Please enter at least one field to update for the ${resource}.`, + { itemIndex: i }, + ); } body = populateFields.call(this, body, updateFields, resource); @@ -925,9 +961,7 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, {}, body); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'void') { - // ---------------------------------- // payment: void // ---------------------------------- @@ -941,11 +975,8 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, qs, {}); responseData = responseData[capitalCase(resource)]; - } - } else if (resource === 'purchase') { - // ********************************************************************* // purchase // ********************************************************************* @@ -953,7 +984,6 @@ export class QuickBooks implements INodeType { // https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/purchase if (operation === 'get') { - // ---------------------------------- // purchase: get // ---------------------------------- @@ -962,20 +992,15 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}/${purchaseId}`; responseData = await quickBooksApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'getAll') { - // ---------------------------------- // purchase: getAll // ---------------------------------- const endpoint = `/v3/company/${companyId}/query`; responseData = await handleListing.call(this, i, endpoint, resource); - } - } else if (resource === 'transaction') { - // ********************************************************************* // transaction // ********************************************************************* @@ -983,19 +1008,14 @@ export class QuickBooks implements INodeType { // https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/transactionlist if (operation === 'getReport') { - // ---------------------------------- // transaction: getReport // ---------------------------------- - const { - columns, - memo, - term, - customer, - vendor, - ...rest - } = this.getNodeParameter('filters', i) as TransactionFields; + const { columns, memo, term, customer, vendor, ...rest } = this.getNodeParameter( + 'filters', + i, + ) as TransactionFields; let qs = { ...rest }; @@ -1034,9 +1054,7 @@ export class QuickBooks implements INodeType { responseData = simplifyTransactionReport(responseData); } } - } else if (resource === 'vendor') { - // ********************************************************************* // vendor // ********************************************************************* @@ -1044,7 +1062,6 @@ export class QuickBooks implements INodeType { // https://developer.intuit.com/app/developer/qbo/docs/api/accounting/most-commonly-used/vendor if (operation === 'create') { - // ---------------------------------- // vendor: create // ---------------------------------- @@ -1060,9 +1077,7 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, {}, body); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'get') { - // ---------------------------------- // vendor: get // ---------------------------------- @@ -1071,18 +1086,14 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}/${vendorId}`; responseData = await quickBooksApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData[capitalCase(resource)]; - } else if (operation === 'getAll') { - // ---------------------------------- // vendor: getAll // ---------------------------------- const endpoint = `/v3/company/${companyId}/query`; responseData = await handleListing.call(this, i, endpoint, resource); - } else if (operation === 'update') { - // ---------------------------------- // vendor: update // ---------------------------------- @@ -1096,7 +1107,11 @@ export class QuickBooks implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; if (isEmpty(updateFields)) { - throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Please enter at least one field to update for the ${resource}.`, + { itemIndex: i }, + ); } body = populateFields.call(this, body, updateFields, resource); @@ -1104,22 +1119,24 @@ export class QuickBooks implements INodeType { const endpoint = `/v3/company/${companyId}/${resource}`; responseData = await quickBooksApiRequest.call(this, 'POST', endpoint, {}, body); responseData = responseData[capitalCase(resource)]; - } - } } catch (error) { if (this.continueOnFail()) { const download = this.getNodeParameter('download', 0, false) as boolean; - if (['invoice', 'estimate', 'payment'].includes(resource) && ['get'].includes(operation) && download) { + if ( + ['invoice', 'estimate', 'payment'].includes(resource) && + ['get'].includes(operation) && + download + ) { // in this case responseDate? === items - if (!responseData){ + if (!responseData) { items[i].json = { error: error.message }; responseData = items; - }else { + } else { responseData[i].json = { error: error.message }; } - }else { + } else { returnData.push({ error: error.message }); } continue; @@ -1134,11 +1151,14 @@ export class QuickBooks implements INodeType { const download = this.getNodeParameter('download', 0, false) as boolean; - if (['invoice', 'estimate', 'payment'].includes(resource) && ['get'].includes(operation) && download) { + if ( + ['invoice', 'estimate', 'payment'].includes(resource) && + ['get'].includes(operation) && + download + ) { return this.prepareOutputData(responseData); } else { return [this.helpers.returnJsonArray(returnData)]; } } } - diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Bill/BillAdditionalFieldsOptions.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Bill/BillAdditionalFieldsOptions.ts index 8cf433f8dd..f6ef99caf9 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Bill/BillAdditionalFieldsOptions.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Bill/BillAdditionalFieldsOptions.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const billAdditionalFieldsOptions: INodeProperties[] = [ { diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Bill/BillDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Bill/BillDescription.ts index 44d0712c7a..281b7b978e 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Bill/BillDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Bill/BillDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - billAdditionalFieldsOptions, -} from './BillAdditionalFieldsOptions'; +import { billAdditionalFieldsOptions } from './BillAdditionalFieldsOptions'; export const billOperations: INodeProperties[] = [ { @@ -42,9 +38,7 @@ export const billOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'bill', - ], + resource: ['bill'], }, }, }, @@ -59,19 +53,16 @@ export const billFields: INodeProperties[] = [ name: 'VendorRef', type: 'options', required: true, - description: 'The ID of the vendor who the bill is for. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the vendor who the bill is for. Choose from the list, or specify an ID using an expression.', default: [], typeOptions: { loadOptionsMethod: 'getVendors', }, displayOptions: { show: { - resource: [ - 'bill', - ], - operation: [ - 'create', - ], + resource: ['bill'], + operation: ['create'], }, }, }, @@ -87,12 +78,8 @@ export const billFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'bill', - ], - operation: [ - 'create', - ], + resource: ['bill'], + operation: ['create'], }, }, options: [ @@ -139,7 +126,8 @@ export const billFields: INodeProperties[] = [ displayName: 'Item Name or ID', name: 'itemId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: [], typeOptions: { loadOptionsMethod: 'getItems', @@ -162,12 +150,8 @@ export const billFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'bill', - ], - operation: [ - 'create', - ], + resource: ['bill'], + operation: ['create'], }, }, options: billAdditionalFieldsOptions, @@ -185,12 +169,8 @@ export const billFields: INodeProperties[] = [ description: 'The ID of the bill to delete', displayOptions: { show: { - resource: [ - 'bill', - ], - operation: [ - 'delete', - ], + resource: ['bill'], + operation: ['delete'], }, }, }, @@ -207,12 +187,8 @@ export const billFields: INodeProperties[] = [ description: 'The ID of the bill to retrieve', displayOptions: { show: { - resource: [ - 'bill', - ], - operation: [ - 'get', - ], + resource: ['bill'], + operation: ['get'], }, }, }, @@ -228,12 +204,8 @@ export const billFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'bill', - ], - operation: [ - 'getAll', - ], + resource: ['bill'], + operation: ['getAll'], }, }, }, @@ -249,15 +221,9 @@ export const billFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'bill', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['bill'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -273,8 +239,9 @@ export const billFields: INodeProperties[] = [ name: 'query', type: 'string', default: '', - placeholder: 'WHERE Metadata.LastUpdatedTime > \'2021-01-01\'', - description: 'The condition for selecting bills. See the guide for supported syntax.', + placeholder: "WHERE Metadata.LastUpdatedTime > '2021-01-01'", + description: + 'The condition for selecting bills. See the guide for supported syntax.', typeOptions: { alwaysOpenEditWindow: true, }, @@ -282,12 +249,8 @@ export const billFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'bill', - ], - operation: [ - 'getAll', - ], + resource: ['bill'], + operation: ['getAll'], }, }, }, @@ -304,12 +267,8 @@ export const billFields: INodeProperties[] = [ description: 'The ID of the bill to update', displayOptions: { show: { - resource: [ - 'bill', - ], - operation: [ - 'update', - ], + resource: ['bill'], + operation: ['update'], }, }, }, @@ -322,15 +281,13 @@ export const billFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'bill', - ], - operation: [ - 'update', - ], + resource: ['bill'], + operation: ['update'], }, }, // filter out fields that cannot be updated - options: billAdditionalFieldsOptions.filter(property => property.name !== 'TotalAmt' && property.name !== 'Balance'), + options: billAdditionalFieldsOptions.filter( + (property) => property.name !== 'TotalAmt' && property.name !== 'Balance', + ), }, ]; diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Customer/CustomerAdditionalFieldsOptions.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Customer/CustomerAdditionalFieldsOptions.ts index 56f72ea1d6..9a0b19e48f 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Customer/CustomerAdditionalFieldsOptions.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Customer/CustomerAdditionalFieldsOptions.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const customerAdditionalFieldsOptions: INodeProperties[] = [ { diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Customer/CustomerDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Customer/CustomerDescription.ts index 84c6c8511f..08cb2d443e 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Customer/CustomerDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Customer/CustomerDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - customerAdditionalFieldsOptions, -} from './CustomerAdditionalFieldsOptions'; +import { customerAdditionalFieldsOptions } from './CustomerAdditionalFieldsOptions'; export const customerOperations: INodeProperties[] = [ { @@ -37,9 +33,7 @@ export const customerOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'customer', - ], + resource: ['customer'], }, }, }, @@ -58,12 +52,8 @@ export const customerFields: INodeProperties[] = [ description: 'The display name of the customer to create', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'create', - ], + resource: ['customer'], + operation: ['create'], }, }, }, @@ -75,12 +65,8 @@ export const customerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'create', - ], + resource: ['customer'], + operation: ['create'], }, }, options: customerAdditionalFieldsOptions, @@ -98,12 +84,8 @@ export const customerFields: INodeProperties[] = [ description: 'The ID of the customer to retrieve', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'get', - ], + resource: ['customer'], + operation: ['get'], }, }, }, @@ -119,12 +101,8 @@ export const customerFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'getAll', - ], + resource: ['customer'], + operation: ['getAll'], }, }, }, @@ -140,15 +118,9 @@ export const customerFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['customer'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -164,8 +136,9 @@ export const customerFields: INodeProperties[] = [ name: 'query', type: 'string', default: '', - placeholder: 'WHERE Metadata.LastUpdatedTime > \'2021-01-01\'', - description: 'The condition for selecting customers. See the guide for supported syntax.', + placeholder: "WHERE Metadata.LastUpdatedTime > '2021-01-01'", + description: + 'The condition for selecting customers. See the guide for supported syntax.', typeOptions: { alwaysOpenEditWindow: true, }, @@ -173,12 +146,8 @@ export const customerFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'getAll', - ], + resource: ['customer'], + operation: ['getAll'], }, }, }, @@ -195,12 +164,8 @@ export const customerFields: INodeProperties[] = [ description: 'The ID of the customer to update', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'update', - ], + resource: ['customer'], + operation: ['update'], }, }, }, @@ -213,12 +178,8 @@ export const customerFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'update', - ], + resource: ['customer'], + operation: ['update'], }, }, options: customerAdditionalFieldsOptions, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Employee/EmployeeAdditionalFieldsOptions.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Employee/EmployeeAdditionalFieldsOptions.ts index 7dd49b4585..b2097c06c2 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Employee/EmployeeAdditionalFieldsOptions.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Employee/EmployeeAdditionalFieldsOptions.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const employeeAdditionalFieldsOptions: INodeProperties[] = [ { diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Employee/EmployeeDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Employee/EmployeeDescription.ts index 02d07aba43..4a26b3856b 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Employee/EmployeeDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Employee/EmployeeDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - employeeAdditionalFieldsOptions, -} from './EmployeeAdditionalFieldsOptions'; +import { employeeAdditionalFieldsOptions } from './EmployeeAdditionalFieldsOptions'; export const employeeOperations: INodeProperties[] = [ { @@ -37,9 +33,7 @@ export const employeeOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'employee', - ], + resource: ['employee'], }, }, }, @@ -56,12 +50,8 @@ export const employeeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'employee', - ], - operation: [ - 'create', - ], + resource: ['employee'], + operation: ['create'], }, }, }, @@ -72,12 +62,8 @@ export const employeeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'employee', - ], - operation: [ - 'create', - ], + resource: ['employee'], + operation: ['create'], }, }, }, @@ -89,12 +75,8 @@ export const employeeFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'employee', - ], - operation: [ - 'create', - ], + resource: ['employee'], + operation: ['create'], }, }, options: employeeAdditionalFieldsOptions, @@ -112,12 +94,8 @@ export const employeeFields: INodeProperties[] = [ description: 'The ID of the employee to retrieve', displayOptions: { show: { - resource: [ - 'employee', - ], - operation: [ - 'get', - ], + resource: ['employee'], + operation: ['get'], }, }, }, @@ -133,12 +111,8 @@ export const employeeFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'employee', - ], - operation: [ - 'getAll', - ], + resource: ['employee'], + operation: ['getAll'], }, }, }, @@ -154,15 +128,9 @@ export const employeeFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'employee', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['employee'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -178,8 +146,9 @@ export const employeeFields: INodeProperties[] = [ name: 'query', type: 'string', default: '', - placeholder: 'WHERE Metadata.LastUpdatedTime > \'2021-01-01\'', - description: 'The condition for selecting employees. See the guide for supported syntax.', + placeholder: "WHERE Metadata.LastUpdatedTime > '2021-01-01'", + description: + 'The condition for selecting employees. See the guide for supported syntax.', typeOptions: { alwaysOpenEditWindow: true, }, @@ -187,12 +156,8 @@ export const employeeFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'employee', - ], - operation: [ - 'getAll', - ], + resource: ['employee'], + operation: ['getAll'], }, }, }, @@ -209,12 +174,8 @@ export const employeeFields: INodeProperties[] = [ description: 'The ID of the employee to update', displayOptions: { show: { - resource: [ - 'employee', - ], - operation: [ - 'update', - ], + resource: ['employee'], + operation: ['update'], }, }, }, @@ -227,12 +188,8 @@ export const employeeFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'employee', - ], - operation: [ - 'update', - ], + resource: ['employee'], + operation: ['update'], }, }, options: employeeAdditionalFieldsOptions, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Estimate/EstimateAdditionalFieldsOptions.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Estimate/EstimateAdditionalFieldsOptions.ts index 8788b03936..c22faaeafc 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Estimate/EstimateAdditionalFieldsOptions.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Estimate/EstimateAdditionalFieldsOptions.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const estimateAdditionalFieldsOptions: INodeProperties[] = [ { @@ -89,7 +87,8 @@ export const estimateAdditionalFieldsOptions: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'ID of the field to set. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Field Value', @@ -105,7 +104,8 @@ export const estimateAdditionalFieldsOptions: INodeProperties[] = [ { displayName: 'Customer Memo', name: 'CustomerMemo', - description: 'User-entered message to the customer. This message is visible to end user on their transactions.', + description: + 'User-entered message to the customer. This message is visible to end user on their transactions.', type: 'string', default: '', }, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Estimate/EstimateDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Estimate/EstimateDescription.ts index 1646679399..5c372dece8 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Estimate/EstimateDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Estimate/EstimateDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - estimateAdditionalFieldsOptions, -} from './EstimateAdditionalFieldsOptions'; +import { estimateAdditionalFieldsOptions } from './EstimateAdditionalFieldsOptions'; export const estimateOperations: INodeProperties[] = [ { @@ -47,9 +43,7 @@ export const estimateOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'estimate', - ], + resource: ['estimate'], }, }, }, @@ -64,19 +58,16 @@ export const estimateFields: INodeProperties[] = [ name: 'CustomerRef', type: 'options', required: true, - description: 'The ID of the customer who the estimate is for. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the customer who the estimate is for. Choose from the list, or specify an ID using an expression.', default: [], typeOptions: { loadOptionsMethod: 'getCustomers', }, displayOptions: { show: { - resource: [ - 'estimate', - ], - operation: [ - 'create', - ], + resource: ['estimate'], + operation: ['create'], }, }, }, @@ -92,12 +83,8 @@ export const estimateFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'estimate', - ], - operation: [ - 'create', - ], + resource: ['estimate'], + operation: ['create'], }, }, options: [ @@ -134,7 +121,8 @@ export const estimateFields: INodeProperties[] = [ displayName: 'Item Name or ID', name: 'itemId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: [], typeOptions: { loadOptionsMethod: 'getItems', @@ -151,7 +139,8 @@ export const estimateFields: INodeProperties[] = [ displayName: 'Tax Code Ref Name or ID', name: 'TaxCodeRef', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: [], typeOptions: { loadOptionsMethod: 'getTaxCodeRefs', @@ -167,12 +156,8 @@ export const estimateFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'estimate', - ], - operation: [ - 'create', - ], + resource: ['estimate'], + operation: ['create'], }, }, options: estimateAdditionalFieldsOptions, @@ -190,12 +175,8 @@ export const estimateFields: INodeProperties[] = [ description: 'The ID of the estimate to delete', displayOptions: { show: { - resource: [ - 'estimate', - ], - operation: [ - 'delete', - ], + resource: ['estimate'], + operation: ['delete'], }, }, }, @@ -212,12 +193,8 @@ export const estimateFields: INodeProperties[] = [ description: 'The ID of the estimate to retrieve', displayOptions: { show: { - resource: [ - 'estimate', - ], - operation: [ - 'get', - ], + resource: ['estimate'], + operation: ['get'], }, }, }, @@ -230,12 +207,8 @@ export const estimateFields: INodeProperties[] = [ description: 'Whether to download the estimate as a PDF file', displayOptions: { show: { - resource: [ - 'estimate', - ], - operation: [ - 'get', - ], + resource: ['estimate'], + operation: ['get'], }, }, }, @@ -248,15 +221,9 @@ export const estimateFields: INodeProperties[] = [ description: 'Name of the binary property to which to write to', displayOptions: { show: { - resource: [ - 'estimate', - ], - operation: [ - 'get', - ], - download: [ - true, - ], + resource: ['estimate'], + operation: ['get'], + download: [true], }, }, }, @@ -270,15 +237,9 @@ export const estimateFields: INodeProperties[] = [ description: 'Name of the file that will be downloaded', displayOptions: { show: { - resource: [ - 'estimate', - ], - operation: [ - 'get', - ], - download: [ - true, - ], + resource: ['estimate'], + operation: ['get'], + download: [true], }, }, }, @@ -294,12 +255,8 @@ export const estimateFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'estimate', - ], - operation: [ - 'getAll', - ], + resource: ['estimate'], + operation: ['getAll'], }, }, }, @@ -315,15 +272,9 @@ export const estimateFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'estimate', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['estimate'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -339,8 +290,9 @@ export const estimateFields: INodeProperties[] = [ name: 'query', type: 'string', default: '', - placeholder: 'WHERE Metadata.LastUpdatedTime > \'2021-01-01\'', - description: 'The condition for selecting estimates. See the guide for supported syntax.', + placeholder: "WHERE Metadata.LastUpdatedTime > '2021-01-01'", + description: + 'The condition for selecting estimates. See the guide for supported syntax.', typeOptions: { alwaysOpenEditWindow: true, }, @@ -348,12 +300,8 @@ export const estimateFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'estimate', - ], - operation: [ - 'getAll', - ], + resource: ['estimate'], + operation: ['getAll'], }, }, }, @@ -370,12 +318,8 @@ export const estimateFields: INodeProperties[] = [ description: 'The ID of the estimate to send', displayOptions: { show: { - resource: [ - 'estimate', - ], - operation: [ - 'send', - ], + resource: ['estimate'], + operation: ['send'], }, }, }, @@ -389,12 +333,8 @@ export const estimateFields: INodeProperties[] = [ description: 'The email of the recipient of the estimate', displayOptions: { show: { - resource: [ - 'estimate', - ], - operation: [ - 'send', - ], + resource: ['estimate'], + operation: ['send'], }, }, }, @@ -411,12 +351,8 @@ export const estimateFields: INodeProperties[] = [ description: 'The ID of the estimate to update', displayOptions: { show: { - resource: [ - 'estimate', - ], - operation: [ - 'update', - ], + resource: ['estimate'], + operation: ['update'], }, }, }, @@ -429,15 +365,13 @@ export const estimateFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'estimate', - ], - operation: [ - 'update', - ], + resource: ['estimate'], + operation: ['update'], }, }, // filter out fields that cannot be updated - options: estimateAdditionalFieldsOptions.filter(property => property.name !== 'TotalAmt' && property.name !== 'TotalTax'), + options: estimateAdditionalFieldsOptions.filter( + (property) => property.name !== 'TotalAmt' && property.name !== 'TotalTax', + ), }, ]; diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceAdditionalFieldsOptions.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceAdditionalFieldsOptions.ts index af3161e657..f7f0100556 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceAdditionalFieldsOptions.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceAdditionalFieldsOptions.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const invoiceAdditionalFieldsOptions: INodeProperties[] = [ { @@ -71,7 +69,8 @@ export const invoiceAdditionalFieldsOptions: INodeProperties[] = [ { displayName: 'Customer Memo', name: 'CustomerMemo', - description: 'User-entered message to the customer. This message is visible to end user on their transactions.', + description: + 'User-entered message to the customer. This message is visible to end user on their transactions.', type: 'string', default: '', }, @@ -97,7 +96,8 @@ export const invoiceAdditionalFieldsOptions: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'ID of the field to set. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Field Value', diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceDescription.ts index 17156bf5d5..533e065fa9 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Invoice/InvoiceDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - invoiceAdditionalFieldsOptions -} from './InvoiceAdditionalFieldsOptions'; +import { invoiceAdditionalFieldsOptions } from './InvoiceAdditionalFieldsOptions'; export const invoiceOperations: INodeProperties[] = [ { @@ -52,9 +48,7 @@ export const invoiceOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'invoice', - ], + resource: ['invoice'], }, }, }, @@ -69,19 +63,16 @@ export const invoiceFields: INodeProperties[] = [ name: 'CustomerRef', type: 'options', required: true, - description: 'The ID of the customer who the invoice is for. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the customer who the invoice is for. Choose from the list, or specify an ID using an expression.', default: [], typeOptions: { loadOptionsMethod: 'getCustomers', }, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'create', - ], + resource: ['invoice'], + operation: ['create'], }, }, }, @@ -97,12 +88,8 @@ export const invoiceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'create', - ], + resource: ['invoice'], + operation: ['create'], }, }, options: [ @@ -139,7 +126,8 @@ export const invoiceFields: INodeProperties[] = [ displayName: 'Item Name or ID', name: 'itemId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: [], typeOptions: { loadOptionsMethod: 'getItems', @@ -156,7 +144,8 @@ export const invoiceFields: INodeProperties[] = [ displayName: 'Tax Code Ref Name or ID', name: 'TaxCodeRef', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: [], typeOptions: { loadOptionsMethod: 'getTaxCodeRefs', @@ -172,12 +161,8 @@ export const invoiceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'create', - ], + resource: ['invoice'], + operation: ['create'], }, }, options: invoiceAdditionalFieldsOptions, @@ -195,12 +180,8 @@ export const invoiceFields: INodeProperties[] = [ description: 'The ID of the invoice to delete', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'delete', - ], + resource: ['invoice'], + operation: ['delete'], }, }, }, @@ -217,12 +198,8 @@ export const invoiceFields: INodeProperties[] = [ description: 'The ID of the invoice to retrieve', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'get', - ], + resource: ['invoice'], + operation: ['get'], }, }, }, @@ -235,12 +212,8 @@ export const invoiceFields: INodeProperties[] = [ description: 'Whether to download the invoice as a PDF file', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'get', - ], + resource: ['invoice'], + operation: ['get'], }, }, }, @@ -253,15 +226,9 @@ export const invoiceFields: INodeProperties[] = [ description: 'Name of the binary property to which to write to', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'get', - ], - download: [ - true, - ], + resource: ['invoice'], + operation: ['get'], + download: [true], }, }, }, @@ -275,15 +242,9 @@ export const invoiceFields: INodeProperties[] = [ description: 'Name of the file that will be downloaded', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'get', - ], - download: [ - true, - ], + resource: ['invoice'], + operation: ['get'], + download: [true], }, }, }, @@ -299,12 +260,8 @@ export const invoiceFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'getAll', - ], + resource: ['invoice'], + operation: ['getAll'], }, }, }, @@ -320,15 +277,9 @@ export const invoiceFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['invoice'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -344,8 +295,9 @@ export const invoiceFields: INodeProperties[] = [ name: 'query', type: 'string', default: '', - placeholder: 'WHERE Metadata.LastUpdatedTime > \'2021-01-01\'', - description: 'The condition for selecting invoices. See the guide for supported syntax.', + placeholder: "WHERE Metadata.LastUpdatedTime > '2021-01-01'", + description: + 'The condition for selecting invoices. See the guide for supported syntax.', typeOptions: { alwaysOpenEditWindow: true, }, @@ -353,12 +305,8 @@ export const invoiceFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'getAll', - ], + resource: ['invoice'], + operation: ['getAll'], }, }, }, @@ -375,12 +323,8 @@ export const invoiceFields: INodeProperties[] = [ description: 'The ID of the invoice to send', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'send', - ], + resource: ['invoice'], + operation: ['send'], }, }, }, @@ -394,12 +338,8 @@ export const invoiceFields: INodeProperties[] = [ description: 'The email of the recipient of the invoice', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'send', - ], + resource: ['invoice'], + operation: ['send'], }, }, }, @@ -416,12 +356,8 @@ export const invoiceFields: INodeProperties[] = [ description: 'The ID of the invoice to void', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'void', - ], + resource: ['invoice'], + operation: ['void'], }, }, }, @@ -438,12 +374,8 @@ export const invoiceFields: INodeProperties[] = [ description: 'The ID of the invoice to update', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'update', - ], + resource: ['invoice'], + operation: ['update'], }, }, }, @@ -456,15 +388,13 @@ export const invoiceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'update', - ], + resource: ['invoice'], + operation: ['update'], }, }, // filter out fields that cannot be updated - options: invoiceAdditionalFieldsOptions.filter(property => property.name !== 'TotalAmt' && property.name !== 'Balance'), + options: invoiceAdditionalFieldsOptions.filter( + (property) => property.name !== 'TotalAmt' && property.name !== 'Balance', + ), }, ]; diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Item/ItemDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Item/ItemDescription.ts index 004ff4562d..4cd6c671ee 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Item/ItemDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Item/ItemDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const itemOperations: INodeProperties[] = [ { @@ -23,9 +21,7 @@ export const itemOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'item', - ], + resource: ['item'], }, }, }, @@ -44,12 +40,8 @@ export const itemFields: INodeProperties[] = [ description: 'The ID of the item to retrieve', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'get', - ], + resource: ['item'], + operation: ['get'], }, }, }, @@ -65,12 +57,8 @@ export const itemFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'getAll', - ], + resource: ['item'], + operation: ['getAll'], }, }, }, @@ -86,15 +74,9 @@ export const itemFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['item'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -110,8 +92,9 @@ export const itemFields: INodeProperties[] = [ name: 'query', type: 'string', default: '', - placeholder: 'WHERE Metadata.LastUpdatedTime > \'2021-01-01\'', - description: 'The condition for selecting items. See the guide for supported syntax.', + placeholder: "WHERE Metadata.LastUpdatedTime > '2021-01-01'", + description: + 'The condition for selecting items. See the guide for supported syntax.', typeOptions: { alwaysOpenEditWindow: true, }, @@ -119,12 +102,8 @@ export const itemFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'getAll', - ], + resource: ['item'], + operation: ['getAll'], }, }, }, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Payment/PaymentAdditionalFieldsOptions.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Payment/PaymentAdditionalFieldsOptions.ts index c4bf17bf2c..930e1ed605 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Payment/PaymentAdditionalFieldsOptions.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Payment/PaymentAdditionalFieldsOptions.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const paymentAdditionalFieldsOptions: INodeProperties[] = [ { diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Payment/PaymentDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Payment/PaymentDescription.ts index f4e608df2a..0e025cbf04 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Payment/PaymentDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Payment/PaymentDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - paymentAdditionalFieldsOptions -} from './PaymentAdditionalFieldsOptions'; +import { paymentAdditionalFieldsOptions } from './PaymentAdditionalFieldsOptions'; export const paymentOperations: INodeProperties[] = [ { @@ -52,9 +48,7 @@ export const paymentOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'payment', - ], + resource: ['payment'], }, }, }, @@ -69,19 +63,16 @@ export const paymentFields: INodeProperties[] = [ name: 'CustomerRef', type: 'options', required: true, - description: 'The ID of the customer who the payment is for. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the customer who the payment is for. Choose from the list, or specify an ID using an expression.', default: [], typeOptions: { loadOptionsMethod: 'getCustomers', }, displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'create', - ], + resource: ['payment'], + operation: ['create'], }, }, }, @@ -93,12 +84,8 @@ export const paymentFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'create', - ], + resource: ['payment'], + operation: ['create'], }, }, }, @@ -110,12 +97,8 @@ export const paymentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'create', - ], + resource: ['payment'], + operation: ['create'], }, }, options: paymentAdditionalFieldsOptions, @@ -133,12 +116,8 @@ export const paymentFields: INodeProperties[] = [ description: 'The ID of the payment to delete', displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'delete', - ], + resource: ['payment'], + operation: ['delete'], }, }, }, @@ -155,12 +134,8 @@ export const paymentFields: INodeProperties[] = [ description: 'The ID of the payment to retrieve', displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'get', - ], + resource: ['payment'], + operation: ['get'], }, }, }, @@ -173,12 +148,8 @@ export const paymentFields: INodeProperties[] = [ description: 'Whether to download estimate as PDF file', displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'get', - ], + resource: ['payment'], + operation: ['get'], }, }, }, @@ -191,15 +162,9 @@ export const paymentFields: INodeProperties[] = [ description: 'Name of the binary property to which to write to', displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'get', - ], - download: [ - true, - ], + resource: ['payment'], + operation: ['get'], + download: [true], }, }, }, @@ -213,15 +178,9 @@ export const paymentFields: INodeProperties[] = [ description: 'Name of the file that will be downloaded', displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'get', - ], - download: [ - true, - ], + resource: ['payment'], + operation: ['get'], + download: [true], }, }, }, @@ -237,12 +196,8 @@ export const paymentFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'getAll', - ], + resource: ['payment'], + operation: ['getAll'], }, }, }, @@ -258,15 +213,9 @@ export const paymentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['payment'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -282,8 +231,9 @@ export const paymentFields: INodeProperties[] = [ name: 'query', type: 'string', default: '', - placeholder: 'WHERE Metadata.LastUpdatedTime > \'2021-01-01\'', - description: 'The condition for selecting payments. See the guide for supported syntax.', + placeholder: "WHERE Metadata.LastUpdatedTime > '2021-01-01'", + description: + 'The condition for selecting payments. See the guide for supported syntax.', typeOptions: { alwaysOpenEditWindow: true, }, @@ -291,12 +241,8 @@ export const paymentFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'getAll', - ], + resource: ['payment'], + operation: ['getAll'], }, }, }, @@ -313,12 +259,8 @@ export const paymentFields: INodeProperties[] = [ description: 'The ID of the payment to send', displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'send', - ], + resource: ['payment'], + operation: ['send'], }, }, }, @@ -332,12 +274,8 @@ export const paymentFields: INodeProperties[] = [ description: 'The email of the recipient of the payment', displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'send', - ], + resource: ['payment'], + operation: ['send'], }, }, }, @@ -354,12 +292,8 @@ export const paymentFields: INodeProperties[] = [ description: 'The ID of the payment to void', displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'void', - ], + resource: ['payment'], + operation: ['void'], }, }, }, @@ -376,12 +310,8 @@ export const paymentFields: INodeProperties[] = [ description: 'The ID of the payment to update', displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'update', - ], + resource: ['payment'], + operation: ['update'], }, }, }, @@ -394,12 +324,8 @@ export const paymentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'payment', - ], - operation: [ - 'update', - ], + resource: ['payment'], + operation: ['update'], }, }, options: paymentAdditionalFieldsOptions, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Purchase/PurchaseDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Purchase/PurchaseDescription.ts index 284c30c5c0..0b0d3797a0 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Purchase/PurchaseDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Purchase/PurchaseDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const purchaseOperations: INodeProperties[] = [ { @@ -23,9 +21,7 @@ export const purchaseOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'purchase', - ], + resource: ['purchase'], }, }, }, @@ -44,12 +40,8 @@ export const purchaseFields: INodeProperties[] = [ description: 'The ID of the purchase to retrieve', displayOptions: { show: { - resource: [ - 'purchase', - ], - operation: [ - 'get', - ], + resource: ['purchase'], + operation: ['get'], }, }, }, @@ -65,12 +57,8 @@ export const purchaseFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'purchase', - ], - operation: [ - 'getAll', - ], + resource: ['purchase'], + operation: ['getAll'], }, }, }, @@ -86,15 +74,9 @@ export const purchaseFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'purchase', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['purchase'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -110,8 +92,9 @@ export const purchaseFields: INodeProperties[] = [ name: 'query', type: 'string', default: '', - placeholder: 'WHERE Metadata.LastUpdatedTime > \'2021-01-01\'', - description: 'The condition for selecting purchases. See the guide for supported syntax.', + placeholder: "WHERE Metadata.LastUpdatedTime > '2021-01-01'", + description: + 'The condition for selecting purchases. See the guide for supported syntax.', typeOptions: { alwaysOpenEditWindow: true, }, @@ -119,12 +102,8 @@ export const purchaseFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'purchase', - ], - operation: [ - 'getAll', - ], + resource: ['purchase'], + operation: ['getAll'], }, }, }, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Transaction/TransactionDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Transaction/TransactionDescription.ts index 474cfac5bf..afde03ab71 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Transaction/TransactionDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Transaction/TransactionDescription.ts @@ -1,11 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - toDisplayName, - toOptions, -} from '../../GenericFunctions'; +import { toDisplayName, toOptions } from '../../GenericFunctions'; import { GROUP_BY_OPTIONS, @@ -32,9 +27,7 @@ export const transactionOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'transaction', - ], + resource: ['transaction'], }, }, }, @@ -50,12 +43,8 @@ export const transactionFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'transaction', - ], - operation: [ - 'getReport', - ], + resource: ['transaction'], + operation: ['getReport'], }, }, default: true, @@ -69,12 +58,8 @@ export const transactionFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'transaction', - ], - operation: [ - 'getReport', - ], + resource: ['transaction'], + operation: ['getReport'], }, }, options: [ @@ -112,7 +97,8 @@ export const transactionFields: INodeProperties[] = [ name: 'customer', type: 'multiOptions', default: [], - description: 'Customer to filter results by. Choose from the list, or specify IDs using an expression.', + description: + 'Customer to filter results by. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getCustomers', }, @@ -244,7 +230,8 @@ export const transactionFields: INodeProperties[] = [ name: 'start_moddate', type: 'dateTime', default: '', - description: 'Start date of the account modification date range to filter results by', + description: + 'Start date of the account modification date range to filter results by', }, { displayName: 'End Modification Date', @@ -270,7 +257,8 @@ export const transactionFields: INodeProperties[] = [ name: 'department', type: 'multiOptions', default: [], - description: 'Department to filter results by. Choose from the list, or specify IDs using an expression.', + description: + 'Department to filter results by. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -295,7 +283,8 @@ export const transactionFields: INodeProperties[] = [ name: 'memo', type: 'multiOptions', default: [], - description: 'Memo to filter results by. Choose from the list, or specify IDs using an expression.', + description: + 'Memo to filter results by. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getMemos', }, @@ -360,7 +349,8 @@ export const transactionFields: INodeProperties[] = [ name: 'term', type: 'multiOptions', default: [], - description: 'Term to filter results by. Choose from the list, or specify IDs using an expression.', + description: + 'Term to filter results by. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getTerms', }, @@ -388,7 +378,8 @@ export const transactionFields: INodeProperties[] = [ name: 'vendor', type: 'multiOptions', default: [], - description: 'Vendor to filter results by. Choose from the list, or specify IDs using an expression.', + description: + 'Vendor to filter results by. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getVendors', }, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Vendor/VendorAdditionalFieldsOptions.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Vendor/VendorAdditionalFieldsOptions.ts index ce9e30ed54..9fab028e34 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Vendor/VendorAdditionalFieldsOptions.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Vendor/VendorAdditionalFieldsOptions.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const vendorAdditionalFieldsOptions: INodeProperties[] = [ { @@ -114,7 +112,8 @@ export const vendorAdditionalFieldsOptions: INodeProperties[] = [ { displayName: 'Vendor 1099', name: 'Vendor1099', - description: 'Whether the vendor is an independent contractor, given a 1099-MISC form at the end of the year', + description: + 'Whether the vendor is an independent contractor, given a 1099-MISC form at the end of the year', type: 'boolean', default: false, }, diff --git a/packages/nodes-base/nodes/QuickBooks/descriptions/Vendor/VendorDescription.ts b/packages/nodes-base/nodes/QuickBooks/descriptions/Vendor/VendorDescription.ts index 26e40af7fc..1fcfd4aba5 100644 --- a/packages/nodes-base/nodes/QuickBooks/descriptions/Vendor/VendorDescription.ts +++ b/packages/nodes-base/nodes/QuickBooks/descriptions/Vendor/VendorDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - vendorAdditionalFieldsOptions, -} from './VendorAdditionalFieldsOptions'; +import { vendorAdditionalFieldsOptions } from './VendorAdditionalFieldsOptions'; export const vendorOperations: INodeProperties[] = [ { @@ -37,9 +33,7 @@ export const vendorOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'vendor', - ], + resource: ['vendor'], }, }, }, @@ -58,12 +52,8 @@ export const vendorFields: INodeProperties[] = [ description: 'The display name of the vendor to create', displayOptions: { show: { - resource: [ - 'vendor', - ], - operation: [ - 'create', - ], + resource: ['vendor'], + operation: ['create'], }, }, }, @@ -75,12 +65,8 @@ export const vendorFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'vendor', - ], - operation: [ - 'create', - ], + resource: ['vendor'], + operation: ['create'], }, }, options: vendorAdditionalFieldsOptions, @@ -98,12 +84,8 @@ export const vendorFields: INodeProperties[] = [ description: 'The ID of the vendor to retrieve', displayOptions: { show: { - resource: [ - 'vendor', - ], - operation: [ - 'get', - ], + resource: ['vendor'], + operation: ['get'], }, }, }, @@ -119,12 +101,8 @@ export const vendorFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'vendor', - ], - operation: [ - 'getAll', - ], + resource: ['vendor'], + operation: ['getAll'], }, }, }, @@ -140,15 +118,9 @@ export const vendorFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'vendor', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['vendor'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -164,8 +136,9 @@ export const vendorFields: INodeProperties[] = [ name: 'query', type: 'string', default: '', - placeholder: 'WHERE Metadata.LastUpdatedTime > \'2021-01-01\'', - description: 'The condition for selecting vendors. See the guide for supported syntax.', + placeholder: "WHERE Metadata.LastUpdatedTime > '2021-01-01'", + description: + 'The condition for selecting vendors. See the guide for supported syntax.', typeOptions: { alwaysOpenEditWindow: true, }, @@ -173,12 +146,8 @@ export const vendorFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'vendor', - ], - operation: [ - 'getAll', - ], + resource: ['vendor'], + operation: ['getAll'], }, }, }, @@ -195,12 +164,8 @@ export const vendorFields: INodeProperties[] = [ description: 'The ID of the vendor to update', displayOptions: { show: { - resource: [ - 'vendor', - ], - operation: [ - 'update', - ], + resource: ['vendor'], + operation: ['update'], }, }, }, @@ -213,12 +178,8 @@ export const vendorFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'vendor', - ], - operation: [ - 'update', - ], + resource: ['vendor'], + operation: ['update'], }, }, options: vendorAdditionalFieldsOptions, diff --git a/packages/nodes-base/nodes/QuickBooks/types.d.ts b/packages/nodes-base/nodes/QuickBooks/types.d.ts index 174aa5bd6c..8747abd8bd 100644 --- a/packages/nodes-base/nodes/QuickBooks/types.d.ts +++ b/packages/nodes-base/nodes/QuickBooks/types.d.ts @@ -1,11 +1,11 @@ -import { IDataObject } from "n8n-workflow"; +import { IDataObject } from 'n8n-workflow'; export type QuickBooksOAuth2Credentials = { environment: 'production' | 'sandbox'; oauthTokenData: { callbackQueryString: { realmId: string; - } + }; }; }; @@ -19,7 +19,7 @@ export type DateFieldsUi = Partial<{ type DateFieldUi = { [key: string]: { [key: string]: string; - } + }; }; export type TransactionFields = Partial<{ @@ -28,20 +28,22 @@ export type TransactionFields = Partial<{ term: string[]; customer: string[]; vendor: string[]; -}> & DateFieldsUi & IDataObject; +}> & + DateFieldsUi & + IDataObject; -export type Option = { name: string, value: string }; +export type Option = { name: string; value: string }; export type TransactionReport = { Columns: { Column: Array<{ ColTitle: string; ColType: string; - }> + }>; }; Rows: { Row: Array<{ ColData: Array<{ value: string }>; - }> + }>; }; }; diff --git a/packages/nodes-base/nodes/RabbitMQ/DefaultOptions.ts b/packages/nodes-base/nodes/RabbitMQ/DefaultOptions.ts index a5326ad03e..2aba7326df 100644 --- a/packages/nodes-base/nodes/RabbitMQ/DefaultOptions.ts +++ b/packages/nodes-base/nodes/RabbitMQ/DefaultOptions.ts @@ -1,10 +1,8 @@ -import { - INodeProperties, - INodePropertyCollection, - INodePropertyOptions, -} from 'n8n-workflow'; +import { INodeProperties, INodePropertyCollection, INodePropertyOptions } from 'n8n-workflow'; -export const rabbitDefaultOptions: Array = [ +export const rabbitDefaultOptions: Array< + INodePropertyOptions | INodeProperties | INodePropertyCollection +> = [ { displayName: 'Arguments', name: 'arguments', diff --git a/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts b/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts index d8d7dee952..c379718762 100644 --- a/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts +++ b/packages/nodes-base/nodes/RabbitMQ/GenericFunctions.ts @@ -1,8 +1,4 @@ -import { - IDataObject, - IExecuteFunctions, - ITriggerFunctions, -} from 'n8n-workflow'; +import { IDataObject, IExecuteFunctions, ITriggerFunctions } from 'n8n-workflow'; import * as amqplib from 'amqplib'; @@ -12,19 +8,16 @@ declare module 'amqplib' { } } -export async function rabbitmqConnect(this: IExecuteFunctions | ITriggerFunctions, options: IDataObject): Promise { +export async function rabbitmqConnect( + this: IExecuteFunctions | ITriggerFunctions, + options: IDataObject, +): Promise { const credentials = await this.getCredentials('rabbitmq'); - const credentialKeys = [ - 'hostname', - 'port', - 'username', - 'password', - 'vhost', - ]; + const credentialKeys = ['hostname', 'port', 'username', 'password', 'vhost']; const credentialData: IDataObject = {}; - credentialKeys.forEach(key => { + credentialKeys.forEach((key) => { credentialData[key] = credentials[key] === '' ? undefined : credentials[key]; }); @@ -41,7 +34,6 @@ export async function rabbitmqConnect(this: IExecuteFunctions | ITriggerFunction } } - return new Promise(async (resolve, reject) => { try { const connection = await amqplib.connect(credentialData, optsData); @@ -50,13 +42,18 @@ export async function rabbitmqConnect(this: IExecuteFunctions | ITriggerFunction reject(error); }); - const channel = await connection.createChannel().catch(console.warn) as amqplib.Channel; + const channel = (await connection.createChannel().catch(console.warn)) as amqplib.Channel; - if (options.arguments && ((options.arguments as IDataObject).argument! as IDataObject[]).length) { + if ( + options.arguments && + ((options.arguments as IDataObject).argument! as IDataObject[]).length + ) { const additionalArguments: IDataObject = {}; - ((options.arguments as IDataObject).argument as IDataObject[]).forEach((argument: IDataObject) => { - additionalArguments[argument.key as string] = argument.value; - }); + ((options.arguments as IDataObject).argument as IDataObject[]).forEach( + (argument: IDataObject) => { + additionalArguments[argument.key as string] = argument.value; + }, + ); options.arguments = additionalArguments; } @@ -67,7 +64,11 @@ export async function rabbitmqConnect(this: IExecuteFunctions | ITriggerFunction }); } -export async function rabbitmqConnectQueue(this: IExecuteFunctions | ITriggerFunctions, queue: string, options: IDataObject): Promise { +export async function rabbitmqConnectQueue( + this: IExecuteFunctions | ITriggerFunctions, + queue: string, + options: IDataObject, +): Promise { const channel = await rabbitmqConnect.call(this, options); return new Promise(async (resolve, reject) => { @@ -80,7 +81,12 @@ export async function rabbitmqConnectQueue(this: IExecuteFunctions | ITriggerFun }); } -export async function rabbitmqConnectExchange(this: IExecuteFunctions | ITriggerFunctions, exchange: string, type: string, options: IDataObject): Promise { +export async function rabbitmqConnectExchange( + this: IExecuteFunctions | ITriggerFunctions, + exchange: string, + type: string, + options: IDataObject, +): Promise { const channel = await rabbitmqConnect.call(this, options); return new Promise(async (resolve, reject) => { @@ -106,7 +112,7 @@ export class MessageTracker { return; } - const index = this.messages.findIndex(value => value !== message.fields.deliveryTag); + const index = this.messages.findIndex((value) => value !== message.fields.deliveryTag); this.messages.splice(index); } diff --git a/packages/nodes-base/nodes/RabbitMQ/RabbitMQ.node.ts b/packages/nodes-base/nodes/RabbitMQ/RabbitMQ.node.ts index e47d71995b..58c09c0e75 100644 --- a/packages/nodes-base/nodes/RabbitMQ/RabbitMQ.node.ts +++ b/packages/nodes-base/nodes/RabbitMQ/RabbitMQ.node.ts @@ -1,7 +1,5 @@ /* eslint-disable n8n-nodes-base/node-filename-against-convention */ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -13,10 +11,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - rabbitmqConnectExchange, - rabbitmqConnectQueue, -} from './GenericFunctions'; +import { rabbitmqConnectExchange, rabbitmqConnectQueue } from './GenericFunctions'; export class RabbitMQ implements INodeType { description: INodeTypeDescription = { @@ -68,9 +63,7 @@ export class RabbitMQ implements INodeType { type: 'string', displayOptions: { show: { - mode: [ - 'queue', - ], + mode: ['queue'], }, }, default: '', @@ -88,9 +81,7 @@ export class RabbitMQ implements INodeType { type: 'string', displayOptions: { show: { - mode: [ - 'exchange', - ], + mode: ['exchange'], }, }, default: '', @@ -103,9 +94,7 @@ export class RabbitMQ implements INodeType { type: 'options', displayOptions: { show: { - mode: [ - 'exchange', - ], + mode: ['exchange'], }, }, options: [ @@ -139,9 +128,7 @@ export class RabbitMQ implements INodeType { type: 'string', displayOptions: { show: { - mode: [ - 'exchange', - ], + mode: ['exchange'], }, }, default: '', @@ -166,9 +153,7 @@ export class RabbitMQ implements INodeType { type: 'string', displayOptions: { show: { - sendInputData: [ - false, - ], + sendInputData: [false], }, }, default: '', @@ -187,13 +172,12 @@ export class RabbitMQ implements INodeType { type: 'string', displayOptions: { show: { - '/mode': [ - 'exchange', - ], + '/mode': ['exchange'], }, }, default: '', - description: 'An exchange to send messages to if this exchange can’t route them to any queues', + description: + 'An exchange to send messages to if this exchange can’t route them to any queues', }, { displayName: 'Arguments', @@ -231,7 +215,8 @@ export class RabbitMQ implements INodeType { name: 'autoDelete', type: 'boolean', default: false, - description: 'Whether the queue will be deleted when the number of consumers drops to zero', + description: + 'Whether the queue will be deleted when the number of consumers drops to zero', }, { displayName: 'Durable', @@ -246,9 +231,7 @@ export class RabbitMQ implements INodeType { type: 'boolean', displayOptions: { show: { - '/mode': [ - 'queue', - ], + '/mode': ['queue'], }, }, default: false, @@ -318,12 +301,17 @@ export class RabbitMQ implements INodeType { } let headers: IDataObject = {}; - if (options.headers && ((options.headers as IDataObject).header! as IDataObject[]).length) { + if ( + options.headers && + ((options.headers as IDataObject).header! as IDataObject[]).length + ) { const itemOptions = this.getNodeParameter('options', i, {}) as IDataObject; const additionalHeaders: IDataObject = {}; - ((itemOptions.headers as IDataObject).header as IDataObject[]).forEach((header: IDataObject) => { - additionalHeaders[header.key as string] = header.value; - }); + ((itemOptions.headers as IDataObject).header as IDataObject[]).forEach( + (header: IDataObject) => { + additionalHeaders[header.key as string] = header.value; + }, + ); headers = additionalHeaders; } @@ -336,18 +324,15 @@ export class RabbitMQ implements INodeType { // @ts-ignore promisesResponses.forEach((response: JsonObject) => { if (response!.status !== 'fulfilled') { - if (this.continueOnFail() !== true) { throw new NodeApiError(this.getNode(), response); } else { // Return the actual reason as error - returnItems.push( - { - json: { - error: response.reason, - }, + returnItems.push({ + json: { + error: response.reason, }, - ); + }); return; } } @@ -361,8 +346,7 @@ export class RabbitMQ implements INodeType { await channel.close(); await channel.connection.close(); - } - else if (mode === 'exchange') { + } else if (mode === 'exchange') { const exchange = this.getNodeParameter('exchange', 0) as string; const type = this.getNodeParameter('exchangeType', 0) as string; const routingKey = this.getNodeParameter('routingKey', 0) as string; @@ -384,16 +368,23 @@ export class RabbitMQ implements INodeType { } let headers: IDataObject = {}; - if (options.headers && ((options.headers as IDataObject).header! as IDataObject[]).length) { + if ( + options.headers && + ((options.headers as IDataObject).header! as IDataObject[]).length + ) { const itemOptions = this.getNodeParameter('options', i, {}) as IDataObject; const additionalHeaders: IDataObject = {}; - ((itemOptions.headers as IDataObject).header as IDataObject[]).forEach((header: IDataObject) => { - additionalHeaders[header.key as string] = header.value; - }); + ((itemOptions.headers as IDataObject).header as IDataObject[]).forEach( + (header: IDataObject) => { + additionalHeaders[header.key as string] = header.value; + }, + ); headers = additionalHeaders; } - exchangePromises.push(channel.publish(exchange, routingKey, Buffer.from(message), { headers })); + exchangePromises.push( + channel.publish(exchange, routingKey, Buffer.from(message), { headers }), + ); } // @ts-ignore @@ -402,18 +393,15 @@ export class RabbitMQ implements INodeType { // @ts-ignore promisesResponses.forEach((response: JsonObject) => { if (response!.status !== 'fulfilled') { - if (this.continueOnFail() !== true) { throw new NodeApiError(this.getNode(), response); } else { // Return the actual reason as error - returnItems.push( - { - json: { - error: response.reason, - }, + returnItems.push({ + json: { + error: response.reason, }, - ); + }); return; } } @@ -432,8 +420,7 @@ export class RabbitMQ implements INodeType { } return this.prepareOutputData(returnItems); - } - catch (error) { + } catch (error) { if (channel) { await channel.close(); await channel.connection.close(); diff --git a/packages/nodes-base/nodes/RabbitMQ/RabbitMQTrigger.node.ts b/packages/nodes-base/nodes/RabbitMQ/RabbitMQTrigger.node.ts index 914abd89b6..aa6133c222 100644 --- a/packages/nodes-base/nodes/RabbitMQ/RabbitMQTrigger.node.ts +++ b/packages/nodes-base/nodes/RabbitMQ/RabbitMQTrigger.node.ts @@ -13,14 +13,9 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - rabbitDefaultOptions, -} from './DefaultOptions'; +import { rabbitDefaultOptions } from './DefaultOptions'; -import { - MessageTracker, - rabbitmqConnectQueue, -} from './GenericFunctions'; +import { MessageTracker, rabbitmqConnectQueue } from './GenericFunctions'; import * as amqplib from 'amqplib'; @@ -76,7 +71,8 @@ export class RabbitMQTrigger implements INodeType { { name: 'Execution Finishes', value: 'executionFinishes', - description: 'After the workflow execution finished. No matter if the execution was successful or not.', + description: + 'After the workflow execution finished. No matter if the execution was successful or not.', }, { name: 'Execution Finishes Successfully', @@ -98,9 +94,7 @@ export class RabbitMQTrigger implements INodeType { type: 'boolean', displayOptions: { hide: { - contentIsBinary: [ - true, - ], + contentIsBinary: [true], }, }, default: false, @@ -112,9 +106,7 @@ export class RabbitMQTrigger implements INodeType { type: 'boolean', displayOptions: { hide: { - contentIsBinary: [ - true, - ], + contentIsBinary: [true], }, }, default: false, @@ -128,24 +120,31 @@ export class RabbitMQTrigger implements INodeType { default: -1, displayOptions: { hide: { - acknowledge: [ - 'immediately', - ], + acknowledge: ['immediately'], }, }, description: 'Max number of executions at a time. Use -1 for no limit.', }, ...rabbitDefaultOptions, ].sort((a, b) => { - if ((a as INodeProperties).displayName.toLowerCase() < (b as INodeProperties).displayName.toLowerCase()) { return -1; } - if ((a as INodeProperties).displayName.toLowerCase() > (b as INodeProperties).displayName.toLowerCase()) { return 1; } + if ( + (a as INodeProperties).displayName.toLowerCase() < + (b as INodeProperties).displayName.toLowerCase() + ) { + return -1; + } + if ( + (a as INodeProperties).displayName.toLowerCase() > + (b as INodeProperties).displayName.toLowerCase() + ) { + return 1; + } return 0; }) as INodeProperties[], }, ], }; - async trigger(this: ITriggerFunctions): Promise { const queue = this.getNodeParameter('queue') as string; const options = this.getNodeParameter('options', {}) as IDataObject; @@ -154,10 +153,16 @@ export class RabbitMQTrigger implements INodeType { const self = this; - let parallelMessages = (options.parallelMessages !== undefined && options.parallelMessages !== -1) ? parseInt(options.parallelMessages as string, 10) : -1; + let parallelMessages = + options.parallelMessages !== undefined && options.parallelMessages !== -1 + ? parseInt(options.parallelMessages as string, 10) + : -1; if (parallelMessages === 0 || parallelMessages < -1) { - throw new NodeOperationError(this.getNode(), 'Parallel message processing limit must be greater than zero (or -1 for no limit)'); + throw new NodeOperationError( + this.getNode(), + 'Parallel message processing limit must be greater than zero (or -1 for no limit)', + ); } if (this.getMode() === 'manual') { @@ -184,7 +189,6 @@ export class RabbitMQTrigger implements INodeType { const consumerInfo = await channel.consume(queue, async (message) => { if (message !== null) { - try { if (acknowledgeMode !== 'immediately') { messageTracker.received(message); @@ -220,17 +224,11 @@ export class RabbitMQTrigger implements INodeType { responsePromise = await createDeferredPromise(); } - self.emit([ - [ - item, - ], - ], undefined, responsePromise); + self.emit([[item]], undefined, responsePromise); if (responsePromise) { // Acknowledge message after the execution finished - await responsePromise - .promise() - .then(async (data: IRun) => { + await responsePromise.promise().then(async (data: IRun) => { if (data.data.resultData.error) { // The execution did fail if (acknowledgeMode === 'executionFinishesSuccessfully') { @@ -247,7 +245,6 @@ export class RabbitMQTrigger implements INodeType { // Acknowledge message directly channel.ack(message); } - } catch (error) { const workflow = this.getWorkflow(); const node = this.getNode(); @@ -255,7 +252,8 @@ export class RabbitMQTrigger implements INodeType { messageTracker.answered(message); } - Logger.error(`There was a problem with the RabbitMQ Trigger node "${node.name}" in workflow "${workflow.id}": "${error.message}"`, + Logger.error( + `There was a problem with the RabbitMQ Trigger node "${node.name}" in workflow "${workflow.id}": "${error.message}"`, { node: node.name, workflowId: workflow.id, @@ -272,13 +270,13 @@ export class RabbitMQTrigger implements INodeType { // The "closeFunction" function gets called by n8n whenever // the workflow gets deactivated and can so clean up. async function closeFunction() { - try { return messageTracker.closeChannel(channel, consumerTag); - } catch(error) { + } catch (error) { const workflow = self.getWorkflow(); const node = self.getNode(); - Logger.error(`There was a problem closing the RabbitMQ Trigger node connection "${node.name}" in workflow "${workflow.id}": "${error.message}"`, + Logger.error( + `There was a problem closing the RabbitMQ Trigger node connection "${node.name}" in workflow "${workflow.id}": "${error.message}"`, { node: node.name, workflowId: workflow.id, @@ -291,5 +289,4 @@ export class RabbitMQTrigger implements INodeType { closeFunction, }; } - } diff --git a/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts b/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts index 9b05f10b4a..1a4680d277 100644 --- a/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts @@ -1,17 +1,8 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - IDataObject, - ILoadOptionsFunctions, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, ILoadOptionsFunctions, NodeApiError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; /** * Make an authenticated API request to Raindrop. @@ -24,7 +15,6 @@ export async function raindropApiRequest( body: IDataObject, option: IDataObject = {}, ) { - const options: OptionsWithUri = { headers: { 'user-agent': 'n8n', diff --git a/packages/nodes-base/nodes/Raindrop/Raindrop.node.ts b/packages/nodes-base/nodes/Raindrop/Raindrop.node.ts index 2304b44ca4..60ff1c3879 100644 --- a/packages/nodes-base/nodes/Raindrop/Raindrop.node.ts +++ b/packages/nodes-base/nodes/Raindrop/Raindrop.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryData, @@ -12,14 +10,9 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - isEmpty, - omit, -} from 'lodash'; +import { isEmpty, omit } from 'lodash'; -import { - raindropApiRequest, -} from './GenericFunctions'; +import { raindropApiRequest } from './GenericFunctions'; import { bookmarkFields, @@ -93,7 +86,7 @@ export class Raindrop implements INodeType { loadOptions: { async getCollections(this: ILoadOptionsFunctions) { const responseData = await raindropApiRequest.call(this, 'GET', '/collections', {}, {}); - return responseData.items.map((item: { title: string, _id: string }) => ({ + return responseData.items.map((item: { title: string; _id: string }) => ({ name: item.title, value: item._id, })); @@ -113,7 +106,6 @@ export class Raindrop implements INodeType { for (let i = 0; i < items.length; i++) { try { if (resource === 'bookmark') { - // ********************************************************************* // bookmark // ********************************************************************* @@ -121,7 +113,6 @@ export class Raindrop implements INodeType { // https://developer.raindrop.io/v1/raindrops if (operation === 'create') { - // ---------------------------------- // bookmark: create // ---------------------------------- @@ -129,7 +120,7 @@ export class Raindrop implements INodeType { const body: IDataObject = { link: this.getNodeParameter('link', i), collection: { - '$id': this.getNodeParameter('collectionId', i), + $id: this.getNodeParameter('collectionId', i), }, }; @@ -145,15 +136,15 @@ export class Raindrop implements INodeType { } if (additionalFields.tags) { - body.tags = (additionalFields.tags as string).split(',').map(tag => tag.trim()) as string[]; + body.tags = (additionalFields.tags as string) + .split(',') + .map((tag) => tag.trim()) as string[]; } const endpoint = `/raindrop`; responseData = await raindropApiRequest.call(this, 'POST', endpoint, {}, body); responseData = responseData.item; - } else if (operation === 'delete') { - // ---------------------------------- // bookmark: delete // ---------------------------------- @@ -161,9 +152,7 @@ export class Raindrop implements INodeType { const bookmarkId = this.getNodeParameter('bookmarkId', i); const endpoint = `/raindrop/${bookmarkId}`; responseData = await raindropApiRequest.call(this, 'DELETE', endpoint, {}, {}); - } else if (operation === 'get') { - // ---------------------------------- // bookmark: get // ---------------------------------- @@ -172,9 +161,7 @@ export class Raindrop implements INodeType { const endpoint = `/raindrop/${bookmarkId}`; responseData = await raindropApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData.item; - } else if (operation === 'getAll') { - // ---------------------------------- // bookmark: getAll // ---------------------------------- @@ -185,14 +172,11 @@ export class Raindrop implements INodeType { responseData = await raindropApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData.items; - if (returnAll === false) { const limit = this.getNodeParameter('limit', 0) as number; responseData = responseData.slice(0, limit); } - } else if (operation === 'update') { - // ---------------------------------- // bookmark: update // ---------------------------------- @@ -204,14 +188,18 @@ export class Raindrop implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; if (isEmpty(updateFields)) { - throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Please enter at least one field to update for the ${resource}.`, + { itemIndex: i }, + ); } Object.assign(body, updateFields); if (updateFields.collectionId) { body.collection = { - '$id': updateFields.collectionId, + $id: updateFields.collectionId, }; delete updateFields.collectionId; } @@ -220,7 +208,9 @@ export class Raindrop implements INodeType { delete updateFields.pleaseParse; } if (updateFields.tags) { - body.tags = (updateFields.tags as string).split(',').map(tag => tag.trim()) as string[]; + body.tags = (updateFields.tags as string) + .split(',') + .map((tag) => tag.trim()) as string[]; } const endpoint = `/raindrop/${bookmarkId}`; @@ -228,7 +218,6 @@ export class Raindrop implements INodeType { responseData = responseData.item; } } else if (resource === 'collection') { - // ********************************************************************* // collection // ********************************************************************* @@ -236,7 +225,6 @@ export class Raindrop implements INodeType { // https://developer.raindrop.io/v1/collections/methods if (operation === 'create') { - // ---------------------------------- // collection: create // ---------------------------------- @@ -262,9 +250,7 @@ export class Raindrop implements INodeType { responseData = await raindropApiRequest.call(this, 'POST', `/collection`, {}, body); responseData = responseData.item; - } else if (operation === 'delete') { - // ---------------------------------- // collection: delete // ---------------------------------- @@ -272,9 +258,7 @@ export class Raindrop implements INodeType { const collectionId = this.getNodeParameter('collectionId', i); const endpoint = `/collection/${collectionId}`; responseData = await raindropApiRequest.call(this, 'DELETE', endpoint, {}, {}); - } else if (operation === 'get') { - // ---------------------------------- // collection: get // ---------------------------------- @@ -283,18 +267,17 @@ export class Raindrop implements INodeType { const endpoint = `/collection/${collectionId}`; responseData = await raindropApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData.item; - } else if (operation === 'getAll') { - // ---------------------------------- // collection: getAll // ---------------------------------- const returnAll = this.getNodeParameter('returnAll', 0) as boolean; - const endpoint = this.getNodeParameter('type', i) === 'parent' - ? '/collections' - : '/collections/childrens'; + const endpoint = + this.getNodeParameter('type', i) === 'parent' + ? '/collections' + : '/collections/childrens'; responseData = await raindropApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData.items; @@ -303,9 +286,7 @@ export class Raindrop implements INodeType { const limit = this.getNodeParameter('limit', 0) as number; responseData = responseData.slice(0, limit); } - } else if (operation === 'update') { - // ---------------------------------- // collection: update // ---------------------------------- @@ -317,7 +298,11 @@ export class Raindrop implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; if (isEmpty(updateFields)) { - throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Please enter at least one field to update for the ${resource}.`, + { itemIndex: i }, + ); } if (updateFields.parentId) { @@ -334,13 +319,18 @@ export class Raindrop implements INodeType { // cover-specific endpoint if (updateFields.cover) { - if (!items[i].binary) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } if (!updateFields.cover) { - throw new NodeOperationError(this.getNode(), 'Please enter a binary property to upload a cover image.', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Please enter a binary property to upload a cover image.', + { itemIndex: i }, + ); } const binaryPropertyName = updateFields.cover as string; @@ -359,13 +349,18 @@ export class Raindrop implements INodeType { }; const endpoint = `/collection/${collectionId}/cover`; - responseData = await raindropApiRequest.call(this, 'PUT', endpoint, {}, {}, { 'Content-Type': 'multipart/form-data', formData }); + responseData = await raindropApiRequest.call( + this, + 'PUT', + endpoint, + {}, + {}, + { 'Content-Type': 'multipart/form-data', formData }, + ); responseData = responseData.item; } } - } else if (resource === 'user') { - // ********************************************************************* // user // ********************************************************************* @@ -373,7 +368,6 @@ export class Raindrop implements INodeType { // https://developer.raindrop.io/v1/user if (operation === 'get') { - // ---------------------------------- // user: get // ---------------------------------- @@ -388,11 +382,8 @@ export class Raindrop implements INodeType { responseData = await raindropApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData.user; - } - } else if (resource === 'tag') { - // ********************************************************************* // tag // ********************************************************************* @@ -400,7 +391,6 @@ export class Raindrop implements INodeType { // https://developer.raindrop.io/v1/tags if (operation === 'delete') { - // ---------------------------------- // tag: delete // ---------------------------------- @@ -418,9 +408,7 @@ export class Raindrop implements INodeType { } responseData = await raindropApiRequest.call(this, 'DELETE', endpoint, {}, body); - } else if (operation === 'getAll') { - // ---------------------------------- // tag: getAll // ---------------------------------- @@ -458,6 +446,5 @@ export class Raindrop implements INodeType { } return [this.helpers.returnJsonArray(returnData)]; - } } diff --git a/packages/nodes-base/nodes/Raindrop/descriptions/BookmarkDescription.ts b/packages/nodes-base/nodes/Raindrop/descriptions/BookmarkDescription.ts index f297861057..75e6cb1268 100644 --- a/packages/nodes-base/nodes/Raindrop/descriptions/BookmarkDescription.ts +++ b/packages/nodes-base/nodes/Raindrop/descriptions/BookmarkDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const bookmarkOperations: INodeProperties[] = [ { @@ -38,9 +36,7 @@ export const bookmarkOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'bookmark', - ], + resource: ['bookmark'], }, }, }, @@ -54,15 +50,12 @@ export const bookmarkFields: INodeProperties[] = [ displayName: 'Collection Name or ID', name: 'collectionId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', displayOptions: { show: { - resource: [ - 'bookmark', - ], - operation: [ - 'create', - ], + resource: ['bookmark'], + operation: ['create'], }, }, typeOptions: { @@ -79,12 +72,8 @@ export const bookmarkFields: INodeProperties[] = [ description: 'Link of the bookmark to be created', displayOptions: { show: { - resource: [ - 'bookmark', - ], - operation: [ - 'create', - ], + resource: ['bookmark'], + operation: ['create'], }, }, }, @@ -96,12 +85,8 @@ export const bookmarkFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'bookmark', - ], - operation: [ - 'create', - ], + resource: ['bookmark'], + operation: ['create'], }, }, options: [ @@ -117,7 +102,8 @@ export const bookmarkFields: INodeProperties[] = [ name: 'order', type: 'number', default: 0, - description: 'Sort order for the bookmark. For example, to move it to first place, enter 0.', + description: + 'Sort order for the bookmark. For example, to move it to first place, enter 0.', }, { displayName: 'Parse Metadata', @@ -155,12 +141,8 @@ export const bookmarkFields: INodeProperties[] = [ description: 'The ID of the bookmark to delete', displayOptions: { show: { - resource: [ - 'bookmark', - ], - operation: [ - 'delete', - ], + resource: ['bookmark'], + operation: ['delete'], }, }, }, @@ -177,12 +159,8 @@ export const bookmarkFields: INodeProperties[] = [ description: 'The ID of the bookmark to retrieve', displayOptions: { show: { - resource: [ - 'bookmark', - ], - operation: [ - 'get', - ], + resource: ['bookmark'], + operation: ['get'], }, }, }, @@ -199,15 +177,12 @@ export const bookmarkFields: INodeProperties[] = [ }, default: [], required: true, - description: 'The ID of the collection from which to retrieve all bookmarks. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the collection from which to retrieve all bookmarks. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'bookmark', - ], - operation: [ - 'getAll', - ], + resource: ['bookmark'], + operation: ['getAll'], }, }, }, @@ -217,12 +192,8 @@ export const bookmarkFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'bookmark', - ], - operation: [ - 'getAll', - ], + resource: ['bookmark'], + operation: ['getAll'], }, }, default: false, @@ -234,15 +205,9 @@ export const bookmarkFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'bookmark', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['bookmark'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -265,12 +230,8 @@ export const bookmarkFields: INodeProperties[] = [ description: 'The ID of the bookmark to update', displayOptions: { show: { - resource: [ - 'bookmark', - ], - operation: [ - 'update', - ], + resource: ['bookmark'], + operation: ['update'], }, }, }, @@ -282,12 +243,8 @@ export const bookmarkFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'bookmark', - ], - operation: [ - 'update', - ], + resource: ['bookmark'], + operation: ['update'], }, }, options: [ @@ -295,7 +252,8 @@ export const bookmarkFields: INodeProperties[] = [ displayName: 'Collection Name or ID', name: 'collectionId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCollections', }, @@ -313,7 +271,8 @@ export const bookmarkFields: INodeProperties[] = [ name: 'order', type: 'number', default: 0, - description: 'For example if you want to move bookmark to the first place set this field to 0', + description: + 'For example if you want to move bookmark to the first place set this field to 0', }, { displayName: 'Parse Metadata', diff --git a/packages/nodes-base/nodes/Raindrop/descriptions/CollectionDescription.ts b/packages/nodes-base/nodes/Raindrop/descriptions/CollectionDescription.ts index d0a1b0a840..52eea17c55 100644 --- a/packages/nodes-base/nodes/Raindrop/descriptions/CollectionDescription.ts +++ b/packages/nodes-base/nodes/Raindrop/descriptions/CollectionDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const collectionOperations: INodeProperties[] = [ { @@ -38,9 +36,7 @@ export const collectionOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'collection', - ], + resource: ['collection'], }, }, }, @@ -59,12 +55,8 @@ export const collectionFields: INodeProperties[] = [ description: 'Title of the collection to create', displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'create', - ], + resource: ['collection'], + operation: ['create'], }, }, }, @@ -76,12 +68,8 @@ export const collectionFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'create', - ], + resource: ['collection'], + operation: ['create'], }, }, options: [ @@ -104,14 +92,15 @@ export const collectionFields: INodeProperties[] = [ name: 'parentId', type: 'string', default: '', - description: 'ID of this collection\'s parent collection, if it is a child collection', + description: "ID of this collection's parent collection, if it is a child collection", }, { displayName: 'Sort Order', name: 'sort', type: 'number', default: 1, - description: 'Descending sort order of this collection. The number is the position of the collection among all the collections with the same parent ID.', + description: + 'Descending sort order of this collection. The number is the position of the collection among all the collections with the same parent ID.', }, { displayName: 'View', @@ -153,12 +142,8 @@ export const collectionFields: INodeProperties[] = [ description: 'The ID of the collection to delete', displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'delete', - ], + resource: ['collection'], + operation: ['delete'], }, }, }, @@ -175,12 +160,8 @@ export const collectionFields: INodeProperties[] = [ description: 'The ID of the collection to retrieve', displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'get', - ], + resource: ['collection'], + operation: ['get'], }, }, }, @@ -196,12 +177,8 @@ export const collectionFields: INodeProperties[] = [ default: 'parent', displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'getAll', - ], + resource: ['collection'], + operation: ['getAll'], }, }, options: [ @@ -223,12 +200,8 @@ export const collectionFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'getAll', - ], + resource: ['collection'], + operation: ['getAll'], }, }, default: false, @@ -240,15 +213,9 @@ export const collectionFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['collection'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -271,12 +238,8 @@ export const collectionFields: INodeProperties[] = [ description: 'The ID of the collection to update', displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'update', - ], + resource: ['collection'], + operation: ['update'], }, }, }, @@ -288,12 +251,8 @@ export const collectionFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'update', - ], + resource: ['collection'], + operation: ['update'], }, }, options: [ @@ -303,7 +262,8 @@ export const collectionFields: INodeProperties[] = [ type: 'string', default: 'data', placeholder: '', - description: 'Name of the binary property containing the data for the image to upload as a cover', + description: + 'Name of the binary property containing the data for the image to upload as a cover', }, { displayName: 'Public', @@ -317,14 +277,15 @@ export const collectionFields: INodeProperties[] = [ name: 'parentId', type: 'string', default: '', - description: 'ID of this collection\'s parent collection, if it is a child collection', + description: "ID of this collection's parent collection, if it is a child collection", }, { displayName: 'Sort Order', name: 'sort', type: 'number', default: 1, - description: 'Descending sort order of this collection. The number is the position of the collection among all the collections with the same parent ID.', + description: + 'Descending sort order of this collection. The number is the position of the collection among all the collections with the same parent ID.', }, { displayName: 'Title', diff --git a/packages/nodes-base/nodes/Raindrop/descriptions/TagDescription.ts b/packages/nodes-base/nodes/Raindrop/descriptions/TagDescription.ts index 3dffc44c18..fbb18524a2 100644 --- a/packages/nodes-base/nodes/Raindrop/descriptions/TagDescription.ts +++ b/packages/nodes-base/nodes/Raindrop/descriptions/TagDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const tagOperations: INodeProperties[] = [ { @@ -23,9 +21,7 @@ export const tagOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'tag', - ], + resource: ['tag'], }, }, }, @@ -43,15 +39,12 @@ export const tagFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'delete', - ], + resource: ['tag'], + operation: ['delete'], }, }, - description: 'One or more tags to delete. Enter comma-separated values to delete multiple tags.', + description: + 'One or more tags to delete. Enter comma-separated values to delete multiple tags.', }, { displayName: 'Additional Fields', @@ -61,12 +54,8 @@ export const tagFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'delete', - ], + resource: ['tag'], + operation: ['delete'], }, }, options: [ @@ -78,7 +67,8 @@ export const tagFields: INodeProperties[] = [ loadOptionsMethod: 'getCollections', }, default: '', - description: 'It\'s possible to restrict remove action to just one collection. It\'s optional. Choose from the list, or specify an ID using an expression.', + description: + 'It\'s possible to restrict remove action to just one collection. It\'s optional. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -91,12 +81,8 @@ export const tagFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'getAll', - ], + resource: ['tag'], + operation: ['getAll'], }, }, default: false, @@ -108,15 +94,9 @@ export const tagFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['tag'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -134,12 +114,8 @@ export const tagFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'getAll', - ], + resource: ['tag'], + operation: ['getAll'], }, }, options: [ @@ -147,7 +123,8 @@ export const tagFields: INodeProperties[] = [ displayName: 'Collection Name or ID', name: 'collectionId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCollections', }, diff --git a/packages/nodes-base/nodes/Raindrop/descriptions/UserDescription.ts b/packages/nodes-base/nodes/Raindrop/descriptions/UserDescription.ts index 69f7b439ac..99b8951bb4 100644 --- a/packages/nodes-base/nodes/Raindrop/descriptions/UserDescription.ts +++ b/packages/nodes-base/nodes/Raindrop/descriptions/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -18,9 +16,7 @@ export const userOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, }, @@ -39,12 +35,8 @@ export const userFields: INodeProperties[] = [ description: 'Whether to return details on the logged-in user', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, }, @@ -57,15 +49,9 @@ export const userFields: INodeProperties[] = [ description: 'The ID of the user to retrieve', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], - self: [ - false, - ], + resource: ['user'], + operation: ['get'], + self: [false], }, }, }, diff --git a/packages/nodes-base/nodes/ReadBinaryFile/ReadBinaryFile.node.ts b/packages/nodes-base/nodes/ReadBinaryFile/ReadBinaryFile.node.ts index b5602d6aa8..026bc38361 100644 --- a/packages/nodes-base/nodes/ReadBinaryFile/ReadBinaryFile.node.ts +++ b/packages/nodes-base/nodes/ReadBinaryFile/ReadBinaryFile.node.ts @@ -6,10 +6,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - readFile as fsReadFile, -} from 'fs/promises'; - +import { readFile as fsReadFile } from 'fs/promises'; export class ReadBinaryFile implements INodeType { description: INodeTypeDescription = { @@ -46,7 +43,6 @@ export class ReadBinaryFile implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); @@ -55,19 +51,20 @@ export class ReadBinaryFile implements INodeType { let item: INodeExecutionData; for (let itemIndex = 0; itemIndex < length; itemIndex++) { - try { - item = items[itemIndex]; const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex) as string; const filePath = this.getNodeParameter('filePath', itemIndex) as string; let data; try { - data = await fsReadFile(filePath) as Buffer; + data = (await fsReadFile(filePath)) as Buffer; } catch (error) { if (error.code === 'ENOENT') { - throw new NodeOperationError(this.getNode(), `The file "${filePath}" could not be found.`); + throw new NodeOperationError( + this.getNode(), + `The file "${filePath}" could not be found.`, + ); } throw error; @@ -90,7 +87,6 @@ export class ReadBinaryFile implements INodeType { newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData(data, filePath); returnData.push(newItem); - } catch (error) { if (this.continueOnFail()) { returnData.push({ @@ -109,5 +105,4 @@ export class ReadBinaryFile implements INodeType { return this.prepareOutputData(returnData); } - } diff --git a/packages/nodes-base/nodes/ReadBinaryFiles/ReadBinaryFiles.node.ts b/packages/nodes-base/nodes/ReadBinaryFiles/ReadBinaryFiles.node.ts index 11d7c5d8de..3741d9344e 100644 --- a/packages/nodes-base/nodes/ReadBinaryFiles/ReadBinaryFiles.node.ts +++ b/packages/nodes-base/nodes/ReadBinaryFiles/ReadBinaryFiles.node.ts @@ -1,16 +1,9 @@ import { IExecuteFunctions } from 'n8n-core'; -import { - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; import glob from 'fast-glob'; import path from 'path'; -import { - readFile as fsReadFile, -} from 'fs/promises'; - +import { readFile as fsReadFile } from 'fs/promises'; export class ReadBinaryFiles implements INodeType { description: INodeTypeDescription = { @@ -47,7 +40,6 @@ export class ReadBinaryFiles implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { const fileSelector = this.getNodeParameter('fileSelector', 0) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string; @@ -58,7 +50,7 @@ export class ReadBinaryFiles implements INodeType { let item: INodeExecutionData; let data: Buffer; for (const filePath of files) { - data = await fsReadFile(filePath) as Buffer; + data = (await fsReadFile(filePath)) as Buffer; item = { binary: { diff --git a/packages/nodes-base/nodes/ReadPdf/ReadPDF.node.ts b/packages/nodes-base/nodes/ReadPdf/ReadPDF.node.ts index 0cd9fa17a9..4e3224ed9f 100644 --- a/packages/nodes-base/nodes/ReadPdf/ReadPDF.node.ts +++ b/packages/nodes-base/nodes/ReadPdf/ReadPDF.node.ts @@ -1,10 +1,6 @@ import { IExecuteFunctions } from 'n8n-core'; -import { - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; const pdf = require('pdf-parse'); @@ -42,9 +38,7 @@ export class ReadPDF implements INodeType { let item: INodeExecutionData; for (let itemIndex = 0; itemIndex < length; itemIndex++) { - - try{ - + try { item = items[itemIndex]; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', itemIndex) as string; @@ -57,7 +51,6 @@ export class ReadPDF implements INodeType { binary: item.binary, json: await pdf(binaryData), }); - } catch (error) { if (this.continueOnFail()) { returnData.push({ @@ -75,5 +68,4 @@ export class ReadPDF implements INodeType { } return this.prepareOutputData(returnData); } - } diff --git a/packages/nodes-base/nodes/Reddit/GenericFunctions.ts b/packages/nodes-base/nodes/Reddit/GenericFunctions.ts index 85d311ffb6..8ad63ab84f 100644 --- a/packages/nodes-base/nodes/Reddit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Reddit/GenericFunctions.ts @@ -1,15 +1,8 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - IDataObject, JsonObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, JsonObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; /** * Make an authenticated or unauthenticated API request to Reddit. @@ -19,8 +12,8 @@ export async function redditApiRequest( method: string, endpoint: string, qs: IDataObject, -): Promise { // tslint:disable-line:no-any - + // tslint:disable-next-line:no-any +): Promise { const resource = this.getNodeParameter('resource', 0) as string; const authRequired = ['profile', 'post', 'postComment'].includes(resource); @@ -32,7 +25,9 @@ export async function redditApiRequest( 'user-agent': 'n8n', }, method, - uri: authRequired ? `https://oauth.reddit.com/${endpoint}` : `https://www.reddit.com/${endpoint}`, + uri: authRequired + ? `https://oauth.reddit.com/${endpoint}` + : `https://www.reddit.com/${endpoint}`, qs, json: true, }; @@ -47,9 +42,7 @@ export async function redditApiRequest( } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); } - } else { - try { return await this.helpers.request.call(this, options); } catch (error) { @@ -66,8 +59,8 @@ export async function redditApiRequestAllItems( method: string, endpoint: string, qs: IDataObject, -): Promise { // tslint:disable-line:no-any - + // tslint:disable-next-line:no-any +): Promise { let responseData; const returnData: IDataObject[] = []; @@ -93,7 +86,6 @@ export async function redditApiRequestAllItems( if (qs.limit && returnData.length >= qs.limit && returnAll === false) { return returnData; } - } while (responseData.data && responseData.data.after); return returnData; @@ -108,8 +100,8 @@ export async function handleListing( endpoint: string, qs: IDataObject = {}, requestMethod: 'GET' | 'POST' = 'GET', -): Promise { // tslint:disable-line:no-any - + // tslint:disable-next-line:no-any +): Promise { let responseData; const returnAll = this.getNodeParameter('returnAll', i); diff --git a/packages/nodes-base/nodes/Reddit/PostCommentDescription.ts b/packages/nodes-base/nodes/Reddit/PostCommentDescription.ts index 81c92a6ccf..5d9ad7a4f6 100644 --- a/packages/nodes-base/nodes/Reddit/PostCommentDescription.ts +++ b/packages/nodes-base/nodes/Reddit/PostCommentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const postCommentOperations: INodeProperties[] = [ { @@ -37,9 +35,7 @@ export const postCommentOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'postComment', - ], + resource: ['postComment'], }, }, }, @@ -55,16 +51,13 @@ export const postCommentFields: INodeProperties[] = [ type: 'string', required: true, default: '', - description: 'ID of the post to write the comment to. Found in the post URL: /r/[subreddit_name]/comments/[post_id]/[post_title]', + description: + 'ID of the post to write the comment to. Found in the post URL: /r/[subreddit_name]/comments/[post_id]/[post_title]', placeholder: 'l0me7x', displayOptions: { show: { - resource: [ - 'postComment', - ], - operation: [ - 'create', - ], + resource: ['postComment'], + operation: ['create'], }, }, }, @@ -77,12 +70,8 @@ export const postCommentFields: INodeProperties[] = [ description: 'Text of the comment. Markdown supported.', displayOptions: { show: { - resource: [ - 'postComment', - ], - operation: [ - 'create', - ], + resource: ['postComment'], + operation: ['create'], }, }, }, @@ -99,12 +88,8 @@ export const postCommentFields: INodeProperties[] = [ description: 'The name of subreddit where the post is', displayOptions: { show: { - resource: [ - 'postComment', - ], - operation: [ - 'getAll', - ], + resource: ['postComment'], + operation: ['getAll'], }, }, }, @@ -114,16 +99,13 @@ export const postCommentFields: INodeProperties[] = [ type: 'string', required: true, default: '', - description: 'ID of the post to get all comments from. Found in the post URL: /r/[subreddit_name]/comments/[post_id]/[post_title]', + description: + 'ID of the post to get all comments from. Found in the post URL: /r/[subreddit_name]/comments/[post_id]/[post_title]', placeholder: 'l0me7x', displayOptions: { show: { - resource: [ - 'postComment', - ], - operation: [ - 'getAll', - ], + resource: ['postComment'], + operation: ['getAll'], }, }, }, @@ -135,12 +117,8 @@ export const postCommentFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'postComment', - ], - operation: [ - 'getAll', - ], + resource: ['postComment'], + operation: ['getAll'], }, }, }, @@ -156,15 +134,9 @@ export const postCommentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'postComment', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['postComment'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -178,16 +150,13 @@ export const postCommentFields: INodeProperties[] = [ type: 'string', required: true, default: '', - description: 'ID of the comment to remove. Found in the comment URL:/r/[subreddit_name]/comments/[post_id]/[post_title]/[comment_id]', + description: + 'ID of the comment to remove. Found in the comment URL:/r/[subreddit_name]/comments/[post_id]/[post_title]/[comment_id]', placeholder: 'gla7fmt', displayOptions: { show: { - resource: [ - 'postComment', - ], - operation: [ - 'delete', - ], + resource: ['postComment'], + operation: ['delete'], }, }, }, @@ -201,16 +170,13 @@ export const postCommentFields: INodeProperties[] = [ type: 'string', required: true, default: '', - description: 'ID of the comment to reply to. To be found in the comment URL: www.reddit.com/r/[subreddit_name]/comments/[post_id]/[post_title]/[comment_id]', + description: + 'ID of the comment to reply to. To be found in the comment URL: www.reddit.com/r/[subreddit_name]/comments/[post_id]/[post_title]/[comment_id]', placeholder: 'gl9iroa', displayOptions: { show: { - resource: [ - 'postComment', - ], - operation: [ - 'reply', - ], + resource: ['postComment'], + operation: ['reply'], }, }, }, @@ -223,12 +189,8 @@ export const postCommentFields: INodeProperties[] = [ description: 'Text of the reply. Markdown supported.', displayOptions: { show: { - resource: [ - 'postComment', - ], - operation: [ - 'reply', - ], + resource: ['postComment'], + operation: ['reply'], }, }, }, diff --git a/packages/nodes-base/nodes/Reddit/PostDescription.ts b/packages/nodes-base/nodes/Reddit/PostDescription.ts index 356488c815..54fae6b561 100644 --- a/packages/nodes-base/nodes/Reddit/PostDescription.ts +++ b/packages/nodes-base/nodes/Reddit/PostDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const postOperations: INodeProperties[] = [ { @@ -43,9 +41,7 @@ export const postOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'post', - ], + resource: ['post'], }, }, }, @@ -64,12 +60,8 @@ export const postFields: INodeProperties[] = [ description: 'Subreddit to create the post in', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], + resource: ['post'], + operation: ['create'], }, }, }, @@ -95,12 +87,8 @@ export const postFields: INodeProperties[] = [ description: 'The kind of the post to create', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], + resource: ['post'], + operation: ['create'], }, }, }, @@ -113,12 +101,8 @@ export const postFields: INodeProperties[] = [ description: 'Title of the post, up to 300 characters long', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], + resource: ['post'], + operation: ['create'], }, }, }, @@ -131,16 +115,9 @@ export const postFields: INodeProperties[] = [ description: 'URL of the post', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], - kind: [ - 'link', - 'image', - ], + resource: ['post'], + operation: ['create'], + kind: ['link', 'image'], }, }, }, @@ -153,15 +130,9 @@ export const postFields: INodeProperties[] = [ description: 'Text of the post. Markdown supported.', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], - kind: [ - 'self', - ], + resource: ['post'], + operation: ['create'], + kind: ['self'], }, }, }, @@ -170,19 +141,13 @@ export const postFields: INodeProperties[] = [ name: 'resubmit', type: 'boolean', default: false, - description: 'Whether the URL will be posted even if it was already posted to the subreddit before. Otherwise, the re-posting will trigger an error.', + description: + 'Whether the URL will be posted even if it was already posted to the subreddit before. Otherwise, the re-posting will trigger an error.', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], - kind: [ - 'link', - 'image', - ], + resource: ['post'], + operation: ['create'], + kind: ['link', 'image'], }, }, }, @@ -196,16 +161,13 @@ export const postFields: INodeProperties[] = [ type: 'string', required: true, default: '', - description: 'ID of the post to delete. Found in the post URL: /r/[subreddit_name]/comments/[post_id]/[post_title]', + description: + 'ID of the post to delete. Found in the post URL: /r/[subreddit_name]/comments/[post_id]/[post_title]', placeholder: 'gla7fmt', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'delete', - ], + resource: ['post'], + operation: ['delete'], }, }, }, @@ -222,12 +184,8 @@ export const postFields: INodeProperties[] = [ description: 'The name of subreddit to retrieve the post from', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'get', - ], + resource: ['post'], + operation: ['get'], }, }, }, @@ -237,16 +195,13 @@ export const postFields: INodeProperties[] = [ type: 'string', required: true, default: '', - description: 'ID of the post to retrieve. Found in the post URL: /r/[subreddit_name]/comments/[post_id]/[post_title]', + description: + 'ID of the post to retrieve. Found in the post URL: /r/[subreddit_name]/comments/[post_id]/[post_title]', placeholder: 'l0me7x', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'get', - ], + resource: ['post'], + operation: ['get'], }, }, }, @@ -263,12 +218,8 @@ export const postFields: INodeProperties[] = [ description: 'The name of subreddit to retrieve the posts from', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'getAll', - ], + resource: ['post'], + operation: ['getAll'], }, }, }, @@ -280,12 +231,8 @@ export const postFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'getAll', - ], + resource: ['post'], + operation: ['getAll'], }, }, }, @@ -301,15 +248,9 @@ export const postFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['post'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -319,12 +260,8 @@ export const postFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'getAll', - ], + resource: ['post'], + operation: ['getAll'], }, }, default: {}, @@ -381,12 +318,8 @@ export const postFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'search', - ], + resource: ['post'], + operation: ['search'], }, }, }, @@ -399,15 +332,9 @@ export const postFields: INodeProperties[] = [ description: 'The name of subreddit to search in', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'search', - ], - location: [ - 'subreddit', - ], + resource: ['post'], + operation: ['search'], + location: ['subreddit'], }, }, }, @@ -420,12 +347,8 @@ export const postFields: INodeProperties[] = [ description: 'The keyword for the search', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'search', - ], + resource: ['post'], + operation: ['search'], }, }, }, @@ -437,12 +360,8 @@ export const postFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'search', - ], + resource: ['post'], + operation: ['search'], }, }, }, @@ -458,15 +377,9 @@ export const postFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'search', - ], - returnAll: [ - false, - ], + resource: ['post'], + operation: ['search'], + returnAll: [false], }, }, }, @@ -478,12 +391,8 @@ export const postFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'search', - ], + resource: ['post'], + operation: ['search'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Reddit/ProfileDescription.ts b/packages/nodes-base/nodes/Reddit/ProfileDescription.ts index 1d8dc98dfd..b1c9d1400a 100644 --- a/packages/nodes-base/nodes/Reddit/ProfileDescription.ts +++ b/packages/nodes-base/nodes/Reddit/ProfileDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const profileOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const profileOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'profile', - ], + resource: ['profile'], }, }, options: [ @@ -26,7 +22,6 @@ export const profileOperations: INodeProperties[] = [ }, ]; - export const profileFields: INodeProperties[] = [ { displayName: 'Details', @@ -74,12 +69,8 @@ export const profileFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'profile', - ], - operation: [ - 'get', - ], + resource: ['profile'], + operation: ['get'], }, }, }, @@ -91,15 +82,9 @@ export const profileFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'profile', - ], - operation: [ - 'get', - ], - details: [ - 'saved', - ], + resource: ['profile'], + operation: ['get'], + details: ['saved'], }, }, }, @@ -115,18 +100,10 @@ export const profileFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'profile', - ], - operation: [ - 'get', - ], - details: [ - 'saved', - ], - returnAll: [ - false, - ], + resource: ['profile'], + operation: ['get'], + details: ['saved'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Reddit/Reddit.node.ts b/packages/nodes-base/nodes/Reddit/Reddit.node.ts index 5e0e84e167..bd8b3d05ff 100644 --- a/packages/nodes-base/nodes/Reddit/Reddit.node.ts +++ b/packages/nodes-base/nodes/Reddit/Reddit.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,35 +8,17 @@ import { NodeApiError, } from 'n8n-workflow'; -import { - handleListing, - redditApiRequest, -} from './GenericFunctions'; +import { handleListing, redditApiRequest } from './GenericFunctions'; -import { - postCommentFields, - postCommentOperations, -} from './PostCommentDescription'; +import { postCommentFields, postCommentOperations } from './PostCommentDescription'; -import { - postFields, - postOperations, -} from './PostDescription'; +import { postFields, postOperations } from './PostDescription'; -import { - profileFields, - profileOperations, -} from './ProfileDescription'; +import { profileFields, profileOperations } from './ProfileDescription'; -import { - subredditFields, - subredditOperations, -} from './SubredditDescription'; +import { subredditFields, subredditOperations } from './SubredditDescription'; -import { - userFields, - userOperations, -} from './UserDescription'; +import { userFields, userOperations } from './UserDescription'; export class Reddit implements INodeType { description: INodeTypeDescription = { @@ -60,11 +40,7 @@ export class Reddit implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'postComment', - 'post', - 'profile', - ], + resource: ['postComment', 'post', 'profile'], }, }, }, @@ -128,9 +104,7 @@ export class Reddit implements INodeType { // ********************************************************************* if (resource === 'post') { - if (operation === 'create') { - // ---------------------------------- // post: create // ---------------------------------- @@ -144,8 +118,8 @@ export class Reddit implements INodeType { }; qs.kind === 'self' - ? qs.text = this.getNodeParameter('text', i) - : qs.url = this.getNodeParameter('url', i); + ? (qs.text = this.getNodeParameter('text', i)) + : (qs.url = this.getNodeParameter('url', i)); if (qs.url) { qs.resubmit = this.getNodeParameter('resubmit', i); @@ -154,9 +128,7 @@ export class Reddit implements INodeType { responseData = await redditApiRequest.call(this, 'POST', 'api/submit', qs); responseData = responseData.json.data; - } else if (operation === 'delete') { - // ---------------------------------- // post: delete // ---------------------------------- @@ -172,9 +144,7 @@ export class Reddit implements INodeType { await redditApiRequest.call(this, 'POST', 'api/del', qs); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------- // post: get // ---------------------------------- @@ -185,9 +155,7 @@ export class Reddit implements INodeType { responseData = await redditApiRequest.call(this, 'GET', endpoint, {}); responseData = responseData[0].data.children[0].data; - } else if (operation === 'getAll') { - // ---------------------------------- // post: getAll // ---------------------------------- @@ -206,9 +174,7 @@ export class Reddit implements INodeType { } responseData = await handleListing.call(this, i, endpoint); - } else if (operation === 'search') { - // ---------------------------------- // post: search // ---------------------------------- @@ -245,17 +211,13 @@ export class Reddit implements INodeType { const limit = this.getNodeParameter('limit', 0) as number; responseData = responseData.splice(0, limit); } - } - } else if (resource === 'postComment') { - // ********************************************************************* // postComment // ********************************************************************* if (operation === 'create') { - // ---------------------------------- // postComment: create // ---------------------------------- @@ -271,9 +233,7 @@ export class Reddit implements INodeType { responseData = await redditApiRequest.call(this, 'POST', 'api/comment', qs); responseData = responseData.json.data.things[0].data; - } else if (operation === 'getAll') { - // ---------------------------------- // postComment: getAll // ---------------------------------- @@ -285,9 +245,7 @@ export class Reddit implements INodeType { const endpoint = `r/${subreddit}/comments/${postId}.json`; responseData = await handleListing.call(this, i, endpoint); - } else if (operation === 'delete') { - // ---------------------------------- // postComment: delete // ---------------------------------- @@ -303,9 +261,7 @@ export class Reddit implements INodeType { await redditApiRequest.call(this, 'POST', 'api/del', qs); responseData = { success: true }; - } else if (operation === 'reply') { - // ---------------------------------- // postComment: reply // ---------------------------------- @@ -322,15 +278,12 @@ export class Reddit implements INodeType { responseData = await redditApiRequest.call(this, 'POST', 'api/comment', qs); responseData = responseData.json.data.things[0].data; } - } else if (resource === 'profile') { - // ********************************************************************* // profile // ********************************************************************* if (operation === 'get') { - // ---------------------------------- // profile: get // ---------------------------------- @@ -358,9 +311,10 @@ export class Reddit implements INodeType { ({ name: username } = await redditApiRequest.call(this, 'GET', `api/v1/me`, {})); } - responseData = details === 'saved' - ? await handleListing.call(this, i, `user/${username}/saved.json`) - : await redditApiRequest.call(this, 'GET', endpoint, {}); + responseData = + details === 'saved' + ? await handleListing.call(this, i, `user/${username}/saved.json`) + : await redditApiRequest.call(this, 'GET', endpoint, {}); if (details === 'identity') { responseData = responseData.features; @@ -378,15 +332,12 @@ export class Reddit implements INodeType { responseData = responseData.data.trophies.map((trophy: IDataObject) => trophy.data); } } - } else if (resource === 'subreddit') { - // ********************************************************************* // subreddit // ********************************************************************* if (operation === 'get') { - // ---------------------------------- // subreddit: get // ---------------------------------- @@ -405,9 +356,7 @@ export class Reddit implements INodeType { } else if (content === 'about') { responseData = responseData.data; } - } else if (operation === 'getAll') { - // ---------------------------------- // subreddit: getAll // ---------------------------------- @@ -427,7 +376,6 @@ export class Reddit implements INodeType { const limit = this.getNodeParameter('limit', 0) as number; responseData = responseData.splice(0, limit); } - } else if (filters.keyword) { const qs: IDataObject = {}; qs.query = filters.keyword; @@ -446,15 +394,12 @@ export class Reddit implements INodeType { responseData = await handleListing.call(this, i, endpoint); } } - } else if (resource === 'user') { - // ********************************************************************* // user // ********************************************************************* if (operation === 'get') { - // ---------------------------------- // user: get // ---------------------------------- @@ -465,9 +410,10 @@ export class Reddit implements INodeType { const details = this.getNodeParameter('details', i) as string; const endpoint = `user/${username}/${details}.json`; - responseData = details === 'about' - ? await redditApiRequest.call(this, 'GET', endpoint, {}) - : await handleListing.call(this, i, endpoint); + responseData = + details === 'about' + ? await redditApiRequest.call(this, 'GET', endpoint, {}) + : await handleListing.call(this, i, endpoint); if (details === 'about') { responseData = responseData.data; diff --git a/packages/nodes-base/nodes/Reddit/SubredditDescription.ts b/packages/nodes-base/nodes/Reddit/SubredditDescription.ts index ef8e0b3340..9e10819755 100644 --- a/packages/nodes-base/nodes/Reddit/SubredditDescription.ts +++ b/packages/nodes-base/nodes/Reddit/SubredditDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const subredditOperations: INodeProperties[] = [ { @@ -25,9 +23,7 @@ export const subredditOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'subreddit', - ], + resource: ['subreddit'], }, }, }, @@ -56,12 +52,8 @@ export const subredditFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'subreddit', - ], - operation: [ - 'get', - ], + resource: ['subreddit'], + operation: ['get'], }, }, }, @@ -74,12 +66,8 @@ export const subredditFields: INodeProperties[] = [ description: 'The name of subreddit to retrieve the content from', displayOptions: { show: { - resource: [ - 'subreddit', - ], - operation: [ - 'get', - ], + resource: ['subreddit'], + operation: ['get'], }, }, }, @@ -95,12 +83,8 @@ export const subredditFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'subreddit', - ], - operation: [ - 'getAll', - ], + resource: ['subreddit'], + operation: ['getAll'], }, }, }, @@ -116,15 +100,9 @@ export const subredditFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'subreddit', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['subreddit'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -152,12 +130,8 @@ export const subredditFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'subreddit', - ], - operation: [ - 'getAll', - ], + resource: ['subreddit'], + operation: ['getAll'], }, }, }, diff --git a/packages/nodes-base/nodes/Reddit/UserDescription.ts b/packages/nodes-base/nodes/Reddit/UserDescription.ts index 5b4aa160f4..c608347e0a 100644 --- a/packages/nodes-base/nodes/Reddit/UserDescription.ts +++ b/packages/nodes-base/nodes/Reddit/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -36,12 +32,8 @@ export const userFields: INodeProperties[] = [ description: 'Reddit ID of the user to retrieve', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, }, @@ -76,12 +68,8 @@ export const userFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, }, @@ -93,18 +81,9 @@ export const userFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], - details: [ - 'overview', - 'submitted', - 'comments', - 'gilded', - ], + resource: ['user'], + operation: ['get'], + details: ['overview', 'submitted', 'comments', 'gilded'], }, }, }, @@ -120,21 +99,10 @@ export const userFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], - details: [ - 'comments', - 'gilded', - 'overview', - 'submitted', - ], - returnAll: [ - false, - ], + resource: ['user'], + operation: ['get'], + details: ['comments', 'gilded', 'overview', 'submitted'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Redis/Redis.node.ts b/packages/nodes-base/nodes/Redis/Redis.node.ts index 423472b81b..3de58a66e7 100644 --- a/packages/nodes-base/nodes/Redis/Redis.node.ts +++ b/packages/nodes-base/nodes/Redis/Redis.node.ts @@ -106,14 +106,13 @@ export class Redis implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], }, }, default: 'propertyName', required: true, - description: 'Name of the property to write received data to. Supports dot-notation. Example: "data.person[0].name".', + description: + 'Name of the property to write received data to. Supports dot-notation. Example: "data.person[0].name".', }, { displayName: 'Key', @@ -121,9 +120,7 @@ export class Redis implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], }, }, default: '', @@ -136,9 +133,7 @@ export class Redis implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], }, }, default: '', @@ -151,9 +146,7 @@ export class Redis implements INodeType { type: 'options', displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], }, }, options: [ @@ -165,22 +158,22 @@ export class Redis implements INodeType { { name: 'Hash', value: 'hash', - description: 'Data in key is of type \'hash\'', + description: "Data in key is of type 'hash'", }, { name: 'List', value: 'list', - description: 'Data in key is of type \'lists\'', + description: "Data in key is of type 'lists'", }, { name: 'Sets', value: 'sets', - description: 'Data in key is of type \'sets\'', + description: "Data in key is of type 'sets'", }, { name: 'String', value: 'string', - description: 'Data in key is of type \'string\'', + description: "Data in key is of type 'string'", }, ], default: 'automatic', @@ -193,9 +186,7 @@ export class Redis implements INodeType { type: 'collection', displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], }, }, placeholder: 'Add Option', @@ -207,12 +198,12 @@ export class Redis implements INodeType { type: 'boolean', default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: '

By default, dot-notation is used in property names. This means that "a.b" will set the property "b" underneath "a" so { "a": { "b": value} }.

If that is not intended this can be deactivated, it will then set { "a.b": value } instead.

.', + description: + '

By default, dot-notation is used in property names. This means that "a.b" will set the property "b" underneath "a" so { "a": { "b": value} }.

If that is not intended this can be deactivated, it will then set { "a.b": value } instead.

.', }, ], }, - // ---------------------------------- // incr // ---------------------------------- @@ -222,9 +213,7 @@ export class Redis implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'incr', - ], + operation: ['incr'], }, }, default: '', @@ -237,9 +226,7 @@ export class Redis implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'incr', - ], + operation: ['incr'], }, }, default: false, @@ -254,12 +241,8 @@ export class Redis implements INodeType { }, displayOptions: { show: { - operation: [ - 'incr', - ], - expire: [ - true, - ], + operation: ['incr'], + expire: [true], }, }, default: 60, @@ -275,9 +258,7 @@ export class Redis implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'keys', - ], + operation: ['keys'], }, }, default: '', @@ -290,9 +271,7 @@ export class Redis implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'keys', - ], + operation: ['keys'], }, }, default: true, @@ -307,9 +286,7 @@ export class Redis implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'set', - ], + operation: ['set'], }, }, default: '', @@ -322,9 +299,7 @@ export class Redis implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'set', - ], + operation: ['set'], }, }, default: '', @@ -336,9 +311,7 @@ export class Redis implements INodeType { type: 'options', displayOptions: { show: { - operation: [ - 'set', - ], + operation: ['set'], }, }, options: [ @@ -350,22 +323,22 @@ export class Redis implements INodeType { { name: 'Hash', value: 'hash', - description: 'Data in key is of type \'hash\'', + description: "Data in key is of type 'hash'", }, { name: 'List', value: 'list', - description: 'Data in key is of type \'lists\'', + description: "Data in key is of type 'lists'", }, { name: 'Sets', value: 'sets', - description: 'Data in key is of type \'sets\'', + description: "Data in key is of type 'sets'", }, { name: 'String', value: 'string', - description: 'Data in key is of type \'string\'', + description: "Data in key is of type 'string'", }, ], default: 'automatic', @@ -378,9 +351,7 @@ export class Redis implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'set', - ], + operation: ['set'], }, }, default: false, @@ -396,12 +367,8 @@ export class Redis implements INodeType { }, displayOptions: { show: { - operation: [ - 'set', - ], - expire: [ - true, - ], + operation: ['set'], + expire: [true], }, }, default: 60, @@ -416,9 +383,7 @@ export class Redis implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'publish', - ], + operation: ['publish'], }, }, default: '', @@ -431,9 +396,7 @@ export class Redis implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'publish', - ], + operation: ['publish'], }, }, typeOptions: { @@ -452,10 +415,7 @@ export class Redis implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'push', - 'pop', - ], + operation: ['push', 'pop'], }, }, default: '', @@ -468,9 +428,7 @@ export class Redis implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'push', - ], + operation: ['push'], }, }, typeOptions: { @@ -486,10 +444,7 @@ export class Redis implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'push', - 'pop', - ], + operation: ['push', 'pop'], }, }, default: false, @@ -501,13 +456,12 @@ export class Redis implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'pop', - ], + operation: ['pop'], }, }, default: 'propertyName', - description: 'Optional name of the property to write received data to. Supports dot-notation. Example: "data.person[0].name".', + description: + 'Optional name of the property to write received data to. Supports dot-notation. Example: "data.person[0].name".', }, { displayName: 'Options', @@ -515,9 +469,7 @@ export class Redis implements INodeType { type: 'collection', displayOptions: { show: { - operation: [ - 'pop', - ], + operation: ['pop'], }, }, placeholder: 'Add Option', @@ -529,14 +481,14 @@ export class Redis implements INodeType { type: 'boolean', default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: '

By default, dot-notation is used in property names. This means that "a.b" will set the property "b" underneath "a" so { "a": { "b": value} }.

If that is not intended this can be deactivated, it will then set { "a.b": value } instead.

.', + description: + '

By default, dot-notation is used in property names. This means that "a.b" will set the property "b" underneath "a" so { "a": { "b": value} }.

If that is not intended this can be deactivated, it will then set { "a.b": value } instead.

.', }, ], }, ], }; - execute(this: IExecuteFunctions): Promise { // Parses the given value in a number if it is one else returns a string function getParsedValue(value: string): string | number { @@ -601,8 +553,14 @@ export class Redis implements INodeType { } } - - const setValue = async (client: redis.RedisClient, keyName: string, value: string | number | object | string[] | number[], expire: boolean, ttl: number, type?: string) => { + const setValue = async ( + client: redis.RedisClient, + keyName: string, + value: string | number | object | string[] | number[], + expire: boolean, + ttl: number, + type?: string, + ) => { if (type === undefined || type === 'automatic') { // Request the type first if (typeof value === 'string') { @@ -612,7 +570,10 @@ export class Redis implements INodeType { } else if (typeof value === 'object') { type = 'hash'; } else { - throw new NodeOperationError(this.getNode(), 'Could not identify the type to set. Please set it manually!'); + throw new NodeOperationError( + this.getNode(), + 'Could not identify the type to set. Please set it manually!', + ); } } @@ -639,7 +600,6 @@ export class Redis implements INodeType { return; }; - return new Promise(async (resolve, reject) => { // TODO: For array and object fields it should not have a "value" field it should // have a parameter field for a path. Because it is not possible to set @@ -673,10 +633,13 @@ export class Redis implements INodeType { const clientInfo = util.promisify(client.info).bind(client); const result = await clientInfo(); - resolve(this.prepareOutputData([{ json: convertInfoToObject(result as unknown as string) }])); + resolve( + this.prepareOutputData([{ json: convertInfoToObject(result as unknown as string) }]), + ); client.quit(); - - } else if (['delete', 'get', 'keys', 'set', 'incr', 'publish', 'push', 'pop'].includes(operation)) { + } else if ( + ['delete', 'get', 'keys', 'set', 'incr', 'publish', 'push', 'pop'].includes(operation) + ) { const items = this.getInputData(); const returnItems: INodeExecutionData[] = []; @@ -696,7 +659,7 @@ export class Redis implements INodeType { const keyGet = this.getNodeParameter('key', itemIndex) as string; const keyType = this.getNodeParameter('keyType', itemIndex) as string; - const value = await getValue(client, keyGet, keyType) || null; + const value = (await getValue(client, keyGet, keyType)) || null; const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; @@ -715,7 +678,7 @@ export class Redis implements INodeType { const keys = await clientKeys(keyPattern); if (!getValues) { - returnItems.push({json: {'keys': keys}}); + returnItems.push({ json: { keys } }); continue; } @@ -741,7 +704,6 @@ export class Redis implements INodeType { await setValue(client, keySet, value, expire, ttl, keyType); returnItems.push(items[itemIndex]); } else if (operation === 'incr') { - const keyIncr = this.getNodeParameter('key', itemIndex) as string; const expire = this.getNodeParameter('expire', itemIndex, false) as boolean; const ttl = this.getNodeParameter('ttl', itemIndex, -1) as number; @@ -752,14 +714,14 @@ export class Redis implements INodeType { const clientExpire = util.promisify(client.expire).bind(client); await clientExpire(keyIncr, ttl); } - returnItems.push({json: {[keyIncr]: incrementVal}}); - } else if (operation === 'publish'){ + returnItems.push({ json: { [keyIncr]: incrementVal } }); + } else if (operation === 'publish') { const channel = this.getNodeParameter('channel', itemIndex) as string; const messageData = this.getNodeParameter('messageData', itemIndex) as string; const clientPublish = util.promisify(client.publish).bind(client); await clientPublish(channel, messageData); returnItems.push(items[itemIndex]); - } else if (operation === 'push'){ + } else if (operation === 'push') { const redisList = this.getNodeParameter('list', itemIndex) as string; const messageData = this.getNodeParameter('messageData', itemIndex) as string; const tail = this.getNodeParameter('tail', itemIndex, false) as boolean; @@ -768,10 +730,14 @@ export class Redis implements INodeType { // @ts-ignore: typescript not understanding generic function signatures await clientPush(redisList, messageData); returnItems.push(items[itemIndex]); - } else if (operation === 'pop'){ + } else if (operation === 'pop') { const redisList = this.getNodeParameter('list', itemIndex) as string; const tail = this.getNodeParameter('tail', itemIndex, false) as boolean; - const propertyName = this.getNodeParameter('propertyName', itemIndex, 'propertyName') as string; + const propertyName = this.getNodeParameter( + 'propertyName', + itemIndex, + 'propertyName', + ) as string; const action = tail ? client.rpop : client.lpop; const clientPop = util.promisify(action).bind(client); diff --git a/packages/nodes-base/nodes/Redis/RedisTrigger.node.ts b/packages/nodes-base/nodes/Redis/RedisTrigger.node.ts index 77d8e24b66..60b9c23964 100644 --- a/packages/nodes-base/nodes/Redis/RedisTrigger.node.ts +++ b/packages/nodes-base/nodes/Redis/RedisTrigger.node.ts @@ -1,6 +1,4 @@ -import { - ITriggerFunctions, -} from 'n8n-core'; +import { ITriggerFunctions } from 'n8n-core'; import { IDataObject, @@ -38,7 +36,8 @@ export class RedisTrigger implements INodeType { type: 'string', default: '', required: true, - description: 'Channels to subscribe to, multiple channels be defined with comma. Wildcard character(*) is supported.', + description: + 'Channels to subscribe to, multiple channels be defined with comma. Wildcard character(*) is supported.', }, { displayName: 'Options', @@ -67,7 +66,6 @@ export class RedisTrigger implements INodeType { }; async trigger(this: ITriggerFunctions): Promise { - const credentials = await this.getCredentials('redis'); const redisOptions: redis.ClientOpts = { @@ -102,16 +100,16 @@ export class RedisTrigger implements INodeType { if (options.jsonParseBody) { try { message = JSON.parse(message); - } catch (error) { } + } catch (error) {} } if (options.onlyMessage) { - self.emit([self.helpers.returnJsonArray({message})]); + self.emit([self.helpers.returnJsonArray({ message })]); resolve(true); return; } - self.emit([self.helpers.returnJsonArray({channel, message})]); + self.emit([self.helpers.returnJsonArray({ channel, message })]); resolve(true); }); }); diff --git a/packages/nodes-base/nodes/RenameKeys/RenameKeys.node.ts b/packages/nodes-base/nodes/RenameKeys/RenameKeys.node.ts index e646edf572..ffc9ee496f 100644 --- a/packages/nodes-base/nodes/RenameKeys/RenameKeys.node.ts +++ b/packages/nodes-base/nodes/RenameKeys/RenameKeys.node.ts @@ -1,16 +1,7 @@ import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - get, - set, - unset, -} from 'lodash'; +import { get, set, unset } from 'lodash'; import { options } from 'rhea'; interface IRenameKey { @@ -55,7 +46,8 @@ export class RenameKeys implements INodeType { type: 'string', default: '', placeholder: 'currentKey', - description: 'The current name of the key. It is also possible to define deep keys by using dot-notation like for example: "level1.level2.currentKey".', + description: + 'The current name of the key. It is also possible to define deep keys by using dot-notation like for example: "level1.level2.currentKey".', }, { displayName: 'New Key Name', @@ -63,7 +55,8 @@ export class RenameKeys implements INodeType { type: 'string', default: '', placeholder: 'newKey', - description: 'The name the key should be renamed to. It is also possible to define deep keys by using dot-notation like for example: "level1.level2.newKey".', + description: + 'The name the key should be renamed to. It is also possible to define deep keys by using dot-notation like for example: "level1.level2.newKey".', }, ], }, @@ -93,7 +86,8 @@ export class RenameKeys implements INodeType { name: 'replacements', values: [ { - displayName: 'Be aware that by using regular expression previously renamed keys can be affected', + displayName: + 'Be aware that by using regular expression previously renamed keys can be affected', name: 'regExNotice', type: 'notice', default: '', @@ -113,7 +107,8 @@ export class RenameKeys implements INodeType { type: 'string', default: '', placeholder: 'replacedName', - description: 'The name the key/s should be renamed to. It\'s possible to use regex captures e.g. $1, $2, ...', + description: + "The name the key/s should be renamed to. It's possible to use regex captures e.g. $1, $2, ...", }, { displayName: 'Options', @@ -148,9 +143,7 @@ export class RenameKeys implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); const returnData: INodeExecutionData[] = []; @@ -162,7 +155,11 @@ export class RenameKeys implements INodeType { for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { renameKeys = this.getNodeParameter('keys.key', itemIndex, []) as IRenameKey[]; - const regexReplacements = this.getNodeParameter('additionalOptions.regexReplacement.replacements', itemIndex, []) as IDataObject[]; + const regexReplacements = this.getNodeParameter( + 'additionalOptions.regexReplacement.replacements', + itemIndex, + [], + ) as IDataObject[]; item = items[itemIndex]; @@ -181,7 +178,11 @@ export class RenameKeys implements INodeType { } renameKeys.forEach((renameKey) => { - if (renameKey.currentKey === '' || renameKey.newKey === '' || renameKey.currentKey === renameKey.newKey) { + if ( + renameKey.currentKey === '' || + renameKey.newKey === '' || + renameKey.currentKey === renameKey.newKey + ) { // Ignore all which do not have all the values set or if the new key is equal to the current key return; } @@ -194,11 +195,11 @@ export class RenameKeys implements INodeType { unset(newItem.json, renameKey.currentKey as string); }); - regexReplacements.forEach(replacement => { + regexReplacements.forEach((replacement) => { const { searchRegex, replaceRegex, options } = replacement; - const {depth, caseInsensitive} = options as IDataObject; + const { depth, caseInsensitive } = options as IDataObject; - const flags = (caseInsensitive as boolean) ? 'i' : undefined; + const flags = (caseInsensitive as boolean) ? 'i' : undefined; const regex = new RegExp(searchRegex as string, flags); diff --git a/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts b/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts index 60ed5f71de..49b4edd0bc 100644 --- a/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts +++ b/packages/nodes-base/nodes/RespondToWebhook/RespondToWebhook.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -25,8 +23,7 @@ export class RespondToWebhook implements INodeType { }, inputs: ['main'], outputs: ['main'], - credentials: [ - ], + credentials: [], properties: [ { displayName: 'Respond With', @@ -58,15 +55,13 @@ export class RespondToWebhook implements INodeType { description: 'The data that should be returned', }, { - displayName: 'When using expressions, note that this node will only run for the first item in the input data.', + displayName: + 'When using expressions, note that this node will only run for the first item in the input data.', name: 'webhookNotice', type: 'notice', displayOptions: { show: { - respondWith: [ - 'json', - 'text', - ], + respondWith: ['json', 'text'], }, }, default: '', @@ -77,9 +72,7 @@ export class RespondToWebhook implements INodeType { type: 'json', displayOptions: { show: { - respondWith: [ - 'json', - ], + respondWith: ['json'], }, }, default: '', @@ -92,9 +85,7 @@ export class RespondToWebhook implements INodeType { type: 'string', displayOptions: { show: { - respondWith: [ - 'text', - ], + respondWith: ['text'], }, }, default: '', @@ -107,9 +98,7 @@ export class RespondToWebhook implements INodeType { type: 'options', displayOptions: { show: { - respondWith: [ - 'binary', - ], + respondWith: ['binary'], }, }, options: [ @@ -134,12 +123,8 @@ export class RespondToWebhook implements INodeType { default: 'data', displayOptions: { show: { - respondWith: [ - 'binary', - ], - responseDataSource: [ - 'set', - ], + respondWith: ['binary'], + responseDataSource: ['set'], }, }, description: 'The name of the node input field with the binary data', @@ -249,10 +234,16 @@ export class RespondToWebhook implements INodeType { } const binaryData = item.binary[responseBinaryPropertyName]; - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(0, responseBinaryPropertyName); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + 0, + responseBinaryPropertyName, + ); if (binaryData === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${responseBinaryPropertyName}" does not exists on item!`); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${responseBinaryPropertyName}" does not exists on item!`, + ); } if (headers['content-type']) { @@ -260,18 +251,20 @@ export class RespondToWebhook implements INodeType { } responseBody = binaryDataBuffer; } else if (respondWith !== 'noData') { - throw new NodeOperationError(this.getNode(), `The Response Data option "${respondWith}" is not supported!`); + throw new NodeOperationError( + this.getNode(), + `The Response Data option "${respondWith}" is not supported!`, + ); } const response: IN8nHttpFullResponse = { body: responseBody, headers, - statusCode: options.responseCode as number || 200, + statusCode: (options.responseCode as number) || 200, }; this.sendResponse(response); return this.prepareOutputData(items); } - } diff --git a/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts b/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts index ec19527085..82471d2b3e 100644 --- a/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts @@ -1,14 +1,18 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { NodeApiError } from 'n8n-workflow'; -export async function rocketchatApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, resource: string, method: string, operation: string, body: any = {}, headers?: object): Promise { // tslint:disable-line:no-any +export async function rocketchatApiRequest( + this: IExecuteFunctions | ILoadOptionsFunctions, + resource: string, + method: string, + operation: string, + // tslint:disable-next-line:no-any + body: any = {}, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('rocketchatApi'); const options: OptionsWithUri = { @@ -28,7 +32,8 @@ export async function rocketchatApiRequest(this: IExecuteFunctions | ILoadOption } } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); diff --git a/packages/nodes-base/nodes/Rocketchat/Rocketchat.node.ts b/packages/nodes-base/nodes/Rocketchat/Rocketchat.node.ts index f3abc8b5de..87c55d6b0f 100644 --- a/packages/nodes-base/nodes/Rocketchat/Rocketchat.node.ts +++ b/packages/nodes-base/nodes/Rocketchat/Rocketchat.node.ts @@ -1,18 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - rocketchatApiRequest, - validateJSON -} from './GenericFunctions'; +import { rocketchatApiRequest, validateJSON } from './GenericFunctions'; interface IField { short?: boolean; @@ -69,7 +59,7 @@ export class Rocketchat implements INodeType { }, ], properties: [ - { + { displayName: 'Resource', name: 'resource', type: 'options', @@ -89,9 +79,7 @@ export class Rocketchat implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'chat', - ], + resource: ['chat'], }, }, options: [ @@ -111,12 +99,8 @@ export class Rocketchat implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'chat', - ], - operation: [ - 'postMessage', - ], + resource: ['chat'], + operation: ['postMessage'], }, }, default: '', @@ -128,12 +112,8 @@ export class Rocketchat implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'chat', - ], - operation: [ - 'postMessage', - ], + resource: ['chat'], + operation: ['postMessage'], }, }, default: '', @@ -146,12 +126,8 @@ export class Rocketchat implements INodeType { default: false, displayOptions: { show: { - resource: [ - 'chat', - ], - operation: [ - 'postMessage', - ], + resource: ['chat'], + operation: ['postMessage'], }, }, }, @@ -163,12 +139,8 @@ export class Rocketchat implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'chat', - ], - operation: [ - 'postMessage', - ], + resource: ['chat'], + operation: ['postMessage'], }, }, options: [ @@ -177,7 +149,8 @@ export class Rocketchat implements INodeType { name: 'alias', type: 'string', default: '', - description: 'This will cause the message’s name to appear as the given alias, but your username will still display', + description: + 'This will cause the message’s name to appear as the given alias, but your username will still display', }, { displayName: 'Avatar', @@ -191,7 +164,8 @@ export class Rocketchat implements INodeType { name: 'emoji', type: 'string', default: '', - description: 'This will cause the message’s name to appear as the given alias, but your username will still display', + description: + 'This will cause the message’s name to appear as the given alias, but your username will still display', }, ], }, @@ -204,19 +178,12 @@ export class Rocketchat implements INodeType { typeOptions: { multipleValues: true, multipleValueButtonText: 'Add Attachment', - }, displayOptions: { show: { - resource: [ - 'chat', - ], - operation: [ - 'postMessage', - ], - jsonParameters: [ - false, - ], + resource: ['chat'], + operation: ['postMessage'], + jsonParameters: [false], }, }, options: [ @@ -225,14 +192,16 @@ export class Rocketchat implements INodeType { name: 'color', type: 'color', default: '#ff0000', - description: 'The color you want the order on the left side to be, any value background-css supports', + description: + 'The color you want the order on the left side to be, any value background-css supports', }, { displayName: 'Text', name: 'text', type: 'string', default: '', - description: 'The text to display for this attachment, it is different than the message’s text', + description: + 'The text to display for this attachment, it is different than the message’s text', }, { displayName: 'Timestamp', @@ -246,14 +215,16 @@ export class Rocketchat implements INodeType { name: 'thumbUrl', type: 'string', default: '', - description: 'An image that displays to the left of the text, looks better when this is relatively small', + description: + 'An image that displays to the left of the text, looks better when this is relatively small', }, { displayName: 'Message Link', name: 'messageLink', type: 'string', default: '', - description: 'Only applicable if the timestamp is provided, as it makes the time clickable to this link', + description: + 'Only applicable if the timestamp is provided, as it makes the time clickable to this link', }, { displayName: 'Collapsed', @@ -261,7 +232,8 @@ export class Rocketchat implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Causes the image, audio, and video sections to be hiding when collapsed is true', + description: + 'Causes the image, audio, and video sections to be hiding when collapsed is true', }, { displayName: 'Author Name', @@ -305,7 +277,8 @@ export class Rocketchat implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'When this is true, a download icon appears and clicking this saves the link to file', + description: + 'When this is true, a download icon appears and clicking this saves the link to file', }, { displayName: 'Image URL', @@ -380,15 +353,9 @@ export class Rocketchat implements INodeType { }, displayOptions: { show: { - resource: [ - 'chat', - ], - operation: [ - 'postMessage', - ], - jsonParameters: [ - true, - ], + resource: ['chat'], + operation: ['postMessage'], + jsonParameters: [true], }, }, default: '', @@ -466,7 +433,8 @@ export class Rocketchat implements INodeType { } else if (option === 'videoUrl') { attachment.video_url = optionsAttachments[i][option] as string; } else if (option === 'fields') { - const fieldsValues = (optionsAttachments[i][option] as IDataObject).fieldsValues as IDataObject[]; + const fieldsValues = (optionsAttachments[i][option] as IDataObject) + .fieldsValues as IDataObject[]; if (fieldsValues.length > 0) { const fields: IField[] = []; for (let i = 0; i < fieldsValues.length; i++) { @@ -491,10 +459,18 @@ export class Rocketchat implements INodeType { body.attachments = attachments; } } else { - body.attachments = validateJSON(this.getNodeParameter('attachmentsJson', i) as string); + body.attachments = validateJSON( + this.getNodeParameter('attachmentsJson', i) as string, + ); } - responseData = await rocketchatApiRequest.call(this, '/chat', 'POST', 'postMessage', body); + responseData = await rocketchatApiRequest.call( + this, + '/chat', + 'POST', + 'postMessage', + body, + ); } } if (Array.isArray(responseData)) { diff --git a/packages/nodes-base/nodes/RssFeedRead/RssFeedRead.node.ts b/packages/nodes-base/nodes/RssFeedRead/RssFeedRead.node.ts index 0d1d14be9d..bd79bc73a8 100644 --- a/packages/nodes-base/nodes/RssFeedRead/RssFeedRead.node.ts +++ b/packages/nodes-base/nodes/RssFeedRead/RssFeedRead.node.ts @@ -36,18 +36,15 @@ export class RssFeedRead implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { - - try{ - + try { const url = this.getNodeParameter('url', 0) as string; if (!url) { throw new NodeOperationError(this.getNode(), 'The parameter "URL" has to be set!'); } - if (!validateURL(url)){ + if (!validateURL(url)) { throw new NodeOperationError(this.getNode(), 'The provided "URL" is not valid!'); } @@ -58,13 +55,15 @@ export class RssFeedRead implements INodeType { feed = await parser.parseURL(url); } catch (error) { if (error.code === 'ECONNREFUSED') { - throw new NodeOperationError(this.getNode(), `It was not possible to connect to the URL. Please make sure the URL "${url}" it is valid!`); + throw new NodeOperationError( + this.getNode(), + `It was not possible to connect to the URL. Please make sure the URL "${url}" it is valid!`, + ); } throw new NodeOperationError(this.getNode(), error); } - const returnData: IDataObject[] = []; // For now we just take the items and ignore everything else @@ -76,10 +75,9 @@ export class RssFeedRead implements INodeType { } return [this.helpers.returnJsonArray(returnData)]; - } catch (error) { if (this.continueOnFail()) { - return this.prepareOutputData([{json:{ error: error.message }}]); + return this.prepareOutputData([{ json: { error: error.message } }]); } throw error; } @@ -88,7 +86,7 @@ export class RssFeedRead implements INodeType { // Utility function -function validateURL (url: string) { +function validateURL(url: string) { try { const parseUrl = new URL(url); return true; diff --git a/packages/nodes-base/nodes/Rundeck/Rundeck.node.ts b/packages/nodes-base/nodes/Rundeck/Rundeck.node.ts index 63f3fd8b64..50088d70de 100644 --- a/packages/nodes-base/nodes/Rundeck/Rundeck.node.ts +++ b/packages/nodes-base/nodes/Rundeck/Rundeck.node.ts @@ -74,12 +74,8 @@ export class Rundeck implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'execute', - ], - resource: [ - 'job', - ], + operation: ['execute'], + resource: ['job'], }, }, default: '', @@ -97,12 +93,8 @@ export class Rundeck implements INodeType { }, displayOptions: { show: { - operation: [ - 'execute', - ], - resource: [ - 'job', - ], + operation: ['execute'], + resource: ['job'], }, }, default: {}, @@ -128,7 +120,6 @@ export class Rundeck implements INodeType { ], }, - // ---------------------------------- // job:getMetadata // ---------------------------------- @@ -138,12 +129,8 @@ export class Rundeck implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'getMetadata', - ], - resource: [ - 'job', - ], + operation: ['getMetadata'], + resource: ['job'], }, }, default: '', @@ -152,12 +139,9 @@ export class Rundeck implements INodeType { description: 'The job ID to get metadata off', }, ], - }; - async execute(this: IExecuteFunctions): Promise { - // Input data const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -168,16 +152,15 @@ export class Rundeck implements INodeType { const rundeckApi = new RundeckApi(this); await rundeckApi.init(); - for (let i = 0; i < length; i++) { - if (resource === 'job') { if (operation === 'execute') { // ---------------------------------- // job: execute // ---------------------------------- const jobid = this.getNodeParameter('jobid', i) as string; - const rundeckArguments = (this.getNodeParameter('arguments', i) as IDataObject).arguments as IDataObject[]; + const rundeckArguments = (this.getNodeParameter('arguments', i) as IDataObject) + .arguments as IDataObject[]; const response = await rundeckApi.executeJob(jobid, rundeckArguments); returnData.push(response); @@ -190,14 +173,21 @@ export class Rundeck implements INodeType { returnData.push(response); } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not supported!`, + { itemIndex: i }, + ); } } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not supported!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The resource "${resource}" is not supported!`, + { itemIndex: i }, + ); } } return [this.helpers.returnJsonArray(returnData)]; - } } diff --git a/packages/nodes-base/nodes/Rundeck/RundeckApi.ts b/packages/nodes-base/nodes/Rundeck/RundeckApi.ts index d7d43a3d7a..bf13cec76a 100644 --- a/packages/nodes-base/nodes/Rundeck/RundeckApi.ts +++ b/packages/nodes-base/nodes/Rundeck/RundeckApi.ts @@ -11,14 +11,11 @@ export class RundeckApi { private credentials?: RundeckCredentials; private executeFunctions: IExecuteFunctions; - constructor(executeFunctions: IExecuteFunctions) { this.executeFunctions = executeFunctions; } - protected async request(method: string, endpoint: string, body: IDataObject, query: object) { - const options: OptionsWithUri = { headers: { 'user-agent': 'n8n', @@ -50,11 +47,10 @@ export class RundeckApi { } executeJob(jobId: string, args: IDataObject[]): Promise { - let params = ''; - if(args) { - for(const arg of args) { + if (args) { + for (const arg of args) { params += '-' + arg.name + ' ' + arg.value + ' '; } } @@ -69,5 +65,4 @@ export class RundeckApi { getJobMetadata(jobId: string): Promise { return this.request('GET', `/api/18/job/${jobId}/info`, {}, {}); } - } diff --git a/packages/nodes-base/nodes/S3/GenericFunctions.ts b/packages/nodes-base/nodes/S3/GenericFunctions.ts index 8b87646bdc..e0f9cfbefb 100644 --- a/packages/nodes-base/nodes/S3/GenericFunctions.ts +++ b/packages/nodes-base/nodes/S3/GenericFunctions.ts @@ -1,19 +1,10 @@ -import { - Request, - sign, -} from 'aws4'; +import { Request, sign } from 'aws4'; -import { - get, -} from 'lodash'; +import { get } from 'lodash'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - parseString, -} from 'xml2js'; +import { parseString } from 'xml2js'; import { IExecuteFunctions, @@ -22,20 +13,31 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; import { URL } from 'url'; -export async function s3ApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, bucket: string, method: string, path: string, body?: string | Buffer, query: IDataObject = {}, headers?: object, option: IDataObject = {}, region?: string): Promise { // tslint:disable-line:no-any - +export async function s3ApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + bucket: string, + method: string, + path: string, + body?: string | Buffer, + query: IDataObject = {}, + headers?: object, + option: IDataObject = {}, + region?: string, + // tslint:disable-next-line:no-any +): Promise { let credentials; credentials = await this.getCredentials('s3'); if (!(credentials.endpoint as string).startsWith('http')) { - throw new NodeOperationError(this.getNode(), 'HTTP(S) Scheme is required in endpoint definition'); + throw new NodeOperationError( + this.getNode(), + 'HTTP(S) Scheme is required in endpoint definition', + ); } const endpoint = new URL(credentials.endpoint as string); @@ -64,7 +66,9 @@ export async function s3ApiRequest(this: IHookFunctions | IExecuteFunctions | IL const securityHeaders = { accessKeyId: `${credentials.accessKeyId}`.trim(), secretAccessKey: `${credentials.secretAccessKey}`.trim(), - sessionToken: credentials.temporaryCredentials ? `${credentials.sessionToken}`.trim() : undefined, + sessionToken: credentials.temporaryCredentials + ? `${credentials.sessionToken}`.trim() + : undefined, }; sign(signOpts, securityHeaders); @@ -87,8 +91,29 @@ export async function s3ApiRequest(this: IHookFunctions | IExecuteFunctions | IL } } -export async function s3ApiRequestREST(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, bucket: string, method: string, path: string, body?: string, query: IDataObject = {}, headers?: object, options: IDataObject = {}, region?: string): Promise { // tslint:disable-line:no-any - const response = await s3ApiRequest.call(this, bucket, method, path, body, query, headers, options, region); +export async function s3ApiRequestREST( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + bucket: string, + method: string, + path: string, + body?: string, + query: IDataObject = {}, + headers?: object, + options: IDataObject = {}, + region?: string, + // tslint:disable-next-line:no-any +): Promise { + const response = await s3ApiRequest.call( + this, + bucket, + method, + path, + body, + query, + headers, + options, + region, + ); try { return JSON.parse(response); } catch (error) { @@ -96,8 +121,29 @@ export async function s3ApiRequestREST(this: IHookFunctions | IExecuteFunctions } } -export async function s3ApiRequestSOAP(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, bucket: string, method: string, path: string, body?: string | Buffer, query: IDataObject = {}, headers?: object, option: IDataObject = {}, region?: string): Promise { // tslint:disable-line:no-any - const response = await s3ApiRequest.call(this, bucket, method, path, body, query, headers, option, region); +export async function s3ApiRequestSOAP( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + bucket: string, + method: string, + path: string, + body?: string | Buffer, + query: IDataObject = {}, + headers?: object, + option: IDataObject = {}, + region?: string, + // tslint:disable-next-line:no-any +): Promise { + const response = await s3ApiRequest.call( + this, + bucket, + method, + path, + body, + query, + headers, + option, + region, + ); try { return await new Promise((resolve, reject) => { parseString(response, { explicitArray: false }, (err, data) => { @@ -112,18 +158,42 @@ export async function s3ApiRequestSOAP(this: IHookFunctions | IExecuteFunctions } } -export async function s3ApiRequestSOAPAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, propertyName: string, service: string, method: string, path: string, body?: string, query: IDataObject = {}, headers: IDataObject = {}, option: IDataObject = {}, region?: string): Promise { // tslint:disable-line:no-any - +export async function s3ApiRequestSOAPAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + propertyName: string, + service: string, + method: string, + path: string, + body?: string, + query: IDataObject = {}, + headers: IDataObject = {}, + option: IDataObject = {}, + region?: string, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; do { - responseData = await s3ApiRequestSOAP.call(this, service, method, path, body, query, headers, option, region); + responseData = await s3ApiRequestSOAP.call( + this, + service, + method, + path, + body, + query, + headers, + option, + region, + ); //https://forums.aws.amazon.com/thread.jspa?threadID=55746 if (get(responseData, `${propertyName.split('.')[0]}.NextContinuationToken`)) { - query['continuation-token'] = get(responseData, `${propertyName.split('.')[0]}.NextContinuationToken`); + query['continuation-token'] = get( + responseData, + `${propertyName.split('.')[0]}.NextContinuationToken`, + ); } if (get(responseData, propertyName)) { if (Array.isArray(get(responseData, propertyName))) { @@ -144,5 +214,7 @@ export async function s3ApiRequestSOAPAllItems(this: IHookFunctions | IExecuteFu } function queryToString(params: IDataObject) { - return Object.keys(params).map(key => key + '=' + params[key]).join('&'); + return Object.keys(params) + .map((key) => key + '=' + params[key]) + .join('&'); } diff --git a/packages/nodes-base/nodes/S3/S3.node.ts b/packages/nodes-base/nodes/S3/S3.node.ts index 99737bf8f4..c5da48b189 100644 --- a/packages/nodes-base/nodes/S3/S3.node.ts +++ b/packages/nodes-base/nodes/S3/S3.node.ts @@ -1,7 +1,4 @@ -import { - paramCase, - snakeCase, -} from 'change-case'; +import { paramCase, snakeCase } from 'change-case'; import { createHash } from 'crypto'; @@ -19,26 +16,13 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - bucketFields, - bucketOperations, -} from '../Aws/S3/BucketDescription'; +import { bucketFields, bucketOperations } from '../Aws/S3/BucketDescription'; -import { - folderFields, - folderOperations, -} from '../Aws/S3/FolderDescription'; +import { folderFields, folderOperations } from '../Aws/S3/FolderDescription'; -import { - fileFields, - fileOperations, -} from '../Aws/S3/FileDescription'; +import { fileFields, fileOperations } from '../Aws/S3/FileDescription'; -import { - s3ApiRequestREST, - s3ApiRequestSOAP, - s3ApiRequestSOAPAllItems, -} from './GenericFunctions'; +import { s3ApiRequestREST, s3ApiRequestSOAP, s3ApiRequestSOAPAllItems } from './GenericFunctions'; export class S3 implements INodeType { description: INodeTypeDescription = { @@ -108,7 +92,6 @@ export class S3 implements INodeType { if (resource === 'bucket') { //https://docs.aws.amazon.com/AmazonS3/latest/API/API_CreateBucket.html if (operation === 'create') { - let credentials; try { @@ -123,7 +106,8 @@ export class S3 implements INodeType { headers['x-amz-acl'] = paramCase(additionalFields.acl as string); } if (additionalFields.bucketObjectLockEnabled) { - headers['x-amz-bucket-object-lock-enabled'] = additionalFields.bucketObjectLockEnabled as boolean; + headers['x-amz-bucket-object-lock-enabled'] = + additionalFields.bucketObjectLockEnabled as boolean; } if (additionalFields.grantFullControl) { headers['x-amz-grant-full-control'] = ''; @@ -148,7 +132,7 @@ export class S3 implements INodeType { const body: IDataObject = { CreateBucketConfiguration: { - '$': { + $: { xmlns: 'http://s3.amazonaws.com/doc/2006-03-01/', }, }, @@ -161,7 +145,15 @@ export class S3 implements INodeType { const builder = new Builder(); data = builder.buildObject(body); } - responseData = await s3ApiRequestSOAP.call(this, `${name}`, 'PUT', '', data, qs, headers); + responseData = await s3ApiRequestSOAP.call( + this, + `${name}`, + 'PUT', + '', + data, + qs, + headers, + ); returnData.push({ success: true }); } @@ -169,10 +161,24 @@ export class S3 implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', 0) as boolean; if (returnAll) { - responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListAllMyBucketsResult.Buckets.Bucket', '', 'GET', ''); + responseData = await s3ApiRequestSOAPAllItems.call( + this, + 'ListAllMyBucketsResult.Buckets.Bucket', + '', + 'GET', + '', + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; - responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListAllMyBucketsResult.Buckets.Bucket', '', 'GET', '', '', qs); + responseData = await s3ApiRequestSOAPAllItems.call( + this, + 'ListAllMyBucketsResult.Buckets.Bucket', + '', + 'GET', + '', + '', + qs, + ); responseData = responseData.slice(0, qs.limit); } returnData.push.apply(returnData, responseData); @@ -210,16 +216,38 @@ export class S3 implements INodeType { qs['list-type'] = 2; - - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' }); + responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._ as string; if (returnAll) { - responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '', '', qs, {}, {}, region); + responseData = await s3ApiRequestSOAPAllItems.call( + this, + 'ListBucketResult.Contents', + bucketName, + 'GET', + '', + '', + qs, + {}, + {}, + region, + ); } else { qs['max-keys'] = this.getNodeParameter('limit', 0) as number; - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', qs, {}, {}, region); + responseData = await s3ApiRequestSOAP.call( + this, + bucketName, + 'GET', + '', + '', + qs, + {}, + {}, + region, + ); responseData = responseData.ListBucketResult.Contents; } if (Array.isArray(responseData)) { @@ -244,13 +272,27 @@ export class S3 implements INodeType { path = `/${additionalFields.parentFolderKey}${folderName}/`; } if (additionalFields.storageClass) { - headers['x-amz-storage-class'] = (snakeCase(additionalFields.storageClass as string)).toUpperCase(); + headers['x-amz-storage-class'] = snakeCase( + additionalFields.storageClass as string, + ).toUpperCase(); } - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' }); + responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._; - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'PUT', path, '', qs, headers, {}, region); + responseData = await s3ApiRequestSOAP.call( + this, + bucketName, + 'PUT', + path, + '', + qs, + headers, + {}, + region, + ); returnData.push({ success: true }); } //https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html @@ -258,24 +300,45 @@ export class S3 implements INodeType { const bucketName = this.getNodeParameter('bucketName', i) as string; const folderKey = this.getNodeParameter('folderKey', i) as string; - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' }); + responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._; - responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '/', '', { 'list-type': 2, prefix: folderKey }, {}, {}, region); + responseData = await s3ApiRequestSOAPAllItems.call( + this, + 'ListBucketResult.Contents', + bucketName, + 'GET', + '/', + '', + { 'list-type': 2, prefix: folderKey }, + {}, + {}, + region, + ); // folder empty then just delete it if (responseData.length === 0) { + responseData = await s3ApiRequestSOAP.call( + this, + bucketName, + 'DELETE', + `/${folderKey}`, + '', + qs, + {}, + {}, + region, + ); - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'DELETE', `/${folderKey}`, '', qs, {}, {}, region); - - responseData = { deleted: [{ 'Key': folderKey }] }; - + responseData = { deleted: [{ Key: folderKey }] }; } else { // delete everything inside the folder const body: IDataObject = { Delete: { - '$': { + $: { xmlns: 'http://s3.amazonaws.com/doc/2006-03-01/', }, Object: [], @@ -296,7 +359,17 @@ export class S3 implements INodeType { headers['Content-Type'] = 'application/xml'; - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'POST', '/', data, { delete: '' }, headers, {}, region); + responseData = await s3ApiRequestSOAP.call( + this, + bucketName, + 'POST', + '/', + data, + { delete: '' }, + headers, + {}, + region, + ); responseData = { deleted: responseData.DeleteResult.Deleted }; } @@ -318,18 +391,45 @@ export class S3 implements INodeType { qs['list-type'] = 2; - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' }); + responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._; if (returnAll) { - responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '', '', qs, {}, {}, region); + responseData = await s3ApiRequestSOAPAllItems.call( + this, + 'ListBucketResult.Contents', + bucketName, + 'GET', + '', + '', + qs, + {}, + {}, + region, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; - responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '', '', qs, {}, {}, region); + responseData = await s3ApiRequestSOAPAllItems.call( + this, + 'ListBucketResult.Contents', + bucketName, + 'GET', + '', + '', + qs, + {}, + {}, + region, + ); } if (Array.isArray(responseData)) { - responseData = responseData.filter((e: IDataObject) => (e.Key as string).endsWith('/') && e.Size === '0' && e.Key !== options.folderKey); + responseData = responseData.filter( + (e: IDataObject) => + (e.Key as string).endsWith('/') && e.Size === '0' && e.Key !== options.folderKey, + ); if (qs.limit) { responseData = responseData.splice(0, qs.limit as number); } @@ -350,7 +450,9 @@ export class S3 implements INodeType { headers['x-amz-request-payer'] = 'requester'; } if (additionalFields.storageClass) { - headers['x-amz-storage-class'] = (snakeCase(additionalFields.storageClass as string)).toUpperCase(); + headers['x-amz-storage-class'] = snakeCase( + additionalFields.storageClass as string, + ).toUpperCase(); } if (additionalFields.acl) { headers['x-amz-acl'] = paramCase(additionalFields.acl as string); @@ -368,37 +470,52 @@ export class S3 implements INodeType { headers['x-amz-grant-write-acp'] = ''; } if (additionalFields.lockLegalHold) { - headers['x-amz-object-lock-legal-hold'] = (additionalFields.lockLegalHold as boolean) ? 'ON' : 'OFF'; + headers['x-amz-object-lock-legal-hold'] = (additionalFields.lockLegalHold as boolean) + ? 'ON' + : 'OFF'; } if (additionalFields.lockMode) { - headers['x-amz-object-lock-mode'] = (additionalFields.lockMode as string).toUpperCase(); + headers['x-amz-object-lock-mode'] = ( + additionalFields.lockMode as string + ).toUpperCase(); } if (additionalFields.lockRetainUntilDate) { - headers['x-amz-object-lock-retain-until-date'] = additionalFields.lockRetainUntilDate as string; + headers['x-amz-object-lock-retain-until-date'] = + additionalFields.lockRetainUntilDate as string; } if (additionalFields.serverSideEncryption) { - headers['x-amz-server-side-encryption'] = additionalFields.serverSideEncryption as string; + headers['x-amz-server-side-encryption'] = + additionalFields.serverSideEncryption as string; } if (additionalFields.encryptionAwsKmsKeyId) { - headers['x-amz-server-side-encryption-aws-kms-key-id'] = additionalFields.encryptionAwsKmsKeyId as string; + headers['x-amz-server-side-encryption-aws-kms-key-id'] = + additionalFields.encryptionAwsKmsKeyId as string; } if (additionalFields.serverSideEncryptionContext) { - headers['x-amz-server-side-encryption-context'] = additionalFields.serverSideEncryptionContext as string; + headers['x-amz-server-side-encryption-context'] = + additionalFields.serverSideEncryptionContext as string; } if (additionalFields.serversideEncryptionCustomerAlgorithm) { - headers['x-amz-server-side-encryption-customer-algorithm'] = additionalFields.serversideEncryptionCustomerAlgorithm as string; + headers['x-amz-server-side-encryption-customer-algorithm'] = + additionalFields.serversideEncryptionCustomerAlgorithm as string; } if (additionalFields.serversideEncryptionCustomerKey) { - headers['x-amz-server-side-encryption-customer-key'] = additionalFields.serversideEncryptionCustomerKey as string; + headers['x-amz-server-side-encryption-customer-key'] = + additionalFields.serversideEncryptionCustomerKey as string; } if (additionalFields.serversideEncryptionCustomerKeyMD5) { - headers['x-amz-server-side-encryption-customer-key-MD5'] = additionalFields.serversideEncryptionCustomerKeyMD5 as string; + headers['x-amz-server-side-encryption-customer-key-MD5'] = + additionalFields.serversideEncryptionCustomerKeyMD5 as string; } if (additionalFields.taggingDirective) { - headers['x-amz-tagging-directive'] = (additionalFields.taggingDirective as string).toUpperCase(); + headers['x-amz-tagging-directive'] = ( + additionalFields.taggingDirective as string + ).toUpperCase(); } if (additionalFields.metadataDirective) { - headers['x-amz-metadata-directive'] = (additionalFields.metadataDirective as string).toUpperCase(); + headers['x-amz-metadata-directive'] = ( + additionalFields.metadataDirective as string + ).toUpperCase(); } const destinationParts = destinationPath.split('/'); @@ -407,17 +524,27 @@ export class S3 implements INodeType { const destination = `/${destinationParts.slice(2, destinationParts.length).join('/')}`; - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' }); + responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._; - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'PUT', destination, '', qs, headers, {}, region); + responseData = await s3ApiRequestSOAP.call( + this, + bucketName, + 'PUT', + destination, + '', + qs, + headers, + {}, + region, + ); returnData.push(responseData.CopyObjectResult); - } //https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html if (operation === 'download') { - const bucketName = this.getNodeParameter('bucketName', i) as string; const fileKey = this.getNodeParameter('fileKey', i) as string; @@ -425,14 +552,29 @@ export class S3 implements INodeType { const fileName = fileKey.split('/')[fileKey.split('/').length - 1]; if (fileKey.substring(fileKey.length - 1) === '/') { - throw new NodeOperationError(this.getNode(), 'Downloding a whole directory is not yet supported, please provide a file key'); + throw new NodeOperationError( + this.getNode(), + 'Downloding a whole directory is not yet supported, please provide a file key', + ); } - let region = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' }); + let region = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { + location: '', + }); region = region.LocationConstraint._; - const response = await s3ApiRequestREST.call(this, bucketName, 'GET', `/${fileKey}`, '', qs, {}, { encoding: null, resolveWithFullResponse: true }, region); + const response = await s3ApiRequestREST.call( + this, + bucketName, + 'GET', + `/${fileKey}`, + '', + qs, + {}, + { encoding: null, resolveWithFullResponse: true }, + region, + ); let mimeType: string | undefined; if (response.headers['content-type']) { @@ -453,11 +595,18 @@ export class S3 implements INodeType { items[i] = newItem; - const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string; + const dataPropertyNameDownload = this.getNodeParameter( + 'binaryPropertyName', + i, + ) as string; const data = Buffer.from(response.body as string, 'utf8'); - items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data as unknown as Buffer, fileName, mimeType); + items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( + data as unknown as Buffer, + fileName, + mimeType, + ); } //https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html if (operation === 'delete') { @@ -471,11 +620,23 @@ export class S3 implements INodeType { qs.versionId = options.versionId as string; } - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' }); + responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._; - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'DELETE', `/${fileKey}`, '', qs, {}, {}, region); + responseData = await s3ApiRequestSOAP.call( + this, + bucketName, + 'DELETE', + `/${fileKey}`, + '', + qs, + {}, + {}, + region, + ); returnData.push({ success: true }); } @@ -497,19 +658,45 @@ export class S3 implements INodeType { qs['list-type'] = 2; - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' }); + responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._; if (returnAll) { - responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '', '', qs, {}, {}, region); + responseData = await s3ApiRequestSOAPAllItems.call( + this, + 'ListBucketResult.Contents', + bucketName, + 'GET', + '', + '', + qs, + {}, + {}, + region, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; - responseData = await s3ApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', bucketName, 'GET', '', '', qs, {}, {}, region); + responseData = await s3ApiRequestSOAPAllItems.call( + this, + 'ListBucketResult.Contents', + bucketName, + 'GET', + '', + '', + qs, + {}, + {}, + region, + ); responseData = responseData.splice(0, qs.limit); } if (Array.isArray(responseData)) { - responseData = responseData.filter((e: IDataObject) => !(e.Key as string).endsWith('/') && e.Size !== '0'); + responseData = responseData.filter( + (e: IDataObject) => !(e.Key as string).endsWith('/') && e.Size !== '0', + ); if (qs.limit) { responseData = responseData.splice(0, qs.limit as number); } @@ -522,7 +709,8 @@ export class S3 implements INodeType { const fileName = this.getNodeParameter('fileName', i) as string; const isBinaryData = this.getNodeParameter('binaryData', i) as boolean; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - const tagsValues = (this.getNodeParameter('tagsUi', i) as IDataObject).tagsValues as IDataObject[]; + const tagsValues = (this.getNodeParameter('tagsUi', i) as IDataObject) + .tagsValues as IDataObject[]; let path = '/'; let body; @@ -534,7 +722,9 @@ export class S3 implements INodeType { path = `/${additionalFields.parentFolderKey}/`; } if (additionalFields.storageClass) { - headers['x-amz-storage-class'] = (snakeCase(additionalFields.storageClass as string)).toUpperCase(); + headers['x-amz-storage-class'] = snakeCase( + additionalFields.storageClass as string, + ).toUpperCase(); } if (additionalFields.acl) { headers['x-amz-acl'] = paramCase(additionalFields.acl as string); @@ -552,39 +742,54 @@ export class S3 implements INodeType { headers['x-amz-grant-write-acp'] = ''; } if (additionalFields.lockLegalHold) { - headers['x-amz-object-lock-legal-hold'] = (additionalFields.lockLegalHold as boolean) ? 'ON' : 'OFF'; + headers['x-amz-object-lock-legal-hold'] = (additionalFields.lockLegalHold as boolean) + ? 'ON' + : 'OFF'; } if (additionalFields.lockMode) { - headers['x-amz-object-lock-mode'] = (additionalFields.lockMode as string).toUpperCase(); + headers['x-amz-object-lock-mode'] = ( + additionalFields.lockMode as string + ).toUpperCase(); } if (additionalFields.lockRetainUntilDate) { - headers['x-amz-object-lock-retain-until-date'] = additionalFields.lockRetainUntilDate as string; + headers['x-amz-object-lock-retain-until-date'] = + additionalFields.lockRetainUntilDate as string; } if (additionalFields.serverSideEncryption) { - headers['x-amz-server-side-encryption'] = additionalFields.serverSideEncryption as string; + headers['x-amz-server-side-encryption'] = + additionalFields.serverSideEncryption as string; } if (additionalFields.encryptionAwsKmsKeyId) { - headers['x-amz-server-side-encryption-aws-kms-key-id'] = additionalFields.encryptionAwsKmsKeyId as string; + headers['x-amz-server-side-encryption-aws-kms-key-id'] = + additionalFields.encryptionAwsKmsKeyId as string; } if (additionalFields.serverSideEncryptionContext) { - headers['x-amz-server-side-encryption-context'] = additionalFields.serverSideEncryptionContext as string; + headers['x-amz-server-side-encryption-context'] = + additionalFields.serverSideEncryptionContext as string; } if (additionalFields.serversideEncryptionCustomerAlgorithm) { - headers['x-amz-server-side-encryption-customer-algorithm'] = additionalFields.serversideEncryptionCustomerAlgorithm as string; + headers['x-amz-server-side-encryption-customer-algorithm'] = + additionalFields.serversideEncryptionCustomerAlgorithm as string; } if (additionalFields.serversideEncryptionCustomerKey) { - headers['x-amz-server-side-encryption-customer-key'] = additionalFields.serversideEncryptionCustomerKey as string; + headers['x-amz-server-side-encryption-customer-key'] = + additionalFields.serversideEncryptionCustomerKey as string; } if (additionalFields.serversideEncryptionCustomerKeyMD5) { - headers['x-amz-server-side-encryption-customer-key-MD5'] = additionalFields.serversideEncryptionCustomerKeyMD5 as string; + headers['x-amz-server-side-encryption-customer-key-MD5'] = + additionalFields.serversideEncryptionCustomerKeyMD5 as string; } if (tagsValues) { const tags: string[] = []; - tagsValues.forEach((o: IDataObject) => { tags.push(`${o.key}=${o.value}`); }); + tagsValues.forEach((o: IDataObject) => { + tags.push(`${o.key}=${o.value}`); + }); headers['x-amz-tagging'] = tags.join('&'); } - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { location: '' }); + responseData = await s3ApiRequestSOAP.call(this, bucketName, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._; @@ -592,11 +797,17 @@ export class S3 implements INodeType { const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string; if (items[i].binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } if ((items[i].binary as IBinaryKeyData)[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + { itemIndex: i }, + ); } const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName]; @@ -606,10 +817,18 @@ export class S3 implements INodeType { headers['Content-MD5'] = createHash('md5').update(body).digest('base64'); - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'PUT', `${path}${fileName || binaryData.fileName}`, body, qs, headers, {}, region); - + responseData = await s3ApiRequestSOAP.call( + this, + bucketName, + 'PUT', + `${path}${fileName || binaryData.fileName}`, + body, + qs, + headers, + {}, + region, + ); } else { - const fileContent = this.getNodeParameter('fileContent', i) as string; body = Buffer.from(fileContent, 'utf8'); @@ -618,7 +837,17 @@ export class S3 implements INodeType { headers['Content-MD5'] = createHash('md5').update(fileContent).digest('base64'); - responseData = await s3ApiRequestSOAP.call(this, bucketName, 'PUT', `${path}${fileName}`, body, qs, headers, {}, region); + responseData = await s3ApiRequestSOAP.call( + this, + bucketName, + 'PUT', + `${path}${fileName}`, + body, + qs, + headers, + {}, + region, + ); } returnData.push({ success: true }); } @@ -627,7 +856,7 @@ export class S3 implements INodeType { if (this.continueOnFail()) { if (resource === 'file' && operation === 'download') { items[i].json = { error: error.message }; - }else { + } else { returnData.push({ error: error.message }); } continue; diff --git a/packages/nodes-base/nodes/Salesforce/AccountDescription.ts b/packages/nodes-base/nodes/Salesforce/AccountDescription.ts index 8328091fc9..384a68e3ad 100644 --- a/packages/nodes-base/nodes/Salesforce/AccountDescription.ts +++ b/packages/nodes-base/nodes/Salesforce/AccountDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const accountOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const accountOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'account', - ], + resource: ['account'], }, }, options: [ @@ -31,7 +27,8 @@ export const accountOperations: INodeProperties[] = [ { name: 'Create or Update', value: 'upsert', - description: 'Create a new account, or update the current one if it already exists (upsert)', + description: + 'Create a new account, or update the current one if it already exists (upsert)', action: 'Create or update an account', }, { @@ -55,7 +52,7 @@ export const accountOperations: INodeProperties[] = [ { name: 'Get Summary', value: 'getSummary', - description: 'Returns an overview of account\'s metadata', + description: "Returns an overview of account's metadata", action: 'Get an account summary', }, { @@ -70,7 +67,6 @@ export const accountOperations: INodeProperties[] = [ ]; export const accountFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* account:create */ /* -------------------------------------------------------------------------- */ @@ -81,23 +77,18 @@ export const accountFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getExternalIdFields', - loadOptionsDependsOn: [ - 'resource', - ], + loadOptionsDependsOn: ['resource'], }, required: true, default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'upsert', - ], + resource: ['account'], + operation: ['upsert'], }, }, - description: 'The field to check to see if the account already exists. Choose from the list, or specify an ID using an expression.', + description: + 'The field to check to see if the account already exists. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value to Match', @@ -107,15 +98,12 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'upsert', - ], + resource: ['account'], + operation: ['upsert'], }, }, - description: 'If this value exists in the \'match against\' field, update the account. Otherwise create a new one.', + description: + "If this value exists in the 'match against' field, update the account. Otherwise create a new one.", }, { displayName: 'Name', @@ -125,13 +113,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['account'], + operation: ['create', 'upsert'], }, }, description: 'Name of the account. Maximum size is 255 characters.', @@ -144,13 +127,8 @@ export const accountFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['account'], + operation: ['create', 'upsert'], }, }, options: [ @@ -159,7 +137,8 @@ export const accountFields: INodeProperties[] = [ name: 'accountNumber', type: 'string', default: '', - description: 'Account number assigned to this account (not the unique ID). Maximum size is 40 characters.', + description: + 'Account number assigned to this account (not the unique ID). Maximum size is 40 characters.', }, { displayName: 'Annual Revenue', @@ -179,35 +158,40 @@ export const accountFields: INodeProperties[] = [ loadOptionsMethod: 'getAccountSources', }, default: '', - description: 'The source of the account record. Choose from the list, or specify an ID using an expression.', + description: + 'The source of the account record. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Billing City', name: 'billingCity', type: 'string', default: '', - description: 'Details for the billing address of this account. Maximum size is 40 characters.', + description: + 'Details for the billing address of this account. Maximum size is 40 characters.', }, { displayName: 'Billing Country', name: 'billingCountry', type: 'string', default: '', - description: 'Details for the billing address of this account. Maximum size is 80 characters.', + description: + 'Details for the billing address of this account. Maximum size is 80 characters.', }, { displayName: 'Billing Postal Code', name: 'billingPostalCode', type: 'string', default: '', - description: 'Details for the billing address of this account. Maximum size is 20 characters.', + description: + 'Details for the billing address of this account. Maximum size is 20 characters.', }, { displayName: 'Billing State', name: 'billingState', type: 'string', default: '', - description: 'Details for the billing address of this account. Maximum size is 80 characters.', + description: + 'Details for the billing address of this account. Maximum size is 80 characters.', }, { displayName: 'Billing Street', @@ -239,7 +223,8 @@ export const accountFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -297,7 +282,8 @@ export const accountFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'The owner of the account. Choose from the list, or specify an ID using an expression.', + description: + 'The owner of the account. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Parent ID', @@ -317,7 +303,8 @@ export const accountFields: INodeProperties[] = [ displayName: 'Record Type Name or ID', name: 'recordTypeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getRecordTypes', }, @@ -331,7 +318,8 @@ export const accountFields: INodeProperties[] = [ typeOptions: { alwaysOpenEditWindow: true, }, - description: 'A brief description of an organization’s line of business, based on its SIC code', + description: + 'A brief description of an organization’s line of business, based on its SIC code', }, { displayName: 'Type Name or ID', @@ -341,42 +329,48 @@ export const accountFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getAccountTypes', }, - description: 'Type of account. Choose from the list, or specify an ID using an expression.', + description: + 'Type of account. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Shipping City', name: 'shippingCity', type: 'string', default: '', - description: 'Details of the shipping address for this account. City maximum size is 40 characters.', + description: + 'Details of the shipping address for this account. City maximum size is 40 characters.', }, { displayName: 'Shipping Country', name: 'shippingCountry', type: 'string', default: '', - description: 'Details of the shipping address for this account. Country maximum size is 80 characters.', + description: + 'Details of the shipping address for this account. Country maximum size is 80 characters.', }, { displayName: 'Shipping Postal Code', name: 'shippingPostalCode', type: 'string', default: '', - description: 'Details of the shipping address for this account. Postal code maximum size is 20 characters.', + description: + 'Details of the shipping address for this account. Postal code maximum size is 20 characters.', }, { displayName: 'Shipping State', name: 'shippingState', type: 'string', default: '', - description: 'Details of the shipping address for this account. State maximum size is 80 characters.', + description: + 'Details of the shipping address for this account. State maximum size is 80 characters.', }, { displayName: 'Shipping Street', name: 'shippingStreet', type: 'string', default: '', - description: 'The street address of the shipping address for this account. Maximum of 255 characters.', + description: + 'The street address of the shipping address for this account. Maximum of 255 characters.', }, { displayName: 'Website', @@ -399,12 +393,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'update', - ], + resource: ['account'], + operation: ['update'], }, }, description: 'ID of account that needs to be fetched', @@ -417,12 +407,8 @@ export const accountFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'update', - ], + resource: ['account'], + operation: ['update'], }, }, options: [ @@ -431,7 +417,8 @@ export const accountFields: INodeProperties[] = [ name: 'accountNumber', type: 'string', default: '', - description: 'Account number assigned to this account (not the unique ID). Maximum size is 40 characters.', + description: + 'Account number assigned to this account (not the unique ID). Maximum size is 40 characters.', }, { displayName: 'Account Source Name or ID', @@ -441,7 +428,8 @@ export const accountFields: INodeProperties[] = [ loadOptionsMethod: 'getAccountSources', }, default: '', - description: 'The source of the account record. Choose from the list, or specify an ID using an expression.', + description: + 'The source of the account record. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Annual Revenue', @@ -458,28 +446,32 @@ export const accountFields: INodeProperties[] = [ name: 'billingCity', type: 'string', default: '', - description: 'Details for the billing address of this account. Maximum size is 40 characters.', + description: + 'Details for the billing address of this account. Maximum size is 40 characters.', }, { displayName: 'Billing Country', name: 'billingCountry', type: 'string', default: '', - description: 'Details for the billing address of this account. Maximum size is 80 characters.', + description: + 'Details for the billing address of this account. Maximum size is 80 characters.', }, { displayName: 'Billing Postal Code', name: 'billingPostalCode', type: 'string', default: '', - description: 'Details for the billing address of this account. Maximum size is 20 characters.', + description: + 'Details for the billing address of this account. Maximum size is 20 characters.', }, { displayName: 'Billing State', name: 'billingState', type: 'string', default: '', - description: 'Details for the billing address of this account. Maximum size is 80 characters.', + description: + 'Details for the billing address of this account. Maximum size is 80 characters.', }, { displayName: 'Billing Street', @@ -511,7 +503,8 @@ export const accountFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -576,7 +569,8 @@ export const accountFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'The owner of the account. Choose from the list, or specify an ID using an expression.', + description: + 'The owner of the account. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Parent ID', @@ -596,7 +590,8 @@ export const accountFields: INodeProperties[] = [ displayName: 'Record Type Name or ID', name: 'recordTypeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getRecordTypes', }, @@ -610,42 +605,48 @@ export const accountFields: INodeProperties[] = [ typeOptions: { alwaysOpenEditWindow: true, }, - description: 'A brief description of an organization’s line of business, based on its SIC code', + description: + 'A brief description of an organization’s line of business, based on its SIC code', }, { displayName: 'Shipping City', name: 'shippingCity', type: 'string', default: '', - description: 'Details of the shipping address for this account. City maximum size is 40 characters.', + description: + 'Details of the shipping address for this account. City maximum size is 40 characters.', }, { displayName: 'Shipping Country', name: 'shippingCountry', type: 'string', default: '', - description: 'Details of the shipping address for this account. Country maximum size is 80 characters.', + description: + 'Details of the shipping address for this account. Country maximum size is 80 characters.', }, { displayName: 'Shipping Postal Code', name: 'shippingPostalCode', type: 'string', default: '', - description: 'Details of the shipping address for this account. Postal code maximum size is 20 characters.', + description: + 'Details of the shipping address for this account. Postal code maximum size is 20 characters.', }, { displayName: 'Shipping State', name: 'shippingState', type: 'string', default: '', - description: 'Details of the shipping address for this account. State maximum size is 80 characters.', + description: + 'Details of the shipping address for this account. State maximum size is 80 characters.', }, { displayName: 'Shipping Street', name: 'shippingStreet', type: 'string', default: '', - description: 'The street address of the shipping address for this account. Maximum of 255 characters.', + description: + 'The street address of the shipping address for this account. Maximum of 255 characters.', }, { displayName: 'Type Name or ID', @@ -655,7 +656,8 @@ export const accountFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getAccountTypes', }, - description: 'Type of account. Choose from the list, or specify an ID using an expression.', + description: + 'Type of account. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Website', @@ -678,12 +680,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'get', - ], + resource: ['account'], + operation: ['get'], }, }, description: 'ID of account that needs to be fetched', @@ -700,12 +698,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'delete', - ], + resource: ['account'], + operation: ['delete'], }, }, description: 'ID of account that needs to be fetched', @@ -720,12 +714,8 @@ export const accountFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getAll', - ], + resource: ['account'], + operation: ['getAll'], }, }, default: false, @@ -737,15 +727,9 @@ export const accountFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['account'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -763,12 +747,8 @@ export const accountFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getAll', - ], + resource: ['account'], + operation: ['getAll'], }, }, options: [ @@ -802,7 +782,8 @@ export const accountFields: INodeProperties[] = [ loadOptionsMethod: 'getAccountFields', }, default: '', - description: 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', + description: + 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Operation', @@ -857,12 +838,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'addNote', - ], + resource: ['account'], + operation: ['addNote'], }, }, description: 'ID of account that needs to be fetched', @@ -875,12 +852,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'addNote', - ], + resource: ['account'], + operation: ['addNote'], }, }, description: 'Title of the note', @@ -893,12 +866,8 @@ export const accountFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'addNote', - ], + resource: ['account'], + operation: ['addNote'], }, }, options: [ @@ -917,7 +886,8 @@ export const accountFields: INodeProperties[] = [ name: 'isPrivate', type: 'boolean', default: false, - description: 'Whether true, only the note owner or a user with the “Modify All Data” permission can view the note or query it via the API', + description: + 'Whether true, only the note owner or a user with the “Modify All Data” permission can view the note or query it via the API', }, { displayName: 'Owner Name or ID', @@ -927,7 +897,8 @@ export const accountFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the user who owns the note. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user who owns the note. Choose from the list, or specify an ID using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/Salesforce/AttachmentDescription.ts b/packages/nodes-base/nodes/Salesforce/AttachmentDescription.ts index 406c65b82d..ab292b866b 100644 --- a/packages/nodes-base/nodes/Salesforce/AttachmentDescription.ts +++ b/packages/nodes-base/nodes/Salesforce/AttachmentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const attachmentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const attachmentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'attachment', - ], + resource: ['attachment'], }, }, options: [ @@ -43,7 +39,7 @@ export const attachmentOperations: INodeProperties[] = [ { name: 'Get Summary', value: 'getSummary', - description: 'Returns an overview of attachment\'s metadata', + description: "Returns an overview of attachment's metadata", action: 'Get an attachment summary', }, { @@ -58,7 +54,6 @@ export const attachmentOperations: INodeProperties[] = [ ]; export const attachmentFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* attachment:create */ /* -------------------------------------------------------------------------- */ @@ -70,12 +65,8 @@ export const attachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'create', - ], + resource: ['attachment'], + operation: ['create'], }, }, }, @@ -87,15 +78,12 @@ export const attachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'create', - ], + resource: ['attachment'], + operation: ['create'], }, }, - description: 'Required. Name of the attached file. Maximum size is 255 characters. Label is File Name.', + description: + 'Required. Name of the attached file. Maximum size is 255 characters. Label is File Name.', }, { displayName: 'Binary Property', @@ -105,12 +93,8 @@ export const attachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'create', - ], + resource: ['attachment'], + operation: ['create'], }, }, placeholder: '', @@ -124,12 +108,8 @@ export const attachmentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'create', - ], + resource: ['attachment'], + operation: ['create'], }, }, options: [ @@ -145,7 +125,8 @@ export const attachmentFields: INodeProperties[] = [ name: 'isPrivate', type: 'boolean', default: false, - description: 'Whether this record is viewable only by the owner and administrators (true) or viewable by all otherwise-allowed users (false)', + description: + 'Whether this record is viewable only by the owner and administrators (true) or viewable by all otherwise-allowed users (false)', }, { displayName: 'Owner Name or ID', @@ -155,7 +136,8 @@ export const attachmentFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the User who owns the attachment. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the User who owns the attachment. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -171,12 +153,8 @@ export const attachmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'update', - ], + resource: ['attachment'], + operation: ['update'], }, }, description: 'ID of attachment that needs to be fetched', @@ -189,12 +167,8 @@ export const attachmentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'update', - ], + resource: ['attachment'], + operation: ['update'], }, }, options: [ @@ -204,7 +178,8 @@ export const attachmentFields: INodeProperties[] = [ type: 'string', default: 'data', placeholder: '', - description: 'Name of the binary property which contains the data for the file to be uploaded', + description: + 'Name of the binary property which contains the data for the file to be uploaded', }, { displayName: 'Description', @@ -218,14 +193,16 @@ export const attachmentFields: INodeProperties[] = [ name: 'isPrivate', type: 'boolean', default: false, - description: 'Whether this record is viewable only by the owner and administrators (true) or viewable by all otherwise-allowed users (false)', + description: + 'Whether this record is viewable only by the owner and administrators (true) or viewable by all otherwise-allowed users (false)', }, { displayName: 'Name', name: 'name', type: 'string', default: '', - description: 'Required. Name of the attached file. Maximum size is 255 characters. Label is File Name.', + description: + 'Required. Name of the attached file. Maximum size is 255 characters. Label is File Name.', }, { displayName: 'Owner Name or ID', @@ -235,7 +212,8 @@ export const attachmentFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the User who owns the attachment. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the User who owns the attachment. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -251,12 +229,8 @@ export const attachmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'get', - ], + resource: ['attachment'], + operation: ['get'], }, }, description: 'ID of attachment that needs to be fetched', @@ -273,12 +247,8 @@ export const attachmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'delete', - ], + resource: ['attachment'], + operation: ['delete'], }, }, description: 'ID of attachment that needs to be fetched', @@ -293,12 +263,8 @@ export const attachmentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'getAll', - ], + resource: ['attachment'], + operation: ['getAll'], }, }, default: false, @@ -310,15 +276,9 @@ export const attachmentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['attachment'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -336,12 +296,8 @@ export const attachmentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'getAll', - ], + resource: ['attachment'], + operation: ['getAll'], }, }, options: [ @@ -368,7 +324,8 @@ export const attachmentFields: INodeProperties[] = [ loadOptionsMethod: 'getAtachmentFields', }, default: '', - description: 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', + description: + 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', }, // eslint-disable-next-line n8n-nodes-base/node-param-operation-without-no-data-expression { diff --git a/packages/nodes-base/nodes/Salesforce/CampaignMemberInterface.ts b/packages/nodes-base/nodes/Salesforce/CampaignMemberInterface.ts index 3b025c0ce9..139bffd4e3 100644 --- a/packages/nodes-base/nodes/Salesforce/CampaignMemberInterface.ts +++ b/packages/nodes-base/nodes/Salesforce/CampaignMemberInterface.ts @@ -1,4 +1,3 @@ - export interface ICampaignMember { CampaignId?: string; ContactId?: string; diff --git a/packages/nodes-base/nodes/Salesforce/CaseDescription.ts b/packages/nodes-base/nodes/Salesforce/CaseDescription.ts index af4ff748e9..56bcf81274 100644 --- a/packages/nodes-base/nodes/Salesforce/CaseDescription.ts +++ b/packages/nodes-base/nodes/Salesforce/CaseDescription.ts @@ -8,9 +8,7 @@ export const caseOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'case', - ], + resource: ['case'], }, }, options: [ @@ -47,7 +45,7 @@ export const caseOperations: INodeProperties[] = [ { name: 'Get Summary', value: 'getSummary', - description: 'Returns an overview of case\'s metadata', + description: "Returns an overview of case's metadata", action: 'Get a case summary', }, { @@ -62,7 +60,6 @@ export const caseOperations: INodeProperties[] = [ ]; export const caseFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* case:create */ /* -------------------------------------------------------------------------- */ @@ -76,16 +73,13 @@ export const caseFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], + resource: ['case'], + operation: ['create'], }, }, default: '', - description: 'The type of case. Choose from the list, or specify an ID using an expression.', + description: + 'The type of case. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Additional Fields', @@ -95,12 +89,8 @@ export const caseFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], + resource: ['case'], + operation: ['create'], }, }, options: [ @@ -141,7 +131,8 @@ export const caseFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -176,7 +167,8 @@ export const caseFields: INodeProperties[] = [ loadOptionsMethod: 'getCaseOrigins', }, default: '', - description: 'The source of the case, such as Email, Phone, or Web. Label is Case Origin. Choose from the list, or specify an ID using an expression.', + description: + 'The source of the case, such as Email, Phone, or Web. Label is Case Origin. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Owner Name or ID', @@ -186,7 +178,8 @@ export const caseFields: INodeProperties[] = [ loadOptionsMethod: 'getCaseOwners', }, default: '', - description: 'The owner of the case. Choose from the list, or specify an ID using an expression.', + description: + 'The owner of the case. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Parent ID', @@ -203,7 +196,8 @@ export const caseFields: INodeProperties[] = [ loadOptionsMethod: 'getCasePriorities', }, default: '', - description: 'The importance or urgency of the case, such as High, Medium, or Low. Choose from the list, or specify an ID using an expression.', + description: + 'The importance or urgency of the case, such as High, Medium, or Low. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Reason Name or ID', @@ -213,13 +207,15 @@ export const caseFields: INodeProperties[] = [ loadOptionsMethod: 'getCaseReasons', }, default: '', - description: 'The reason why the case was created, such as Instructions not clear, or User didn’t attend training. Choose from the list, or specify an ID using an expression.', + description: + 'The reason why the case was created, such as Instructions not clear, or User didn’t attend training. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Record Type Name or ID', name: 'recordTypeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getRecordTypes', }, @@ -233,7 +229,8 @@ export const caseFields: INodeProperties[] = [ loadOptionsMethod: 'getCaseStatuses', }, default: '', - description: 'The status of the case, such as “New,” “Closed,” or “Escalated.” This field directly controls the IsClosed flag. Choose from the list, or specify an ID using an expression.', + description: + 'The status of the case, such as “New,” “Closed,” or “Escalated.” This field directly controls the IsClosed flag. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Subject', @@ -247,28 +244,32 @@ export const caseFields: INodeProperties[] = [ name: 'suppliedCompany', type: 'string', default: '', - description: 'The company name that was entered when the case was created. This field can\'t be updated after the case has been created..', + description: + "The company name that was entered when the case was created. This field can't be updated after the case has been created..", }, { displayName: 'Supplied Email', name: 'suppliedEmail', type: 'string', default: '', - description: 'The email address that was entered when the case was created. This field can\'t be updated after the case has been created.', + description: + "The email address that was entered when the case was created. This field can't be updated after the case has been created.", }, { displayName: 'Supplied Name', name: 'suppliedName', type: 'string', default: '', - description: 'The name that was entered when the case was created. This field can\'t be updated after the case has been created.', + description: + "The name that was entered when the case was created. This field can't be updated after the case has been created.", }, { displayName: 'Supplied Phone', name: 'suppliedPhone', type: 'string', default: '', - description: 'The phone number that was entered when the case was created. This field can\'t be updated after the case has been created.', + description: + "The phone number that was entered when the case was created. This field can't be updated after the case has been created.", }, ], }, @@ -284,12 +285,8 @@ export const caseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'update', - ], + resource: ['case'], + operation: ['update'], }, }, description: 'ID of case that needs to be fetched', @@ -302,12 +299,8 @@ export const caseFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'update', - ], + resource: ['case'], + operation: ['update'], }, }, options: [ @@ -348,7 +341,8 @@ export const caseFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -383,7 +377,8 @@ export const caseFields: INodeProperties[] = [ loadOptionsMethod: 'getCaseOrigins', }, default: '', - description: 'The source of the case, such as Email, Phone, or Web. Label is Case Origin. Choose from the list, or specify an ID using an expression.', + description: + 'The source of the case, such as Email, Phone, or Web. Label is Case Origin. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Owner Name or ID', @@ -393,7 +388,8 @@ export const caseFields: INodeProperties[] = [ loadOptionsMethod: 'getCaseOwners', }, default: '', - description: 'The owner of the case. Choose from the list, or specify an ID using an expression.', + description: + 'The owner of the case. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Parent ID', @@ -410,7 +406,8 @@ export const caseFields: INodeProperties[] = [ loadOptionsMethod: 'getCasePriorities', }, default: '', - description: 'The importance or urgency of the case, such as High, Medium, or Low. Choose from the list, or specify an ID using an expression.', + description: + 'The importance or urgency of the case, such as High, Medium, or Low. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Reason Name or ID', @@ -420,13 +417,15 @@ export const caseFields: INodeProperties[] = [ loadOptionsMethod: 'getCaseReasons', }, default: '', - description: 'The reason why the case was created, such as Instructions not clear, or User didn’t attend training. Choose from the list, or specify an ID using an expression.', + description: + 'The reason why the case was created, such as Instructions not clear, or User didn’t attend training. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Record Type Name or ID', name: 'recordTypeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getRecordTypes', }, @@ -440,7 +439,8 @@ export const caseFields: INodeProperties[] = [ loadOptionsMethod: 'getCaseStatuses', }, default: '', - description: 'The status of the case, such as “New,” “Closed,” or “Escalated.” This field directly controls the IsClosed flag. Choose from the list, or specify an ID using an expression.', + description: + 'The status of the case, such as “New,” “Closed,” or “Escalated.” This field directly controls the IsClosed flag. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Subject', @@ -454,28 +454,32 @@ export const caseFields: INodeProperties[] = [ name: 'suppliedCompany', type: 'string', default: '', - description: 'The company name that was entered when the case was created. This field can\'t be updated after the case has been created..', + description: + "The company name that was entered when the case was created. This field can't be updated after the case has been created..", }, { displayName: 'Supplied Email', name: 'suppliedEmail', type: 'string', default: '', - description: 'The email address that was entered when the case was created. This field can\'t be updated after the case has been created.', + description: + "The email address that was entered when the case was created. This field can't be updated after the case has been created.", }, { displayName: 'Supplied Name', name: 'suppliedName', type: 'string', default: '', - description: 'The name that was entered when the case was created. This field can\'t be updated after the case has been created.', + description: + "The name that was entered when the case was created. This field can't be updated after the case has been created.", }, { displayName: 'Supplied Phone', name: 'suppliedPhone', type: 'string', default: '', - description: 'The phone number that was entered when the case was created. This field can\'t be updated after the case has been created.', + description: + "The phone number that was entered when the case was created. This field can't be updated after the case has been created.", }, { displayName: 'Type Name or ID', @@ -485,7 +489,8 @@ export const caseFields: INodeProperties[] = [ loadOptionsMethod: 'getCaseTypes', }, default: '', - description: 'The type of case. Choose from the list, or specify an ID using an expression.', + description: + 'The type of case. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -501,12 +506,8 @@ export const caseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'get', - ], + resource: ['case'], + operation: ['get'], }, }, description: 'ID of case that needs to be fetched', @@ -523,12 +524,8 @@ export const caseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'delete', - ], + resource: ['case'], + operation: ['delete'], }, }, description: 'ID of case that needs to be fetched', @@ -543,12 +540,8 @@ export const caseFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'getAll', - ], + resource: ['case'], + operation: ['getAll'], }, }, default: false, @@ -560,15 +553,9 @@ export const caseFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['case'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -586,12 +573,8 @@ export const caseFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'getAll', - ], + resource: ['case'], + operation: ['getAll'], }, }, options: [ @@ -618,7 +601,8 @@ export const caseFields: INodeProperties[] = [ loadOptionsMethod: 'getCaseFields', }, default: '', - description: 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', + description: + 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', }, // eslint-disable-next-line n8n-nodes-base/node-param-operation-without-no-data-expression { @@ -680,12 +664,8 @@ export const caseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'addComment', - ], + resource: ['case'], + operation: ['addComment'], }, }, description: 'ID of case that needs to be fetched', @@ -698,12 +678,8 @@ export const caseFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'addComment', - ], + resource: ['case'], + operation: ['addComment'], }, }, options: [ @@ -715,14 +691,16 @@ export const caseFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'Text of the CaseComment. The maximum size of the comment body is 4,000 bytes. Label is Body.', + description: + 'Text of the CaseComment. The maximum size of the comment body is 4,000 bytes. Label is Body.', }, { displayName: 'Is Published', name: 'isPublished', type: 'boolean', default: false, - description: 'Whether the CaseComment is visible to customers in the Self-Service portal (true) or not (false)', + description: + 'Whether the CaseComment is visible to customers in the Self-Service portal (true) or not (false)', }, ], }, diff --git a/packages/nodes-base/nodes/Salesforce/CaseInterface.ts b/packages/nodes-base/nodes/Salesforce/CaseInterface.ts index 76ac5016c9..61f75258af 100644 --- a/packages/nodes-base/nodes/Salesforce/CaseInterface.ts +++ b/packages/nodes-base/nodes/Salesforce/CaseInterface.ts @@ -1,4 +1,3 @@ - export interface ICase { Type?: string; Origin?: string; diff --git a/packages/nodes-base/nodes/Salesforce/ContactDescription.ts b/packages/nodes-base/nodes/Salesforce/ContactDescription.ts index 32a548ca2f..6d46fd52bb 100644 --- a/packages/nodes-base/nodes/Salesforce/ContactDescription.ts +++ b/packages/nodes-base/nodes/Salesforce/ContactDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const contactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contact', - ], + resource: ['contact'], }, }, options: [ @@ -37,7 +33,8 @@ export const contactOperations: INodeProperties[] = [ { name: 'Create or Update', value: 'upsert', - description: 'Create a new contact, or update the current one if it already exists (upsert)', + description: + 'Create a new contact, or update the current one if it already exists (upsert)', action: 'Create or update a contact', }, { @@ -61,7 +58,7 @@ export const contactOperations: INodeProperties[] = [ { name: 'Get Summary', value: 'getSummary', - description: 'Returns an overview of contact\'s metadata', + description: "Returns an overview of contact's metadata", action: 'Get a contact summary', }, { @@ -76,7 +73,6 @@ export const contactOperations: INodeProperties[] = [ ]; export const contactFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* contact:create */ /* -------------------------------------------------------------------------- */ @@ -87,23 +83,18 @@ export const contactFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getExternalIdFields', - loadOptionsDependsOn: [ - 'resource', - ], + loadOptionsDependsOn: ['resource'], }, required: true, default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'upsert', - ], + resource: ['contact'], + operation: ['upsert'], }, }, - description: 'The field to check to see if the contact already exists. Choose from the list, or specify an ID using an expression.', + description: + 'The field to check to see if the contact already exists. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value to Match', @@ -113,15 +104,12 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'upsert', - ], + resource: ['contact'], + operation: ['upsert'], }, }, - description: 'If this value exists in the \'match against\' field, update the contact. Otherwise create a new one.', + description: + "If this value exists in the 'match against' field, update the contact. Otherwise create a new one.", }, { displayName: 'Last Name', @@ -131,13 +119,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['contact'], + operation: ['create', 'upsert'], }, }, description: 'Required. Last name of the contact. Limited to 80 characters.', @@ -150,13 +133,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['contact'], + operation: ['create', 'upsert'], }, }, options: [ @@ -168,7 +146,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getAccounts', }, default: '', - description: 'ID of the account that is the parent of this contact. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the account that is the parent of this contact. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Assistant Name', @@ -214,7 +193,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -254,14 +234,16 @@ export const contactFields: INodeProperties[] = [ name: 'otherPostalCode', type: 'dateTime', default: '', - description: 'If bounce management is activated and an email sent to the contact bounces, the date and time the bounce occurred', + description: + 'If bounce management is activated and an email sent to the contact bounces, the date and time the bounce occurred', }, { displayName: 'Email Bounced Reason', name: 'emailBouncedReason', type: 'string', default: '', - description: 'If bounce management is activated and an email sent to the contact bounces, the reason the bounce occurred', + description: + 'If bounce management is activated and an email sent to the contact bounces, the reason the bounce occurred', }, { displayName: 'Fax', @@ -289,7 +271,8 @@ export const contactFields: INodeProperties[] = [ name: 'jigsaw', type: 'string', default: '', - description: 'References the ID of a contact in Data.com. If a contact has a value in this field, it means that a contact was imported as a contact from Data.com.', + description: + 'References the ID of a contact in Data.com. If a contact has a value in this field, it means that a contact was imported as a contact from Data.com.', }, { displayName: 'Lead Source Name or ID', @@ -299,7 +282,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getLeadSources', }, default: '', - description: 'Source from which the lead was obtained. Choose from the list, or specify an ID using an expression.', + description: + 'Source from which the lead was obtained. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Mailing City', @@ -385,7 +369,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'The owner of the contact. Choose from the list, or specify an ID using an expression.', + description: + 'The owner of the contact. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Phone', @@ -398,7 +383,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Record Type Name or ID', name: 'recordTypeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getRecordTypes', }, @@ -409,7 +395,8 @@ export const contactFields: INodeProperties[] = [ name: 'salutation', type: 'string', default: '', - description: 'Honorific abbreviation, word, or phrase to be used in front of name in greetings, such as Dr. or Mrs.', + description: + 'Honorific abbreviation, word, or phrase to be used in front of name in greetings, such as Dr. or Mrs.', }, { displayName: 'Title', @@ -432,12 +419,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, description: 'ID of contact that needs to be fetched', @@ -450,12 +433,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, options: [ @@ -467,7 +446,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getAccounts', }, default: '', - description: 'ID of the account that is the parent of this contact. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the account that is the parent of this contact. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Assistant Name', @@ -513,7 +493,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -553,14 +534,16 @@ export const contactFields: INodeProperties[] = [ name: 'emailBouncedDate', type: 'dateTime', default: '', - description: 'If bounce management is activated and an email sent to the contact bounces, the date and time the bounce occurred', + description: + 'If bounce management is activated and an email sent to the contact bounces, the date and time the bounce occurred', }, { displayName: 'Email Bounced Reason', name: 'emailBouncedReason', type: 'string', default: '', - description: 'If bounce management is activated and an email sent to the contact bounces, the reason the bounce occurred', + description: + 'If bounce management is activated and an email sent to the contact bounces, the reason the bounce occurred', }, { displayName: 'Fax', @@ -588,7 +571,8 @@ export const contactFields: INodeProperties[] = [ name: 'jigsaw', type: 'string', default: '', - description: 'References the ID of a contact in Data.com. If a contact has a value in this field, it means that a contact was imported as a contact from Data.com.', + description: + 'References the ID of a contact in Data.com. If a contact has a value in this field, it means that a contact was imported as a contact from Data.com.', }, { displayName: 'Last Name', @@ -605,7 +589,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getLeadSources', }, default: '', - description: 'Source from which the lead was obtained. Choose from the list, or specify an ID using an expression.', + description: + 'Source from which the lead was obtained. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Mailing City', @@ -691,7 +676,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'The owner of the contact. Choose from the list, or specify an ID using an expression.', + description: + 'The owner of the contact. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Phone', @@ -704,7 +690,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Record Type Name or ID', name: 'recordTypeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getRecordTypes', }, @@ -715,7 +702,8 @@ export const contactFields: INodeProperties[] = [ name: 'salutation', type: 'string', default: '', - description: 'Honorific abbreviation, word, or phrase to be used in front of name in greetings, such as Dr. or Mrs.', + description: + 'Honorific abbreviation, word, or phrase to be used in front of name in greetings, such as Dr. or Mrs.', }, { displayName: 'Title', @@ -738,12 +726,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], + resource: ['contact'], + operation: ['get'], }, }, description: 'ID of contact that needs to be fetched', @@ -760,12 +744,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'delete', - ], + resource: ['contact'], + operation: ['delete'], }, }, description: 'ID of contact that needs to be fetched', @@ -780,12 +760,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, default: false, @@ -797,15 +773,9 @@ export const contactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['contact'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -823,12 +793,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, options: [ @@ -855,7 +821,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactFields', }, default: '', - description: 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', + description: + 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', }, // eslint-disable-next-line n8n-nodes-base/node-param-operation-without-no-data-expression { @@ -917,12 +884,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'addToCampaign', - ], + resource: ['contact'], + operation: ['addToCampaign'], }, }, description: 'ID of contact that needs to be fetched', @@ -938,15 +901,12 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'addToCampaign', - ], + resource: ['contact'], + operation: ['addToCampaign'], }, }, - description: 'ID of the campaign that needs to be fetched. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the campaign that needs to be fetched. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Options', @@ -956,12 +916,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'addToCampaign', - ], + resource: ['contact'], + operation: ['addToCampaign'], }, }, options: [ @@ -986,12 +942,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'addNote', - ], + resource: ['contact'], + operation: ['addNote'], }, }, description: 'ID of contact that needs to be fetched', @@ -1004,12 +956,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'addNote', - ], + resource: ['contact'], + operation: ['addNote'], }, }, description: 'Title of the note', @@ -1022,12 +970,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'addNote', - ], + resource: ['contact'], + operation: ['addNote'], }, }, options: [ @@ -1046,7 +990,8 @@ export const contactFields: INodeProperties[] = [ name: 'isPrivate', type: 'boolean', default: false, - description: 'Whether only the note owner or a user with the “Modify All Data” permission can view the note or query it via the API', + description: + 'Whether only the note owner or a user with the “Modify All Data” permission can view the note or query it via the API', }, { displayName: 'Owner Name or ID', @@ -1056,7 +1001,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the user who owns the note. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user who owns the note. Choose from the list, or specify an ID using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/Salesforce/CustomObjectDescription.ts b/packages/nodes-base/nodes/Salesforce/CustomObjectDescription.ts index bd12f7c183..c98c04863a 100644 --- a/packages/nodes-base/nodes/Salesforce/CustomObjectDescription.ts +++ b/packages/nodes-base/nodes/Salesforce/CustomObjectDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const customObjectOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const customObjectOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'customObject', - ], + resource: ['customObject'], }, }, options: [ @@ -58,7 +54,6 @@ export const customObjectOperations: INodeProperties[] = [ ]; export const customObjectFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* customObject:create */ /* -------------------------------------------------------------------------- */ @@ -73,16 +68,12 @@ export const customObjectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customObject', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['customObject'], + operation: ['create', 'upsert'], }, }, - description: 'Name of the custom object. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the custom object. Choose from the list, or specify an ID using an expression.', }, { // eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-dynamic-options @@ -91,23 +82,18 @@ export const customObjectFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getExternalIdFields', - loadOptionsDependsOn: [ - 'customObject', - ], + loadOptionsDependsOn: ['customObject'], }, required: true, default: '', displayOptions: { show: { - resource: [ - 'customObject', - ], - operation: [ - 'upsert', - ], + resource: ['customObject'], + operation: ['upsert'], }, }, - description: 'The field to check to see if the object already exists. Choose from the list, or specify an ID using an expression.', + description: + 'The field to check to see if the object already exists. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value to Match', @@ -117,15 +103,12 @@ export const customObjectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customObject', - ], - operation: [ - 'upsert', - ], + resource: ['customObject'], + operation: ['upsert'], }, }, - description: 'If this value exists in the \'match against\' field, update the object. Otherwise create a new one.', + description: + "If this value exists in the 'match against' field, update the object. Otherwise create a new one.", }, { displayName: 'Fields', @@ -137,13 +120,8 @@ export const customObjectFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'customObject', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['customObject'], + operation: ['create', 'upsert'], }, }, description: 'Filter by custom fields', @@ -159,12 +137,11 @@ export const customObjectFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCustomObjectFields', - loadOptionsDependsOn: [ - 'customObject', - ], + loadOptionsDependsOn: ['customObject'], }, default: '', - description: 'The ID of the field. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -192,15 +169,12 @@ export const customObjectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customObject', - ], - operation: [ - 'update', - ], + resource: ['customObject'], + operation: ['update'], }, }, - description: 'Name of the custom object. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the custom object. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Record ID', @@ -210,12 +184,8 @@ export const customObjectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customObject', - ], - operation: [ - 'update', - ], + resource: ['customObject'], + operation: ['update'], }, }, description: 'Record ID to be updated', @@ -232,12 +202,8 @@ export const customObjectFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'customObject', - ], - operation: [ - 'update', - ], + resource: ['customObject'], + operation: ['update'], }, }, options: [ @@ -251,12 +217,11 @@ export const customObjectFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCustomObjectFields', - loadOptionsDependsOn: [ - 'customObject', - ], + loadOptionsDependsOn: ['customObject'], }, default: '', - description: 'The ID of the field. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -284,15 +249,12 @@ export const customObjectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customObject', - ], - operation: [ - 'get', - ], + resource: ['customObject'], + operation: ['get'], }, }, - description: 'Name of the custom object. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the custom object. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Record ID', @@ -302,12 +264,8 @@ export const customObjectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customObject', - ], - operation: [ - 'get', - ], + resource: ['customObject'], + operation: ['get'], }, }, description: 'Record ID to be retrieved', @@ -327,15 +285,12 @@ export const customObjectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customObject', - ], - operation: [ - 'delete', - ], + resource: ['customObject'], + operation: ['delete'], }, }, - description: 'Name of the custom object. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the custom object. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Record ID', @@ -345,12 +300,8 @@ export const customObjectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customObject', - ], - operation: [ - 'delete', - ], + resource: ['customObject'], + operation: ['delete'], }, }, description: 'Record ID to be deleted', @@ -370,15 +321,12 @@ export const customObjectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customObject', - ], - operation: [ - 'getAll', - ], + resource: ['customObject'], + operation: ['getAll'], }, }, - description: 'Name of the custom object. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the custom object. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -386,12 +334,8 @@ export const customObjectFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'customObject', - ], - operation: [ - 'getAll', - ], + resource: ['customObject'], + operation: ['getAll'], }, }, default: false, @@ -403,15 +347,9 @@ export const customObjectFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'customObject', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['customObject'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -429,12 +367,8 @@ export const customObjectFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'customObject', - ], - operation: [ - 'getAll', - ], + resource: ['customObject'], + operation: ['getAll'], }, }, options: [ @@ -459,12 +393,11 @@ export const customObjectFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCustomObjectFields', - loadOptionsDependsOn: [ - 'customObject', - ], + loadOptionsDependsOn: ['customObject'], }, default: '', - description: 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', + description: + 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', }, // eslint-disable-next-line n8n-nodes-base/node-param-operation-without-no-data-expression { @@ -511,12 +444,11 @@ export const customObjectFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getCustomObjectFields', - loadOptionsDependsOn: [ - 'customObject', - ], + loadOptionsDependsOn: ['customObject'], }, default: [], - description: 'Fields to include separated by commas. Choose from the list, or specify IDs using an expression.', + description: + 'Fields to include separated by commas. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -526,13 +458,8 @@ export const customObjectFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'create', - 'upsert', - ], - resource: [ - 'customObject', - ], + operation: ['create', 'upsert'], + resource: ['customObject'], }, }, default: {}, @@ -542,12 +469,11 @@ export const customObjectFields: INodeProperties[] = [ displayName: 'Record Type Name or ID', name: 'recordTypeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getRecordTypes', - loadOptionsDependsOn: [ - 'customObject', - ], + loadOptionsDependsOn: ['customObject'], }, default: '', }, @@ -559,12 +485,8 @@ export const customObjectFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'customObject', - ], + operation: ['update'], + resource: ['customObject'], }, }, default: {}, @@ -574,12 +496,11 @@ export const customObjectFields: INodeProperties[] = [ displayName: 'Record Type Name or ID', name: 'recordTypeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getRecordTypes', - loadOptionsDependsOn: [ - 'customObject', - ], + loadOptionsDependsOn: ['customObject'], }, default: '', }, diff --git a/packages/nodes-base/nodes/Salesforce/DocumentDescription.ts b/packages/nodes-base/nodes/Salesforce/DocumentDescription.ts index 162185f270..7f24fd824d 100644 --- a/packages/nodes-base/nodes/Salesforce/DocumentDescription.ts +++ b/packages/nodes-base/nodes/Salesforce/DocumentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const documentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const documentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'document', - ], + resource: ['document'], }, }, options: [ @@ -28,7 +24,6 @@ export const documentOperations: INodeProperties[] = [ ]; export const documentFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* document:upload */ /* -------------------------------------------------------------------------- */ @@ -40,12 +35,8 @@ export const documentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'upload', - ], + resource: ['document'], + operation: ['upload'], }, }, description: 'Name of the file', @@ -58,12 +49,8 @@ export const documentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'upload', - ], + resource: ['document'], + operation: ['upload'], }, }, placeholder: '', @@ -77,12 +64,8 @@ export const documentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'upload', - ], + resource: ['document'], + operation: ['upload'], }, }, options: [ @@ -92,7 +75,8 @@ export const documentFields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'pdf', - description: 'File extension to use. If none is set, the value from the binary data will be used.', + description: + 'File extension to use. If none is set, the value from the binary data will be used.', }, { displayName: 'Link To Object ID', @@ -109,7 +93,8 @@ export const documentFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the owner of this document. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the owner of this document. Choose from the list, or specify an ID using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/Salesforce/FlowDescription.ts b/packages/nodes-base/nodes/Salesforce/FlowDescription.ts index d0823bb824..840af1201c 100644 --- a/packages/nodes-base/nodes/Salesforce/FlowDescription.ts +++ b/packages/nodes-base/nodes/Salesforce/FlowDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const flowOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const flowOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'flow', - ], + resource: ['flow'], }, }, options: [ @@ -34,7 +30,6 @@ export const flowOperations: INodeProperties[] = [ ]; export const flowFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* flow:getAll */ /* -------------------------------------------------------------------------- */ @@ -44,12 +39,8 @@ export const flowFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'flow', - ], + operation: ['getAll'], + resource: ['flow'], }, }, default: false, @@ -61,15 +52,9 @@ export const flowFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'flow', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['flow'], + returnAll: [false], }, }, typeOptions: { @@ -91,12 +76,8 @@ export const flowFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'flow', - ], - operation: [ - 'invoke', - ], + resource: ['flow'], + operation: ['invoke'], }, }, description: 'Required. API name of the flow.', @@ -108,12 +89,8 @@ export const flowFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'flow', - ], - operation: [ - 'invoke', - ], + resource: ['flow'], + operation: ['invoke'], }, }, description: 'Whether the input variables should be set via the value-key pair UI or JSON/RAW', @@ -124,15 +101,9 @@ export const flowFields: INodeProperties[] = [ type: 'json', displayOptions: { show: { - resource: [ - 'flow', - ], - operation: [ - 'invoke', - ], - jsonParameters: [ - true, - ], + resource: ['flow'], + operation: ['invoke'], + jsonParameters: [true], }, }, default: '', @@ -148,15 +119,9 @@ export const flowFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'flow', - ], - operation: [ - 'invoke', - ], - jsonParameters: [ - false, - ], + resource: ['flow'], + operation: ['invoke'], + jsonParameters: [false], }, }, description: 'The input variable to send', diff --git a/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts b/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts index a01355e336..acba5da91e 100644 --- a/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts @@ -1,28 +1,26 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - INodePropertyOptions, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, INodePropertyOptions, NodeApiError } from 'n8n-workflow'; import moment from 'moment-timezone'; import jwt from 'jsonwebtoken'; -import { - LoggerProxy as Logger -} from 'n8n-workflow'; +import { LoggerProxy as Logger } from 'n8n-workflow'; -export async function salesforceApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function salesforceApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0, 'oAuth2') as string; try { if (authenticationMethod === 'jwt') { @@ -31,8 +29,17 @@ export async function salesforceApiRequest(this: IExecuteFunctions | IExecuteSin const credentials = await this.getCredentials(credentialsType); const response = await getAccessToken.call(this, credentials); const { instance_url, access_token } = response; - const options = getOptions.call(this, method, (uri || endpoint), body, qs, instance_url as string); - Logger.debug(`Authentication for "Salesforce" node is using "jwt". Invoking URI ${options.uri}`); + const options = getOptions.call( + this, + method, + uri || endpoint, + body, + qs, + instance_url as string, + ); + Logger.debug( + `Authentication for "Salesforce" node is using "jwt". Invoking URI ${options.uri}`, + ); options.headers!.Authorization = `Bearer ${access_token}`; Object.assign(options, option); //@ts-ignore @@ -40,9 +47,20 @@ export async function salesforceApiRequest(this: IExecuteFunctions | IExecuteSin } else { // https://help.salesforce.com/articleView?id=remoteaccess_oauth_web_server_flow.htm&type=5 const credentialsType = 'salesforceOAuth2Api'; - const credentials = await this.getCredentials(credentialsType) as { oauthTokenData: { instance_url: string } }; - const options = getOptions.call(this, method, (uri || endpoint), body, qs, credentials.oauthTokenData.instance_url); - Logger.debug(`Authentication for "Salesforce" node is using "OAuth2". Invoking URI ${options.uri}`); + const credentials = (await this.getCredentials(credentialsType)) as { + oauthTokenData: { instance_url: string }; + }; + const options = getOptions.call( + this, + method, + uri || endpoint, + body, + qs, + credentials.oauthTokenData.instance_url, + ); + Logger.debug( + `Authentication for "Salesforce" node is using "OAuth2". Invoking URI ${options.uri}`, + ); Object.assign(options, option); //@ts-ignore return await this.helpers.requestOAuth2.call(this, credentialsType, options); @@ -52,7 +70,16 @@ export async function salesforceApiRequest(this: IExecuteFunctions | IExecuteSin } } -export async function salesforceApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function salesforceApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -62,10 +89,7 @@ export async function salesforceApiRequestAllItems(this: IExecuteFunctions | ILo responseData = await salesforceApiRequest.call(this, method, endpoint, body, query, uri); uri = `${endpoint}/${responseData.nextRecordsUrl?.split('/')?.pop()}`; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData.nextRecordsUrl !== undefined && - responseData.nextRecordsUrl !== null - ); + } while (responseData.nextRecordsUrl !== undefined && responseData.nextRecordsUrl !== null); return returnData; } @@ -79,13 +103,26 @@ export async function salesforceApiRequestAllItems(this: IExecuteFunctions | ILo */ export function sortOptions(options: INodePropertyOptions[]): void { options.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); } -function getOptions(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any, qs: IDataObject, instanceUrl: string): OptionsWithUri { // tslint:disable-line:no-any +function getOptions( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any, + qs: IDataObject, + instanceUrl: string, +): OptionsWithUri { + // tslint:disable-line:no-any const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -105,22 +142,28 @@ function getOptions(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOpt return options; } -function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, credentials: IDataObject): Promise { +function getAccessToken( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + credentials: IDataObject, +): Promise { const now = moment().unix(); - const authUrl = credentials.environment === 'sandbox' ? 'https://test.salesforce.com' : 'https://login.salesforce.com'; + const authUrl = + credentials.environment === 'sandbox' + ? 'https://test.salesforce.com' + : 'https://login.salesforce.com'; const signature = jwt.sign( { - 'iss': credentials.clientId as string, - 'sub': credentials.username as string, - 'aud': authUrl, - 'exp': now + 3 * 60, + iss: credentials.clientId as string, + sub: credentials.username as string, + aud: authUrl, + exp: now + 3 * 60, }, credentials.privateKey as string, { algorithm: 'RS256', header: { - 'alg': 'RS256', + alg: 'RS256', }, }, ); @@ -143,10 +186,15 @@ function getAccessToken(this: IExecuteFunctions | IExecuteSingleFunctions | ILoa } export function getConditions(options: IDataObject) { - const conditions = (options.conditionsUi as IDataObject || {}).conditionValues as IDataObject[]; + const conditions = ((options.conditionsUi as IDataObject) || {}).conditionValues as IDataObject[]; let data = undefined; if (Array.isArray(conditions) && conditions.length !== 0) { - data = conditions.map((condition: IDataObject) => `${condition.field} ${(condition.operation) === 'equal' ? '=' : condition.operation} ${getValue(condition.value)}`); + data = conditions.map( + (condition: IDataObject) => + `${condition.field} ${ + condition.operation === 'equal' ? '=' : condition.operation + } ${getValue(condition.value)}`, + ); data = `WHERE ${data.join(' AND ')}`; } return data; @@ -155,14 +203,14 @@ export function getConditions(options: IDataObject) { export function getDefaultFields(sobject: string) { return ( { - 'Account': 'id,name,type', - 'Lead': 'id,company,firstname,lastname,street,postalCode,city,email,status', - 'Contact': 'id,firstname,lastname,email', - 'Opportunity': 'id,accountId,amount,probability,type', - 'Case': 'id,accountId,contactId,priority,status,subject,type', - 'Task': 'id,subject,status,priority', - 'Attachment': 'id,name', - 'User': 'id,name,email', + Account: 'id,name,type', + Lead: 'id,company,firstname,lastname,street,postalCode,city,email,status', + Contact: 'id,firstname,lastname,email', + Opportunity: 'id,accountId,amount,probability,type', + Case: 'id,accountId,contactId,priority,status,subject,type', + Task: 'id,subject,status,priority', + Attachment: 'id,name', + User: 'id,name,email', } as IDataObject )[sobject]; } @@ -177,20 +225,23 @@ export function getQuery(options: IDataObject, sobject: string, returnAll: boole fields.push.apply(fields, options.fields as string[]); } } else { - fields.push.apply(fields, (getDefaultFields(sobject) as string || 'id').split(',')); + fields.push.apply(fields, ((getDefaultFields(sobject) as string) || 'id').split(',')); } const conditions = getConditions(options); - let query = `SELECT ${fields.join(',')} FROM ${sobject} ${(conditions ? conditions : '')}`; + let query = `SELECT ${fields.join(',')} FROM ${sobject} ${conditions ? conditions : ''}`; if (returnAll === false) { - query = `SELECT ${fields.join(',')} FROM ${sobject} ${(conditions ? conditions : '')} LIMIT ${limit}`; + query = `SELECT ${fields.join(',')} FROM ${sobject} ${ + conditions ? conditions : '' + } LIMIT ${limit}`; } return query; } -export function getValue(value: any) { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function getValue(value: any) { if (moment(value).isValid()) { return value; } else if (typeof value === 'string') { diff --git a/packages/nodes-base/nodes/Salesforce/LeadDescription.ts b/packages/nodes-base/nodes/Salesforce/LeadDescription.ts index ad8529c738..f0c34c159c 100644 --- a/packages/nodes-base/nodes/Salesforce/LeadDescription.ts +++ b/packages/nodes-base/nodes/Salesforce/LeadDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const leadOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const leadOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'lead', - ], + resource: ['lead'], }, }, options: [ @@ -61,7 +57,7 @@ export const leadOperations: INodeProperties[] = [ { name: 'Get Summary', value: 'getSummary', - description: 'Returns an overview of Lead\'s metadata', + description: "Returns an overview of Lead's metadata", action: 'Get a lead summary', }, { @@ -76,7 +72,6 @@ export const leadOperations: INodeProperties[] = [ ]; export const leadFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* lead:create */ /* -------------------------------------------------------------------------- */ @@ -87,23 +82,18 @@ export const leadFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getExternalIdFields', - loadOptionsDependsOn: [ - 'resource', - ], + loadOptionsDependsOn: ['resource'], }, required: true, default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'upsert', - ], + resource: ['lead'], + operation: ['upsert'], }, }, - description: 'The field to check to see if the lead already exists. Choose from the list, or specify an ID using an expression.', + description: + 'The field to check to see if the lead already exists. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value to Match', @@ -113,15 +103,12 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'upsert', - ], + resource: ['lead'], + operation: ['upsert'], }, }, - description: 'If this value exists in the \'match against\' field, update the lead. Otherwise create a new one.', + description: + "If this value exists in the 'match against' field, update the lead. Otherwise create a new one.", }, { displayName: 'Company', @@ -131,16 +118,12 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['lead'], + operation: ['create', 'upsert'], }, }, - description: 'Company of the lead. If person account record types have been enabled, and if the value of Company is null, the lead converts to a person account.', + description: + 'Company of the lead. If person account record types have been enabled, and if the value of Company is null, the lead converts to a person account.', }, { displayName: 'Last Name', @@ -150,13 +133,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['lead'], + operation: ['create', 'upsert'], }, }, description: 'Required. Last name of the lead. Limited to 80 characters.', @@ -169,13 +147,8 @@ export const leadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['lead'], + operation: ['create', 'upsert'], }, }, options: [ @@ -226,7 +199,8 @@ export const leadFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -276,14 +250,16 @@ export const leadFields: INodeProperties[] = [ name: 'IsUnreadByOwner', type: 'boolean', default: false, - description: 'Whether true, lead has been assigned, but not yet viewed. See Unread Leads for more information. Label is Unread By Owner.', + description: + 'Whether true, lead has been assigned, but not yet viewed. See Unread Leads for more information. Label is Unread By Owner.', }, { displayName: 'Jigsaw', name: 'jigsaw', type: 'string', default: '', - description: 'References the ID of a contact in Data.com. If a lead has a value in this field, it means that a contact was imported as a lead from Data.com.', + description: + 'References the ID of a contact in Data.com. If a lead has a value in this field, it means that a contact was imported as a lead from Data.com.', }, { displayName: 'Lead Source Name or ID', @@ -293,7 +269,8 @@ export const leadFields: INodeProperties[] = [ loadOptionsMethod: 'getLeadSources', }, default: '', - description: 'Source from which the lead was obtained. Choose from the list, or specify an ID using an expression.', + description: + 'Source from which the lead was obtained. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Mobile Phone', @@ -317,7 +294,8 @@ export const leadFields: INodeProperties[] = [ loadOptionsMethod: 'getLeadOwners', }, default: '', - description: 'The owner of the lead. Choose from the list, or specify an ID using an expression.', + description: + 'The owner of the lead. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Phone', @@ -337,7 +315,8 @@ export const leadFields: INodeProperties[] = [ displayName: 'Record Type Name or ID', name: 'recordTypeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getRecordTypes', }, @@ -372,7 +351,8 @@ export const leadFields: INodeProperties[] = [ loadOptionsMethod: 'getLeadStatuses', }, default: '', - description: 'Status code for this converted lead. Choose from the list, or specify an ID using an expression.', + description: + 'Status code for this converted lead. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Street', @@ -409,12 +389,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'update', - ], + resource: ['lead'], + operation: ['update'], }, }, description: 'ID of Lead that needs to be fetched', @@ -427,12 +403,8 @@ export const leadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'update', - ], + resource: ['lead'], + operation: ['update'], }, }, options: [ @@ -458,7 +430,8 @@ export const leadFields: INodeProperties[] = [ name: 'company', type: 'string', default: '', - description: 'Company of the lead. If person account record types have been enabled, and if the value of Company is null, the lead converts to a person account.', + description: + 'Company of the lead. If person account record types have been enabled, and if the value of Company is null, the lead converts to a person account.', }, { displayName: 'Country', @@ -490,7 +463,8 @@ export const leadFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -540,14 +514,16 @@ export const leadFields: INodeProperties[] = [ name: 'IsUnreadByOwner', type: 'boolean', default: false, - description: 'Whether true, lead has been assigned, but not yet viewed. See Unread Leads for more information. Label is Unread By Owner.', + description: + 'Whether true, lead has been assigned, but not yet viewed. See Unread Leads for more information. Label is Unread By Owner.', }, { displayName: 'Jigsaw', name: 'jigsaw', type: 'string', default: '', - description: 'References the ID of a contact in Data.com. If a lead has a value in this field, it means that a contact was imported as a lead from Data.com.', + description: + 'References the ID of a contact in Data.com. If a lead has a value in this field, it means that a contact was imported as a lead from Data.com.', }, { displayName: 'Last Name', @@ -564,7 +540,8 @@ export const leadFields: INodeProperties[] = [ loadOptionsMethod: 'getLeadSources', }, default: '', - description: 'Source from which the lead was obtained. Choose from the list, or specify an ID using an expression.', + description: + 'Source from which the lead was obtained. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Mobile Phone', @@ -588,7 +565,8 @@ export const leadFields: INodeProperties[] = [ loadOptionsMethod: 'getLeadOwners', }, default: '', - description: 'The owner of the lead. Choose from the list, or specify an ID using an expression.', + description: + 'The owner of the lead. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Postal Code', @@ -608,7 +586,8 @@ export const leadFields: INodeProperties[] = [ displayName: 'Record Type Name or ID', name: 'recordTypeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getRecordTypes', }, @@ -643,7 +622,8 @@ export const leadFields: INodeProperties[] = [ loadOptionsMethod: 'getLeadStatuses', }, default: '', - description: 'Status code for this converted lead. Choose from the list, or specify an ID using an expression.', + description: + 'Status code for this converted lead. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Street', @@ -680,12 +660,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'get', - ], + resource: ['lead'], + operation: ['get'], }, }, description: 'ID of Lead that needs to be fetched', @@ -702,12 +678,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'delete', - ], + resource: ['lead'], + operation: ['delete'], }, }, description: 'ID of Lead that needs to be fetched', @@ -722,12 +694,8 @@ export const leadFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'getAll', - ], + resource: ['lead'], + operation: ['getAll'], }, }, default: false, @@ -739,15 +707,9 @@ export const leadFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['lead'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -765,12 +727,8 @@ export const leadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'getAll', - ], + resource: ['lead'], + operation: ['getAll'], }, }, options: [ @@ -797,7 +755,8 @@ export const leadFields: INodeProperties[] = [ loadOptionsMethod: 'getLeadFields', }, default: '', - description: 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', + description: + 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', }, // eslint-disable-next-line n8n-nodes-base/node-param-operation-without-no-data-expression { @@ -859,12 +818,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'addToCampaign', - ], + resource: ['lead'], + operation: ['addToCampaign'], }, }, description: 'ID of contact that needs to be fetched', @@ -880,15 +835,12 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'addToCampaign', - ], + resource: ['lead'], + operation: ['addToCampaign'], }, }, - description: 'ID of the campaign that needs to be fetched. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the campaign that needs to be fetched. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Options', @@ -898,12 +850,8 @@ export const leadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'addToCampaign', - ], + resource: ['lead'], + operation: ['addToCampaign'], }, }, options: [ @@ -928,12 +876,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'addNote', - ], + resource: ['lead'], + operation: ['addNote'], }, }, description: 'ID of lead that needs to be fetched', @@ -946,12 +890,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'addNote', - ], + resource: ['lead'], + operation: ['addNote'], }, }, description: 'Title of the note', @@ -964,12 +904,8 @@ export const leadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'addNote', - ], + resource: ['lead'], + operation: ['addNote'], }, }, options: [ @@ -988,7 +924,8 @@ export const leadFields: INodeProperties[] = [ name: 'isPrivate', type: 'boolean', default: false, - description: 'Whether true, only the note owner or a user with the “Modify All Data” permission can view the note or query it via the API', + description: + 'Whether true, only the note owner or a user with the “Modify All Data” permission can view the note or query it via the API', }, { displayName: 'Owner Name or ID', @@ -998,7 +935,8 @@ export const leadFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the user who owns the note. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user who owns the note. Choose from the list, or specify an ID using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/Salesforce/LeadInterface.ts b/packages/nodes-base/nodes/Salesforce/LeadInterface.ts index 2c84fc5852..21fa13ffca 100644 --- a/packages/nodes-base/nodes/Salesforce/LeadInterface.ts +++ b/packages/nodes-base/nodes/Salesforce/LeadInterface.ts @@ -1,6 +1,6 @@ export interface ILead { // tslint:disable-next-line: no-any - [key: string]: any; + [key: string]: any; Company?: string; LastName?: string; Email?: string; diff --git a/packages/nodes-base/nodes/Salesforce/OpportunityDescription.ts b/packages/nodes-base/nodes/Salesforce/OpportunityDescription.ts index 2b124d6acd..78e1ba10d6 100644 --- a/packages/nodes-base/nodes/Salesforce/OpportunityDescription.ts +++ b/packages/nodes-base/nodes/Salesforce/OpportunityDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const opportunityOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const opportunityOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'opportunity', - ], + resource: ['opportunity'], }, }, options: [ @@ -31,7 +27,8 @@ export const opportunityOperations: INodeProperties[] = [ { name: 'Create or Update', value: 'upsert', - description: 'Create a new opportunity, or update the current one if it already exists (upsert)', + description: + 'Create a new opportunity, or update the current one if it already exists (upsert)', action: 'Create or update an opportunity', }, { @@ -55,7 +52,7 @@ export const opportunityOperations: INodeProperties[] = [ { name: 'Get Summary', value: 'getSummary', - description: 'Returns an overview of opportunity\'s metadata', + description: "Returns an overview of opportunity's metadata", action: 'Get an opportunity summary', }, { @@ -70,7 +67,6 @@ export const opportunityOperations: INodeProperties[] = [ ]; export const opportunityFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* opportunity:create */ /* -------------------------------------------------------------------------- */ @@ -81,23 +77,18 @@ export const opportunityFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getExternalIdFields', - loadOptionsDependsOn: [ - 'resource', - ], + loadOptionsDependsOn: ['resource'], }, required: true, default: '', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'upsert', - ], + resource: ['opportunity'], + operation: ['upsert'], }, }, - description: 'The field to check to see if the opportunity already exists. Choose from the list, or specify an ID using an expression.', + description: + 'The field to check to see if the opportunity already exists. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value to Match', @@ -107,15 +98,12 @@ export const opportunityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'upsert', - ], + resource: ['opportunity'], + operation: ['upsert'], }, }, - description: 'If this value exists in the \'match against\' field, update the opportunity. Otherwise create a new one.', + description: + "If this value exists in the 'match against' field, update the opportunity. Otherwise create a new one.", }, { displayName: 'Name', @@ -125,13 +113,8 @@ export const opportunityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['opportunity'], + operation: ['create', 'upsert'], }, }, description: 'Required. Last name of the opportunity. Limited to 80 characters.', @@ -144,13 +127,8 @@ export const opportunityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['opportunity'], + operation: ['create', 'upsert'], }, }, description: 'Required. Date when the opportunity is expected to close.', @@ -166,16 +144,12 @@ export const opportunityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['opportunity'], + operation: ['create', 'upsert'], }, }, - description: 'Required. Date when the opportunity is expected to close. Choose from the list, or specify an ID using an expression.', + description: + 'Required. Date when the opportunity is expected to close. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Additional Fields', @@ -185,13 +159,8 @@ export const opportunityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['opportunity'], + operation: ['create', 'upsert'], }, }, options: [ @@ -203,7 +172,8 @@ export const opportunityFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getAccounts', }, - description: 'ID of the account associated with this opportunity. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the account associated with this opportunity. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Amount', @@ -223,7 +193,8 @@ export const opportunityFields: INodeProperties[] = [ loadOptionsMethod: 'getCampaigns', }, default: '', - description: 'ID of the campaign that needs to be fetched. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the campaign that needs to be fetched. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Custom Fields', @@ -248,7 +219,8 @@ export const opportunityFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -266,7 +238,8 @@ export const opportunityFields: INodeProperties[] = [ name: 'description', type: 'string', default: '', - description: 'A description of the opportunity. Label is Contact Description. Limit: 32 KB.', + description: + 'A description of the opportunity. Label is Contact Description. Limit: 32 KB.', }, { displayName: 'Forecast Category Name', @@ -283,7 +256,8 @@ export const opportunityFields: INodeProperties[] = [ loadOptionsMethod: 'getLeadSources', }, default: '', - description: 'Source from which the lead was obtained. Choose from the list, or specify an ID using an expression.', + description: + 'Source from which the lead was obtained. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Next Step', @@ -300,7 +274,8 @@ export const opportunityFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'The owner of the opportunity. Choose from the list, or specify an ID using an expression.', + description: + 'The owner of the opportunity. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Phone', @@ -341,7 +316,8 @@ export const opportunityFields: INodeProperties[] = [ value: 'New Business', }, ], - description: 'Type of opportunity. For example, Existing Business or New Business. Label is Opportunity Type.', + description: + 'Type of opportunity. For example, Existing Business or New Business. Label is Opportunity Type.', }, ], }, @@ -357,12 +333,8 @@ export const opportunityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'update', - ], + resource: ['opportunity'], + operation: ['update'], }, }, description: 'ID of opportunity that needs to be fetched', @@ -375,12 +347,8 @@ export const opportunityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'update', - ], + resource: ['opportunity'], + operation: ['update'], }, }, options: [ @@ -392,7 +360,8 @@ export const opportunityFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getAccounts', }, - description: 'ID of the account associated with this opportunity. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the account associated with this opportunity. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Amount', @@ -412,7 +381,8 @@ export const opportunityFields: INodeProperties[] = [ loadOptionsMethod: 'getCampaigns', }, default: '', - description: 'ID of the campaign that needs to be fetched. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the campaign that needs to be fetched. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Close Date', @@ -444,7 +414,8 @@ export const opportunityFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -462,7 +433,8 @@ export const opportunityFields: INodeProperties[] = [ name: 'description', type: 'string', default: '', - description: 'A description of the opportunity. Label is Contact Description. Limit: 32 KB.', + description: + 'A description of the opportunity. Label is Contact Description. Limit: 32 KB.', }, { displayName: 'Forecast Category Name', @@ -479,7 +451,8 @@ export const opportunityFields: INodeProperties[] = [ loadOptionsMethod: 'getLeadSources', }, default: '', - description: 'Source from which the lead was obtained. Choose from the list, or specify an ID using an expression.', + description: + 'Source from which the lead was obtained. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Name', @@ -503,7 +476,8 @@ export const opportunityFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'The owner of the opportunity. Choose from the list, or specify an ID using an expression.', + description: + 'The owner of the opportunity. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Phone', @@ -537,7 +511,8 @@ export const opportunityFields: INodeProperties[] = [ loadOptionsMethod: 'getStages', }, default: '', - description: 'Required. Date when the opportunity is expected to close. Choose from the list, or specify an ID using an expression.', + description: + 'Required. Date when the opportunity is expected to close. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Type', @@ -554,7 +529,8 @@ export const opportunityFields: INodeProperties[] = [ value: 'New Business', }, ], - description: 'Type of opportunity. For example, Existing Business or New Business. Label is Opportunity Type.', + description: + 'Type of opportunity. For example, Existing Business or New Business. Label is Opportunity Type.', }, ], }, @@ -570,12 +546,8 @@ export const opportunityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'get', - ], + resource: ['opportunity'], + operation: ['get'], }, }, description: 'ID of opportunity that needs to be fetched', @@ -592,12 +564,8 @@ export const opportunityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'delete', - ], + resource: ['opportunity'], + operation: ['delete'], }, }, description: 'ID of opportunity that needs to be fetched', @@ -612,12 +580,8 @@ export const opportunityFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'getAll', - ], + resource: ['opportunity'], + operation: ['getAll'], }, }, default: false, @@ -629,15 +593,9 @@ export const opportunityFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['opportunity'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -655,12 +613,8 @@ export const opportunityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'getAll', - ], + resource: ['opportunity'], + operation: ['getAll'], }, }, options: [ @@ -687,7 +641,8 @@ export const opportunityFields: INodeProperties[] = [ loadOptionsMethod: 'getOpportunityFields', }, default: '', - description: 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', + description: + 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', }, // eslint-disable-next-line n8n-nodes-base/node-param-operation-without-no-data-expression { @@ -749,12 +704,8 @@ export const opportunityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'addNote', - ], + resource: ['opportunity'], + operation: ['addNote'], }, }, description: 'ID of opportunity that needs to be fetched', @@ -767,12 +718,8 @@ export const opportunityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'addNote', - ], + resource: ['opportunity'], + operation: ['addNote'], }, }, description: 'Title of the note', @@ -785,12 +732,8 @@ export const opportunityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'addNote', - ], + resource: ['opportunity'], + operation: ['addNote'], }, }, options: [ @@ -809,7 +752,8 @@ export const opportunityFields: INodeProperties[] = [ name: 'isPrivate', type: 'boolean', default: false, - description: 'Whether true, only the note owner or a user with the “Modify All Data” permission can view the note or query it via the API', + description: + 'Whether true, only the note owner or a user with the “Modify All Data” permission can view the note or query it via the API', }, { displayName: 'Owner Name or ID', @@ -819,7 +763,8 @@ export const opportunityFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the user who owns the note. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user who owns the note. Choose from the list, or specify an ID using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts b/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts index 8094e0a45b..b91b28ae5f 100644 --- a/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts +++ b/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -13,56 +11,27 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - accountFields, - accountOperations, -} from './AccountDescription'; +import { accountFields, accountOperations } from './AccountDescription'; -import { - IAccount, -} from './AccountInterface'; +import { IAccount } from './AccountInterface'; -import { - attachmentFields, - attachmentOperations, -} from './AttachmentDescription'; +import { attachmentFields, attachmentOperations } from './AttachmentDescription'; -import { - IAttachment, -} from './AttachmentInterface'; +import { IAttachment } from './AttachmentInterface'; -import { - ICampaignMember, -} from './CampaignMemberInterface'; +import { ICampaignMember } from './CampaignMemberInterface'; -import { - caseFields, - caseOperations, -} from './CaseDescription'; +import { caseFields, caseOperations } from './CaseDescription'; -import { - ICase, - ICaseComment, -} from './CaseInterface'; +import { ICase, ICaseComment } from './CaseInterface'; -import { - contactFields, - contactOperations, -} from './ContactDescription'; +import { contactFields, contactOperations } from './ContactDescription'; -import { - IContact, -} from './ContactInterface'; +import { IContact } from './ContactInterface'; -import { - customObjectFields, - customObjectOperations, -} from './CustomObjectDescription'; +import { customObjectFields, customObjectOperations } from './CustomObjectDescription'; -import { - flowFields, - flowOperations, -} from './FlowDescription'; +import { flowFields, flowOperations } from './FlowDescription'; import { getQuery, @@ -71,55 +40,27 @@ import { sortOptions, } from './GenericFunctions'; -import { - leadFields, - leadOperations, -} from './LeadDescription'; +import { leadFields, leadOperations } from './LeadDescription'; -import { - ILead, -} from './LeadInterface'; +import { ILead } from './LeadInterface'; -import { - INote, -} from './NoteInterface'; +import { INote } from './NoteInterface'; -import { - opportunityFields, - opportunityOperations, -} from './OpportunityDescription'; +import { opportunityFields, opportunityOperations } from './OpportunityDescription'; -import { - IOpportunity, -} from './OpportunityInterface'; +import { IOpportunity } from './OpportunityInterface'; -import { - searchFields, - searchOperations, -} from './SearchDescription'; +import { searchFields, searchOperations } from './SearchDescription'; -import { - taskFields, - taskOperations, -} from './TaskDescription'; +import { taskFields, taskOperations } from './TaskDescription'; -import { - ITask, -} from './TaskInterface'; +import { ITask } from './TaskInterface'; -import { - userFields, - userOperations, -} from './UserDescription'; +import { userFields, userOperations } from './UserDescription'; -import { - documentFields, - documentOperations, -} from './DocumentDescription'; +import { documentFields, documentOperations } from './DocumentDescription'; -import { - LoggerProxy as Logger, -} from 'n8n-workflow'; +import { LoggerProxy as Logger } from 'n8n-workflow'; export class Salesforce implements INodeType { description: INodeTypeDescription = { @@ -141,9 +82,7 @@ export class Salesforce implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -152,9 +91,7 @@ export class Salesforce implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'jwt', - ], + authentication: ['jwt'], }, }, }, @@ -186,7 +123,8 @@ export class Salesforce implements INodeType { { name: 'Account', value: 'account', - description: 'Represents an individual account, which is an organization or person involved with your business (such as customers, competitors, and partners)', + description: + 'Represents an individual account, which is an organization or person involved with your business (such as customers, competitors, and partners)', }, { name: 'Attachment', @@ -236,7 +174,8 @@ export class Salesforce implements INodeType { { name: 'Task', value: 'task', - description: 'Represents a business activity such as making a phone call or other to-do items. In the user interface, and records are collectively referred to as activities.', + description: + 'Represents a business activity such as making a phone call or other to-do items. In the user interface, and records are collectively referred to as activities.', }, { name: 'User', @@ -282,7 +221,14 @@ export class Salesforce implements INodeType { const qs = { q: 'SELECT id, MasterLabel FROM LeadStatus', }; - const statuses = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + const statuses = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); for (const status of statuses) { const statusName = status.MasterLabel; returnData.push({ @@ -300,7 +246,14 @@ export class Salesforce implements INodeType { const qs = { q: 'SELECT id, Name FROM User', }; - const users = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + const users = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); for (const user of users) { const userName = user.Name; const userId = user.Id; @@ -317,9 +270,16 @@ export class Salesforce implements INodeType { async getCaseOwners(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const qsQueues = { - q: 'SELECT Queue.Id, Queue.Name FROM QueuesObject where Queue.Type=\'Queue\' and SobjectType = \'Case\'', + q: "SELECT Queue.Id, Queue.Name FROM QueuesObject where Queue.Type='Queue' and SobjectType = 'Case'", }; - const queues = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qsQueues); + const queues = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qsQueues, + ); for (const queue of queues) { const queueName = queue.Queue.Name; const queueId = queue.Queue.Id; @@ -331,7 +291,14 @@ export class Salesforce implements INodeType { const qsUsers = { q: 'SELECT id, Name FROM User', }; - const users = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qsUsers); + const users = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qsUsers, + ); const userPrefix = returnData.length > 0 ? 'User: ' : ''; for (const user of users) { const userName = user.Name; @@ -349,9 +316,16 @@ export class Salesforce implements INodeType { async getLeadOwners(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const qsQueues = { - q: 'SELECT Queue.Id, Queue.Name FROM QueuesObject where Queue.Type=\'Queue\' and SobjectType = \'Lead\'', + q: "SELECT Queue.Id, Queue.Name FROM QueuesObject where Queue.Type='Queue' and SobjectType = 'Lead'", }; - const queues = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qsQueues); + const queues = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qsQueues, + ); for (const queue of queues) { const queueName = queue.Queue.Name; const queueId = queue.Queue.Id; @@ -363,7 +337,14 @@ export class Salesforce implements INodeType { const qsUsers = { q: 'SELECT id, Name FROM User', }; - const users = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qsUsers); + const users = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qsUsers, + ); const userPrefix = returnData.length > 0 ? 'User: ' : ''; for (const user of users) { const userName = user.Name; @@ -404,7 +385,11 @@ export class Salesforce implements INodeType { const returnData: INodePropertyOptions[] = []; const resource = this.getNodeParameter('resource', 0) as string; // TODO: find a way to filter this object to get just the lead sources instead of the whole object - const { fields } = await salesforceApiRequest.call(this, 'GET', `/sobjects/${resource}/describe`); + const { fields } = await salesforceApiRequest.call( + this, + 'GET', + `/sobjects/${resource}/describe`, + ); for (const field of fields) { if (field.custom === true) { const fieldName = field.label; @@ -429,7 +414,14 @@ export class Salesforce implements INodeType { const qs = { q: `SELECT Id, Name, SobjectType, IsActive FROM RecordType WHERE SobjectType = '${resource}'`, }; - const types = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + const types = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); for (const type of types) { if (type.IsActive === true) { returnData.push({ @@ -446,8 +438,15 @@ export class Salesforce implements INodeType { async getExternalIdFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; let resource = this.getCurrentNodeParameter('resource') as string; - resource = (resource === 'customObject') ? this.getCurrentNodeParameter('customObject') as string : resource; - const { fields } = await salesforceApiRequest.call(this, 'GET', `/sobjects/${resource}/describe`); + resource = + resource === 'customObject' + ? (this.getCurrentNodeParameter('customObject') as string) + : resource; + const { fields } = await salesforceApiRequest.call( + this, + 'GET', + `/sobjects/${resource}/describe`, + ); for (const field of fields) { if (field.externalId === true || field.idLookup === true) { const fieldName = field.label; @@ -468,7 +467,14 @@ export class Salesforce implements INodeType { const qs = { q: 'SELECT id, Name FROM Account', }; - const accounts = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + const accounts = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); for (const account of accounts) { const accountName = account.Name; const accountId = account.Id; @@ -487,7 +493,14 @@ export class Salesforce implements INodeType { const qs = { q: 'SELECT id, Name FROM Campaign', }; - const campaigns = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + const campaigns = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); for (const campaign of campaigns) { const campaignName = campaign.Name; const campaignId = campaign.Id; @@ -504,7 +517,11 @@ export class Salesforce implements INodeType { async getStages(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; // TODO: find a way to filter this object to get just the lead sources instead of the whole object - const { fields } = await salesforceApiRequest.call(this, 'GET', '/sobjects/opportunity/describe'); + const { fields } = await salesforceApiRequest.call( + this, + 'GET', + '/sobjects/opportunity/describe', + ); for (const field of fields) { if (field.name === 'StageName') { for (const pickValue of field.picklistValues) { @@ -525,7 +542,11 @@ export class Salesforce implements INodeType { async getAccountTypes(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; // TODO: find a way to filter this object to get just the lead sources instead of the whole object - const { fields } = await salesforceApiRequest.call(this, 'GET', '/sobjects/account/describe'); + const { fields } = await salesforceApiRequest.call( + this, + 'GET', + '/sobjects/account/describe', + ); for (const field of fields) { if (field.name === 'Type') { for (const pickValue of field.picklistValues) { @@ -546,7 +567,11 @@ export class Salesforce implements INodeType { async getAccountSources(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; // TODO: find a way to filter this object to get just the lead sources instead of the whole object - const { fields } = await salesforceApiRequest.call(this, 'GET', '/sobjects/account/describe'); + const { fields } = await salesforceApiRequest.call( + this, + 'GET', + '/sobjects/account/describe', + ); for (const field of fields) { if (field.name === 'AccountSource') { for (const pickValue of field.picklistValues) { @@ -795,7 +820,9 @@ export class Salesforce implements INodeType { }, // Get all the task recurrence instances to display them to user so that he can // select them easily - async getTaskRecurrenceInstances(this: ILoadOptionsFunctions): Promise { + async getTaskRecurrenceInstances( + this: ILoadOptionsFunctions, + ): Promise { const returnData: INodePropertyOptions[] = []; // TODO: find a way to filter this object to get just the lead sources instead of the whole object const { fields } = await salesforceApiRequest.call(this, 'GET', '/sobjects/task/describe'); @@ -841,7 +868,11 @@ export class Salesforce implements INodeType { const returnData: INodePropertyOptions[] = []; // TODO: find a way to filter this object to get just the lead sources instead of the whole object const customObject = this.getCurrentNodeParameter('customObject') as string; - const { fields } = await salesforceApiRequest.call(this, 'GET', `/sobjects/${customObject}/describe`); + const { fields } = await salesforceApiRequest.call( + this, + 'GET', + `/sobjects/${customObject}/describe`, + ); for (const field of fields) { const fieldName = field.label; const fieldId = field.name; @@ -858,7 +889,11 @@ export class Salesforce implements INodeType { async getAccountFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; // TODO: find a way to filter this object to get just the lead sources instead of the whole object - const { fields } = await salesforceApiRequest.call(this, 'GET', `/sobjects/account/describe`); + const { fields } = await salesforceApiRequest.call( + this, + 'GET', + `/sobjects/account/describe`, + ); for (const field of fields) { const fieldName = field.label; const fieldId = field.name; @@ -875,7 +910,11 @@ export class Salesforce implements INodeType { async getAtachmentFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; // TODO: find a way to filter this object to get just the lead sources instead of the whole object - const { fields } = await salesforceApiRequest.call(this, 'GET', `/sobjects/attachment/describe`); + const { fields } = await salesforceApiRequest.call( + this, + 'GET', + `/sobjects/attachment/describe`, + ); for (const field of fields) { const fieldName = field.label; const fieldId = field.name; @@ -926,7 +965,11 @@ export class Salesforce implements INodeType { async getOpportunityFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; // TODO: find a way to filter this object to get just the lead sources instead of the whole object - const { fields } = await salesforceApiRequest.call(this, 'GET', `/sobjects/opportunity/describe`); + const { fields } = await salesforceApiRequest.call( + this, + 'GET', + `/sobjects/opportunity/describe`, + ); for (const field of fields) { const fieldName = field.label; const fieldId = field.name; @@ -977,7 +1020,11 @@ export class Salesforce implements INodeType { async getContactFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; // TODO: find a way to filter this object to get just the lead sources instead of the whole object - const { fields } = await salesforceApiRequest.call(this, 'GET', `/sobjects/contact/describe`); + const { fields } = await salesforceApiRequest.call( + this, + 'GET', + `/sobjects/contact/describe`, + ); for (const field of fields) { const fieldName = field.label; const fieldId = field.name; @@ -1021,7 +1068,9 @@ export class Salesforce implements INodeType { const resource = this.getNodeParameter('resource', 0) as string; const operation = this.getNodeParameter('operation', 0) as string; - Logger.debug(`Running "Salesforce" node named "${this.getNode.name}" resource "${resource}" operation "${operation}"`); + Logger.debug( + `Running "Salesforce" node named "${this.getNode.name}" resource "${resource}" operation "${operation}"`, + ); for (let i = 0; i < items.length; i++) { try { @@ -1105,7 +1154,8 @@ export class Salesforce implements INodeType { body.RecordTypeId = additionalFields.recordTypeId as string; } if (additionalFields.customFieldsUi) { - const customFields = (additionalFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (additionalFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -1132,7 +1182,11 @@ export class Salesforce implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const body: ILead = {}; if (!Object.keys(updateFields).length) { - throw new NodeOperationError(this.getNode(), 'You must add at least one update field', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'You must add at least one update field', + { itemIndex: i }, + ); } if (updateFields.lastname !== undefined) { body.LastName = updateFields.lastname as string; @@ -1210,7 +1264,8 @@ export class Salesforce implements INodeType { body.RecordTypeId = updateFields.recordTypeId as string; } if (updateFields.customFieldsUi) { - const customFields = (updateFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (updateFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -1218,7 +1273,12 @@ export class Salesforce implements INodeType { } } } - responseData = await salesforceApiRequest.call(this, 'PATCH', `/sobjects/lead/${leadId}`, body); + responseData = await salesforceApiRequest.call( + this, + 'PATCH', + `/sobjects/lead/${leadId}`, + body, + ); } //https://developer.salesforce.com/docs/api-explorer/sobject/Lead/get-lead-id if (operation === 'get') { @@ -1232,11 +1292,25 @@ export class Salesforce implements INodeType { try { if (returnAll) { qs.q = getQuery(options, 'Lead', returnAll) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.q = getQuery(options, 'Lead', returnAll, limit) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } } catch (error) { throw new NodeApiError(this.getNode(), error); @@ -1246,7 +1320,11 @@ export class Salesforce implements INodeType { if (operation === 'delete') { const leadId = this.getNodeParameter('leadId', i) as string; try { - responseData = await salesforceApiRequest.call(this, 'DELETE', `/sobjects/lead/${leadId}`); + responseData = await salesforceApiRequest.call( + this, + 'DELETE', + `/sobjects/lead/${leadId}`, + ); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -1267,7 +1345,12 @@ export class Salesforce implements INodeType { if (options.status) { body.Status = options.status as string; } - responseData = await salesforceApiRequest.call(this, 'POST', '/sobjects/CampaignMember', body); + responseData = await salesforceApiRequest.call( + this, + 'POST', + '/sobjects/CampaignMember', + body, + ); } //https://developer.salesforce.com/docs/api-explorer/sobject/Note/post-note if (operation === 'addNote') { @@ -1392,7 +1475,8 @@ export class Salesforce implements INodeType { body.EmailBouncedReason = additionalFields.emailBouncedReason as string; } if (additionalFields.customFieldsUi) { - const customFields = (additionalFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (additionalFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -1419,7 +1503,11 @@ export class Salesforce implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const body: IContact = {}; if (!Object.keys(updateFields).length) { - throw new NodeOperationError(this.getNode(), 'You must add at least one update field', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'You must add at least one update field', + { itemIndex: i }, + ); } if (updateFields.lastName !== undefined) { body.LastName = updateFields.lastName as string; @@ -1518,7 +1606,8 @@ export class Salesforce implements INodeType { body.EmailBouncedReason = updateFields.emailBouncedReason as string; } if (updateFields.customFieldsUi) { - const customFields = (updateFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (updateFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -1526,12 +1615,21 @@ export class Salesforce implements INodeType { } } } - responseData = await salesforceApiRequest.call(this, 'PATCH', `/sobjects/contact/${contactId}`, body); + responseData = await salesforceApiRequest.call( + this, + 'PATCH', + `/sobjects/contact/${contactId}`, + body, + ); } //https://developer.salesforce.com/docs/api-explorer/sobject/Contact/get-contact-id if (operation === 'get') { const contactId = this.getNodeParameter('contactId', i) as string; - responseData = await salesforceApiRequest.call(this, 'GET', `/sobjects/contact/${contactId}`); + responseData = await salesforceApiRequest.call( + this, + 'GET', + `/sobjects/contact/${contactId}`, + ); } //https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm if (operation === 'getAll') { @@ -1540,11 +1638,25 @@ export class Salesforce implements INodeType { try { if (returnAll) { qs.q = getQuery(options, 'Contact', returnAll) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.q = getQuery(options, 'Contact', returnAll, limit) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } } catch (error) { throw new NodeApiError(this.getNode(), error); @@ -1554,7 +1666,11 @@ export class Salesforce implements INodeType { if (operation === 'delete') { const contactId = this.getNodeParameter('contactId', i) as string; try { - responseData = await salesforceApiRequest.call(this, 'DELETE', `/sobjects/contact/${contactId}`); + responseData = await salesforceApiRequest.call( + this, + 'DELETE', + `/sobjects/contact/${contactId}`, + ); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -1575,7 +1691,12 @@ export class Salesforce implements INodeType { if (options.status) { body.Status = options.status as string; } - responseData = await salesforceApiRequest.call(this, 'POST', '/sobjects/CampaignMember', body); + responseData = await salesforceApiRequest.call( + this, + 'POST', + '/sobjects/CampaignMember', + body, + ); } //https://developer.salesforce.com/docs/api-explorer/sobject/Note/post-note if (operation === 'addNote') { @@ -1606,7 +1727,8 @@ export class Salesforce implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body: IDataObject = {}; if (customFieldsUi) { - const customFields = (customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -1640,7 +1762,8 @@ export class Salesforce implements INodeType { body.RecordTypeId = updateFields.recordTypeId as string; } if (customFieldsUi) { - const customFields = (customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -1648,12 +1771,21 @@ export class Salesforce implements INodeType { } } } - responseData = await salesforceApiRequest.call(this, 'PATCH', `/sobjects/${customObject}/${recordId}`, body); + responseData = await salesforceApiRequest.call( + this, + 'PATCH', + `/sobjects/${customObject}/${recordId}`, + body, + ); } if (operation === 'get') { const customObject = this.getNodeParameter('customObject', i) as string; const recordId = this.getNodeParameter('recordId', i) as string; - responseData = await salesforceApiRequest.call(this, 'GET', `/sobjects/${customObject}/${recordId}`); + responseData = await salesforceApiRequest.call( + this, + 'GET', + `/sobjects/${customObject}/${recordId}`, + ); } if (operation === 'getAll') { const customObject = this.getNodeParameter('customObject', i) as string; @@ -1662,11 +1794,25 @@ export class Salesforce implements INodeType { try { if (returnAll) { qs.q = getQuery(options, customObject, returnAll) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.q = getQuery(options, customObject, returnAll, limit) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } } catch (error) { throw new NodeApiError(this.getNode(), error); @@ -1676,7 +1822,11 @@ export class Salesforce implements INodeType { const customObject = this.getNodeParameter('customObject', i) as string; const recordId = this.getNodeParameter('recordId', i) as string; try { - responseData = await salesforceApiRequest.call(this, 'DELETE', `/sobjects/${customObject}/${recordId}`); + responseData = await salesforceApiRequest.call( + this, + 'DELETE', + `/sobjects/${customObject}/${recordId}`, + ); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -1699,13 +1849,16 @@ export class Salesforce implements INodeType { body.entity_content['ownerId'] = additionalFields.ownerId as string; } if (additionalFields.linkToObjectId) { - body.entity_content['FirstPublishLocationId'] = additionalFields.linkToObjectId as string; + body.entity_content['FirstPublishLocationId'] = + additionalFields.linkToObjectId as string; } if (items[i].binary && items[i].binary![binaryPropertyName]) { const binaryData = items[i].binary![binaryPropertyName]; const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); - body.entity_content['PathOnClient'] = `${title}.${additionalFields.fileExtension || binaryData.fileExtension}`; + body.entity_content['PathOnClient'] = `${title}.${ + additionalFields.fileExtension || binaryData.fileExtension + }`; data = { entity_content: { value: JSON.stringify(body.entity_content), @@ -1720,11 +1873,22 @@ export class Salesforce implements INodeType { }, }, }; - } else { - throw new NodeOperationError(this.getNode(), `The property ${binaryPropertyName} does not exist`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The property ${binaryPropertyName} does not exist`, + { itemIndex: i }, + ); } - responseData = await salesforceApiRequest.call(this, 'POST', '/sobjects/ContentVersion', {}, {}, undefined, { formData: data }); + responseData = await salesforceApiRequest.call( + this, + 'POST', + '/sobjects/ContentVersion', + {}, + {}, + undefined, + { formData: data }, + ); } } if (resource === 'opportunity') { @@ -1773,7 +1937,8 @@ export class Salesforce implements INodeType { body.ForecastCategoryName = additionalFields.forecastCategoryName as string; } if (additionalFields.customFieldsUi) { - const customFields = (additionalFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (additionalFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -1842,7 +2007,8 @@ export class Salesforce implements INodeType { body.ForecastCategoryName = updateFields.forecastCategoryName as string; } if (updateFields.customFieldsUi) { - const customFields = (updateFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (updateFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -1850,12 +2016,21 @@ export class Salesforce implements INodeType { } } } - responseData = await salesforceApiRequest.call(this, 'PATCH', `/sobjects/opportunity/${opportunityId}`, body); + responseData = await salesforceApiRequest.call( + this, + 'PATCH', + `/sobjects/opportunity/${opportunityId}`, + body, + ); } //https://developer.salesforce.com/docs/api-explorer/sobject/Opportunity/get-opportunity-id if (operation === 'get') { const opportunityId = this.getNodeParameter('opportunityId', i) as string; - responseData = await salesforceApiRequest.call(this, 'GET', `/sobjects/opportunity/${opportunityId}`); + responseData = await salesforceApiRequest.call( + this, + 'GET', + `/sobjects/opportunity/${opportunityId}`, + ); } //https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm if (operation === 'getAll') { @@ -1864,11 +2039,25 @@ export class Salesforce implements INodeType { try { if (returnAll) { qs.q = getQuery(options, 'Opportunity', returnAll) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.q = getQuery(options, 'Opportunity', returnAll, limit) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } } catch (error) { throw new NodeApiError(this.getNode(), error); @@ -1878,7 +2067,11 @@ export class Salesforce implements INodeType { if (operation === 'delete') { const opportunityId = this.getNodeParameter('opportunityId', i) as string; try { - responseData = await salesforceApiRequest.call(this, 'DELETE', `/sobjects/opportunity/${opportunityId}`); + responseData = await salesforceApiRequest.call( + this, + 'DELETE', + `/sobjects/opportunity/${opportunityId}`, + ); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -1995,7 +2188,8 @@ export class Salesforce implements INodeType { body.RecordTypeId = additionalFields.recordTypeId as string; } if (additionalFields.customFieldsUi) { - const customFields = (additionalFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (additionalFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -2103,7 +2297,8 @@ export class Salesforce implements INodeType { body.ShippingPostalCode = updateFields.shippingPostalCode as string; } if (updateFields.customFieldsUi) { - const customFields = (updateFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (updateFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -2111,12 +2306,21 @@ export class Salesforce implements INodeType { } } } - responseData = await salesforceApiRequest.call(this, 'PATCH', `/sobjects/account/${accountId}`, body); + responseData = await salesforceApiRequest.call( + this, + 'PATCH', + `/sobjects/account/${accountId}`, + body, + ); } //https://developer.salesforce.com/docs/api-explorer/sobject/Account/get-account-id if (operation === 'get') { const accountId = this.getNodeParameter('accountId', i) as string; - responseData = await salesforceApiRequest.call(this, 'GET', `/sobjects/account/${accountId}`); + responseData = await salesforceApiRequest.call( + this, + 'GET', + `/sobjects/account/${accountId}`, + ); } //https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm if (operation === 'getAll') { @@ -2125,11 +2329,25 @@ export class Salesforce implements INodeType { try { if (returnAll) { qs.q = getQuery(options, 'Account', returnAll) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.q = getQuery(options, 'Account', returnAll, limit) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } } catch (error) { throw new NodeApiError(this.getNode(), error); @@ -2139,7 +2357,11 @@ export class Salesforce implements INodeType { if (operation === 'delete') { const accountId = this.getNodeParameter('accountId', i) as string; try { - responseData = await salesforceApiRequest.call(this, 'DELETE', `/sobjects/account/${accountId}`); + responseData = await salesforceApiRequest.call( + this, + 'DELETE', + `/sobjects/account/${accountId}`, + ); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -2226,7 +2448,8 @@ export class Salesforce implements INodeType { body.RecordTypeId = additionalFields.recordTypeId as string; } if (additionalFields.customFieldsUi) { - const customFields = (additionalFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (additionalFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -2293,7 +2516,8 @@ export class Salesforce implements INodeType { body.SuppliedCompany = updateFields.suppliedCompany as string; } if (updateFields.customFieldsUi) { - const customFields = (updateFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (updateFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -2301,7 +2525,12 @@ export class Salesforce implements INodeType { } } } - responseData = await salesforceApiRequest.call(this, 'PATCH', `/sobjects/case/${caseId}`, body); + responseData = await salesforceApiRequest.call( + this, + 'PATCH', + `/sobjects/case/${caseId}`, + body, + ); } //https://developer.salesforce.com/docs/api-explorer/sobject/Case/get-case-id if (operation === 'get') { @@ -2315,11 +2544,25 @@ export class Salesforce implements INodeType { try { if (returnAll) { qs.q = getQuery(options, 'Case', returnAll) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.q = getQuery(options, 'Case', returnAll, limit) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } } catch (error) { throw new NodeApiError(this.getNode(), error); @@ -2329,7 +2572,11 @@ export class Salesforce implements INodeType { if (operation === 'delete') { const caseId = this.getNodeParameter('caseId', i) as string; try { - responseData = await salesforceApiRequest.call(this, 'DELETE', `/sobjects/case/${caseId}`); + responseData = await salesforceApiRequest.call( + this, + 'DELETE', + `/sobjects/case/${caseId}`, + ); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -2351,7 +2598,12 @@ export class Salesforce implements INodeType { if (options.isPublished !== undefined) { body.IsPublished = options.isPublished as boolean; } - responseData = await salesforceApiRequest.call(this, 'POST', '/sobjects/casecomment', body); + responseData = await salesforceApiRequest.call( + this, + 'POST', + '/sobjects/casecomment', + body, + ); } } if (resource === 'task') { @@ -2435,7 +2687,8 @@ export class Salesforce implements INodeType { body.RecurrenceRegeneratedType = additionalFields.recurrenceRegeneratedType as string; } if (additionalFields.customFieldsUi) { - const customFields = (additionalFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (additionalFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -2526,7 +2779,8 @@ export class Salesforce implements INodeType { body.RecurrenceRegeneratedType = updateFields.recurrenceRegeneratedType as string; } if (updateFields.customFieldsUi) { - const customFields = (updateFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (updateFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { //@ts-ignore @@ -2534,7 +2788,12 @@ export class Salesforce implements INodeType { } } } - responseData = await salesforceApiRequest.call(this, 'PATCH', `/sobjects/task/${taskId}`, body); + responseData = await salesforceApiRequest.call( + this, + 'PATCH', + `/sobjects/task/${taskId}`, + body, + ); } //https://developer.salesforce.com/docs/api-explorer/sobject/Task/get-task-id if (operation === 'get') { @@ -2548,11 +2807,25 @@ export class Salesforce implements INodeType { try { if (returnAll) { qs.q = getQuery(options, 'Task', returnAll) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.q = getQuery(options, 'Task', returnAll, limit) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } } catch (error) { throw new NodeApiError(this.getNode(), error); @@ -2562,7 +2835,11 @@ export class Salesforce implements INodeType { if (operation === 'delete') { const taskId = this.getNodeParameter('taskId', i) as string; try { - responseData = await salesforceApiRequest.call(this, 'DELETE', `/sobjects/task/${taskId}`); + responseData = await salesforceApiRequest.call( + this, + 'DELETE', + `/sobjects/task/${taskId}`, + ); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -2587,7 +2864,11 @@ export class Salesforce implements INodeType { body.Body = items[i].binary![binaryPropertyName].data; body.ContentType = items[i].binary![binaryPropertyName].mimeType; } else { - throw new NodeOperationError(this.getNode(), `The property ${binaryPropertyName} does not exist`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The property ${binaryPropertyName} does not exist`, + { itemIndex: i }, + ); } if (additionalFields.description !== undefined) { body.Description = additionalFields.description as string; @@ -2598,7 +2879,12 @@ export class Salesforce implements INodeType { if (additionalFields.isPrivate !== undefined) { body.IsPrivate = additionalFields.isPrivate as boolean; } - responseData = await salesforceApiRequest.call(this, 'POST', '/sobjects/attachment', body); + responseData = await salesforceApiRequest.call( + this, + 'POST', + '/sobjects/attachment', + body, + ); } //https://developer.salesforce.com/docs/api-explorer/sobject/Attachment/patch-attachment-id if (operation === 'update') { @@ -2611,7 +2897,11 @@ export class Salesforce implements INodeType { body.Body = items[i].binary![binaryPropertyName].data; body.ContentType = items[i].binary![binaryPropertyName].mimeType; } else { - throw new NodeOperationError(this.getNode(), `The property ${binaryPropertyName} does not exist`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The property ${binaryPropertyName} does not exist`, + { itemIndex: i }, + ); } } if (updateFields.name !== undefined) { @@ -2626,12 +2916,21 @@ export class Salesforce implements INodeType { if (updateFields.isPrivate !== undefined) { body.IsPrivate = updateFields.isPrivate as boolean; } - responseData = await salesforceApiRequest.call(this, 'PATCH', `/sobjects/attachment/${attachmentId}`, body); + responseData = await salesforceApiRequest.call( + this, + 'PATCH', + `/sobjects/attachment/${attachmentId}`, + body, + ); } //https://developer.salesforce.com/docs/api-explorer/sobject/Attachment/get-attachment-id if (operation === 'get') { const attachmentId = this.getNodeParameter('attachmentId', i) as string; - responseData = await salesforceApiRequest.call(this, 'GET', `/sobjects/attachment/${attachmentId}`); + responseData = await salesforceApiRequest.call( + this, + 'GET', + `/sobjects/attachment/${attachmentId}`, + ); } //https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm if (operation === 'getAll') { @@ -2640,11 +2939,25 @@ export class Salesforce implements INodeType { try { if (returnAll) { qs.q = getQuery(options, 'Attachment', returnAll) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.q = getQuery(options, 'Attachment', returnAll, limit) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } } catch (error) { throw new NodeApiError(this.getNode(), error); @@ -2654,7 +2967,11 @@ export class Salesforce implements INodeType { if (operation === 'delete') { const attachmentId = this.getNodeParameter('attachmentId', i) as string; try { - responseData = await salesforceApiRequest.call(this, 'DELETE', `/sobjects/attachment/${attachmentId}`); + responseData = await salesforceApiRequest.call( + this, + 'DELETE', + `/sobjects/attachment/${attachmentId}`, + ); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -2677,11 +2994,25 @@ export class Salesforce implements INodeType { try { if (returnAll) { qs.q = getQuery(options, 'User', returnAll) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.q = getQuery(options, 'User', returnAll, limit) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } } catch (error) { throw new NodeApiError(this.getNode(), error); @@ -2700,18 +3031,22 @@ export class Salesforce implements INodeType { // Input variables are defined in UI const setInputVariable = this.getNodeParameter('variablesUi', i, {}) as IDataObject; if (setInputVariable!.variablesValues !== undefined) { - for (const inputVariableData of setInputVariable!.variablesValues as IDataObject[]) { + for (const inputVariableData of setInputVariable! + .variablesValues as IDataObject[]) { // @ts-ignore variables[inputVariableData!.name as string] = inputVariableData!.value; } } } const body = { - inputs: [ - variables, - ], + inputs: [variables], }; - responseData = await salesforceApiRequest.call(this, 'POST', `/actions/custom/flow/${apiName}`, body); + responseData = await salesforceApiRequest.call( + this, + 'POST', + `/actions/custom/flow/${apiName}`, + body, + ); } //https://developer.salesforce.com/docs/atlas.en-us.api_action.meta/api_action/actions_obj_flow.htm if (operation === 'getAll') { @@ -2728,7 +3063,14 @@ export class Salesforce implements INodeType { //https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_query.htm if (operation === 'query') { qs.q = this.getNodeParameter('query', i) as string; - responseData = await salesforceApiRequestAllItems.call(this, 'records', 'GET', '/query', {}, qs); + responseData = await salesforceApiRequestAllItems.call( + this, + 'records', + 'GET', + '/query', + {}, + qs, + ); } } if (Array.isArray(responseData)) { @@ -2755,6 +3097,3 @@ export class Salesforce implements INodeType { return [this.helpers.returnJsonArray(returnData)]; } } - - - diff --git a/packages/nodes-base/nodes/Salesforce/SearchDescription.ts b/packages/nodes-base/nodes/Salesforce/SearchDescription.ts index 5cc8dc83d9..c83ac6d520 100644 --- a/packages/nodes-base/nodes/Salesforce/SearchDescription.ts +++ b/packages/nodes-base/nodes/Salesforce/SearchDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const searchOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const searchOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'search', - ], + resource: ['search'], }, }, options: [ @@ -28,7 +24,6 @@ export const searchOperations: INodeProperties[] = [ ]; export const searchFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* search:query */ /* -------------------------------------------------------------------------- */ @@ -40,14 +35,11 @@ export const searchFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'search', - ], - operation: [ - 'query', - ], + resource: ['search'], + operation: ['query'], }, }, - description: 'A SOQL query. An example query parameter string might look like: “SELECT+Name+FROM+MyObject”. If the SOQL query string is invalid, a MALFORMED_QUERY response is returned.', + description: + 'A SOQL query. An example query parameter string might look like: “SELECT+Name+FROM+MyObject”. If the SOQL query string is invalid, a MALFORMED_QUERY response is returned.', }, ]; diff --git a/packages/nodes-base/nodes/Salesforce/TaskDescription.ts b/packages/nodes-base/nodes/Salesforce/TaskDescription.ts index b4c8319401..477d77b428 100644 --- a/packages/nodes-base/nodes/Salesforce/TaskDescription.ts +++ b/packages/nodes-base/nodes/Salesforce/TaskDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const taskOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const taskOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'task', - ], + resource: ['task'], }, }, options: [ @@ -43,7 +39,7 @@ export const taskOperations: INodeProperties[] = [ { name: 'Get Summary', value: 'getSummary', - description: 'Returns an overview of task\'s metadata', + description: "Returns an overview of task's metadata", action: 'Get a task summary', }, { @@ -58,7 +54,6 @@ export const taskOperations: INodeProperties[] = [ ]; export const taskFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* task:create */ /* -------------------------------------------------------------------------- */ @@ -70,18 +65,15 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, typeOptions: { loadOptionsMethod: 'getTaskStatuses', }, - description: 'The current status of the task, such as In Progress or Completed. Choose from the list, or specify an ID using an expression.', + description: + 'The current status of the task, such as In Progress or Completed. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Additional Fields', @@ -91,12 +83,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, options: [ @@ -105,7 +93,8 @@ export const taskFields: INodeProperties[] = [ name: 'activityDate', type: 'dateTime', default: '', - description: 'Represents the due date of the task. This field has a timestamp that is always set to midnight in the Coordinated Universal Time (UTC) time zone.', + description: + 'Represents the due date of the task. This field has a timestamp that is always set to midnight in the Coordinated Universal Time (UTC) time zone.', }, { displayName: 'Call Disposition', @@ -115,14 +104,16 @@ export const taskFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'Represents the result of a given call, for example, “we\'ll call back,” or “call unsuccessful.” Limit is 255 characters. Not subject to field-level security, available for any user in an organization with Salesforce CRM Call Center.', + description: + "Represents the result of a given call, for example, “we'll call back,” or “call unsuccessful.” Limit is 255 characters. Not subject to field-level security, available for any user in an organization with Salesforce CRM Call Center.", }, { displayName: 'Call Duration In Seconds', name: 'callDurationInSeconds', type: 'number', default: '', - description: 'Duration of the call in seconds. Not subject to field-level security, available for any user in an organization with Salesforce CRM Call Center.', + description: + 'Duration of the call in seconds. Not subject to field-level security, available for any user in an organization with Salesforce CRM Call Center.', }, { displayName: 'Call Object', @@ -132,7 +123,8 @@ export const taskFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'Name of a call center. Limit is 255 characters. Not subject to field-level security, available for any user in an organization with Salesforce CRM Call Center.', + description: + 'Name of a call center. Limit is 255 characters. Not subject to field-level security, available for any user in an organization with Salesforce CRM Call Center.', }, { displayName: 'Call Type Name or ID', @@ -142,7 +134,8 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTaskCallTypes', }, - description: 'The type of call being answered: Inbound, Internal, or Outbound. Choose from the list, or specify an ID using an expression.', + description: + 'The type of call being answered: Inbound, Internal, or Outbound. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Custom Fields', @@ -167,7 +160,8 @@ export const taskFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -205,7 +199,8 @@ export const taskFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the User who owns the record. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the User who owns the record. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Priority Name or ID', @@ -215,7 +210,8 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTaskPriorities', }, - description: 'Indicates the importance or urgency of a task, such as high or low. Choose from the list, or specify an ID using an expression.', + description: + 'Indicates the importance or urgency of a task, such as high or low. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Recurrence Type Name or ID', @@ -225,7 +221,8 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTaskRecurrenceTypes', }, - description: 'Recurrence Type of the task. Choose from the list, or specify an ID using an expression.', + description: + 'Recurrence Type of the task. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Recurrence Instance Name or ID', @@ -235,7 +232,8 @@ export const taskFields: INodeProperties[] = [ loadOptionsMethod: 'getTaskRecurrenceInstances', }, default: '', - description: 'The frequency of the recurring task. For example, “2nd” or “3rd.”. Choose from the list, or specify an ID using an expression.', + description: + 'The frequency of the recurring task. For example, “2nd” or “3rd.”. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Recurrence Interval', @@ -256,14 +254,16 @@ export const taskFields: INodeProperties[] = [ name: 'recurrenceDayOfWeekMask', type: 'number', default: '', - description: 'The day or days of the week on which the task repeats. This field contains a bitmask. The values are as follows: Sunday = 1 Monday = 2 Tuesday = 4 Wednesday = 8 Thursday = 16 Friday = 32 Saturday = 64 Multiple days are represented as the sum of their numerical values. For example, Tuesday and Thursday = 4 + 16 = 20.', + description: + 'The day or days of the week on which the task repeats. This field contains a bitmask. The values are as follows: Sunday = 1 Monday = 2 Tuesday = 4 Wednesday = 8 Thursday = 16 Friday = 32 Saturday = 64 Multiple days are represented as the sum of their numerical values. For example, Tuesday and Thursday = 4 + 16 = 20.', }, { displayName: 'Recurrence End Date Only', name: 'recurrenceEndDateOnly', type: 'dateTime', default: '', - description: 'The last date on which the task repeats. This field has a timestamp that is always set to midnight in the Coordinated Universal Time (UTC) time zone.', + description: + 'The last date on which the task repeats. This field has a timestamp that is always set to midnight in the Coordinated Universal Time (UTC) time zone.', }, { displayName: 'Recurrence Month Of Year', @@ -342,28 +342,32 @@ export const taskFields: INodeProperties[] = [ value: 'RecurrenceRegenerated', }, ], - description: 'Represents what triggers a repeating task to repeat. Add this field to a page layout together with the RecurrenceInterval field, which determines the number of days between the triggering date (due date or close date) and the due date of the next repeating task in the series. Label is Repeat This Task.', + description: + 'Represents what triggers a repeating task to repeat. Add this field to a page layout together with the RecurrenceInterval field, which determines the number of days between the triggering date (due date or close date) and the due date of the next repeating task in the series. Label is Repeat This Task.', }, { displayName: 'Recurrence Start Date Only', name: 'recurrenceEndDateOnly', type: 'dateTime', default: '', - description: 'The date when the recurring task begins. Must be a date and time before RecurrenceEndDateOnly.', + description: + 'The date when the recurring task begins. Must be a date and time before RecurrenceEndDateOnly.', }, { displayName: 'Recurrence TimeZone SidKey', name: 'recurrenceTimeZoneSidKey', type: 'string', default: '', - description: 'The time zone associated with the recurring task. For example, “UTC-8:00” for Pacific Standard Time.', + description: + 'The time zone associated with the recurring task. For example, “UTC-8:00” for Pacific Standard Time.', }, { displayName: 'Reminder Date Time', name: 'reminderDateTime', type: 'dateTime', default: '', - description: 'Represents the time when the reminder is scheduled to fire, if IsReminderSet is set to true. If IsReminderSet is set to false, then the user may have deselected the reminder checkbox in the Salesforce user interface, or the reminder has already fired at the time indicated by the value.', + description: + 'Represents the time when the reminder is scheduled to fire, if IsReminderSet is set to true. If IsReminderSet is set to false, then the user may have deselected the reminder checkbox in the Salesforce user interface, or the reminder has already fired at the time indicated by the value.', }, { displayName: 'Subject Name or ID', @@ -373,7 +377,8 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTaskSubjects', }, - description: 'The subject line of the task, such as “Call” or “Send Quote.” Limit: 255 characters. Choose from the list, or specify an ID using an expression.', + description: + 'The subject line of the task, such as “Call” or “Send Quote.” Limit: 255 characters. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Type Name or ID', @@ -383,21 +388,24 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTaskTypes', }, - description: 'Represents Type of the task, such as Call or Meeting. Choose from the list, or specify an ID using an expression.', + description: + 'Represents Type of the task, such as Call or Meeting. Choose from the list, or specify an ID using an expression.', }, { displayName: 'What ID', name: 'whatId', type: 'string', default: '', - description: 'The WhatId represents nonhuman objects such as accounts, opportunities, campaigns, cases, or custom objects. WhatIds are polymorphic. Polymorphic means a WhatId is equivalent to the ID of a related object.', + description: + 'The WhatId represents nonhuman objects such as accounts, opportunities, campaigns, cases, or custom objects. WhatIds are polymorphic. Polymorphic means a WhatId is equivalent to the ID of a related object.', }, { displayName: 'Who ID', name: 'whoId', type: 'string', default: '', - description: 'The WhoId represents a human such as a lead or a contact. WhoIds are polymorphic. Polymorphic means a WhoId is equivalent to a contact’s ID or a lead’s ID.', + description: + 'The WhoId represents a human such as a lead or a contact. WhoIds are polymorphic. Polymorphic means a WhoId is equivalent to a contact’s ID or a lead’s ID.', }, ], }, @@ -413,12 +421,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, description: 'ID of task that needs to be fetched', @@ -431,12 +435,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, options: [ @@ -445,7 +445,8 @@ export const taskFields: INodeProperties[] = [ name: 'activityDate', type: 'dateTime', default: '', - description: 'Represents the due date of the task. This field has a timestamp that is always set to midnight in the Coordinated Universal Time (UTC) time zone.', + description: + 'Represents the due date of the task. This field has a timestamp that is always set to midnight in the Coordinated Universal Time (UTC) time zone.', }, { displayName: 'Call Disposition', @@ -455,14 +456,16 @@ export const taskFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'Represents the result of a given call, for example, “we\'ll call back,” or “call unsuccessful.” Limit is 255 characters. Not subject to field-level security, available for any user in an organization with Salesforce CRM Call Center.', + description: + "Represents the result of a given call, for example, “we'll call back,” or “call unsuccessful.” Limit is 255 characters. Not subject to field-level security, available for any user in an organization with Salesforce CRM Call Center.", }, { displayName: 'Call Duration In Seconds', name: 'callDurationInSeconds', type: 'number', default: '', - description: 'Duration of the call in seconds. Not subject to field-level security, available for any user in an organization with Salesforce CRM Call Center.', + description: + 'Duration of the call in seconds. Not subject to field-level security, available for any user in an organization with Salesforce CRM Call Center.', }, { displayName: 'Call Object', @@ -472,7 +475,8 @@ export const taskFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'Name of a call center. Limit is 255 characters. Not subject to field-level security, available for any user in an organization with Salesforce CRM Call Center.', + description: + 'Name of a call center. Limit is 255 characters. Not subject to field-level security, available for any user in an organization with Salesforce CRM Call Center.', }, { displayName: 'Call Type Name or ID', @@ -482,7 +486,8 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTaskCallTypes', }, - description: 'The type of call being answered: Inbound, Internal, or Outbound. Choose from the list, or specify an ID using an expression.', + description: + 'The type of call being answered: Inbound, Internal, or Outbound. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Custom Fields', @@ -507,7 +512,8 @@ export const taskFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the field to add custom field to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -545,7 +551,8 @@ export const taskFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the User who owns the record. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the User who owns the record. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Priority Name or ID', @@ -555,7 +562,8 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTaskPriorities', }, - description: 'Indicates the importance or urgency of a task, such as high or low. Choose from the list, or specify an ID using an expression.', + description: + 'Indicates the importance or urgency of a task, such as high or low. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Status Name or ID', @@ -565,7 +573,8 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTaskStatuses', }, - description: 'The current status of the task, such as In Progress or Completed. Choose from the list, or specify an ID using an expression.', + description: + 'The current status of the task, such as In Progress or Completed. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Subject Name or ID', @@ -575,7 +584,8 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTaskSubjects', }, - description: 'The subject line of the task, such as “Call” or “Send Quote.” Limit: 255 characters. Choose from the list, or specify an ID using an expression.', + description: + 'The subject line of the task, such as “Call” or “Send Quote.” Limit: 255 characters. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Recurrence Day Of Month', @@ -589,14 +599,16 @@ export const taskFields: INodeProperties[] = [ name: 'recurrenceDayOfWeekMask', type: 'number', default: '', - description: 'The day or days of the week on which the task repeats. This field contains a bitmask. The values are as follows: Sunday = 1 Monday = 2 Tuesday = 4 Wednesday = 8 Thursday = 16 Friday = 32 Saturday = 64. Multiple days are represented as the sum of their numerical values. For example, Tuesday and Thursday = 4 + 16 = 20.', + description: + 'The day or days of the week on which the task repeats. This field contains a bitmask. The values are as follows: Sunday = 1 Monday = 2 Tuesday = 4 Wednesday = 8 Thursday = 16 Friday = 32 Saturday = 64. Multiple days are represented as the sum of their numerical values. For example, Tuesday and Thursday = 4 + 16 = 20.', }, { displayName: 'Recurrence End Date Only', name: 'recurrenceEndDateOnly', type: 'dateTime', default: '', - description: 'The last date on which the task repeats. This field has a timestamp that is always set to midnight in the Coordinated Universal Time (UTC) time zone.', + description: + 'The last date on which the task repeats. This field has a timestamp that is always set to midnight in the Coordinated Universal Time (UTC) time zone.', }, { displayName: 'Recurrence Instance Name or ID', @@ -606,7 +618,8 @@ export const taskFields: INodeProperties[] = [ loadOptionsMethod: 'getTaskRecurrenceInstances', }, default: '', - description: 'The frequency of the recurring task. For example, “2nd” or “3rd.”. Choose from the list, or specify an ID using an expression.', + description: + 'The frequency of the recurring task. For example, “2nd” or “3rd.”. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Recurrence Interval', @@ -678,7 +691,8 @@ export const taskFields: INodeProperties[] = [ name: 'recurrenceEndDateOnly', type: 'dateTime', default: '', - description: 'The date when the recurring task begins. Must be a date and time before RecurrenceEndDateOnly.', + description: + 'The date when the recurring task begins. Must be a date and time before RecurrenceEndDateOnly.', }, { displayName: 'Recurrence Regenerated Type', @@ -699,7 +713,8 @@ export const taskFields: INodeProperties[] = [ value: 'RecurrenceRegenerated', }, ], - description: 'Represents what triggers a repeating task to repeat. Add this field to a page layout together with the RecurrenceInterval field, which determines the number of days between the triggering date (due date or close date) and the due date of the next repeating task in the series. Label is Repeat This Task.', + description: + 'Represents what triggers a repeating task to repeat. Add this field to a page layout together with the RecurrenceInterval field, which determines the number of days between the triggering date (due date or close date) and the due date of the next repeating task in the series. Label is Repeat This Task.', }, { displayName: 'Recurrence Type Name or ID', @@ -709,21 +724,24 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTaskRecurrenceTypes', }, - description: 'Website for the task. Choose from the list, or specify an ID using an expression.', + description: + 'Website for the task. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Recurrence TimeZone SidKey', name: 'recurrenceTimeZoneSidKey', type: 'string', default: '', - description: 'The time zone associated with the recurring task. For example, “UTC-8:00” for Pacific Standard Time.', + description: + 'The time zone associated with the recurring task. For example, “UTC-8:00” for Pacific Standard Time.', }, { displayName: 'Reminder Date Time', name: 'reminderDateTime', type: 'dateTime', default: '', - description: 'Represents the time when the reminder is scheduled to fire, if IsReminderSet is set to true. If IsReminderSet is set to false, then the user may have deselected the reminder checkbox in the Salesforce user interface, or the reminder has already fired at the time indicated by the value.', + description: + 'Represents the time when the reminder is scheduled to fire, if IsReminderSet is set to true. If IsReminderSet is set to false, then the user may have deselected the reminder checkbox in the Salesforce user interface, or the reminder has already fired at the time indicated by the value.', }, { displayName: 'Type Name or ID', @@ -733,21 +751,24 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTaskTypes', }, - description: 'Represents Type of the task, such as Call or Meeting. Choose from the list, or specify an ID using an expression.', + description: + 'Represents Type of the task, such as Call or Meeting. Choose from the list, or specify an ID using an expression.', }, { displayName: 'What ID', name: 'whatId', type: 'string', default: '', - description: 'The WhatId represents nonhuman objects such as accounts, opportunities, campaigns, cases, or custom objects. WhatIds are polymorphic. Polymorphic means a WhatId is equivalent to the ID of a related object.', + description: + 'The WhatId represents nonhuman objects such as accounts, opportunities, campaigns, cases, or custom objects. WhatIds are polymorphic. Polymorphic means a WhatId is equivalent to the ID of a related object.', }, { displayName: 'Who ID', name: 'whoId', type: 'string', default: '', - description: 'The WhoId represents a human such as a lead or a contact. WhoIds are polymorphic. Polymorphic means a WhoId is equivalent to a contact’s ID or a lead’s ID.', + description: + 'The WhoId represents a human such as a lead or a contact. WhoIds are polymorphic. Polymorphic means a WhoId is equivalent to a contact’s ID or a lead’s ID.', }, ], }, @@ -763,12 +784,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'get', - ], + resource: ['task'], + operation: ['get'], }, }, description: 'ID of task that needs to be fetched', @@ -785,12 +802,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'delete', - ], + resource: ['task'], + operation: ['delete'], }, }, description: 'ID of task that needs to be fetched', @@ -805,12 +818,8 @@ export const taskFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, default: false, @@ -822,15 +831,9 @@ export const taskFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['task'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -848,12 +851,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, options: [ @@ -880,7 +879,8 @@ export const taskFields: INodeProperties[] = [ loadOptionsMethod: 'getTaskFields', }, default: '', - description: 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', + description: + 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', }, // eslint-disable-next-line n8n-nodes-base/node-param-operation-without-no-data-expression { diff --git a/packages/nodes-base/nodes/Salesforce/UserDescription.ts b/packages/nodes-base/nodes/Salesforce/UserDescription.ts index 478c6ff73b..0f2d05f96b 100644 --- a/packages/nodes-base/nodes/Salesforce/UserDescription.ts +++ b/packages/nodes-base/nodes/Salesforce/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -34,7 +30,6 @@ export const userOperations: INodeProperties[] = [ ]; export const userFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* user:get */ /* -------------------------------------------------------------------------- */ @@ -46,12 +41,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, description: 'ID of user that needs to be fetched', @@ -66,12 +57,8 @@ export const userFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, default: false, @@ -83,15 +70,9 @@ export const userFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['user'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -109,12 +90,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, options: [ @@ -141,7 +118,8 @@ export const userFields: INodeProperties[] = [ loadOptionsMethod: 'getUserFields', }, default: '', - description: 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', + description: + 'For date, number, or boolean, please use expressions. Choose from the list, or specify an ID using an expression.', }, // eslint-disable-next-line n8n-nodes-base/node-param-operation-without-no-data-expression { diff --git a/packages/nodes-base/nodes/Salesmate/ActivityDescription.ts b/packages/nodes-base/nodes/Salesmate/ActivityDescription.ts index 833146aa64..352757347e 100644 --- a/packages/nodes-base/nodes/Salesmate/ActivityDescription.ts +++ b/packages/nodes-base/nodes/Salesmate/ActivityDescription.ts @@ -8,9 +8,7 @@ export const activityOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'activity', - ], + resource: ['activity'], }, }, options: [ @@ -50,10 +48,9 @@ export const activityOperations: INodeProperties[] = [ ]; export const activityFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* activity:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* activity:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Title', name: 'title', @@ -61,12 +58,8 @@ export const activityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, required: true, @@ -75,19 +68,16 @@ export const activityFields: INodeProperties[] = [ displayName: 'Owner Name or ID', name: 'owner', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getUsers', }, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, required: true, @@ -99,12 +89,8 @@ export const activityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, description: 'This field displays activity type such as call, meeting etc', @@ -116,12 +102,8 @@ export const activityFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, default: false, @@ -135,12 +117,8 @@ export const activityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, options: [ @@ -191,9 +169,9 @@ export const activityFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* activity:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* activity:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'Activity ID', name: 'id', @@ -202,12 +180,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'update', - ], + resource: ['activity'], + operation: ['update'], }, }, }, @@ -217,12 +191,8 @@ export const activityFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'update', - ], + resource: ['activity'], + operation: ['update'], }, }, default: false, @@ -236,12 +206,8 @@ export const activityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'update', - ], + resource: ['activity'], + operation: ['update'], }, }, options: [ @@ -309,11 +275,10 @@ export const activityFields: INodeProperties[] = [ description: 'Whether the activity is completed or not', }, ], - }, -/* -------------------------------------------------------------------------- */ -/* activity:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* activity:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Activity ID', name: 'id', @@ -322,12 +287,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'get', - ], + resource: ['activity'], + operation: ['get'], }, }, }, @@ -337,32 +298,24 @@ export const activityFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'get', - ], + resource: ['activity'], + operation: ['get'], }, }, default: false, description: 'Whether the data should include the fields details', }, -/* -------------------------------------------------------------------------- */ -/* activity:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* activity:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getAll', - ], + resource: ['activity'], + operation: ['getAll'], }, }, default: false, @@ -374,15 +327,9 @@ export const activityFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['activity'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -399,12 +346,8 @@ export const activityFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'activity', - ], + operation: ['getAll'], + resource: ['activity'], }, }, }, @@ -416,12 +359,8 @@ export const activityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getAll', - ], + resource: ['activity'], + operation: ['getAll'], }, }, options: [ @@ -467,15 +406,9 @@ export const activityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'activity', - ], - jsonParameters: [ - true, - ], + operation: ['getAll'], + resource: ['activity'], + jsonParameters: [true], }, }, }, @@ -489,15 +422,9 @@ export const activityFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getAll', - ], - jsonParameters: [ - false, - ], + resource: ['activity'], + operation: ['getAll'], + jsonParameters: [false], }, }, default: {}, @@ -608,9 +535,9 @@ export const activityFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* activity:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* activity:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Activity ID', name: 'id', @@ -619,12 +546,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'delete', - ], + resource: ['activity'], + operation: ['delete'], }, }, description: 'If more than one activity add them separated by ,', diff --git a/packages/nodes-base/nodes/Salesmate/CompanyDescription.ts b/packages/nodes-base/nodes/Salesmate/CompanyDescription.ts index cb34fe7924..e4ac3e2a02 100644 --- a/packages/nodes-base/nodes/Salesmate/CompanyDescription.ts +++ b/packages/nodes-base/nodes/Salesmate/CompanyDescription.ts @@ -8,9 +8,7 @@ export const companyOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'company', - ], + resource: ['company'], }, }, options: [ @@ -50,10 +48,9 @@ export const companyOperations: INodeProperties[] = [ ]; export const companyFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* company:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* company:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Name', name: 'name', @@ -61,12 +58,8 @@ export const companyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], + resource: ['company'], + operation: ['create'], }, }, required: true, @@ -75,19 +68,16 @@ export const companyFields: INodeProperties[] = [ displayName: 'Owner Name or ID', name: 'owner', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getUsers', }, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], + resource: ['company'], + operation: ['create'], }, }, required: true, @@ -98,12 +88,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], + resource: ['company'], + operation: ['create'], }, }, default: false, @@ -117,12 +103,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], + resource: ['company'], + operation: ['create'], }, }, options: [ @@ -230,9 +212,9 @@ export const companyFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* company:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* company:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'Company ID', name: 'id', @@ -241,12 +223,8 @@ export const companyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'update', - ], + resource: ['company'], + operation: ['update'], }, }, }, @@ -256,12 +234,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'update', - ], + resource: ['company'], + operation: ['update'], }, }, default: false, @@ -275,12 +249,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'update', - ], + resource: ['company'], + operation: ['update'], }, }, options: [ @@ -294,7 +264,8 @@ export const companyFields: INodeProperties[] = [ displayName: 'Owner Name or ID', name: 'owner', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getUsers', @@ -403,11 +374,10 @@ export const companyFields: INodeProperties[] = [ default: '', }, ], - }, -/* -------------------------------------------------------------------------- */ -/* company:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* company:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Company ID', name: 'id', @@ -416,12 +386,8 @@ export const companyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'get', - ], + resource: ['company'], + operation: ['get'], }, }, }, @@ -431,32 +397,24 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'get', - ], + resource: ['company'], + operation: ['get'], }, }, default: false, description: 'Whether the data should include the fields details', }, -/* -------------------------------------------------------------------------- */ -/* company:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* company:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], + resource: ['company'], + operation: ['getAll'], }, }, default: false, @@ -468,15 +426,9 @@ export const companyFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['company'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -493,12 +445,8 @@ export const companyFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'company', - ], + operation: ['getAll'], + resource: ['company'], }, }, }, @@ -510,12 +458,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], + resource: ['company'], + operation: ['getAll'], }, }, options: [ @@ -561,15 +505,9 @@ export const companyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'company', - ], - jsonParameters: [ - true, - ], + operation: ['getAll'], + resource: ['company'], + jsonParameters: [true], }, }, }, @@ -583,15 +521,9 @@ export const companyFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], - jsonParameters: [ - false, - ], + resource: ['company'], + operation: ['getAll'], + jsonParameters: [false], }, }, default: {}, @@ -706,9 +638,9 @@ export const companyFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* company:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* company:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Company ID', name: 'id', @@ -717,12 +649,8 @@ export const companyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'delete', - ], + resource: ['company'], + operation: ['delete'], }, }, description: 'If more than one company add them separated by ,', diff --git a/packages/nodes-base/nodes/Salesmate/DealDescription.ts b/packages/nodes-base/nodes/Salesmate/DealDescription.ts index 37ac6dfdf4..e143ec811c 100644 --- a/packages/nodes-base/nodes/Salesmate/DealDescription.ts +++ b/packages/nodes-base/nodes/Salesmate/DealDescription.ts @@ -8,9 +8,7 @@ export const dealOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'deal', - ], + resource: ['deal'], }, }, options: [ @@ -50,10 +48,9 @@ export const dealOperations: INodeProperties[] = [ ]; export const dealFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* deal:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* deal:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Title', name: 'title', @@ -61,12 +58,8 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, required: true, @@ -75,19 +68,16 @@ export const dealFields: INodeProperties[] = [ displayName: 'Owner Name or ID', name: 'owner', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getUsers', }, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, required: true, @@ -102,15 +92,12 @@ export const dealFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, - description: 'Primary contact for the deal. Choose from the list, or specify an ID using an expression.', + description: + 'Primary contact for the deal. Choose from the list, or specify an ID using an expression.', required: true, }, { @@ -126,12 +113,8 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, required: true, @@ -157,12 +140,8 @@ export const dealFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, required: true, @@ -197,12 +176,8 @@ export const dealFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, required: true, @@ -214,12 +189,8 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, required: true, @@ -230,12 +201,8 @@ export const dealFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, default: false, @@ -249,12 +216,8 @@ export const dealFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, options: [ @@ -279,7 +242,8 @@ export const dealFields: INodeProperties[] = [ displayName: 'Primary Company Name or ID', name: 'primaryCompany', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCompanies', }, @@ -346,9 +310,9 @@ export const dealFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* deal:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* deal:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'Deal ID', name: 'id', @@ -357,12 +321,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], + resource: ['deal'], + operation: ['update'], }, }, }, @@ -372,12 +332,8 @@ export const dealFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], + resource: ['deal'], + operation: ['update'], }, }, default: false, @@ -391,12 +347,8 @@ export const dealFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], + resource: ['deal'], + operation: ['update'], }, }, options: [ @@ -410,7 +362,8 @@ export const dealFields: INodeProperties[] = [ displayName: 'Owner Name or ID', name: 'owner', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getUsers', @@ -420,7 +373,8 @@ export const dealFields: INodeProperties[] = [ displayName: 'Primary Contact Name or ID', name: 'primaryContact', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', typeOptions: { loadOptionsMethod: 'getContacts', @@ -513,7 +467,8 @@ export const dealFields: INodeProperties[] = [ displayName: 'Primary Company Name or ID', name: 'primaryCompany', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCompanies', }, @@ -580,9 +535,9 @@ export const dealFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* deal:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* deal:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Deal ID', name: 'id', @@ -591,12 +546,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'get', - ], + resource: ['deal'], + operation: ['get'], }, }, }, @@ -606,32 +557,24 @@ export const dealFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'get', - ], + resource: ['deal'], + operation: ['get'], }, }, default: false, description: 'Whether the data should include the fields details', }, -/* -------------------------------------------------------------------------- */ -/* deal:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* deal:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'getAll', - ], + resource: ['deal'], + operation: ['getAll'], }, }, default: false, @@ -643,15 +586,9 @@ export const dealFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['deal'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -668,12 +605,8 @@ export const dealFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'deal', - ], + operation: ['getAll'], + resource: ['deal'], }, }, }, @@ -685,12 +618,8 @@ export const dealFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'getAll', - ], + resource: ['deal'], + operation: ['getAll'], }, }, options: [ @@ -736,15 +665,9 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'deal', - ], - jsonParameters: [ - true, - ], + operation: ['getAll'], + resource: ['deal'], + jsonParameters: [true], }, }, }, @@ -758,15 +681,9 @@ export const dealFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'getAll', - ], - jsonParameters: [ - false, - ], + resource: ['deal'], + operation: ['getAll'], + jsonParameters: [false], }, }, default: {}, @@ -881,9 +798,9 @@ export const dealFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* deal:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* deal:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Deal ID', name: 'id', @@ -892,12 +809,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'delete', - ], + resource: ['deal'], + operation: ['delete'], }, }, description: 'If more than one deal add them separated by ,', diff --git a/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts b/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts index 359390211c..af4509942b 100644 --- a/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts @@ -6,21 +6,36 @@ import { ILoadOptionsFunctions, IWebhookFunctions, } from 'n8n-core'; -import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function salesmateApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function salesmateApiRequest( + this: + | IHookFunctions + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IWebhookFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('salesmateApi'); const options: OptionsWithUri = { headers: { - 'sessionToken': credentials.sessionToken, + sessionToken: credentials.sessionToken, 'x-linkname': credentials.url, 'Content-Type': 'application/json', }, method, qs, body, - uri: uri ||`https://apis.salesmate.io${resource}`, + uri: uri || `https://apis.salesmate.io${resource}`, json: true, }; if (!Object.keys(body).length) { @@ -33,8 +48,16 @@ export async function salesmateApiRequest(this: IHookFunctions | IExecuteFunctio } } -export async function salesmateApiRequestAllItems(this: IHookFunctions | IExecuteFunctions| ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function salesmateApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -52,8 +75,8 @@ export async function salesmateApiRequestAllItems(this: IHookFunctions | IExecut return returnData; } - -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); @@ -63,7 +86,6 @@ export function validateJSON(json: string | undefined): any { // tslint:disable- return result; } - /** * Converts data from the Salesmate format into a simple object * diff --git a/packages/nodes-base/nodes/Salesmate/Salesmate.node.ts b/packages/nodes-base/nodes/Salesmate/Salesmate.node.ts index 4ae20f7634..749675b462 100644 --- a/packages/nodes-base/nodes/Salesmate/Salesmate.node.ts +++ b/packages/nodes-base/nodes/Salesmate/Salesmate.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, ILoadOptionsFunctions, @@ -16,27 +14,12 @@ import { simplifySalesmateData, validateJSON, } from './GenericFunctions'; -import { - companyFields, - companyOperations, -} from './CompanyDescription'; -import { - activityFields, - activityOperations, -} from './ActivityDescription'; -import { - ICompany, - } from './CompanyInterface'; - import { - IActivity, - } from './ActivityInterface'; - import { - IDeal, - } from './DealInterface'; -import { - dealFields, - dealOperations, - } from './DealDescription'; +import { companyFields, companyOperations } from './CompanyDescription'; +import { activityFields, activityOperations } from './ActivityDescription'; +import { ICompany } from './CompanyInterface'; +import { IActivity } from './ActivityInterface'; +import { IDeal } from './DealInterface'; +import { dealFields, dealOperations } from './DealDescription'; export class Salesmate implements INodeType { description: INodeTypeDescription = { @@ -164,8 +147,8 @@ export class Salesmate implements INodeType { const rawData = this.getNodeParameter('rawData', i) as boolean; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body: ICompany = { - name, - owner, + name, + owner, }; if (additionalFields.website) { body.website = additionalFields.website as string; @@ -280,7 +263,12 @@ export class Salesmate implements INodeType { if (updateFields.tags) { body.tags = updateFields.tags as string; } - responseData = await salesmateApiRequest.call(this, 'PUT', `/v1/companies/${companyId}`, body); + responseData = await salesmateApiRequest.call( + this, + 'PUT', + `/v1/companies/${companyId}`, + body, + ); responseData = responseData.Data; if (!rawData) { delete responseData.detail; @@ -302,8 +290,7 @@ export class Salesmate implements INodeType { const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean; let body: IDataObject = { query: { - group: { - }, + group: {}, }, }; if (options.sortBy) { @@ -314,7 +301,9 @@ export class Salesmate implements INodeType { } if (options.fields) { if ((options.fields as string).trim() === '') { - throw new NodeOperationError(this.getNode(), 'You have to add at least one field', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'You have to add at least one field', { + itemIndex: i, + }); } body.fields = (options.fields as string).split(',') as string[]; } else { @@ -336,7 +325,8 @@ export class Salesmate implements INodeType { } if (!jsonActive) { const filters: IDataObject[] = []; - const filtersUi = (this.getNodeParameter('filters', i) as IDataObject).filtersUi as IDataObject; + const filtersUi = (this.getNodeParameter('filters', i) as IDataObject) + .filtersUi as IDataObject; if (filtersUi && filtersUi.conditions) { const conditions = filtersUi.conditions as IDataObject; if (conditions.conditionsUi) { @@ -364,17 +354,34 @@ export class Salesmate implements INodeType { body = json; } if (returnAll) { - responseData = await salesmateApiRequestAllItems.call(this, 'Data', 'POST', '/v2/companies/search', body, qs); + responseData = await salesmateApiRequestAllItems.call( + this, + 'Data', + 'POST', + '/v2/companies/search', + body, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.rows = limit; - responseData = await salesmateApiRequest.call(this, 'POST', '/v2/companies/search', body, qs); + responseData = await salesmateApiRequest.call( + this, + 'POST', + '/v2/companies/search', + body, + qs, + ); responseData = responseData.Data.data; } } if (operation === 'delete') { const companyId = parseInt(this.getNodeParameter('id', i) as string, 10); - responseData = await salesmateApiRequest.call(this, 'DELETE', `/v1/companies/${companyId}`); + responseData = await salesmateApiRequest.call( + this, + 'DELETE', + `/v1/companies/${companyId}`, + ); } } if (resource === 'activity') { @@ -385,9 +392,9 @@ export class Salesmate implements INodeType { const rawData = this.getNodeParameter('rawData', i) as boolean; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body: IActivity = { - title, - owner, - type, + title, + owner, + type, }; if (additionalFields.dueDate) { body.dueDate = new Date(additionalFields.dueDate as string).getTime(); @@ -445,7 +452,12 @@ export class Salesmate implements INodeType { if (updateFields.tags) { body.tags = updateFields.tags as string; } - responseData = await salesmateApiRequest.call(this, 'PUT', `/v1/activities/${activityId}`, body); + responseData = await salesmateApiRequest.call( + this, + 'PUT', + `/v1/activities/${activityId}`, + body, + ); responseData = responseData.Data; if (!rawData) { delete responseData.detail; @@ -454,7 +466,11 @@ export class Salesmate implements INodeType { if (operation === 'get') { const activityId = this.getNodeParameter('id', i) as string; const rawData = this.getNodeParameter('rawData', i) as boolean; - responseData = await salesmateApiRequest.call(this, 'GET', `/v1/activities/${activityId}`); + responseData = await salesmateApiRequest.call( + this, + 'GET', + `/v1/activities/${activityId}`, + ); responseData = responseData.Data; if (!rawData) { @@ -467,8 +483,7 @@ export class Salesmate implements INodeType { const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean; let body: IDataObject = { query: { - group: { - }, + group: {}, }, }; if (options.sortBy) { @@ -479,7 +494,9 @@ export class Salesmate implements INodeType { } if (options.fields) { if ((options.fields as string).trim() === '') { - throw new NodeOperationError(this.getNode(), 'You have to add at least one field', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'You have to add at least one field', { + itemIndex: i, + }); } body.fields = (options.fields as string).split(',') as string[]; } else { @@ -502,7 +519,8 @@ export class Salesmate implements INodeType { } if (!jsonActive) { const filters: IDataObject[] = []; - const filtersUi = (this.getNodeParameter('filters', i) as IDataObject).filtersUi as IDataObject; + const filtersUi = (this.getNodeParameter('filters', i) as IDataObject) + .filtersUi as IDataObject; if (filtersUi && filtersUi.conditions) { const conditions = filtersUi.conditions as IDataObject; if (conditions.conditionsUi) { @@ -530,17 +548,34 @@ export class Salesmate implements INodeType { body = json; } if (returnAll) { - responseData = await salesmateApiRequestAllItems.call(this, 'Data', 'POST', '/v2/activities/search', body, qs); + responseData = await salesmateApiRequestAllItems.call( + this, + 'Data', + 'POST', + '/v2/activities/search', + body, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.rows = limit; - responseData = await salesmateApiRequest.call(this, 'POST', '/v2/activities/search', body, qs); + responseData = await salesmateApiRequest.call( + this, + 'POST', + '/v2/activities/search', + body, + qs, + ); responseData = responseData.Data.data; } } if (operation === 'delete') { const activityId = this.getNodeParameter('id', i) as string; - responseData = await salesmateApiRequest.call(this, 'DELETE', `/v1/activities/${activityId}`); + responseData = await salesmateApiRequest.call( + this, + 'DELETE', + `/v1/activities/${activityId}`, + ); } } if (resource === 'deal') { @@ -555,13 +590,13 @@ export class Salesmate implements INodeType { const rawData = this.getNodeParameter('rawData', i) as boolean; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body: IDeal = { - title, - owner, - primaryContact, - pipeline, - status, - stage, - currency, + title, + owner, + primaryContact, + pipeline, + status, + stage, + currency, }; if (additionalFields.description) { body.description = additionalFields.description as string; @@ -659,8 +694,7 @@ export class Salesmate implements INodeType { const jsonActive = this.getNodeParameter('jsonParameters', i) as boolean; let body: IDataObject = { query: { - group: { - }, + group: {}, }, }; if (options.sortBy) { @@ -671,7 +705,9 @@ export class Salesmate implements INodeType { } if (options.fields !== undefined) { if ((options.fields as string).trim() === '') { - throw new NodeOperationError(this.getNode(), 'You have to add at least one field', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'You have to add at least one field', { + itemIndex: i, + }); } body.fields = (options.fields as string).split(',') as string[]; } else { @@ -692,7 +728,8 @@ export class Salesmate implements INodeType { } if (!jsonActive) { const filters: IDataObject[] = []; - const filtersUi = (this.getNodeParameter('filters', i) as IDataObject).filtersUi as IDataObject; + const filtersUi = (this.getNodeParameter('filters', i) as IDataObject) + .filtersUi as IDataObject; if (filtersUi && filtersUi.conditions) { const conditions = filtersUi.conditions as IDataObject; if (conditions.conditionsUi) { @@ -720,11 +757,24 @@ export class Salesmate implements INodeType { body = json; } if (returnAll) { - responseData = await salesmateApiRequestAllItems.call(this, 'Data', 'POST', '/v2/deals/search', body, qs); + responseData = await salesmateApiRequestAllItems.call( + this, + 'Data', + 'POST', + '/v2/deals/search', + body, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.rows = limit; - responseData = await salesmateApiRequest.call(this, 'POST', '/v2/deals/search', body, qs); + responseData = await salesmateApiRequest.call( + this, + 'POST', + '/v2/deals/search', + body, + qs, + ); responseData = responseData.Data.data; } } diff --git a/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts b/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts index 528c5a5d0a..ebd14a4b6d 100644 --- a/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts @@ -1,17 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IDataObject, - ILoadOptionsFunctions, - IPollFunctions, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, ILoadOptionsFunctions, IPollFunctions, NodeApiError } from 'n8n-workflow'; import { TDtableMetadataColumns, @@ -20,9 +11,7 @@ import { TEndpointVariableName, } from './types'; -import { - schema, -} from './Schema'; +import { schema } from './Schema'; import { ICredential, @@ -36,8 +25,18 @@ import { import _ from 'lodash'; -export async function seaTableApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, ctx: ICtx, method: string, endpoint: string, body: any = {}, qs: IDataObject = {}, url: string | undefined = undefined, option: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function seaTableApiRequest( + this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, + ctx: ICtx, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + url: string | undefined = undefined, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('seaTableApi'); ctx.credentials = credentials as unknown as ICredential; @@ -71,8 +70,16 @@ export async function seaTableApiRequest(this: IExecuteFunctions | ILoadOptionsF } } -export async function setableApiRequestAllItems(this: IExecuteFunctions | IPollFunctions, ctx: ICtx, propertyName: string, method: string, endpoint: string, body: IDataObject, query?: IDataObject): Promise { // tslint:disable-line:no-any - +export async function setableApiRequestAllItems( + this: IExecuteFunctions | IPollFunctions, + ctx: ICtx, + propertyName: string, + method: string, + endpoint: string, + body: IDataObject, + query?: IDataObject, + // tslint:disable-next-line:no-any +): Promise { if (query === undefined) { query = {}; } @@ -85,7 +92,14 @@ export async function setableApiRequestAllItems(this: IExecuteFunctions | IPollF let responseData; do { - responseData = await seaTableApiRequest.call(this, ctx, method, endpoint, body, query) as unknown as IRow[]; + responseData = (await seaTableApiRequest.call( + this, + ctx, + method, + endpoint, + body, + query, + )) as unknown as IRow[]; //@ts-ignore returnData.push.apply(returnData, responseData[propertyName]); query.start = +query.start + segment; @@ -94,9 +108,19 @@ export async function setableApiRequestAllItems(this: IExecuteFunctions | IPollF return returnData; } - -export async function getTableColumns(this: ILoadOptionsFunctions | IExecuteFunctions | IPollFunctions, tableName: string, ctx: ICtx = {}): Promise { - const { metadata: { tables } } = await seaTableApiRequest.call(this, ctx, 'GET', `/dtable-server/api/v1/dtables/{{dtable_uuid}}/metadata`); +export async function getTableColumns( + this: ILoadOptionsFunctions | IExecuteFunctions | IPollFunctions, + tableName: string, + ctx: ICtx = {}, +): Promise { + const { + metadata: { tables }, + } = await seaTableApiRequest.call( + this, + ctx, + 'GET', + `/dtable-server/api/v1/dtables/{{dtable_uuid}}/metadata`, + ); for (const table of tables) { if (table.name === tableName) { return table.columns; @@ -105,13 +129,26 @@ export async function getTableColumns(this: ILoadOptionsFunctions | IExecuteFunc return []; } -export async function getTableViews(this: ILoadOptionsFunctions | IExecuteFunctions, tableName: string, ctx: ICtx = {}): Promise { - const { views } = await seaTableApiRequest.call(this, ctx, 'GET', `/dtable-server/api/v1/dtables/{{dtable_uuid}}/views`, {}, { table_name: tableName }); +export async function getTableViews( + this: ILoadOptionsFunctions | IExecuteFunctions, + tableName: string, + ctx: ICtx = {}, +): Promise { + const { views } = await seaTableApiRequest.call( + this, + ctx, + 'GET', + `/dtable-server/api/v1/dtables/{{dtable_uuid}}/views`, + {}, + { table_name: tableName }, + ); return views; } -export async function getBaseAccessToken(this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, ctx: ICtx) { - +export async function getBaseAccessToken( + this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, + ctx: ICtx, +) { if (ctx?.base?.access_token !== undefined) { return; } @@ -128,8 +165,9 @@ export async function getBaseAccessToken(this: IExecuteFunctions | ILoadOptionsF } export function resolveBaseUri(ctx: ICtx) { - return (ctx?.credentials?.environment === 'cloudHosted') - ? 'https://cloud.seatable.io' : userBaseUri(ctx?.credentials?.domain); + return ctx?.credentials?.environment === 'cloudHosted' + ? 'https://cloud.seatable.io' + : userBaseUri(ctx?.credentials?.domain); } export function simplify(data: { results: IRow[] }, metadata: IDataObject) { @@ -144,32 +182,37 @@ export function simplify(data: { results: IRow[] }, metadata: IDataObject) { }); } -export function getColumns(data: { metadata: [{ key: string, name: string }] }) { - return data.metadata.reduce((obj, value) => Object.assign(obj, { [`${value.key}`]: value.name }), {}); +export function getColumns(data: { metadata: [{ key: string; name: string }] }) { + return data.metadata.reduce( + (obj, value) => Object.assign(obj, { [`${value.key}`]: value.name }), + {}, + ); } -export function getDownloadableColumns(data: { metadata: [{ key: string, name: string, type: string }] }) { - return data.metadata.filter(row => (['image', 'file'].includes(row.type))).map(row => row.name); +export function getDownloadableColumns(data: { + metadata: [{ key: string; name: string; type: string }]; +}) { + return data.metadata.filter((row) => ['image', 'file'].includes(row.type)).map((row) => row.name); } -const uniquePredicate = (current: string, index: number, all: string[]) => all.indexOf(current) === index; +const uniquePredicate = (current: string, index: number, all: string[]) => + all.indexOf(current) === index; const nonInternalPredicate = (name: string) => !Object.keys(schema.internalNames).includes(name); const namePredicate = (name: string) => (named: IName) => named.name === name; -export const nameOfPredicate = (names: ReadonlyArray) => (name: string) => names.find(namePredicate(name)); +export const nameOfPredicate = (names: ReadonlyArray) => (name: string) => + names.find(namePredicate(name)); export function columnNamesToArray(columnNames: string): string[] { - return columnNames - ? split(columnNames) - .filter(nonInternalPredicate) - .filter(uniquePredicate) - : [] - ; + return columnNames ? split(columnNames).filter(nonInternalPredicate).filter(uniquePredicate) : []; } -export function columnNamesGlob(columnNames: string[], dtableColumns: TDtableMetadataColumns): string[] { +export function columnNamesGlob( + columnNames: string[], + dtableColumns: TDtableMetadataColumns, +): string[] { const buffer: string[] = []; - const names: string[] = dtableColumns.map(c => c.name).filter(nonInternalPredicate); - columnNames.forEach(columnName => { + const names: string[] = dtableColumns.map((c) => c.name).filter(nonInternalPredicate); + columnNames.forEach((columnName) => { if (columnName !== '*') { buffer.push(columnName); return; @@ -190,13 +233,13 @@ export function rowsSequence(rows: IRow[]) { return; } } - for (let i = 0; i < l;) { + for (let i = 0; i < l; ) { rows[i]._seq = ++i; } } export function rowDeleteInternalColumns(row: IRow): IRow { - Object.keys(schema.internalNames).forEach(columnName => delete row[columnName]); + Object.keys(schema.internalNames).forEach((columnName) => delete row[columnName]); return row; } @@ -213,7 +256,7 @@ function rowFormatColumn(input: unknown): boolean | number | string | string[] | return input; } - if (Array.isArray(input) && input.every(i => (typeof i === 'string'))) { + if (Array.isArray(input) && input.every((i) => typeof i === 'string')) { return input; } @@ -242,8 +285,8 @@ export function rowMapKeyToName(row: IRow, columns: TDtableMetadataColumns): IRo }); // pick each by its key for name - Object.keys(row).forEach(key => { - const column = columns.find(c => c.key === key); + Object.keys(row).forEach((key) => { + const column = columns.find((c) => c.key === key); if (column) { mappedRow[column.name] = row[key]; } @@ -278,20 +321,21 @@ function endpointCtxExpr(this: void, ctx: ICtx, endpoint: string): string { endpointVariables.access_token = ctx?.base?.access_token; endpointVariables.dtable_uuid = ctx?.base?.dtable_uuid; - return endpoint.replace(/({{ *(access_token|dtable_uuid|server) *}})/g, (match: string, expr: string, name: TEndpointVariableName) => { - return endpointVariables[name] || match; - }) as TEndpointResolvedExpr; + return endpoint.replace( + /({{ *(access_token|dtable_uuid|server) *}})/g, + (match: string, expr: string, name: TEndpointVariableName) => { + return endpointVariables[name] || match; + }, + ) as TEndpointResolvedExpr; } - -const normalize = (subject: string): string => subject ? subject.normalize() : ''; +const normalize = (subject: string): string => (subject ? subject.normalize() : ''); export const split = (subject: string): string[] => normalize(subject) .split(/\s*((?:[^\\,]*?(?:\\[\s\S])*)*?)\s*(?:,|$)/) - .filter(s => s.length) - .map(s => s.replace(/\\([\s\S])/gm, ($0, $1) => $1)) - ; + .filter((s) => s.length) + .map((s) => s.replace(/\\([\s\S])/gm, ($0, $1) => $1)); const userBaseUri = (uri?: string) => { if (uri === undefined) { diff --git a/packages/nodes-base/nodes/SeaTable/Interfaces.ts b/packages/nodes-base/nodes/SeaTable/Interfaces.ts index d950d98be8..675be34d30 100644 --- a/packages/nodes-base/nodes/SeaTable/Interfaces.ts +++ b/packages/nodes-base/nodes/SeaTable/Interfaces.ts @@ -72,7 +72,6 @@ export interface IName { name: string; } - type TOperation = 'cloudHosted' | 'selfHosted'; export interface ICredential { @@ -91,12 +90,12 @@ export interface ICtx { credentials?: ICredential; } -export interface IRowResponse{ +export interface IRowResponse { metadata: [ { - key: string, - name: string, - } + key: string; + name: string; + }, ]; results: IRow[]; } diff --git a/packages/nodes-base/nodes/SeaTable/RowDescription.ts b/packages/nodes-base/nodes/SeaTable/RowDescription.ts index b5dbc76fdc..a13ec1d372 100644 --- a/packages/nodes-base/nodes/SeaTable/RowDescription.ts +++ b/packages/nodes-base/nodes/SeaTable/RowDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const rowOperations: INodeProperties[] = [ { @@ -61,13 +59,12 @@ export const rowFields: INodeProperties[] = [ }, displayOptions: { hide: { - operation: [ - 'get', - ], + operation: ['get'], }, }, default: '', - description: 'The name of SeaTable table to access. Choose from the list, or specify an ID using an expression.', + description: + 'The name of SeaTable table to access. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Table Name or ID', @@ -80,13 +77,12 @@ export const rowFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], }, }, default: '', - description: 'The name of SeaTable table to access. Choose from the list, or specify an ID using an expression.', + description: + 'The name of SeaTable table to access. Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- @@ -98,9 +94,7 @@ export const rowFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: '', @@ -127,10 +121,7 @@ export const rowFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'create', - 'update', - ], + operation: ['create', 'update'], }, }, default: 'defineBelow', @@ -142,17 +133,13 @@ export const rowFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - 'update', - ], - fieldsToSend: [ - 'autoMapInputData', - ], + operation: ['create', 'update'], + fieldsToSend: ['autoMapInputData'], }, }, default: '', - description: 'List of input properties to avoid sending, separated by commas. Leave empty to send all properties.', + description: + 'List of input properties to avoid sending, separated by commas. Leave empty to send all properties.', placeholder: 'Enter properties...', }, { @@ -173,11 +160,10 @@ export const rowFields: INodeProperties[] = [ displayName: 'Column Name or ID', name: 'columnName', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'table', - ], + loadOptionsDependsOn: ['table'], loadOptionsMethod: 'getTableUpdateAbleColumns', }, default: '', @@ -193,13 +179,8 @@ export const rowFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'create', - 'update', - ], - fieldsToSend: [ - 'defineBelow', - ], + operation: ['create', 'update'], + fieldsToSend: ['defineBelow'], }, }, default: {}, @@ -214,9 +195,7 @@ export const rowFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], }, }, default: '', @@ -231,9 +210,7 @@ export const rowFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], }, }, default: '', @@ -248,9 +225,7 @@ export const rowFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, default: true, @@ -262,12 +237,8 @@ export const rowFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -285,9 +256,7 @@ export const rowFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, options: [ @@ -295,7 +264,8 @@ export const rowFields: INodeProperties[] = [ displayName: 'View Name or ID', name: 'view_name', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getViews', }, @@ -311,9 +281,7 @@ export const rowFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, options: [ @@ -322,7 +290,8 @@ export const rowFields: INodeProperties[] = [ name: 'convert_link_id', type: 'boolean', default: false, - description: 'Whether the link column in the returned row is the ID of the linked row or the name of the linked row', + description: + 'Whether the link column in the returned row is the ID of the linked row or the name of the linked row', }, { displayName: 'Direction', @@ -350,7 +319,8 @@ export const rowFields: INodeProperties[] = [ loadOptionsMethod: 'getAllSortableColumns', }, default: '', - description: 'A column\'s name or ID, use this column to sort the rows. Choose from the list, or specify an ID using an expression.', + description: + 'A column\'s name or ID, use this column to sort the rows. Choose from the list, or specify an ID using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/SeaTable/Schema.ts b/packages/nodes-base/nodes/SeaTable/Schema.ts index 50eec9d26e..b8d4518b24 100644 --- a/packages/nodes-base/nodes/SeaTable/Schema.ts +++ b/packages/nodes-base/nodes/SeaTable/Schema.ts @@ -1,49 +1,49 @@ -import {TColumnType, TDateTimeFormat, TInheritColumnKey} from './types'; +import { TColumnType, TDateTimeFormat, TInheritColumnKey } from './types'; export type ColumnType = keyof typeof schema.columnTypes; export const schema = { - rowFetchSegmentLimit: 1000, - dateTimeFormat: 'YYYY-MM-DDTHH:mm:ss.SSSZ', - internalNames: { - '_id': 'text', - '_creator': 'creator', - '_ctime': 'ctime', - '_last_modifier': 'last-modifier', - '_mtime': 'mtime', - '_seq': 'auto-number', - }, - columnTypes: { - text: 'Text', - 'long-text': 'Long Text', - number: 'Number', - collaborator: 'Collaborator', - date: 'Date', - duration: 'Duration', - 'single-select': 'Single Select', - 'multiple-select': 'Multiple Select', - email: 'Email', - url: 'URL', - 'rate': 'Rating', - checkbox: 'Checkbox', - formula: 'Formula', - creator: 'Creator', - ctime: 'Created time', - 'last-modifier': 'Last Modifier', - mtime: 'Last modified time', - 'auto-number': 'Auto number', - }, - nonUpdateAbleColumnTypes: { - 'creator': 'creator', - 'ctime': 'ctime', - 'last-modifier': 'last-modifier', - 'mtime': 'mtime', - 'auto-number': 'auto-number', - }, + rowFetchSegmentLimit: 1000, + dateTimeFormat: 'YYYY-MM-DDTHH:mm:ss.SSSZ', + internalNames: { + _id: 'text', + _creator: 'creator', + _ctime: 'ctime', + _last_modifier: 'last-modifier', + _mtime: 'mtime', + _seq: 'auto-number', + }, + columnTypes: { + text: 'Text', + 'long-text': 'Long Text', + number: 'Number', + collaborator: 'Collaborator', + date: 'Date', + duration: 'Duration', + 'single-select': 'Single Select', + 'multiple-select': 'Multiple Select', + email: 'Email', + url: 'URL', + rate: 'Rating', + checkbox: 'Checkbox', + formula: 'Formula', + creator: 'Creator', + ctime: 'Created time', + 'last-modifier': 'Last Modifier', + mtime: 'Last modified time', + 'auto-number': 'Auto number', + }, + nonUpdateAbleColumnTypes: { + creator: 'creator', + ctime: 'ctime', + 'last-modifier': 'last-modifier', + mtime: 'mtime', + 'auto-number': 'auto-number', + }, } as { - rowFetchSegmentLimit: number, - dateTimeFormat: TDateTimeFormat, - internalNames: { [key in TInheritColumnKey]: ColumnType } - columnTypes: { [key in TColumnType]: string } - nonUpdateAbleColumnTypes: { [key in ColumnType]: ColumnType } + rowFetchSegmentLimit: number; + dateTimeFormat: TDateTimeFormat; + internalNames: { [key in TInheritColumnKey]: ColumnType }; + columnTypes: { [key in TColumnType]: string }; + nonUpdateAbleColumnTypes: { [key in ColumnType]: ColumnType }; }; diff --git a/packages/nodes-base/nodes/SeaTable/SeaTable.node.ts b/packages/nodes-base/nodes/SeaTable/SeaTable.node.ts index e4f922a5cc..ed76ab986b 100644 --- a/packages/nodes-base/nodes/SeaTable/SeaTable.node.ts +++ b/packages/nodes-base/nodes/SeaTable/SeaTable.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -24,21 +22,11 @@ import { updateAble, } from './GenericFunctions'; -import { - rowFields, - rowOperations, -} from './RowDescription'; +import { rowFields, rowOperations } from './RowDescription'; -import { - TColumnsUiValues, - TColumnValue, -} from './types'; +import { TColumnsUiValues, TColumnValue } from './types'; -import { - ICtx, - IRow, - IRowObject, -} from './Interfaces'; +import { ICtx, IRow, IRowObject } from './Interfaces'; export class SeaTable implements INodeType { description: INodeTypeDescription = { @@ -83,7 +71,14 @@ export class SeaTable implements INodeType { loadOptions: { async getTableNames(this: ILoadOptionsFunctions) { const returnData: INodePropertyOptions[] = []; - const { metadata: { tables } } = await seaTableApiRequest.call(this, {}, 'GET', `/dtable-server/api/v1/dtables/{{dtable_uuid}}/metadata`); + const { + metadata: { tables }, + } = await seaTableApiRequest.call( + this, + {}, + 'GET', + `/dtable-server/api/v1/dtables/{{dtable_uuid}}/metadata`, + ); for (const table of tables) { returnData.push({ name: table.name, @@ -94,7 +89,14 @@ export class SeaTable implements INodeType { }, async getTableIds(this: ILoadOptionsFunctions) { const returnData: INodePropertyOptions[] = []; - const { metadata: { tables } } = await seaTableApiRequest.call(this, {}, 'GET', `/dtable-server/api/v1/dtables/{{dtable_uuid}}/metadata`); + const { + metadata: { tables }, + } = await seaTableApiRequest.call( + this, + {}, + 'GET', + `/dtable-server/api/v1/dtables/{{dtable_uuid}}/metadata`, + ); for (const table of tables) { returnData.push({ name: table.name, @@ -106,18 +108,25 @@ export class SeaTable implements INodeType { async getTableUpdateAbleColumns(this: ILoadOptionsFunctions) { const tableName = this.getNodeParameter('tableName') as string; - const columns = await getTableColumns.call(this, tableName,); - return columns.filter(column => column.editable).map(column => ({ name: column.name, value: column.name })); + const columns = await getTableColumns.call(this, tableName); + return columns + .filter((column) => column.editable) + .map((column) => ({ name: column.name, value: column.name })); }, async getAllSortableColumns(this: ILoadOptionsFunctions) { const tableName = this.getNodeParameter('tableName') as string; const columns = await getTableColumns.call(this, tableName); - return columns.filter(column => !['file', 'image', 'url', 'collaborator', 'long-text'].includes(column.type)).map(column => ({ name: column.name, value: column.name })); + return columns + .filter( + (column) => + !['file', 'image', 'url', 'collaborator', 'long-text'].includes(column.type), + ) + .map((column) => ({ name: column.name, value: column.name })); }, async getViews(this: ILoadOptionsFunctions) { const tableName = this.getNodeParameter('tableName') as string; const views = await getTableViews.call(this, tableName); - return views.map(view => ({ name: view.name, value: view.name })); + return views.map((view) => ({ name: view.name, value: view.name })); }, }, }; @@ -145,7 +154,9 @@ export class SeaTable implements INodeType { body.table_name = tableName; - const fieldsToSend = this.getNodeParameter('fieldsToSend', 0) as 'defineBelow' | 'autoMapInputData'; + const fieldsToSend = this.getNodeParameter('fieldsToSend', 0) as + | 'defineBelow' + | 'autoMapInputData'; let rowInput: IRowObject = {}; for (let i = 0; i < items.length; i++) { @@ -153,37 +164,67 @@ export class SeaTable implements INodeType { try { if (fieldsToSend === 'autoMapInputData') { const incomingKeys = Object.keys(items[i].json); - const inputDataToIgnore = split(this.getNodeParameter('inputsToIgnore', i, '') as string); + const inputDataToIgnore = split( + this.getNodeParameter('inputsToIgnore', i, '') as string, + ); for (const key of incomingKeys) { if (inputDataToIgnore.includes(key)) continue; rowInput[key] = items[i].json[key] as TColumnValue; } } else { - const columns = this.getNodeParameter('columnsUi.columnValues', i, []) as TColumnsUiValues; + const columns = this.getNodeParameter( + 'columnsUi.columnValues', + i, + [], + ) as TColumnsUiValues; for (const column of columns) { rowInput[column.columnName] = column.columnValue; } } body.row = rowExport(rowInput, updateAble(tableColumns)); - responseData = await seaTableApiRequest.call(this, ctx, 'POST', `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/`, body); + responseData = await seaTableApiRequest.call( + this, + ctx, + 'POST', + `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/`, + body, + ); const { _id: insertId } = responseData; if (insertId === undefined) { - throw new NodeOperationError(this.getNode(), 'SeaTable: No identity after appending row.', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'SeaTable: No identity after appending row.', + { itemIndex: i }, + ); } const newRowInsertData = rowMapKeyToName(responseData, tableColumns); qs.table_name = tableName; qs.convert = true; - const newRow = await seaTableApiRequest.call(this, ctx, 'GET', `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/${encodeURIComponent(insertId)}/`, body, qs); + const newRow = await seaTableApiRequest.call( + this, + ctx, + 'GET', + `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/${encodeURIComponent(insertId)}/`, + body, + qs, + ); if (newRow._id === undefined) { - throw new NodeOperationError(this.getNode(), 'SeaTable: No identity for appended row.', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'SeaTable: No identity for appended row.', + { itemIndex: i }, + ); } - const row = rowFormatColumns({ ...newRowInsertData, ...newRow }, tableColumns.map(({ name }) => name).concat(['_id', '_ctime', '_mtime'])); + const row = rowFormatColumns( + { ...newRowInsertData, ...newRow }, + tableColumns.map(({ name }) => name).concat(['_id', '_ctime', '_mtime']), + ); returnData.push(row); } catch (error) { @@ -199,9 +240,15 @@ export class SeaTable implements INodeType { try { const tableId = this.getNodeParameter('tableId', 0) as string; const rowId = this.getNodeParameter('rowId', i) as string; - const response = await seaTableApiRequest.call(this, ctx, 'GET', `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/${rowId}`, {}, { table_id: tableId, convert: true }) as IDataObject; + const response = (await seaTableApiRequest.call( + this, + ctx, + 'GET', + `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/${rowId}`, + {}, + { table_id: tableId, convert: true }, + )) as IDataObject; returnData.push(response); - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -229,14 +276,27 @@ export class SeaTable implements INodeType { Object.assign(qs, filters, options); if (returnAll) { - responseData = await setableApiRequestAllItems.call(this, ctx, 'rows', 'GET', endpoint, body, qs); + responseData = await setableApiRequestAllItems.call( + this, + ctx, + 'rows', + 'GET', + endpoint, + body, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; responseData = await seaTableApiRequest.call(this, ctx, 'GET', endpoint, body, qs); responseData = responseData.rows; } - const rows = responseData.map((row: IRow) => rowFormatColumns({ ...row }, tableColumns.map(({ name }) => name).concat(['_id', '_ctime', '_mtime']))); + const rows = responseData.map((row: IRow) => + rowFormatColumns( + { ...row }, + tableColumns.map(({ name }) => name).concat(['_id', '_ctime', '_mtime']), + ), + ); returnData.push(...rows); } @@ -255,7 +315,14 @@ export class SeaTable implements INodeType { table_name: tableName, row_id: rowId, }; - const response = await seaTableApiRequest.call(this, ctx, 'DELETE', `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/`, body, qs) as IDataObject; + const response = (await seaTableApiRequest.call( + this, + ctx, + 'DELETE', + `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/`, + body, + qs, + )) as IDataObject; returnData.push(response); } catch (error) { if (this.continueOnFail()) { @@ -275,7 +342,9 @@ export class SeaTable implements INodeType { body.table_name = tableName; - const fieldsToSend = this.getNodeParameter('fieldsToSend', 0) as 'defineBelow' | 'autoMapInputData'; + const fieldsToSend = this.getNodeParameter('fieldsToSend', 0) as + | 'defineBelow' + | 'autoMapInputData'; let rowInput: IRowObject = {}; for (let i = 0; i < items.length; i++) { @@ -284,13 +353,19 @@ export class SeaTable implements INodeType { try { if (fieldsToSend === 'autoMapInputData') { const incomingKeys = Object.keys(items[i].json); - const inputDataToIgnore = split(this.getNodeParameter('inputsToIgnore', i, '') as string); + const inputDataToIgnore = split( + this.getNodeParameter('inputsToIgnore', i, '') as string, + ); for (const key of incomingKeys) { if (inputDataToIgnore.includes(key)) continue; rowInput[key] = items[i].json[key] as TColumnValue; } } else { - const columns = this.getNodeParameter('columnsUi.columnValues', i, []) as TColumnsUiValues; + const columns = this.getNodeParameter( + 'columnsUi.columnValues', + i, + [], + ) as TColumnsUiValues; for (const column of columns) { rowInput[column.columnName] = column.columnValue; } @@ -298,9 +373,15 @@ export class SeaTable implements INodeType { body.row = rowExport(rowInput, updateAble(tableColumns)); body.table_name = tableName; body.row_id = rowId; - responseData = await seaTableApiRequest.call(this, ctx, 'PUT', `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/`, body); + responseData = await seaTableApiRequest.call( + this, + ctx, + 'PUT', + `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/`, + body, + ); - returnData.push({ _id: rowId, ... responseData }); + returnData.push({ _id: rowId, ...responseData }); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/SeaTable/SeaTableTrigger.node.ts b/packages/nodes-base/nodes/SeaTable/SeaTableTrigger.node.ts index e84fc2a516..cb4f674fa3 100644 --- a/packages/nodes-base/nodes/SeaTable/SeaTableTrigger.node.ts +++ b/packages/nodes-base/nodes/SeaTable/SeaTableTrigger.node.ts @@ -1,6 +1,4 @@ -import { - IPollFunctions, -} from 'n8n-core'; +import { IPollFunctions } from 'n8n-core'; import { IDataObject, @@ -11,18 +9,9 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - getColumns, - rowFormatColumns, - seaTableApiRequest, - simplify, -} from './GenericFunctions'; +import { getColumns, rowFormatColumns, seaTableApiRequest, simplify } from './GenericFunctions'; -import { - ICtx, - IRow, - IRowResponse, -} from './Interfaces'; +import { ICtx, IRow, IRowResponse } from './Interfaces'; import moment from 'moment'; @@ -57,7 +46,8 @@ export class SeaTableTrigger implements INodeType { loadOptionsMethod: 'getTableNames', }, default: '', - description: 'The name of SeaTable table to access. Choose from the list, or specify an ID using an expression.', + description: + 'The name of SeaTable table to access. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Event', @@ -82,7 +72,8 @@ export class SeaTableTrigger implements INodeType { name: 'simple', type: 'boolean', default: true, - description: 'Whether to return a simplified version of the response instead of the raw data', + description: + 'Whether to return a simplified version of the response instead of the raw data', }, ], }; @@ -91,7 +82,14 @@ export class SeaTableTrigger implements INodeType { loadOptions: { async getTableNames(this: ILoadOptionsFunctions) { const returnData: INodePropertyOptions[] = []; - const { metadata: { tables } } = await seaTableApiRequest.call(this, {}, 'GET', `/dtable-server/api/v1/dtables/{{dtable_uuid}}/metadata`); + const { + metadata: { tables }, + } = await seaTableApiRequest.call( + this, + {}, + 'GET', + `/dtable-server/api/v1/dtables/{{dtable_uuid}}/metadata`, + ); for (const table of tables) { returnData.push({ name: table.name, @@ -111,29 +109,27 @@ export class SeaTableTrigger implements INodeType { const ctx: ICtx = {}; const credentials = await this.getCredentials('seaTableApi'); - const timezone = credentials.timezone as string || 'Europe/Berlin'; + const timezone = (credentials.timezone as string) || 'Europe/Berlin'; const now = moment().utc().format(); - const startDate = webhookData.lastTimeChecked as string || now; + const startDate = (webhookData.lastTimeChecked as string) || now; const endDate = now; webhookData.lastTimeChecked = endDate; let rows; - const filterField = (event === 'rowCreated') ? '_ctime' : '_mtime'; + const filterField = event === 'rowCreated' ? '_ctime' : '_mtime'; const endpoint = `/dtable-db/api/v1/query/{{dtable_uuid}}/`; if (this.getMode() === 'manual') { - rows = await seaTableApiRequest.call(this, ctx, 'POST', endpoint, { sql: `SELECT * FROM ${tableName} LIMIT 1` }) as IRowResponse; + rows = (await seaTableApiRequest.call(this, ctx, 'POST', endpoint, { + sql: `SELECT * FROM ${tableName} LIMIT 1`, + })) as IRowResponse; } else { rows = (await seaTableApiRequest.call(this, ctx, 'POST', endpoint, { sql: `SELECT * FROM ${tableName} - WHERE ${filterField} BETWEEN "${moment(startDate) - .tz(timezone) - .format('YYYY-MM-D HH:mm:ss')}" - AND "${moment(endDate) - .tz(timezone) - .format('YYYY-MM-D HH:mm:ss')}"`, + WHERE ${filterField} BETWEEN "${moment(startDate).tz(timezone).format('YYYY-MM-D HH:mm:ss')}" + AND "${moment(endDate).tz(timezone).format('YYYY-MM-D HH:mm:ss')}"`, })) as IRowResponse; } @@ -150,9 +146,9 @@ export class SeaTableTrigger implements INodeType { const allColumns = rows.metadata.map((meta) => meta.name); response = response - //@ts-ignore - .map((row: IRow) => rowFormatColumns(row, allColumns)) - .map((row: IRow) => ({ json: row })); + //@ts-ignore + .map((row: IRow) => rowFormatColumns(row, allColumns)) + .map((row: IRow) => ({ json: row })); } if (Array.isArray(response) && response.length) { diff --git a/packages/nodes-base/nodes/SeaTable/types.d.ts b/packages/nodes-base/nodes/SeaTable/types.d.ts index f76460ce26..eb4eed2aa8 100644 --- a/packages/nodes-base/nodes/SeaTable/types.d.ts +++ b/packages/nodes-base/nodes/SeaTable/types.d.ts @@ -9,20 +9,37 @@ type TSeaTableServerEdition = 'enterprise edition'; // dtable // ---------------------------------- -import {IDtableMetadataColumn, IDtableMetadataTable, TDtableViewColumn} from './Interfaces'; -import {ICredentialDataDecryptedObject} from 'n8n-workflow'; +import { IDtableMetadataColumn, IDtableMetadataTable, TDtableViewColumn } from './Interfaces'; +import { ICredentialDataDecryptedObject } from 'n8n-workflow'; type TInheritColumnTypeTime = 'ctime' | 'mtime'; type TInheritColumnTypeUser = 'creator' | 'last-modifier'; -type TColumnType = 'text' | 'long-text' | 'number' +type TColumnType = + | 'text' + | 'long-text' + | 'number' | 'collaborator' - | 'date' | 'duration' | 'single-select' | 'multiple-select' | 'email' | 'url' | 'rate' - | 'checkbox' | 'formula' - | TInheritColumnTypeTime | TInheritColumnTypeUser | 'auto-number'; - + | 'date' + | 'duration' + | 'single-select' + | 'multiple-select' + | 'email' + | 'url' + | 'rate' + | 'checkbox' + | 'formula' + | TInheritColumnTypeTime + | TInheritColumnTypeUser + | 'auto-number'; type TImplementInheritColumnKey = '_seq'; -type TInheritColumnKey = '_id' | '_creator' | '_ctime' | '_last_modifier' | '_mtime' | TImplementInheritColumnKey; +type TInheritColumnKey = + | '_id' + | '_creator' + | '_ctime' + | '_last_modifier' + | '_mtime' + | TImplementInheritColumnKey; type TColumnValue = undefined | boolean | number | string | string[] | null; type TColumnKey = TInheritColumnKey | string; @@ -42,11 +59,13 @@ type TMethod = 'GET' | 'POST'; type TDeferredEndpoint = string; type TDeferredEndpointExpr = string; type TEndpoint = - '/api/v2.1/dtable/app-access-token/' + | '/api/v2.1/dtable/app-access-token/' | '/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/' | TDeferredEndpoint; type TEndpointExpr = TEndpoint | TDeferredEndpointExpr; -type TEndpointResolvedExpr = TEndpoint | string; /* deferred: but already in use for header values, e.g. authentication */ +type TEndpointResolvedExpr = + | TEndpoint + | string; /* deferred: but already in use for header values, e.g. authentication */ type TDateTimeFormat = 'YYYY-MM-DDTHH:mm:ss.SSSZ' /* moment.js */; @@ -61,9 +80,9 @@ type TTriggerOperation = 'create' | 'update'; type TOperation = 'append' | 'list' | 'metadata'; type TLoadedResource = { - name: string; + name: string; }; export type TColumnsUiValues = Array<{ - columnName: string; - columnValue: string; + columnName: string; + columnValue: string; }>; diff --git a/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts b/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts index 74e1471aed..69d412aee8 100644 --- a/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts @@ -1,18 +1,20 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function scorecardApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function scorecardApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('securityScorecardApi'); const headerWithAuthentication = { Authorization: `Token ${credentials.apiKey}` }; diff --git a/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts b/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts index e22e7f4f37..8a2c60ab36 100644 --- a/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts +++ b/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts @@ -1,48 +1,23 @@ -import { - IExecuteFunctions -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - companyFields, - companyOperations, -} from './descriptions/CompanyDescription'; +import { companyFields, companyOperations } from './descriptions/CompanyDescription'; -import { - industryFields, - industryOperations, -} from './descriptions/IndustryDescription'; +import { industryFields, industryOperations } from './descriptions/IndustryDescription'; -import { - inviteFields, - inviteOperations, -} from './descriptions/InviteDescription'; +import { inviteFields, inviteOperations } from './descriptions/InviteDescription'; -import { - portfolioFields, - portfolioOperations, -} from './descriptions/PortfolioDescription'; +import { portfolioFields, portfolioOperations } from './descriptions/PortfolioDescription'; import { portfolioCompanyFields, portfolioCompanyOperations, } from './descriptions/PortfolioCompanyDescription'; -import { - reportFields, - reportOperations, -} from './descriptions/ReportDescription'; +import { reportFields, reportOperations } from './descriptions/ReportDescription'; -import { - scorecardApiRequest, - simplify, -} from './GenericFunctions'; +import { scorecardApiRequest, simplify } from './GenericFunctions'; import moment from 'moment'; @@ -132,9 +107,7 @@ export class SecurityScorecard implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < length; i++) { - if (resource === 'portfolio') { - if (operation === 'create') { const name = this.getNodeParameter('name', i) as string; const description = this.getNodeParameter('description', i) as string; @@ -146,12 +119,7 @@ export class SecurityScorecard implements INodeType { privacy, }; - responseData = await scorecardApiRequest.call( - this, - 'POST', - 'portfolios', - body, - ); + responseData = await scorecardApiRequest.call(this, 'POST', 'portfolios', body); returnData.push(responseData as IDataObject); } @@ -188,11 +156,7 @@ export class SecurityScorecard implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', 0) as boolean; - responseData = await scorecardApiRequest.call( - this, - 'GET', - 'portfolios', - ); + responseData = await scorecardApiRequest.call(this, 'GET', 'portfolios'); responseData = responseData.entries; if (returnAll === false) { @@ -254,14 +218,10 @@ export class SecurityScorecard implements INodeType { if (operation === 'download') { const reportUrl = this.getNodeParameter('url', i) as string; - const response = await scorecardApiRequest.call( - this, - 'GET', - '', - {}, - {}, - reportUrl, - { encoding: null, resolveWithFullResponse: true }); + const response = await scorecardApiRequest.call(this, 'GET', '', {}, {}, reportUrl, { + encoding: null, + resolveWithFullResponse: true, + }); let mimeType: string | undefined; if (response.headers['content-type']) { @@ -287,7 +247,11 @@ export class SecurityScorecard implements INodeType { const fileName = reportUrl.split('/').pop(); const data = Buffer.from(response.body as string, 'utf8'); - items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data as unknown as Buffer, fileName, mimeType); + items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( + data as unknown as Buffer, + fileName, + mimeType, + ); } if (operation === 'generate') { @@ -329,11 +293,7 @@ export class SecurityScorecard implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', 0) as boolean; - responseData = await scorecardApiRequest.call( - this, - 'GET', - 'reports/recent', - ); + responseData = await scorecardApiRequest.call(this, 'GET', 'reports/recent'); responseData = responseData.entries; if (returnAll === false) { @@ -355,12 +315,7 @@ export class SecurityScorecard implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i); Object.assign(body, additionalFields); - responseData = await scorecardApiRequest.call( - this, - 'POST', - `invitations`, - body, - ); + responseData = await scorecardApiRequest.call(this, 'POST', `invitations`, body); returnData.push(responseData as IDataObject); } } diff --git a/packages/nodes-base/nodes/SecurityScorecard/descriptions/CompanyDescription.ts b/packages/nodes-base/nodes/SecurityScorecard/descriptions/CompanyDescription.ts index 097fddf014..bb809f72b6 100644 --- a/packages/nodes-base/nodes/SecurityScorecard/descriptions/CompanyDescription.ts +++ b/packages/nodes-base/nodes/SecurityScorecard/descriptions/CompanyDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const companyOperations: INodeProperties[] = [ { @@ -11,9 +9,7 @@ export const companyOperations: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], + resource: ['company'], }, }, options: [ @@ -26,14 +22,14 @@ export const companyOperations: INodeProperties[] = [ { name: 'Get Historical Factor Scores', value: 'getFactorHistorical', - description: 'Get company\'s historical factor scores', - action: 'Get a company\'s historical factor scores', + description: "Get company's historical factor scores", + action: "Get a company's historical factor scores", }, { name: 'Get Historical Scores', value: 'getHistoricalScore', - description: 'Get company\'s historical scores', - action: 'Get a company\'s historical scores', + description: "Get company's historical scores", + action: "Get a company's historical scores", }, { name: 'Get Information and Scorecard', @@ -44,8 +40,8 @@ export const companyOperations: INodeProperties[] = [ { name: 'Get Score Plan', value: 'getScorePlan', - description: 'Get company\'s score improvement plan', - action: 'Get a company\'s score improvement plan', + description: "Get company's score improvement plan", + action: "Get a company's score improvement plan", }, ], default: 'getFactor', @@ -62,9 +58,7 @@ export const companyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], + resource: ['company'], operation: [ 'getScorecard', 'getFactor', @@ -82,12 +76,8 @@ export const companyFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getScorePlan', - ], + resource: ['company'], + operation: ['getScorePlan'], }, }, required: true, @@ -99,15 +89,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getFactor', - 'getFactorHistorical', - 'getHistoricalScore', - 'getScorePlan', - ], + resource: ['company'], + operation: ['getFactor', 'getFactorHistorical', 'getHistoricalScore', 'getScorePlan'], }, }, default: false, @@ -119,18 +102,9 @@ export const companyFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getFactor', - 'getFactorHistorical', - 'getHistoricalScore', - 'getScorePlan', - ], - returnAll: [ - false, - ], + resource: ['company'], + operation: ['getFactor', 'getFactorHistorical', 'getHistoricalScore', 'getScorePlan'], + returnAll: [false], }, }, typeOptions: { @@ -146,13 +120,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getFactorHistorical', - 'getHistoricalScore', - ], + resource: ['company'], + operation: ['getFactorHistorical', 'getHistoricalScore'], }, }, default: true, @@ -165,12 +134,8 @@ export const companyFields: INodeProperties[] = [ name: 'filters', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getFactor', - ], + resource: ['company'], + operation: ['getFactor'], }, }, type: 'collection', @@ -202,13 +167,8 @@ export const companyFields: INodeProperties[] = [ name: 'options', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getFactorHistorical', - 'getHistoricalScore', - ], + resource: ['company'], + operation: ['getFactorHistorical', 'getHistoricalScore'], }, }, type: 'collection', @@ -221,7 +181,6 @@ export const companyFields: INodeProperties[] = [ name: 'date_from', type: 'dateTime', default: '', - }, { displayName: 'Date To', diff --git a/packages/nodes-base/nodes/SecurityScorecard/descriptions/IndustryDescription.ts b/packages/nodes-base/nodes/SecurityScorecard/descriptions/IndustryDescription.ts index 599833e1a9..47d1209392 100644 --- a/packages/nodes-base/nodes/SecurityScorecard/descriptions/IndustryDescription.ts +++ b/packages/nodes-base/nodes/SecurityScorecard/descriptions/IndustryDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const industryOperations: INodeProperties[] = [ { @@ -11,9 +9,7 @@ export const industryOperations: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'industry', - ], + resource: ['industry'], }, }, options: [ @@ -68,14 +64,8 @@ export const industryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'industry', - ], - operation: [ - 'getScore', - 'getFactor', - 'getFactorHistorical', - ], + resource: ['industry'], + operation: ['getScore', 'getFactor', 'getFactorHistorical'], }, }, }, @@ -85,13 +75,8 @@ export const industryFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'industry', - ], - operation: [ - 'getFactor', - 'getFactorHistorical', - ], + resource: ['industry'], + operation: ['getFactor', 'getFactorHistorical'], }, }, default: false, @@ -103,16 +88,9 @@ export const industryFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'industry', - ], - operation: [ - 'getFactor', - 'getFactorHistorical', - ], - returnAll: [ - false, - ], + resource: ['industry'], + operation: ['getFactor', 'getFactorHistorical'], + returnAll: [false], }, }, typeOptions: { @@ -128,13 +106,8 @@ export const industryFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'industry', - ], - operation: [ - 'getFactor', - 'getFactorHistorical', - ], + resource: ['industry'], + operation: ['getFactor', 'getFactorHistorical'], }, }, default: true, @@ -145,12 +118,8 @@ export const industryFields: INodeProperties[] = [ name: 'options', displayOptions: { show: { - resource: [ - 'industry', - ], - operation: [ - 'getFactorHistorical', - ], + resource: ['industry'], + operation: ['getFactorHistorical'], }, }, type: 'collection', diff --git a/packages/nodes-base/nodes/SecurityScorecard/descriptions/InviteDescription.ts b/packages/nodes-base/nodes/SecurityScorecard/descriptions/InviteDescription.ts index 98aceea8af..4754f94614 100644 --- a/packages/nodes-base/nodes/SecurityScorecard/descriptions/InviteDescription.ts +++ b/packages/nodes-base/nodes/SecurityScorecard/descriptions/InviteDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const inviteOperations: INodeProperties[] = [ { @@ -11,9 +9,7 @@ export const inviteOperations: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'invite', - ], + resource: ['invite'], }, }, options: [ @@ -38,12 +34,8 @@ export const inviteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'invite', - ], - operation: [ - 'create', - ], + resource: ['invite'], + operation: ['create'], }, }, }, @@ -55,12 +47,8 @@ export const inviteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'invite', - ], - operation: [ - 'create', - ], + resource: ['invite'], + operation: ['create'], }, }, }, @@ -72,12 +60,8 @@ export const inviteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'invite', - ], - operation: [ - 'create', - ], + resource: ['invite'], + operation: ['create'], }, }, }, @@ -90,12 +74,8 @@ export const inviteFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'invite', - ], - operation: [ - 'create', - ], + resource: ['invite'], + operation: ['create'], }, }, }, @@ -106,12 +86,8 @@ export const inviteFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'invite', - ], - operation: [ - 'create', - ], + resource: ['invite'], + operation: ['create'], }, }, default: {}, @@ -132,7 +108,7 @@ export const inviteFields: INodeProperties[] = [ }, { displayName: 'Grade to Maintain', - description: 'Request the invitee\'s organisation to maintain a minimum grade', + description: "Request the invitee's organisation to maintain a minimum grade", name: 'grade_to_maintain', type: 'string', default: '', @@ -140,7 +116,7 @@ export const inviteFields: INodeProperties[] = [ { displayName: 'Is Organisation Point of Contact', // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Is the invitee organisation\'s point of contact', + description: "Is the invitee organisation's point of contact", name: 'is_organization_point_of_contact', type: 'boolean', default: false, diff --git a/packages/nodes-base/nodes/SecurityScorecard/descriptions/PortfolioCompanyDescription.ts b/packages/nodes-base/nodes/SecurityScorecard/descriptions/PortfolioCompanyDescription.ts index 4ff5cc813d..87cd0c9fad 100644 --- a/packages/nodes-base/nodes/SecurityScorecard/descriptions/PortfolioCompanyDescription.ts +++ b/packages/nodes-base/nodes/SecurityScorecard/descriptions/PortfolioCompanyDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const portfolioCompanyOperations: INodeProperties[] = [ { @@ -11,9 +9,7 @@ export const portfolioCompanyOperations: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'portfolioCompany', - ], + resource: ['portfolioCompany'], }, }, options: [ @@ -49,14 +45,8 @@ export const portfolioCompanyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'portfolioCompany', - ], - operation: [ - 'getAll', - 'add', - 'remove', - ], + resource: ['portfolioCompany'], + operation: ['getAll', 'add', 'remove'], }, }, }, @@ -66,12 +56,8 @@ export const portfolioCompanyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'portfolioCompany', - ], - operation: [ - 'getAll', - ], + resource: ['portfolioCompany'], + operation: ['getAll'], }, }, default: false, @@ -83,15 +69,9 @@ export const portfolioCompanyFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'portfolioCompany', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['portfolioCompany'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -106,12 +86,8 @@ export const portfolioCompanyFields: INodeProperties[] = [ name: 'filters', displayOptions: { show: { - resource: [ - 'portfolioCompany', - ], - operation: [ - 'getAll', - ], + resource: ['portfolioCompany'], + operation: ['getAll'], }, }, type: 'collection', @@ -176,17 +152,10 @@ export const portfolioCompanyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'portfolioCompany', - ], - operation: [ - 'add', - 'remove', - ], + resource: ['portfolioCompany'], + operation: ['add', 'remove'], }, }, - description: 'Company\'s domain name', + description: "Company's domain name", }, - ]; - diff --git a/packages/nodes-base/nodes/SecurityScorecard/descriptions/PortfolioDescription.ts b/packages/nodes-base/nodes/SecurityScorecard/descriptions/PortfolioDescription.ts index 9307437457..20917c02a9 100644 --- a/packages/nodes-base/nodes/SecurityScorecard/descriptions/PortfolioDescription.ts +++ b/packages/nodes-base/nodes/SecurityScorecard/descriptions/PortfolioDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const portfolioOperations: INodeProperties[] = [ { @@ -11,9 +9,7 @@ export const portfolioOperations: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'portfolio', - ], + resource: ['portfolio'], }, }, options: [ @@ -53,12 +49,8 @@ export const portfolioFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'portfolio', - ], - operation: [ - 'getAll', - ], + resource: ['portfolio'], + operation: ['getAll'], }, }, default: false, @@ -70,15 +62,9 @@ export const portfolioFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'portfolio', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['portfolio'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -96,13 +82,8 @@ export const portfolioFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'portfolio', - ], - operation: [ - 'update', - 'delete', - ], + resource: ['portfolio'], + operation: ['update', 'delete'], }, }, }, @@ -114,13 +95,8 @@ export const portfolioFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'portfolio', - ], - operation: [ - 'create', - 'update', - ], + resource: ['portfolio'], + operation: ['create', 'update'], }, }, description: 'Name of the portfolio', @@ -132,13 +108,8 @@ export const portfolioFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'portfolio', - ], - operation: [ - 'create', - 'update', - ], + resource: ['portfolio'], + operation: ['create', 'update'], }, }, }, @@ -148,13 +119,8 @@ export const portfolioFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'portfolio', - ], - operation: [ - 'create', - 'update', - ], + resource: ['portfolio'], + operation: ['create', 'update'], }, }, options: [ @@ -177,4 +143,3 @@ export const portfolioFields: INodeProperties[] = [ default: 'shared', }, ]; - diff --git a/packages/nodes-base/nodes/SecurityScorecard/descriptions/ReportDescription.ts b/packages/nodes-base/nodes/SecurityScorecard/descriptions/ReportDescription.ts index 15cbb7519c..30c5061605 100644 --- a/packages/nodes-base/nodes/SecurityScorecard/descriptions/ReportDescription.ts +++ b/packages/nodes-base/nodes/SecurityScorecard/descriptions/ReportDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const reportOperations: INodeProperties[] = [ { @@ -11,9 +9,7 @@ export const reportOperations: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'report', - ], + resource: ['report'], }, }, options: [ @@ -47,12 +43,8 @@ export const reportFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'getAll', - ], + resource: ['report'], + operation: ['getAll'], }, }, default: false, @@ -64,15 +56,9 @@ export const reportFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['report'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -89,12 +75,8 @@ export const reportFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'generate', - ], + resource: ['report'], + operation: ['generate'], }, }, options: [ @@ -130,7 +112,6 @@ export const reportFields: INodeProperties[] = [ name: 'Scorecard Footprint', value: 'scorecard-footprint', }, - ], default: 'detailed', }, @@ -143,12 +124,8 @@ export const reportFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'generate', - ], + resource: ['report'], + operation: ['generate'], report: [ 'detailed', 'events-json', @@ -169,15 +146,9 @@ export const reportFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'generate', - ], - report: [ - 'portfolio', - ], + resource: ['report'], + operation: ['generate'], + report: ['portfolio'], }, }, }, @@ -187,16 +158,9 @@ export const reportFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'generate', - ], - report: [ - 'detailed', - 'summary', - ], + resource: ['report'], + operation: ['generate'], + report: ['detailed', 'summary'], }, }, options: [ @@ -223,15 +187,9 @@ export const reportFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'generate', - ], - report: [ - 'events-json', - ], + resource: ['report'], + operation: ['generate'], + report: ['events-json'], }, }, }, @@ -243,16 +201,9 @@ export const reportFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'generate', - ], - report: [ - 'issues', - 'portfolio', - ], + resource: ['report'], + operation: ['generate'], + report: ['issues', 'portfolio'], }, }, options: [ @@ -282,15 +233,9 @@ export const reportFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'generate', - ], - report: [ - 'scorecard-footprint', - ], + resource: ['report'], + operation: ['generate'], + report: ['scorecard-footprint'], }, }, options: [ @@ -337,7 +282,6 @@ export const reportFields: INodeProperties[] = [ }, default: [], }, - ], }, { @@ -349,12 +293,8 @@ export const reportFields: INodeProperties[] = [ description: 'URL to a generated report', displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'download', - ], + resource: ['report'], + operation: ['download'], }, }, }, @@ -366,12 +306,8 @@ export const reportFields: INodeProperties[] = [ default: 'data', displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'download', - ], + resource: ['report'], + operation: ['download'], }, }, description: 'Name of the binary property to which to write the data of the read file', diff --git a/packages/nodes-base/nodes/Segment/GenericFunctions.ts b/packages/nodes-base/nodes/Segment/GenericFunctions.ts index 645175728d..1e54839f22 100644 --- a/packages/nodes-base/nodes/Segment/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Segment/GenericFunctions.ts @@ -6,11 +6,26 @@ import { ILoadOptionsFunctions, IWebhookFunctions, } from 'n8n-core'; -import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function segmentApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function segmentApiRequest( + this: + | IHookFunctions + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IWebhookFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('segmentApi'); - const base64Key = Buffer.from(`${credentials.writekey}:`).toString('base64'); + const base64Key = Buffer.from(`${credentials.writekey}:`).toString('base64'); const options: OptionsWithUri = { headers: { Authorization: `Basic ${base64Key}`, @@ -19,7 +34,7 @@ export async function segmentApiRequest(this: IHookFunctions | IExecuteFunctions method, qs, body, - uri: uri ||`https://api.segment.io/v1${resource}`, + uri: uri || `https://api.segment.io/v1${resource}`, json: true, }; if (!Object.keys(body).length) { diff --git a/packages/nodes-base/nodes/Segment/GroupDescription.ts b/packages/nodes-base/nodes/Segment/GroupDescription.ts index 80fe734acc..22cc2b3aa1 100644 --- a/packages/nodes-base/nodes/Segment/GroupDescription.ts +++ b/packages/nodes-base/nodes/Segment/GroupDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const groupOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const groupOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'group', - ], + resource: ['group'], }, }, options: [ @@ -28,10 +24,9 @@ export const groupOperations: INodeProperties[] = [ ]; export const groupFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* group:add */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* group:add */ + /* -------------------------------------------------------------------------- */ { displayName: 'User ID', name: 'userId', @@ -39,12 +34,8 @@ export const groupFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'add', - ], + resource: ['group'], + operation: ['add'], }, }, }, @@ -55,15 +46,12 @@ export const groupFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'add', - ], + resource: ['group'], + operation: ['add'], }, }, - description: 'A Group ID is the unique identifier which you recognize a group by in your own database', + description: + 'A Group ID is the unique identifier which you recognize a group by in your own database', required: true, }, { @@ -76,12 +64,8 @@ export const groupFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'add', - ], + resource: ['group'], + operation: ['add'], }, }, default: {}, @@ -116,12 +100,8 @@ export const groupFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'add', - ], + resource: ['group'], + operation: ['add'], }, }, default: {}, @@ -156,14 +136,16 @@ export const groupFields: INodeProperties[] = [ name: 'page', type: 'string', default: '', - description: 'Dictionary of information about the current page in the browser, containing hash, path, referrer, search, title and URL', + description: + 'Dictionary of information about the current page in the browser, containing hash, path, referrer, search, title and URL', }, { displayName: 'Timezone', name: 'timezone', type: 'string', default: '', - description: 'Timezones are sent as tzdata strings to add user timezone information which might be stripped from the timestamp, for example America/New_York', + description: + 'Timezones are sent as tzdata strings to add user timezone information which might be stripped from the timestamp, for example America/New_York', }, { displayName: 'App', @@ -317,12 +299,8 @@ export const groupFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'add', - ], + resource: ['group'], + operation: ['add'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/Segment/IdentifyDescription.ts b/packages/nodes-base/nodes/Segment/IdentifyDescription.ts index 6e9a740d8f..47397ba874 100644 --- a/packages/nodes-base/nodes/Segment/IdentifyDescription.ts +++ b/packages/nodes-base/nodes/Segment/IdentifyDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const identifyOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const identifyOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'identify', - ], + resource: ['identify'], }, }, options: [ @@ -28,10 +24,9 @@ export const identifyOperations: INodeProperties[] = [ ]; export const identifyFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* identify:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* identify:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'User ID', name: 'userId', @@ -39,12 +34,8 @@ export const identifyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'identify', - ], - operation: [ - 'create', - ], + resource: ['identify'], + operation: ['create'], }, }, }, @@ -58,12 +49,8 @@ export const identifyFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'identify', - ], - operation: [ - 'create', - ], + resource: ['identify'], + operation: ['create'], }, }, default: {}, @@ -98,12 +85,8 @@ export const identifyFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'identify', - ], - operation: [ - 'create', - ], + resource: ['identify'], + operation: ['create'], }, }, default: {}, @@ -138,14 +121,16 @@ export const identifyFields: INodeProperties[] = [ name: 'page', type: 'string', default: '', - description: 'Dictionary of information about the current page in the browser, containing hash, path, referrer, search, title and URL', + description: + 'Dictionary of information about the current page in the browser, containing hash, path, referrer, search, title and URL', }, { displayName: 'Timezone', name: 'timezone', type: 'string', default: '', - description: 'Timezones are sent as tzdata strings to add user timezone information which might be stripped from the timestamp, for example America/New_York', + description: + 'Timezones are sent as tzdata strings to add user timezone information which might be stripped from the timestamp, for example America/New_York', }, { displayName: 'App', @@ -299,12 +284,8 @@ export const identifyFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'identify', - ], - operation: [ - 'create', - ], + resource: ['identify'], + operation: ['create'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/Segment/Segment.node.ts b/packages/nodes-base/nodes/Segment/Segment.node.ts index 00cfe24368..d1f3df69ee 100644 --- a/packages/nodes-base/nodes/Segment/Segment.node.ts +++ b/packages/nodes-base/nodes/Segment/Segment.node.ts @@ -1,41 +1,18 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - segmentApiRequest, -} from './GenericFunctions'; +import { segmentApiRequest } from './GenericFunctions'; -import { - groupFields, - groupOperations, -} from './GroupDescription'; +import { groupFields, groupOperations } from './GroupDescription'; -import { - identifyFields, - identifyOperations, -} from './IdentifyDescription'; +import { identifyFields, identifyOperations } from './IdentifyDescription'; -import { - IIdentify, -} from './IdentifyInterface'; +import { IIdentify } from './IdentifyInterface'; -import { - trackFields, - trackOperations, -} from './TrackDescription'; +import { trackFields, trackOperations } from './TrackDescription'; -import { - IGroup, - ITrack, -} from './TrackInterface'; +import { IGroup, ITrack } from './TrackInterface'; import { v4 as uuid } from 'uuid'; @@ -109,9 +86,12 @@ export class Segment implements INodeType { if (operation === 'add') { const userId = this.getNodeParameter('userId', i) as string; const groupId = this.getNodeParameter('groupId', i) as string; - const traits = (this.getNodeParameter('traits', i) as IDataObject).traitsUi as IDataObject[]; - const context = (this.getNodeParameter('context', i) as IDataObject).contextUi as IDataObject; - const integrations = (this.getNodeParameter('integrations', i) as IDataObject).integrationsUi as IDataObject; + const traits = (this.getNodeParameter('traits', i) as IDataObject) + .traitsUi as IDataObject[]; + const context = (this.getNodeParameter('context', i) as IDataObject) + .contextUi as IDataObject; + const integrations = (this.getNodeParameter('integrations', i) as IDataObject) + .integrationsUi as IDataObject; const body: IGroup = { groupId, traits: { @@ -240,9 +220,12 @@ export class Segment implements INodeType { //https://segment.com/docs/connections/sources/catalog/libraries/server/http-api/#identify if (operation === 'create') { const userId = this.getNodeParameter('userId', i) as string; - const context = (this.getNodeParameter('context', i) as IDataObject).contextUi as IDataObject; - const traits = (this.getNodeParameter('traits', i) as IDataObject).traitsUi as IDataObject[]; - const integrations = (this.getNodeParameter('integrations', i) as IDataObject).integrationsUi as IDataObject; + const context = (this.getNodeParameter('context', i) as IDataObject) + .contextUi as IDataObject; + const traits = (this.getNodeParameter('traits', i) as IDataObject) + .traitsUi as IDataObject[]; + const integrations = (this.getNodeParameter('integrations', i) as IDataObject) + .integrationsUi as IDataObject; const body: IIdentify = { context: { app: {}, @@ -370,13 +353,15 @@ export class Segment implements INodeType { if (operation === 'event') { const userId = this.getNodeParameter('userId', i) as string; const event = this.getNodeParameter('event', i) as string; - const context = (this.getNodeParameter('context', i) as IDataObject).contextUi as IDataObject; - const integrations = (this.getNodeParameter('integrations', i) as IDataObject).integrationsUi as IDataObject; - const properties = (this.getNodeParameter('properties', i) as IDataObject).propertiesUi as IDataObject[]; + const context = (this.getNodeParameter('context', i) as IDataObject) + .contextUi as IDataObject; + const integrations = (this.getNodeParameter('integrations', i) as IDataObject) + .integrationsUi as IDataObject; + const properties = (this.getNodeParameter('properties', i) as IDataObject) + .propertiesUi as IDataObject[]; const body: ITrack = { event, - traits: { - }, + traits: {}, context: { app: {}, campaign: {}, @@ -500,9 +485,12 @@ export class Segment implements INodeType { if (operation === 'page') { const userId = this.getNodeParameter('userId', i) as string; const name = this.getNodeParameter('name', i) as string; - const context = (this.getNodeParameter('context', i) as IDataObject).contextUi as IDataObject; - const integrations = (this.getNodeParameter('integrations', i) as IDataObject).integrationsUi as IDataObject; - const properties = (this.getNodeParameter('properties', i) as IDataObject).propertiesUi as IDataObject[]; + const context = (this.getNodeParameter('context', i) as IDataObject) + .contextUi as IDataObject; + const integrations = (this.getNodeParameter('integrations', i) as IDataObject) + .integrationsUi as IDataObject; + const properties = (this.getNodeParameter('properties', i) as IDataObject) + .propertiesUi as IDataObject[]; const body: ITrack = { name, traits: {}, diff --git a/packages/nodes-base/nodes/Segment/TrackDescription.ts b/packages/nodes-base/nodes/Segment/TrackDescription.ts index 67aacc8908..058457f1e7 100644 --- a/packages/nodes-base/nodes/Segment/TrackDescription.ts +++ b/packages/nodes-base/nodes/Segment/TrackDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const trackOperations: INodeProperties[] = [ { @@ -10,22 +8,22 @@ export const trackOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'track', - ], + resource: ['track'], }, }, options: [ { name: 'Event', value: 'event', - description: 'Record the actions your users perform. Every action triggers an event, which can also have associated properties.', + description: + 'Record the actions your users perform. Every action triggers an event, which can also have associated properties.', action: 'Track an event', }, { name: 'Page', value: 'page', - description: 'Record page views on your website, along with optional extra information about the page being viewed', + description: + 'Record page views on your website, along with optional extra information about the page being viewed', action: 'Track a page', }, ], @@ -34,10 +32,9 @@ export const trackOperations: INodeProperties[] = [ ]; export const trackFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* track:event */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* track:event */ + /* -------------------------------------------------------------------------- */ { displayName: 'User ID', name: 'userId', @@ -45,12 +42,8 @@ export const trackFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'track', - ], - operation: [ - 'event', - ], + resource: ['track'], + operation: ['event'], }, }, }, @@ -61,12 +54,8 @@ export const trackFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'track', - ], - operation: [ - 'event', - ], + resource: ['track'], + operation: ['event'], }, }, description: 'Name of the action that a user has performed', @@ -82,12 +71,8 @@ export const trackFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'track', - ], - operation: [ - 'event', - ], + resource: ['track'], + operation: ['event'], }, }, default: {}, @@ -122,14 +107,16 @@ export const trackFields: INodeProperties[] = [ name: 'page', type: 'string', default: '', - description: 'Dictionary of information about the current page in the browser, containing hash, path, referrer, search, title and URL', + description: + 'Dictionary of information about the current page in the browser, containing hash, path, referrer, search, title and URL', }, { displayName: 'Timezone', name: 'timezone', type: 'string', default: '', - description: 'Timezones are sent as tzdata strings to add user timezone information which might be stripped from the timestamp, for example America/New_York', + description: + 'Timezones are sent as tzdata strings to add user timezone information which might be stripped from the timestamp, for example America/New_York', }, { displayName: 'App', @@ -283,12 +270,8 @@ export const trackFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'track', - ], - operation: [ - 'event', - ], + resource: ['track'], + operation: ['event'], }, }, default: {}, @@ -323,12 +306,8 @@ export const trackFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'track', - ], - operation: [ - 'event', - ], + resource: ['track'], + operation: ['event'], }, }, default: {}, @@ -353,9 +332,9 @@ export const trackFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* track:page */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* track:page */ + /* -------------------------------------------------------------------------- */ { displayName: 'User ID', name: 'userId', @@ -363,12 +342,8 @@ export const trackFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'track', - ], - operation: [ - 'page', - ], + resource: ['track'], + operation: ['page'], }, }, }, @@ -379,15 +354,12 @@ export const trackFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'track', - ], - operation: [ - 'page', - ], + resource: ['track'], + operation: ['page'], }, }, - description: 'Name of the page For example, most sites have a “Signup” page that can be useful to tag, so you can see users as they move through your funnel', + description: + 'Name of the page For example, most sites have a “Signup” page that can be useful to tag, so you can see users as they move through your funnel', }, { displayName: 'Context', @@ -399,12 +371,8 @@ export const trackFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'track', - ], - operation: [ - 'page', - ], + resource: ['track'], + operation: ['page'], }, }, default: {}, @@ -439,14 +407,16 @@ export const trackFields: INodeProperties[] = [ name: 'page', type: 'string', default: '', - description: 'Dictionary of information about the current page in the browser, containing hash, path, referrer, search, title and URL', + description: + 'Dictionary of information about the current page in the browser, containing hash, path, referrer, search, title and URL', }, { displayName: 'Timezone', name: 'timezone', type: 'string', default: '', - description: 'Timezones are sent as tzdata strings to add user timezone information which might be stripped from the timestamp, for example America/New_York', + description: + 'Timezones are sent as tzdata strings to add user timezone information which might be stripped from the timestamp, for example America/New_York', }, { displayName: 'App', @@ -600,12 +570,8 @@ export const trackFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'track', - ], - operation: [ - 'page', - ], + resource: ['track'], + operation: ['page'], }, }, default: {}, @@ -640,12 +606,8 @@ export const trackFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'track', - ], - operation: [ - 'page', - ], + resource: ['track'], + operation: ['page'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/Segment/TrackInterface.ts b/packages/nodes-base/nodes/Segment/TrackInterface.ts index 6fe9270012..a15b8eed2b 100644 --- a/packages/nodes-base/nodes/Segment/TrackInterface.ts +++ b/packages/nodes-base/nodes/Segment/TrackInterface.ts @@ -1,6 +1,4 @@ -import { - IDataObject, -} from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export interface ITrack { event?: string; @@ -14,6 +12,6 @@ export interface ITrack { integrations?: IDataObject; } -export interface IGroup extends ITrack{ +export interface IGroup extends ITrack { groupId: string; } diff --git a/packages/nodes-base/nodes/SendGrid/ContactDescription.ts b/packages/nodes-base/nodes/SendGrid/ContactDescription.ts index 3533528975..6542ab4460 100644 --- a/packages/nodes-base/nodes/SendGrid/ContactDescription.ts +++ b/packages/nodes-base/nodes/SendGrid/ContactDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactOperations: INodeProperties[] = [ { @@ -10,16 +8,15 @@ export const contactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contact', - ], + resource: ['contact'], }, }, options: [ { name: 'Create or Update', value: 'upsert', - description: 'Create a new contact, or update the current one if it already exists (upsert)', + description: + 'Create a new contact, or update the current one if it already exists (upsert)', action: 'Create or update a contact', }, { @@ -55,12 +52,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, default: false, @@ -72,15 +65,9 @@ export const contactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['contact'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -98,12 +85,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, options: [ @@ -112,7 +95,8 @@ export const contactFields: INodeProperties[] = [ name: 'query', type: 'string', default: '', - description: 'The query field accepts valid SGQL for searching for a contact', + description: + 'The query field accepts valid SGQL for searching for a contact', }, ], }, @@ -128,12 +112,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'upsert', - ], - resource: [ - 'contact', - ], + operation: ['upsert'], + resource: ['contact'], }, }, default: '', @@ -147,12 +127,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'upsert', - ], + resource: ['contact'], + operation: ['upsert'], }, }, options: [ @@ -248,7 +224,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getListIds', }, default: [], - description: 'ID of the field to set. Choose from the list, or specify IDs using an expression.', + description: + 'ID of the field to set. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -277,7 +254,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'ID of the field. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the field. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Field Value', @@ -303,15 +281,9 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'delete', - ], - deleteAll: [ - false, - ], + resource: ['contact'], + operation: ['delete'], + deleteAll: [false], }, }, description: 'ID of the contact. Multiple can be added separated by comma.', @@ -322,12 +294,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'delete', - ], + resource: ['contact'], + operation: ['delete'], }, }, default: false, @@ -354,12 +322,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], + operation: ['get'], + resource: ['contact'], }, }, default: 'id', @@ -372,15 +336,9 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], - by: [ - 'id', - ], + operation: ['get'], + resource: ['contact'], + by: ['id'], }, }, default: '', @@ -394,15 +352,9 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], - by: [ - 'email', - ], + operation: ['get'], + resource: ['contact'], + by: ['email'], }, }, default: '', diff --git a/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts b/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts index b7ba9b7a26..abd813a29c 100644 --- a/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,11 +7,18 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function sendGridApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, endpoint: string, method: string, body: any = {}, qs: IDataObject = {}, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function sendGridApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + endpoint: string, + method: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const host = 'api.sendgrid.com/v3'; const options: OptionsWithUri = { @@ -39,8 +44,16 @@ export async function sendGridApiRequest(this: IHookFunctions | IExecuteFunction } } -export async function sendGridApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, endpoint: string, method: string, propertyName: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function sendGridApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + endpoint: string, + method: string, + propertyName: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -54,9 +67,7 @@ export async function sendGridApiRequestAllItems(this: IExecuteFunctions | ILoad if (query.limit && returnData.length >= query.limit) { return returnData; } - } while ( - responseData._metadata.next !== undefined - ); + } while (responseData._metadata.next !== undefined); return returnData; } diff --git a/packages/nodes-base/nodes/SendGrid/ListDescription.ts b/packages/nodes-base/nodes/SendGrid/ListDescription.ts index 646e0d3c73..7e3d6eef1f 100644 --- a/packages/nodes-base/nodes/SendGrid/ListDescription.ts +++ b/packages/nodes-base/nodes/SendGrid/ListDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const listOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const listOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'list', - ], + resource: ['list'], }, }, options: [ @@ -61,12 +57,8 @@ export const listFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], + resource: ['list'], + operation: ['getAll'], }, }, default: false, @@ -78,15 +70,9 @@ export const listFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['list'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -107,12 +93,8 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'list', - ], + operation: ['create'], + resource: ['list'], }, }, default: '', @@ -129,12 +111,8 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'list', - ], + operation: ['delete'], + resource: ['list'], }, }, default: '', @@ -147,12 +125,8 @@ export const listFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'list', - ], + operation: ['delete'], + resource: ['list'], }, }, description: 'Whether to delete all contacts on the list', @@ -168,12 +142,8 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'list', - ], + operation: ['get'], + resource: ['list'], }, }, default: '', @@ -186,12 +156,8 @@ export const listFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'list', - ], + operation: ['get'], + resource: ['list'], }, }, description: 'Whether to return the contact sample', @@ -206,12 +172,8 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'list', - ], + operation: ['update'], + resource: ['list'], }, }, default: '', @@ -224,12 +186,8 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'list', - ], + operation: ['update'], + resource: ['list'], }, }, default: '', diff --git a/packages/nodes-base/nodes/SendGrid/MailDescription.ts b/packages/nodes-base/nodes/SendGrid/MailDescription.ts index f331de786c..1a02f8b6f9 100644 --- a/packages/nodes-base/nodes/SendGrid/MailDescription.ts +++ b/packages/nodes-base/nodes/SendGrid/MailDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const mailOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const mailOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'mail', - ], + resource: ['mail'], }, }, options: [ @@ -40,12 +36,8 @@ export const mailFields: INodeProperties[] = [ description: 'Email address of the sender of the email', displayOptions: { show: { - resource: [ - 'mail', - ], - operation: [ - 'send', - ], + resource: ['mail'], + operation: ['send'], }, }, }, @@ -58,12 +50,8 @@ export const mailFields: INodeProperties[] = [ description: 'Name of the sender of the email', displayOptions: { show: { - resource: [ - 'mail', - ], - operation: [ - 'send', - ], + resource: ['mail'], + operation: ['send'], }, }, }, @@ -76,12 +64,8 @@ export const mailFields: INodeProperties[] = [ description: 'Comma-separated list of recipient email addresses', displayOptions: { show: { - resource: [ - 'mail', - ], - operation: [ - 'send', - ], + resource: ['mail'], + operation: ['send'], }, }, }, @@ -93,15 +77,9 @@ export const mailFields: INodeProperties[] = [ description: 'Subject of the email to send', displayOptions: { show: { - resource: [ - 'mail', - ], - operation: [ - 'send', - ], - dynamicTemplate: [ - false, - ], + resource: ['mail'], + operation: ['send'], + dynamicTemplate: [false], }, }, }, @@ -114,12 +92,8 @@ export const mailFields: INodeProperties[] = [ description: 'Whether this email will contain a dynamic template', displayOptions: { show: { - resource: [ - 'mail', - ], - operation: [ - 'send', - ], + resource: ['mail'], + operation: ['send'], }, }, }, @@ -141,15 +115,9 @@ export const mailFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'mail', - ], - operation: [ - 'send', - ], - dynamicTemplate: [ - false, - ], + resource: ['mail'], + operation: ['send'], + dynamicTemplate: [false], }, }, }, @@ -165,15 +133,9 @@ export const mailFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'mail', - ], - operation: [ - 'send', - ], - dynamicTemplate: [ - false, - ], + resource: ['mail'], + operation: ['send'], + dynamicTemplate: [false], }, }, }, @@ -181,22 +143,17 @@ export const mailFields: INodeProperties[] = [ displayName: 'Template Name or ID', name: 'templateId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: [], typeOptions: { loadOptionsMethod: 'getTemplateIds', }, displayOptions: { show: { - resource: [ - 'mail', - ], - operation: [ - 'send', - ], - dynamicTemplate: [ - true, - ], + resource: ['mail'], + operation: ['send'], + dynamicTemplate: [true], }, }, }, @@ -211,15 +168,9 @@ export const mailFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'mail', - ], - operation: [ - 'send', - ], - dynamicTemplate: [ - true, - ], + resource: ['mail'], + operation: ['send'], + dynamicTemplate: [true], }, }, options: [ @@ -253,12 +204,8 @@ export const mailFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'mail', - ], - operation: [ - 'send', - ], + resource: ['mail'], + operation: ['send'], }, }, options: [ @@ -274,21 +221,24 @@ export const mailFields: INodeProperties[] = [ name: 'bccEmail', type: 'string', default: '', - description: 'Comma-separated list of emails of the recipients of a blind carbon copy of the email', + description: + 'Comma-separated list of emails of the recipients of a blind carbon copy of the email', }, { displayName: 'Categories', name: 'categories', type: 'string', default: '', - description: 'Comma-separated list of categories. Each category name may not exceed 255 characters.', + description: + 'Comma-separated list of categories. Each category name may not exceed 255 characters.', }, { displayName: 'CC Email', name: 'ccEmail', type: 'string', default: '', - description: 'Comma-separated list of emails of the recipients of a carbon copy of the email', + description: + 'Comma-separated list of emails of the recipients of a carbon copy of the email', }, { displayName: 'Enable Sandbox', @@ -341,7 +291,8 @@ export const mailFields: INodeProperties[] = [ name: 'sendAt', type: 'dateTime', default: '', - description: 'When to deliver the email. Scheduling more than 72 hours in advance is forbidden.', + description: + 'When to deliver the email. Scheduling more than 72 hours in advance is forbidden.', }, ], }, @@ -349,35 +300,35 @@ export const mailFields: INodeProperties[] = [ export type SendMailBody = { personalizations: Array<{ - to: EmailName[], - subject?: string, - cc?: EmailName[], - bcc?: EmailName[], - dynamic_template_data?: { [key: string]: string }, - send_at?: number, - }>, + to: EmailName[]; + subject?: string; + cc?: EmailName[]; + bcc?: EmailName[]; + dynamic_template_data?: { [key: string]: string }; + send_at?: number; + }>; ip_pool_name?: string; - from: EmailName, - template_id?: string, + from: EmailName; + template_id?: string; content?: Array<{ - type: string, - value: string, - }>, - categories?: string[], - headers?: { [key: string]: string }, + type: string; + value: string; + }>; + categories?: string[]; + headers?: { [key: string]: string }; attachments?: Array<{ - content: string, - filename: string, - type: string, - }>, + content: string; + filename: string; + type: string; + }>; mail_settings: { sandbox_mode: { - enable: boolean, - }, - }, + enable: boolean; + }; + }; }; type EmailName = { - email: string, - name?: string, + email: string; + name?: string; }; diff --git a/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts b/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts index 8032b2b507..28fba2bc01 100644 --- a/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts +++ b/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts @@ -7,29 +7,16 @@ import { INodePropertyOptions, INodeType, INodeTypeDescription, - NodeOperationError + NodeOperationError, } from 'n8n-workflow'; -import { - listFields, - listOperations, -} from './ListDescription'; +import { listFields, listOperations } from './ListDescription'; -import { - contactFields, - contactOperations -} from './ContactDescription'; +import { contactFields, contactOperations } from './ContactDescription'; -import { - mailFields, - mailOperations, - SendMailBody, -} from './MailDescription'; +import { mailFields, mailOperations, SendMailBody } from './MailDescription'; -import { - sendGridApiRequest, - sendGridApiRequestAllItems, -} from './GenericFunctions'; +import { sendGridApiRequest, sendGridApiRequestAllItems } from './GenericFunctions'; import moment from 'moment-timezone'; @@ -90,9 +77,15 @@ export class SendGrid implements INodeType { methods = { loadOptions: { // Get custom fields to display to user so that they can select them easily - async getCustomFields(this: ILoadOptionsFunctions,): Promise { + async getCustomFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { custom_fields } = await sendGridApiRequest.call(this, '/marketing/field_definitions', 'GET', {}, {}); + const { custom_fields } = await sendGridApiRequest.call( + this, + '/marketing/field_definitions', + 'GET', + {}, + {}, + ); if (custom_fields !== undefined) { for (const customField of custom_fields) { returnData.push({ @@ -106,7 +99,14 @@ export class SendGrid implements INodeType { // Get lists to display to user so that they can select them easily async getListIds(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const lists = await sendGridApiRequestAllItems.call(this, `/marketing/lists`, 'GET', 'result', {}, {}); + const lists = await sendGridApiRequestAllItems.call( + this, + `/marketing/lists`, + 'GET', + 'result', + {}, + {}, + ); for (const list of lists) { returnData.push({ name: list.name, @@ -116,8 +116,17 @@ export class SendGrid implements INodeType { return returnData; }, async getTemplateIds(this: ILoadOptionsFunctions): Promise { - const responseData = await sendGridApiRequest.call(this, '/templates', 'GET', {}, { generations: 'dynamic' }); - return responseData.templates.map(({ id, name }: { id: string, name: string }) => ({ name, value: id })); + const responseData = await sendGridApiRequest.call( + this, + '/templates', + 'GET', + {}, + { generations: 'dynamic' }, + ); + return responseData.templates.map(({ id, name }: { id: string; name: string }) => ({ + name, + value: id, + })); }, }, }; @@ -146,7 +155,14 @@ export class SendGrid implements INodeType { method = 'POST'; Object.assign(body, { query: filters.query }); } - responseData = await sendGridApiRequestAllItems.call(this, endpoint, method, 'result', body, qs); + responseData = await sendGridApiRequestAllItems.call( + this, + endpoint, + method, + 'result', + body, + qs, + ); if (returnAll === false) { const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.splice(0, limit); @@ -199,15 +215,13 @@ export class SendGrid implements INodeType { let lists; for (let i = 0; i < length; i++) { const email = this.getNodeParameter('email', i) as string; - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const contact: IDataObject = { email, }; if (additionalFields.addressUi) { - const addressValues = (additionalFields.addressUi as IDataObject).addressValues as IDataObject; + const addressValues = (additionalFields.addressUi as IDataObject) + .addressValues as IDataObject; const addressLine1 = addressValues.address1 as string; const addressLine2 = addressValues.address2 as string; if (addressLine2) { @@ -240,26 +254,39 @@ export class SendGrid implements INodeType { Object.assign(contact, { state_province_region: stateProvinceRegion }); } if (additionalFields.alternateEmails) { - const alternateEmails = ((additionalFields.alternateEmails as string).split(',') as string[]).filter(email => !!email); + const alternateEmails = ( + (additionalFields.alternateEmails as string).split(',') as string[] + ).filter((email) => !!email); if (alternateEmails.length !== 0) { Object.assign(contact, { alternate_emails: alternateEmails }); } } if (additionalFields.listIdsUi) { - const listIdValues = (additionalFields.listIdsUi as IDataObject).listIdValues as IDataObject; + const listIdValues = (additionalFields.listIdsUi as IDataObject) + .listIdValues as IDataObject; const listIds = listIdValues.listIds as IDataObject[]; lists = listIds; } if (additionalFields.customFieldsUi) { - const customFields = (additionalFields.customFieldsUi as IDataObject).customFieldValues as IDataObject[]; + const customFields = (additionalFields.customFieldsUi as IDataObject) + .customFieldValues as IDataObject[]; if (customFields) { - const data = customFields.reduce((obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), {}); + const data = customFields.reduce( + (obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), + {}, + ); Object.assign(contact, { custom_fields: data }); } } contacts.push(contact); } - responseData = await sendGridApiRequest.call(this, '/marketing/contacts', 'PUT', { list_ids: lists, contacts }, qs); + responseData = await sendGridApiRequest.call( + this, + '/marketing/contacts', + 'PUT', + { list_ids: lists, contacts }, + qs, + ); returnData.push(responseData); } catch (error) { if (this.continueOnFail()) { @@ -277,7 +304,13 @@ export class SendGrid implements INodeType { qs.delete_all_contacts = 'true'; } qs.ids = (this.getNodeParameter('ids', i) as string).replace(/\s/g, ''); - responseData = await sendGridApiRequest.call(this, `/marketing/contacts`, 'DELETE', {}, qs); + responseData = await sendGridApiRequest.call( + this, + `/marketing/contacts`, + 'DELETE', + {}, + qs, + ); returnData.push(responseData); } catch (error) { if (this.continueOnFail()) { @@ -294,7 +327,14 @@ export class SendGrid implements INodeType { for (let i = 0; i < length; i++) { try { const returnAll = this.getNodeParameter('returnAll', i) as boolean; - responseData = await sendGridApiRequestAllItems.call(this, `/marketing/lists`, 'GET', 'result', {}, qs); + responseData = await sendGridApiRequestAllItems.call( + this, + `/marketing/lists`, + 'GET', + 'result', + {}, + qs, + ); if (returnAll === false) { const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.splice(0, limit); @@ -314,7 +354,13 @@ export class SendGrid implements INodeType { try { const listId = this.getNodeParameter('listId', i) as string; qs.contact_sample = this.getNodeParameter('contactSample', i) as boolean; - responseData = await sendGridApiRequest.call(this, `/marketing/lists/${listId}`, 'GET', {}, qs); + responseData = await sendGridApiRequest.call( + this, + `/marketing/lists/${listId}`, + 'GET', + {}, + qs, + ); returnData.push(responseData); } catch (error) { if (this.continueOnFail()) { @@ -329,7 +375,13 @@ export class SendGrid implements INodeType { for (let i = 0; i < length; i++) { try { const name = this.getNodeParameter('name', i) as string; - responseData = await sendGridApiRequest.call(this, '/marketing/lists', 'POST', { name }, qs); + responseData = await sendGridApiRequest.call( + this, + '/marketing/lists', + 'POST', + { name }, + qs, + ); returnData.push(responseData); } catch (error) { if (this.continueOnFail()) { @@ -345,7 +397,13 @@ export class SendGrid implements INodeType { try { const listId = this.getNodeParameter('listId', i) as string; qs.delete_contacts = this.getNodeParameter('deleteContacts', i) as boolean; - responseData = await sendGridApiRequest.call(this, `/marketing/lists/${listId}`, 'DELETE', {}, qs); + responseData = await sendGridApiRequest.call( + this, + `/marketing/lists/${listId}`, + 'DELETE', + {}, + qs, + ); responseData = { success: true }; returnData.push(responseData); } catch (error) { @@ -362,7 +420,13 @@ export class SendGrid implements INodeType { try { const name = this.getNodeParameter('name', i) as string; const listId = this.getNodeParameter('listId', i) as string; - responseData = await sendGridApiRequest.call(this, `/marketing/lists/${listId}`, 'PATCH', { name }, qs); + responseData = await sendGridApiRequest.call( + this, + `/marketing/lists/${listId}`, + 'PATCH', + { name }, + qs, + ); returnData.push(responseData); } catch (error) { if (this.continueOnFail()) { @@ -396,7 +460,7 @@ export class SendGrid implements INodeType { } = this.getNodeParameter('additionalFields', i) as { bccEmail: string; ccEmail: string; - enableSandbox: boolean, + enableSandbox: boolean; sendAt: string; headers: { details: Array<{ key: string; value: string }> }; attachments: string; @@ -405,9 +469,11 @@ export class SendGrid implements INodeType { }; const body: SendMailBody = { - personalizations: [{ - to: parsedToEmail, - }], + personalizations: [ + { + to: parsedToEmail, + }, + ], from: { email: (this.getNodeParameter('fromEmail', i) as string).trim(), name: this.getNodeParameter('fromName', i) as string, @@ -426,12 +492,12 @@ export class SendGrid implements INodeType { body.template_id = this.getNodeParameter('templateId', i) as string; const { fields } = this.getNodeParameter('dynamicTemplateFields', i) as { - fields: Array<{ [key: string]: string }> + fields: Array<{ [key: string]: string }>; }; if (fields) { body.personalizations[0].dynamic_template_data = {}; - fields.forEach(field => { + fields.forEach((field) => { body.personalizations[0].dynamic_template_data![field.key] = field.value; }); } @@ -439,10 +505,12 @@ export class SendGrid implements INodeType { // message body } else { body.personalizations[0].subject = this.getNodeParameter('subject', i) as string; - body.content = [{ - type: this.getNodeParameter('contentType', i) as string, - value: this.getNodeParameter('contentValue', i) as string, - }]; + body.content = [ + { + type: this.getNodeParameter('contentType', i) as string, + value: this.getNodeParameter('contentValue', i) as string, + }, + ]; } if (attachments) { @@ -451,7 +519,11 @@ export class SendGrid implements INodeType { for (const property of binaryProperties) { if (!items[i].binary?.hasOwnProperty(property)) { - throw new NodeOperationError(this.getNode(), `The binary property ${property} does not exist`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The binary property ${property} does not exist`, + { itemIndex: i }, + ); } const binaryProperty = items[i].binary![property]; @@ -471,16 +543,16 @@ export class SendGrid implements INodeType { } if (bccEmail) { - body.personalizations[0].bcc = bccEmail.split(',').map(i => ({ email: i.trim() })); + body.personalizations[0].bcc = bccEmail.split(',').map((i) => ({ email: i.trim() })); } if (ccEmail) { - body.personalizations[0].cc = ccEmail.split(',').map(i => ({ email: i.trim() })); + body.personalizations[0].cc = ccEmail.split(',').map((i) => ({ email: i.trim() })); } if (headers?.details.length) { const parsedHeaders: { [key: string]: string } = {}; - headers.details.forEach(obj => parsedHeaders[obj['key']] = obj['value']); + headers.details.forEach((obj) => (parsedHeaders[obj['key']] = obj['value'])); body.headers = parsedHeaders; } @@ -496,7 +568,9 @@ export class SendGrid implements INodeType { body.personalizations[0].send_at = moment.tz(sendAt, timezone).unix(); } - const data = await sendGridApiRequest.call(this, '/mail/send', 'POST', body, qs, { resolveWithFullResponse: true }); + const data = await sendGridApiRequest.call(this, '/mail/send', 'POST', body, qs, { + resolveWithFullResponse: true, + }); returnData.push({ messageId: data!.headers['x-message-id'] }); } catch (error) { diff --git a/packages/nodes-base/nodes/Sendy/CampaignDescription.ts b/packages/nodes-base/nodes/Sendy/CampaignDescription.ts index e37def7b7c..84c86fc091 100644 --- a/packages/nodes-base/nodes/Sendy/CampaignDescription.ts +++ b/packages/nodes-base/nodes/Sendy/CampaignDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const campaignOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const campaignOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'campaign', - ], + resource: ['campaign'], }, }, options: [ @@ -28,26 +24,21 @@ export const campaignOperations: INodeProperties[] = [ ]; export const campaignFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* campaign:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* campaign:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'From Name', name: 'fromName', type: 'string', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'create', - ], + resource: ['campaign'], + operation: ['create'], }, }, default: '', - description: 'The \'From name\' of your campaign', + description: "The 'From name' of your campaign", }, { displayName: 'From Email', @@ -55,16 +46,12 @@ export const campaignFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'create', - ], + resource: ['campaign'], + operation: ['create'], }, }, default: '', - description: 'The \'From email\' of your campaign', + description: "The 'From email' of your campaign", }, { displayName: 'Reply To', @@ -72,16 +59,12 @@ export const campaignFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'create', - ], + resource: ['campaign'], + operation: ['create'], }, }, default: '', - description: 'The \'Reply to\' of your campaign', + description: "The 'Reply to' of your campaign", }, { displayName: 'Title', @@ -89,16 +72,12 @@ export const campaignFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'create', - ], + resource: ['campaign'], + operation: ['create'], }, }, default: '', - description: 'The \'Title\' of your campaign', + description: "The 'Title' of your campaign", }, { displayName: 'Subject', @@ -106,16 +85,12 @@ export const campaignFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'create', - ], + resource: ['campaign'], + operation: ['create'], }, }, default: '', - description: 'The \'Subject\' of your campaign', + description: "The 'Subject' of your campaign", }, { displayName: 'HTML Text', @@ -123,16 +98,12 @@ export const campaignFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'create', - ], + resource: ['campaign'], + operation: ['create'], }, }, default: '', - description: 'The \'HTML version\' of your campaign', + description: "The 'HTML version' of your campaign", }, { displayName: 'Send Campaign', @@ -140,16 +111,13 @@ export const campaignFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'create', - ], + resource: ['campaign'], + operation: ['create'], }, }, default: false, - description: 'Whether to send the campaign as well and not just create a draft. Default is false.', + description: + 'Whether to send the campaign as well and not just create a draft. Default is false.', }, { displayName: 'Brand ID', @@ -157,15 +125,9 @@ export const campaignFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'campaign', - ], - sendCampaign: [ - false, - ], + operation: ['create'], + resource: ['campaign'], + sendCampaign: [false], }, }, required: true, @@ -179,12 +141,8 @@ export const campaignFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'create', - ], + resource: ['campaign'], + operation: ['create'], }, }, options: [ @@ -193,14 +151,16 @@ export const campaignFields: INodeProperties[] = [ name: 'excludeListIds', type: 'string', default: '', - description: 'Lists to exclude from your campaign. List IDs should be single or comma-separated.', + description: + 'Lists to exclude from your campaign. List IDs should be single or comma-separated.', }, { displayName: 'Exclude Segment IDs', name: 'excludeSegmentIds', type: 'string', default: '', - description: 'Segments to exclude from your campaign. Segment IDs should be single or comma-separated.', + description: + 'Segments to exclude from your campaign. Segment IDs should be single or comma-separated.', }, { displayName: 'List IDs', @@ -214,7 +174,7 @@ export const campaignFields: INodeProperties[] = [ name: 'plainText', type: 'string', default: '', - description: 'The \'Plain text version\' of your campaign', + description: "The 'Plain text version' of your campaign", }, { displayName: 'Querystring', diff --git a/packages/nodes-base/nodes/Sendy/GenericFunctions.ts b/packages/nodes-base/nodes/Sendy/GenericFunctions.ts index 1d70932fef..96b2bd22ca 100644 --- a/packages/nodes-base/nodes/Sendy/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Sendy/GenericFunctions.ts @@ -1,18 +1,19 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; - -export async function sendyApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, option = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError } from 'n8n-workflow'; +export async function sendyApiRequest( + this: IExecuteFunctions | ILoadOptionsFunctions, + method: string, + path: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + option = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('sendyApi'); body.api_key = credentials.apiKey; diff --git a/packages/nodes-base/nodes/Sendy/Sendy.node.ts b/packages/nodes-base/nodes/Sendy/Sendy.node.ts index 37164bdffd..d562a4e560 100644 --- a/packages/nodes-base/nodes/Sendy/Sendy.node.ts +++ b/packages/nodes-base/nodes/Sendy/Sendy.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,19 +9,11 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - sendyApiRequest, -} from './GenericFunctions'; +import { sendyApiRequest } from './GenericFunctions'; -import { - campaignFields, - campaignOperations, -} from './CampaignDescription'; +import { campaignFields, campaignOperations } from './CampaignDescription'; -import { - subscriberFields, - subscriberOperations, -} from './SubscriberDescription'; +import { subscriberFields, subscriberOperations } from './SubscriberDescription'; export class Sendy implements INodeType { description: INodeTypeDescription = { @@ -80,10 +70,8 @@ export class Sendy implements INodeType { const resource = this.getNodeParameter('resource', 0) as string; const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < length; i++) { - if (resource === 'campaign') { if (operation === 'create') { - const fromName = this.getNodeParameter('fromName', i) as string; const fromEmail = this.getNodeParameter('fromEmail', i) as string; @@ -139,11 +127,11 @@ export class Sendy implements INodeType { } if (additionalFields.trackOpens) { - body.track_opens = additionalFields.trackOpens as boolean ? 1 : 0; + body.track_opens = (additionalFields.trackOpens as boolean) ? 1 : 0; } if (additionalFields.trackClicks) { - body.track_clicks = additionalFields.trackClicks as boolean ? 1 : 0; + body.track_clicks = (additionalFields.trackClicks as boolean) ? 1 : 0; } responseData = await sendyApiRequest.call( @@ -153,10 +141,7 @@ export class Sendy implements INodeType { body, ); - const success = [ - 'Campaign created', - 'Campaign created and now sending', - ]; + const success = ['Campaign created', 'Campaign created and now sending']; if (success.includes(responseData)) { responseData = { message: responseData }; @@ -168,7 +153,6 @@ export class Sendy implements INodeType { if (resource === 'subscriber') { if (operation === 'add') { - const email = this.getNodeParameter('email', i) as string; const listId = this.getNodeParameter('listId', i) as string; @@ -182,22 +166,20 @@ export class Sendy implements INodeType { Object.assign(body, additionalFields); - responseData = await sendyApiRequest.call( - this, - 'POST', - '/subscribe', - body, - ); + responseData = await sendyApiRequest.call(this, 'POST', '/subscribe', body); if (responseData === '1') { responseData = { success: true }; } else { - throw new NodeOperationError(this.getNode(), `Sendy error response [${400}]: ${responseData}`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Sendy error response [${400}]: ${responseData}`, + { itemIndex: i }, + ); } } if (operation === 'count') { - const listId = this.getNodeParameter('listId', i) as string; const body: IDataObject = { @@ -222,12 +204,15 @@ export class Sendy implements INodeType { if (!errors.includes(responseData)) { responseData = { count: responseData }; } else { - throw new NodeOperationError(this.getNode(), `Sendy error response [${400}]: ${responseData}`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Sendy error response [${400}]: ${responseData}`, + { itemIndex: i }, + ); } } if (operation === 'delete') { - const email = this.getNodeParameter('email', i) as string; const listId = this.getNodeParameter('listId', i) as string; @@ -247,12 +232,15 @@ export class Sendy implements INodeType { if (responseData === '1') { responseData = { success: true }; } else { - throw new NodeOperationError(this.getNode(), `Sendy error response [${400}]: ${responseData}`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Sendy error response [${400}]: ${responseData}`, + { itemIndex: i }, + ); } } if (operation === 'remove') { - const email = this.getNodeParameter('email', i) as string; const listId = this.getNodeParameter('listId', i) as string; @@ -262,22 +250,20 @@ export class Sendy implements INodeType { list: listId, }; - responseData = await sendyApiRequest.call( - this, - 'POST', - '/unsubscribe', - body, - ); + responseData = await sendyApiRequest.call(this, 'POST', '/unsubscribe', body); if (responseData === '1') { responseData = { success: true }; } else { - throw new NodeOperationError(this.getNode(), `Sendy error response [${400}]: ${responseData}`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Sendy error response [${400}]: ${responseData}`, + { itemIndex: i }, + ); } } if (operation === 'status') { - const email = this.getNodeParameter('email', i) as string; const listId = this.getNodeParameter('listId', i) as string; @@ -306,7 +292,11 @@ export class Sendy implements INodeType { if (status.includes(responseData)) { responseData = { status: responseData }; } else { - throw new NodeOperationError(this.getNode(), `Sendy error response [${400}]: ${responseData}`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Sendy error response [${400}]: ${responseData}`, + { itemIndex: i }, + ); } } } diff --git a/packages/nodes-base/nodes/Sendy/SubscriberDescription.ts b/packages/nodes-base/nodes/Sendy/SubscriberDescription.ts index fcd422a652..0c4715e37a 100644 --- a/packages/nodes-base/nodes/Sendy/SubscriberDescription.ts +++ b/packages/nodes-base/nodes/Sendy/SubscriberDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const subscriberOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const subscriberOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'subscriber', - ], + resource: ['subscriber'], }, }, options: [ @@ -44,7 +40,7 @@ export const subscriberOperations: INodeProperties[] = [ name: 'Status', value: 'status', description: 'Get the status of subscriber', - action: 'Get subscriber\'s status', + action: "Get subscriber's status", }, ], default: 'add', @@ -52,10 +48,9 @@ export const subscriberOperations: INodeProperties[] = [ ]; export const subscriberFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* subscriber:add */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* subscriber:add */ + /* -------------------------------------------------------------------------- */ { displayName: 'Email', name: 'email', @@ -63,12 +58,8 @@ export const subscriberFields: INodeProperties[] = [ placeholder: 'name@email.com', displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'add', - ], + resource: ['subscriber'], + operation: ['add'], }, }, default: '', @@ -80,16 +71,13 @@ export const subscriberFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'add', - ], + resource: ['subscriber'], + operation: ['add'], }, }, default: '', - description: 'The list ID you want to subscribe a user to. This encrypted & hashed ID can be found under View all lists section named ID.', + description: + 'The list ID you want to subscribe a user to. This encrypted & hashed ID can be found under View all lists section named ID.', }, { displayName: 'Additional Fields', @@ -99,12 +87,8 @@ export const subscriberFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'add', - ], + resource: ['subscriber'], + operation: ['add'], }, }, options: [ @@ -113,14 +97,14 @@ export const subscriberFields: INodeProperties[] = [ name: 'country', type: 'string', default: '', - description: 'User\'s 2 letter country code', + description: "User's 2 letter country code", }, { displayName: 'GDPR', name: 'gdpr', type: 'boolean', default: false, - description: 'Whether you\'re signing up EU users in a GDPR compliant manner', + description: "Whether you're signing up EU users in a GDPR compliant manner", }, { displayName: 'Honeypot', @@ -128,21 +112,22 @@ export const subscriberFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Include this \'honeypot\' field to prevent spambots from signing up via this API call. When spambots fills in this field, this API call will exit, preventing them from signing up fake addresses to your form. This parameter is only supported in Sendy 3.0 onwards.', + description: + "Include this 'honeypot' field to prevent spambots from signing up via this API call. When spambots fills in this field, this API call will exit, preventing them from signing up fake addresses to your form. This parameter is only supported in Sendy 3.0 onwards.", }, { displayName: 'IP Address', name: 'ipaddress', type: 'string', default: '', - description: 'User\'s IP address', + description: "User's IP address", }, { displayName: 'Name', name: 'name', type: 'string', default: '', - description: 'User\'s name', + description: "User's name", }, { displayName: 'Referrer', @@ -157,33 +142,31 @@ export const subscriberFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Set to "true" if your list is \'Double opt-in\' but you want to bypass that and signup the user to the list as \'Single Opt-in instead\' (optional)', + description: + "Set to \"true\" if your list is 'Double opt-in' but you want to bypass that and signup the user to the list as 'Single Opt-in instead' (optional)", }, ], }, -/* -------------------------------------------------------------------------- */ -/* subscriber:count */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* subscriber:count */ + /* -------------------------------------------------------------------------- */ { displayName: 'List ID', name: 'listId', type: 'string', displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'count', - ], + resource: ['subscriber'], + operation: ['count'], }, }, default: '', - description: 'The list ID you want to subscribe a user to. This encrypted & hashed ID can be found under View all lists section named ID.', + description: + 'The list ID you want to subscribe a user to. This encrypted & hashed ID can be found under View all lists section named ID.', }, -/* -------------------------------------------------------------------------- */ -/* subscriber:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* subscriber:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Email', name: 'email', @@ -191,12 +174,8 @@ export const subscriberFields: INodeProperties[] = [ placeholder: 'name@email.com', displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'delete', - ], + resource: ['subscriber'], + operation: ['delete'], }, }, default: '', @@ -208,20 +187,17 @@ export const subscriberFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'delete', - ], + resource: ['subscriber'], + operation: ['delete'], }, }, default: '', - description: 'The list ID you want to subscribe a user to. This encrypted & hashed ID can be found under View all lists section named ID.', + description: + 'The list ID you want to subscribe a user to. This encrypted & hashed ID can be found under View all lists section named ID.', }, -/* -------------------------------------------------------------------------- */ -/* subscriber:remove */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* subscriber:remove */ + /* -------------------------------------------------------------------------- */ { displayName: 'Email', name: 'email', @@ -229,12 +205,8 @@ export const subscriberFields: INodeProperties[] = [ placeholder: 'name@email.com', displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'remove', - ], + resource: ['subscriber'], + operation: ['remove'], }, }, default: '', @@ -246,20 +218,17 @@ export const subscriberFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'remove', - ], + resource: ['subscriber'], + operation: ['remove'], }, }, default: '', - description: 'The list ID you want to subscribe a user to. This encrypted & hashed ID can be found under View all lists section named ID.', + description: + 'The list ID you want to subscribe a user to. This encrypted & hashed ID can be found under View all lists section named ID.', }, -/* -------------------------------------------------------------------------- */ -/* subscriber:status */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* subscriber:status */ + /* -------------------------------------------------------------------------- */ { displayName: 'Email', name: 'email', @@ -267,12 +236,8 @@ export const subscriberFields: INodeProperties[] = [ placeholder: 'name@email.com', displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'status', - ], + resource: ['subscriber'], + operation: ['status'], }, }, default: '', @@ -284,15 +249,12 @@ export const subscriberFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'subscriber', - ], - operation: [ - 'status', - ], + resource: ['subscriber'], + operation: ['status'], }, }, default: '', - description: 'The list ID you want to subscribe a user to. This encrypted & hashed ID can be found under View all lists section named ID.', + description: + 'The list ID you want to subscribe a user to. This encrypted & hashed ID can be found under View all lists section named ID.', }, ]; diff --git a/packages/nodes-base/nodes/SentryIo/EventDescription.ts b/packages/nodes-base/nodes/SentryIo/EventDescription.ts index 7793dde696..16cfe110b1 100644 --- a/packages/nodes-base/nodes/SentryIo/EventDescription.ts +++ b/packages/nodes-base/nodes/SentryIo/EventDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const eventOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const eventOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'event', - ], + resource: ['event'], }, }, options: [ @@ -47,16 +43,13 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'getAll', - ], + resource: ['event'], + operation: ['getAll'], }, }, required: true, - description: 'The slug of the organization the events belong to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization the events belong to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Project Slug Name or ID', @@ -64,23 +57,18 @@ export const eventFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getProjects', - loadOptionsDependsOn: [ - 'organizationSlug', - ], + loadOptionsDependsOn: ['organizationSlug'], }, default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'getAll', - ], + resource: ['event'], + operation: ['getAll'], }, }, required: true, - description: 'The slug of the project the events belong to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the project the events belong to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Full', @@ -89,15 +77,12 @@ export const eventFields: INodeProperties[] = [ default: true, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'getAll', - ], + resource: ['event'], + operation: ['getAll'], }, }, - description: 'Whether the event payload will include the full event body, including the stack trace', + description: + 'Whether the event payload will include the full event body, including the stack trace', }, { displayName: 'Return All', @@ -105,12 +90,8 @@ export const eventFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'event', - ], + operation: ['getAll'], + resource: ['event'], }, }, default: false, @@ -122,15 +103,9 @@ export const eventFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'event', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['event'], + returnAll: [false], }, }, typeOptions: { @@ -154,16 +129,13 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'get', - ], + resource: ['event'], + operation: ['get'], }, }, required: true, - description: 'The slug of the organization the events belong to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization the events belong to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Project Slug Name or ID', @@ -175,16 +147,13 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'get', - ], + resource: ['event'], + operation: ['get'], }, }, required: true, - description: 'The slug of the project the events belong to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the project the events belong to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Event ID', @@ -193,15 +162,12 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'get', - ], + resource: ['event'], + operation: ['get'], }, }, required: true, - description: 'The ID of the event to retrieve (either the numeric primary-key or the hexadecimal ID as reported by the raven client)', + description: + 'The ID of the event to retrieve (either the numeric primary-key or the hexadecimal ID as reported by the raven client)', }, ]; diff --git a/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts b/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts index ae9b2243ae..975010e22a 100644 --- a/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -10,11 +8,24 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function sentryIoApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function sentryIoApiRequest( + this: + | IHookFunctions + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IWebhookFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const authentication = this.getNodeParameter('authentication', 0); const version = this.getNodeParameter('sentryVersion', 0); @@ -43,7 +54,6 @@ export async function sentryIoApiRequest(this: IHookFunctions | IExecuteFunction try { if (authentication === 'accessToken') { - if (version === 'cloud') { credentialName = 'sentryIoApi'; } else { @@ -62,19 +72,23 @@ export async function sentryIoApiRequest(this: IHookFunctions | IExecuteFunction //@ts-ignore return this.helpers.request(options); - } else { - return await this.helpers.requestOAuth2!.call(this, 'sentryIoOAuth2Api', options); } - } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function sentryApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function sentryApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -84,16 +98,16 @@ export async function sentryApiRequestAllItems(this: IHookFunctions | IExecuteFu let uri: string | undefined; do { - responseData = await sentryIoApiRequest.call(this, method, resource, body, query, uri, { resolveWithFullResponse: true }); + responseData = await sentryIoApiRequest.call(this, method, resource, body, query, uri, { + resolveWithFullResponse: true, + }); link = responseData.headers.link; uri = getNext(link); returnData.push.apply(returnData, responseData.body); - if (query.limit && (query.limit >= returnData.length)) { + if (query.limit && query.limit >= returnData.length) { return; } - } while ( - hasMore(link) - ); + } while (hasMore(link)); return returnData; } diff --git a/packages/nodes-base/nodes/SentryIo/IssueDescription.ts b/packages/nodes-base/nodes/SentryIo/IssueDescription.ts index 143e16276a..f547d61e82 100644 --- a/packages/nodes-base/nodes/SentryIo/IssueDescription.ts +++ b/packages/nodes-base/nodes/SentryIo/IssueDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const issueOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const issueOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'issue', - ], + resource: ['issue'], }, }, options: [ @@ -57,13 +53,8 @@ export const issueFields: INodeProperties[] = [ placeholder: '1234', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'get', - 'delete', - ], + resource: ['issue'], + operation: ['get', 'delete'], }, }, required: true, @@ -83,16 +74,13 @@ export const issueFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'getAll', - ], + resource: ['issue'], + operation: ['getAll'], }, }, required: true, - description: 'The slug of the organization the issues belong to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization the issues belong to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Project Slug Name or ID', @@ -100,23 +88,18 @@ export const issueFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getProjects', - loadOptionsDependsOn: [ - 'organizationSlug', - ], + loadOptionsDependsOn: ['organizationSlug'], }, default: '', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'getAll', - ], + resource: ['issue'], + operation: ['getAll'], }, }, required: true, - description: 'The slug of the project the issues belong to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the project the issues belong to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -124,12 +107,8 @@ export const issueFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'issue', - ], + operation: ['getAll'], + resource: ['issue'], }, }, default: false, @@ -141,15 +120,9 @@ export const issueFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'issue', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['issue'], + returnAll: [false], }, }, typeOptions: { @@ -167,12 +140,8 @@ export const issueFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'getAll', - ], + resource: ['issue'], + operation: ['getAll'], }, }, options: [ @@ -181,7 +150,8 @@ export const issueFields: INodeProperties[] = [ name: 'query', type: 'string', default: '', - description: 'An optional Sentry structured search query. If not provided, an implied "is:unresolved" is assumed. Info here.', + description: + 'An optional Sentry structured search query. If not provided, an implied "is:unresolved" is assumed. Info here.', }, { displayName: 'Stats Period', @@ -205,7 +175,8 @@ export const issueFields: INodeProperties[] = [ name: 'shortIdLookUp', type: 'boolean', default: true, - description: 'Whether short IDs are looked up by this function as well. This can cause the return value of the function to return an event issue of a different project which is why this is an opt-in.', + description: + 'Whether short IDs are looked up by this function as well. This can cause the return value of the function to return an event issue of a different project which is why this is an opt-in.', }, ], }, @@ -221,12 +192,8 @@ export const issueFields: INodeProperties[] = [ placeholder: '1234', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'update', - ], + resource: ['issue'], + operation: ['update'], }, }, required: true, @@ -240,12 +207,8 @@ export const issueFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'update', - ], + resource: ['issue'], + operation: ['update'], }, }, options: [ @@ -254,21 +217,24 @@ export const issueFields: INodeProperties[] = [ name: 'assignedTo', type: 'string', default: '', - description: 'The actor ID (or username) of the user or team that should be assigned to this issue', + description: + 'The actor ID (or username) of the user or team that should be assigned to this issue', }, { displayName: 'Has Seen', name: 'hasSeen', type: 'boolean', default: true, - description: 'Whether this API call is invoked with a user context this allows changing of the flag that indicates if the user has seen the event', + description: + 'Whether this API call is invoked with a user context this allows changing of the flag that indicates if the user has seen the event', }, { displayName: 'Is Bookmarked', name: 'isBookmarked', type: 'boolean', default: true, - description: 'Whether this API call is invoked with a user context this allows changing of the bookmark flag', + description: + 'Whether this API call is invoked with a user context this allows changing of the bookmark flag', }, { displayName: 'Is Public', diff --git a/packages/nodes-base/nodes/SentryIo/OrganizationDescription.ts b/packages/nodes-base/nodes/SentryIo/OrganizationDescription.ts index 1457ab32e7..d35bf99957 100644 --- a/packages/nodes-base/nodes/SentryIo/OrganizationDescription.ts +++ b/packages/nodes-base/nodes/SentryIo/OrganizationDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const organizationOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const organizationOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'organization', - ], + resource: ['organization'], }, }, options: [ @@ -55,12 +51,8 @@ export const organizationFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'organization', - ], + operation: ['getAll'], + resource: ['organization'], }, }, default: false, @@ -72,15 +64,9 @@ export const organizationFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'organization', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['organization'], + returnAll: [false], }, }, typeOptions: { @@ -98,12 +84,8 @@ export const organizationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'getAll', - ], + resource: ['organization'], + operation: ['getAll'], }, }, options: [ @@ -137,16 +119,13 @@ export const organizationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'get', - ], + resource: ['organization'], + operation: ['get'], }, }, required: true, - description: 'The slug of the organization the team should be created for. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization the team should be created for. Choose from the list, or specify an ID using an expression.', }, /* -------------------------------------------------------------------------- */ @@ -159,12 +138,8 @@ export const organizationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'create', - ], + resource: ['organization'], + operation: ['create'], }, }, required: true, @@ -177,15 +152,12 @@ export const organizationFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'create', - ], + resource: ['organization'], + operation: ['create'], }, }, - description: 'Whether you agree to the applicable terms of service and privacy policy of Sentry.io', + description: + 'Whether you agree to the applicable terms of service and privacy policy of Sentry.io', }, { displayName: 'Additional Fields', @@ -195,12 +167,8 @@ export const organizationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'create', - ], + resource: ['organization'], + operation: ['create'], }, }, options: [ @@ -209,7 +177,8 @@ export const organizationFields: INodeProperties[] = [ name: 'slug', type: 'string', default: '', - description: 'The unique URL slug for this organization. If this is not provided a slug is automatically generated based on the name.', + description: + 'The unique URL slug for this organization. If this is not provided a slug is automatically generated based on the name.', }, ], }, @@ -227,16 +196,13 @@ export const organizationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'update', - ], + resource: ['organization'], + operation: ['update'], }, }, required: true, - description: 'The slug of the organization to update. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization to update. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Update Fields', @@ -246,12 +212,8 @@ export const organizationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'update', - ], + resource: ['organization'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/SentryIo/ProjectDescription.ts b/packages/nodes-base/nodes/SentryIo/ProjectDescription.ts index e570828053..2f843b299a 100644 --- a/packages/nodes-base/nodes/SentryIo/ProjectDescription.ts +++ b/packages/nodes-base/nodes/SentryIo/ProjectDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const projectOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const projectOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'project', - ], + resource: ['project'], }, }, options: [ @@ -65,17 +61,13 @@ export const projectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'create', - 'get', - ], + resource: ['project'], + operation: ['create', 'get'], }, }, required: true, - description: 'The slug of the organization the events belong to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization the events belong to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Project Slug Name or ID', @@ -83,23 +75,18 @@ export const projectFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getProjects', - loadOptionsDependsOn: [ - 'organizationSlug', - ], + loadOptionsDependsOn: ['organizationSlug'], }, default: '', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'get', - ], + resource: ['project'], + operation: ['get'], }, }, required: true, - description: 'The slug of the project to retrieve. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the project to retrieve. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Team Slug Name or ID', @@ -107,23 +94,18 @@ export const projectFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getTeams', - loadOptionsDependsOn: [ - 'organizationSlug', - ], + loadOptionsDependsOn: ['organizationSlug'], }, default: '', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'create', - ], + resource: ['project'], + operation: ['create'], }, }, required: true, - description: 'The slug of the team to create a new project for. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the team to create a new project for. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Name', @@ -132,12 +114,8 @@ export const projectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'create', - ], + resource: ['project'], + operation: ['create'], }, }, required: true, @@ -151,12 +129,8 @@ export const projectFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'create', - ], + resource: ['project'], + operation: ['create'], }, }, options: [ @@ -165,7 +139,8 @@ export const projectFields: INodeProperties[] = [ name: 'slug', type: 'string', default: '', - description: 'Optionally a slug for the new project. If it’s not provided a slug is generated from the name.', + description: + 'Optionally a slug for the new project. If it’s not provided a slug is generated from the name.', }, ], }, @@ -179,12 +154,8 @@ export const projectFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'project', - ], + operation: ['getAll'], + resource: ['project'], }, }, default: false, @@ -196,15 +167,9 @@ export const projectFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'project', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['project'], + returnAll: [false], }, }, typeOptions: { @@ -228,16 +193,13 @@ export const projectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'update', - ], + resource: ['project'], + operation: ['update'], }, }, required: true, - description: 'The slug of the organization the project belong to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization the project belong to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Project Slug Name or ID', @@ -245,23 +207,18 @@ export const projectFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getProjects', - loadOptionsDependsOn: [ - 'organizationSlug', - ], + loadOptionsDependsOn: ['organizationSlug'], }, default: '', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'update', - ], + resource: ['project'], + operation: ['update'], }, }, required: true, - description: 'The slug of the project to update. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the project to update. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Update Fields', @@ -271,12 +228,8 @@ export const projectFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'update', - ], + resource: ['project'], + operation: ['update'], }, }, options: [ @@ -346,16 +299,13 @@ export const projectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'delete', - ], + resource: ['project'], + operation: ['delete'], }, }, required: true, - description: 'The slug of the organization the project belong to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization the project belong to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Project Slug Name or ID', @@ -363,22 +313,17 @@ export const projectFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getProjects', - loadOptionsDependsOn: [ - 'organizationSlug', - ], + loadOptionsDependsOn: ['organizationSlug'], }, default: '', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'delete', - ], + resource: ['project'], + operation: ['delete'], }, }, required: true, - description: 'The slug of the project to delete. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the project to delete. Choose from the list, or specify an ID using an expression.', }, ]; diff --git a/packages/nodes-base/nodes/SentryIo/ReleaseDescription.ts b/packages/nodes-base/nodes/SentryIo/ReleaseDescription.ts index 2e7062d484..3136027827 100644 --- a/packages/nodes-base/nodes/SentryIo/ReleaseDescription.ts +++ b/packages/nodes-base/nodes/SentryIo/ReleaseDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const releaseOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const releaseOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'release', - ], + resource: ['release'], }, }, options: [ @@ -65,16 +61,13 @@ export const releaseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'getAll', - ], + resource: ['release'], + operation: ['getAll'], }, }, required: true, - description: 'The slug of the organization the releases belong to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization the releases belong to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -82,12 +75,8 @@ export const releaseFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'release', - ], + operation: ['getAll'], + resource: ['release'], }, }, default: false, @@ -99,15 +88,9 @@ export const releaseFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'release', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['release'], + returnAll: [false], }, }, typeOptions: { @@ -125,12 +108,8 @@ export const releaseFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'getAll', - ], + resource: ['release'], + operation: ['getAll'], }, }, options: [ @@ -157,17 +136,13 @@ export const releaseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'get', - 'delete', - ], + resource: ['release'], + operation: ['get', 'delete'], }, }, required: true, - description: 'The slug of the organization the release belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization the release belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Version', @@ -176,13 +151,8 @@ export const releaseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'get', - 'delete', - ], + resource: ['release'], + operation: ['get', 'delete'], }, }, required: true, @@ -202,16 +172,13 @@ export const releaseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'create', - ], + resource: ['release'], + operation: ['create'], }, }, required: true, - description: 'The slug of the organization the release belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization the release belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Version', @@ -220,16 +187,13 @@ export const releaseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'create', - ], + resource: ['release'], + operation: ['create'], }, }, required: true, - description: 'A version identifier for this release. Can be a version number, a commit hash etc.', + description: + 'A version identifier for this release. Can be a version number, a commit hash etc.', }, { displayName: 'URL', @@ -238,16 +202,13 @@ export const releaseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'create', - ], + resource: ['release'], + operation: ['create'], }, }, required: true, - description: 'A URL that points to the release. This can be the path to an online interface to the sourcecode for instance.', + description: + 'A URL that points to the release. This can be the path to an online interface to the sourcecode for instance.', }, { displayName: 'Project Names or IDs', @@ -259,16 +220,13 @@ export const releaseFields: INodeProperties[] = [ default: [], displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'create', - ], + resource: ['release'], + operation: ['create'], }, }, required: true, - description: 'A list of project slugs that are involved in this release. Choose from the list, or specify IDs using an expression.', + description: + 'A list of project slugs that are involved in this release. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Additional Fields', @@ -278,12 +236,8 @@ export const releaseFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'create', - ], + resource: ['release'], + operation: ['create'], }, }, options: [ @@ -292,7 +246,8 @@ export const releaseFields: INodeProperties[] = [ name: 'dateReleased', type: 'dateTime', default: '', - description: 'An optional date that indicates when the release went live. If not provided the current time is assumed.', + description: + 'An optional date that indicates when the release went live. If not provided the current time is assumed.', }, { displayName: 'Commits', @@ -340,7 +295,8 @@ export const releaseFields: INodeProperties[] = [ { displayName: 'Patch Set', name: 'patchSet', - description: 'A list of the files that have been changed in the commit. Specifying the patch_set is necessary to power suspect commits and suggested assignees.', + description: + 'A list of the files that have been changed in the commit. Specifying the patch_set is necessary to power suspect commits and suggested assignees.', type: 'fixedCollection', typeOptions: { multipleValues: true, @@ -356,7 +312,8 @@ export const releaseFields: INodeProperties[] = [ name: 'path', type: 'string', default: '', - description: 'The path to the file. Both forward and backward slashes are supported.', + description: + 'The path to the file. Both forward and backward slashes are supported.', required: true, }, { @@ -405,7 +362,8 @@ export const releaseFields: INodeProperties[] = [ { displayName: 'Refs', name: 'refs', - description: 'An optional way to indicate the start and end commits for each repository included in a release', + description: + 'An optional way to indicate the start and end commits for each repository included in a release', type: 'fixedCollection', typeOptions: { multipleValues: true, @@ -459,16 +417,13 @@ export const releaseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'update', - ], + resource: ['release'], + operation: ['update'], }, }, required: true, - description: 'The slug of the organization the release belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization the release belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Version', @@ -477,16 +432,13 @@ export const releaseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'update', - ], + resource: ['release'], + operation: ['update'], }, }, required: true, - description: 'A version identifier for this release. Can be a version number, a commit hash etc.', + description: + 'A version identifier for this release. Can be a version number, a commit hash etc.', }, { displayName: 'Update Fields', @@ -496,12 +448,8 @@ export const releaseFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'update', - ], + resource: ['release'], + operation: ['update'], }, }, options: [ @@ -551,7 +499,8 @@ export const releaseFields: INodeProperties[] = [ { displayName: 'Patch Set', name: 'patchSet', - description: 'A list of the files that have been changed in the commit. Specifying the patch_set is necessary to power suspect commits and suggested assignees.', + description: + 'A list of the files that have been changed in the commit. Specifying the patch_set is necessary to power suspect commits and suggested assignees.', type: 'fixedCollection', typeOptions: { multipleValues: true, @@ -567,7 +516,8 @@ export const releaseFields: INodeProperties[] = [ name: 'path', type: 'string', default: '', - description: 'The path to the file. Both forward and backward slashes are supported.', + description: + 'The path to the file. Both forward and backward slashes are supported.', required: true, }, { @@ -618,19 +568,22 @@ export const releaseFields: INodeProperties[] = [ name: 'dateReleased', type: 'dateTime', default: '', - description: 'An optional date that indicates when the release went live. If not provided the current time is assumed.', + description: + 'An optional date that indicates when the release went live. If not provided the current time is assumed.', }, { displayName: 'Ref', name: 'ref', type: 'string', default: '', - description: 'A URL that points to the release. This can be the path to an online interface to the sourcecode for instance.', + description: + 'A URL that points to the release. This can be the path to an online interface to the sourcecode for instance.', }, { displayName: 'Refs', name: 'refs', - description: 'An optional way to indicate the start and end commits for each repository included in a release', + description: + 'An optional way to indicate the start and end commits for each repository included in a release', type: 'fixedCollection', typeOptions: { multipleValues: true, @@ -673,7 +626,8 @@ export const releaseFields: INodeProperties[] = [ name: 'url', type: 'string', default: '', - description: 'A URL that points to the release. This can be the path to an online interface to the sourcecode for instance.', + description: + 'A URL that points to the release. This can be the path to an online interface to the sourcecode for instance.', }, ], }, diff --git a/packages/nodes-base/nodes/SentryIo/SentryIo.node.ts b/packages/nodes-base/nodes/SentryIo/SentryIo.node.ts index b9567e85d3..eaf06b9c65 100644 --- a/packages/nodes-base/nodes/SentryIo/SentryIo.node.ts +++ b/packages/nodes-base/nodes/SentryIo/SentryIo.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,46 +9,21 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - eventFields, - eventOperations, -} from './EventDescription'; +import { eventFields, eventOperations } from './EventDescription'; -import { - issueFields, - issueOperations, -} from './IssueDescription'; +import { issueFields, issueOperations } from './IssueDescription'; -import { - organizationFields, - organizationOperations, -} from './OrganizationDescription'; +import { organizationFields, organizationOperations } from './OrganizationDescription'; -import { - projectFields, - projectOperations, -} from './ProjectDescription'; +import { projectFields, projectOperations } from './ProjectDescription'; -import { - releaseFields, - releaseOperations, -} from './ReleaseDescription'; +import { releaseFields, releaseOperations } from './ReleaseDescription'; -import { - teamFields, - teamOperations, -} from './TeamDescription'; +import { teamFields, teamOperations } from './TeamDescription'; -import { - sentryApiRequestAllItems, - sentryIoApiRequest, -} from './GenericFunctions'; +import { sentryApiRequestAllItems, sentryIoApiRequest } from './GenericFunctions'; -import { - ICommit, - IPatchSet, - IRef, -} from './Interface'; +import { ICommit, IPatchSet, IRef } from './Interface'; export class SentryIo implements INodeType { description: INodeTypeDescription = { @@ -72,12 +45,8 @@ export class SentryIo implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], - sentryVersion: [ - 'cloud', - ], + authentication: ['oAuth2'], + sentryVersion: ['cloud'], }, }, }, @@ -86,12 +55,8 @@ export class SentryIo implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], - sentryVersion: [ - 'cloud', - ], + authentication: ['accessToken'], + sentryVersion: ['cloud'], }, }, }, @@ -100,12 +65,8 @@ export class SentryIo implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], - sentryVersion: [ - 'server', - ], + authentication: ['accessToken'], + sentryVersion: ['server'], }, }, }, @@ -133,9 +94,7 @@ export class SentryIo implements INodeType { type: 'options', displayOptions: { show: { - sentryVersion: [ - 'cloud', - ], + sentryVersion: ['cloud'], }, }, options: [ @@ -156,9 +115,7 @@ export class SentryIo implements INodeType { type: 'options', displayOptions: { show: { - sentryVersion: [ - 'server', - ], + sentryVersion: ['server'], }, }, options: [ @@ -234,7 +191,12 @@ export class SentryIo implements INodeType { // Get all organizations so they can be displayed easily async getOrganizations(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const organizations = await sentryApiRequestAllItems.call(this, 'GET', `/api/0/organizations/`, {}); + const organizations = await sentryApiRequestAllItems.call( + this, + 'GET', + `/api/0/organizations/`, + {}, + ); for (const organization of organizations) { returnData.push({ @@ -244,8 +206,12 @@ export class SentryIo implements INodeType { } returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -259,7 +225,6 @@ export class SentryIo implements INodeType { const organizationSlug = this.getNodeParameter('organizationSlug') as string; for (const project of projects) { - if (organizationSlug !== project.organization.slug) { continue; } @@ -271,8 +236,12 @@ export class SentryIo implements INodeType { } returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -283,7 +252,12 @@ export class SentryIo implements INodeType { const returnData: INodePropertyOptions[] = []; const organizationSlug = this.getNodeParameter('organizationSlug') as string; - const teams = await sentryApiRequestAllItems.call(this, 'GET', `/api/0/organizations/${organizationSlug}/teams/`, {}); + const teams = await sentryApiRequestAllItems.call( + this, + 'GET', + `/api/0/organizations/${organizationSlug}/teams/`, + {}, + ); for (const team of teams) { returnData.push({ @@ -293,8 +267,12 @@ export class SentryIo implements INodeType { } returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -303,7 +281,6 @@ export class SentryIo implements INodeType { }, }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -379,7 +356,6 @@ export class SentryIo implements INodeType { const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.splice(0, limit); } - } if (operation === 'get') { const issueId = this.getNodeParameter('issueId', i) as string; @@ -491,7 +467,7 @@ export class SentryIo implements INodeType { const body = { name, - ...this.getNodeParameter('additionalFields', i) as IDataObject, + ...(this.getNodeParameter('additionalFields', i) as IDataObject), }; responseData = await sentryIoApiRequest.call(this, 'POST', endpoint, body, qs); diff --git a/packages/nodes-base/nodes/SentryIo/TeamDescription.ts b/packages/nodes-base/nodes/SentryIo/TeamDescription.ts index 6160971e27..17a6e4ac4b 100644 --- a/packages/nodes-base/nodes/SentryIo/TeamDescription.ts +++ b/packages/nodes-base/nodes/SentryIo/TeamDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const teamOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const teamOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'team', - ], + resource: ['team'], }, }, options: [ @@ -65,16 +61,13 @@ export const teamFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'getAll', - ], + resource: ['team'], + operation: ['getAll'], }, }, required: true, - description: 'The slug of the organization for which the teams should be listed. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization for which the teams should be listed. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -82,12 +75,8 @@ export const teamFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'team', - ], + operation: ['getAll'], + resource: ['team'], }, }, default: false, @@ -99,15 +88,9 @@ export const teamFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'team', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['team'], + returnAll: [false], }, }, typeOptions: { @@ -131,16 +114,13 @@ export const teamFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'get', - ], + resource: ['team'], + operation: ['get'], }, }, required: true, - description: 'The slug of the organization the team belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization the team belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Team Slug Name or ID', @@ -148,23 +128,18 @@ export const teamFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getTeams', - loadOptionsDependsOn: [ - 'organizationSlug', - ], + loadOptionsDependsOn: ['organizationSlug'], }, default: '', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'get', - ], + resource: ['team'], + operation: ['get'], }, }, required: true, - description: 'The slug of the team to get. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the team to get. Choose from the list, or specify an ID using an expression.', }, /* -------------------------------------------------------------------------- */ @@ -180,16 +155,13 @@ export const teamFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'create', - ], + resource: ['team'], + operation: ['create'], }, }, required: true, - description: 'The slug of the organization the team belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization the team belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Name', @@ -198,12 +170,8 @@ export const teamFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'create', - ], + resource: ['team'], + operation: ['create'], }, }, required: true, @@ -217,12 +185,8 @@ export const teamFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'create', - ], + resource: ['team'], + operation: ['create'], }, }, options: [ @@ -231,7 +195,8 @@ export const teamFields: INodeProperties[] = [ name: 'slug', type: 'string', default: '', - description: 'The optional slug for this team. If not provided it will be auto generated from the name.', + description: + 'The optional slug for this team. If not provided it will be auto generated from the name.', }, ], }, @@ -249,16 +214,13 @@ export const teamFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'update', - ], + resource: ['team'], + operation: ['update'], }, }, required: true, - description: 'The slug of the organization the team belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization the team belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Team Slug Name or ID', @@ -266,23 +228,18 @@ export const teamFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getTeams', - loadOptionsDependsOn: [ - 'organizationSlug', - ], + loadOptionsDependsOn: ['organizationSlug'], }, default: '', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'update', - ], + resource: ['team'], + operation: ['update'], }, }, required: true, - description: 'The slug of the team to update. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the team to update. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Update Fields', @@ -292,12 +249,8 @@ export const teamFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'update', - ], + resource: ['team'], + operation: ['update'], }, }, options: [ @@ -331,16 +284,13 @@ export const teamFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'delete', - ], + resource: ['team'], + operation: ['delete'], }, }, required: true, - description: 'The slug of the organization the team belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the organization the team belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Team Slug Name or ID', @@ -348,22 +298,17 @@ export const teamFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getTeams', - loadOptionsDependsOn: [ - 'organizationSlug', - ], + loadOptionsDependsOn: ['organizationSlug'], }, default: '', displayOptions: { show: { - resource: [ - 'team', - ], - operation: [ - 'delete', - ], + resource: ['team'], + operation: ['delete'], }, }, required: true, - description: 'The slug of the team to delete. Choose from the list, or specify an ID using an expression.', + description: + 'The slug of the team to delete. Choose from the list, or specify an ID using an expression.', }, ]; diff --git a/packages/nodes-base/nodes/ServiceNow/AttachmentDescription.ts b/packages/nodes-base/nodes/ServiceNow/AttachmentDescription.ts index 2624655881..5e8ef491e9 100644 --- a/packages/nodes-base/nodes/ServiceNow/AttachmentDescription.ts +++ b/packages/nodes-base/nodes/ServiceNow/AttachmentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const attachmentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const attachmentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'attachment', - ], + resource: ['attachment'], }, }, options: [ @@ -46,7 +42,6 @@ export const attachmentOperations: INodeProperties[] = [ ]; export const attachmentFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* attachment common fields */ /* -------------------------------------------------------------------------- */ @@ -55,20 +50,16 @@ export const attachmentFields: INodeProperties[] = [ displayName: 'Table Name or ID', name: 'tableName', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTables', }, default: '', displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'upload', - 'getAll', - ], + resource: ['attachment'], + operation: ['upload', 'getAll'], }, }, required: true, @@ -84,16 +75,13 @@ export const attachmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'upload', - ], + resource: ['attachment'], + operation: ['upload'], }, }, required: true, - description: 'Sys_id of the record in the table specified in Table Name that you want to attach the file to', + description: + 'Sys_id of the record in the table specified in Table Name that you want to attach the file to', }, { displayName: 'Input Data Field Name', @@ -103,12 +91,8 @@ export const attachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'upload', - ], + resource: ['attachment'], + operation: ['upload'], }, }, description: 'Name of the binary property that contains the data to upload', @@ -120,12 +104,8 @@ export const attachmentFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'upload', - ], + resource: ['attachment'], + operation: ['upload'], }, }, default: {}, @@ -149,12 +129,8 @@ export const attachmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'delete', - ], + resource: ['attachment'], + operation: ['delete'], }, }, required: true, @@ -170,12 +146,8 @@ export const attachmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'get', - ], + resource: ['attachment'], + operation: ['get'], }, }, required: true, @@ -190,12 +162,8 @@ export const attachmentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'getAll', - ], + resource: ['attachment'], + operation: ['getAll'], }, }, default: false, @@ -207,15 +175,9 @@ export const attachmentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['attachment'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -233,13 +195,8 @@ export const attachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'get', - 'getAll', - ], + resource: ['attachment'], + operation: ['get', 'getAll'], }, }, }, @@ -251,16 +208,9 @@ export const attachmentFields: INodeProperties[] = [ description: 'Field name where downloaded data will be placed', displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'get', - 'getAll', - ], - download: [ - true, - ], + resource: ['attachment'], + operation: ['get', 'getAll'], + download: [true], }, }, }, @@ -271,12 +221,8 @@ export const attachmentFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'attachment', - ], - operation: [ - 'get', 'getAll', - ], + resource: ['attachment'], + operation: ['get', 'getAll'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/ServiceNow/BusinessServiceDescription.ts b/packages/nodes-base/nodes/ServiceNow/BusinessServiceDescription.ts index adf0065cee..4e1fc7dc17 100644 --- a/packages/nodes-base/nodes/ServiceNow/BusinessServiceDescription.ts +++ b/packages/nodes-base/nodes/ServiceNow/BusinessServiceDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const businessServiceOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const businessServiceOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'businessService', - ], + resource: ['businessService'], }, }, options: [ @@ -27,7 +23,6 @@ export const businessServiceOperations: INodeProperties[] = [ ]; export const businessServiceFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* businessService:getAll */ /* -------------------------------------------------------------------------- */ @@ -37,12 +32,8 @@ export const businessServiceFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'businessService', - ], + operation: ['getAll'], + resource: ['businessService'], }, }, default: false, @@ -54,15 +45,9 @@ export const businessServiceFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'businessService', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['businessService'], + returnAll: [false], }, }, typeOptions: { @@ -79,12 +64,8 @@ export const businessServiceFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'businessService', - ], - operation: [ - 'getAll', - ], + resource: ['businessService'], + operation: ['getAll'], }, }, default: {}, @@ -105,7 +86,8 @@ export const businessServiceFields: INodeProperties[] = [ loadOptionsMethod: 'getColumns', }, default: [], - description: 'A list of fields to return. Choose from the list, or specify IDs using an expression.', + description: + 'A list of fields to return. Choose from the list, or specify IDs using an expression.', hint: 'String of comma separated values or an array of strings can be set in an expression', }, { @@ -113,7 +95,8 @@ export const businessServiceFields: INodeProperties[] = [ name: 'sysparm_query', type: 'string', default: '', - description: 'An encoded query string used to filter the results. More info.', + description: + 'An encoded query string used to filter the results. More info.', }, { displayName: 'Return Values', diff --git a/packages/nodes-base/nodes/ServiceNow/ConfigurationItemsDescription.ts b/packages/nodes-base/nodes/ServiceNow/ConfigurationItemsDescription.ts index d9904e9b53..4b78ffda00 100644 --- a/packages/nodes-base/nodes/ServiceNow/ConfigurationItemsDescription.ts +++ b/packages/nodes-base/nodes/ServiceNow/ConfigurationItemsDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const configurationItemsOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const configurationItemsOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'configurationItems', - ], + resource: ['configurationItems'], }, }, options: [ @@ -27,7 +23,6 @@ export const configurationItemsOperations: INodeProperties[] = [ ]; export const configurationItemsFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* configurationItems:getAll */ /* -------------------------------------------------------------------------- */ @@ -37,12 +32,8 @@ export const configurationItemsFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'configurationItems', - ], + operation: ['getAll'], + resource: ['configurationItems'], }, }, default: false, @@ -54,15 +45,9 @@ export const configurationItemsFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'configurationItems', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['configurationItems'], + returnAll: [false], }, }, typeOptions: { @@ -79,12 +64,8 @@ export const configurationItemsFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'configurationItems', - ], - operation: [ - 'getAll', - ], + resource: ['configurationItems'], + operation: ['getAll'], }, }, default: {}, @@ -105,7 +86,8 @@ export const configurationItemsFields: INodeProperties[] = [ loadOptionsMethod: 'getColumns', }, default: [], - description: 'A list of fields to return. Choose from the list, or specify IDs using an expression.', + description: + 'A list of fields to return. Choose from the list, or specify IDs using an expression.', hint: 'String of comma separated values or an array of strings can be set in an expression', }, { @@ -113,7 +95,8 @@ export const configurationItemsFields: INodeProperties[] = [ name: 'sysparm_query', type: 'string', default: '', - description: 'An encoded query string used to filter the results. More info.', + description: + 'An encoded query string used to filter the results. More info.', }, { displayName: 'Return Values', diff --git a/packages/nodes-base/nodes/ServiceNow/DepartmentDescription.ts b/packages/nodes-base/nodes/ServiceNow/DepartmentDescription.ts index f902c5dd94..81d49c63a6 100644 --- a/packages/nodes-base/nodes/ServiceNow/DepartmentDescription.ts +++ b/packages/nodes-base/nodes/ServiceNow/DepartmentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const departmentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const departmentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'department', - ], + resource: ['department'], }, }, options: [ @@ -27,7 +23,6 @@ export const departmentOperations: INodeProperties[] = [ ]; export const departmentFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* department:getAll */ /* -------------------------------------------------------------------------- */ @@ -37,12 +32,8 @@ export const departmentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'department', - ], + operation: ['getAll'], + resource: ['department'], }, }, default: false, @@ -54,15 +45,9 @@ export const departmentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'department', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['department'], + returnAll: [false], }, }, typeOptions: { @@ -79,12 +64,8 @@ export const departmentFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'department', - ], - operation: [ - 'getAll', - ], + resource: ['department'], + operation: ['getAll'], }, }, default: {}, @@ -105,7 +86,8 @@ export const departmentFields: INodeProperties[] = [ loadOptionsMethod: 'getColumns', }, default: [], - description: 'A list of fields to return. Choose from the list, or specify IDs using an expression.', + description: + 'A list of fields to return. Choose from the list, or specify IDs using an expression.', hint: 'String of comma separated values or an array of strings can be set in an expression', }, { @@ -113,7 +95,8 @@ export const departmentFields: INodeProperties[] = [ name: 'sysparm_query', type: 'string', default: '', - description: 'An encoded query string used to filter the results. More info.', + description: + 'An encoded query string used to filter the results. More info.', }, { displayName: 'Return Values', diff --git a/packages/nodes-base/nodes/ServiceNow/DictionaryDescription.ts b/packages/nodes-base/nodes/ServiceNow/DictionaryDescription.ts index 25dec4dd57..aa10af1f35 100644 --- a/packages/nodes-base/nodes/ServiceNow/DictionaryDescription.ts +++ b/packages/nodes-base/nodes/ServiceNow/DictionaryDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const dictionaryOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const dictionaryOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'dictionary', - ], + resource: ['dictionary'], }, }, options: [ @@ -27,7 +23,6 @@ export const dictionaryOperations: INodeProperties[] = [ ]; export const dictionaryFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* dictionary:getAll */ /* -------------------------------------------------------------------------- */ @@ -37,12 +32,8 @@ export const dictionaryFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'dictionary', - ], + operation: ['getAll'], + resource: ['dictionary'], }, }, default: false, @@ -54,15 +45,9 @@ export const dictionaryFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'dictionary', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['dictionary'], + returnAll: [false], }, }, typeOptions: { @@ -79,12 +64,8 @@ export const dictionaryFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'dictionary', - ], - operation: [ - 'getAll', - ], + resource: ['dictionary'], + operation: ['getAll'], }, }, default: {}, @@ -105,7 +86,8 @@ export const dictionaryFields: INodeProperties[] = [ loadOptionsMethod: 'getColumns', }, default: [], - description: 'A list of fields to return. Choose from the list, or specify IDs using an expression.', + description: + 'A list of fields to return. Choose from the list, or specify IDs using an expression.', hint: 'String of comma separated values or an array of strings can be set in an expression', }, { @@ -113,7 +95,8 @@ export const dictionaryFields: INodeProperties[] = [ name: 'sysparm_query', type: 'string', default: '', - description: 'An encoded query string used to filter the results. More info.', + description: + 'An encoded query string used to filter the results. More info.', }, { displayName: 'Return Values', diff --git a/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts b/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts index 33d6a7262a..088f9611f1 100644 --- a/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts @@ -1,21 +1,20 @@ -import { - OptionsWithUri -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - INodePropertyOptions, - JsonObject, - NodeApiError, -} from 'n8n-workflow'; - -export async function serviceNowApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, INodePropertyOptions, JsonObject, NodeApiError } from 'n8n-workflow'; +export async function serviceNowApiRequest( + this: IExecuteFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const headers = {} as IDataObject; const authenticationMethod = this.getNodeParameter('authentication', 0, 'oAuth2') as string; @@ -48,16 +47,23 @@ export async function serviceNowApiRequest(this: IExecuteFunctions | ILoadOption } try { - const credentialType = authenticationMethod === 'oAuth2' ? 'serviceNowOAuth2Api' : 'serviceNowBasicApi'; + const credentialType = + authenticationMethod === 'oAuth2' ? 'serviceNowOAuth2Api' : 'serviceNowBasicApi'; return await this.helpers.requestWithAuthentication.call(this, credentialType, options); - } catch (error) { - throw new NodeApiError(this.getNode(), (error as JsonObject)); + throw new NodeApiError(this.getNode(), error as JsonObject); } } -export async function serviceNowRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function serviceNowRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -65,7 +71,9 @@ export async function serviceNowRequestAllItems(this: IExecuteFunctions | ILoadO query.sysparm_limit = page; - responseData = await serviceNowApiRequest.call(this, method, resource, body, query, undefined, { resolveWithFullResponse: true }); + responseData = await serviceNowApiRequest.call(this, method, resource, body, query, undefined, { + resolveWithFullResponse: true, + }); returnData.push.apply(returnData, responseData.body.result); const quantity = responseData.headers['x-total-count']; @@ -74,7 +82,9 @@ export async function serviceNowRequestAllItems(this: IExecuteFunctions | ILoadO for (let iteration = 1; iteration < iterations; iteration++) { query.sysparm_limit = page; query.sysparm_offset = iteration * page; - responseData = await serviceNowApiRequest.call(this, method, resource, body, query, undefined, { resolveWithFullResponse: true }); + responseData = await serviceNowApiRequest.call(this, method, resource, body, query, undefined, { + resolveWithFullResponse: true, + }); returnData.push.apply(returnData, responseData.body.result); } @@ -83,20 +93,16 @@ export async function serviceNowRequestAllItems(this: IExecuteFunctions | ILoadO } export async function serviceNowDownloadAttachment( - this: IExecuteFunctions, - endpoint: string, - fileName: string, - contentType: string, - ) { - const fileData = await serviceNowApiRequest.call( - this, - 'GET', - `${endpoint}/file`, - {}, - {}, - '', - { json: false, encoding: null, resolveWithFullResponse: true }, - ); + this: IExecuteFunctions, + endpoint: string, + fileName: string, + contentType: string, +) { + const fileData = await serviceNowApiRequest.call(this, 'GET', `${endpoint}/file`, {}, {}, '', { + json: false, + encoding: null, + resolveWithFullResponse: true, + }); const binaryData = await this.helpers.prepareBinaryData( Buffer.from(fileData.body as string), fileName, @@ -106,7 +112,6 @@ export async function serviceNowDownloadAttachment( return binaryData; } - export const mapEndpoint = (resource: string, operation: string) => { const resourceEndpoint = new Map([ ['attachment', 'sys_dictionary'], @@ -125,8 +130,12 @@ export const mapEndpoint = (resource: string, operation: string) => { export const sortData = (returnData: INodePropertyOptions[]): INodePropertyOptions[] => { returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); return returnData; diff --git a/packages/nodes-base/nodes/ServiceNow/IncidentDescription.ts b/packages/nodes-base/nodes/ServiceNow/IncidentDescription.ts index bed55bb080..a89dc0fbae 100644 --- a/packages/nodes-base/nodes/ServiceNow/IncidentDescription.ts +++ b/packages/nodes-base/nodes/ServiceNow/IncidentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const incidentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const incidentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'incident', - ], + resource: ['incident'], }, }, options: [ @@ -58,12 +54,8 @@ export const incidentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'create', - ], + resource: ['incident'], + operation: ['create'], }, }, required: true, @@ -76,12 +68,8 @@ export const incidentFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'create', - ], + resource: ['incident'], + operation: ['create'], }, }, default: {}, @@ -93,12 +81,11 @@ export const incidentFields: INodeProperties[] = [ typeOptions: { // nodelinter-ignore-next-line loadOptionsMethod: 'getUsers', - loadOptionsDependsOn: [ - 'additionalFields.assignment_group', - ], + loadOptionsDependsOn: ['additionalFields.assignment_group'], }, default: '', - description: 'Which user is the incident assigned to. Requires the selection of an assignment group. Choose from the list, or specify an ID using an expression.', + description: + 'Which user is the incident assigned to. Requires the selection of an assignment group. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Assignment Group Name or ID', @@ -109,13 +96,15 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getAssignmentGroups', }, default: '', - description: 'The assignment group of the incident. Choose from the list, or specify an ID using an expression.', + description: + 'The assignment group of the incident. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Business Service Name or ID', name: 'business_service', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { // nodelinter-ignore-next-line loadOptionsMethod: 'getBusinessServices', @@ -138,7 +127,8 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getIncidentCategories', }, default: '', - description: 'The category of the incident. Choose from the list, or specify an ID using an expression.', + description: + 'The category of the incident. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Close Notes', @@ -156,7 +146,8 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getConfigurationItems', }, default: [], - description: 'Configuration Items, \'cmdb_ci\' in metadata. Choose from the list, or specify IDs using an expression.', + description: + 'Configuration Items, \'cmdb_ci\' in metadata. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Contact Type', @@ -219,7 +210,8 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getIncidentResolutionCodes', }, default: '', - description: 'The resolution code of the incident, \'close_code\' in metadata. Choose from the list, or specify an ID using an expression.', + description: + 'The resolution code of the incident, \'close_code\' in metadata. Choose from the list, or specify an ID using an expression.', }, { displayName: 'State Name or ID', @@ -230,7 +222,8 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getIncidentStates', }, default: '', - description: 'The state of the incident. Choose from the list, or specify an ID using an expression.', + description: + 'The state of the incident. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Subcategory Name or ID', @@ -239,12 +232,11 @@ export const incidentFields: INodeProperties[] = [ typeOptions: { // nodelinter-ignore-next-line loadOptionsMethod: 'getIncidentSubcategories', - loadOptionsDependsOn: [ - 'additionalFields.category', - ], + loadOptionsDependsOn: ['additionalFields.category'], }, default: '', - description: 'The subcategory of the incident. Choose from the list, or specify an ID using an expression.', + description: + 'The subcategory of the incident. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Urgency', @@ -279,12 +271,8 @@ export const incidentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'incident', - ], + operation: ['getAll'], + resource: ['incident'], }, }, default: false, @@ -296,15 +284,9 @@ export const incidentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'incident', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['incident'], + returnAll: [false], }, }, typeOptions: { @@ -321,12 +303,8 @@ export const incidentFields: INodeProperties[] = [ placeholder: 'Add Option', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'getAll', - ], + resource: ['incident'], + operation: ['getAll'], }, }, default: {}, @@ -347,7 +325,8 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getColumns', }, default: [], - description: 'A list of fields to return. Choose from the list, or specify IDs using an expression.', + description: + 'A list of fields to return. Choose from the list, or specify IDs using an expression.', hint: 'String of comma separated values or an array of strings can be set in an expression', }, { @@ -355,7 +334,8 @@ export const incidentFields: INodeProperties[] = [ name: 'sysparm_query', type: 'string', default: '', - description: 'An encoded query string used to filter the results. More info.', + description: + 'An encoded query string used to filter the results. More info.', }, { displayName: 'Return Values', @@ -391,13 +371,8 @@ export const incidentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'delete', - 'get', - ], + resource: ['incident'], + operation: ['delete', 'get'], }, }, required: true, @@ -410,12 +385,8 @@ export const incidentFields: INodeProperties[] = [ placeholder: 'Add Option', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'get', - ], + resource: ['incident'], + operation: ['get'], }, }, default: {}, @@ -436,7 +407,8 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getColumns', }, default: [], - description: 'A list of fields to return. Choose from the list, or specify IDs using an expression.', + description: + 'A list of fields to return. Choose from the list, or specify IDs using an expression.', hint: 'String of comma separated values or an array of strings can be set in an expression', }, { @@ -473,12 +445,8 @@ export const incidentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'update', - ], + resource: ['incident'], + operation: ['update'], }, }, required: true, @@ -491,12 +459,8 @@ export const incidentFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'incident', - ], - operation: [ - 'update', - ], + resource: ['incident'], + operation: ['update'], }, }, default: {}, @@ -508,12 +472,11 @@ export const incidentFields: INodeProperties[] = [ typeOptions: { // nodelinter-ignore-next-line loadOptionsMethod: 'getUsers', - loadOptionsDependsOn: [ - 'additionalFields.assignment_group', - ], + loadOptionsDependsOn: ['additionalFields.assignment_group'], }, default: '', - description: 'Which user is the incident assigned to. Requires the selection of an assignment group. Choose from the list, or specify an ID using an expression.', + description: + 'Which user is the incident assigned to. Requires the selection of an assignment group. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Assignment Group Name or ID', @@ -524,13 +487,15 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getAssignmentGroups', }, default: '', - description: 'The assignment group of the incident. Choose from the list, or specify an ID using an expression.', + description: + 'The assignment group of the incident. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Business Service Name or ID', name: 'business_service', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { // nodelinter-ignore-next-line loadOptionsMethod: 'getBusinessServices', @@ -553,7 +518,8 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getIncidentCategories', }, default: '', - description: 'The category of the incident. Choose from the list, or specify an ID using an expression.', + description: + 'The category of the incident. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Close Notes', @@ -571,7 +537,8 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getConfigurationItems', }, default: [], - description: 'Configuration Items, \'cmdb_ci\' in metadata. Choose from the list, or specify IDs using an expression.', + description: + 'Configuration Items, \'cmdb_ci\' in metadata. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Contact Type', @@ -635,7 +602,8 @@ export const incidentFields: INodeProperties[] = [ }, default: '', // nodelinter-ignore-next-line - description: 'The resolution code of the incident. \'close_code\' in metadata. Choose from the list, or specify an ID using an expression.', + description: + 'The resolution code of the incident. \'close_code\' in metadata. Choose from the list, or specify an ID using an expression.', }, { displayName: 'On Hold Reason Name or ID', @@ -646,7 +614,8 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getIncidentHoldReasons', }, default: '', - description: 'The on hold reason for the incident. It applies if the state is On Hold. Choose from the list, or specify an ID using an expression.', + description: + 'The on hold reason for the incident. It applies if the state is On Hold. Choose from the list, or specify an ID using an expression.', }, { displayName: 'State Name or ID', @@ -657,7 +626,8 @@ export const incidentFields: INodeProperties[] = [ loadOptionsMethod: 'getIncidentStates', }, default: '', - description: 'The state of the incident. Choose from the list, or specify an ID using an expression.', + description: + 'The state of the incident. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Subcategory Name or ID', @@ -666,12 +636,11 @@ export const incidentFields: INodeProperties[] = [ typeOptions: { // nodelinter-ignore-next-line loadOptionsMethod: 'getIncidentSubcategories', - loadOptionsDependsOn: [ - 'additionalFields.category', - ], + loadOptionsDependsOn: ['additionalFields.category'], }, default: '', - description: 'The subcategory of the incident. Choose from the list, or specify an ID using an expression.', + description: + 'The subcategory of the incident. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Urgency', diff --git a/packages/nodes-base/nodes/ServiceNow/ServiceNow.node.ts b/packages/nodes-base/nodes/ServiceNow/ServiceNow.node.ts index 9f996ca4f0..1ede584d80 100644 --- a/packages/nodes-base/nodes/ServiceNow/ServiceNow.node.ts +++ b/packages/nodes-base/nodes/ServiceNow/ServiceNow.node.ts @@ -1,7 +1,4 @@ -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IBinaryData, @@ -19,58 +16,31 @@ import { serviceNowApiRequest, serviceNowDownloadAttachment, serviceNowRequestAllItems, - sortData + sortData, } from './GenericFunctions'; -import { - attachmentFields, - attachmentOperations, -} from './AttachmentDescription'; +import { attachmentFields, attachmentOperations } from './AttachmentDescription'; -import { - businessServiceFields, - businessServiceOperations, -} from './BusinessServiceDescription'; +import { businessServiceFields, businessServiceOperations } from './BusinessServiceDescription'; import { configurationItemsFields, configurationItemsOperations, } from './ConfigurationItemsDescription'; -import { - departmentFields, - departmentOperations, -} from './DepartmentDescription'; +import { departmentFields, departmentOperations } from './DepartmentDescription'; -import { - dictionaryFields, - dictionaryOperations, -} from './DictionaryDescription'; +import { dictionaryFields, dictionaryOperations } from './DictionaryDescription'; -import { - incidentFields, - incidentOperations, -} from './IncidentDescription'; +import { incidentFields, incidentOperations } from './IncidentDescription'; -import { - tableRecordFields, - tableRecordOperations, -} from './TableRecordDescription'; +import { tableRecordFields, tableRecordOperations } from './TableRecordDescription'; -import { - userFields, - userOperations, -} from './UserDescription'; +import { userFields, userOperations } from './UserDescription'; -import { - userGroupFields, - userGroupOperations, -} from './UserGroupDescription'; +import { userGroupFields, userGroupOperations } from './UserGroupDescription'; -import { - userRoleFields, - userRoleOperations, -} from './UserRoleDescription'; +import { userRoleFields, userRoleOperations } from './UserRoleDescription'; export class ServiceNow implements INodeType { description: INodeTypeDescription = { @@ -92,9 +62,7 @@ export class ServiceNow implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -103,9 +71,7 @@ export class ServiceNow implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'basicAuth', - ], + authentication: ['basicAuth'], }, }, }, @@ -214,7 +180,13 @@ export class ServiceNow implements INodeType { loadOptions: { async getTables(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const response = await serviceNowApiRequest.call(this, 'GET', `/now/doc/table/schema`, {}, {}); + const response = await serviceNowApiRequest.call( + this, + 'GET', + `/now/doc/table/schema`, + {}, + {}, + ); for (const table of response.result) { returnData.push({ name: table.label, @@ -240,7 +212,13 @@ export class ServiceNow implements INodeType { sysparm_query: `name=${tableName}`, sysparm_fields: 'column_label,element', }; - const response = await serviceNowApiRequest.call(this, 'GET', `/now/table/sys_dictionary`, {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + `/now/table/sys_dictionary`, + {}, + qs, + ); for (const column of response.result) { if (column.element) { returnData.push({ @@ -256,7 +234,13 @@ export class ServiceNow implements INodeType { const qs = { sysparm_fields: 'name,sys_id', }; - const response = await serviceNowApiRequest.call(this, 'GET', `/now/table/cmdb_ci_service`, {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + `/now/table/cmdb_ci_service`, + {}, + qs, + ); for (const column of response.result) { returnData.push({ @@ -278,14 +262,25 @@ export class ServiceNow implements INodeType { const additionalFields = this.getNodeParameter('additionalFields') as IDataObject; const group = additionalFields.assignment_group; - const response = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user_grmember', {}, { - sysparm_query: `group=${group}^`, - }); + const response = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/sys_user_grmember', + {}, + { + sysparm_query: `group=${group}^`, + }, + ); for (const column of response) { if (column.user) { - - const responseData = await serviceNowApiRequest.call(this, 'GET', `/now/table/sys_user/${column.user.value}`, {}, {}); + const responseData = await serviceNowApiRequest.call( + this, + 'GET', + `/now/table/sys_user/${column.user.value}`, + {}, + {}, + ); const user = responseData.result; returnData.push({ @@ -295,8 +290,13 @@ export class ServiceNow implements INodeType { } } } else { - - const response = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user', {}, qs); + const response = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/sys_user', + {}, + qs, + ); for (const column of response) { if (column.user_name) { @@ -314,7 +314,13 @@ export class ServiceNow implements INodeType { const qs = { sysparm_fields: 'sys_id,name', }; - const response = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user_group', {}, qs); + const response = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/sys_user_group', + {}, + qs, + ); for (const column of response) { if (column.name) { @@ -331,7 +337,13 @@ export class ServiceNow implements INodeType { const qs = { sysparm_fields: 'sys_id,name', }; - const response = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user_role', {}, qs); + const response = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/sys_user_role', + {}, + qs, + ); for (const column of response) { if (column.name) { @@ -348,7 +360,13 @@ export class ServiceNow implements INodeType { const qs = { sysparm_fields: 'sys_id,name,sys_class_name', }; - const response = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/cmdb_ci', {}, qs); + const response = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/cmdb_ci', + {}, + qs, + ); for (const column of response) { if (column.name) { @@ -367,14 +385,19 @@ export class ServiceNow implements INodeType { sysparm_fields: 'label,value', sysparm_query: 'element=category^name=incident', }; - const response = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_choice', {}, qs); + const response = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/sys_choice', + {}, + qs, + ); for (const column of response) { returnData.push({ name: column.label, value: column.value, }); - } return sortData(returnData); }, @@ -393,7 +416,13 @@ export class ServiceNow implements INodeType { sysparm_fields: 'label,value', sysparm_query: `name=incident^element=subcategory^dependent_value=${category}`, }; - const response = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_choice', {}, qs); + const response = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/sys_choice', + {}, + qs, + ); for (const column of response) { returnData.push({ @@ -410,31 +439,43 @@ export class ServiceNow implements INodeType { sysparm_fields: 'label,value', sysparm_query: 'element=state^name=incident', }; - const response = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_choice', {}, qs); + const response = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/sys_choice', + {}, + qs, + ); for (const column of response) { returnData.push({ name: column.label, value: column.value, }); - } return sortData(returnData); }, - async getIncidentResolutionCodes(this: ILoadOptionsFunctions): Promise { + async getIncidentResolutionCodes( + this: ILoadOptionsFunctions, + ): Promise { const returnData: INodePropertyOptions[] = []; const qs = { sysparm_fields: 'label,value', sysparm_query: 'element=close_code^name=incident', }; - const response = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_choice', {}, qs); + const response = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/sys_choice', + {}, + qs, + ); for (const column of response) { returnData.push({ name: column.label, value: column.value, }); - } return sortData(returnData); }, @@ -444,14 +485,19 @@ export class ServiceNow implements INodeType { sysparm_fields: 'label,value', sysparm_query: 'element=hold_reason^name=incident', }; - const response = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_choice', {}, qs); + const response = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/sys_choice', + {}, + qs, + ); for (const column of response) { returnData.push({ name: column.label, value: column.value, }); - } return sortData(returnData); }, @@ -472,7 +518,6 @@ export class ServiceNow implements INodeType { // https://developer.servicenow.com/dev.do#!/reference/api/rome/rest/c_AttachmentAPI if (resource === 'attachment') { if (operation === 'get') { - const attachmentsSysId = this.getNodeParameter('attachmentId', i) as string; const download = this.getNodeParameter('download', i) as boolean; const endpoint = `/now/attachment/${attachmentsSysId}`; @@ -498,7 +543,6 @@ export class ServiceNow implements INodeType { }, }; } - } else if (operation === 'getAll') { const download = this.getNodeParameter('download', i) as boolean; const tableName = this.getNodeParameter('tableName', i) as string; @@ -516,10 +560,22 @@ export class ServiceNow implements INodeType { if (!returnAll) { const limit = this.getNodeParameter('limit', i) as number; qs.sysparm_limit = limit; - const response = await serviceNowApiRequest.call(this, 'GET', '/now/attachment', {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + '/now/attachment', + {}, + qs, + ); responseData = response.result; } else { - responseData = await serviceNowRequestAllItems.call(this, 'GET', '/now/attachment', {}, qs); + responseData = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/attachment', + {}, + qs, + ); } if (download) { @@ -542,9 +598,8 @@ export class ServiceNow implements INodeType { responseData = responseDataWithAttachments; } else { - responseData = (responseData as IDataObject[]).map( data => ({ json: data })); + responseData = (responseData as IDataObject[]).map((data) => ({ json: data })); } - } else if (operation === 'upload') { const tableName = this.getNodeParameter('tableName', i) as string; const recordId = this.getNodeParameter('id', i) as string; @@ -556,7 +611,11 @@ export class ServiceNow implements INodeType { if (items[i].binary && items[i].binary![inputDataFieldName]) { binaryData = items[i].binary![inputDataFieldName]; } else { - throw new NodeOperationError(this.getNode(), `No binary data property "${inputDataFieldName}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${inputDataFieldName}" does not exists on item!`, + { itemIndex: i }, + ); } const headers: IDataObject = { @@ -566,23 +625,31 @@ export class ServiceNow implements INodeType { const qs: IDataObject = { table_name: tableName, table_sys_id: recordId, - file_name: binaryData.fileName ? binaryData.fileName : `${inputDataFieldName}.${binaryData.fileExtension}`, + file_name: binaryData.fileName + ? binaryData.fileName + : `${inputDataFieldName}.${binaryData.fileExtension}`, ...options, }; - const body = await this.helpers.getBinaryDataBuffer(i, inputDataFieldName) as Buffer; + const body = (await this.helpers.getBinaryDataBuffer(i, inputDataFieldName)) as Buffer; - const response = await serviceNowApiRequest.call(this, 'POST', '/now/attachment/file', body, qs, '', {headers}); + const response = await serviceNowApiRequest.call( + this, + 'POST', + '/now/attachment/file', + body, + qs, + '', + { headers }, + ); responseData = response.result; } else if (operation === 'delete') { const attachmentsSysId = this.getNodeParameter('attachmentId', i) as string; await serviceNowApiRequest.call(this, 'DELETE', `/now/attachment/${attachmentsSysId}`); - responseData = {'success': true}; + responseData = { success: true }; } } else if (resource === 'businessService') { - if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; qs = this.getNodeParameter('options', i) as IDataObject; @@ -593,17 +660,26 @@ export class ServiceNow implements INodeType { if (!returnAll) { const limit = this.getNodeParameter('limit', i) as number; qs.sysparm_limit = limit; - const response = await serviceNowApiRequest.call(this, 'GET', '/now/table/cmdb_ci_service', {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + '/now/table/cmdb_ci_service', + {}, + qs, + ); responseData = response.result; } else { - responseData = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/cmdb_ci_service', {}, qs); + responseData = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/cmdb_ci_service', + {}, + qs, + ); } - } } else if (resource === 'configurationItems') { - if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; qs = this.getNodeParameter('options', i) as IDataObject; @@ -614,17 +690,26 @@ export class ServiceNow implements INodeType { if (!returnAll) { const limit = this.getNodeParameter('limit', i) as number; qs.sysparm_limit = limit; - const response = await serviceNowApiRequest.call(this, 'GET', '/now/table/cmdb_ci', {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + '/now/table/cmdb_ci', + {}, + qs, + ); responseData = response.result; } else { - responseData = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/cmdb_ci', {}, qs); + responseData = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/cmdb_ci', + {}, + qs, + ); } - } } else if (resource === 'department') { - if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; qs = this.getNodeParameter('options', i) as IDataObject; @@ -635,17 +720,26 @@ export class ServiceNow implements INodeType { if (!returnAll) { const limit = this.getNodeParameter('limit', i) as number; qs.sysparm_limit = limit; - const response = await serviceNowApiRequest.call(this, 'GET', '/now/table/cmn_department', {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + '/now/table/cmn_department', + {}, + qs, + ); responseData = response.result; } else { - responseData = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/cmn_department', {}, qs); + responseData = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/cmn_department', + {}, + qs, + ); } - } } else if (resource === 'dictionary') { - if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; qs = this.getNodeParameter('options', i) as IDataObject; @@ -656,17 +750,26 @@ export class ServiceNow implements INodeType { if (!returnAll) { const limit = this.getNodeParameter('limit', i) as number; qs.sysparm_limit = limit; - const response = await serviceNowApiRequest.call(this, 'GET', '/now/table/sys_dictionary', {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + '/now/table/sys_dictionary', + {}, + qs, + ); responseData = response.result; } else { - responseData = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_dictionary', {}, qs); + responseData = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/sys_dictionary', + {}, + qs, + ); } - } } else if (resource === 'incident') { - if (operation === 'create') { - const shortDescription = this.getNodeParameter('short_description', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body = { @@ -674,17 +777,22 @@ export class ServiceNow implements INodeType { ...additionalFields, }; - const response = await serviceNowApiRequest.call(this, 'POST', `/now/table/incident`, body); + const response = await serviceNowApiRequest.call( + this, + 'POST', + `/now/table/incident`, + body, + ); responseData = response.result; - } else if (operation === 'delete') { - const id = this.getNodeParameter('id', i) as string; - responseData = await serviceNowApiRequest.call(this, 'DELETE', `/now/table/incident/${id}`); + responseData = await serviceNowApiRequest.call( + this, + 'DELETE', + `/now/table/incident/${id}`, + ); responseData = { success: true }; - } else if (operation === 'get') { - const id = this.getNodeParameter('id', i) as string; qs = this.getNodeParameter('options', i) as IDataObject; @@ -692,11 +800,15 @@ export class ServiceNow implements INodeType { qs.sysparm_fields = (qs.sysparm_fields as string[]).join(','); } - const response = await serviceNowApiRequest.call(this, 'GET', `/now/table/incident/${id}`, {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + `/now/table/incident/${id}`, + {}, + qs, + ); responseData = response.result; - } else if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; qs = this.getNodeParameter('options', i) as IDataObject; @@ -707,39 +819,57 @@ export class ServiceNow implements INodeType { if (!returnAll) { const limit = this.getNodeParameter('limit', i) as number; qs.sysparm_limit = limit; - const response = await serviceNowApiRequest.call(this, 'GET', `/now/table/incident`, {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + `/now/table/incident`, + {}, + qs, + ); responseData = response.result; } else { - responseData = await serviceNowRequestAllItems.call(this, 'GET', `/now/table/incident`, {}, qs); + responseData = await serviceNowRequestAllItems.call( + this, + 'GET', + `/now/table/incident`, + {}, + qs, + ); } - } else if (operation === 'update') { - const id = this.getNodeParameter('id', i) as string; const body = this.getNodeParameter('updateFields', i) as IDataObject; - const response = await serviceNowApiRequest.call(this, 'PATCH', `/now/table/incident/${id}`, body); + const response = await serviceNowApiRequest.call( + this, + 'PATCH', + `/now/table/incident/${id}`, + body, + ); responseData = response.result; - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'tableRecord') { - if (operation === 'create') { - const tableName = this.getNodeParameter('tableName', i) as string; const dataToSend = this.getNodeParameter('dataToSend', i) as string; let body = {}; if (dataToSend === 'mapInput') { - const inputsToIgnore = (this.getNodeParameter('inputsToIgnore', i) as string).split(',').map(field => field.trim()); + const inputsToIgnore = (this.getNodeParameter('inputsToIgnore', i) as string) + .split(',') + .map((field) => field.trim()); body = Object.entries(items[i].json) .filter(([key]) => !inputsToIgnore.includes(key)) .reduce((obj, [key, val]) => Object.assign(obj, { [key]: val }), {}); } else if (dataToSend === 'columns') { const fieldsToSend = this.getNodeParameter('fieldsToSend', i) as { - field: IDataObject[] + field: IDataObject[]; }; body = fieldsToSend.field.reduce((obj, field) => { obj[field.column as string] = field.value; @@ -747,18 +877,23 @@ export class ServiceNow implements INodeType { }, {}); } - const response = await serviceNowApiRequest.call(this, 'POST', `/now/table/${tableName}`, body); + const response = await serviceNowApiRequest.call( + this, + 'POST', + `/now/table/${tableName}`, + body, + ); responseData = response.result; - } else if (operation === 'delete') { - const tableName = this.getNodeParameter('tableName', i) as string; const id = this.getNodeParameter('id', i) as string; - responseData = await serviceNowApiRequest.call(this, 'DELETE', `/now/table/${tableName}/${id}`); + responseData = await serviceNowApiRequest.call( + this, + 'DELETE', + `/now/table/${tableName}/${id}`, + ); responseData = { success: true }; - } else if (operation === 'get') { - const tableName = this.getNodeParameter('tableName', i) as string; const id = this.getNodeParameter('id', i) as string; qs = this.getNodeParameter('options', i) as IDataObject; @@ -767,11 +902,15 @@ export class ServiceNow implements INodeType { qs.sysparm_fields = (qs.sysparm_fields as string[]).join(','); } - const response = await serviceNowApiRequest.call(this, 'GET', `/now/table/${tableName}/${id}`, {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + `/now/table/${tableName}/${id}`, + {}, + qs, + ); responseData = response.result; - } else if (operation === 'getAll') { - const tableName = this.getNodeParameter('tableName', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; qs = this.getNodeParameter('options', i) as IDataObject; @@ -783,28 +922,39 @@ export class ServiceNow implements INodeType { if (!returnAll) { const limit = this.getNodeParameter('limit', i) as number; qs.sysparm_limit = limit; - const response = await serviceNowApiRequest.call(this, 'GET', `/now/table/${tableName}`, {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + `/now/table/${tableName}`, + {}, + qs, + ); responseData = response.result; } else { - responseData = await serviceNowRequestAllItems.call(this, 'GET', `/now/table/${tableName}`, {}, qs); + responseData = await serviceNowRequestAllItems.call( + this, + 'GET', + `/now/table/${tableName}`, + {}, + qs, + ); } - - } else if (operation === 'update') { - const tableName = this.getNodeParameter('tableName', i) as string; const id = this.getNodeParameter('id', i) as string; const dataToSend = this.getNodeParameter('dataToSend', i) as string; let body = {}; if (dataToSend === 'mapInput') { - const inputsToIgnore = (this.getNodeParameter('inputsToIgnore', i) as string).split(',').map(field => field.trim()); + const inputsToIgnore = (this.getNodeParameter('inputsToIgnore', i) as string) + .split(',') + .map((field) => field.trim()); body = Object.entries(items[i].json) .filter(([key]) => !inputsToIgnore.includes(key)) .reduce((obj, [key, val]) => Object.assign(obj, { [key]: val }), {}); } else if (dataToSend === 'columns') { const fieldsToSend = this.getNodeParameter('fieldsToSend', i) as { - field: IDataObject[] + field: IDataObject[]; }; body = fieldsToSend.field.reduce((obj, field) => { obj[field.column as string] = field.value; @@ -812,29 +962,40 @@ export class ServiceNow implements INodeType { }, {}); } - const response = await serviceNowApiRequest.call(this, 'PATCH', `/now/table/${tableName}/${id}`, body); + const response = await serviceNowApiRequest.call( + this, + 'PATCH', + `/now/table/${tableName}/${id}`, + body, + ); responseData = response.result; - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'user') { - if (operation === 'create') { - const body = this.getNodeParameter('additionalFields', i) as IDataObject; - const response = await serviceNowApiRequest.call(this, 'POST', '/now/table/sys_user', body); + const response = await serviceNowApiRequest.call( + this, + 'POST', + '/now/table/sys_user', + body, + ); responseData = response.result; - } else if (operation === 'delete') { - const id = this.getNodeParameter('id', i) as string; - responseData = await serviceNowApiRequest.call(this, 'DELETE', `/now/table/sys_user/${id}`); + responseData = await serviceNowApiRequest.call( + this, + 'DELETE', + `/now/table/sys_user/${id}`, + ); responseData = { success: true }; - } else if (operation === 'get') { - const getOption = this.getNodeParameter('getOption', i) as string; qs = this.getNodeParameter('options', i) as IDataObject; @@ -844,18 +1005,28 @@ export class ServiceNow implements INodeType { if (getOption === 'id') { const id = this.getNodeParameter('id', i) as string; - const response = await serviceNowApiRequest.call(this, 'GET', `/now/table/sys_user/${id}`, {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + `/now/table/sys_user/${id}`, + {}, + qs, + ); responseData = response.result; } else { const userName = this.getNodeParameter('user_name', i) as string; qs.sysparm_query = `user_name=${userName}`; qs.sysparm_limit = 1; - const response = await serviceNowApiRequest.call(this, 'GET', '/now/table/sys_user', {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + '/now/table/sys_user', + {}, + qs, + ); responseData = response.result; } - } else if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; qs = this.getNodeParameter('options', i) as IDataObject; @@ -866,26 +1037,43 @@ export class ServiceNow implements INodeType { if (!returnAll) { const limit = this.getNodeParameter('limit', i) as number; qs.sysparm_limit = limit; - const response = await serviceNowApiRequest.call(this, 'GET', '/now/table/sys_user', {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + '/now/table/sys_user', + {}, + qs, + ); responseData = response.result; } else { - responseData = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user', {}, qs); + responseData = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/sys_user', + {}, + qs, + ); } - } else if (operation === 'update') { - const id = this.getNodeParameter('id', i) as string; const body = this.getNodeParameter('updateFields', i) as IDataObject; - const response = await serviceNowApiRequest.call(this, 'PATCH', `/now/table/sys_user/${id}`, body); + const response = await serviceNowApiRequest.call( + this, + 'PATCH', + `/now/table/sys_user/${id}`, + body, + ); responseData = response.result; - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'userGroup') { if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; qs = this.getNodeParameter('options', i) as IDataObject; @@ -896,17 +1084,32 @@ export class ServiceNow implements INodeType { if (!returnAll) { const limit = this.getNodeParameter('limit', i) as number; qs.sysparm_limit = limit; - const response = await serviceNowApiRequest.call(this, 'GET', '/now/table/sys_user_group', {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + '/now/table/sys_user_group', + {}, + qs, + ); responseData = response.result; } else { - responseData = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user_group', {}, qs); + responseData = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/sys_user_group', + {}, + qs, + ); } } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'userRole') { if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; qs = this.getNodeParameter('options', i) as IDataObject; @@ -917,16 +1120,34 @@ export class ServiceNow implements INodeType { if (!returnAll) { const limit = this.getNodeParameter('limit', i) as number; qs.sysparm_limit = limit; - const response = await serviceNowApiRequest.call(this, 'GET', '/now/table/sys_user_role', {}, qs); + const response = await serviceNowApiRequest.call( + this, + 'GET', + '/now/table/sys_user_role', + {}, + qs, + ); responseData = response.result; } else { - responseData = await serviceNowRequestAllItems.call(this, 'GET', '/now/table/sys_user_role', {}, qs); + responseData = await serviceNowRequestAllItems.call( + this, + 'GET', + '/now/table/sys_user_role', + {}, + qs, + ); } } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { + itemIndex: i, + }); } } catch (error) { if (this.continueOnFail()) { diff --git a/packages/nodes-base/nodes/ServiceNow/TableRecordDescription.ts b/packages/nodes-base/nodes/ServiceNow/TableRecordDescription.ts index 3f8f34e0c0..5d67a216f8 100644 --- a/packages/nodes-base/nodes/ServiceNow/TableRecordDescription.ts +++ b/packages/nodes-base/nodes/ServiceNow/TableRecordDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const tableRecordOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const tableRecordOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'tableRecord', - ], + resource: ['tableRecord'], }, }, options: [ @@ -54,19 +50,16 @@ export const tableRecordFields: INodeProperties[] = [ displayName: 'Table Name or ID', name: 'tableName', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTables', }, default: '', displayOptions: { show: { - resource: [ - 'tableRecord', - ], - operation: [ - 'create', - ], + resource: ['tableRecord'], + operation: ['create'], }, }, required: true, @@ -89,17 +82,13 @@ export const tableRecordFields: INodeProperties[] = [ { name: 'Nothing', value: 'nothing', - description: 'Don\'t send any column data', + description: "Don't send any column data", }, ], displayOptions: { show: { - resource: [ - 'tableRecord', - ], - operation: [ - 'create', - ], + resource: ['tableRecord'], + operation: ['create'], }, }, default: 'columns', @@ -110,19 +99,14 @@ export const tableRecordFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'tableRecord', - ], - operation: [ - 'create', - ], - dataToSend: [ - 'mapInput', - ], + resource: ['tableRecord'], + operation: ['create'], + dataToSend: ['mapInput'], }, }, default: '', - description: 'List of input properties to avoid sending, separated by commas. Leave empty to send all inputs.', + description: + 'List of input properties to avoid sending, separated by commas. Leave empty to send all inputs.', }, { displayName: 'Fields to Send', @@ -134,15 +118,9 @@ export const tableRecordFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'tableRecord', - ], - operation: [ - 'create', - ], - dataToSend: [ - 'columns', - ], + resource: ['tableRecord'], + operation: ['create'], + dataToSend: ['columns'], }, }, default: {}, @@ -155,12 +133,11 @@ export const tableRecordFields: INodeProperties[] = [ displayName: 'Field Name or ID', name: 'column', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getColumns', - loadOptionsDependsOn: [ - 'tableName', - ], + loadOptionsDependsOn: ['tableName'], }, default: '', }, @@ -182,19 +159,16 @@ export const tableRecordFields: INodeProperties[] = [ displayName: 'Table Name or ID', name: 'tableName', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTables', }, default: '', displayOptions: { show: { - resource: [ - 'tableRecord', - ], - operation: [ - 'getAll', - ], + resource: ['tableRecord'], + operation: ['getAll'], }, }, required: true, @@ -205,12 +179,8 @@ export const tableRecordFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'tableRecord', - ], + operation: ['getAll'], + resource: ['tableRecord'], }, }, default: false, @@ -222,15 +192,9 @@ export const tableRecordFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'tableRecord', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['tableRecord'], + returnAll: [false], }, }, typeOptions: { @@ -247,12 +211,8 @@ export const tableRecordFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'tableRecord', - ], - operation: [ - 'getAll', - ], + resource: ['tableRecord'], + operation: ['getAll'], }, }, default: {}, @@ -270,12 +230,11 @@ export const tableRecordFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getColumns', - loadOptionsDependsOn: [ - 'tableName', - ], + loadOptionsDependsOn: ['tableName'], }, default: [], - description: 'A list of fields to return. Choose from the list, or specify IDs using an expression.', + description: + 'A list of fields to return. Choose from the list, or specify IDs using an expression.', hint: 'String of comma separated values or an array of strings can be set in an expression', }, { @@ -283,7 +242,8 @@ export const tableRecordFields: INodeProperties[] = [ name: 'sysparm_query', type: 'string', default: '', - description: 'An encoded query string used to filter the results. More info.', + description: + 'An encoded query string used to filter the results. More info.', }, { displayName: 'Return Values', @@ -322,17 +282,13 @@ export const tableRecordFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'tableRecord', - ], - operation: [ - 'delete', - 'get', - ], + resource: ['tableRecord'], + operation: ['delete', 'get'], }, }, required: true, - description: 'Name of the table in which the record exists. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the table in which the record exists. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Table Record ID', @@ -341,13 +297,8 @@ export const tableRecordFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'tableRecord', - ], - operation: [ - 'delete', - 'get', - ], + resource: ['tableRecord'], + operation: ['delete', 'get'], }, }, required: true, @@ -360,12 +311,8 @@ export const tableRecordFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'tableRecord', - ], - operation: [ - 'get', - ], + resource: ['tableRecord'], + operation: ['get'], }, }, default: {}, @@ -383,12 +330,11 @@ export const tableRecordFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getColumns', - loadOptionsDependsOn: [ - 'tableName', - ], + loadOptionsDependsOn: ['tableName'], }, default: [], - description: 'A list of fields to return. Choose from the list, or specify IDs using an expression.', + description: + 'A list of fields to return. Choose from the list, or specify IDs using an expression.', hint: 'String of comma separated values or an array of strings can be set in an expression', }, { @@ -422,19 +368,16 @@ export const tableRecordFields: INodeProperties[] = [ displayName: 'Table Name or ID', name: 'tableName', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTables', }, default: '', displayOptions: { show: { - resource: [ - 'tableRecord', - ], - operation: [ - 'update', - ], + resource: ['tableRecord'], + operation: ['update'], }, }, required: true, @@ -446,12 +389,8 @@ export const tableRecordFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'tableRecord', - ], - operation: [ - 'update', - ], + resource: ['tableRecord'], + operation: ['update'], }, }, required: true, @@ -475,17 +414,13 @@ export const tableRecordFields: INodeProperties[] = [ { name: 'Nothing', value: 'nothing', - description: 'Don\'t send any column data', + description: "Don't send any column data", }, ], displayOptions: { show: { - resource: [ - 'tableRecord', - ], - operation: [ - 'update', - ], + resource: ['tableRecord'], + operation: ['update'], }, }, default: 'columns', @@ -496,19 +431,14 @@ export const tableRecordFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'tableRecord', - ], - operation: [ - 'update', - ], - dataToSend: [ - 'mapInput', - ], + resource: ['tableRecord'], + operation: ['update'], + dataToSend: ['mapInput'], }, }, default: '', - description: 'List of input properties to avoid sending, separated by commas. Leave empty to send all inputs.', + description: + 'List of input properties to avoid sending, separated by commas. Leave empty to send all inputs.', }, { displayName: 'Fields to Send', @@ -520,15 +450,9 @@ export const tableRecordFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'tableRecord', - ], - operation: [ - 'update', - ], - dataToSend: [ - 'columns', - ], + resource: ['tableRecord'], + operation: ['update'], + dataToSend: ['columns'], }, }, default: {}, @@ -541,12 +465,11 @@ export const tableRecordFields: INodeProperties[] = [ displayName: 'Field Name or ID', name: 'column', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getColumns', - loadOptionsDependsOn: [ - 'tableName', - ], + loadOptionsDependsOn: ['tableName'], }, default: '', }, diff --git a/packages/nodes-base/nodes/ServiceNow/UserDescription.ts b/packages/nodes-base/nodes/ServiceNow/UserDescription.ts index 9ae43fdb94..3893982c9a 100644 --- a/packages/nodes-base/nodes/ServiceNow/UserDescription.ts +++ b/packages/nodes-base/nodes/ServiceNow/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -58,12 +54,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, required: true, @@ -76,12 +68,8 @@ export const userFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, default: {}, @@ -197,7 +185,7 @@ export const userFields: INodeProperties[] = [ name: 'user_password', type: 'string', default: '', - description: 'The user\'s password', + description: "The user's password", }, { displayName: 'Password Needs Reset', @@ -221,7 +209,8 @@ export const userFields: INodeProperties[] = [ loadOptionsMethod: 'getUserRoles', }, default: [], - description: 'Roles of the user. Choose from the list, or specify IDs using an expression.', + description: + 'Roles of the user. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Source', @@ -270,12 +259,8 @@ export const userFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'user', - ], + operation: ['getAll'], + resource: ['user'], }, }, default: false, @@ -287,15 +272,9 @@ export const userFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'user', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['user'], + returnAll: [false], }, }, typeOptions: { @@ -312,12 +291,8 @@ export const userFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, default: {}, @@ -335,12 +310,11 @@ export const userFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getColumns', - loadOptionsDependsOn: [ - 'operation', - ], + loadOptionsDependsOn: ['operation'], }, default: [], - description: 'A list of fields to return. Choose from the list, or specify IDs using an expression.', + description: + 'A list of fields to return. Choose from the list, or specify IDs using an expression.', hint: 'String of comma separated values or an array of strings can be set in an expression', }, { @@ -348,7 +322,8 @@ export const userFields: INodeProperties[] = [ name: 'sysparm_query', type: 'string', default: '', - description: 'An encoded query string used to filter the results. More info.', + description: + 'An encoded query string used to filter the results. More info.', }, { displayName: 'Return Values', @@ -394,12 +369,8 @@ export const userFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, required: true, @@ -412,15 +383,9 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], - getOption: [ - 'user_name', - ], + resource: ['user'], + operation: ['get'], + getOption: ['user_name'], }, }, required: true, @@ -433,15 +398,9 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], - getOption: [ - 'id', - ], + resource: ['user'], + operation: ['get'], + getOption: ['id'], }, }, required: true, @@ -454,12 +413,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'delete', - ], + resource: ['user'], + operation: ['delete'], }, }, required: true, @@ -472,12 +427,8 @@ export const userFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, default: {}, @@ -495,12 +446,11 @@ export const userFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getColumns', - loadOptionsDependsOn: [ - 'operation', - ], + loadOptionsDependsOn: ['operation'], }, default: [], - description: 'A list of fields to return. Choose from the list, or specify IDs using an expression.', + description: + 'A list of fields to return. Choose from the list, or specify IDs using an expression.', hint: 'String of comma separated values or an array of strings can be set in an expression', }, { @@ -537,12 +487,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, required: true, @@ -555,12 +501,8 @@ export const userFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, default: {}, @@ -676,7 +618,7 @@ export const userFields: INodeProperties[] = [ name: 'user_password', type: 'string', default: '', - description: 'The user\'s password', + description: "The user's password", }, { displayName: 'Password Needs Reset', @@ -700,7 +642,8 @@ export const userFields: INodeProperties[] = [ loadOptionsMethod: 'getUserRoles', }, default: [], - description: 'Roles of the user. Choose from the list, or specify IDs using an expression.', + description: + 'Roles of the user. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Source', diff --git a/packages/nodes-base/nodes/ServiceNow/UserGroupDescription.ts b/packages/nodes-base/nodes/ServiceNow/UserGroupDescription.ts index 6977b87b0f..9d0fe75a26 100644 --- a/packages/nodes-base/nodes/ServiceNow/UserGroupDescription.ts +++ b/packages/nodes-base/nodes/ServiceNow/UserGroupDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userGroupOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userGroupOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'userGroup', - ], + resource: ['userGroup'], }, }, options: [ @@ -27,7 +23,6 @@ export const userGroupOperations: INodeProperties[] = [ ]; export const userGroupFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* userGroup:getAll */ /* -------------------------------------------------------------------------- */ @@ -37,12 +32,8 @@ export const userGroupFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'userGroup', - ], + operation: ['getAll'], + resource: ['userGroup'], }, }, default: false, @@ -54,15 +45,9 @@ export const userGroupFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'userGroup', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['userGroup'], + returnAll: [false], }, }, typeOptions: { @@ -79,12 +64,8 @@ export const userGroupFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'userGroup', - ], - operation: [ - 'getAll', - ], + resource: ['userGroup'], + operation: ['getAll'], }, }, default: {}, @@ -104,7 +85,8 @@ export const userGroupFields: INodeProperties[] = [ loadOptionsMethod: 'getColumns', }, default: [], - description: 'A list of fields to return. Choose from the list, or specify IDs using an expression.', + description: + 'A list of fields to return. Choose from the list, or specify IDs using an expression.', hint: 'String of comma separated values or an array of strings can be set in an expression', }, { @@ -112,7 +94,8 @@ export const userGroupFields: INodeProperties[] = [ name: 'sysparm_query', type: 'string', default: '', - description: 'An encoded query string used to filter the results. More info.', + description: + 'An encoded query string used to filter the results. More info.', }, { displayName: 'Return Values', diff --git a/packages/nodes-base/nodes/ServiceNow/UserRoleDescription.ts b/packages/nodes-base/nodes/ServiceNow/UserRoleDescription.ts index f33eb3f8fa..e617bad427 100644 --- a/packages/nodes-base/nodes/ServiceNow/UserRoleDescription.ts +++ b/packages/nodes-base/nodes/ServiceNow/UserRoleDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userRoleOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userRoleOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'userRole', - ], + resource: ['userRole'], }, }, options: [ @@ -27,7 +23,6 @@ export const userRoleOperations: INodeProperties[] = [ ]; export const userRoleFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* userRole:getAll */ /* -------------------------------------------------------------------------- */ @@ -37,12 +32,8 @@ export const userRoleFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'userRole', - ], + operation: ['getAll'], + resource: ['userRole'], }, }, default: false, @@ -54,15 +45,9 @@ export const userRoleFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'userRole', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['userRole'], + returnAll: [false], }, }, typeOptions: { @@ -79,12 +64,8 @@ export const userRoleFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'userRole', - ], - operation: [ - 'getAll', - ], + resource: ['userRole'], + operation: ['getAll'], }, }, default: {}, @@ -104,7 +85,8 @@ export const userRoleFields: INodeProperties[] = [ loadOptionsMethod: 'getColumns', }, default: [], - description: 'A list of fields to return. Choose from the list, or specify IDs using an expression.', + description: + 'A list of fields to return. Choose from the list, or specify IDs using an expression.', hint: 'String of comma separated values or an array of strings can be set in an expression', }, { @@ -112,7 +94,8 @@ export const userRoleFields: INodeProperties[] = [ name: 'sysparm_query', type: 'string', default: '', - description: 'An encoded query string used to filter the results. More info.', + description: + 'An encoded query string used to filter the results. More info.', }, { displayName: 'Return Values', diff --git a/packages/nodes-base/nodes/Set/Set.node.ts b/packages/nodes-base/nodes/Set/Set.node.ts index 9f1df0f610..3055f7b177 100644 --- a/packages/nodes-base/nodes/Set/Set.node.ts +++ b/packages/nodes-base/nodes/Set/Set.node.ts @@ -29,7 +29,8 @@ export class Set implements INodeType { name: 'keepOnlySet', type: 'boolean', default: false, - description: 'Whether only the values set on this node should be kept and all others removed', + description: + 'Whether only the values set on this node should be kept and all others removed', }, { displayName: 'Values to Set', @@ -52,7 +53,8 @@ export class Set implements INodeType { name: 'name', type: 'string', default: 'propertyName', - description: 'Name of the property to write data to. Supports dot-notation. Example: "data.person[0].name"', + description: + 'Name of the property to write data to. Supports dot-notation. Example: "data.person[0].name"', }, { displayName: 'Value', @@ -73,7 +75,8 @@ export class Set implements INodeType { name: 'name', type: 'string', default: 'propertyName', - description: 'Name of the property to write data to. Supports dot-notation. Example: "data.person[0].name"', + description: + 'Name of the property to write data to. Supports dot-notation. Example: "data.person[0].name"', }, { displayName: 'Value', @@ -93,7 +96,8 @@ export class Set implements INodeType { name: 'name', type: 'string', default: 'propertyName', - description: 'Name of the property to write data to. Supports dot-notation. Example: "data.person[0].name"', + description: + 'Name of the property to write data to. Supports dot-notation. Example: "data.person[0].name"', }, { displayName: 'Value', @@ -120,20 +124,19 @@ export class Set implements INodeType { type: 'boolean', default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: '

By default, dot-notation is used in property names. This means that "a.b" will set the property "b" underneath "a" so { "a": { "b": value} }.

If that is not intended this can be deactivated, it will then set { "a.b": value } instead.

.', + description: + '

By default, dot-notation is used in property names. This means that "a.b" will set the property "b" underneath "a" so { "a": { "b": value} }.

If that is not intended this can be deactivated, it will then set { "a.b": value } instead.

.', }, ], }, ], }; - execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); if (items.length === 0) { - items.push({json: {}}); + items.push({ json: {} }); } const returnData: INodeExecutionData[] = []; @@ -163,31 +166,37 @@ export class Set implements INodeType { } // Add boolean values - (this.getNodeParameter('values.boolean', itemIndex, []) as INodeParameters[]).forEach((setItem) => { - if (options.dotNotation === false) { - newItem.json[setItem.name as string] = !!setItem.value; - } else { - set(newItem.json, setItem.name as string, !!setItem.value); - } - }); + (this.getNodeParameter('values.boolean', itemIndex, []) as INodeParameters[]).forEach( + (setItem) => { + if (options.dotNotation === false) { + newItem.json[setItem.name as string] = !!setItem.value; + } else { + set(newItem.json, setItem.name as string, !!setItem.value); + } + }, + ); // Add number values - (this.getNodeParameter('values.number', itemIndex, []) as INodeParameters[]).forEach((setItem) => { - if (options.dotNotation === false) { - newItem.json[setItem.name as string] = setItem.value; - } else { - set(newItem.json, setItem.name as string, setItem.value); - } - }); + (this.getNodeParameter('values.number', itemIndex, []) as INodeParameters[]).forEach( + (setItem) => { + if (options.dotNotation === false) { + newItem.json[setItem.name as string] = setItem.value; + } else { + set(newItem.json, setItem.name as string, setItem.value); + } + }, + ); // Add string values - (this.getNodeParameter('values.string', itemIndex, []) as INodeParameters[]).forEach((setItem) => { - if (options.dotNotation === false) { - newItem.json[setItem.name as string] = setItem.value; - } else { - set(newItem.json, setItem.name as string, setItem.value); - } - }); + (this.getNodeParameter('values.string', itemIndex, []) as INodeParameters[]).forEach( + (setItem) => { + if (options.dotNotation === false) { + newItem.json[setItem.name as string] = setItem.value; + } else { + set(newItem.json, setItem.name as string, setItem.value); + } + }, + ); returnData.push(newItem); } diff --git a/packages/nodes-base/nodes/Shopify/GenericFunctions.ts b/packages/nodes-base/nodes/Shopify/GenericFunctions.ts index 67fe517de6..f174af4df4 100644 --- a/packages/nodes-base/nodes/Shopify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Shopify/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { BINARY_ENCODING, @@ -10,15 +8,21 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, IOAuth2Options, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, IOAuth2Options, NodeApiError } from 'n8n-workflow'; -import { - snakeCase, -} from 'change-case'; +import { snakeCase } from 'change-case'; -export async function shopifyApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function shopifyApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0, 'oAuth2') as string; let credentials; @@ -48,7 +52,9 @@ export async function shopifyApiRequest(this: IHookFunctions | IExecuteFunctions }; if (authenticationMethod === 'apiKey') { - Object.assign(options, { auth: { username: credentials.apiKey, password: credentials.password } }); + Object.assign(options, { + auth: { username: credentials.apiKey, password: credentials.password }, + }); } if (Object.keys(option).length !== 0) { @@ -62,14 +68,24 @@ export async function shopifyApiRequest(this: IHookFunctions | IExecuteFunctions } try { - return await this.helpers.requestWithAuthentication.call(this, credentialType, options, { oauth2: oAuth2Options }); + return await this.helpers.requestWithAuthentication.call(this, credentialType, options, { + oauth2: oAuth2Options, + }); } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function shopifyApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function shopifyApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -77,7 +93,9 @@ export async function shopifyApiRequestAllItems(this: IHookFunctions | IExecuteF let uri: string | undefined; do { - responseData = await shopifyApiRequest.call(this, method, resource, body, query, uri, { resolveWithFullResponse: true }); + responseData = await shopifyApiRequest.call(this, method, resource, body, query, uri, { + resolveWithFullResponse: true, + }); if (responseData.headers.link) { uri = responseData.headers['link'].split(';')[0].replace('<', '').replace('>', ''); } diff --git a/packages/nodes-base/nodes/Shopify/OrderDescription.ts b/packages/nodes-base/nodes/Shopify/OrderDescription.ts index 7301a11a09..770fdfa8dd 100644 --- a/packages/nodes-base/nodes/Shopify/OrderDescription.ts +++ b/packages/nodes-base/nodes/Shopify/OrderDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const orderOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const orderOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'order', - ], + resource: ['order'], }, }, options: [ @@ -52,7 +48,6 @@ export const orderOperations: INodeProperties[] = [ ]; export const orderFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* order:create */ /* -------------------------------------------------------------------------- */ @@ -63,12 +58,8 @@ export const orderFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'order', - ], + operation: ['create'], + resource: ['order'], }, }, default: {}, @@ -170,7 +161,7 @@ export const orderFields: INodeProperties[] = [ name: 'amount', type: 'string', default: '', - description: 'The amount that\'s deducted from the order total', + description: "The amount that's deducted from the order total", }, { displayName: 'Code', @@ -187,7 +178,7 @@ export const orderFields: INodeProperties[] = [ { name: 'Fixed Amount', value: 'fixedAmount', - description: 'Applies amount as a unit of the store\'s currency', + description: "Applies amount as a unit of the store's currency", }, { name: 'Percentage', @@ -197,7 +188,8 @@ export const orderFields: INodeProperties[] = [ { name: 'Shipping', value: 'shipping', - description: 'Applies a free shipping discount on orders that have a shipping rate less than or equal to amount', + description: + 'Applies a free shipping discount on orders that have a shipping rate less than or equal to amount', }, ], default: 'fixedAmount', @@ -213,7 +205,7 @@ export const orderFields: INodeProperties[] = [ type: 'string', placeholder: 'name@email.com', default: '', - description: 'The customer\'s email address', + description: "The customer's email address", }, { displayName: 'Fulfillment Status', @@ -242,7 +234,7 @@ export const orderFields: INodeProperties[] = [ }, ], default: '', - description: 'The order\'s status in terms of fulfilled line items', + description: "The order's status in terms of fulfilled line items", }, { displayName: 'Inventory Behaviour', @@ -257,12 +249,12 @@ export const orderFields: INodeProperties[] = [ { name: 'Decrement Ignoring Policy', value: 'decrementIgnoringPolicy', - description: 'Ignore the product\'s inventory policy and claim inventory', + description: "Ignore the product's inventory policy and claim inventory", }, { name: 'Decrement Obeying Policy', value: 'decrementObeyingPolicy', - description: 'Follow the product\'s inventory policy and claim inventory, if possible', + description: "Follow the product's inventory policy and claim inventory, if possible", }, ], default: 'bypass', @@ -276,7 +268,8 @@ export const orderFields: INodeProperties[] = [ loadOptionsMethod: 'getLocations', }, default: '', - description: 'The ID of the physical location where the order was processed. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the physical location where the order was processed. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Note', @@ -385,7 +378,8 @@ export const orderFields: INodeProperties[] = [ name: 'sourceName', type: 'string', default: '', - description: 'Where the order originated. Can be set only during order creation, and is not writeable afterwards.', + description: + 'Where the order originated. Can be set only during order creation, and is not writeable afterwards.', }, { displayName: 'Tags', @@ -413,12 +407,8 @@ export const orderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'create', - ], + resource: ['order'], + operation: ['create'], }, }, default: {}, @@ -435,7 +425,8 @@ export const orderFields: INodeProperties[] = [ loadOptionsMethod: 'getProducts', }, default: '', - description: 'The ID of the product that the line item belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the product that the line item belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Variant ID', @@ -488,12 +479,8 @@ export const orderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'delete', - ], + resource: ['order'], + operation: ['delete'], }, }, required: true, @@ -508,12 +495,8 @@ export const orderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'get', - ], + resource: ['order'], + operation: ['get'], }, }, required: true, @@ -525,12 +508,8 @@ export const orderFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'order', - ], + operation: ['get'], + resource: ['order'], }, }, default: {}, @@ -540,7 +519,8 @@ export const orderFields: INodeProperties[] = [ name: 'fields', type: 'string', default: '', - description: 'Fields the order will return, formatted as a string of comma-separated values. By default all the fields are returned.', + description: + 'Fields the order will return, formatted as a string of comma-separated values. By default all the fields are returned.', }, ], }, @@ -553,12 +533,8 @@ export const orderFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'getAll', - ], + resource: ['order'], + operation: ['getAll'], }, }, default: false, @@ -570,15 +546,9 @@ export const orderFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['order'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -596,12 +566,8 @@ export const orderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'order', - ], + operation: ['getAll'], + resource: ['order'], }, }, options: [ @@ -610,7 +576,8 @@ export const orderFields: INodeProperties[] = [ name: 'attributionAppId', type: 'string', default: '', - description: 'Show orders attributed to a certain app, specified by the app ID. Set as current to show orders for the app currently consuming the API.', + description: + 'Show orders attributed to a certain app, specified by the app ID. Set as current to show orders for the app currently consuming the API.', }, { displayName: 'Created At Min', @@ -698,7 +665,8 @@ export const orderFields: INodeProperties[] = [ { name: 'Shipped', value: 'shipped', - description: 'Show orders that have been shipped. Returns orders with fulfillment_status of fulfilled.', + description: + 'Show orders that have been shipped. Returns orders with fulfillment_status of fulfilled.', }, { name: 'Unfulfilled', @@ -708,7 +676,8 @@ export const orderFields: INodeProperties[] = [ { name: 'Unshipped', value: 'unshipped', - description: 'Show orders that have not yet been shipped. Returns orders with fulfillment_status of null.', + description: + 'Show orders that have not yet been shipped. Returns orders with fulfillment_status of null.', }, ], default: 'any', @@ -719,7 +688,8 @@ export const orderFields: INodeProperties[] = [ name: 'fields', type: 'string', default: '', - description: 'Fields the orders will return, formatted as a string of comma-separated values. By default all the fields are returned.', + description: + 'Fields the orders will return, formatted as a string of comma-separated values. By default all the fields are returned.', }, { displayName: 'IDs', @@ -804,12 +774,8 @@ export const orderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'update', - ], + resource: ['order'], + operation: ['update'], }, }, required: true, @@ -821,12 +787,8 @@ export const orderFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'order', - ], + operation: ['update'], + resource: ['order'], }, }, default: {}, @@ -837,7 +799,7 @@ export const orderFields: INodeProperties[] = [ type: 'string', placeholder: 'name@email.com', default: '', - description: 'The customer\'s email address', + description: "The customer's email address", }, { displayName: 'Location Name or ID', @@ -847,7 +809,8 @@ export const orderFields: INodeProperties[] = [ loadOptionsMethod: 'getLocations', }, default: '', - description: 'The ID of the physical location where the order was processed. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the physical location where the order was processed. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Note', @@ -942,7 +905,8 @@ export const orderFields: INodeProperties[] = [ name: 'sourceName', type: 'string', default: '', - description: 'Where the order originated. Can be set only during order creation, and is not writeable afterwards.', + description: + 'Where the order originated. Can be set only during order creation, and is not writeable afterwards.', }, { displayName: 'Tags', diff --git a/packages/nodes-base/nodes/Shopify/ProductDescription.ts b/packages/nodes-base/nodes/Shopify/ProductDescription.ts index 0a9f58387b..c8439267d1 100644 --- a/packages/nodes-base/nodes/Shopify/ProductDescription.ts +++ b/packages/nodes-base/nodes/Shopify/ProductDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const productOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const productOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'product', - ], + resource: ['product'], }, }, options: [ @@ -52,7 +48,6 @@ export const productOperations: INodeProperties[] = [ ]; export const productFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* product:create/update */ /* -------------------------------------------------------------------------- */ @@ -63,12 +58,8 @@ export const productFields: INodeProperties[] = [ placeholder: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'product', - ], + operation: ['create'], + resource: ['product'], }, }, default: '', @@ -82,12 +73,8 @@ export const productFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'update', - ], + resource: ['product'], + operation: ['update'], }, }, required: true, @@ -99,12 +86,8 @@ export const productFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'product', - ], + operation: ['create'], + resource: ['product'], }, }, default: {}, @@ -121,7 +104,8 @@ export const productFields: INodeProperties[] = [ name: 'handle', type: 'string', default: '', - description: 'A unique human-friendly string for the product. Automatically generated from the product\'s title. Used by the Liquid templating language to refer to objects.', + description: + "A unique human-friendly string for the product. Automatically generated from the product's title. Used by the Liquid templating language to refer to objects.", }, { displayName: 'Images', @@ -132,7 +116,8 @@ export const productFields: INodeProperties[] = [ multipleValues: true, }, default: {}, - description: 'A list of product image objects, each one representing an image associated with the product', + description: + 'A list of product image objects, each one representing an image associated with the product', options: [ { displayName: 'Created At', @@ -153,7 +138,8 @@ export const productFields: INodeProperties[] = [ name: 'position', type: 'number', default: '', - description: 'The order of the product image in the list. The first product image is at position 1 and is the "main" image for the product.', + description: + 'The order of the product image in the list. The first product image is at position 1 and is the "main" image for the product.', }, { displayName: 'Product ID', @@ -177,7 +163,8 @@ export const productFields: INodeProperties[] = [ name: 'src', type: 'string', default: '', - description: '

Specifies the location of the product image. This parameter supports URL filters that you can use to retrieve modified copies of the image.

For example, add _small, to the filename to retrieve a scaled copy of the image at 100 x 100 px (for example, ipod-nano_small.png), or add _2048x2048 to retrieve a copy of the image constrained at 2048 x 2048 px resolution (for example, ipod-nano_2048x2048.png).

.', + description: + '

Specifies the location of the product image. This parameter supports URL filters that you can use to retrieve modified copies of the image.

For example, add _small, to the filename to retrieve a scaled copy of the image at 100 x 100 px (for example, ipod-nano_small.png), or add _2048x2048 to retrieve a copy of the image constrained at 2048 x 2048 px resolution (for example, ipod-nano_2048x2048.png).

.', }, { displayName: 'Width', @@ -211,7 +198,8 @@ export const productFields: INodeProperties[] = [ multipleValues: true, }, default: {}, - description: 'The custom product property names like Size, Color, and Material. You can add up to 3 options of up to 255 characters each.', + description: + 'The custom product property names like Size, Color, and Material. You can add up to 3 options of up to 255 characters each.', options: [ { displayName: 'Option', @@ -222,14 +210,14 @@ export const productFields: INodeProperties[] = [ name: 'name', type: 'string', default: '', - description: 'Option\'s name', + description: "Option's name", }, { displayName: 'Value', name: 'value', type: 'string', default: '', - description: 'Option\'s values', + description: "Option's values", }, ], }, @@ -247,7 +235,8 @@ export const productFields: INodeProperties[] = [ name: 'published_at', type: 'dateTime', default: '', - description: 'The date and time (ISO 8601 format) when the product was published. Can be set to null to unpublish the product from the Online Store channel.', + description: + 'The date and time (ISO 8601 format) when the product was published. Can be set to null to unpublish the product from the Online Store channel.', }, { displayName: 'Published Scope', @@ -258,12 +247,14 @@ export const productFields: INodeProperties[] = [ { name: 'Global', value: 'global', - description: 'The product is published to both the Online Store channel and the Point of Sale channel', + description: + 'The product is published to both the Online Store channel and the Point of Sale channel', }, { name: 'Web', value: 'web', - description: 'The product is published to the Online Store channel but not published to the Point of Sale channel', + description: + 'The product is published to the Online Store channel but not published to the Point of Sale channel', }, ], }, @@ -272,14 +263,16 @@ export const productFields: INodeProperties[] = [ name: 'tags', type: 'string', default: '', - description: 'A string of comma-separated tags that are used for filtering and search. A product can have up to 250 tags. Each tag can have up to 255 characters.', + description: + 'A string of comma-separated tags that are used for filtering and search. A product can have up to 250 tags. Each tag can have up to 255 characters.', }, { displayName: 'Template Suffix', name: 'template_suffix', type: 'string', default: '', - description: 'The suffix of the Liquid template used for the product page. If this property is specified, then the product page uses a template called "product.suffix.liquid", where "suffix" is the value of this property. If this property is "" or null, then the product page uses the default template "product.liquid". (default: null)', + description: + 'The suffix of the Liquid template used for the product page. If this property is specified, then the product page uses a template called "product.suffix.liquid", where "suffix" is the value of this property. If this property is "" or null, then the product page uses the default template "product.liquid". (default: null)', }, // { // displayName: 'Variants', @@ -306,7 +299,7 @@ export const productFields: INodeProperties[] = [ name: 'vendor', type: 'string', default: '', - description: 'The name of the product\'s vendor', + description: "The name of the product's vendor", }, ], }, @@ -317,12 +310,8 @@ export const productFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'product', - ], + operation: ['update'], + resource: ['product'], }, }, default: {}, @@ -339,7 +328,8 @@ export const productFields: INodeProperties[] = [ name: 'handle', type: 'string', default: '', - description: 'A unique human-friendly string for the product. Automatically generated from the product\'s title. Used by the Liquid templating language to refer to objects.', + description: + "A unique human-friendly string for the product. Automatically generated from the product's title. Used by the Liquid templating language to refer to objects.", }, { displayName: 'Images', @@ -350,7 +340,8 @@ export const productFields: INodeProperties[] = [ multipleValues: true, }, default: {}, - description: 'A list of product image objects, each one representing an image associated with the product', + description: + 'A list of product image objects, each one representing an image associated with the product', options: [ { displayName: 'Created At', @@ -371,7 +362,8 @@ export const productFields: INodeProperties[] = [ name: 'position', type: 'number', default: '', - description: 'The order of the product image in the list. The first product image is at position 1 and is the "main" image for the product.', + description: + 'The order of the product image in the list. The first product image is at position 1 and is the "main" image for the product.', }, { displayName: 'Product ID', @@ -395,7 +387,8 @@ export const productFields: INodeProperties[] = [ name: 'src', type: 'string', default: '', - description: '

Specifies the location of the product image. This parameter supports URL filters that you can use to retrieve modified copies of the image.

For example, add _small, to the filename to retrieve a scaled copy of the image at 100 x 100 px (for example, ipod-nano_small.png), or add _2048x2048 to retrieve a copy of the image constrained at 2048 x 2048 px resolution (for example, ipod-nano_2048x2048.png).

.', + description: + '

Specifies the location of the product image. This parameter supports URL filters that you can use to retrieve modified copies of the image.

For example, add _small, to the filename to retrieve a scaled copy of the image at 100 x 100 px (for example, ipod-nano_small.png), or add _2048x2048 to retrieve a copy of the image constrained at 2048 x 2048 px resolution (for example, ipod-nano_2048x2048.png).

.', }, { displayName: 'Width', @@ -429,7 +422,8 @@ export const productFields: INodeProperties[] = [ multipleValues: true, }, default: {}, - description: 'The custom product property names like Size, Color, and Material. You can add up to 3 options of up to 255 characters each.', + description: + 'The custom product property names like Size, Color, and Material. You can add up to 3 options of up to 255 characters each.', options: [ { displayName: 'Option', @@ -440,14 +434,14 @@ export const productFields: INodeProperties[] = [ name: 'name', type: 'string', default: '', - description: 'Option\'s name', + description: "Option's name", }, { displayName: 'Value', name: 'value', type: 'string', default: '', - description: 'Option\'s values', + description: "Option's values", }, ], }, @@ -465,7 +459,8 @@ export const productFields: INodeProperties[] = [ name: 'published_at', type: 'dateTime', default: '', - description: 'The date and time (ISO 8601 format) when the product was published. Can be set to null to unpublish the product from the Online Store channel.', + description: + 'The date and time (ISO 8601 format) when the product was published. Can be set to null to unpublish the product from the Online Store channel.', }, { displayName: 'Published Scope', @@ -476,12 +471,14 @@ export const productFields: INodeProperties[] = [ { name: 'Global', value: 'global', - description: 'The product is published to both the Online Store channel and the Point of Sale channel', + description: + 'The product is published to both the Online Store channel and the Point of Sale channel', }, { name: 'Web', value: 'web', - description: 'The product is published to the Online Store channel but not published to the Point of Sale channel', + description: + 'The product is published to the Online Store channel but not published to the Point of Sale channel', }, ], }, @@ -490,14 +487,16 @@ export const productFields: INodeProperties[] = [ name: 'tags', type: 'string', default: '', - description: 'A string of comma-separated tags that are used for filtering and search. A product can have up to 250 tags. Each tag can have up to 255 characters.', + description: + 'A string of comma-separated tags that are used for filtering and search. A product can have up to 250 tags. Each tag can have up to 255 characters.', }, { displayName: 'Template Suffix', name: 'template_suffix', type: 'string', default: '', - description: 'The suffix of the Liquid template used for the product page. If this property is specified, then the product page uses a template called "product.suffix.liquid", where "suffix" is the value of this property. If this property is "" or null, then the product page uses the default template "product.liquid". (default: null)', + description: + 'The suffix of the Liquid template used for the product page. If this property is specified, then the product page uses a template called "product.suffix.liquid", where "suffix" is the value of this property. If this property is "" or null, then the product page uses the default template "product.liquid". (default: null)', }, { displayName: 'Title', @@ -531,7 +530,7 @@ export const productFields: INodeProperties[] = [ name: 'vendor', type: 'string', default: '', - description: 'The name of the product\'s vendor', + description: "The name of the product's vendor", }, ], }, @@ -545,12 +544,8 @@ export const productFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'delete', - ], + resource: ['product'], + operation: ['delete'], }, }, required: true, @@ -565,12 +560,8 @@ export const productFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'get', - ], + resource: ['product'], + operation: ['get'], }, }, required: true, @@ -582,12 +573,8 @@ export const productFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'product', - ], + operation: ['get'], + resource: ['product'], }, }, default: {}, @@ -597,7 +584,8 @@ export const productFields: INodeProperties[] = [ name: 'fields', type: 'string', default: '', - description: 'Fields the product will return, formatted as a string of comma-separated values. By default all the fields are returned.', + description: + 'Fields the product will return, formatted as a string of comma-separated values. By default all the fields are returned.', }, ], }, @@ -610,12 +598,8 @@ export const productFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'getAll', - ], + resource: ['product'], + operation: ['getAll'], }, }, default: false, @@ -627,15 +611,9 @@ export const productFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['product'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -653,12 +631,8 @@ export const productFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'product', - ], + operation: ['getAll'], + resource: ['product'], }, }, options: [ @@ -709,7 +683,8 @@ export const productFields: INodeProperties[] = [ name: 'presentment_currencies', type: 'string', default: '', - description: 'Return presentment prices in only certain currencies, specified by a comma-separated list of ISO 4217 currency codes', + description: + 'Return presentment prices in only certain currencies, specified by a comma-separated list of ISO 4217 currency codes', }, { displayName: 'Product Type', diff --git a/packages/nodes-base/nodes/Shopify/ProductInterface.ts b/packages/nodes-base/nodes/Shopify/ProductInterface.ts index 05b0d3f1ae..1cd3db6b55 100644 --- a/packages/nodes-base/nodes/Shopify/ProductInterface.ts +++ b/packages/nodes-base/nodes/Shopify/ProductInterface.ts @@ -1,6 +1,4 @@ -import { - IDataObject, -} from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export interface IImage { id?: string; diff --git a/packages/nodes-base/nodes/Shopify/Shopify.node.ts b/packages/nodes-base/nodes/Shopify/Shopify.node.ts index f2f22d3ede..d4bbe23abf 100644 --- a/packages/nodes-base/nodes/Shopify/Shopify.node.ts +++ b/packages/nodes-base/nodes/Shopify/Shopify.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,32 +10,15 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - keysToSnakeCase, - shopifyApiRequest, - shopifyApiRequestAllItems, -} from './GenericFunctions'; +import { keysToSnakeCase, shopifyApiRequest, shopifyApiRequestAllItems } from './GenericFunctions'; -import { - orderFields, - orderOperations, -} from './OrderDescription'; +import { orderFields, orderOperations } from './OrderDescription'; -import { - productFields, - productOperations, -} from './ProductDescription'; +import { productFields, productOperations } from './ProductDescription'; -import { - IAddress, - IDiscountCode, - ILineItem, - IOrder, -} from './OrderInterface'; +import { IAddress, IDiscountCode, ILineItem, IOrder } from './OrderInterface'; -import { - IProduct, -} from './ProductInterface'; +import { IProduct } from './ProductInterface'; export class Shopify implements INodeType { description: INodeTypeDescription = { @@ -59,9 +40,7 @@ export class Shopify implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'apiKey', - ], + authentication: ['apiKey'], }, }, }, @@ -70,9 +49,7 @@ export class Shopify implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -81,9 +58,7 @@ export class Shopify implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -141,7 +116,14 @@ export class Shopify implements INodeType { // select them easily async getProducts(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const products = await shopifyApiRequestAllItems.call(this, 'products', 'GET', '/products.json', {}, { fields: 'id,title' }); + const products = await shopifyApiRequestAllItems.call( + this, + 'products', + 'GET', + '/products.json', + {}, + { fields: 'id,title' }, + ); for (const product of products) { const productName = product.title; const productId = product.id; @@ -156,7 +138,14 @@ export class Shopify implements INodeType { // select them easily async getLocations(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const locations = await shopifyApiRequestAllItems.call(this, 'locations', 'GET', '/locations.json', {}, { fields: 'id,name' }); + const locations = await shopifyApiRequestAllItems.call( + this, + 'locations', + 'GET', + '/locations.json', + {}, + { fields: 'id,name' }, + ); for (const location of locations) { const locationName = location.name; const locationId = location.id; @@ -187,9 +176,14 @@ export class Shopify implements INodeType { const discount = additionalFields.discountCodesUi as IDataObject; const billing = additionalFields.billingAddressUi as IDataObject; const shipping = additionalFields.shippingAddressUi as IDataObject; - const lineItem = (this.getNodeParameter('limeItemsUi', i) as IDataObject).lineItemValues as IDataObject[]; + const lineItem = (this.getNodeParameter('limeItemsUi', i) as IDataObject) + .lineItemValues as IDataObject[]; if (lineItem === undefined) { - throw new NodeOperationError(this.getNode(), 'At least one line item has to be added', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'At least one line item has to be added', + { itemIndex: i }, + ); } const body: IOrder = { test: true, @@ -232,12 +226,18 @@ export class Shopify implements INodeType { body.discount_codes = discount.discountCodesValues as IDiscountCode[]; } if (billing) { - body.billing_address = keysToSnakeCase(billing.billingAddressValues as IDataObject)[0] as IAddress; + body.billing_address = keysToSnakeCase( + billing.billingAddressValues as IDataObject, + )[0] as IAddress; } if (shipping) { - body.shipping_address = keysToSnakeCase(shipping.shippingAddressValues as IDataObject)[0] as IAddress; + body.shipping_address = keysToSnakeCase( + shipping.shippingAddressValues as IDataObject, + )[0] as IAddress; } - responseData = await shopifyApiRequest.call(this, 'POST', '/orders.json', { order: body }); + responseData = await shopifyApiRequest.call(this, 'POST', '/orders.json', { + order: body, + }); responseData = responseData.order; } //https://shopify.dev/docs/admin-api/rest/reference/orders/order#destroy-2020-04 @@ -253,7 +253,13 @@ export class Shopify implements INodeType { if (options.fields) { qs.fields = options.fields as string; } - responseData = await shopifyApiRequest.call(this, 'GET', `/orders/${orderId}.json`, {}, qs); + responseData = await shopifyApiRequest.call( + this, + 'GET', + `/orders/${orderId}.json`, + {}, + qs, + ); responseData = responseData.order; } //https://shopify.dev/docs/admin-api/rest/reference/orders/order#index-2020-04 @@ -301,7 +307,14 @@ export class Shopify implements INodeType { } if (returnAll === true) { - responseData = await shopifyApiRequestAllItems.call(this, 'orders', 'GET', '/orders.json', {}, qs); + responseData = await shopifyApiRequestAllItems.call( + this, + 'orders', + 'GET', + '/orders.json', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await shopifyApiRequest.call(this, 'GET', '/orders.json', {}, qs); @@ -330,9 +343,13 @@ export class Shopify implements INodeType { body.email = updateFields.email as string; } if (shipping) { - body.shipping_address = keysToSnakeCase(shipping.shippingAddressValues as IDataObject)[0] as IAddress; + body.shipping_address = keysToSnakeCase( + shipping.shippingAddressValues as IDataObject, + )[0] as IAddress; } - responseData = await shopifyApiRequest.call(this, 'PUT', `/orders/${orderId}.json`, { order: body }); + responseData = await shopifyApiRequest.call(this, 'PUT', `/orders/${orderId}.json`, { + order: body, + }); responseData = responseData.order; } } else if (resource === 'product') { @@ -342,10 +359,15 @@ export class Shopify implements INodeType { if (operation === 'create') { const title = this.getNodeParameter('title', i) as string; - const additionalFields = this.getNodeParameter('additionalFields', i, {}) as IDataObject; + const additionalFields = this.getNodeParameter( + 'additionalFields', + i, + {}, + ) as IDataObject; if (additionalFields.productOptions) { - const metadata = (additionalFields.productOptions as IDataObject).option as IDataObject[]; + const metadata = (additionalFields.productOptions as IDataObject) + .option as IDataObject[]; additionalFields.options = {}; for (const data of metadata) { //@ts-ignore @@ -358,31 +380,58 @@ export class Shopify implements INodeType { body.title = title; - responseData = await shopifyApiRequest.call(this, 'POST', '/products.json', { product: body }); + responseData = await shopifyApiRequest.call(this, 'POST', '/products.json', { + product: body, + }); responseData = responseData.product; } if (operation === 'delete') { //https://shopify.dev/docs/admin-api/rest/reference/products/product#destroy-2020-04 - responseData = await shopifyApiRequest.call(this, 'DELETE', `/products/${productId}.json`); + responseData = await shopifyApiRequest.call( + this, + 'DELETE', + `/products/${productId}.json`, + ); responseData = { success: true }; } if (operation === 'get') { //https://shopify.dev/docs/admin-api/rest/reference/products/product#show-2020-04 - const additionalFields = this.getNodeParameter('additionalFields', i, {}) as IDataObject; + const additionalFields = this.getNodeParameter( + 'additionalFields', + i, + {}, + ) as IDataObject; Object.assign(qs, additionalFields); - responseData = await shopifyApiRequest.call(this, 'GET', `/products/${productId}.json`, {}, qs); + responseData = await shopifyApiRequest.call( + this, + 'GET', + `/products/${productId}.json`, + {}, + qs, + ); responseData = responseData.product; } if (operation === 'getAll') { //https://shopify.dev/docs/admin-api/rest/reference/products/product#index-2020-04 - const additionalFields = this.getNodeParameter('additionalFields', i, {}) as IDataObject; + const additionalFields = this.getNodeParameter( + 'additionalFields', + i, + {}, + ) as IDataObject; const returnAll = this.getNodeParameter('returnAll', i) as boolean; Object.assign(qs, additionalFields); if (returnAll === true) { - responseData = await shopifyApiRequestAllItems.call(this, 'products', 'GET', '/products.json', {}, qs); + responseData = await shopifyApiRequestAllItems.call( + this, + 'products', + 'GET', + '/products.json', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await shopifyApiRequest.call(this, 'GET', '/products.json', {}, qs); @@ -405,7 +454,12 @@ export class Shopify implements INodeType { body = updateFields; - responseData = await shopifyApiRequest.call(this, 'PUT', `/products/${productId}.json`, { product: body }); + responseData = await shopifyApiRequest.call( + this, + 'PUT', + `/products/${productId}.json`, + { product: body }, + ); responseData = responseData.product; } diff --git a/packages/nodes-base/nodes/Shopify/ShopifyTrigger.node.ts b/packages/nodes-base/nodes/Shopify/ShopifyTrigger.node.ts index 74df777156..5c1b0a42a8 100644 --- a/packages/nodes-base/nodes/Shopify/ShopifyTrigger.node.ts +++ b/packages/nodes-base/nodes/Shopify/ShopifyTrigger.node.ts @@ -1,22 +1,10 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import { - IDataObject, - INodeType, - INodeTypeDescription, - IWebhookResponseData, -} from 'n8n-workflow'; +import { IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; -import { - shopifyApiRequest, -} from './GenericFunctions'; +import { shopifyApiRequest } from './GenericFunctions'; -import { - createHmac, -} from 'crypto'; +import { createHmac } from 'crypto'; export class ShopifyTrigger implements INodeType { description: INodeTypeDescription = { @@ -38,9 +26,7 @@ export class ShopifyTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'apiKey', - ], + authentication: ['apiKey'], }, }, }, @@ -49,9 +35,7 @@ export class ShopifyTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -60,9 +44,7 @@ export class ShopifyTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -352,7 +334,7 @@ export class ShopifyTrigger implements INodeType { const webhookUrl = this.getNodeWebhookUrl('default'); const endpoint = `/webhooks`; - const { webhooks } = await shopifyApiRequest.call(this, 'GET', endpoint, {}, { topic }); + const { webhooks } = await shopifyApiRequest.call(this, 'GET', endpoint, {}, { topic }); for (const webhook of webhooks) { if (webhook.address === webhookUrl) { webhookData.webhookId = webhook.id; @@ -425,10 +407,12 @@ export class ShopifyTrigger implements INodeType { } const topic = this.getNodeParameter('topic') as string; - if (headerData['x-shopify-topic'] !== undefined - && headerData['x-shopify-hmac-sha256'] !== undefined - && headerData['x-shopify-shop-domain'] !== undefined - && headerData['x-shopify-api-version'] !== undefined) { + if ( + headerData['x-shopify-topic'] !== undefined && + headerData['x-shopify-hmac-sha256'] !== undefined && + headerData['x-shopify-shop-domain'] !== undefined && + headerData['x-shopify-api-version'] !== undefined + ) { // @ts-ignore const computedSignature = createHmac('sha256', secret).update(req.rawBody).digest('base64'); @@ -442,9 +426,7 @@ export class ShopifyTrigger implements INodeType { return {}; } return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/Signl4/GenericFunctions.ts b/packages/nodes-base/nodes/Signl4/GenericFunctions.ts index 3254932ef5..b9d8398a54 100644 --- a/packages/nodes-base/nodes/Signl4/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Signl4/GenericFunctions.ts @@ -1,14 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; /** * Make an API request to SIGNL4 @@ -24,14 +18,21 @@ import { * */ -export async function SIGNL4ApiRequest(this: IExecuteFunctions, method: string, body: string, query: IDataObject = {}, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function SIGNL4ApiRequest( + this: IExecuteFunctions, + method: string, + body: string, + query: IDataObject = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('signl4Api'); const teamSecret = credentials?.teamSecret as string; let options: OptionsWithUri = { headers: { - 'Accept': '*/*', + Accept: '*/*', }, method, body, diff --git a/packages/nodes-base/nodes/Signl4/Signl4.node.ts b/packages/nodes-base/nodes/Signl4/Signl4.node.ts index 92d60db4a3..3528a56c79 100644 --- a/packages/nodes-base/nodes/Signl4/Signl4.node.ts +++ b/packages/nodes-base/nodes/Signl4/Signl4.node.ts @@ -9,9 +9,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - SIGNL4ApiRequest, -} from './GenericFunctions'; +import { SIGNL4ApiRequest } from './GenericFunctions'; export class Signl4 implements INodeType { description: INodeTypeDescription = { @@ -55,9 +53,7 @@ export class Signl4 implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'alert', - ], + resource: ['alert'], }, }, options: [ @@ -86,12 +82,8 @@ export class Signl4 implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'alert', - ], + operation: ['send'], + resource: ['alert'], }, }, description: 'A more detailed description for the alert', @@ -103,12 +95,8 @@ export class Signl4 implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'alert', - ], + operation: ['send'], + resource: ['alert'], }, }, default: {}, @@ -126,7 +114,8 @@ export class Signl4 implements INodeType { { name: 'Multi ACK', value: 'multi_ack', - description: 'In case this alert must be confirmed by the number of people who are on duty at the time this Singl is raised', + description: + 'In case this alert must be confirmed by the number of people who are on duty at the time this Singl is raised', }, ], default: 'single_ack', @@ -150,7 +139,8 @@ export class Signl4 implements INodeType { type: 'string', placeholder: 'data', default: '', - description: 'Name of the binary properties which contain data which should be added as attachment', + description: + 'Name of the binary properties which contain data which should be added as attachment', }, ], }, @@ -162,14 +152,16 @@ export class Signl4 implements INodeType { name: 'externalId', type: 'string', default: '', - description: 'If the event originates from a record in a 3rd party system, use this parameter to pass the unique ID of that record. That ID will be communicated in outbound webhook notifications from SIGNL4, which is great for correlation/synchronization of that record with the alert. If you resolve / close an alert you must use the same External ID as in the original alert.', + description: + 'If the event originates from a record in a 3rd party system, use this parameter to pass the unique ID of that record. That ID will be communicated in outbound webhook notifications from SIGNL4, which is great for correlation/synchronization of that record with the alert. If you resolve / close an alert you must use the same External ID as in the original alert.', }, { displayName: 'Filtering', name: 'filtering', type: 'boolean', default: false, - description: 'Whether to apply event filtering for this event, or not. If set to true, the event will only trigger a notification to the team, if it contains at least one keyword from one of your services and system categories (i.e. it is whitelisted)', + description: + 'Whether to apply event filtering for this event, or not. If set to true, the event will only trigger a notification to the team, if it contains at least one keyword from one of your services and system categories (i.e. it is whitelisted)', }, { displayName: 'Location', @@ -177,7 +169,8 @@ export class Signl4 implements INodeType { type: 'fixedCollection', placeholder: 'Add Location', default: {}, - description: 'Transmit location information (\'latitude, longitude\') with your event and display a map in the mobile app', + description: + "Transmit location information ('latitude, longitude') with your event and display a map in the mobile app", options: [ { name: 'locationFieldsValues', @@ -226,15 +219,12 @@ export class Signl4 implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'resolve', - ], - resource: [ - 'alert', - ], + operation: ['resolve'], + resource: ['alert'], }, }, - description: 'If the event originates from a record in a 3rd party system, use this parameter to pass the unique ID of that record. That ID will be communicated in outbound webhook notifications from SIGNL4, which is great for correlation/synchronization of that record with the alert. If you resolve / close an alert you must use the same External ID as in the original alert.', + description: + 'If the event originates from a record in a 3rd party system, use this parameter to pass the unique ID of that record. That ID will be communicated in outbound webhook notifications from SIGNL4, which is great for correlation/synchronization of that record with the alert. If you resolve / close an alert you must use the same External ID as in the original alert.', }, ], }; @@ -268,7 +258,8 @@ export class Signl4 implements INodeType { data.service = additionalFields.service as string; } if (additionalFields.locationFieldsUi) { - const locationUi = (additionalFields.locationFieldsUi as IDataObject).locationFieldsValues as IDataObject; + const locationUi = (additionalFields.locationFieldsUi as IDataObject) + .locationFieldsValues as IDataObject; if (locationUi) { data['X-S4-Location'] = `${locationUi.latitude},${locationUi.longitude}`; } @@ -294,18 +285,20 @@ export class Signl4 implements INodeType { const attachments = additionalFields.attachmentsUi as IDataObject; if (attachments) { if (attachments.attachmentsBinary && items[i].binary) { - - const propertyName = (attachments.attachmentsBinary as IDataObject).property as string; + const propertyName = (attachments.attachmentsBinary as IDataObject) + .property as string; const binaryProperty = (items[i].binary as IBinaryKeyData)[propertyName]; if (binaryProperty) { - const supportedFileExtension = ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'mp3', 'wav']; if (!supportedFileExtension.includes(binaryProperty.fileExtension as string)) { - - throw new NodeOperationError(this.getNode(), `Invalid extension, just ${supportedFileExtension.join(',')} are supported}`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Invalid extension, just ${supportedFileExtension.join(',')} are supported}`, + { itemIndex: i }, + ); } const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, propertyName); @@ -316,9 +309,12 @@ export class Signl4 implements INodeType { contentType: binaryProperty.mimeType, }, }; - } else { - throw new NodeOperationError(this.getNode(), `Binary property ${propertyName} does not exist on input`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Binary property ${propertyName} does not exist on input`, + { itemIndex: i }, + ); } } } @@ -335,7 +331,6 @@ export class Signl4 implements INodeType { } // Resolve alert if (operation === 'resolve') { - const data: IDataObject = {}; data['X-S4-ExternalID'] = this.getNodeParameter('externalId', i) as string; diff --git a/packages/nodes-base/nodes/Slack/ChannelDescription.ts b/packages/nodes-base/nodes/Slack/ChannelDescription.ts index d178e7a6b9..7e4bb3f3ad 100644 --- a/packages/nodes-base/nodes/Slack/ChannelDescription.ts +++ b/packages/nodes-base/nodes/Slack/ChannelDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const channelOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const channelOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'channel', - ], + resource: ['channel'], }, }, options: [ @@ -49,7 +45,7 @@ export const channelOperations: INodeProperties[] = [ { name: 'History', value: 'history', - description: 'Get a conversation\'s history of messages and events', + description: "Get a conversation's history of messages and events", action: 'Get the history of a channel', }, { @@ -124,7 +120,6 @@ export const channelOperations: INodeProperties[] = [ ]; export const channelFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* channel:archive */ /* -------------------------------------------------------------------------- */ @@ -137,17 +132,14 @@ export const channelFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'archive', - ], - resource: [ - 'channel', - ], + operation: ['archive'], + resource: ['channel'], }, }, default: '', required: true, - description: 'The name of the channel to archive. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the channel to archive. Choose from the list, or specify an ID using an expression.', }, /* -------------------------------------------------------------------------- */ @@ -162,17 +154,14 @@ export const channelFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'close', - ], - resource: [ - 'channel', - ], + operation: ['close'], + resource: ['channel'], }, }, default: '', required: true, - description: 'The name of the channel to close. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the channel to close. Choose from the list, or specify an ID using an expression.', }, /* -------------------------------------------------------------------------- */ @@ -186,12 +175,8 @@ export const channelFields: INodeProperties[] = [ placeholder: 'Channel name', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'channel', - ], + operation: ['create'], + resource: ['channel'], }, }, required: true, @@ -205,12 +190,8 @@ export const channelFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'create', - ], + resource: ['channel'], + operation: ['create'], }, }, options: [ @@ -237,16 +218,13 @@ export const channelFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'invite', - ], - resource: [ - 'channel', - ], + operation: ['invite'], + resource: ['channel'], }, }, required: true, - description: 'The ID of the channel to invite user to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the channel to invite user to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'User Names or IDs', @@ -258,16 +236,13 @@ export const channelFields: INodeProperties[] = [ default: [], displayOptions: { show: { - operation: [ - 'invite', - ], - resource: [ - 'channel', - ], + operation: ['invite'], + resource: ['channel'], }, }, required: true, - description: 'The ID of the user to invite into channel. Choose from the list, or specify IDs using an expression.', + description: + 'The ID of the user to invite into channel. Choose from the list, or specify IDs using an expression.', }, /* -------------------------------------------------------------------------- */ @@ -280,12 +255,8 @@ export const channelFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'channel', - ], + operation: ['get'], + resource: ['channel'], }, }, required: true, @@ -299,12 +270,8 @@ export const channelFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'get', - ], + resource: ['channel'], + operation: ['get'], }, }, options: [ @@ -331,33 +298,27 @@ export const channelFields: INodeProperties[] = [ placeholder: 'Channel name', displayOptions: { show: { - operation: [ - 'kick', - ], - resource: [ - 'channel', - ], + operation: ['kick'], + resource: ['channel'], }, }, required: true, - description: 'The name of the channel to create. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the channel to create. Choose from the list, or specify an ID using an expression.', }, { displayName: 'User Name or ID', name: 'userId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getUsers', }, displayOptions: { show: { - operation: [ - 'kick', - ], - resource: [ - 'channel', - ], + operation: ['kick'], + resource: ['channel'], }, }, default: '', @@ -370,7 +331,8 @@ export const channelFields: INodeProperties[] = [ displayName: 'Channel Name or ID', name: 'channelId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getChannels', }, @@ -378,12 +340,8 @@ export const channelFields: INodeProperties[] = [ placeholder: 'Channel name', displayOptions: { show: { - operation: [ - 'join', - ], - resource: [ - 'channel', - ], + operation: ['join'], + resource: ['channel'], }, }, required: true, @@ -398,12 +356,8 @@ export const channelFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'getAll', - ], + resource: ['channel'], + operation: ['getAll'], }, }, default: false, @@ -415,15 +369,9 @@ export const channelFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['channel'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -441,12 +389,8 @@ export const channelFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'getAll', - ], + resource: ['channel'], + operation: ['getAll'], }, }, options: [ @@ -501,16 +445,13 @@ export const channelFields: INodeProperties[] = [ placeholder: 'Channel name', displayOptions: { show: { - operation: [ - 'history', - ], - resource: [ - 'channel', - ], + operation: ['history'], + resource: ['channel'], }, }, required: true, - description: 'The name of the channel to create. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the channel to create. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -518,12 +459,8 @@ export const channelFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'history', - ], + resource: ['channel'], + operation: ['history'], }, }, default: false, @@ -535,15 +472,9 @@ export const channelFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'history', - ], - returnAll: [ - false, - ], + resource: ['channel'], + operation: ['history'], + returnAll: [false], }, }, typeOptions: { @@ -561,12 +492,8 @@ export const channelFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'history', - ], + resource: ['channel'], + operation: ['history'], }, }, options: [ @@ -575,7 +502,8 @@ export const channelFields: INodeProperties[] = [ name: 'inclusive', type: 'boolean', default: false, - description: 'Whether to include messages with latest or oldest timestamp in results only when either timestamp is specified', + description: + 'Whether to include messages with latest or oldest timestamp in results only when either timestamp is specified', }, { displayName: 'Latest', @@ -606,17 +534,14 @@ export const channelFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'leave', - ], - resource: [ - 'channel', - ], + operation: ['leave'], + resource: ['channel'], }, }, default: '', required: true, - description: 'The name of the channel to leave. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the channel to leave. Choose from the list, or specify an ID using an expression.', }, /* -------------------------------------------------------------------------- */ @@ -626,19 +551,16 @@ export const channelFields: INodeProperties[] = [ displayName: 'Channel Name or ID', name: 'channelId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getChannels', }, default: '', displayOptions: { show: { - operation: [ - 'member', - ], - resource: [ - 'channel', - ], + operation: ['member'], + resource: ['channel'], }, }, required: true, @@ -649,12 +571,8 @@ export const channelFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'member', - ], + resource: ['channel'], + operation: ['member'], }, }, default: false, @@ -672,15 +590,9 @@ export const channelFields: INodeProperties[] = [ placeholder: 'Limit', displayOptions: { show: { - operation: [ - 'member', - ], - resource: [ - 'channel', - ], - returnAll: [ - false, - ], + operation: ['member'], + resource: ['channel'], + returnAll: [false], }, }, }, @@ -691,15 +603,12 @@ export const channelFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'member', - ], + resource: ['channel'], + operation: ['member'], }, }, - description: 'Whether to resolve the data automatically. By default the response only contain the ID to resource.', + description: + 'Whether to resolve the data automatically. By default the response only contain the ID to resource.', }, /* -------------------------------------------------------------------------- */ @@ -713,12 +622,8 @@ export const channelFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'open', - ], + resource: ['channel'], + operation: ['open'], }, }, options: [ @@ -727,7 +632,8 @@ export const channelFields: INodeProperties[] = [ name: 'channelId', type: 'string', default: '', - description: 'Resume a conversation by supplying an im or mpim\'s ID. Or provide the users field instead.', + description: + "Resume a conversation by supplying an im or mpim's ID. Or provide the users field instead.", }, { displayName: 'Return IM', @@ -744,7 +650,8 @@ export const channelFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: [], - description: 'If only one user is included, this creates a 1:1 DM. The ordering of the users is preserved whenever a multi-person direct message is returned. Supply a channel when not supplying users. Choose from the list, or specify IDs using an expression.', + description: + 'If only one user is included, this creates a 1:1 DM. The ordering of the users is preserved whenever a multi-person direct message is returned. Supply a channel when not supplying users. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -761,17 +668,14 @@ export const channelFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'rename', - ], - resource: [ - 'channel', - ], + operation: ['rename'], + resource: ['channel'], }, }, default: '', required: true, - description: 'The name of the channel to rename. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the channel to rename. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Name', @@ -779,12 +683,8 @@ export const channelFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'rename', - ], - resource: [ - 'channel', - ], + operation: ['rename'], + resource: ['channel'], }, }, default: '', @@ -806,16 +706,13 @@ export const channelFields: INodeProperties[] = [ placeholder: 'Channel name', displayOptions: { show: { - operation: [ - 'replies', - ], - resource: [ - 'channel', - ], + operation: ['replies'], + resource: ['channel'], }, }, required: true, - description: 'The name of the channel to create. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the channel to create. Choose from the list, or specify an ID using an expression.', }, { displayName: 'TS', @@ -824,16 +721,12 @@ export const channelFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'replies', - ], - resource: [ - 'channel', - ], + operation: ['replies'], + resource: ['channel'], }, }, required: true, - description: 'Unique identifier of a thread\'s parent message', + description: "Unique identifier of a thread's parent message", }, { displayName: 'Return All', @@ -841,12 +734,8 @@ export const channelFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'replies', - ], + resource: ['channel'], + operation: ['replies'], }, }, default: false, @@ -858,15 +747,9 @@ export const channelFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'replies', - ], - returnAll: [ - false, - ], + resource: ['channel'], + operation: ['replies'], + returnAll: [false], }, }, typeOptions: { @@ -884,12 +767,8 @@ export const channelFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'replies', - ], + resource: ['channel'], + operation: ['replies'], }, }, options: [ @@ -898,7 +777,8 @@ export const channelFields: INodeProperties[] = [ name: 'inclusive', type: 'boolean', default: false, - description: 'Whether to include messages with latest or oldest timestamp in results only when either timestamp is specified', + description: + 'Whether to include messages with latest or oldest timestamp in results only when either timestamp is specified', }, { displayName: 'Latest', @@ -929,17 +809,14 @@ export const channelFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'setPurpose', - ], - resource: [ - 'channel', - ], + operation: ['setPurpose'], + resource: ['channel'], }, }, default: '', required: true, - description: 'Conversation to set the purpose of. Choose from the list, or specify an ID using an expression.', + description: + 'Conversation to set the purpose of. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Purpose', @@ -947,12 +824,8 @@ export const channelFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'setPurpose', - ], - resource: [ - 'channel', - ], + operation: ['setPurpose'], + resource: ['channel'], }, }, default: '', @@ -972,17 +845,14 @@ export const channelFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'setTopic', - ], - resource: [ - 'channel', - ], + operation: ['setTopic'], + resource: ['channel'], }, }, default: '', required: true, - description: 'Conversation to set the topic of. Choose from the list, or specify an ID using an expression.', + description: + 'Conversation to set the topic of. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Topic', @@ -990,12 +860,8 @@ export const channelFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'setTopic', - ], - resource: [ - 'channel', - ], + operation: ['setTopic'], + resource: ['channel'], }, }, default: '', @@ -1015,16 +881,13 @@ export const channelFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'unarchive', - ], - resource: [ - 'channel', - ], + operation: ['unarchive'], + resource: ['channel'], }, }, default: '', required: true, - description: 'The ID of the channel to unarchive. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the channel to unarchive. Choose from the list, or specify an ID using an expression.', }, ]; diff --git a/packages/nodes-base/nodes/Slack/FileDescription.ts b/packages/nodes-base/nodes/Slack/FileDescription.ts index 0c80f50516..5797eb5e74 100644 --- a/packages/nodes-base/nodes/Slack/FileDescription.ts +++ b/packages/nodes-base/nodes/Slack/FileDescription.ts @@ -8,9 +8,7 @@ export const fileOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'file', - ], + resource: ['file'], }, }, options: [ @@ -38,7 +36,6 @@ export const fileOperations: INodeProperties[] = [ ]; export const fileFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* file:upload */ /* -------------------------------------------------------------------------- */ @@ -49,12 +46,8 @@ export const fileFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, description: 'Whether the data to upload should be taken from binary field', @@ -66,17 +59,10 @@ export const fileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], - binaryData: [ - false, - ], + operation: ['upload'], + resource: ['file'], + binaryData: [false], }, - }, placeholder: '', description: 'The text content of the file to upload', @@ -89,17 +75,10 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], - binaryData: [ - true, - ], + operation: ['upload'], + resource: ['file'], + binaryData: [true], }, - }, placeholder: '', description: 'Name of the binary property which contains the data for the file to be uploaded', @@ -110,12 +89,8 @@ export const fileFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, default: {}, @@ -130,7 +105,8 @@ export const fileFields: INodeProperties[] = [ loadOptionsMethod: 'getChannels', }, default: [], - description: 'The channels to send the file to. Choose from the list, or specify IDs using an expression.', + description: + 'The channels to send the file to. Choose from the list, or specify IDs using an expression.', }, { displayName: 'File Name', @@ -151,7 +127,8 @@ export const fileFields: INodeProperties[] = [ name: 'threadTs', type: 'string', default: '', - description: 'Provide another message\'s ts value to upload this file as a reply. Never use a reply\'s ts value; use its parent instead.', + description: + "Provide another message's ts value to upload this file as a reply. Never use a reply's ts value; use its parent instead.", }, { displayName: 'Title', @@ -172,12 +149,8 @@ export const fileFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'getAll', - ], + resource: ['file'], + operation: ['getAll'], }, }, default: false, @@ -189,15 +162,9 @@ export const fileFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['file'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -213,12 +180,8 @@ export const fileFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'file', - ], + operation: ['getAll'], + resource: ['file'], }, }, default: {}, @@ -232,14 +195,16 @@ export const fileFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getChannels', }, - description: 'Channel containing the file to be listed. Choose from the list, or specify an ID using an expression.', + description: + 'Channel containing the file to be listed. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Show Files Hidden By Limit', name: 'showFilesHidden', type: 'boolean', default: false, - description: 'Whether to show truncated file info for files hidden due to being too old, and the team who owns the file being over the file limit', + description: + 'Whether to show truncated file info for files hidden due to being too old, and the team who owns the file being over the file limit', }, { displayName: 'Timestamp From', @@ -301,7 +266,8 @@ export const fileFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getUsers', }, - description: 'Filter files created by a single user. Choose from the list, or specify an ID using an expression.', + description: + 'Filter files created by a single user. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -315,12 +281,8 @@ export const fileFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'get', - ], + resource: ['file'], + operation: ['get'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Slack/GenericFunctions.ts b/packages/nodes-base/nodes/Slack/GenericFunctions.ts index bdb1c6a677..b4dfcdac2d 100644 --- a/packages/nodes-base/nodes/Slack/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Slack/GenericFunctions.ts @@ -1,12 +1,6 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject, @@ -18,7 +12,16 @@ import { import _ from 'lodash'; -export async function slackApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: object = {}, query: object = {}, headers: {} | undefined = undefined, option: {} = {}): Promise { // tslint:disable-line:no-any +export async function slackApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + body: object = {}, + query: object = {}, + headers: {} | undefined = undefined, + option: {} = {}, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0, 'accessToken') as string; let options: OptionsWithUri = { method, @@ -46,16 +49,27 @@ export async function slackApiRequest(this: IExecuteFunctions | IExecuteSingleFu try { let response: any; // tslint:disable-line:no-any const credentialType = authenticationMethod === 'accessToken' ? 'slackApi' : 'slackOAuth2Api'; - response = await this.helpers.requestWithAuthentication.call(this, credentialType, options, { oauth2: oAuth2Options }); + response = await this.helpers.requestWithAuthentication.call(this, credentialType, options, { + oauth2: oAuth2Options, + }); if (response.ok === false) { if (response.error === 'paid_teams_only') { - throw new NodeOperationError(this.getNode(), `Your current Slack plan does not include the resource '${this.getNodeParameter('resource', 0) as string}'`, { - description: `Hint: Upgrate to the Slack plan that includes the funcionality you want to use.`, - }); + throw new NodeOperationError( + this.getNode(), + `Your current Slack plan does not include the resource '${ + this.getNodeParameter('resource', 0) as string + }'`, + { + description: `Hint: Upgrate to the Slack plan that includes the funcionality you want to use.`, + }, + ); } - throw new NodeOperationError(this.getNode(), 'Slack error response: ' + JSON.stringify(response)); + throw new NodeOperationError( + this.getNode(), + 'Slack error response: ' + JSON.stringify(response), + ); } return response; @@ -64,7 +78,16 @@ export async function slackApiRequest(this: IExecuteFunctions | IExecuteSingleFu } } -export async function slackApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function slackApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; query.page = 1; @@ -88,14 +111,14 @@ export async function slackApiRequestAllItems(this: IExecuteFunctions | ILoadOpt (responseData.paging !== undefined && responseData.paging.pages !== undefined && responseData.paging.page !== undefined && - responseData.paging.page < responseData.paging.pages - ) + responseData.paging.page < responseData.paging.pages) ); return returnData; } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); diff --git a/packages/nodes-base/nodes/Slack/MessageDescription.ts b/packages/nodes-base/nodes/Slack/MessageDescription.ts index be781ee091..b5e8c9de70 100644 --- a/packages/nodes-base/nodes/Slack/MessageDescription.ts +++ b/packages/nodes-base/nodes/Slack/MessageDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const messageOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const messageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'message', - ], + resource: ['message'], }, }, options: [ @@ -52,7 +48,6 @@ export const messageOperations: INodeProperties[] = [ ]; export const messageFields: INodeProperties[] = [ - /* ----------------------------------------------------------------------- */ /* message:getPermalink /* ----------------------------------------------------------------------- */ @@ -67,15 +62,12 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'getPermalink', - ], + resource: ['message'], + operation: ['getPermalink'], }, }, - description: 'Channel containing the message. Choose from the list, or specify an ID using an expression.', + description: + 'Channel containing the message. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Timestamp', @@ -85,12 +77,8 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'getPermalink', - ], + resource: ['message'], + operation: ['getPermalink'], }, }, description: 'Timestamp of the message to get permanent link', @@ -107,13 +95,8 @@ export const messageFields: INodeProperties[] = [ placeholder: 'Channel name', displayOptions: { show: { - operation: [ - 'post', - 'postEphemeral', - ], - resource: [ - 'message', - ], + operation: ['post', 'postEphemeral'], + resource: ['message'], }, }, required: true, @@ -127,12 +110,8 @@ export const messageFields: INodeProperties[] = [ placeholder: 'User ID', displayOptions: { show: { - operation: [ - 'postEphemeral', - ], - resource: [ - 'message', - ], + operation: ['postEphemeral'], + resource: ['message'], }, }, required: true, @@ -148,13 +127,8 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'post', - 'postEphemeral', - ], - resource: [ - 'message', - ], + operation: ['post', 'postEphemeral'], + resource: ['message'], }, }, description: 'The text to send', @@ -166,13 +140,8 @@ export const messageFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'post', - 'postEphemeral', - ], - resource: [ - 'message', - ], + operation: ['post', 'postEphemeral'], + resource: ['message'], }, }, }, @@ -182,13 +151,8 @@ export const messageFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'post', - 'postEphemeral', - ], - resource: [ - 'message', - ], + operation: ['post', 'postEphemeral'], + resource: ['message'], }, }, default: {}, @@ -221,7 +185,7 @@ export const messageFields: INodeProperties[] = [ name: 'thread_ts', type: 'string', default: '', - description: 'Provide another message\'s ts value to make this message a reply', + description: "Provide another message's ts value to make this message a reply", }, { displayName: 'Markdown', @@ -235,7 +199,8 @@ export const messageFields: INodeProperties[] = [ name: 'reply_broadcast', type: 'boolean', default: false, - description: 'Whether the reply should be made visible to everyone in the channel or conversation. Use in conjunction with thread_ts.', + description: + 'Whether the reply should be made visible to everyone in the channel or conversation. Use in conjunction with thread_ts.', }, { displayName: 'Unfurl Links', @@ -257,13 +222,12 @@ export const messageFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/authentication': [ - 'accessToken', - ], + '/authentication': ['accessToken'], }, }, default: '', - description: 'The message will be sent from this username (i.e. as if this individual sent the message).', + description: + 'The message will be sent from this username (i.e. as if this individual sent the message).', }, ], }, @@ -277,13 +241,8 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'post', - 'postEphemeral', - ], - resource: [ - 'message', - ], + operation: ['post', 'postEphemeral'], + resource: ['message'], }, }, default: {}, // TODO: Remove comment: has to make default array for the main property, check where that happens in UI @@ -478,15 +437,12 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], + resource: ['message'], + operation: ['update'], }, }, - description: 'Channel containing the message to be updated. Choose from the list, or specify an ID using an expression.', + description: + 'Channel containing the message to be updated. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Text', @@ -495,15 +451,12 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], + resource: ['message'], + operation: ['update'], }, }, - description: 'New text for the message, using the default formatting rules. It\'s not required when presenting attachments.', + description: + "New text for the message, using the default formatting rules. It's not required when presenting attachments.", }, { displayName: 'TS', @@ -513,12 +466,8 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], + resource: ['message'], + operation: ['update'], }, }, description: 'Timestamp of the message to be updated', @@ -530,12 +479,8 @@ export const messageFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'message', - ], + operation: ['update'], + resource: ['message'], }, }, }, @@ -547,12 +492,8 @@ export const messageFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], + resource: ['message'], + operation: ['update'], }, }, options: [ @@ -596,15 +537,9 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['message'], + operation: ['update'], + jsonParameters: [true], }, }, description: 'The attachments to add', @@ -619,15 +554,9 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['message'], + operation: ['update'], + jsonParameters: [true], }, }, description: 'The blocks to add', @@ -642,15 +571,9 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'post', - ], - resource: [ - 'message', - ], - jsonParameters: [ - false, - ], + operation: ['post'], + resource: ['message'], + jsonParameters: [false], }, }, default: {}, @@ -683,13 +606,12 @@ export const messageFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - type: [ - 'actions', - ], + type: ['actions'], }, }, default: '', - description: 'A string acting as a unique identifier for a block. You can use this block_id when you receive an interaction payload to identify the source of the action. If not specified, a block_id will be generated. Maximum length for this field is 255 characters.', + description: + 'A string acting as a unique identifier for a block. You can use this block_id when you receive an interaction payload to identify the source of the action. If not specified, a block_id will be generated. Maximum length for this field is 255 characters.', }, { displayName: 'Elements', @@ -701,9 +623,7 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - type: [ - 'actions', - ], + type: ['actions'], }, }, default: {}, @@ -731,9 +651,7 @@ export const messageFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - type: [ - 'button', - ], + type: ['button'], }, }, default: '', @@ -745,13 +663,12 @@ export const messageFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - type: [ - 'button', - ], + type: ['button'], }, }, default: false, - description: 'Whether emojis in a text field should be escaped into the colon emoji format', + description: + 'Whether emojis in a text field should be escaped into the colon emoji format', }, { displayName: 'Action ID', @@ -759,13 +676,12 @@ export const messageFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - type: [ - 'button', - ], + type: ['button'], }, }, default: '', - description: 'An identifier for this action. You can use this when you receive an interaction payload to identify the source of the action. Should be unique among all other action_ids used elsewhere by your app.', + description: + 'An identifier for this action. You can use this when you receive an interaction payload to identify the source of the action. Should be unique among all other action_ids used elsewhere by your app.', }, { displayName: 'URL', @@ -773,13 +689,12 @@ export const messageFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - type: [ - 'button', - ], + type: ['button'], }, }, default: '', - description: 'A URL to load in the user\'s browser when the button is clicked. Maximum length for this field is 3000 characters. If you\'re using URL, you\'ll still receive an interaction payload and will need to send an acknowledgement response.', + description: + "A URL to load in the user's browser when the button is clicked. Maximum length for this field is 3000 characters. If you're using URL, you'll still receive an interaction payload and will need to send an acknowledgement response.", }, { displayName: 'Value', @@ -787,9 +702,7 @@ export const messageFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - type: [ - 'button', - ], + type: ['button'], }, }, default: '', @@ -801,9 +714,7 @@ export const messageFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - type: [ - 'button', - ], + type: ['button'], }, }, options: [ @@ -863,12 +774,13 @@ export const messageFields: INodeProperties[] = [ name: 'emoji', type: 'boolean', default: false, - description: 'Whether emojis in a text field should be escaped into the colon emoji format', + description: + 'Whether emojis in a text field should be escaped into the colon emoji format', }, ], }, ], - description: 'Defines the dialog\'s title', + description: "Defines the dialog's title", }, { displayName: 'Text', @@ -896,12 +808,14 @@ export const messageFields: INodeProperties[] = [ name: 'emoji', type: 'boolean', default: false, - description: 'Whether emojis in a text field should be escaped into the colon emoji format', + description: + 'Whether emojis in a text field should be escaped into the colon emoji format', }, ], }, ], - description: 'Defines the explanatory text that appears in the confirm dialog', + description: + 'Defines the explanatory text that appears in the confirm dialog', }, { displayName: 'Confirm', @@ -922,14 +836,16 @@ export const messageFields: INodeProperties[] = [ name: 'text', type: 'string', default: '', - description: 'Defines the explanatory text that appears in the confirm dialog', + description: + 'Defines the explanatory text that appears in the confirm dialog', }, { displayName: 'Emoji', name: 'emoji', type: 'boolean', default: false, - description: 'Whether emojis in a text field should be escaped into the colon emoji format', + description: + 'Whether emojis in a text field should be escaped into the colon emoji format', }, ], }, @@ -955,14 +871,16 @@ export const messageFields: INodeProperties[] = [ name: 'text', type: 'string', default: '', - description: 'Defines the text of the button that cancels the action', + description: + 'Defines the text of the button that cancels the action', }, { displayName: 'Emoji', name: 'emoji', type: 'boolean', default: false, - description: 'Whether emojis in a text field should be escaped into the colon emoji format', + description: + 'Whether emojis in a text field should be escaped into the colon emoji format', }, ], }, @@ -993,7 +911,8 @@ export const messageFields: INodeProperties[] = [ ], }, ], - description: 'Defines an optional confirmation dialog after the button is clicked', + description: + 'Defines an optional confirmation dialog after the button is clicked', }, ], }, @@ -1005,13 +924,12 @@ export const messageFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - type: [ - 'section', - ], + type: ['section'], }, }, default: '', - description: 'A string acting as a unique identifier for a block. You can use this block_id when you receive an interaction payload to identify the source of the action. If not specified, a block_id will be generated. Maximum length for this field is 255 characters.', + description: + 'A string acting as a unique identifier for a block. You can use this block_id when you receive an interaction payload to identify the source of the action. If not specified, a block_id will be generated. Maximum length for this field is 255 characters.', }, { displayName: 'Text', @@ -1023,9 +941,7 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - type: [ - 'section', - ], + type: ['section'], }, }, default: {}, @@ -1056,35 +972,34 @@ export const messageFields: INodeProperties[] = [ name: 'text', type: 'string', default: '', - description: 'The text for the block. This field accepts any of the standard text formatting markup when type is mrkdwn.', + description: + 'The text for the block. This field accepts any of the standard text formatting markup when type is mrkdwn.', }, { displayName: 'Emoji', name: 'emoji', displayOptions: { show: { - type: [ - 'plainText', - ], + type: ['plainText'], }, }, type: 'boolean', default: false, - description: 'Whether emojis in a text field should be escaped into the colon emoji format. This field is only usable when type is plain_text.', + description: + 'Whether emojis in a text field should be escaped into the colon emoji format. This field is only usable when type is plain_text.', }, { displayName: 'Verbatim', name: 'verbatim', displayOptions: { show: { - type: [ - 'mrkwdn', - ], + type: ['mrkwdn'], }, }, type: 'boolean', default: false, - description: 'Whether to set to false (as is default) URLs will be auto-converted into links, conversation names will be link-ified, and certain mentions will be automatically parsed', + description: + 'Whether to set to false (as is default) URLs will be auto-converted into links, conversation names will be link-ified, and certain mentions will be automatically parsed', }, ], }, @@ -1101,9 +1016,7 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - type: [ - 'section', - ], + type: ['section'], }, }, default: {}, @@ -1134,7 +1047,8 @@ export const messageFields: INodeProperties[] = [ name: 'text', type: 'string', default: '', - description: 'The text for the block. This field accepts any of the standard text formatting markup when type is mrkdwn.', + description: + 'The text for the block. This field accepts any of the standard text formatting markup when type is mrkdwn.', }, { displayName: 'Emoji', @@ -1142,33 +1056,32 @@ export const messageFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - type: [ - 'plainText', - ], + type: ['plainText'], }, }, default: false, - description: 'Whether emojis in a text field should be escaped into the colon emoji format. This field is only usable when type is plain_text.', + description: + 'Whether emojis in a text field should be escaped into the colon emoji format. This field is only usable when type is plain_text.', }, { displayName: 'Verbatim', name: 'verbatim', displayOptions: { show: { - type: [ - 'mrkwdn', - ], + type: ['mrkwdn'], }, }, type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'When set to false (as is default) URLs will be auto-converted into links, conversation names will be link-ified, and certain mentions will be automatically parsed', + description: + 'When set to false (as is default) URLs will be auto-converted into links, conversation names will be link-ified, and certain mentions will be automatically parsed', }, ], }, ], - description: 'An array of text objects. Any text objects included with fields will be rendered in a compact format that allows for 2 columns of side-by-side text. Maximum number of items is 10.', + description: + 'An array of text objects. Any text objects included with fields will be rendered in a compact format that allows for 2 columns of side-by-side text. Maximum number of items is 10.', }, { displayName: 'Accessory', @@ -1180,9 +1093,7 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - type: [ - 'section', - ], + type: ['section'], }, }, default: {}, @@ -1209,9 +1120,7 @@ export const messageFields: INodeProperties[] = [ name: 'text', displayOptions: { show: { - type: [ - 'button', - ], + type: ['button'], }, }, type: 'string', @@ -1223,51 +1132,46 @@ export const messageFields: INodeProperties[] = [ name: 'emoji', displayOptions: { show: { - type: [ - 'button', - ], + type: ['button'], }, }, type: 'boolean', default: false, - description: 'Whether emojis in a text field should be escaped into the colon emoji format', + description: + 'Whether emojis in a text field should be escaped into the colon emoji format', }, { displayName: 'Action ID', name: 'actionId', displayOptions: { show: { - type: [ - 'button', - ], + type: ['button'], }, }, type: 'string', default: '', - description: 'An identifier for this action. You can use this when you receive an interaction payload to identify the source of the action. Should be unique among all other action_ids used elsewhere by your app.', + description: + 'An identifier for this action. You can use this when you receive an interaction payload to identify the source of the action. Should be unique among all other action_ids used elsewhere by your app.', }, { displayName: 'URL', name: 'url', displayOptions: { show: { - type: [ - 'button', - ], + type: ['button'], }, }, type: 'string', default: '', - description: 'A URL to load in the user\'s browser when the button is clicked. Maximum length for this field is 3000 characters. If you\'re using URL, you\'ll still receive an interaction payload and will need to send an acknowledgement response.', + description: + "A URL to load in the user's browser when the button is clicked. Maximum length for this field is 3000 characters. If you're using URL, you'll still receive an interaction payload and will need to send an acknowledgement response.", }, { displayName: 'Value', name: 'value', displayOptions: { show: { - type: [ - 'button', - ], + type: ['button'], }, }, type: 'string', @@ -1279,9 +1183,7 @@ export const messageFields: INodeProperties[] = [ name: 'style', displayOptions: { show: { - type: [ - 'button', - ], + type: ['button'], }, }, type: 'options', @@ -1312,9 +1214,7 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - type: [ - 'button', - ], + type: ['button'], }, }, default: {}, @@ -1349,12 +1249,14 @@ export const messageFields: INodeProperties[] = [ name: 'emoji', type: 'boolean', default: false, - description: 'Whether emojis in a text field should be escaped into the colon emoji format', + description: + 'Whether emojis in a text field should be escaped into the colon emoji format', }, ], }, ], - description: 'Defines an optional confirmation dialog after the button is clicked', + description: + 'Defines an optional confirmation dialog after the button is clicked', }, { displayName: 'Text', @@ -1382,12 +1284,14 @@ export const messageFields: INodeProperties[] = [ name: 'emoji', type: 'boolean', default: false, - description: 'Whether emojis in a text field should be escaped into the colon emoji format', + description: + 'Whether emojis in a text field should be escaped into the colon emoji format', }, ], }, ], - description: 'Defines the explanatory text that appears in the confirm dialog', + description: + 'Defines the explanatory text that appears in the confirm dialog', }, { displayName: 'Confirm', @@ -1408,19 +1312,22 @@ export const messageFields: INodeProperties[] = [ name: 'text', type: 'string', default: '', - description: 'Defines the explanatory text that appears in the confirm dialog', + description: + 'Defines the explanatory text that appears in the confirm dialog', }, { displayName: 'Emoji', name: 'emoji', type: 'boolean', default: false, - description: 'Whether emojis in a text field should be escaped into the colon emoji format', + description: + 'Whether emojis in a text field should be escaped into the colon emoji format', }, ], }, ], - description: 'Defines the explanatory text that appears in the confirm dialog', + description: + 'Defines the explanatory text that appears in the confirm dialog', }, { displayName: 'Deny', @@ -1441,14 +1348,16 @@ export const messageFields: INodeProperties[] = [ name: 'text', type: 'string', default: '', - description: 'Define the text of the button that cancels the action', + description: + 'Define the text of the button that cancels the action', }, { displayName: 'Emoji', name: 'emoji', type: 'boolean', default: false, - description: 'Whether emojis in a text field should be escaped into the colon emoji format', + description: + 'Whether emojis in a text field should be escaped into the colon emoji format', }, ], }, @@ -1479,7 +1388,8 @@ export const messageFields: INodeProperties[] = [ ], }, ], - description: 'Defines an optional confirmation dialog after the button is clicked', + description: + 'Defines an optional confirmation dialog after the button is clicked', }, ], }, @@ -1499,15 +1409,9 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'post', - ], - jsonParameters: [ - true, - ], + resource: ['message'], + operation: ['post'], + jsonParameters: [true], }, }, description: 'The attachments to add', @@ -1522,15 +1426,9 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'post', - ], - jsonParameters: [ - true, - ], + resource: ['message'], + operation: ['post'], + jsonParameters: [true], }, }, description: 'The blocks to add', @@ -1545,15 +1443,9 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - jsonParameters: [ - false, - ], - operation: [ - 'update', - ], - resource: [ - 'message', - ], + jsonParameters: [false], + operation: ['update'], + resource: ['message'], }, }, default: {}, // TODO: Remove comment: has to make default array for the main property, check where that happens in UI @@ -1748,15 +1640,12 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'delete', - ], + resource: ['message'], + operation: ['delete'], }, }, - description: 'Channel containing the message to be deleted. Choose from the list, or specify an ID using an expression.', + description: + 'Channel containing the message to be deleted. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Timestamp', @@ -1766,12 +1655,8 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'delete', - ], + resource: ['message'], + operation: ['delete'], }, }, description: 'Timestamp of the message to be deleted', diff --git a/packages/nodes-base/nodes/Slack/MessageInterface.ts b/packages/nodes-base/nodes/Slack/MessageInterface.ts index 463c2fa636..69c7b9cb4b 100644 --- a/packages/nodes-base/nodes/Slack/MessageInterface.ts +++ b/packages/nodes-base/nodes/Slack/MessageInterface.ts @@ -1,4 +1,3 @@ - export interface IAttachment { fields: { item?: object[]; diff --git a/packages/nodes-base/nodes/Slack/ReactionDescription.ts b/packages/nodes-base/nodes/Slack/ReactionDescription.ts index 32bb6c4b9d..03c2b832ed 100644 --- a/packages/nodes-base/nodes/Slack/ReactionDescription.ts +++ b/packages/nodes-base/nodes/Slack/ReactionDescription.ts @@ -8,9 +8,7 @@ export const reactionOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'reaction', - ], + resource: ['reaction'], }, }, options: [ @@ -49,17 +47,12 @@ export const reactionFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'reaction', - ], - operation: [ - 'add', - 'get', - 'remove', - ], + resource: ['reaction'], + operation: ['add', 'get', 'remove'], }, }, - description: 'Channel containing the message. Choose from the list, or specify an ID using an expression.', + description: + 'Channel containing the message. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Emoji', @@ -69,13 +62,8 @@ export const reactionFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'reaction', - ], - operation: [ - 'add', - 'remove', - ], + resource: ['reaction'], + operation: ['add', 'remove'], }, }, description: 'Name of emoji', @@ -89,14 +77,8 @@ export const reactionFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'reaction', - ], - operation: [ - 'add', - 'get', - 'remove', - ], + resource: ['reaction'], + operation: ['add', 'get', 'remove'], }, }, description: 'Timestamp of the message', diff --git a/packages/nodes-base/nodes/Slack/Slack.node.ts b/packages/nodes-base/nodes/Slack/Slack.node.ts index 5d079ab995..583b8565d4 100644 --- a/packages/nodes-base/nodes/Slack/Slack.node.ts +++ b/packages/nodes-base/nodes/Slack/Slack.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -16,55 +14,25 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - channelFields, - channelOperations, -} from './ChannelDescription'; +import { channelFields, channelOperations } from './ChannelDescription'; -import { - messageFields, - messageOperations, -} from './MessageDescription'; +import { messageFields, messageOperations } from './MessageDescription'; -import { - starFields, - starOperations, -} from './StarDescription'; +import { starFields, starOperations } from './StarDescription'; -import { - fileFields, - fileOperations, -} from './FileDescription'; +import { fileFields, fileOperations } from './FileDescription'; -import { - reactionFields, - reactionOperations, -} from './ReactionDescription'; +import { reactionFields, reactionOperations } from './ReactionDescription'; -import { - userGroupFields, - userGroupOperations, -} from './UserGroupDescription'; +import { userGroupFields, userGroupOperations } from './UserGroupDescription'; -import { - userFields, - userOperations, -} from './UserDescription'; +import { userFields, userOperations } from './UserDescription'; -import { - userProfileFields, - userProfileOperations, -} from './UserProfileDescription'; +import { userProfileFields, userProfileOperations } from './UserProfileDescription'; -import { - slackApiRequest, - slackApiRequestAllItems, - validateJSON, -} from './GenericFunctions'; +import { slackApiRequest, slackApiRequestAllItems, validateJSON } from './GenericFunctions'; -import { - IAttachment, -} from './MessageInterface'; +import { IAttachment } from './MessageInterface'; import moment from 'moment'; @@ -128,9 +96,7 @@ export class Slack implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -139,9 +105,7 @@ export class Slack implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -242,8 +206,12 @@ export class Slack implements INodeType { } returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -254,7 +222,14 @@ export class Slack implements INodeType { async getChannels(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const qs = { types: 'public_channel,private_channel', limit: 1000 }; - const channels = await slackApiRequestAllItems.call(this, 'channels', 'GET', '/conversations.list', {}, qs); + const channels = await slackApiRequestAllItems.call( + this, + 'channels', + 'GET', + '/conversations.list', + {}, + qs, + ); for (const channel of channels) { const channelName = channel.name; const channelId = channel.id; @@ -265,8 +240,12 @@ export class Slack implements INodeType { } returnData.sort((a, b) => { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); @@ -276,7 +255,9 @@ export class Slack implements INodeType { // select them easily async getTeamFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { profile: { fields } } = await slackApiRequest.call(this, 'GET', '/team.profile.get'); + const { + profile: { fields }, + } = await slackApiRequest.call(this, 'GET', '/team.profile.get'); for (const field of fields) { const fieldName = field.label; const fieldId = field.id; @@ -302,7 +283,9 @@ export class Slack implements INodeType { for (let i = 0; i < length; i++) { try { - responseData = { error: 'Resource ' + resource + ' / operation ' + operation + ' not found!' }; + responseData = { + error: 'Resource ' + resource + ' / operation ' + operation + ' not found!', + }; qs = {}; if (resource === 'channel') { //https://api.slack.com/methods/conversations.archive @@ -311,7 +294,13 @@ export class Slack implements INodeType { const body: IDataObject = { channel, }; - responseData = await slackApiRequest.call(this, 'POST', '/conversations.archive', body, qs); + responseData = await slackApiRequest.call( + this, + 'POST', + '/conversations.archive', + body, + qs, + ); } //https://api.slack.com/methods/conversations.close if (operation === 'close') { @@ -319,7 +308,13 @@ export class Slack implements INodeType { const body: IDataObject = { channel, }; - responseData = await slackApiRequest.call(this, 'POST', '/conversations.close', body, qs); + responseData = await slackApiRequest.call( + this, + 'POST', + '/conversations.close', + body, + qs, + ); } //https://api.slack.com/methods/conversations.create if (operation === 'create') { @@ -331,7 +326,13 @@ export class Slack implements INodeType { if (additionalFields.isPrivate) { body.is_private = additionalFields.isPrivate as boolean; } - responseData = await slackApiRequest.call(this, 'POST', '/conversations.create', body, qs); + responseData = await slackApiRequest.call( + this, + 'POST', + '/conversations.create', + body, + qs, + ); responseData = responseData.channel; } //https://api.slack.com/methods/conversations.kick @@ -342,7 +343,13 @@ export class Slack implements INodeType { channel, user: userId, }; - responseData = await slackApiRequest.call(this, 'POST', '/conversations.kick', body, qs); + responseData = await slackApiRequest.call( + this, + 'POST', + '/conversations.kick', + body, + qs, + ); } //https://api.slack.com/methods/conversations.join if (operation === 'join') { @@ -350,7 +357,13 @@ export class Slack implements INodeType { const body: IDataObject = { channel, }; - responseData = await slackApiRequest.call(this, 'POST', '/conversations.join', body, qs); + responseData = await slackApiRequest.call( + this, + 'POST', + '/conversations.join', + body, + qs, + ); responseData = responseData.channel; } //https://api.slack.com/methods/conversations.info @@ -371,7 +384,14 @@ export class Slack implements INodeType { qs.exclude_archived = filters.excludeArchived as boolean; } if (returnAll === true) { - responseData = await slackApiRequestAllItems.call(this, 'channels', 'GET', '/conversations.list', {}, qs); + responseData = await slackApiRequestAllItems.call( + this, + 'channels', + 'GET', + '/conversations.list', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await slackApiRequest.call(this, 'GET', '/conversations.list', {}, qs); @@ -394,10 +414,23 @@ export class Slack implements INodeType { qs.oldest = new Date(filters.oldest as string).getTime() / 1000; } if (returnAll === true) { - responseData = await slackApiRequestAllItems.call(this, 'messages', 'GET', '/conversations.history', {}, qs); + responseData = await slackApiRequestAllItems.call( + this, + 'messages', + 'GET', + '/conversations.history', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await slackApiRequest.call(this, 'GET', '/conversations.history', {}, qs); + responseData = await slackApiRequest.call( + this, + 'GET', + '/conversations.history', + {}, + qs, + ); responseData = responseData.messages; } } @@ -409,7 +442,13 @@ export class Slack implements INodeType { channel, users: userIds, }; - responseData = await slackApiRequest.call(this, 'POST', '/conversations.invite', body, qs); + responseData = await slackApiRequest.call( + this, + 'POST', + '/conversations.invite', + body, + qs, + ); responseData = responseData.channel; } //https://api.slack.com/methods/conversations.leave @@ -418,7 +457,13 @@ export class Slack implements INodeType { const body: IDataObject = { channel, }; - responseData = await slackApiRequest.call(this, 'POST', '/conversations.leave', body, qs); + responseData = await slackApiRequest.call( + this, + 'POST', + '/conversations.leave', + body, + qs, + ); } //https://api.slack.com/methods/conversations.members if (operation === 'member') { @@ -426,18 +471,37 @@ export class Slack implements INodeType { const resolveData = this.getNodeParameter('resolveData', 0) as boolean; qs.channel = this.getNodeParameter('channelId', i) as string; if (returnAll) { - responseData = await slackApiRequestAllItems.call(this, 'members', 'GET', '/conversations.members', {}, qs); + responseData = await slackApiRequestAllItems.call( + this, + 'members', + 'GET', + '/conversations.members', + {}, + qs, + ); responseData = responseData.map((member: string) => ({ member })); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await slackApiRequest.call(this, 'GET', '/conversations.members', {}, qs); + responseData = await slackApiRequest.call( + this, + 'GET', + '/conversations.members', + {}, + qs, + ); responseData = responseData.members.map((member: string) => ({ member })); } if (resolveData) { const data: IDataObject[] = []; for (const { member } of responseData) { - const { user } = await slackApiRequest.call(this, 'GET', '/users.info', {}, { user: member }); + const { user } = await slackApiRequest.call( + this, + 'GET', + '/users.info', + {}, + { user: member }, + ); data.push(user); } responseData = data; @@ -456,7 +520,13 @@ export class Slack implements INodeType { if (options.users) { body.users = (options.users as string[]).join(','); } - responseData = await slackApiRequest.call(this, 'POST', '/conversations.open', body, qs); + responseData = await slackApiRequest.call( + this, + 'POST', + '/conversations.open', + body, + qs, + ); responseData = responseData.channel; } //https://api.slack.com/methods/conversations.rename @@ -467,7 +537,13 @@ export class Slack implements INodeType { channel, name, }; - responseData = await slackApiRequest.call(this, 'POST', '/conversations.rename', body, qs); + responseData = await slackApiRequest.call( + this, + 'POST', + '/conversations.rename', + body, + qs, + ); responseData = responseData.channel; } //https://api.slack.com/methods/conversations.replies @@ -488,10 +564,23 @@ export class Slack implements INodeType { qs.oldest = new Date(filters.oldest as string).getTime() / 1000; } if (returnAll === true) { - responseData = await slackApiRequestAllItems.call(this, 'messages', 'GET', '/conversations.replies', {}, qs); + responseData = await slackApiRequestAllItems.call( + this, + 'messages', + 'GET', + '/conversations.replies', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await slackApiRequest.call(this, 'GET', '/conversations.replies', {}, qs); + responseData = await slackApiRequest.call( + this, + 'GET', + '/conversations.replies', + {}, + qs, + ); responseData = responseData.messages; } } @@ -503,7 +592,13 @@ export class Slack implements INodeType { channel, purpose, }; - responseData = await slackApiRequest.call(this, 'POST', '/conversations.setPurpose', body, qs); + responseData = await slackApiRequest.call( + this, + 'POST', + '/conversations.setPurpose', + body, + qs, + ); responseData = responseData.channel; } //https://api.slack.com/methods/conversations.setTopic @@ -514,7 +609,13 @@ export class Slack implements INodeType { channel, topic, }; - responseData = await slackApiRequest.call(this, 'POST', '/conversations.setTopic', body, qs); + responseData = await slackApiRequest.call( + this, + 'POST', + '/conversations.setTopic', + body, + qs, + ); responseData = responseData.channel; } //https://api.slack.com/methods/conversations.unarchive @@ -523,7 +624,13 @@ export class Slack implements INodeType { const body: IDataObject = { channel, }; - responseData = await slackApiRequest.call(this, 'POST', '/conversations.unarchive', body, qs); + responseData = await slackApiRequest.call( + this, + 'POST', + '/conversations.unarchive', + body, + qs, + ); } } if (resource === 'message') { @@ -551,8 +658,13 @@ export class Slack implements INodeType { } if (!jsonParameters) { - const attachments = this.getNodeParameter('attachments', i, []) as unknown as Attachment[]; - const blocksUi = (this.getNodeParameter('blocksUi', i, []) as IDataObject).blocksValues as IDataObject[]; + const attachments = this.getNodeParameter( + 'attachments', + i, + [], + ) as unknown as Attachment[]; + const blocksUi = (this.getNodeParameter('blocksUi', i, []) as IDataObject) + .blocksValues as IDataObject[]; // The node does save the fields data differently than the API // expects so fix the data befre we send the request @@ -579,15 +691,20 @@ export class Slack implements INodeType { block.block_id = blockUi.blockId as string; block.type = blockUi.type as string; if (block.type === 'actions') { - const elementsUi = (blockUi.elementsUi as IDataObject).elementsValues as IDataObject[]; + const elementsUi = (blockUi.elementsUi as IDataObject) + .elementsValues as IDataObject[]; if (elementsUi) { for (const elementUi of elementsUi) { const element: Element = {}; if (elementUi.actionId === '') { - throw new NodeOperationError(this.getNode(), 'Action ID must be set', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Action ID must be set', { + itemIndex: i, + }); } if (elementUi.text === '') { - throw new NodeOperationError(this.getNode(), 'Text must be set', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Text must be set', { + itemIndex: i, + }); } element.action_id = elementUi.actionId as string; element.type = elementUi.type as string; @@ -605,12 +722,15 @@ export class Slack implements INodeType { if (elementUi.style !== 'default') { element.style = elementUi.style as string; } - const confirmUi = (elementUi.confirmUi as IDataObject).confirmValue as IDataObject; + const confirmUi = (elementUi.confirmUi as IDataObject) + .confirmValue as IDataObject; if (confirmUi) { const confirm: Confirm = {}; - const titleUi = (confirmUi.titleUi as IDataObject).titleValue as IDataObject; + const titleUi = (confirmUi.titleUi as IDataObject) + .titleValue as IDataObject; const textUi = (confirmUi.textUi as IDataObject).textValue as IDataObject; - const confirmTextUi = (confirmUi.confirmTextUi as IDataObject).confirmValue as IDataObject; + const confirmTextUi = (confirmUi.confirmTextUi as IDataObject) + .confirmValue as IDataObject; const denyUi = (confirmUi.denyUi as IDataObject).denyValue as IDataObject; const style = confirmUi.style as string; if (titleUi) { @@ -664,9 +784,14 @@ export class Slack implements INodeType { text.text = textUi.text as string; block.text = text; } else { - throw new NodeOperationError(this.getNode(), 'Property text must be defined', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Property text must be defined', + { itemIndex: i }, + ); } - const fieldsUi = (blockUi.fieldsUi as IDataObject).fieldsValues as IDataObject[]; + const fieldsUi = (blockUi.fieldsUi as IDataObject) + .fieldsValues as IDataObject[]; if (fieldsUi) { const fields: Text[] = []; for (const fieldUi of fieldsUi) { @@ -686,7 +811,8 @@ export class Slack implements INodeType { block.fields = fields; } } - const accessoryUi = (blockUi.accessoryUi as IDataObject).accessoriesValues as IDataObject; + const accessoryUi = (blockUi.accessoryUi as IDataObject) + .accessoriesValues as IDataObject; if (accessoryUi) { const accessory: Element = {}; if (accessoryUi.type === 'button') { @@ -705,12 +831,15 @@ export class Slack implements INodeType { if (accessoryUi.style !== 'default') { accessory.style = accessoryUi.style as string; } - const confirmUi = (accessoryUi.confirmUi as IDataObject).confirmValue as IDataObject; + const confirmUi = (accessoryUi.confirmUi as IDataObject) + .confirmValue as IDataObject; if (confirmUi) { const confirm: Confirm = {}; - const titleUi = (confirmUi.titleUi as IDataObject).titleValue as IDataObject; + const titleUi = (confirmUi.titleUi as IDataObject) + .titleValue as IDataObject; const textUi = (confirmUi.textUi as IDataObject).textValue as IDataObject; - const confirmTextUi = (confirmUi.confirmTextUi as IDataObject).confirmValue as IDataObject; + const confirmTextUi = (confirmUi.confirmTextUi as IDataObject) + .confirmValue as IDataObject; const denyUi = (confirmUi.denyUi as IDataObject).denyValue as IDataObject; const style = confirmUi.style as string; if (titleUi) { @@ -754,15 +883,18 @@ export class Slack implements INodeType { } body.blocks = blocks; } - } else { const attachmentsJson = this.getNodeParameter('attachmentsJson', i, '') as string; const blocksJson = this.getNodeParameter('blocksJson', i, []) as string; if (attachmentsJson !== '' && validateJSON(attachmentsJson) === undefined) { - throw new NodeOperationError(this.getNode(), 'Attachments it is not a valid json', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Attachments it is not a valid json', { + itemIndex: i, + }); } if (blocksJson !== '' && validateJSON(blocksJson) === undefined) { - throw new NodeOperationError(this.getNode(), 'Blocks it is not a valid json', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Blocks it is not a valid json', { + itemIndex: i, + }); } if (attachmentsJson !== '') { body.attachments = attachmentsJson; @@ -782,7 +914,11 @@ export class Slack implements INodeType { const channel = this.getNodeParameter('channelId', i) as string; const text = this.getNodeParameter('text', i) as string; const ts = this.getNodeParameter('ts', i) as string; - const attachments = this.getNodeParameter('attachments', i, []) as unknown as IAttachment[]; + const attachments = this.getNodeParameter( + 'attachments', + i, + [], + ) as unknown as IAttachment[]; const body: IDataObject = { channel, text, @@ -811,7 +947,9 @@ export class Slack implements INodeType { const blocksJson = this.getNodeParameter('blocksJson', i, []) as string; if (blocksJson !== '' && validateJSON(blocksJson) === undefined) { - throw new NodeOperationError(this.getNode(), 'Blocks it is not a valid json', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Blocks it is not a valid json', { + itemIndex: i, + }); } if (blocksJson !== '') { body.blocks = blocksJson; @@ -820,7 +958,9 @@ export class Slack implements INodeType { const attachmentsJson = this.getNodeParameter('attachmentsJson', i, '') as string; if (attachmentsJson !== '' && validateJSON(attachmentsJson) === undefined) { - throw new NodeOperationError(this.getNode(), 'Attachments it is not a valid json', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Attachments it is not a valid json', { + itemIndex: i, + }); } if (attachmentsJson !== '') { @@ -926,7 +1066,14 @@ export class Slack implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll === true) { - responseData = await slackApiRequestAllItems.call(this, 'items', 'GET', '/stars.list', {}, qs); + responseData = await slackApiRequestAllItems.call( + this, + 'items', + 'GET', + '/stars.list', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await slackApiRequest.call(this, 'GET', '/stars.list', {}, qs); @@ -957,12 +1104,21 @@ export class Slack implements INodeType { } if (binaryData) { const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; - if (items[i].binary === undefined + if ( + items[i].binary === undefined || //@ts-ignore - || items[i].binary[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i }); + items[i].binary[binaryPropertyName] === undefined + ) { + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryPropertyName}" does not exists on item!`, + { itemIndex: i }, + ); } - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + i, + binaryPropertyName, + ); body.file = { //@ts-ignore value: binaryDataBuffer, @@ -973,12 +1129,28 @@ export class Slack implements INodeType { contentType: items[i].binary[binaryPropertyName].mimeType, }, }; - responseData = await slackApiRequest.call(this, 'POST', '/files.upload', {}, qs, { 'Content-Type': 'multipart/form-data' }, { formData: body }); + responseData = await slackApiRequest.call( + this, + 'POST', + '/files.upload', + {}, + qs, + { 'Content-Type': 'multipart/form-data' }, + { formData: body }, + ); responseData = responseData.file; } else { const fileContent = this.getNodeParameter('fileContent', i) as string; body.content = fileContent; - responseData = await slackApiRequest.call(this, 'POST', '/files.upload', body, qs, { 'Content-Type': 'application/x-www-form-urlencoded' }, { form: body }); + responseData = await slackApiRequest.call( + this, + 'POST', + '/files.upload', + body, + qs, + { 'Content-Type': 'application/x-www-form-urlencoded' }, + { form: body }, + ); responseData = responseData.file; } } @@ -1005,7 +1177,14 @@ export class Slack implements INodeType { qs.user = filters.userId as string; } if (returnAll === true) { - responseData = await slackApiRequestAllItems.call(this, 'files', 'GET', '/files.list', {}, qs); + responseData = await slackApiRequestAllItems.call( + this, + 'files', + 'GET', + '/files.list', + {}, + qs, + ); } else { qs.count = this.getNodeParameter('limit', i) as number; responseData = await slackApiRequest.call(this, 'GET', '/files.list', {}, qs); @@ -1078,7 +1257,13 @@ export class Slack implements INodeType { Object.assign(body, additionalFields); - responseData = await slackApiRequest.call(this, 'POST', '/usergroups.disable', body, qs); + responseData = await slackApiRequest.call( + this, + 'POST', + '/usergroups.disable', + body, + qs, + ); responseData = responseData.usergroup; } @@ -1134,13 +1319,13 @@ export class Slack implements INodeType { if (body.status_expiration === undefined) { body.status_expiration = 0; - } else { body.status_expiration = moment.tz(body.status_expiration as string, timezone).unix(); } if (body.customFieldUi) { - const customFields = (body.customFieldUi as IDataObject).customFieldValues as IDataObject[]; + const customFields = (body.customFieldUi as IDataObject) + .customFieldValues as IDataObject[]; body.fields = {}; @@ -1153,7 +1338,13 @@ export class Slack implements INodeType { } } - responseData = await slackApiRequest.call(this, 'POST', '/users.profile.set', { profile: body }, qs); + responseData = await slackApiRequest.call( + this, + 'POST', + '/users.profile.set', + { profile: body }, + qs, + ); responseData = responseData.profile; } @@ -1165,7 +1356,13 @@ export class Slack implements INodeType { Object.assign(qs, additionalFields); - responseData = await slackApiRequest.call(this, 'POST', '/users.profile.get', undefined, qs); + responseData = await slackApiRequest.call( + this, + 'POST', + '/users.profile.get', + undefined, + qs, + ); responseData = responseData.profile; } diff --git a/packages/nodes-base/nodes/Slack/StarDescription.ts b/packages/nodes-base/nodes/Slack/StarDescription.ts index 8d02116f51..8c01476294 100644 --- a/packages/nodes-base/nodes/Slack/StarDescription.ts +++ b/packages/nodes-base/nodes/Slack/StarDescription.ts @@ -8,9 +8,7 @@ export const starOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'star', - ], + resource: ['star'], }, }, options: [ @@ -38,7 +36,6 @@ export const starOperations: INodeProperties[] = [ ]; export const starFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* star:add */ /* -------------------------------------------------------------------------- */ @@ -48,12 +45,8 @@ export const starFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'star', - ], + operation: ['add'], + resource: ['star'], }, }, default: {}, @@ -68,7 +61,8 @@ export const starFields: INodeProperties[] = [ loadOptionsMethod: 'getChannels', }, default: '', - description: 'Channel to add star to, or channel where the message to add star to was posted (used with timestamp). Choose from the list, or specify an ID using an expression.', + description: + 'Channel to add star to, or channel where the message to add star to was posted (used with timestamp). Choose from the list, or specify an ID using an expression.', }, { displayName: 'File Comment', @@ -103,12 +97,8 @@ export const starFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'star', - ], + operation: ['delete'], + resource: ['star'], }, }, default: {}, @@ -123,7 +113,8 @@ export const starFields: INodeProperties[] = [ loadOptionsMethod: 'getChannels', }, default: '', - description: 'Channel to add star to, or channel where the message to add star to was posted (used with timestamp). Choose from the list, or specify an ID using an expression.', + description: + 'Channel to add star to, or channel where the message to add star to was posted (used with timestamp). Choose from the list, or specify an ID using an expression.', }, { displayName: 'File ID', @@ -158,12 +149,8 @@ export const starFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'star', - ], - operation: [ - 'getAll', - ], + resource: ['star'], + operation: ['getAll'], }, }, default: false, @@ -175,15 +162,9 @@ export const starFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'star', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['star'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Slack/UserDescription.ts b/packages/nodes-base/nodes/Slack/UserDescription.ts index f0c5a93939..c22168a055 100644 --- a/packages/nodes-base/nodes/Slack/UserDescription.ts +++ b/packages/nodes-base/nodes/Slack/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -26,7 +22,7 @@ export const userOperations: INodeProperties[] = [ name: 'Get Presence', value: 'getPresence', description: 'Get online status of a user', - action: 'Get a user\'s presence status', + action: "Get a user's presence status", }, ], default: 'info', @@ -34,7 +30,6 @@ export const userOperations: INodeProperties[] = [ ]; export const userFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* user:info */ /* -------------------------------------------------------------------------- */ @@ -48,12 +43,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'info', - ], - resource: [ - 'user', - ], + operation: ['info'], + resource: ['user'], }, }, required: true, @@ -73,12 +64,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'getPresence', - ], - resource: [ - 'user', - ], + operation: ['getPresence'], + resource: ['user'], }, }, required: true, diff --git a/packages/nodes-base/nodes/Slack/UserGroupDescription.ts b/packages/nodes-base/nodes/Slack/UserGroupDescription.ts index 265eca0a7a..e5e5f9a0f3 100644 --- a/packages/nodes-base/nodes/Slack/UserGroupDescription.ts +++ b/packages/nodes-base/nodes/Slack/UserGroupDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userGroupOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userGroupOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'userGroup', - ], + resource: ['userGroup'], }, }, options: [ @@ -52,7 +48,6 @@ export const userGroupOperations: INodeProperties[] = [ ]; export const userGroupFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* userGroup:create */ /* -------------------------------------------------------------------------- */ @@ -63,12 +58,8 @@ export const userGroupFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'userGroup', - ], + operation: ['create'], + resource: ['userGroup'], }, }, required: true, @@ -82,12 +73,8 @@ export const userGroupFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'userGroup', - ], - operation: [ - 'create', - ], + resource: ['userGroup'], + operation: ['create'], }, }, options: [ @@ -99,7 +86,8 @@ export const userGroupFields: INodeProperties[] = [ loadOptionsMethod: 'getChannels', }, default: [], - description: 'A comma-separated string of encoded channel IDs for which the User Group uses as a default. Choose from the list, or specify IDs using an expression.', + description: + 'A comma-separated string of encoded channel IDs for which the User Group uses as a default. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Description', @@ -134,12 +122,8 @@ export const userGroupFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'disable', - ], - resource: [ - 'userGroup', - ], + operation: ['disable'], + resource: ['userGroup'], }, }, required: true, @@ -153,12 +137,8 @@ export const userGroupFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'userGroup', - ], - operation: [ - 'disable', - ], + resource: ['userGroup'], + operation: ['disable'], }, }, options: [ @@ -181,12 +161,8 @@ export const userGroupFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'enable', - ], - resource: [ - 'userGroup', - ], + operation: ['enable'], + resource: ['userGroup'], }, }, required: true, @@ -200,12 +176,8 @@ export const userGroupFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'userGroup', - ], - operation: [ - 'enable', - ], + resource: ['userGroup'], + operation: ['enable'], }, }, options: [ @@ -227,12 +199,8 @@ export const userGroupFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'userGroup', - ], + operation: ['getAll'], + resource: ['userGroup'], }, }, default: false, @@ -244,15 +212,9 @@ export const userGroupFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'userGroup', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['userGroup'], + returnAll: [false], }, }, typeOptions: { @@ -270,12 +232,8 @@ export const userGroupFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'userGroup', - ], - operation: [ - 'getAll', - ], + resource: ['userGroup'], + operation: ['getAll'], }, }, options: [ @@ -312,12 +270,8 @@ export const userGroupFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'userGroup', - ], + operation: ['update'], + resource: ['userGroup'], }, }, required: true, @@ -331,12 +285,8 @@ export const userGroupFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'userGroup', - ], - operation: [ - 'update', - ], + resource: ['userGroup'], + operation: ['update'], }, }, options: [ @@ -348,7 +298,8 @@ export const userGroupFields: INodeProperties[] = [ loadOptionsMethod: 'getChannels', }, default: [], - description: 'A comma-separated string of encoded channel IDs for which the User Group uses as a default. Choose from the list, or specify IDs using an expression.', + description: + 'A comma-separated string of encoded channel IDs for which the User Group uses as a default. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Description', diff --git a/packages/nodes-base/nodes/Slack/UserProfileDescription.ts b/packages/nodes-base/nodes/Slack/UserProfileDescription.ts index 050553209d..9b1dd702bd 100644 --- a/packages/nodes-base/nodes/Slack/UserProfileDescription.ts +++ b/packages/nodes-base/nodes/Slack/UserProfileDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import { text } from 'express'; export const userProfileOperations: INodeProperties[] = [ @@ -11,22 +9,20 @@ export const userProfileOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'userProfile', - ], + resource: ['userProfile'], }, }, options: [ { name: 'Get', value: 'get', - description: 'Get your user\'s profile', + description: "Get your user's profile", action: 'Get a user profile', }, { name: 'Update', value: 'update', - description: 'Update user\'s profile', + description: "Update user's profile", action: 'Update a user profile', }, ], @@ -35,7 +31,6 @@ export const userProfileOperations: INodeProperties[] = [ ]; export const userProfileFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* userProfile:update */ /* -------------------------------------------------------------------------- */ @@ -47,12 +42,8 @@ export const userProfileFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'userProfile', - ], - operation: [ - 'update', - ], + resource: ['userProfile'], + operation: ['update'], }, }, options: [ @@ -78,7 +69,8 @@ export const userProfileFields: INodeProperties[] = [ loadOptionsMethod: 'getTeamFields', }, default: '', - description: 'ID of the field to set. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Field Value', @@ -122,14 +114,16 @@ export const userProfileFields: INodeProperties[] = [ name: 'status_emoji', type: 'string', default: '', - description: 'Is a string referencing an emoji enabled for the Slack team, such as :mountain_railway:', + description: + 'Is a string referencing an emoji enabled for the Slack team, such as :mountain_railway:', }, { displayName: 'Status Expiration', name: 'status_expiration', type: 'dateTime', default: '', - description: 'Is an integer specifying seconds since the epoch, more commonly known as "UNIX time". Providing 0 or omitting this field results in a custom status that will not expire.', + description: + 'Is an integer specifying seconds since the epoch, more commonly known as "UNIX time". Providing 0 or omitting this field results in a custom status that will not expire.', }, { displayName: 'Status Text', @@ -143,7 +137,8 @@ export const userProfileFields: INodeProperties[] = [ name: 'user', type: 'string', default: '', - description: 'ID of user to change. This argument may only be specified by team admins on paid teams.', + description: + 'ID of user to change. This argument may only be specified by team admins on paid teams.', }, ], }, @@ -159,12 +154,8 @@ export const userProfileFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'userProfile', - ], - operation: [ - 'get', - ], + resource: ['userProfile'], + operation: ['get'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Sms77/GenericFunctions.ts b/packages/nodes-base/nodes/Sms77/GenericFunctions.ts index d9b378ea50..3dbbe987fb 100644 --- a/packages/nodes-base/nodes/Sms77/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Sms77/GenericFunctions.ts @@ -1,17 +1,8 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - IDataObject, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; /** * Make an API request to Sms77 @@ -22,7 +13,14 @@ import { * @param {object | undefined} data * @returns {Promise} */ -export async function sms77ApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: IDataObject, qs: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function sms77ApiRequest( + this: IHookFunctions | IExecuteFunctions, + method: string, + endpoint: string, + body: IDataObject, + qs: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { headers: { SentWith: 'n8n', @@ -41,7 +39,9 @@ export async function sms77ApiRequest(this: IHookFunctions | IExecuteFunctions, const response = await this.helpers.requestWithAuthentication.call(this, 'sms77Api', options); if (response.success !== '100') { - throw new NodeApiError(this.getNode(), response, { message: 'Invalid sms77 credentials or API error!' }); + throw new NodeApiError(this.getNode(), response, { + message: 'Invalid sms77 credentials or API error!', + }); } return response; diff --git a/packages/nodes-base/nodes/Sms77/Sms77.node.ts b/packages/nodes-base/nodes/Sms77/Sms77.node.ts index ce37350183..809683dcd8 100644 --- a/packages/nodes-base/nodes/Sms77/Sms77.node.ts +++ b/packages/nodes-base/nodes/Sms77/Sms77.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,9 +8,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - sms77ApiRequest, -} from './GenericFunctions'; +import { sms77ApiRequest } from './GenericFunctions'; export class Sms77 implements INodeType { description: INodeTypeDescription = { @@ -62,9 +58,7 @@ export class Sms77 implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'sms', - ], + resource: ['sms'], }, }, options: [ @@ -84,9 +78,7 @@ export class Sms77 implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'voice', - ], + resource: ['voice'], }, }, options: [ @@ -107,15 +99,12 @@ export class Sms77 implements INodeType { placeholder: '+4901234567890', displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - ], + operation: ['send'], + resource: ['sms'], }, }, - description: 'The caller ID displayed in the receivers display. Max 16 numeric or 11 alphanumeric characters.', + description: + 'The caller ID displayed in the receivers display. Max 16 numeric or 11 alphanumeric characters.', }, { displayName: 'To', @@ -126,16 +115,12 @@ export class Sms77 implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - 'voice', - ], + operation: ['send'], + resource: ['sms', 'voice'], }, }, - description: 'The number of your recipient(s) separated by comma. Can be regular numbers or contact/groups from Sms77.', + description: + 'The number of your recipient(s) separated by comma. Can be regular numbers or contact/groups from Sms77.', }, { displayName: 'Message', @@ -148,13 +133,8 @@ export class Sms77 implements INodeType { }, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - 'voice', - ], + operation: ['send'], + resource: ['sms', 'voice'], }, }, description: 'The message to send. Max. 1520 characters', @@ -167,12 +147,8 @@ export class Sms77 implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - ], + operation: ['send'], + resource: ['sms'], }, }, options: [ @@ -204,7 +180,7 @@ export class Sms77 implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Send as flash message being displayed directly the receiver\'s display', + description: "Send as flash message being displayed directly the receiver's display", }, { displayName: 'Label', @@ -226,7 +202,8 @@ export class Sms77 implements INodeType { name: 'performance_tracking', type: 'boolean', default: false, - description: 'Whether to enable performance tracking for URLs found in the message text', + description: + 'Whether to enable performance tracking for URLs found in the message text', }, { displayName: 'TTL', @@ -236,7 +213,8 @@ export class Sms77 implements INodeType { typeOptions: { minValue: 1, }, - description: 'Custom time to live specifying the validity period of a message in minutes', + description: + 'Custom time to live specifying the validity period of a message in minutes', }, ], }, @@ -248,12 +226,8 @@ export class Sms77 implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'voice', - ], + operation: ['send'], + resource: ['voice'], }, }, options: [ @@ -270,7 +244,8 @@ export class Sms77 implements INodeType { type: 'string', default: '', placeholder: '+4901234567890', - description: 'The caller ID. Please use only verified sender IDs, one of your virtual inbound numbers or one of our shared virtual numbers.', + description: + 'The caller ID. Please use only verified sender IDs, one of your virtual inbound numbers or one of our shared virtual numbers.', }, { displayName: 'XML', @@ -327,7 +302,6 @@ export class Sms77 implements INodeType { } else if (responseData !== undefined) { returnData.push(responseData as IDataObject); } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/Snowflake/GenericFunctions.ts b/packages/nodes-base/nodes/Snowflake/GenericFunctions.ts index f970090060..364255848c 100644 --- a/packages/nodes-base/nodes/Snowflake/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Snowflake/GenericFunctions.ts @@ -1,7 +1,4 @@ -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; import snowflake from 'snowflake-sdk'; diff --git a/packages/nodes-base/nodes/Snowflake/Snowflake.node.ts b/packages/nodes-base/nodes/Snowflake/Snowflake.node.ts index 879fc7eaf1..5bc0ea2f31 100644 --- a/packages/nodes-base/nodes/Snowflake/Snowflake.node.ts +++ b/packages/nodes-base/nodes/Snowflake/Snowflake.node.ts @@ -1,20 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - connect, - copyInputItems, - destroy, - execute, -} from './GenericFunctions'; +import { connect, copyInputItems, destroy, execute } from './GenericFunctions'; import snowflake from 'snowflake-sdk'; @@ -78,9 +66,7 @@ export class Snowflake implements INodeType { }, displayOptions: { show: { - operation: [ - 'executeQuery', - ], + operation: ['executeQuery'], }, }, default: '', @@ -89,7 +75,6 @@ export class Snowflake implements INodeType { description: 'The SQL query to execute', }, - // ---------------------------------- // insert // ---------------------------------- @@ -99,9 +84,7 @@ export class Snowflake implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'insert', - ], + operation: ['insert'], }, }, default: '', @@ -114,17 +97,15 @@ export class Snowflake implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'insert', - ], + operation: ['insert'], }, }, default: '', placeholder: 'id,name,description', - description: 'Comma-separated list of the properties which should used as columns for the new rows', + description: + 'Comma-separated list of the properties which should used as columns for the new rows', }, - // ---------------------------------- // update // ---------------------------------- @@ -134,9 +115,7 @@ export class Snowflake implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: '', @@ -149,15 +128,14 @@ export class Snowflake implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: 'id', required: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id - description: 'Name of the property which decides which rows in the database should be updated. Normally that would be "id".', + description: + 'Name of the property which decides which rows in the database should be updated. Normally that would be "id".', }, { displayName: 'Columns', @@ -165,21 +143,21 @@ export class Snowflake implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: '', placeholder: 'name,description', - description: 'Comma-separated list of the properties which should used as columns for rows to update', + description: + 'Comma-separated list of the properties which should used as columns for rows to update', }, - ], }; async execute(this: IExecuteFunctions): Promise { - const credentials = await this.getCredentials('snowflake') as unknown as snowflake.ConnectionOptions; + const credentials = (await this.getCredentials( + 'snowflake', + )) as unknown as snowflake.ConnectionOptions; const returnData: IDataObject[] = []; let responseData; @@ -209,10 +187,12 @@ export class Snowflake implements INodeType { const table = this.getNodeParameter('table', 0) as string; const columnString = this.getNodeParameter('columns', 0) as string; - const columns = columnString.split(',').map(column => column.trim()); - const query = `INSERT INTO ${table}(${columns.join(',')}) VALUES (${columns.map(column => '?').join(',')})`; + const columns = columnString.split(',').map((column) => column.trim()); + const query = `INSERT INTO ${table}(${columns.join(',')}) VALUES (${columns + .map((column) => '?') + .join(',')})`; const data = copyInputItems(items, columns); - const binds = data.map((element => Object.values(element))); + const binds = data.map((element) => Object.values(element)); await execute(connection, query, binds as unknown as snowflake.InsertBinds); returnData.push.apply(returnData, data); } @@ -225,15 +205,17 @@ export class Snowflake implements INodeType { const table = this.getNodeParameter('table', 0) as string; const updateKey = this.getNodeParameter('updateKey', 0) as string; const columnString = this.getNodeParameter('columns', 0) as string; - const columns = columnString.split(',').map(column => column.trim()); + const columns = columnString.split(',').map((column) => column.trim()); if (!columns.includes(updateKey)) { columns.unshift(updateKey); } - const query = `UPDATE ${table} SET ${columns.map(column => `${column} = ?`).join(',')} WHERE ${updateKey} = ?;`; + const query = `UPDATE ${table} SET ${columns + .map((column) => `${column} = ?`) + .join(',')} WHERE ${updateKey} = ?;`; const data = copyInputItems(items, columns); - const binds = data.map((element => Object.values(element).concat(element[updateKey]))); + const binds = data.map((element) => Object.values(element).concat(element[updateKey])); for (let i = 0; i < binds.length; i++) { await execute(connection, query, binds[i] as unknown as snowflake.InsertBinds); } diff --git a/packages/nodes-base/nodes/SplitInBatches/SplitInBatches.node.ts b/packages/nodes-base/nodes/SplitInBatches/SplitInBatches.node.ts index a7a49fb379..ad9eaea595 100644 --- a/packages/nodes-base/nodes/SplitInBatches/SplitInBatches.node.ts +++ b/packages/nodes-base/nodes/SplitInBatches/SplitInBatches.node.ts @@ -1,11 +1,5 @@ import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; - +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; export class SplitInBatches implements INodeType { description: INodeTypeDescription = { @@ -23,7 +17,8 @@ export class SplitInBatches implements INodeType { outputs: ['main'], properties: [ { - displayName: 'You may not need this node — n8n nodes automatically run once for each input item. More info', + displayName: + 'You may not need this node — n8n nodes automatically run once for each input item. More info', name: 'splitInBatchesNotice', type: 'notice', default: '', @@ -50,7 +45,8 @@ export class SplitInBatches implements INodeType { name: 'reset', type: 'boolean', default: false, - description: 'Whether the node will be reset and so with the current input-data newly initialized', + description: + 'Whether the node will be reset and so with the current input-data newly initialized', }, ], }, diff --git a/packages/nodes-base/nodes/Splunk/GenericFunctions.ts b/packages/nodes-base/nodes/Splunk/GenericFunctions.ts index 4be67818fa..e760bc6889 100644 --- a/packages/nodes-base/nodes/Splunk/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Splunk/GenericFunctions.ts @@ -1,20 +1,10 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - ILoadOptionsFunctions, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, ILoadOptionsFunctions, NodeApiError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - parseString, -} from 'xml2js'; +import { parseString } from 'xml2js'; import { SplunkCredentials, @@ -31,15 +21,13 @@ export async function splunkApiRequest( body: IDataObject = {}, qs: IDataObject = {}, ) { - const { - authToken, - baseUrl, - allowUnauthorizedCerts, - } = await this.getCredentials('splunkApi') as SplunkCredentials; + const { authToken, baseUrl, allowUnauthorizedCerts } = (await this.getCredentials( + 'splunkApi', + )) as SplunkCredentials; const options: OptionsWithUri = { headers: { - 'Authorization': `Bearer ${authToken}`, + Authorization: `Bearer ${authToken}`, 'Content-Type': 'application/x-www-form-urlencoded', }, method, @@ -66,7 +54,7 @@ export async function splunkApiRequest( throw new NodeApiError(this.getNode(), { ...error, code: 401 }); } - const rawError = await parseXml(error.error) as SplunkError; + const rawError = (await parseXml(error.error)) as SplunkError; error = extractErrorDescription(rawError); if ('fatal' in error) { @@ -91,13 +79,11 @@ export function parseXml(xml: string) { export function extractErrorDescription(rawError: SplunkError) { const messages = rawError.response?.messages; - return messages - ? { [messages.msg.$.type.toLowerCase()]: messages.msg._ } - : rawError; + return messages ? { [messages.msg.$.type.toLowerCase()]: messages.msg._ } : rawError; } export function toUnixEpoch(timestamp: string) { - return Date.parse(timestamp) /1000; + return Date.parse(timestamp) / 1000; } // ---------------------------------------- @@ -109,9 +95,7 @@ export function formatSearch(responseData: SplunkSearchResponse) { if (!entries) return []; - return Array.isArray(entries) - ? entries.map(formatEntry) - : [formatEntry(entries)]; + return Array.isArray(entries) ? entries.map(formatEntry) : [formatEntry(entries)]; } // ---------------------------------------- @@ -123,9 +107,7 @@ export function formatFeed(responseData: SplunkFeedResponse) { if (!entries) return []; - return Array.isArray(entries) - ? entries.map(formatEntry) - : [formatEntry(entries)]; + return Array.isArray(entries) ? entries.map(formatEntry) : [formatEntry(entries)]; } // ---------------------------------------- @@ -137,7 +119,7 @@ export function formatResults(responseData: SplunkResultResponse) { if (!results) return []; return Array.isArray(results) - ? results.map(r => formatResult(r.field)) + ? results.map((r) => formatResult(r.field)) : [formatResult(results.field)]; } @@ -155,14 +137,9 @@ function compactResult(splunkObject: any): any { return {}; } - if ( - Array.isArray(splunkObject?.value) && - splunkObject?.value[0]?.text - ) { + if (Array.isArray(splunkObject?.value) && splunkObject?.value[0]?.text) { return { - [splunkObject.$.k]: splunkObject.value - .map((v: { text: string }) => v.text) - .join(','), + [splunkObject.$.k]: splunkObject.value.map((v: { text: string }) => v.text).join(','), }; } @@ -241,7 +218,7 @@ function compactEntryContent(splunkObject: any): any { export function setCount(this: IExecuteFunctions, qs: IDataObject) { qs.count = this.getNodeParameter('returnAll', 0) ? 0 - : this.getNodeParameter('limit', 0) as number; + : (this.getNodeParameter('limit', 0) as number); } export function populate(source: IDataObject, destination: IDataObject) { @@ -262,7 +239,5 @@ export function getId( ) { const id = this.getNodeParameter(idType, i) as string; - return id.includes(endpoint) - ? id.split(endpoint).pop()! - : id; + return id.includes(endpoint) ? id.split(endpoint).pop()! : id; } diff --git a/packages/nodes-base/nodes/Splunk/Splunk.node.ts b/packages/nodes-base/nodes/Splunk/Splunk.node.ts index 7dc22e3db6..4c23d8e977 100644 --- a/packages/nodes-base/nodes/Splunk/Splunk.node.ts +++ b/packages/nodes-base/nodes/Splunk/Splunk.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -36,14 +34,9 @@ import { userOperations, } from './descriptions'; -import { - SplunkCredentials, - SplunkFeedResponse, -} from './types'; +import { SplunkCredentials, SplunkFeedResponse } from './types'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; export class Splunk implements INodeType { description: INodeTypeDescription = { @@ -112,11 +105,15 @@ export class Splunk implements INodeType { loadOptions: { async getRoles(this: ILoadOptionsFunctions) { const endpoint = '/services/authorization/roles'; - const responseData = await splunkApiRequest.call(this, 'GET', endpoint) as SplunkFeedResponse; + const responseData = (await splunkApiRequest.call( + this, + 'GET', + endpoint, + )) as SplunkFeedResponse; const { entry: entries } = responseData.feed; return Array.isArray(entries) - ? entries.map(entry => ({ name: entry.title, value: entry.title })) + ? entries.map((entry) => ({ name: entry.title, value: entry.title })) : [{ name: entries.title, value: entries.title }]; }, }, @@ -125,17 +122,13 @@ export class Splunk implements INodeType { this: ICredentialTestFunctions, credential: ICredentialsDecrypted, ): Promise { - const { - authToken, - baseUrl, - allowUnauthorizedCerts, - } = credential.data as SplunkCredentials; + const { authToken, baseUrl, allowUnauthorizedCerts } = credential.data as SplunkCredentials; const endpoint = '/services/alerts/fired_alerts'; const options: OptionsWithUri = { headers: { - 'Authorization': `Bearer ${authToken}`, + Authorization: `Bearer ${authToken}`, 'Content-Type': 'application/x-www-form-urlencoded', }, method: 'GET', @@ -172,17 +165,13 @@ export class Splunk implements INodeType { let responseData; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'firedAlert') { - // ********************************************************************** // firedAlert // ********************************************************************** if (operation === 'getReport') { - // ---------------------------------------- // firedAlert: getReport // ---------------------------------------- @@ -191,17 +180,13 @@ export class Splunk implements INodeType { const endpoint = '/services/alerts/fired_alerts'; responseData = await splunkApiRequest.call(this, 'GET', endpoint).then(formatFeed); - } - } else if (resource === 'searchConfiguration') { - // ********************************************************************** // searchConfiguration // ********************************************************************** if (operation === 'delete') { - // ---------------------------------------- // searchConfiguration: delete // ---------------------------------------- @@ -210,14 +195,15 @@ export class Splunk implements INodeType { const partialEndpoint = '/services/saved/searches/'; const searchConfigurationId = getId.call( - this, i, 'searchConfigurationId', '/search/saved/searches/', + this, + i, + 'searchConfigurationId', + '/search/saved/searches/', ); // id endpoint differs from operation endpoint const endpoint = `${partialEndpoint}/${searchConfigurationId}`; responseData = await splunkApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // searchConfiguration: get // ---------------------------------------- @@ -226,14 +212,15 @@ export class Splunk implements INodeType { const partialEndpoint = '/services/saved/searches/'; const searchConfigurationId = getId.call( - this, i, 'searchConfigurationId', '/search/saved/searches/', + this, + i, + 'searchConfigurationId', + '/search/saved/searches/', ); // id endpoint differs from operation endpoint const endpoint = `${partialEndpoint}/${searchConfigurationId}`; responseData = await splunkApiRequest.call(this, 'GET', endpoint).then(formatFeed); - } else if (operation === 'getAll') { - // ---------------------------------------- // searchConfiguration: getAll // ---------------------------------------- @@ -247,18 +234,16 @@ export class Splunk implements INodeType { setCount.call(this, qs); const endpoint = '/services/saved/searches'; - responseData = await splunkApiRequest.call(this, 'GET', endpoint, {}, qs).then(formatFeed); - + responseData = await splunkApiRequest + .call(this, 'GET', endpoint, {}, qs) + .then(formatFeed); } - } else if (resource === 'searchJob') { - // ********************************************************************** // searchJob // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // searchJob: create // ---------------------------------------- @@ -269,35 +254,31 @@ export class Splunk implements INodeType { search: this.getNodeParameter('search', i), } as IDataObject; - const { - earliest_time, - latest_time, - index_earliest, - index_latest, - ...rest - } = this.getNodeParameter('additionalFields', i) as IDataObject & { - earliest_time?: string; - latest_time?: string; - index_earliest?: string, - index_latest?: string, - }; + const { earliest_time, latest_time, index_earliest, index_latest, ...rest } = + this.getNodeParameter('additionalFields', i) as IDataObject & { + earliest_time?: string; + latest_time?: string; + index_earliest?: string; + index_latest?: string; + }; - populate({ - ...earliest_time && { earliest_time: toUnixEpoch(earliest_time) }, - ...latest_time && { latest_time: toUnixEpoch(latest_time) }, - ...index_earliest && { index_earliest: toUnixEpoch(index_earliest) }, - ...index_latest && { index_latest: toUnixEpoch(index_latest) }, - ...rest, - }, body); + populate( + { + ...(earliest_time && { earliest_time: toUnixEpoch(earliest_time) }), + ...(latest_time && { latest_time: toUnixEpoch(latest_time) }), + ...(index_earliest && { index_earliest: toUnixEpoch(index_earliest) }), + ...(index_latest && { index_latest: toUnixEpoch(index_latest) }), + ...rest, + }, + body, + ); const endpoint = '/services/search/jobs'; responseData = await splunkApiRequest.call(this, 'POST', endpoint, body); const getEndpoint = `/services/search/jobs/${responseData.response.sid}`; responseData = await splunkApiRequest.call(this, 'GET', getEndpoint).then(formatSearch); - } else if (operation === 'delete') { - // ---------------------------------------- // searchJob: delete // ---------------------------------------- @@ -308,9 +289,7 @@ export class Splunk implements INodeType { const searchJobId = getId.call(this, i, 'searchJobId', partialEndpoint); const endpoint = `${partialEndpoint}/${searchJobId}`; responseData = await splunkApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // searchJob: get // ---------------------------------------- @@ -321,9 +300,7 @@ export class Splunk implements INodeType { const searchJobId = getId.call(this, i, 'searchJobId', partialEndpoint); const endpoint = `${partialEndpoint}/${searchJobId}`; responseData = await splunkApiRequest.call(this, 'GET', endpoint).then(formatSearch); - } else if (operation === 'getAll') { - // ---------------------------------------- // searchJob: getAll // ---------------------------------------- @@ -337,19 +314,21 @@ export class Splunk implements INodeType { setCount.call(this, qs); const endpoint = '/services/search/jobs'; - responseData = await splunkApiRequest.call(this, 'GET', endpoint, {}, qs) as SplunkFeedResponse; + responseData = (await splunkApiRequest.call( + this, + 'GET', + endpoint, + {}, + qs, + )) as SplunkFeedResponse; responseData = formatFeed(responseData); - } - } else if (resource === 'searchResult') { - // ********************************************************************** // searchResult // ********************************************************************** if (operation === 'getAll') { - // ---------------------------------------- // searchResult: getAll // ---------------------------------------- @@ -360,7 +339,7 @@ export class Splunk implements INodeType { const qs = {} as IDataObject; const filters = this.getNodeParameter('filters', i) as IDataObject & { - keyValueMatch?: { keyValuePair?: { key: string; value: string; } } + keyValueMatch?: { keyValuePair?: { key: string; value: string } }; }; const options = this.getNodeParameter('options', i) as IDataObject; @@ -374,18 +353,16 @@ export class Splunk implements INodeType { setCount.call(this, qs); const endpoint = `/services/search/jobs/${searchJobId}/results`; - responseData = await splunkApiRequest.call(this, 'GET', endpoint, {}, qs).then(formatResults); - + responseData = await splunkApiRequest + .call(this, 'GET', endpoint, {}, qs) + .then(formatResults); } - } else if (resource === 'user') { - // ********************************************************************** // user // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // user: create // ---------------------------------------- @@ -405,11 +382,14 @@ export class Splunk implements INodeType { populate(additionalFields, body); const endpoint = '/services/authentication/users'; - responseData = await splunkApiRequest.call(this, 'POST', endpoint, body) as SplunkFeedResponse; + responseData = (await splunkApiRequest.call( + this, + 'POST', + endpoint, + body, + )) as SplunkFeedResponse; responseData = formatFeed(responseData); - } else if (operation === 'delete') { - // ---------------------------------------- // user: delete // ---------------------------------------- @@ -421,9 +401,7 @@ export class Splunk implements INodeType { const endpoint = `${partialEndpoint}/${userId}`; await splunkApiRequest.call(this, 'DELETE', endpoint); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // user: get // ---------------------------------------- @@ -434,9 +412,7 @@ export class Splunk implements INodeType { const userId = getId.call(this, i, 'userId', '/services/authentication/users/'); const endpoint = `${partialEndpoint}/${userId}`; responseData = await splunkApiRequest.call(this, 'GET', endpoint).then(formatFeed); - } else if (operation === 'getAll') { - // ---------------------------------------- // user: getAll // ---------------------------------------- @@ -447,10 +423,10 @@ export class Splunk implements INodeType { setCount.call(this, qs); const endpoint = '/services/authentication/users'; - responseData = await splunkApiRequest.call(this, 'GET', endpoint, {}, qs).then(formatFeed); - + responseData = await splunkApiRequest + .call(this, 'GET', endpoint, {}, qs) + .then(formatFeed); } else if (operation === 'update') { - // ---------------------------------------- // user: update // ---------------------------------------- @@ -462,20 +438,22 @@ export class Splunk implements INodeType { roles: string[]; }; - populate({ - ...roles && { roles }, - ...rest, - }, body); + populate( + { + ...(roles && { roles }), + ...rest, + }, + body, + ); const partialEndpoint = '/services/authentication/users/'; const userId = getId.call(this, i, 'userId', partialEndpoint); const endpoint = `${partialEndpoint}/${userId}`; - responseData = await splunkApiRequest.call(this, 'POST', endpoint, body).then(formatFeed); - + responseData = await splunkApiRequest + .call(this, 'POST', endpoint, body) + .then(formatFeed); } - } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.cause.error }); @@ -488,7 +466,6 @@ export class Splunk implements INodeType { Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData as IDataObject); - } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Splunk/descriptions/FiredAlertDescription.ts b/packages/nodes-base/nodes/Splunk/descriptions/FiredAlertDescription.ts index 2b1f6687d3..cf05ce444a 100644 --- a/packages/nodes-base/nodes/Splunk/descriptions/FiredAlertDescription.ts +++ b/packages/nodes-base/nodes/Splunk/descriptions/FiredAlertDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const firedAlertOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const firedAlertOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'firedAlert', - ], + resource: ['firedAlert'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Splunk/descriptions/SearchConfigurationDescription.ts b/packages/nodes-base/nodes/Splunk/descriptions/SearchConfigurationDescription.ts index d1967dcaa7..db56bf92f4 100644 --- a/packages/nodes-base/nodes/Splunk/descriptions/SearchConfigurationDescription.ts +++ b/packages/nodes-base/nodes/Splunk/descriptions/SearchConfigurationDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const searchConfigurationOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const searchConfigurationOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'searchConfiguration', - ], + resource: ['searchConfiguration'], }, }, options: [ @@ -52,12 +48,8 @@ export const searchConfigurationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'searchConfiguration', - ], - operation: [ - 'delete', - ], + resource: ['searchConfiguration'], + operation: ['delete'], }, }, }, @@ -74,12 +66,8 @@ export const searchConfigurationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'searchConfiguration', - ], - operation: [ - 'get', - ], + resource: ['searchConfiguration'], + operation: ['get'], }, }, }, @@ -95,12 +83,8 @@ export const searchConfigurationFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'searchConfiguration', - ], - operation: [ - 'getAll', - ], + resource: ['searchConfiguration'], + operation: ['getAll'], }, }, }, @@ -115,15 +99,9 @@ export const searchConfigurationFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'searchConfiguration', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['searchConfiguration'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -135,19 +113,16 @@ export const searchConfigurationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'searchConfiguration', - ], - operation: [ - 'getAll', - ], + resource: ['searchConfiguration'], + operation: ['getAll'], }, }, options: [ { displayName: 'Add Orphan Field', name: 'add_orphan_field', - description: 'Whether to include a boolean value for each saved search to show whether the search is orphaned, meaning that it has no valid owner', + description: + 'Whether to include a boolean value for each saved search to show whether the search is orphaned, meaning that it has no valid owner', type: 'boolean', default: false, }, diff --git a/packages/nodes-base/nodes/Splunk/descriptions/SearchJobDescription.ts b/packages/nodes-base/nodes/Splunk/descriptions/SearchJobDescription.ts index a71e95429c..600cfd63cc 100644 --- a/packages/nodes-base/nodes/Splunk/descriptions/SearchJobDescription.ts +++ b/packages/nodes-base/nodes/Splunk/descriptions/SearchJobDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const searchJobOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const searchJobOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'searchJob', - ], + resource: ['searchJob'], }, }, options: [ @@ -52,18 +48,15 @@ export const searchJobFields: INodeProperties[] = [ { displayName: 'Query', name: 'search', - description: 'Search language string to execute, in Splunk\'s Search Processing Language', + description: + 'Search language string to execute, in Splunk\'s Search Processing Language', type: 'string', required: true, default: '', displayOptions: { show: { - resource: [ - 'searchJob', - ], - operation: [ - 'create', - ], + resource: ['searchJob'], + operation: ['create'], }, }, }, @@ -75,12 +68,8 @@ export const searchJobFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'searchJob', - ], - operation: [ - 'create', - ], + resource: ['searchJob'], + operation: ['create'], }, }, options: [ @@ -185,7 +174,8 @@ export const searchJobFields: INodeProperties[] = [ name: 'max_time', type: 'number', default: 0, - description: 'Number of seconds to run this search before finalizing. Enter 0 to never finalize.', + description: + 'Number of seconds to run this search before finalizing. Enter 0 to never finalize.', }, { displayName: 'Namespace', @@ -206,21 +196,24 @@ export const searchJobFields: INodeProperties[] = [ name: 'remote_server_list', type: 'string', default: '', - description: 'Comma-separated list of (possibly wildcarded) servers from which raw events should be pulled. This same server list is to be used in subsearches.', + description: + 'Comma-separated list of (possibly wildcarded) servers from which raw events should be pulled. This same server list is to be used in subsearches.', }, { displayName: 'Reuse Limit (Seconds)', name: 'reuse_max_seconds_ago', type: 'number', default: 0, - description: 'Number of seconds ago to check when an identical search is started and return the job\’s search ID instead of starting a new job', + description: + 'Number of seconds ago to check when an identical search is started and return the job’s search ID instead of starting a new job', }, { displayName: 'Required Field', name: 'rf', type: 'string', default: '', - description: 'Name of a required field to add to the search. Even if not referenced or used directly by the search, a required field is still included in events and summary endpoints.', + description: + 'Name of a required field to add to the search. Even if not referenced or used directly by the search, a required field is still included in events and summary endpoints.', }, { displayName: 'Search Mode', @@ -243,7 +236,8 @@ export const searchJobFields: INodeProperties[] = [ name: 'status_buckets', type: 'number', default: 0, - description: 'The most status buckets to generate. Set 0 generate no timeline information.', + description: + 'The most status buckets to generate. Set 0 generate no timeline information.', }, { displayName: 'Timeout', @@ -274,12 +268,8 @@ export const searchJobFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'searchJob', - ], - operation: [ - 'delete', - ], + resource: ['searchJob'], + operation: ['delete'], }, }, }, @@ -296,12 +286,8 @@ export const searchJobFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'searchJob', - ], - operation: [ - 'get', - ], + resource: ['searchJob'], + operation: ['get'], }, }, }, @@ -317,12 +303,8 @@ export const searchJobFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'searchJob', - ], - operation: [ - 'getAll', - ], + resource: ['searchJob'], + operation: ['getAll'], }, }, }, @@ -337,15 +319,9 @@ export const searchJobFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'searchJob', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['searchJob'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -357,12 +333,8 @@ export const searchJobFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'searchJob', - ], - operation: [ - 'getAll', - ], + resource: ['searchJob'], + operation: ['getAll'], }, }, options: [ @@ -397,7 +369,8 @@ export const searchJobFields: INodeProperties[] = [ { name: 'Automatic', value: 'auto', - description: 'If all field values are numeric, collate numerically. Otherwise, collate alphabetically.', + description: + 'If all field values are numeric, collate numerically. Otherwise, collate alphabetically.', }, { name: 'Alphabetic', diff --git a/packages/nodes-base/nodes/Splunk/descriptions/SearchResultDescription.ts b/packages/nodes-base/nodes/Splunk/descriptions/SearchResultDescription.ts index 3a9fec1ac4..a4ca305307 100644 --- a/packages/nodes-base/nodes/Splunk/descriptions/SearchResultDescription.ts +++ b/packages/nodes-base/nodes/Splunk/descriptions/SearchResultDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const searchResultOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const searchResultOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'searchResult', - ], + resource: ['searchResult'], }, }, options: [ @@ -40,12 +36,8 @@ export const searchResultFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'searchResult', - ], - operation: [ - 'getAll', - ], + resource: ['searchResult'], + operation: ['getAll'], }, }, }, @@ -57,12 +49,8 @@ export const searchResultFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'searchResult', - ], - operation: [ - 'getAll', - ], + resource: ['searchResult'], + operation: ['getAll'], }, }, }, @@ -77,15 +65,9 @@ export const searchResultFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'searchResult', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['searchResult'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -97,19 +79,16 @@ export const searchResultFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'searchResult', - ], - operation: [ - 'getAll', - ], + resource: ['searchResult'], + operation: ['getAll'], }, }, options: [ { displayName: 'Key-Value Match', name: 'keyValueMatch', - description: 'Key-value pair to match against. Example: if "Key" is set to user and "Field" is set to john, only the results where user is john will be returned.', + description: + 'Key-value pair to match against. Example: if "Key" is set to user and "Field" is set to john, only the results where user is john will be returned.', type: 'fixedCollection', default: {}, placeholder: 'Add Key-Value Pair', @@ -146,12 +125,8 @@ export const searchResultFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'searchResult', - ], - operation: [ - 'getAll', - ], + resource: ['searchResult'], + operation: ['getAll'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Splunk/descriptions/UserDescription.ts b/packages/nodes-base/nodes/Splunk/descriptions/UserDescription.ts index 8b499b2737..c822f9e58b 100644 --- a/packages/nodes-base/nodes/Splunk/descriptions/UserDescription.ts +++ b/packages/nodes-base/nodes/Splunk/descriptions/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -64,12 +60,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, }, @@ -77,7 +69,8 @@ export const userFields: INodeProperties[] = [ displayName: 'Role Names or IDs', name: 'roles', type: 'multiOptions', - description: 'Comma-separated list of roles to assign to the user. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated list of roles to assign to the user. Choose from the list, or specify IDs using an expression.', required: true, default: [], typeOptions: { @@ -85,12 +78,8 @@ export const userFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, }, @@ -102,12 +91,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, }, @@ -119,12 +104,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, options: [ @@ -157,12 +138,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'delete', - ], + resource: ['user'], + operation: ['delete'], }, }, }, @@ -179,12 +156,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, }, @@ -192,7 +165,7 @@ export const userFields: INodeProperties[] = [ // ---------------------------------------- // user: getAll // ---------------------------------------- -{ + { displayName: 'Return All', name: 'returnAll', type: 'boolean', @@ -200,12 +173,8 @@ export const userFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, }, @@ -220,15 +189,9 @@ export const userFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['user'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -245,12 +208,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, }, @@ -262,12 +221,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, options: [ @@ -295,7 +250,8 @@ export const userFields: INodeProperties[] = [ displayName: 'Role Names or IDs', name: 'roles', type: 'multiOptions', - description: 'Comma-separated list of roles to assign to the user. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated list of roles to assign to the user. Choose from the list, or specify IDs using an expression.', default: [], typeOptions: { loadOptionsMethod: 'getRoles', diff --git a/packages/nodes-base/nodes/Splunk/types.d.ts b/packages/nodes-base/nodes/Splunk/types.d.ts index fd8cd218bb..61e87490ca 100644 --- a/packages/nodes-base/nodes/Splunk/types.d.ts +++ b/packages/nodes-base/nodes/Splunk/types.d.ts @@ -24,7 +24,7 @@ export type SplunkError = { msg: { $: { type: string }; _: string; - } - } - } + }; + }; + }; }; diff --git a/packages/nodes-base/nodes/Spontit/GenericFunctions.ts b/packages/nodes-base/nodes/Spontit/GenericFunctions.ts index 2469ae7de8..5c431b2955 100644 --- a/packages/nodes-base/nodes/Spontit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Spontit/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,12 +7,17 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; - -export async function spontitApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError } from 'n8n-workflow'; +export async function spontitApiRequest( + this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('spontitApi'); try { diff --git a/packages/nodes-base/nodes/Spontit/PushDescription.ts b/packages/nodes-base/nodes/Spontit/PushDescription.ts index 262f485e50..32f1fb8e4b 100644 --- a/packages/nodes-base/nodes/Spontit/PushDescription.ts +++ b/packages/nodes-base/nodes/Spontit/PushDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const pushOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const pushOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'push', - ], + resource: ['push'], }, }, options: [ @@ -38,15 +34,12 @@ export const pushFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'push', - ], + operation: ['create'], + resource: ['push'], }, }, - description: 'To provide text in a push, supply one of either "content" or "pushContent" (or both). Limited to 2500 characters. (Required if a value for "pushContent" is not provided).', + description: + 'To provide text in a push, supply one of either "content" or "pushContent" (or both). Limited to 2500 characters. (Required if a value for "pushContent" is not provided).', }, { displayName: 'Additional Fields', @@ -55,12 +48,8 @@ export const pushFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'push', - ], + operation: ['create'], + resource: ['push'], }, }, default: {}, @@ -70,21 +59,24 @@ export const pushFields: INodeProperties[] = [ name: 'channelName', type: 'string', default: '', - description: 'The name of a channel you created. If you have not yet created a channel, simply don\'t provide this value and the push will be sent to your main account.', + description: + "The name of a channel you created. If you have not yet created a channel, simply don't provide this value and the push will be sent to your main account.", }, { displayName: 'Expiration Stamp', name: 'expirationStamp', type: 'dateTime', default: '', - description: 'A Unix timestamp. When to automatically expire your push notification. The default is 10 days after pushing. The push will become unaccessible within 15-30 minutes of the selected time, but will remain on all device screens until dismissed or clicked.', + description: + 'A Unix timestamp. When to automatically expire your push notification. The default is 10 days after pushing. The push will become unaccessible within 15-30 minutes of the selected time, but will remain on all device screens until dismissed or clicked.', }, { displayName: 'iOS DeepLink', name: 'iOSDeepLink', type: 'string', default: '', - description: 'An iOS deep link. Use this to deep link into other apps. Alternatively, you can provide a universal link in the link attribute and set openLinkInApp to false.', + description: + 'An iOS deep link. Use this to deep link into other apps. Alternatively, you can provide a universal link in the link attribute and set openLinkInApp to false.', }, { displayName: 'Link', @@ -98,35 +90,40 @@ export const pushFields: INodeProperties[] = [ name: 'openInHomeFeed', type: 'boolean', default: false, - description: 'Whether the notification opens to the home feed or to a standalone page with the notification. The default (openInHomeFeed=False) is to open the notification on a standalone page.', + description: + 'Whether the notification opens to the home feed or to a standalone page with the notification. The default (openInHomeFeed=False) is to open the notification on a standalone page.', }, { displayName: 'Open Link In App', name: 'openLinkInApp', type: 'boolean', default: false, - description: 'Whether to open the provided link within the iOS app or in Safari. Android PWA opens all links in the default web browser.', + description: + 'Whether to open the provided link within the iOS app or in Safari. Android PWA opens all links in the default web browser.', }, { displayName: 'Push To Emails', name: 'pushToEmails', type: 'string', default: '', - description: '

Emails (strings) to whom to send the notification. If all three attributes \'pushToFollowers\', \'pushToPhoneNumbers\' and \'pushToEmails\' are not supplied, then everyone who follows the channel will receive the push notification.

If \'pushToFollowers\' is supplied, only those listed in the array will receive the push notification.

If one of the userIds supplied does not follow the specified channel, then that userId value will be ignored.

See the "Followers" section to learn how to list the userIds of those who follow one of your channels.

.', + description: + "

Emails (strings) to whom to send the notification. If all three attributes 'pushToFollowers', 'pushToPhoneNumbers' and 'pushToEmails' are not supplied, then everyone who follows the channel will receive the push notification.

If 'pushToFollowers' is supplied, only those listed in the array will receive the push notification.

If one of the userIds supplied does not follow the specified channel, then that userId value will be ignored.

See the \"Followers\" section to learn how to list the userIds of those who follow one of your channels.

.", }, { displayName: 'Push To Followers', name: 'pushToFollowers', type: 'string', default: '', - description: '

User IDs (strings) to whom to send the notification. If all three attributes \'pushToFollowers\', \'pushToPhoneNumbers\' and \'pushToEmails\' are not supplied, then everyone who follows the channel will receive the push notification.

If \'pushToFollowers\' is supplied, only those listed in the array will receive the push notification.

If one of the userIds supplied does not follow the specified channel, then that userId value will be ignored.

See the "Followers" section to learn how to list the userIds of those who follow one of your channels.

.', + description: + "

User IDs (strings) to whom to send the notification. If all three attributes 'pushToFollowers', 'pushToPhoneNumbers' and 'pushToEmails' are not supplied, then everyone who follows the channel will receive the push notification.

If 'pushToFollowers' is supplied, only those listed in the array will receive the push notification.

If one of the userIds supplied does not follow the specified channel, then that userId value will be ignored.

See the \"Followers\" section to learn how to list the userIds of those who follow one of your channels.

.", }, { displayName: 'Push To Phone Numbers', name: 'pushToPhoneNumbers', type: 'string', default: '', - description: '

Phone numbers (strings) to whom to send the notification. If all three attributes \'pushToFollowers\', \'pushToPhoneNumbers\' and \'pushToEmails\' are not supplied, then everyone who follows the channel will receive the push notification.

If \'pushToFollowers\' is supplied, only those listed in the array will receive the push notification.

If one of the userIds supplied does not follow the specified channel, then that userId value will be ignored.

See the "Followers" section to learn how to list the userIds of those who follow one of your channels.

.', + description: + "

Phone numbers (strings) to whom to send the notification. If all three attributes 'pushToFollowers', 'pushToPhoneNumbers' and 'pushToEmails' are not supplied, then everyone who follows the channel will receive the push notification.

If 'pushToFollowers' is supplied, only those listed in the array will receive the push notification.

If one of the userIds supplied does not follow the specified channel, then that userId value will be ignored.

See the \"Followers\" section to learn how to list the userIds of those who follow one of your channels.

.", }, { displayName: 'Schedule', @@ -140,7 +137,8 @@ export const pushFields: INodeProperties[] = [ name: 'subtitle', type: 'string', default: '', - description: 'The subtitle of your push. Limited to 20 characters. Only appears on iOS devices.', + description: + 'The subtitle of your push. Limited to 20 characters. Only appears on iOS devices.', }, { displayName: 'Title', diff --git a/packages/nodes-base/nodes/Spontit/Spontit.node.ts b/packages/nodes-base/nodes/Spontit/Spontit.node.ts index 4790b3ab3d..6ac08e4021 100644 --- a/packages/nodes-base/nodes/Spontit/Spontit.node.ts +++ b/packages/nodes-base/nodes/Spontit/Spontit.node.ts @@ -1,21 +1,9 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IExecuteFunctions } from 'n8n-core'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - spontitApiRequest, -} from './GenericFunctions'; +import { spontitApiRequest } from './GenericFunctions'; -import { - pushFields, - pushOperations, -} from './PushDescription'; +import { pushFields, pushOperations } from './PushDescription'; import moment from 'moment'; diff --git a/packages/nodes-base/nodes/Spotify/GenericFunctions.ts b/packages/nodes-base/nodes/Spotify/GenericFunctions.ts index 4de5c6c72d..1a09b0f356 100644 --- a/packages/nodes-base/nodes/Spotify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Spotify/GenericFunctions.ts @@ -1,21 +1,10 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - IDataObject, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - get, -} from 'lodash'; +import { get } from 'lodash'; /** * Make an API request to Spotify @@ -26,15 +15,21 @@ import { * @param {object} body * @returns {Promise} */ -export async function spotifyApiRequest(this: IHookFunctions | IExecuteFunctions, - method: string, endpoint: string, body: object, query?: object, uri?: string): Promise { // tslint:disable-line:no-any - +export async function spotifyApiRequest( + this: IHookFunctions | IExecuteFunctions, + method: string, + endpoint: string, + body: object, + query?: object, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { method, headers: { 'User-Agent': 'n8n', 'Content-Type': 'text/plain', - 'Accept': ' application/json', + Accept: ' application/json', }, qs: query, uri: uri || `https://api.spotify.com/v1${endpoint}`, @@ -51,9 +46,15 @@ export async function spotifyApiRequest(this: IHookFunctions | IExecuteFunctions } } -export async function spotifyApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, - propertyName: string, method: string, endpoint: string, body: object, query?: object): Promise { // tslint:disable-line:no-any - +export async function spotifyApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions, + propertyName: string, + method: string, + endpoint: string, + body: object, + query?: object, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -72,7 +73,8 @@ export async function spotifyApiRequestAllItems(this: IHookFunctions | IExecuteF } } while ( (responseData['next'] !== null && responseData['next'] !== undefined) || - (responseData[propertyName.split('.')[0]].next !== null && responseData[propertyName.split('.')[0]].next !== undefined) + (responseData[propertyName.split('.')[0]].next !== null && + responseData[propertyName.split('.')[0]].next !== undefined) ); return returnData; diff --git a/packages/nodes-base/nodes/Spotify/IsoCountryCodes.ts b/packages/nodes-base/nodes/Spotify/IsoCountryCodes.ts index 0358d866e1..53196c7a31 100644 --- a/packages/nodes-base/nodes/Spotify/IsoCountryCodes.ts +++ b/packages/nodes-base/nodes/Spotify/IsoCountryCodes.ts @@ -218,7 +218,7 @@ export const isoCountryCodes = [ alpha2: 'CR', }, { - name: 'Côte d\'Ivoire', + name: "Côte d'Ivoire", alpha2: 'CI', }, { @@ -470,7 +470,7 @@ export const isoCountryCodes = [ alpha2: 'KI', }, { - name: 'Korea (the Democratic People\'s Republic of)', + name: "Korea (the Democratic People's Republic of)", alpha2: 'KP', }, { @@ -486,7 +486,7 @@ export const isoCountryCodes = [ alpha2: 'KG', }, { - name: 'Lao People\'s Democratic Republic (the)', + name: "Lao People's Democratic Republic (the)", alpha2: 'LA', }, { diff --git a/packages/nodes-base/nodes/Spotify/Spotify.node.ts b/packages/nodes-base/nodes/Spotify/Spotify.node.ts index f4da105ccd..36be7c118b 100644 --- a/packages/nodes-base/nodes/Spotify/Spotify.node.ts +++ b/packages/nodes-base/nodes/Spotify/Spotify.node.ts @@ -1,22 +1,10 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - spotifyApiRequest, - spotifyApiRequestAllItems, -} from './GenericFunctions'; +import { spotifyApiRequest, spotifyApiRequestAllItems } from './GenericFunctions'; -import { - isoCountryCodes -} from './IsoCountryCodes'; +import { isoCountryCodes } from './IsoCountryCodes'; export class Spotify implements INodeType { description: INodeTypeDescription = { @@ -93,9 +81,7 @@ export class Spotify implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'player', - ], + resource: ['player'], }, }, options: [ @@ -164,12 +150,8 @@ export class Spotify implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'player', - ], - operation: [ - 'startMusic', - ], + resource: ['player'], + operation: ['startMusic'], }, }, placeholder: 'spotify:album:1YZ3k65Mqw3G8FzYlW1mmp', @@ -183,12 +165,8 @@ export class Spotify implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'player', - ], - operation: [ - 'addSongToQueue', - ], + resource: ['player'], + operation: ['addSongToQueue'], }, }, placeholder: 'spotify:track:0xE4LEFzSNGsz1F6kvXsHU', @@ -206,9 +184,7 @@ export class Spotify implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'album', - ], + resource: ['album'], }, }, options: [ @@ -227,8 +203,8 @@ export class Spotify implements INodeType { { name: `Get Tracks`, value: 'getTracks', - description: 'Get an album\'s tracks by URI or ID', - action: 'Get an album\'s tracks by URI or ID', + description: "Get an album's tracks by URI or ID", + action: "Get an album's tracks by URI or ID", }, { name: `Search`, @@ -247,22 +223,15 @@ export class Spotify implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'album', - ], - operation: [ - 'get', - 'getTracks', - ], + resource: ['album'], + operation: ['get', 'getTracks'], }, hide: { - operation: [ - 'search', - ], + operation: ['search'], }, }, placeholder: 'spotify:album:1YZ3k65Mqw3G8FzYlW1mmp', - description: 'The album\'s Spotify URI or ID', + description: "The album's Spotify URI or ID", }, { displayName: 'Search Keyword', @@ -273,12 +242,8 @@ export class Spotify implements INodeType { description: 'The keyword term to search for', displayOptions: { show: { - resource: [ - 'album', - ], - operation: [ - 'search', - ], + resource: ['album'], + operation: ['search'], }, }, }, @@ -294,9 +259,7 @@ export class Spotify implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'artist', - ], + resource: ['artist'], }, }, options: [ @@ -309,20 +272,20 @@ export class Spotify implements INodeType { { name: `Get Albums`, value: 'getAlbums', - description: 'Get an artist\'s albums by URI or ID', - action: 'Get an artist\'s albums by URI or ID', + description: "Get an artist's albums by URI or ID", + action: "Get an artist's albums by URI or ID", }, { name: `Get Related Artists`, value: 'getRelatedArtists', - description: 'Get an artist\'s related artists by URI or ID', - action: 'Get an artist\'s related artists by URI or ID', + description: "Get an artist's related artists by URI or ID", + action: "Get an artist's related artists by URI or ID", }, { name: `Get Top Tracks`, value: 'getTopTracks', - description: 'Get an artist\'s top tracks by URI or ID', - action: 'Get an artist\'s top tracks by URI or ID', + description: "Get an artist's top tracks by URI or ID", + action: "Get an artist's top tracks by URI or ID", }, { name: `Search`, @@ -341,18 +304,14 @@ export class Spotify implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'artist', - ], + resource: ['artist'], }, hide: { - operation: [ - 'search', - ], + operation: ['search'], }, }, placeholder: 'spotify:artist:4LLpKhyESsyAXpc4laK94U', - description: 'The artist\'s Spotify URI or ID', + description: "The artist's Spotify URI or ID", }, { displayName: 'Country', @@ -362,12 +321,8 @@ export class Spotify implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'artist', - ], - operation: [ - 'getTopTracks', - ], + resource: ['artist'], + operation: ['getTopTracks'], }, }, placeholder: 'US', @@ -383,12 +338,8 @@ export class Spotify implements INodeType { description: 'The keyword term to search for', displayOptions: { show: { - resource: [ - 'artist', - ], - operation: [ - 'search', - ], + resource: ['artist'], + operation: ['search'], }, }, }, @@ -404,9 +355,7 @@ export class Spotify implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'playlist', - ], + resource: ['playlist'], }, }, options: [ @@ -431,14 +380,14 @@ export class Spotify implements INodeType { { name: 'Get Tracks', value: 'getTracks', - description: 'Get a playlist\'s tracks by URI or ID', - action: 'Get a playlist\'s tracks by URI or ID', + description: "Get a playlist's tracks by URI or ID", + action: "Get a playlist's tracks by URI or ID", }, { name: `Get the User's Playlists`, value: 'getUserPlaylists', - description: 'Get a user\'s playlists', - action: 'Get a user\'s playlists', + description: "Get a user's playlists", + action: "Get a user's playlists", }, { name: 'Remove an Item', @@ -463,19 +412,12 @@ export class Spotify implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'playlist', - ], - operation: [ - 'add', - 'delete', - 'get', - 'getTracks', - ], + resource: ['playlist'], + operation: ['add', 'delete', 'get', 'getTracks'], }, }, placeholder: 'spotify:playlist:37i9dQZF1DWUhI3iC1khPH', - description: 'The playlist\'s Spotify URI or its ID', + description: "The playlist's Spotify URI or its ID", }, { displayName: 'Name', @@ -485,12 +427,8 @@ export class Spotify implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'playlist', - ], - operation: [ - 'create', - ], + resource: ['playlist'], + operation: ['create'], }, }, placeholder: 'Favorite Songs', @@ -504,12 +442,8 @@ export class Spotify implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'playlist', - ], - operation: [ - 'create', - ], + resource: ['playlist'], + operation: ['create'], }, }, options: [ @@ -538,17 +472,13 @@ export class Spotify implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'playlist', - ], - operation: [ - 'add', - 'delete', - ], + resource: ['playlist'], + operation: ['add', 'delete'], }, }, placeholder: 'spotify:track:0xE4LEFzSNGsz1F6kvXsHU', - description: 'The track\'s Spotify URI or its ID. The track to add/delete from the playlist.', + description: + "The track's Spotify URI or its ID. The track to add/delete from the playlist.", }, { displayName: 'Additional Fields', @@ -558,12 +488,8 @@ export class Spotify implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'playlist', - ], - operation: [ - 'add', - ], + resource: ['playlist'], + operation: ['add'], }, }, options: [ @@ -576,7 +502,7 @@ export class Spotify implements INodeType { }, default: 0, placeholder: '0', - description: 'The new track\'s position in the playlist', + description: "The new track's position in the playlist", }, ], }, @@ -589,12 +515,8 @@ export class Spotify implements INodeType { description: 'The keyword term to search for', displayOptions: { show: { - resource: [ - 'playlist', - ], - operation: [ - 'search', - ], + resource: ['playlist'], + operation: ['search'], }, }, }, @@ -610,9 +532,7 @@ export class Spotify implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'track', - ], + resource: ['track'], }, }, options: [ @@ -645,18 +565,14 @@ export class Spotify implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'track', - ], + resource: ['track'], }, hide: { - operation: [ - 'search', - ], + operation: ['search'], }, }, placeholder: 'spotify:track:0xE4LEFzSNGsz1F6kvXsHU', - description: 'The track\'s Spotify URI or ID', + description: "The track's Spotify URI or ID", }, { displayName: 'Search Keyword', @@ -667,12 +583,8 @@ export class Spotify implements INodeType { description: 'The keyword term to search for', displayOptions: { show: { - resource: [ - 'track', - ], - operation: [ - 'search', - ], + resource: ['track'], + operation: ['search'], }, }, }, @@ -688,16 +600,14 @@ export class Spotify implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'library', - ], + resource: ['library'], }, }, options: [ { name: 'Get Liked Tracks', value: 'getLikedTracks', - description: 'Get the user\'s liked tracks', + description: "Get the user's liked tracks", action: 'Get liked tracks', }, ], @@ -715,9 +625,7 @@ export class Spotify implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'myData', - ], + resource: ['myData'], }, }, options: [ @@ -738,15 +646,7 @@ export class Spotify implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'album', - 'artist', - 'library', - 'myData', - 'playlist', - 'track', - 'player', - ], + resource: ['album', 'artist', 'library', 'myData', 'playlist', 'track', 'player'], operation: [ 'getTracks', 'getAlbums', @@ -769,13 +669,7 @@ export class Spotify implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'album', - 'artist', - 'library', - 'playlist', - 'track', - ], + resource: ['album', 'artist', 'library', 'playlist', 'track'], operation: [ 'getTracks', 'getAlbums', @@ -784,9 +678,7 @@ export class Spotify implements INodeType { 'getLikedTracks', 'search', ], - returnAll: [ - false, - ], + returnAll: [false], }, }, typeOptions: { @@ -803,17 +695,9 @@ export class Spotify implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'myData', - 'player', - ], - operation: [ - 'getFollowingArtists', - 'recentlyPlayed', - ], - returnAll: [ - false, - ], + resource: ['myData', 'player'], + operation: ['getFollowingArtists', 'recentlyPlayed'], + returnAll: [false], }, }, typeOptions: { @@ -830,12 +714,8 @@ export class Spotify implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'player', - ], - operation: [ - 'volume', - ], + resource: ['player'], + operation: ['volume'], }, }, typeOptions: { @@ -852,12 +732,8 @@ export class Spotify implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'album', - ], - operation: [ - 'getNewReleases', - ], + resource: ['album'], + operation: ['getNewReleases'], }, }, options: [ @@ -879,15 +755,8 @@ export class Spotify implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'playlist', - 'artist', - 'track', - 'album', - ], - operation: [ - 'search', - ], + resource: ['playlist', 'artist', 'track', 'album'], + operation: ['search'], }, }, options: [ @@ -897,7 +766,8 @@ export class Spotify implements INodeType { type: 'options', options: isoCountryCodes.map(({ name, alpha2 }) => ({ name, value: alpha2 })), default: '', - description: 'If a country code is specified, only content that is playable in that market is returned', + description: + 'If a country code is specified, only content that is playable in that market is returned', }, ], }, @@ -933,7 +803,6 @@ export class Spotify implements INodeType { for (let i = 0; i < items.length; i++) { try { if (resource === 'player') { - // ----------------------------- // Player Operations // ----------------------------- @@ -943,11 +812,9 @@ export class Spotify implements INodeType { endpoint = `/me/player/pause`; - responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = { success: true }; - } else if (operation === 'recentlyPlayed') { requestMethod = 'GET'; @@ -958,7 +825,6 @@ export class Spotify implements INodeType { propertyName = 'items'; if (!returnAll) { - const limit = this.getNodeParameter('limit', i) as number; qs = { @@ -969,14 +835,12 @@ export class Spotify implements INodeType { responseData = responseData.items; } - } else if (operation === 'currentlyPlaying') { requestMethod = 'GET'; endpoint = `/me/player/currently-playing`; responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); - } else if (operation === 'nextSong') { requestMethod = 'POST'; @@ -985,7 +849,6 @@ export class Spotify implements INodeType { responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = { success: true }; - } else if (operation === 'previousSong') { requestMethod = 'POST'; @@ -994,7 +857,6 @@ export class Spotify implements INodeType { responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = { success: true }; - } else if (operation === 'startMusic') { requestMethod = 'PUT'; @@ -1007,7 +869,6 @@ export class Spotify implements INodeType { responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = { success: true }; - } else if (operation === 'addSongToQueue') { requestMethod = 'POST'; @@ -1045,9 +906,7 @@ export class Spotify implements INodeType { responseData = { success: true }; } - } else if (resource === 'album') { - // ----------------------------- // Album Operations // ----------------------------- @@ -1062,9 +921,7 @@ export class Spotify implements INodeType { endpoint = `/albums/${id}`; responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); - } else if (operation === 'getNewReleases') { - endpoint = '/browse/new-releases'; requestMethod = 'GET'; propertyName = 'albums.items'; @@ -1082,7 +939,6 @@ export class Spotify implements INodeType { responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = responseData.albums.items; } - } else if (operation === 'getTracks') { const uri = this.getNodeParameter('id', i) as string; @@ -1133,9 +989,7 @@ export class Spotify implements INodeType { responseData = responseData.albums.items; } } - } else if (resource === 'artist') { - // ----------------------------- // Artist Operations // ----------------------------- @@ -1145,7 +999,6 @@ export class Spotify implements INodeType { const id = uri.replace('spotify:artist:', ''); if (operation === 'getAlbums') { - endpoint = `/artists/${id}/albums`; returnAll = this.getNodeParameter('returnAll', i) as boolean; @@ -1163,15 +1016,12 @@ export class Spotify implements INodeType { responseData = responseData.items; } - } else if (operation === 'getRelatedArtists') { - endpoint = `/artists/${id}/related-artists`; responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = responseData.artists; - } else if (operation === 'getTopTracks') { const country = this.getNodeParameter('country', i) as string; @@ -1184,9 +1034,7 @@ export class Spotify implements INodeType { responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = responseData.tracks; - } else if (operation === 'get') { - requestMethod = 'GET'; endpoint = `/artists/${id}`; @@ -1217,9 +1065,7 @@ export class Spotify implements INodeType { responseData = responseData.artists.items; } } - } else if (resource === 'playlist') { - // ----------------------------- // Playlist Operations // ----------------------------- @@ -1244,14 +1090,12 @@ export class Spotify implements INodeType { responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = { success: true }; - } else if (operation === 'get') { requestMethod = 'GET'; endpoint = `/playlists/${id}`; responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); - } else if (operation === 'getTracks') { requestMethod = 'GET'; @@ -1265,10 +1109,16 @@ export class Spotify implements INodeType { const limit = this.getNodeParameter('limit', i) as number; qs = { - 'limit': limit, + limit, }; - responseData = await spotifyApiRequest.call(this, requestMethod, endpoint, body, qs); + responseData = await spotifyApiRequest.call( + this, + requestMethod, + endpoint, + body, + qs, + ); responseData = responseData.items; } @@ -1310,9 +1160,7 @@ export class Spotify implements INodeType { responseData = responseData.items; } - } else if (operation === 'create') { - // https://developer.spotify.com/console/post-playlists/ body.name = this.getNodeParameter('name', i) as string; @@ -1349,9 +1197,7 @@ export class Spotify implements INodeType { responseData = responseData.playlists.items; } } - } else if (resource === 'track') { - // ----------------------------- // Track Operations // ----------------------------- @@ -1393,9 +1239,7 @@ export class Spotify implements INodeType { responseData = responseData.tracks.items; } } - } else if (resource === 'library') { - // ----------------------------- // Library Operations // ----------------------------- @@ -1422,7 +1266,6 @@ export class Spotify implements INodeType { } } } else if (resource === 'myData') { - if (operation === 'getFollowingArtists') { requestMethod = 'GET'; @@ -1449,7 +1292,14 @@ export class Spotify implements INodeType { } if (returnAll) { - responseData = await spotifyApiRequestAllItems.call(this, propertyName, requestMethod, endpoint, body, qs); + responseData = await spotifyApiRequestAllItems.call( + this, + propertyName, + requestMethod, + endpoint, + body, + qs, + ); } if (Array.isArray(responseData)) { @@ -1469,11 +1319,3 @@ export class Spotify implements INodeType { return [this.helpers.returnJsonArray(returnData)]; } } - - - - - - - - diff --git a/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts b/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts index 9470e64413..cbdec3116c 100644 --- a/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts +++ b/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts @@ -18,7 +18,6 @@ import { WritingOptions, } from 'xlsx'; - /** * Flattens an object with deep data * @@ -28,7 +27,7 @@ import { function flattenObject(data: IDataObject) { const returnData: IDataObject = {}; for (const key1 of Object.keys(data)) { - if (data[key1] !== null && (typeof data[key1]) === 'object') { + if (data[key1] !== null && typeof data[key1] === 'object') { if (data[key1] instanceof Date) { returnData[key1] = data[key1]?.toString(); continue; @@ -47,7 +46,6 @@ function flattenObject(data: IDataObject) { return returnData; } - export class SpreadsheetFile implements INodeType { description: INodeTypeDescription = { displayName: 'Spreadsheet File', @@ -96,14 +94,12 @@ export class SpreadsheetFile implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'fromFile', - ], + operation: ['fromFile'], }, - }, placeholder: '', - description: 'Name of the binary property from which to read the binary data of the spreadsheet file', + description: + 'Name of the binary property from which to read the binary data of the spreadsheet file', }, // ---------------------------------- @@ -148,9 +144,7 @@ export class SpreadsheetFile implements INodeType { default: 'xls', displayOptions: { show: { - operation: [ - 'toFile', - ], + operation: ['toFile'], }, }, description: 'The format of the file to save the data as', @@ -163,13 +157,12 @@ export class SpreadsheetFile implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'toFile', - ], + operation: ['toFile'], }, }, placeholder: '', - description: 'Name of the binary property in which to save the binary data of the spreadsheet file', + description: + 'Name of the binary property in which to save the binary data of the spreadsheet file', }, { @@ -185,13 +178,8 @@ export class SpreadsheetFile implements INodeType { type: 'boolean', displayOptions: { show: { - '/operation': [ - 'toFile', - ], - '/fileFormat': [ - 'xlsx', - 'ods', - ], + '/operation': ['toFile'], + '/fileFormat': ['xlsx', 'ods'], }, }, default: false, @@ -203,13 +191,12 @@ export class SpreadsheetFile implements INodeType { type: 'string', displayOptions: { show: { - '/operation': [ - 'toFile', - ], + '/operation': ['toFile'], }, }, default: '', - description: 'File name to set in binary data. By default will "spreadsheet.<fileFormat>" be used.', + description: + 'File name to set in binary data. By default will "spreadsheet.<fileFormat>" be used.', }, { displayName: 'Header Row', @@ -217,10 +204,7 @@ export class SpreadsheetFile implements INodeType { type: 'boolean', displayOptions: { show: { - '/operation': [ - 'fromFile', - 'toFile', - ], + '/operation': ['fromFile', 'toFile'], }, }, default: true, @@ -232,14 +216,13 @@ export class SpreadsheetFile implements INodeType { type: 'boolean', displayOptions: { show: { - '/operation': [ - 'fromFile', - ], + '/operation': ['fromFile'], }, }, default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'When reading from file the empty cells will be filled with an empty string in the JSON', + description: + 'When reading from file the empty cells will be filled with an empty string in the JSON', }, { displayName: 'RAW Data', @@ -247,9 +230,7 @@ export class SpreadsheetFile implements INodeType { type: 'boolean', displayOptions: { show: { - '/operation': [ - 'fromFile', - ], + '/operation': ['fromFile'], }, }, default: false, @@ -261,14 +242,13 @@ export class SpreadsheetFile implements INodeType { type: 'boolean', displayOptions: { show: { - '/operation': [ - 'fromFile', - ], + '/operation': ['fromFile'], }, }, default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'In some cases and file formats, it is necessary to read specifically as string else some special character get interpreted wrong', + description: + 'In some cases and file formats, it is necessary to read specifically as string else some special character get interpreted wrong', }, { displayName: 'Range', @@ -276,13 +256,12 @@ export class SpreadsheetFile implements INodeType { type: 'string', displayOptions: { show: { - '/operation': [ - 'fromFile', - ], + '/operation': ['fromFile'], }, }, default: '', - description: 'The range to read from the table. If set to a number it will be the starting row. If set to string it will be used as A1-style bounded range.', + description: + 'The range to read from the table. If set to a number it will be the starting row. If set to string it will be used as A1-style bounded range.', }, { displayName: 'Sheet Name', @@ -290,13 +269,12 @@ export class SpreadsheetFile implements INodeType { type: 'string', displayOptions: { show: { - '/operation': [ - 'fromFile', - ], + '/operation': ['fromFile'], }, }, default: 'Sheet', - description: 'Name of the sheet to read from in the spreadsheet (if supported). If not set, the first one gets chosen.', + description: + 'Name of the sheet to read from in the spreadsheet (if supported). If not set, the first one gets chosen.', }, { displayName: 'Sheet Name', @@ -304,14 +282,8 @@ export class SpreadsheetFile implements INodeType { type: 'string', displayOptions: { show: { - '/operation': [ - 'toFile', - ], - '/fileFormat': [ - 'ods', - 'xls', - 'xlsx', - ], + '/operation': ['toFile'], + '/fileFormat': ['ods', 'xls', 'xlsx'], }, }, default: 'Sheet', @@ -322,9 +294,7 @@ export class SpreadsheetFile implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); const operation = this.getNodeParameter('operation', 0) as string; @@ -336,8 +306,7 @@ export class SpreadsheetFile implements INodeType { let item: INodeExecutionData; for (let i = 0; i < items.length; i++) { - try{ - + try { item = items[i]; const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; @@ -352,19 +321,28 @@ export class SpreadsheetFile implements INodeType { const binaryData = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); let workbook; if (options.readAsString === true) { - workbook = xlsxRead(binaryData.toString(), { type: 'string', raw: options.rawData as boolean }); + workbook = xlsxRead(binaryData.toString(), { + type: 'string', + raw: options.rawData as boolean, + }); } else { workbook = xlsxRead(binaryData, { raw: options.rawData as boolean }); } if (workbook.SheetNames.length === 0) { - throw new NodeOperationError(this.getNode(), 'Spreadsheet does not have any sheets!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Spreadsheet does not have any sheets!', { + itemIndex: i, + }); } let sheetName = workbook.SheetNames[0]; if (options.sheetName) { if (!workbook.SheetNames.includes(options.sheetName as string)) { - throw new NodeOperationError(this.getNode(), `Spreadsheet does not contain sheet called "${options.sheetName}"!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Spreadsheet does not contain sheet called "${options.sheetName}"!`, + { itemIndex: i }, + ); } sheetName = options.sheetName as string; } @@ -416,7 +394,6 @@ export class SpreadsheetFile implements INodeType { } as INodeExecutionData); } } - } catch (error) { if (this.continueOnFail()) { newItems.push({ @@ -436,7 +413,6 @@ export class SpreadsheetFile implements INodeType { return this.prepareOutputData(newItems); } else if (operation === 'toFile') { try { - // Write the workflow data to spreadsheet file const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string; const fileFormat = this.getNodeParameter('fileFormat', 0) as string; @@ -481,7 +457,7 @@ export class SpreadsheetFile implements INodeType { } // Convert the data in the correct format - const sheetName = options.sheetName as string || 'Sheet'; + const sheetName = (options.sheetName as string) || 'Sheet'; const wb: WorkBook = { SheetNames: [sheetName], Sheets: { @@ -523,9 +499,14 @@ export class SpreadsheetFile implements INodeType { } } else { if (this.continueOnFail()) { - return this.prepareOutputData([{json:{ error: `The operation "${operation}" is not supported!` }}]); - }else{ - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`); + return this.prepareOutputData([ + { json: { error: `The operation "${operation}" is not supported!` } }, + ]); + } else { + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not supported!`, + ); } } return this.prepareOutputData(newItems); diff --git a/packages/nodes-base/nodes/SseTrigger/SseTrigger.node.ts b/packages/nodes-base/nodes/SseTrigger/SseTrigger.node.ts index cc8a178c83..c8995d89ef 100644 --- a/packages/nodes-base/nodes/SseTrigger/SseTrigger.node.ts +++ b/packages/nodes-base/nodes/SseTrigger/SseTrigger.node.ts @@ -1,11 +1,6 @@ import EventSource from 'eventsource'; import { ITriggerFunctions } from 'n8n-core'; -import { - INodeType, - INodeTypeDescription, - ITriggerResponse, -} from 'n8n-workflow'; - +import { INodeType, INodeTypeDescription, ITriggerResponse } from 'n8n-workflow'; export class SseTrigger implements INodeType { description: INodeTypeDescription = { @@ -36,7 +31,6 @@ export class SseTrigger implements INodeType { ], }; - async trigger(this: ITriggerFunctions): Promise { const url = this.getNodeParameter('url') as string; @@ -54,6 +48,5 @@ export class SseTrigger implements INodeType { return { closeFunction, }; - } } diff --git a/packages/nodes-base/nodes/Ssh/Ssh.node.ts b/packages/nodes-base/nodes/Ssh/Ssh.node.ts index 6d690367f3..4d112e17e4 100644 --- a/packages/nodes-base/nodes/Ssh/Ssh.node.ts +++ b/packages/nodes-base/nodes/Ssh/Ssh.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryData, @@ -11,11 +9,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - readFile, - rm, - writeFile, -} from 'fs/promises'; +import { readFile, rm, writeFile } from 'fs/promises'; import { file } from 'tmp-promise'; @@ -42,9 +36,7 @@ export class Ssh implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'password', - ], + authentication: ['password'], }, }, }, @@ -53,9 +45,7 @@ export class Ssh implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'privateKey', - ], + authentication: ['privateKey'], }, }, }, @@ -101,9 +91,7 @@ export class Ssh implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'command', - ], + resource: ['command'], }, }, options: [ @@ -122,12 +110,8 @@ export class Ssh implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'command', - ], - operation: [ - 'execute', - ], + resource: ['command'], + operation: ['execute'], }, }, default: '', @@ -139,12 +123,8 @@ export class Ssh implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'command', - ], - operation: [ - 'execute', - ], + resource: ['command'], + operation: ['execute'], }, }, default: '/', @@ -157,9 +137,7 @@ export class Ssh implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'file', - ], + resource: ['file'], }, }, options: [ @@ -186,16 +164,13 @@ export class Ssh implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, placeholder: '', - description: 'Name of the binary property which contains the data for the file to be uploaded', + description: + 'Name of the binary property which contains the data for the file to be uploaded', }, { displayName: 'Target Directory', @@ -203,48 +178,38 @@ export class Ssh implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'upload', - ], + resource: ['file'], + operation: ['upload'], }, }, default: '', required: true, placeholder: '/home/user', - description: 'The directory to upload the file to. The name of the file does not need to be specified, it\'s taken from the binary data file name. To override this behavior, set the parameter "File Name" under options.', + description: + 'The directory to upload the file to. The name of the file does not need to be specified, it\'s taken from the binary data file name. To override this behavior, set the parameter "File Name" under options.', }, { displayName: 'Path', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'download', - ], + resource: ['file'], + operation: ['download'], }, }, name: 'path', type: 'string', default: '', placeholder: '/home/user/invoice.txt', - description: 'The file path of the file to download. Has to contain the full path including file name.', + description: + 'The file path of the file to download. Has to contain the full path including file name.', required: true, }, { displayName: 'Binary Property', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'download', - ], + resource: ['file'], + operation: ['download'], }, }, name: 'binaryPropertyName', @@ -260,12 +225,8 @@ export class Ssh implements INodeType { placeholder: 'Add Option', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'upload', - ], + resource: ['file'], + operation: ['upload'], }, }, default: {}, @@ -297,7 +258,6 @@ export class Ssh implements INodeType { try { if (authentication === 'password') { - const credentials = await this.getCredentials('sshPassword'); await ssh.connect({ @@ -306,12 +266,10 @@ export class Ssh implements INodeType { port: credentials.port as number, password: credentials.password as string, }); - } else if (authentication === 'privateKey') { - const credentials = await this.getCredentials('sshPrivateKey'); - const { path, } = await file({ prefix: 'n8n-ssh-' }); + const { path } = await file({ prefix: 'n8n-ssh-' }); temporaryFiles.push(path); await writeFile(path, credentials.privateKey as string); @@ -332,13 +290,11 @@ export class Ssh implements INodeType { for (let i = 0; i < items.length; i++) { try { if (resource === 'command') { - if (operation === 'execute') { - const command = this.getNodeParameter('command', i) as string; const cwd = this.getNodeParameter('cwd', i) as string; returnItems.push({ - json: await ssh.execCommand(command, { cwd, }), + json: await ssh.execCommand(command, { cwd }), pairedItem: { item: i, }, @@ -347,10 +303,11 @@ export class Ssh implements INodeType { } if (resource === 'file') { - if (operation === 'download') { - - const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string; + const dataPropertyNameDownload = this.getNodeParameter( + 'binaryPropertyName', + i, + ) as string; const parameterPath = this.getNodeParameter('path', i) as string; const { path } = await file({ prefix: 'n8n-ssh-' }); @@ -377,18 +334,22 @@ export class Ssh implements INodeType { const data = await readFile(path as string); - items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data, parameterPath); + items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( + data, + parameterPath, + ); } if (operation === 'upload') { - const parameterPath = this.getNodeParameter('path', i) as string; const fileName = this.getNodeParameter('options.fileName', i, '') as string; const item = items[i]; if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string; @@ -396,7 +357,11 @@ export class Ssh implements INodeType { const binaryData = item.binary[propertyNameUpload] as IBinaryData; if (item.binary[propertyNameUpload] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${propertyNameUpload}" does not exists on item!`, + { itemIndex: i }, + ); } const dataBuffer = await this.helpers.getBinaryDataBuffer(i, propertyNameUpload); @@ -405,7 +370,12 @@ export class Ssh implements INodeType { temporaryFiles.push(path); await writeFile(path, dataBuffer); - await ssh.putFile(path, `${parameterPath}${(parameterPath.charAt(parameterPath.length - 1) === '/') ? '' : '/'}${fileName || binaryData.fileName}`); + await ssh.putFile( + path, + `${parameterPath}${ + parameterPath.charAt(parameterPath.length - 1) === '/' ? '' : '/' + }${fileName || binaryData.fileName}`, + ); returnItems.push({ json: { diff --git a/packages/nodes-base/nodes/Stackby/GenericFunction.ts b/packages/nodes-base/nodes/Stackby/GenericFunction.ts index 10611d6b2b..2e50e99b3f 100644 --- a/packages/nodes-base/nodes/Stackby/GenericFunction.ts +++ b/packages/nodes-base/nodes/Stackby/GenericFunction.ts @@ -1,18 +1,8 @@ -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IDataObject, - IPollFunctions, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, IPollFunctions, NodeApiError } from 'n8n-workflow'; /** * Make an API request to Airtable @@ -23,7 +13,16 @@ import { * @param {object} body * @returns {Promise} */ -export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function apiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, + method: string, + endpoint: string, + body: IDataObject, + query?: IDataObject, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('stackbyApi'); const options: OptionsWithUri = { @@ -48,7 +47,6 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa try { return await this.helpers.request!(options); - } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -66,8 +64,14 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa * @param {IDataObject} [query] * @returns {Promise} */ -export async function apiRequestAllItems(this: IHookFunctions | IExecuteFunctions | IPollFunctions, method: string, endpoint: string, body: IDataObject = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function apiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | IPollFunctions, + method: string, + endpoint: string, + body: IDataObject = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { query.maxrecord = 100; query.offset = 0; @@ -80,17 +84,13 @@ export async function apiRequestAllItems(this: IHookFunctions | IExecuteFunction responseData = await apiRequest.call(this, method, endpoint, body, query); returnData.push.apply(returnData, responseData); query.offset += query.maxrecord; - - } while ( - responseData.length !== 0 - ); + } while (responseData.length !== 0); return returnData; } export interface IRecord { field: { - [key: string]: string + [key: string]: string; }; } - diff --git a/packages/nodes-base/nodes/Stackby/Stackby.node.ts b/packages/nodes-base/nodes/Stackby/Stackby.node.ts index 45ddcfd877..8116682f5d 100644 --- a/packages/nodes-base/nodes/Stackby/Stackby.node.ts +++ b/packages/nodes-base/nodes/Stackby/Stackby.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,11 +8,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - apiRequest, - apiRequestAllItems, - IRecord, -} from './GenericFunction'; +import { apiRequest, apiRequestAllItems, IRecord } from './GenericFunction'; export class Stackby implements INodeType { description: INodeTypeDescription = { @@ -93,10 +87,7 @@ export class Stackby implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'read', - 'delete', - ], + operation: ['read', 'delete'], }, }, default: '', @@ -113,9 +104,7 @@ export class Stackby implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'list', - ], + operation: ['list'], }, }, default: true, @@ -127,12 +116,8 @@ export class Stackby implements INodeType { type: 'number', displayOptions: { show: { - 'operation': [ - 'list', - ], - 'returnAll': [ - false, - ], + operation: ['list'], + returnAll: [false], }, }, typeOptions: { @@ -148,9 +133,7 @@ export class Stackby implements INodeType { type: 'collection', displayOptions: { show: { - operation: [ - 'list', - ], + operation: ['list'], }, }, default: {}, @@ -162,7 +145,8 @@ export class Stackby implements INodeType { type: 'string', default: '', placeholder: 'All Stories', - description: 'The name or ID of a view in the Stories table. If set, only the records in that view will be returned. The records will be sorted according to the order of the view.', + description: + 'The name or ID of a view in the Stories table. If set, only the records in that view will be returned. The records will be sorted according to the order of the view.', }, ], }, @@ -175,15 +159,14 @@ export class Stackby implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'append', - ], + operation: ['append'], }, }, default: '', required: true, placeholder: 'id,name,description', - description: 'Comma-separated list of the properties which should used as columns for the new rows', + description: + 'Comma-separated list of the properties which should used as columns for the new rows', }, ], }; @@ -203,8 +186,11 @@ export class Stackby implements INodeType { const rowIds = this.getNodeParameter('id', i) as string; qs.rowIds = [rowIds]; responseData = await apiRequest.call(this, 'GET', `/rowlist/${stackId}/${table}`, {}, qs); - // tslint:disable-next-line: no-any - returnData.push.apply(returnData, responseData.map((data: any) => data.field)); + returnData.push.apply( + returnData, + // tslint:disable-next-line:no-any + responseData.map((data: any) => data.field), + ); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -222,7 +208,13 @@ export class Stackby implements INodeType { const rowIds = this.getNodeParameter('id', i) as string; qs.rowIds = [rowIds]; - responseData = await apiRequest.call(this, 'DELETE', `/rowdelete/${stackId}/${table}`, {}, qs); + responseData = await apiRequest.call( + this, + 'DELETE', + `/rowdelete/${stackId}/${table}`, + {}, + qs, + ); responseData = responseData.records; returnData.push.apply(returnData, responseData); } catch (error) { @@ -243,13 +235,17 @@ export class Stackby implements INodeType { const stackId = this.getNodeParameter('stackId', i) as string; const table = encodeURI(this.getNodeParameter('table', i) as string); const columns = this.getNodeParameter('columns', i) as string; - const columnList = columns.split(',').map(column => column.trim()); + const columnList = columns.split(',').map((column) => column.trim()); // tslint:disable-next-line: no-any const record: { [key: string]: any } = {}; for (const column of columnList) { if (items[i].json[column] === undefined) { - throw new NodeOperationError(this.getNode(), `Column ${column} does not exist on input`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Column ${column} does not exist on input`, + { itemIndex: i }, + ); } else { record[column] = items[i].json[column]; } @@ -263,11 +259,16 @@ export class Stackby implements INodeType { } for (const key of Object.keys(records)) { - responseData = await apiRequest.call(this, 'POST', `/rowcreate/${key}`, { records: records[key] }); + responseData = await apiRequest.call(this, 'POST', `/rowcreate/${key}`, { + records: records[key], + }); } - // tslint:disable-next-line: no-any - returnData.push.apply(returnData, responseData.map((data: any) => data.field)); + returnData.push.apply( + returnData, + // tslint:disable-next-line:no-any + responseData.map((data: any) => data.field), + ); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -291,14 +292,29 @@ export class Stackby implements INodeType { } if (returnAll === true) { - responseData = await apiRequestAllItems.call(this, 'GET', `/rowlist/${stackId}/${table}`, {}, qs); + responseData = await apiRequestAllItems.call( + this, + 'GET', + `/rowlist/${stackId}/${table}`, + {}, + qs, + ); } else { qs.maxrecord = this.getNodeParameter('limit', 0) as number; - responseData = await apiRequest.call(this, 'GET', `/rowlist/${stackId}/${table}`, {}, qs); + responseData = await apiRequest.call( + this, + 'GET', + `/rowlist/${stackId}/${table}`, + {}, + qs, + ); } - // tslint:disable-next-line: no-any - returnData.push.apply(returnData, responseData.map((data: any) => data.field)); + returnData.push.apply( + returnData, + // tslint:disable-next-line:no-any + responseData.map((data: any) => data.field), + ); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/Start/Start.node.ts b/packages/nodes-base/nodes/Start/Start.node.ts index 4da18077b1..ba1924178b 100644 --- a/packages/nodes-base/nodes/Start/Start.node.ts +++ b/packages/nodes-base/nodes/Start/Start.node.ts @@ -1,10 +1,5 @@ import { IExecuteFunctions } from 'n8n-core'; -import { - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; - +import { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; export class Start implements INodeType { description: INodeTypeDescription = { @@ -24,7 +19,8 @@ export class Start implements INodeType { outputs: ['main'], properties: [ { - displayName: 'This node is where a manual workflow execution starts. To make one, go back to the canvas and click ‘execute workflow’', + displayName: + 'This node is where a manual workflow execution starts. To make one, go back to the canvas and click ‘execute workflow’', name: 'notice', type: 'notice', default: '', diff --git a/packages/nodes-base/nodes/StickyNote/StickyNote.node.ts b/packages/nodes-base/nodes/StickyNote/StickyNote.node.ts index 533e54a018..32d0140805 100644 --- a/packages/nodes-base/nodes/StickyNote/StickyNote.node.ts +++ b/packages/nodes-base/nodes/StickyNote/StickyNote.node.ts @@ -1,10 +1,5 @@ import { IExecuteFunctions } from 'n8n-core'; -import { - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; - +import { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; export class StickyNote implements INodeType { description: INodeTypeDescription = { diff --git a/packages/nodes-base/nodes/StopAndError/StopAndError.node.ts b/packages/nodes-base/nodes/StopAndError/StopAndError.node.ts index f8bdc47856..68cfbb1acf 100644 --- a/packages/nodes-base/nodes/StopAndError/StopAndError.node.ts +++ b/packages/nodes-base/nodes/StopAndError/StopAndError.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { INodeExecutionData, @@ -59,9 +57,7 @@ export class StopAndError implements INodeType { required: true, displayOptions: { show: { - errorType: [ - 'errorMessage', - ], + errorType: ['errorMessage'], }, }, }, @@ -78,9 +74,7 @@ export class StopAndError implements INodeType { required: true, displayOptions: { show: { - errorType: [ - 'errorObject', - ], + errorType: ['errorObject'], }, }, }, diff --git a/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts b/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts index ed3ff7ff63..6956bac2c8 100644 --- a/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,11 +7,18 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function storyblokApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function storyblokApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('source', 0) as string; let options: OptionsWithUri = { @@ -44,7 +49,7 @@ export async function storyblokApiRequest(this: IHookFunctions | IExecuteFunctio options.uri = `https://mapi.storyblok.com${resource}`; - Object.assign(options.headers, { 'Authorization': credentials.accessToken }); + Object.assign(options.headers, { Authorization: credentials.accessToken }); } try { @@ -54,7 +59,16 @@ export async function storyblokApiRequest(this: IHookFunctions | IExecuteFunctio } } -export async function storyblokApiRequestAllItems(this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function storyblokApiRequestAllItems( + this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, + propertyName: string, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -67,14 +81,13 @@ export async function storyblokApiRequestAllItems(this: IHookFunctions | ILoadOp responseData = await storyblokApiRequest.call(this, method, resource, body, query); query.page++; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData[propertyName].length !== 0 - ); + } while (responseData[propertyName].length !== 0); return returnData; } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); diff --git a/packages/nodes-base/nodes/Storyblok/StoryContentDescription.ts b/packages/nodes-base/nodes/Storyblok/StoryContentDescription.ts index ebfd1db4d0..688e2e2e9c 100644 --- a/packages/nodes-base/nodes/Storyblok/StoryContentDescription.ts +++ b/packages/nodes-base/nodes/Storyblok/StoryContentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const storyContentOperations: INodeProperties[] = [ { @@ -10,12 +8,8 @@ export const storyContentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - source: [ - 'contentApi', - ], - resource: [ - 'story', - ], + source: ['contentApi'], + resource: ['story'], }, }, options: [ @@ -37,7 +31,6 @@ export const storyContentOperations: INodeProperties[] = [ ]; export const storyContentFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* story:get */ /* -------------------------------------------------------------------------- */ @@ -49,15 +42,9 @@ export const storyContentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'contentApi', - ], - resource: [ - 'story', - ], - operation: [ - 'get', - ], + source: ['contentApi'], + resource: ['story'], + operation: ['get'], }, }, description: 'The ID or slug of the story to get', @@ -72,15 +59,9 @@ export const storyContentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - source: [ - 'contentApi', - ], - resource: [ - 'story', - ], - operation: [ - 'getAll', - ], + source: ['contentApi'], + resource: ['story'], + operation: ['getAll'], }, }, default: false, @@ -92,18 +73,10 @@ export const storyContentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - source: [ - 'contentApi', - ], - resource: [ - 'story', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + source: ['contentApi'], + resource: ['story'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -121,15 +94,9 @@ export const storyContentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - source: [ - 'contentApi', - ], - resource: [ - 'story', - ], - operation: [ - 'getAll', - ], + source: ['contentApi'], + resource: ['story'], + operation: ['getAll'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Storyblok/StoryManagementDescription.ts b/packages/nodes-base/nodes/Storyblok/StoryManagementDescription.ts index bfacb7d790..487d79ffae 100644 --- a/packages/nodes-base/nodes/Storyblok/StoryManagementDescription.ts +++ b/packages/nodes-base/nodes/Storyblok/StoryManagementDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const storyManagementOperations: INodeProperties[] = [ { @@ -10,12 +8,8 @@ export const storyManagementOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - source: [ - 'managementApi', - ], - resource: [ - 'story', - ], + source: ['managementApi'], + resource: ['story'], }, }, options: [ @@ -60,7 +54,6 @@ export const storyManagementOperations: INodeProperties[] = [ ]; export const storyManagementFields: INodeProperties[] = [ - // /* -------------------------------------------------------------------------- */ // /* story:create */ // /* -------------------------------------------------------------------------- */ @@ -328,18 +321,13 @@ export const storyManagementFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'managementApi', - ], - resource: [ - 'story', - ], - operation: [ - 'delete', - ], + source: ['managementApi'], + resource: ['story'], + operation: ['delete'], }, }, - description: 'The name of the space. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the space. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Story ID', @@ -349,15 +337,9 @@ export const storyManagementFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'managementApi', - ], - resource: [ - 'story', - ], - operation: [ - 'delete', - ], + source: ['managementApi'], + resource: ['story'], + operation: ['delete'], }, }, description: 'Numeric ID of the story', @@ -377,18 +359,13 @@ export const storyManagementFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'managementApi', - ], - resource: [ - 'story', - ], - operation: [ - 'get', - ], + source: ['managementApi'], + resource: ['story'], + operation: ['get'], }, }, - description: 'The name of the space. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the space. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Story ID', @@ -398,15 +375,9 @@ export const storyManagementFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'managementApi', - ], - resource: [ - 'story', - ], - operation: [ - 'get', - ], + source: ['managementApi'], + resource: ['story'], + operation: ['get'], }, }, description: 'Numeric ID of the story', @@ -426,18 +397,13 @@ export const storyManagementFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'managementApi', - ], - resource: [ - 'story', - ], - operation: [ - 'getAll', - ], + source: ['managementApi'], + resource: ['story'], + operation: ['getAll'], }, }, - description: 'The name of the space. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the space. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -445,15 +411,9 @@ export const storyManagementFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - source: [ - 'managementApi', - ], - resource: [ - 'story', - ], - operation: [ - 'getAll', - ], + source: ['managementApi'], + resource: ['story'], + operation: ['getAll'], }, }, default: false, @@ -465,18 +425,10 @@ export const storyManagementFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - source: [ - 'managementApi', - ], - resource: [ - 'story', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + source: ['managementApi'], + resource: ['story'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -494,15 +446,9 @@ export const storyManagementFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - source: [ - 'managementApi', - ], - resource: [ - 'story', - ], - operation: [ - 'getAll', - ], + source: ['managementApi'], + resource: ['story'], + operation: ['getAll'], }, }, options: [ @@ -530,18 +476,13 @@ export const storyManagementFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'managementApi', - ], - resource: [ - 'story', - ], - operation: [ - 'publish', - ], + source: ['managementApi'], + resource: ['story'], + operation: ['publish'], }, }, - description: 'The name of the space. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the space. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Story ID', @@ -551,15 +492,9 @@ export const storyManagementFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'managementApi', - ], - resource: [ - 'story', - ], - operation: [ - 'publish', - ], + source: ['managementApi'], + resource: ['story'], + operation: ['publish'], }, }, description: 'Numeric ID of the story', @@ -571,15 +506,9 @@ export const storyManagementFields: INodeProperties[] = [ placeholder: 'Add Option', displayOptions: { show: { - source: [ - 'managementApi', - ], - resource: [ - 'story', - ], - operation: [ - 'publish', - ], + source: ['managementApi'], + resource: ['story'], + operation: ['publish'], }, }, default: {}, @@ -596,7 +525,8 @@ export const storyManagementFields: INodeProperties[] = [ name: 'language', type: 'string', default: '', - description: 'Language code to publish the story individually (must be enabled in the space settings)', + description: + 'Language code to publish the story individually (must be enabled in the space settings)', }, ], }, @@ -615,18 +545,13 @@ export const storyManagementFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'managementApi', - ], - resource: [ - 'story', - ], - operation: [ - 'unpublish', - ], + source: ['managementApi'], + resource: ['story'], + operation: ['unpublish'], }, }, - description: 'The name of the space. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the space. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Story ID', @@ -636,15 +561,9 @@ export const storyManagementFields: INodeProperties[] = [ required: true, displayOptions: { show: { - source: [ - 'managementApi', - ], - resource: [ - 'story', - ], - operation: [ - 'unpublish', - ], + source: ['managementApi'], + resource: ['story'], + operation: ['unpublish'], }, }, description: 'Numeric ID of the story', diff --git a/packages/nodes-base/nodes/Storyblok/Storyblok.node.ts b/packages/nodes-base/nodes/Storyblok/Storyblok.node.ts index ed8994537f..06cba1cfed 100644 --- a/packages/nodes-base/nodes/Storyblok/Storyblok.node.ts +++ b/packages/nodes-base/nodes/Storyblok/Storyblok.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,21 +9,11 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - storyblokApiRequest, - storyblokApiRequestAllItems, - validateJSON, -} from './GenericFunctions'; +import { storyblokApiRequest, storyblokApiRequestAllItems, validateJSON } from './GenericFunctions'; -import { - storyContentFields, - storyContentOperations, -} from './StoryContentDescription'; +import { storyContentFields, storyContentOperations } from './StoryContentDescription'; -import { - storyManagementFields, - storyManagementOperations, -} from './StoryManagementDescription'; +import { storyManagementFields, storyManagementOperations } from './StoryManagementDescription'; import { v4 as uuidv4 } from 'uuid'; @@ -49,9 +37,7 @@ export class Storyblok implements INodeType { required: true, displayOptions: { show: { - source: [ - 'contentApi', - ], + source: ['contentApi'], }, }, }, @@ -60,9 +46,7 @@ export class Storyblok implements INodeType { required: true, displayOptions: { show: { - source: [ - 'managementApi', - ], + source: ['managementApi'], }, }, }, @@ -100,9 +84,7 @@ export class Storyblok implements INodeType { default: 'story', displayOptions: { show: { - source: [ - 'contentApi', - ], + source: ['contentApi'], }, }, }, @@ -121,9 +103,7 @@ export class Storyblok implements INodeType { default: 'story', displayOptions: { show: { - source: [ - 'managementApi', - ], + source: ['managementApi'], }, }, }, @@ -138,15 +118,9 @@ export class Storyblok implements INodeType { methods = { loadOptions: { - async getSpaces( - this: ILoadOptionsFunctions, - ): Promise { + async getSpaces(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { spaces } = await storyblokApiRequest.call( - this, - 'GET', - '/v1/spaces', - ); + const { spaces } = await storyblokApiRequest.call(this, 'GET', '/v1/spaces'); for (const space of spaces) { returnData.push({ name: space.name, @@ -155,9 +129,7 @@ export class Storyblok implements INodeType { } return returnData; }, - async getComponents( - this: ILoadOptionsFunctions, - ): Promise { + async getComponents(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const space = this.getCurrentNodeParameter('space') as string; const { components } = await storyblokApiRequest.call( @@ -167,7 +139,7 @@ export class Storyblok implements INodeType { ); for (const component of components) { returnData.push({ - name: `${component.name} ${(component.is_root ? '(root)' : '')}`, + name: `${component.name} ${component.is_root ? '(root)' : ''}`, value: component.name, }); } @@ -192,7 +164,11 @@ export class Storyblok implements INodeType { if (operation === 'get') { const identifier = this.getNodeParameter('identifier', i) as string; - responseData = await storyblokApiRequest.call(this, 'GET', `/v1/cdn/stories/${identifier}`); + responseData = await storyblokApiRequest.call( + this, + 'GET', + `/v1/cdn/stories/${identifier}`, + ); responseData = responseData.story; } if (operation === 'getAll') { @@ -201,11 +177,24 @@ export class Storyblok implements INodeType { Object.assign(qs, filters); if (returnAll) { - responseData = await storyblokApiRequestAllItems.call(this, 'stories', 'GET', '/v1/cdn/stories', {}, qs); + responseData = await storyblokApiRequestAllItems.call( + this, + 'stories', + 'GET', + '/v1/cdn/stories', + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.per_page = limit; - responseData = await storyblokApiRequest.call(this, 'GET', `/v1/cdn/stories`, {}, qs); + responseData = await storyblokApiRequest.call( + this, + 'GET', + `/v1/cdn/stories`, + {}, + qs, + ); responseData = responseData.stories; } } @@ -273,14 +262,22 @@ export class Storyblok implements INodeType { const space = this.getNodeParameter('space', i) as string; const storyId = this.getNodeParameter('storyId', i) as string; - responseData = await storyblokApiRequest.call(this, 'DELETE', `/v1/spaces/${space}/stories/${storyId}`); + responseData = await storyblokApiRequest.call( + this, + 'DELETE', + `/v1/spaces/${space}/stories/${storyId}`, + ); responseData = responseData.story; } if (operation === 'get') { const space = this.getNodeParameter('space', i) as string; const storyId = this.getNodeParameter('storyId', i) as string; - responseData = await storyblokApiRequest.call(this, 'GET', `/v1/spaces/${space}/stories/${storyId}`); + responseData = await storyblokApiRequest.call( + this, + 'GET', + `/v1/spaces/${space}/stories/${storyId}`, + ); responseData = responseData.story; } if (operation === 'getAll') { @@ -290,11 +287,24 @@ export class Storyblok implements INodeType { Object.assign(qs, filters); if (returnAll) { - responseData = await storyblokApiRequestAllItems.call(this, 'stories', 'GET', `/v1/spaces/${space}/stories`, {}, qs); + responseData = await storyblokApiRequestAllItems.call( + this, + 'stories', + 'GET', + `/v1/spaces/${space}/stories`, + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.per_page = limit; - responseData = await storyblokApiRequest.call(this, 'GET', `/v1/spaces/${space}/stories`, {}, qs); + responseData = await storyblokApiRequest.call( + this, + 'GET', + `/v1/spaces/${space}/stories`, + {}, + qs, + ); responseData = responseData.stories; } } @@ -311,14 +321,24 @@ export class Storyblok implements INodeType { query.lang = options.language as string; } - responseData = await storyblokApiRequest.call(this, 'GET', `/v1/spaces/${space}/stories/${storyId}/publish`, {}, query); + responseData = await storyblokApiRequest.call( + this, + 'GET', + `/v1/spaces/${space}/stories/${storyId}/publish`, + {}, + query, + ); responseData = responseData.story; } if (operation === 'unpublish') { const space = this.getNodeParameter('space', i) as string; const storyId = this.getNodeParameter('storyId', i) as string; - responseData = await storyblokApiRequest.call(this, 'GET', `/v1/spaces/${space}/stories/${storyId}/unpublish`); + responseData = await storyblokApiRequest.call( + this, + 'GET', + `/v1/spaces/${space}/stories/${storyId}/unpublish`, + ); responseData = responseData.story; } } diff --git a/packages/nodes-base/nodes/Strapi/EntryDescription.ts b/packages/nodes-base/nodes/Strapi/EntryDescription.ts index c920dd8925..5563741b7c 100644 --- a/packages/nodes-base/nodes/Strapi/EntryDescription.ts +++ b/packages/nodes-base/nodes/Strapi/EntryDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const entryOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const entryOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'entry', - ], + resource: ['entry'], }, }, options: [ @@ -63,12 +59,8 @@ export const entryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'entry', - ], - operation: [ - 'create', - ], + resource: ['entry'], + operation: ['create'], }, }, description: 'Name of the content type', @@ -79,17 +71,14 @@ export const entryFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'entry', - ], - operation: [ - 'create', - ], + resource: ['entry'], + operation: ['create'], }, }, default: '', placeholder: 'id,name,description', - description: 'Comma-separated list of the properties which should used as columns for the new rows', + description: + 'Comma-separated list of the properties which should used as columns for the new rows', }, /* -------------------------------------------------------------------------- */ @@ -103,12 +92,8 @@ export const entryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'entry', - ], - operation: [ - 'delete', - ], + resource: ['entry'], + operation: ['delete'], }, }, description: 'Name of the content type', @@ -121,12 +106,8 @@ export const entryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'entry', - ], - operation: [ - 'delete', - ], + resource: ['entry'], + operation: ['delete'], }, }, description: 'The ID of the entry to delete', @@ -143,12 +124,8 @@ export const entryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'entry', - ], - operation: [ - 'get', - ], + resource: ['entry'], + operation: ['get'], }, }, description: 'Name of the content type', @@ -161,12 +138,8 @@ export const entryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'entry', - ], - operation: [ - 'get', - ], + resource: ['entry'], + operation: ['get'], }, }, description: 'The ID of the entry to get', @@ -183,12 +156,8 @@ export const entryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'entry', - ], - operation: [ - 'getAll', - ], + resource: ['entry'], + operation: ['getAll'], }, }, description: 'Name of the content type', @@ -199,12 +168,8 @@ export const entryFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'entry', - ], - operation: [ - 'getAll', - ], + resource: ['entry'], + operation: ['getAll'], }, }, default: false, @@ -216,15 +181,9 @@ export const entryFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'entry', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['entry'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -242,12 +201,8 @@ export const entryFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'entry', - ], - operation: [ - 'getAll', - ], + resource: ['entry'], + operation: ['getAll'], }, }, options: [ @@ -278,7 +233,8 @@ export const entryFields: INodeProperties[] = [ }, default: '', placeholder: 'name:asc', - description: 'Name of the fields to sort the data by. By default will be sorted ascendingly. To modify that behavior, you have to add the sort direction after the name of sort field preceded by a colon. For example: name:asc.', + description: + 'Name of the fields to sort the data by. By default will be sorted ascendingly. To modify that behavior, you have to add the sort direction after the name of sort field preceded by a colon. For example: name:asc.', }, { displayName: 'Where (JSON)', @@ -288,7 +244,8 @@ export const entryFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'JSON query to filter the data. More info.', + description: + 'JSON query to filter the data. More info.', }, ], }, @@ -304,12 +261,8 @@ export const entryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'entry', - ], - operation: [ - 'update', - ], + resource: ['entry'], + operation: ['update'], }, }, description: 'Name of the content type', @@ -320,18 +273,15 @@ export const entryFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'entry', - ], - operation: [ - 'update', - ], + resource: ['entry'], + operation: ['update'], }, }, default: 'id', required: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id - description: 'Name of the property which decides which rows in the database should be updated. Normally that would be "id".', + description: + 'Name of the property which decides which rows in the database should be updated. Normally that would be "id".', }, { displayName: 'Columns', @@ -339,16 +289,13 @@ export const entryFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'entry', - ], - operation: [ - 'update', - ], + resource: ['entry'], + operation: ['update'], }, }, default: '', placeholder: 'id,name,description', - description: 'Comma-separated list of the properties which should used as columns for the new rows', + description: + 'Comma-separated list of the properties which should used as columns for the new rows', }, ]; diff --git a/packages/nodes-base/nodes/Strapi/GenericFunctions.ts b/packages/nodes-base/nodes/Strapi/GenericFunctions.ts index e52e46f6c0..e38bb958d5 100644 --- a/packages/nodes-base/nodes/Strapi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Strapi/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,12 +7,19 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; - -export async function strapiApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError } from 'n8n-workflow'; +export async function strapiApiRequest( + this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('strapiApi'); try { @@ -23,7 +28,10 @@ export async function strapiApiRequest(this: IExecuteFunctions | ILoadOptionsFun method, body, qs, - uri: uri || credentials.apiVersion === 'v4' ? `${credentials.url}/api${resource}` : `${credentials.url}${resource}`, + uri: + uri || credentials.apiVersion === 'v4' + ? `${credentials.url}/api${resource}` + : `${credentials.url}${resource}`, json: true, qsStringifyOptions: { arrayFormat: 'indice', @@ -43,56 +51,82 @@ export async function strapiApiRequest(this: IExecuteFunctions | ILoadOptionsFun } } -export async function getToken(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions): Promise { // tslint:disable-line:no-any +export async function getToken( + this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('strapiApi'); let options = {} as OptionsWithUri; - options = { - headers: { - 'content-type': 'application/json', - }, - method: 'POST', - body: { - identifier: credentials.email, - password: credentials.password, - }, - uri: credentials.apiVersion === 'v4' ? `${credentials.url}/api/auth/local`:`${credentials.url}/auth/local`, - json: true, - }; + options = { + headers: { + 'content-type': 'application/json', + }, + method: 'POST', + body: { + identifier: credentials.email, + password: credentials.password, + }, + uri: + credentials.apiVersion === 'v4' + ? `${credentials.url}/api/auth/local` + : `${credentials.url}/auth/local`, + json: true, + }; return this.helpers.request!(options); } -export async function strapiApiRequestAllItems(this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function strapiApiRequestAllItems( + this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; - const {apiVersion} = await this.getCredentials('strapiApi'); + const { apiVersion } = await this.getCredentials('strapiApi'); let responseData; if (apiVersion === 'v4') { query['pagination[pageSize]'] = 20; query['pagination[page]'] = 0; do { - ({data:responseData} = await strapiApiRequest.call(this, method, resource, body, query, undefined, headers)); + ({ data: responseData } = await strapiApiRequest.call( + this, + method, + resource, + body, + query, + undefined, + headers, + )); query['pagination[page]'] += query['pagination[pageSize]']; returnData.push.apply(returnData, responseData); - } while ( - responseData.length !== 0 - ); - + } while (responseData.length !== 0); } else { query._limit = 20; query._start = 0; do { - responseData = await strapiApiRequest.call(this, method, resource, body, query, undefined, headers); + responseData = await strapiApiRequest.call( + this, + method, + resource, + body, + query, + undefined, + headers, + ); query._start += query._limit; returnData.push.apply(returnData, responseData); - } while ( - responseData.length !== 0 - ); + } while (responseData.length !== 0); } return returnData; } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); diff --git a/packages/nodes-base/nodes/Strapi/Strapi.node.ts b/packages/nodes-base/nodes/Strapi/Strapi.node.ts index 442c6be10d..ce9c0e268c 100644 --- a/packages/nodes-base/nodes/Strapi/Strapi.node.ts +++ b/packages/nodes-base/nodes/Strapi/Strapi.node.ts @@ -1,10 +1,6 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { ICredentialsDecrypted, @@ -24,10 +20,7 @@ import { validateJSON, } from './GenericFunctions'; -import { - entryFields, - entryOperations, -} from './EntryDescription'; +import { entryFields, entryOperations } from './EntryDescription'; export class Strapi implements INodeType { description: INodeTypeDescription = { @@ -71,8 +64,11 @@ export class Strapi implements INodeType { methods = { credentialTest: { - async strapiApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { - const credentials = await credential.data as IDataObject; + async strapiApiTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { + const credentials = (await credential.data) as IDataObject; let options = {} as OptionsWithUri; options = { @@ -84,21 +80,24 @@ export class Strapi implements INodeType { identifier: credentials.email, password: credentials.password, }, - uri: credentials.apiVersion === 'v4' ? `${credentials.url}/api/auth/local`:`${credentials.url}/auth/local`, + uri: + credentials.apiVersion === 'v4' + ? `${credentials.url}/api/auth/local` + : `${credentials.url}/auth/local`, json: true, }; - try { - await this.helpers.request(options); - return { - status: 'OK', - message: 'Authentication successful', - }; - } catch (error) { - return { - status: 'Error', - message: `Auth settings are not valid: ${error}`, - }; - } + try { + await this.helpers.request(options); + return { + status: 'OK', + message: 'Authentication successful', + }; + } catch (error) { + return { + status: 'Error', + message: `Auth settings are not valid: ${error}`, + }; + } }, }, }; @@ -121,21 +120,30 @@ export class Strapi implements INodeType { try { if (resource === 'entry') { if (operation === 'create') { - const body: IDataObject = {}; const contentType = this.getNodeParameter('contentType', i) as string; const columns = this.getNodeParameter('columns', i) as string; - const columnList = columns.split(',').map(column => column.trim()); + const columnList = columns.split(',').map((column) => column.trim()); for (const key of Object.keys(items[i].json)) { if (columnList.includes(key)) { - apiVersion === 'v4'? body.data = items[i].json: body[key] = items[i].json[key]; + apiVersion === 'v4' + ? (body.data = items[i].json) + : (body[key] = items[i].json[key]); } } - responseData = await strapiApiRequest.call(this, 'POST', `/${contentType}`, body, qs, undefined, headers); + responseData = await strapiApiRequest.call( + this, + 'POST', + `/${contentType}`, + body, + qs, + undefined, + headers, + ); returnData.push(responseData); } @@ -145,13 +153,20 @@ export class Strapi implements INodeType { const entryId = this.getNodeParameter('entryId', i) as string; - responseData = await strapiApiRequest.call(this, 'DELETE', `/${contentType}/${entryId}`, {}, qs, undefined, headers); + responseData = await strapiApiRequest.call( + this, + 'DELETE', + `/${contentType}/${entryId}`, + {}, + qs, + undefined, + headers, + ); returnData.push(responseData); } if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; const contentType = this.getNodeParameter('contentType', i) as string; @@ -170,7 +185,9 @@ export class Strapi implements INodeType { if (query !== undefined) { qs.filters = query; } else { - throw new NodeOperationError(this.getNode(), 'Query must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Query must be a valid JSON', { + itemIndex: i, + }); } } // Publication Option @@ -179,10 +196,25 @@ export class Strapi implements INodeType { } // Limit Option if (returnAll) { - responseData = await strapiApiRequestAllItems.call(this, 'GET', `/${contentType}`, {}, qs, headers); + responseData = await strapiApiRequestAllItems.call( + this, + 'GET', + `/${contentType}`, + {}, + qs, + headers, + ); } else { qs['pagination[pageSize]'] = this.getNodeParameter('limit', i) as number; - ({ data:responseData } = await strapiApiRequest.call(this, 'GET', `/${contentType}`, {}, qs, undefined, headers)); + ({ data: responseData } = await strapiApiRequest.call( + this, + 'GET', + `/${contentType}`, + {}, + qs, + undefined, + headers, + )); } } else { // Sort Option @@ -196,7 +228,9 @@ export class Strapi implements INodeType { if (query !== undefined) { qs._where = query; } else { - throw new NodeOperationError(this.getNode(), 'Query must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Query must be a valid JSON', { + itemIndex: i, + }); } } // Publication Option @@ -205,27 +239,50 @@ export class Strapi implements INodeType { } // Limit Option if (returnAll) { - responseData = await strapiApiRequestAllItems.call(this, 'GET', `/${contentType}`, {}, qs, headers); + responseData = await strapiApiRequestAllItems.call( + this, + 'GET', + `/${contentType}`, + {}, + qs, + headers, + ); } else { qs._limit = this.getNodeParameter('limit', i) as number; - responseData = await strapiApiRequest.call(this, 'GET', `/${contentType}`, {}, qs, undefined, headers); + responseData = await strapiApiRequest.call( + this, + 'GET', + `/${contentType}`, + {}, + qs, + undefined, + headers, + ); } } returnData.push.apply(returnData, responseData); } if (operation === 'get') { - const contentType = this.getNodeParameter('contentType', i) as string; const entryId = this.getNodeParameter('entryId', i) as string; - responseData = await strapiApiRequest.call(this, 'GET', `/${contentType}/${entryId}`, {}, qs, undefined, headers); - apiVersion === 'v4'? returnData.push(responseData.data): returnData.push(responseData); + responseData = await strapiApiRequest.call( + this, + 'GET', + `/${contentType}/${entryId}`, + {}, + qs, + undefined, + headers, + ); + apiVersion === 'v4' + ? returnData.push(responseData.data) + : returnData.push(responseData); } if (operation === 'update') { - const body: IDataObject = {}; const contentType = this.getNodeParameter('contentType', i) as string; @@ -234,19 +291,30 @@ export class Strapi implements INodeType { const updateKey = this.getNodeParameter('updateKey', i) as string; - const columnList = columns.split(',').map(column => column.trim()); + const columnList = columns.split(',').map((column) => column.trim()); const entryId = items[i].json[updateKey]; for (const key of Object.keys(items[i].json)) { if (columnList.includes(key)) { - apiVersion === 'v4'? body.data = items[i].json:body[key] = items[i].json[key]; + apiVersion === 'v4' + ? (body.data = items[i].json) + : (body[key] = items[i].json[key]); } } - responseData = await strapiApiRequest.call(this, 'PUT', `/${contentType}/${entryId}`, body, qs, undefined, headers); - apiVersion === 'v4'? returnData.push(responseData.data): returnData.push(responseData); - + responseData = await strapiApiRequest.call( + this, + 'PUT', + `/${contentType}/${entryId}`, + body, + qs, + undefined, + headers, + ); + apiVersion === 'v4' + ? returnData.push(responseData.data) + : returnData.push(responseData); } } } catch (error) { diff --git a/packages/nodes-base/nodes/Strava/ActivityDescription.ts b/packages/nodes-base/nodes/Strava/ActivityDescription.ts index 6572d33eac..01b89406f0 100644 --- a/packages/nodes-base/nodes/Strava/ActivityDescription.ts +++ b/packages/nodes-base/nodes/Strava/ActivityDescription.ts @@ -1,7 +1,4 @@ - -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const activityOperations: INodeProperties[] = [ { @@ -11,9 +8,7 @@ export const activityOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'activity', - ], + resource: ['activity'], }, }, options: [ @@ -77,7 +72,6 @@ export const activityOperations: INodeProperties[] = [ ]; export const activityFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* activity:create */ /* -------------------------------------------------------------------------- */ @@ -88,12 +82,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, default: '', @@ -106,12 +96,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, default: '', @@ -125,12 +111,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, description: 'ISO 8601 formatted date time', @@ -142,12 +124,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, typeOptions: { @@ -164,12 +142,8 @@ export const activityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'create', - ], + resource: ['activity'], + operation: ['create'], }, }, options: [ @@ -217,12 +191,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'update', - ], + resource: ['activity'], + operation: ['update'], }, }, default: '', @@ -236,12 +206,8 @@ export const activityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'update', - ], + resource: ['activity'], + operation: ['update'], }, }, options: [ @@ -264,7 +230,8 @@ export const activityFields: INodeProperties[] = [ name: 'gear_id', type: 'string', default: '', - description: 'Identifier for the gear associated with the activity. ‘none’ clears gear from activity.', + description: + 'Identifier for the gear associated with the activity. ‘none’ clears gear from activity.', }, { displayName: 'Name', @@ -300,12 +267,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'get', - ], + resource: ['activity'], + operation: ['get'], }, }, default: '', @@ -322,16 +285,8 @@ export const activityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getComments', - 'getLaps', - 'getKudos', - 'getZones', - 'getStreams', - ], + resource: ['activity'], + operation: ['getComments', 'getLaps', 'getKudos', 'getZones', 'getStreams'], }, }, default: '', @@ -343,15 +298,8 @@ export const activityFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getComments', - 'getLaps', - 'getKudos', - 'getZones', - ], + resource: ['activity'], + operation: ['getComments', 'getLaps', 'getKudos', 'getZones'], }, }, default: false, @@ -363,18 +311,9 @@ export const activityFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getComments', - 'getLaps', - 'getKudos', - 'getZones', - ], - returnAll: [ - false, - ], + resource: ['activity'], + operation: ['getComments', 'getLaps', 'getKudos', 'getZones'], + returnAll: [false], }, }, typeOptions: { @@ -436,12 +375,8 @@ export const activityFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getStreams', - ], + resource: ['activity'], + operation: ['getStreams'], }, }, required: true, @@ -457,12 +392,8 @@ export const activityFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getAll', - ], + resource: ['activity'], + operation: ['getAll'], }, }, default: false, @@ -474,15 +405,9 @@ export const activityFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'activity', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['activity'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Strava/GenericFunctions.ts b/packages/nodes-base/nodes/Strava/GenericFunctions.ts index 4915d0c877..4600d60d6d 100644 --- a/packages/nodes-base/nodes/Strava/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Strava/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -10,12 +8,24 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; - -export async function stravaApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError } from 'n8n-workflow'; +export async function stravaApiRequest( + this: + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IHookFunctions + | IWebhookFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { method, form: body, @@ -42,18 +52,26 @@ export async function stravaApiRequest(this: IExecuteFunctions | IExecuteSingleF } //@ts-ignore return this.helpers?.request(options); - } else { //@ts-ignore - return await this.helpers.requestOAuth2.call(this, 'stravaOAuth2Api', options, { includeCredentialsOnRefreshOnBody: true }); + return await this.helpers.requestOAuth2.call(this, 'stravaOAuth2Api', options, { + includeCredentialsOnRefreshOnBody: true, + }); } } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function stravaApiRequestAllItems(this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function stravaApiRequestAllItems( + this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -66,9 +84,7 @@ export async function stravaApiRequestAllItems(this: IHookFunctions | ILoadOptio responseData = await stravaApiRequest.call(this, method, resource, body, query); query.page++; returnData.push.apply(returnData, responseData); - } while ( - responseData.length !== 0 - ); + } while (responseData.length !== 0); return returnData; } diff --git a/packages/nodes-base/nodes/Strava/Strava.node.ts b/packages/nodes-base/nodes/Strava/Strava.node.ts index 7013534af6..22796eafeb 100644 --- a/packages/nodes-base/nodes/Strava/Strava.node.ts +++ b/packages/nodes-base/nodes/Strava/Strava.node.ts @@ -1,23 +1,10 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - stravaApiRequest, - stravaApiRequestAllItems, -} from './GenericFunctions'; +import { stravaApiRequest, stravaApiRequestAllItems } from './GenericFunctions'; -import { - activityFields, - activityOperations, -} from './ActivityDescription'; +import { activityFields, activityOperations } from './ActivityDescription'; import moment from 'moment'; @@ -69,7 +56,6 @@ export class Strava implements INodeType { const resource = this.getNodeParameter('resource', 0) as string; const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < length; i++) { - try { if (resource === 'activity') { //https://developers.strava.com/docs/reference/#api-Activities-createActivity @@ -110,19 +96,22 @@ export class Strava implements INodeType { responseData = await stravaApiRequest.call(this, 'GET', `/activities/${activityId}`); } if (['getLaps', 'getZones', 'getKudos', 'getComments'].includes(operation)) { - const path: IDataObject = { - 'getComments': 'comments', - 'getZones': 'zones', - 'getKudos': 'kudos', - 'getLaps': 'laps', + getComments: 'comments', + getZones: 'zones', + getKudos: 'kudos', + getLaps: 'laps', }; const activityId = this.getNodeParameter('activityId', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; - responseData = await stravaApiRequest.call(this, 'GET', `/activities/${activityId}/${path[operation]}`); + responseData = await stravaApiRequest.call( + this, + 'GET', + `/activities/${activityId}/${path[operation]}`, + ); if (returnAll === false) { const limit = this.getNodeParameter('limit', i) as number; @@ -136,15 +125,26 @@ export class Strava implements INodeType { qs.keys = keys.toString(); qs.key_by_type = true; - responseData = await stravaApiRequest.call(this, 'GET', `/activities/${activityId}/streams`, {}, qs); + responseData = await stravaApiRequest.call( + this, + 'GET', + `/activities/${activityId}/streams`, + {}, + qs, + ); } //https://developers.mailerlite.com/reference#subscribers if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll) { - - responseData = await stravaApiRequestAllItems.call(this, 'GET', `/activities`, {}, qs); + responseData = await stravaApiRequestAllItems.call( + this, + 'GET', + `/activities`, + {}, + qs, + ); } else { qs.per_page = this.getNodeParameter('limit', i) as number; @@ -169,7 +169,12 @@ export class Strava implements INodeType { Object.assign(body, updateFields); - responseData = await stravaApiRequest.call(this, 'PUT', `/activities/${activityId}`, body); + responseData = await stravaApiRequest.call( + this, + 'PUT', + `/activities/${activityId}`, + body, + ); } } if (Array.isArray(responseData)) { diff --git a/packages/nodes-base/nodes/Strava/StravaTrigger.node.ts b/packages/nodes-base/nodes/Strava/StravaTrigger.node.ts index f9f436e377..d78cac239f 100644 --- a/packages/nodes-base/nodes/Strava/StravaTrigger.node.ts +++ b/packages/nodes-base/nodes/Strava/StravaTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -11,13 +8,9 @@ import { NodeApiError, } from 'n8n-workflow'; -import { - stravaApiRequest, -} from './GenericFunctions'; +import { stravaApiRequest } from './GenericFunctions'; -import { - randomBytes, -} from 'crypto'; +import { randomBytes } from 'crypto'; export class StravaTrigger implements INodeType { description: INodeTypeDescription = { @@ -103,7 +96,8 @@ export class StravaTrigger implements INodeType { type: 'boolean', default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default the webhook-data only contain the Object ID. If this option gets activated, it will resolve the data automatically.', + description: + 'By default the webhook-data only contain the Object ID. If this option gets activated, it will resolve the data automatically.', }, { displayName: 'Options', @@ -118,7 +112,8 @@ export class StravaTrigger implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Strava allows just one subscription at all times. If you want to delete the current subscription to make room for a new subcription with the current parameters, set this parameter to true. Keep in mind this is a destructive operation.', + description: + 'Strava allows just one subscription at all times. If you want to delete the current subscription to make room for a new subcription with the current parameters, set this parameter to true. Keep in mind this is a destructive operation.', }, ], }, @@ -170,18 +165,32 @@ export class StravaTrigger implements INodeType { if (error.resource === 'PushSubscription' && error.code === 'already exists') { const options = this.getNodeParameter('options') as IDataObject; //get the current subscription - const webhooks = await stravaApiRequest.call(this, 'GET', `/push_subscriptions`, {}); + const webhooks = await stravaApiRequest.call( + this, + 'GET', + `/push_subscriptions`, + {}, + ); if (options.deleteIfExist) { // delete the subscription - await stravaApiRequest.call(this, 'DELETE', `/push_subscriptions/${webhooks[0].id}`); + await stravaApiRequest.call( + this, + 'DELETE', + `/push_subscriptions/${webhooks[0].id}`, + ); // now there is room create a subscription with the n8n data const body = { callback_url: webhookUrl, verify_token: randomBytes(20).toString('hex') as string, }; - responseData = await stravaApiRequest.call(this, 'POST', `/push_subscriptions`, body); + responseData = await stravaApiRequest.call( + this, + 'POST', + `/push_subscriptions`, + body, + ); } else { error.message = `A subscription already exists [${webhooks[0].callback_url}]. If you want to delete this subcription and create a new one with the current parameters please go to options and set delete if exist to true`; throw error; @@ -206,7 +215,6 @@ export class StravaTrigger implements INodeType { async delete(this: IHookFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); if (webhookData.webhookId !== undefined) { - const endpoint = `/push_subscriptions/${webhookData.webhookId}`; try { @@ -273,9 +281,7 @@ export class StravaTrigger implements INodeType { } return { - workflowData: [ - this.helpers.returnJsonArray(body), - ], + workflowData: [this.helpers.returnJsonArray(body)], }; } } diff --git a/packages/nodes-base/nodes/Stripe/Stripe.node.ts b/packages/nodes-base/nodes/Stripe/Stripe.node.ts index 7fb973b837..7cb284bae5 100644 --- a/packages/nodes-base/nodes/Stripe/Stripe.node.ts +++ b/packages/nodes-base/nodes/Stripe/Stripe.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,9 +10,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - isEmpty, -} from 'lodash'; +import { isEmpty } from 'lodash'; import { adjustChargeFields, @@ -144,11 +140,8 @@ export class Stripe implements INodeType { const returnData: IDataObject[] = []; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'balance') { - // ********************************************************************* // balance // ********************************************************************* @@ -156,17 +149,13 @@ export class Stripe implements INodeType { // https://stripe.com/docs/api/balance if (operation === 'get') { - // ---------------------------------- // balance: get // ---------------------------------- responseData = await stripeApiRequest.call(this, 'GET', '/balance', {}, {}); - } - } else if (resource === 'customerCard') { - // ********************************************************************* // customer card // ********************************************************************* @@ -174,7 +163,6 @@ export class Stripe implements INodeType { // https://stripe.com/docs/api/cards if (operation === 'add') { - // ---------------------------------- // customerCard: add // ---------------------------------- @@ -186,9 +174,7 @@ export class Stripe implements INodeType { const customerId = this.getNodeParameter('customerId', i); const endpoint = `/customers/${customerId}/sources`; responseData = await stripeApiRequest.call(this, 'POST', endpoint, body, {}); - } else if (operation === 'remove') { - // ---------------------------------- // customerCard: remove // ---------------------------------- @@ -197,9 +183,7 @@ export class Stripe implements INodeType { const cardId = this.getNodeParameter('cardId', i); const endpoint = `/customers/${customerId}/sources/${cardId}`; responseData = await stripeApiRequest.call(this, 'DELETE', endpoint, {}, {}); - } else if (operation === 'get') { - // ---------------------------------- // customerCard: get // ---------------------------------- @@ -208,11 +192,8 @@ export class Stripe implements INodeType { const sourceId = this.getNodeParameter('sourceId', i); const endpoint = `/customers/${customerId}/sources/${sourceId}`; responseData = await stripeApiRequest.call(this, 'GET', endpoint, {}, {}); - } - } else if (resource === 'charge') { - // ********************************************************************* // charge // ********************************************************************* @@ -220,7 +201,6 @@ export class Stripe implements INodeType { // https://stripe.com/docs/api/charges if (operation === 'create') { - // ---------------------------------- // charge: create // ---------------------------------- @@ -239,26 +219,20 @@ export class Stripe implements INodeType { } responseData = await stripeApiRequest.call(this, 'POST', '/charges', body, {}); - } else if (operation === 'get') { - // ---------------------------------- // charge: get // ---------------------------------- const chargeId = this.getNodeParameter('chargeId', i); responseData = await stripeApiRequest.call(this, 'GET', `/charges/${chargeId}`, {}, {}); - } else if (operation === 'getAll') { - // ---------------------------------- // charge: getAll // ---------------------------------- responseData = await handleListing.call(this, resource, i); - } else if (operation === 'update') { - // ---------------------------------- // charge: update // ---------------------------------- @@ -268,18 +242,25 @@ export class Stripe implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; if (isEmpty(updateFields)) { - throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Please enter at least one field to update for the ${resource}.`, + { itemIndex: i }, + ); } Object.assign(body, adjustChargeFields(updateFields)); const chargeId = this.getNodeParameter('chargeId', i); - responseData = await stripeApiRequest.call(this, 'POST', `/charges/${chargeId}`, body, {}); - + responseData = await stripeApiRequest.call( + this, + 'POST', + `/charges/${chargeId}`, + body, + {}, + ); } - } else if (resource === 'coupon') { - // ********************************************************************* // coupon // ********************************************************************* @@ -287,7 +268,6 @@ export class Stripe implements INodeType { // https://stripe.com/docs/api/coupons if (operation === 'create') { - // ---------------------------------- // coupon: create // ---------------------------------- @@ -306,19 +286,14 @@ export class Stripe implements INodeType { } responseData = await stripeApiRequest.call(this, 'POST', '/coupons', body, {}); - } else if (operation === 'getAll') { - // ---------------------------------- // coupon: getAll // ---------------------------------- responseData = await handleListing.call(this, resource, i); - } - } else if (resource === 'customer') { - // ********************************************************************* // customer // ********************************************************************* @@ -326,7 +301,6 @@ export class Stripe implements INodeType { // https://stripe.com/docs/api/customers if (operation === 'create') { - // ---------------------------------- // customer: create // ---------------------------------- @@ -342,27 +316,33 @@ export class Stripe implements INodeType { } responseData = await stripeApiRequest.call(this, 'POST', '/customers', body, {}); - } else if (operation === 'delete') { - // ---------------------------------- // customer: delete // ---------------------------------- const customerId = this.getNodeParameter('customerId', i); - responseData = await stripeApiRequest.call(this, 'DELETE', `/customers/${customerId}`, {}, {}); - + responseData = await stripeApiRequest.call( + this, + 'DELETE', + `/customers/${customerId}`, + {}, + {}, + ); } else if (operation === 'get') { - // ---------------------------------- // customer: get // ---------------------------------- const customerId = this.getNodeParameter('customerId', i); - responseData = await stripeApiRequest.call(this, 'GET', `/customers/${customerId}`, {}, {}); - + responseData = await stripeApiRequest.call( + this, + 'GET', + `/customers/${customerId}`, + {}, + {}, + ); } else if (operation === 'getAll') { - // ---------------------------------- // customer: getAll // ---------------------------------- @@ -375,9 +355,7 @@ export class Stripe implements INodeType { } responseData = await handleListing.call(this, resource, i, qs); - } else if (operation === 'update') { - // ---------------------------------- // customer: update // ---------------------------------- @@ -387,18 +365,25 @@ export class Stripe implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; if (isEmpty(updateFields)) { - throw new NodeOperationError(this.getNode(), `Please enter at least one field to update for the ${resource}.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Please enter at least one field to update for the ${resource}.`, + { itemIndex: i }, + ); } Object.assign(body, adjustCustomerFields(updateFields)); const customerId = this.getNodeParameter('customerId', i); - responseData = await stripeApiRequest.call(this, 'POST', `/customers/${customerId}`, body, {}); - + responseData = await stripeApiRequest.call( + this, + 'POST', + `/customers/${customerId}`, + body, + {}, + ); } - } else if (resource === 'source') { - // ********************************************************************* // source // ********************************************************************* @@ -406,7 +391,6 @@ export class Stripe implements INodeType { // https://stripe.com/docs/api/sources if (operation === 'create') { - // ---------------------------------- // source: create // ---------------------------------- @@ -430,9 +414,7 @@ export class Stripe implements INodeType { // attach source to customer const endpoint = `/customers/${customerId}/sources`; await stripeApiRequest.call(this, 'POST', endpoint, { source: responseData.id }, {}); - } else if (operation === 'delete') { - // ---------------------------------- // source: delete // ---------------------------------- @@ -441,20 +423,15 @@ export class Stripe implements INodeType { const customerId = this.getNodeParameter('customerId', i); const endpoint = `/customers/${customerId}/sources/${sourceId}`; responseData = await stripeApiRequest.call(this, 'DELETE', endpoint, {}, {}); - } else if (operation === 'get') { - // ---------------------------------- // source: get // ---------------------------------- const sourceId = this.getNodeParameter('sourceId', i); responseData = await stripeApiRequest.call(this, 'GET', `/sources/${sourceId}`, {}, {}); - } - } else if (resource === 'token') { - // ********************************************************************* // token // ********************************************************************* @@ -462,7 +439,6 @@ export class Stripe implements INodeType { // https://stripe.com/docs/api/tokens if (operation === 'create') { - // ---------------------------------- // token: create // ---------------------------------- @@ -471,7 +447,11 @@ export class Stripe implements INodeType { const body = {} as IDataObject; if (type !== 'cardToken') { - throw new NodeOperationError(this.getNode(), 'Only card token creation implemented.', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Only card token creation implemented.', + { itemIndex: i }, + ); } body.card = { @@ -483,9 +463,7 @@ export class Stripe implements INodeType { responseData = await stripeApiRequest.call(this, 'POST', '/tokens', body, {}); } - } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -501,6 +479,5 @@ export class Stripe implements INodeType { } return [this.helpers.returnJsonArray(returnData)]; - } } diff --git a/packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts b/packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts index c4d63ce8a0..b007265a7b 100644 --- a/packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts +++ b/packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts @@ -1,7 +1,5 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +/* eslint-disable n8n-nodes-base/node-param-description-excess-final-period */ +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -12,9 +10,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - stripeApiRequest, -} from './helpers'; +import { stripeApiRequest } from './helpers'; export class StripeTrigger implements INodeType { description: INodeTypeDescription = { @@ -51,6 +47,7 @@ export class StripeTrigger implements INodeType { required: true, default: [], description: 'The event to listen to', + // eslint-disable-next-line n8n-nodes-base/node-param-multi-options-type-unsorted-items options: [ { name: '*', @@ -58,744 +55,770 @@ export class StripeTrigger implements INodeType { description: 'Any time any event is triggered (Wildcard Event)', }, { - 'name': 'Account Updated', - 'value': 'account.updated', - 'description': 'Occurs whenever an account status or property has changed.', + name: 'Account Updated', + value: 'account.updated', + description: 'Occurs whenever an account status or property has changed', }, { - 'name': 'Account Application.authorized', - 'value': 'account.application.authorized', - 'description': 'Occurs whenever a user authorizes an application. Sent to the related application only.', + name: 'Account Application.authorized', + value: 'account.application.authorized', + description: + 'Occurs whenever a user authorizes an application. Sent to the related application only.', }, { - 'name': 'Account Application.deauthorized', - 'value': 'account.application.deauthorized', - 'description': 'Occurs whenever a user deauthorizes an application. Sent to the related application only.', + name: 'Account Application.deauthorized', + value: 'account.application.deauthorized', + description: + 'Occurs whenever a user deauthorizes an application. Sent to the related application only.', }, { - 'name': 'Account External_account.created', - 'value': 'account.external_account.created', - 'description': 'Occurs whenever an external account is created.', + name: 'Account External_account.created', + value: 'account.external_account.created', + description: 'Occurs whenever an external account is created.', }, { - 'name': 'Account External_account.deleted', - 'value': 'account.external_account.deleted', - 'description': 'Occurs whenever an external account is deleted.', + name: 'Account External_account.deleted', + value: 'account.external_account.deleted', + description: 'Occurs whenever an external account is deleted.', }, { - 'name': 'Account External_account.updated', - 'value': 'account.external_account.updated', - 'description': 'Occurs whenever an external account is updated.', + name: 'Account External_account.updated', + value: 'account.external_account.updated', + description: 'Occurs whenever an external account is updated.', }, { - 'name': 'Application Fee.created', - 'value': 'application_fee.created', - 'description': 'Occurs whenever an application fee is created on a charge.', + name: 'Application Fee.created', + value: 'application_fee.created', + description: 'Occurs whenever an application fee is created on a charge.', }, { - 'name': 'Application Fee.refunded', - 'value': 'application_fee.refunded', - 'description': 'Occurs whenever an application fee is refunded, whether from refunding a charge or from refunding the application fee directly. This includes partial refunds.', + name: 'Application Fee.refunded', + value: 'application_fee.refunded', + description: + 'Occurs whenever an application fee is refunded, whether from refunding a charge or from refunding the application fee directly. This includes partial refunds.', }, { - 'name': 'Application Fee.refund.updated', - 'value': 'application_fee.refund.updated', - 'description': 'Occurs whenever an application fee refund is updated.', + name: 'Application Fee.refund.updated', + value: 'application_fee.refund.updated', + description: 'Occurs whenever an application fee refund is updated.', }, { - 'name': 'Balance Available', - 'value': 'balance.available', - 'description': 'Occurs whenever your Stripe balance has been updated (e.g., when a charge is available to be paid out). By default, Stripe automatically transfers funds in your balance to your bank account on a daily basis.', + name: 'Balance Available', + value: 'balance.available', + description: + 'Occurs whenever your Stripe balance has been updated (e.g., when a charge is available to be paid out). By default, Stripe automatically transfers funds in your balance to your bank account on a daily basis.', }, { - 'name': 'Capability Updated', - 'value': 'capability.updated', - 'description': 'Occurs whenever a capability has new requirements or a new status.', + name: 'Capability Updated', + value: 'capability.updated', + description: 'Occurs whenever a capability has new requirements or a new status.', }, { - 'name': 'Charge Captured', - 'value': 'charge.captured', - 'description': 'Occurs whenever a previously uncaptured charge is captured.', + name: 'Charge Captured', + value: 'charge.captured', + description: 'Occurs whenever a previously uncaptured charge is captured.', }, { - 'name': 'Charge Expired', - 'value': 'charge.expired', - 'description': 'Occurs whenever an uncaptured charge expires.', + name: 'Charge Expired', + value: 'charge.expired', + description: 'Occurs whenever an uncaptured charge expires.', }, { - 'name': 'Charge Failed', - 'value': 'charge.failed', - 'description': 'Occurs whenever a failed charge attempt occurs.', + name: 'Charge Failed', + value: 'charge.failed', + description: 'Occurs whenever a failed charge attempt occurs.', }, { - 'name': 'Charge Pending', - 'value': 'charge.pending', - 'description': 'Occurs whenever a pending charge is created.', + name: 'Charge Pending', + value: 'charge.pending', + description: 'Occurs whenever a pending charge is created.', }, { - 'name': 'Charge Refunded', - 'value': 'charge.refunded', - 'description': 'Occurs whenever a charge is refunded, including partial refunds.', + name: 'Charge Refunded', + value: 'charge.refunded', + description: 'Occurs whenever a charge is refunded, including partial refunds.', }, { - 'name': 'Charge Succeeded', - 'value': 'charge.succeeded', - 'description': 'Occurs whenever a new charge is created and is successful.', + name: 'Charge Succeeded', + value: 'charge.succeeded', + description: 'Occurs whenever a new charge is created and is successful.', }, { - 'name': 'Charge Updated', - 'value': 'charge.updated', - 'description': 'Occurs whenever a charge description or metadata is updated.', + name: 'Charge Updated', + value: 'charge.updated', + description: 'Occurs whenever a charge description or metadata is updated.', }, { - 'name': 'Charge Dispute.closed', - 'value': 'charge.dispute.closed', - 'description': 'Occurs when a dispute is closed and the dispute status changes to lost, warning_closed, or won.', + name: 'Charge Dispute.closed', + value: 'charge.dispute.closed', + description: + 'Occurs when a dispute is closed and the dispute status changes to lost, warning_closed, or won.', }, { - 'name': 'Charge Dispute.created', - 'value': 'charge.dispute.created', - 'description': 'Occurs whenever a customer disputes a charge with their bank.', + name: 'Charge Dispute.created', + value: 'charge.dispute.created', + description: 'Occurs whenever a customer disputes a charge with their bank.', }, { - 'name': 'Charge Dispute.funds_reinstated', - 'value': 'charge.dispute.funds_reinstated', - 'description': 'Occurs when funds are reinstated to your account after a dispute is closed. This includes partially refunded payments.', + name: 'Charge Dispute.funds_reinstated', + value: 'charge.dispute.funds_reinstated', + description: + 'Occurs when funds are reinstated to your account after a dispute is closed. This includes partially refunded payments.', }, { - 'name': 'Charge Dispute.funds_withdrawn', - 'value': 'charge.dispute.funds_withdrawn', - 'description': 'Occurs when funds are removed from your account due to a dispute.', + name: 'Charge Dispute.funds_withdrawn', + value: 'charge.dispute.funds_withdrawn', + description: 'Occurs when funds are removed from your account due to a dispute.', }, { - 'name': 'Charge Dispute.updated', - 'value': 'charge.dispute.updated', - 'description': 'Occurs when the dispute is updated (usually with evidence).', + name: 'Charge Dispute.updated', + value: 'charge.dispute.updated', + description: 'Occurs when the dispute is updated (usually with evidence).', }, { - 'name': 'Charge Refund.updated', - 'value': 'charge.refund.updated', - 'description': 'Occurs whenever a refund is updated, on selected payment methods.', + name: 'Charge Refund.updated', + value: 'charge.refund.updated', + description: 'Occurs whenever a refund is updated, on selected payment methods.', }, { - 'name': 'Checkout Session.completed', - 'value': 'checkout.session.completed', - 'description': 'Occurs when a Checkout Session has been successfully completed.', + name: 'Checkout Session.completed', + value: 'checkout.session.completed', + description: 'Occurs when a Checkout Session has been successfully completed.', }, { - 'name': 'Coupon Created', - 'value': 'coupon.created', - 'description': 'Occurs whenever a coupon is created.', + name: 'Coupon Created', + value: 'coupon.created', + description: 'Occurs whenever a coupon is created.', }, { - 'name': 'Coupon Deleted', - 'value': 'coupon.deleted', - 'description': 'Occurs whenever a coupon is deleted.', + name: 'Coupon Deleted', + value: 'coupon.deleted', + description: 'Occurs whenever a coupon is deleted.', }, { - 'name': 'Coupon Updated', - 'value': 'coupon.updated', - 'description': 'Occurs whenever a coupon is updated.', + name: 'Coupon Updated', + value: 'coupon.updated', + description: 'Occurs whenever a coupon is updated.', }, { - 'name': 'Credit Note.created', - 'value': 'credit_note.created', - 'description': 'Occurs whenever a credit note is created.', + name: 'Credit Note.created', + value: 'credit_note.created', + description: 'Occurs whenever a credit note is created.', }, { - 'name': 'Credit Note.updated', - 'value': 'credit_note.updated', - 'description': 'Occurs whenever a credit note is updated.', + name: 'Credit Note.updated', + value: 'credit_note.updated', + description: 'Occurs whenever a credit note is updated.', }, { - 'name': 'Credit Note.voided', - 'value': 'credit_note.voided', - 'description': 'Occurs whenever a credit note is voided.', + name: 'Credit Note.voided', + value: 'credit_note.voided', + description: 'Occurs whenever a credit note is voided.', }, { - 'name': 'Customer Created', - 'value': 'customer.created', - 'description': 'Occurs whenever a new customer is created.', + name: 'Customer Created', + value: 'customer.created', + description: 'Occurs whenever a new customer is created.', }, { - 'name': 'Customer Deleted', - 'value': 'customer.deleted', - 'description': 'Occurs whenever a customer is deleted.', + name: 'Customer Deleted', + value: 'customer.deleted', + description: 'Occurs whenever a customer is deleted.', }, { - 'name': 'Customer Updated', - 'value': 'customer.updated', - 'description': 'Occurs whenever any property of a customer changes.', + name: 'Customer Updated', + value: 'customer.updated', + description: 'Occurs whenever any property of a customer changes.', }, { - 'name': 'Customer Discount.created', - 'value': 'customer.discount.created', - 'description': 'Occurs whenever a coupon is attached to a customer.', + name: 'Customer Discount.created', + value: 'customer.discount.created', + description: 'Occurs whenever a coupon is attached to a customer.', }, { - 'name': 'Customer Discount.deleted', - 'value': 'customer.discount.deleted', - 'description': 'Occurs whenever a coupon is removed from a customer.', + name: 'Customer Discount.deleted', + value: 'customer.discount.deleted', + description: 'Occurs whenever a coupon is removed from a customer.', }, { - 'name': 'Customer Discount.updated', - 'value': 'customer.discount.updated', - 'description': 'Occurs whenever a customer is switched from one coupon to another.', + name: 'Customer Discount.updated', + value: 'customer.discount.updated', + description: 'Occurs whenever a customer is switched from one coupon to another.', }, { - 'name': 'Customer Source.created', - 'value': 'customer.source.created', - 'description': 'Occurs whenever a new source is created for a customer.', + name: 'Customer Source.created', + value: 'customer.source.created', + description: 'Occurs whenever a new source is created for a customer.', }, { - 'name': 'Customer Source.deleted', - 'value': 'customer.source.deleted', - 'description': 'Occurs whenever a source is removed from a customer.', + name: 'Customer Source.deleted', + value: 'customer.source.deleted', + description: 'Occurs whenever a source is removed from a customer.', }, { - 'name': 'Customer Source.expiring', - 'value': 'customer.source.expiring', - 'description': 'Occurs whenever a card or source will expire at the end of the month.', + name: 'Customer Source.expiring', + value: 'customer.source.expiring', + description: 'Occurs whenever a card or source will expire at the end of the month.', }, { - 'name': 'Customer Source.updated', - 'value': 'customer.source.updated', - 'description': 'Occurs whenever a source\'s details are changed.', + name: 'Customer Source.updated', + value: 'customer.source.updated', + description: "Occurs whenever a source's details are changed.", }, { - 'name': 'Customer Subscription.created', - 'value': 'customer.subscription.created', - 'description': 'Occurs whenever a customer is signed up for a new plan.', + name: 'Customer Subscription.created', + value: 'customer.subscription.created', + description: 'Occurs whenever a customer is signed up for a new plan.', }, { - 'name': 'Customer Subscription.deleted', - 'value': 'customer.subscription.deleted', - 'description': 'Occurs whenever a customer\'s subscription ends.', + name: 'Customer Subscription.deleted', + value: 'customer.subscription.deleted', + description: "Occurs whenever a customer's subscription ends.", }, { - 'name': 'Customer Subscription.trial_will_end', - 'value': 'customer.subscription.trial_will_end', - 'description': 'Occurs three days before a subscription\'s trial period is scheduled to end, or when a trial is ended immediately (using trial_end=now).', + name: 'Customer Subscription.trial_will_end', + value: 'customer.subscription.trial_will_end', + description: + "Occurs three days before a subscription's trial period is scheduled to end, or when a trial is ended immediately (using trial_end=now).", }, { - 'name': 'Customer Subscription.updated', - 'value': 'customer.subscription.updated', - 'description': 'Occurs whenever a subscription changes (e.g., switching from one plan to another, or changing the status from trial to active).', + name: 'Customer Subscription.updated', + value: 'customer.subscription.updated', + description: + 'Occurs whenever a subscription changes (e.g., switching from one plan to another, or changing the status from trial to active).', }, { - 'name': 'Customer Tax_id.created', - 'value': 'customer.tax_id.created', - 'description': 'Occurs whenever a tax ID is created for a customer.', + name: 'Customer Tax_id.created', + value: 'customer.tax_id.created', + description: 'Occurs whenever a tax ID is created for a customer.', }, { - 'name': 'Customer Tax_id.deleted', - 'value': 'customer.tax_id.deleted', - 'description': 'Occurs whenever a tax ID is deleted from a customer.', + name: 'Customer Tax_id.deleted', + value: 'customer.tax_id.deleted', + description: 'Occurs whenever a tax ID is deleted from a customer.', }, { - 'name': 'Customer Tax_id.updated', - 'value': 'customer.tax_id.updated', - 'description': 'Occurs whenever a customer\'s tax ID is updated.', + name: 'Customer Tax_id.updated', + value: 'customer.tax_id.updated', + description: "Occurs whenever a customer's tax ID is updated.", }, { - 'name': 'File Created', - 'value': 'file.created', - 'description': 'Occurs whenever a new Stripe-generated file is available for your account.', + name: 'File Created', + value: 'file.created', + description: + 'Occurs whenever a new Stripe-generated file is available for your account.', }, { - 'name': 'Invoice Created', - 'value': 'invoice.created', - 'description': 'Occurs whenever a new invoice is created. To learn how webhooks can be used with this event, and how they can affect it, see Using Webhooks with Subscriptions.', + name: 'Invoice Created', + value: 'invoice.created', + description: + 'Occurs whenever a new invoice is created. To learn how webhooks can be used with this event, and how they can affect it, see Using Webhooks with Subscriptions.', }, { - 'name': 'Invoice Deleted', - 'value': 'invoice.deleted', - 'description': 'Occurs whenever a draft invoice is deleted.', + name: 'Invoice Deleted', + value: 'invoice.deleted', + description: 'Occurs whenever a draft invoice is deleted.', }, { - 'name': 'Invoice Finalized', - 'value': 'invoice.finalized', - 'description': 'Occurs whenever a draft invoice is finalized and updated to be an open invoice.', + name: 'Invoice Finalized', + value: 'invoice.finalized', + description: + 'Occurs whenever a draft invoice is finalized and updated to be an open invoice.', }, { - 'name': 'Invoice Marked_uncollectible', - 'value': 'invoice.marked_uncollectible', - 'description': 'Occurs whenever an invoice is marked uncollectible.', + name: 'Invoice Marked_uncollectible', + value: 'invoice.marked_uncollectible', + description: 'Occurs whenever an invoice is marked uncollectible.', }, { - 'name': 'Invoice Payment_action_required', - 'value': 'invoice.payment_action_required', - 'description': 'Occurs whenever an invoice payment attempt requires further user action to complete.', + name: 'Invoice Payment_action_required', + value: 'invoice.payment_action_required', + description: + 'Occurs whenever an invoice payment attempt requires further user action to complete.', }, { - 'name': 'Invoice Payment_failed', - 'value': 'invoice.payment_failed', - 'description': 'Occurs whenever an invoice payment attempt fails, due either to a declined payment or to the lack of a stored payment method.', + name: 'Invoice Payment_failed', + value: 'invoice.payment_failed', + description: + 'Occurs whenever an invoice payment attempt fails, due either to a declined payment or to the lack of a stored payment method.', }, { - 'name': 'Invoice Payment_succeeded', - 'value': 'invoice.payment_succeeded', - 'description': 'Occurs whenever an invoice payment attempt succeeds.', + name: 'Invoice Payment_succeeded', + value: 'invoice.payment_succeeded', + description: 'Occurs whenever an invoice payment attempt succeeds.', }, { - 'name': 'Invoice Sent', - 'value': 'invoice.sent', - 'description': 'Occurs whenever an invoice email is sent out.', + name: 'Invoice Sent', + value: 'invoice.sent', + description: 'Occurs whenever an invoice email is sent out.', }, { - 'name': 'Invoice Upcoming', - 'value': 'invoice.upcoming', - 'description': 'Occurs X number of days before a subscription is scheduled to create an invoice that is automatically charged—where X is determined by your subscriptions settings. Note: The received Invoice object will not have an invoice ID.', + name: 'Invoice Upcoming', + value: 'invoice.upcoming', + description: + 'Occurs X number of days before a subscription is scheduled to create an invoice that is automatically charged—where X is determined by your subscriptions settings. Note: The received Invoice object will not have an invoice ID.', }, { - 'name': 'Invoice Updated', - 'value': 'invoice.updated', - 'description': 'Occurs whenever an invoice changes (e.g., the invoice amount).', + name: 'Invoice Updated', + value: 'invoice.updated', + description: 'Occurs whenever an invoice changes (e.g., the invoice amount).', }, { - 'name': 'Invoice Voided', - 'value': 'invoice.voided', - 'description': 'Occurs whenever an invoice is voided.', + name: 'Invoice Voided', + value: 'invoice.voided', + description: 'Occurs whenever an invoice is voided.', }, { - 'name': 'Invoiceitem Created', - 'value': 'invoiceitem.created', - 'description': 'Occurs whenever an invoice item is created.', + name: 'Invoiceitem Created', + value: 'invoiceitem.created', + description: 'Occurs whenever an invoice item is created.', }, { - 'name': 'Invoiceitem Deleted', - 'value': 'invoiceitem.deleted', - 'description': 'Occurs whenever an invoice item is deleted.', + name: 'Invoiceitem Deleted', + value: 'invoiceitem.deleted', + description: 'Occurs whenever an invoice item is deleted.', }, { - 'name': 'Invoiceitem Updated', - 'value': 'invoiceitem.updated', - 'description': 'Occurs whenever an invoice item is updated.', + name: 'Invoiceitem Updated', + value: 'invoiceitem.updated', + description: 'Occurs whenever an invoice item is updated.', }, { - 'name': 'Issuing Authorization.created', - 'value': 'issuing_authorization.created', - 'description': 'Occurs whenever an authorization is created.', + name: 'Issuing Authorization.created', + value: 'issuing_authorization.created', + description: 'Occurs whenever an authorization is created.', }, { - 'name': 'Issuing Authorization.request', - 'value': 'issuing_authorization.request', - 'description': 'Represents a synchronous request for authorization, see Using your integration to handle authorization requests.', + name: 'Issuing Authorization.request', + value: 'issuing_authorization.request', + description: + 'Represents a synchronous request for authorization, see Using your integration to handle authorization requests.', }, { - 'name': 'Issuing Authorization.updated', - 'value': 'issuing_authorization.updated', - 'description': 'Occurs whenever an authorization is updated.', + name: 'Issuing Authorization.updated', + value: 'issuing_authorization.updated', + description: 'Occurs whenever an authorization is updated.', }, { - 'name': 'Issuing Card.created', - 'value': 'issuing_card.created', - 'description': 'Occurs whenever a card is created.', + name: 'Issuing Card.created', + value: 'issuing_card.created', + description: 'Occurs whenever a card is created.', }, { - 'name': 'Issuing Card.updated', - 'value': 'issuing_card.updated', - 'description': 'Occurs whenever a card is updated.', + name: 'Issuing Card.updated', + value: 'issuing_card.updated', + description: 'Occurs whenever a card is updated.', }, { - 'name': 'Issuing Cardholder.created', - 'value': 'issuing_cardholder.created', - 'description': 'Occurs whenever a cardholder is created.', + name: 'Issuing Cardholder.created', + value: 'issuing_cardholder.created', + description: 'Occurs whenever a cardholder is created.', }, { - 'name': 'Issuing Cardholder.updated', - 'value': 'issuing_cardholder.updated', - 'description': 'Occurs whenever a cardholder is updated.', + name: 'Issuing Cardholder.updated', + value: 'issuing_cardholder.updated', + description: 'Occurs whenever a cardholder is updated.', }, { - 'name': 'Issuing Dispute.created', - 'value': 'issuing_dispute.created', - 'description': 'Occurs whenever a dispute is created.', + name: 'Issuing Dispute.created', + value: 'issuing_dispute.created', + description: 'Occurs whenever a dispute is created.', }, { - 'name': 'Issuing Dispute.updated', - 'value': 'issuing_dispute.updated', - 'description': 'Occurs whenever a dispute is updated.', + name: 'Issuing Dispute.updated', + value: 'issuing_dispute.updated', + description: 'Occurs whenever a dispute is updated.', }, { - 'name': 'Issuing Settlement.created', - 'value': 'issuing_settlement.created', - 'description': 'Occurs whenever an issuing settlement is created.', + name: 'Issuing Settlement.created', + value: 'issuing_settlement.created', + description: 'Occurs whenever an issuing settlement is created.', }, { - 'name': 'Issuing Settlement.updated', - 'value': 'issuing_settlement.updated', - 'description': 'Occurs whenever an issuing settlement is updated.', + name: 'Issuing Settlement.updated', + value: 'issuing_settlement.updated', + description: 'Occurs whenever an issuing settlement is updated.', }, { - 'name': 'Issuing Transaction.created', - 'value': 'issuing_transaction.created', - 'description': 'Occurs whenever an issuing transaction is created.', + name: 'Issuing Transaction.created', + value: 'issuing_transaction.created', + description: 'Occurs whenever an issuing transaction is created.', }, { - 'name': 'Issuing Transaction.updated', - 'value': 'issuing_transaction.updated', - 'description': 'Occurs whenever an issuing transaction is updated.', + name: 'Issuing Transaction.updated', + value: 'issuing_transaction.updated', + description: 'Occurs whenever an issuing transaction is updated.', }, { - 'name': 'Order Created', - 'value': 'order.created', - 'description': 'Occurs whenever an order is created.', + name: 'Order Created', + value: 'order.created', + description: 'Occurs whenever an order is created.', }, { - 'name': 'Order Payment_failed', - 'value': 'order.payment_failed', - 'description': 'Occurs whenever an order payment attempt fails.', + name: 'Order Payment_failed', + value: 'order.payment_failed', + description: 'Occurs whenever an order payment attempt fails.', }, { - 'name': 'Order Payment_succeeded', - 'value': 'order.payment_succeeded', - 'description': 'Occurs whenever an order payment attempt succeeds.', + name: 'Order Payment_succeeded', + value: 'order.payment_succeeded', + description: 'Occurs whenever an order payment attempt succeeds.', }, { - 'name': 'Order Updated', - 'value': 'order.updated', - 'description': 'Occurs whenever an order is updated.', + name: 'Order Updated', + value: 'order.updated', + description: 'Occurs whenever an order is updated.', }, { - 'name': 'Order Return.created', - 'value': 'order_return.created', - 'description': 'Occurs whenever an order return is created.', + name: 'Order Return.created', + value: 'order_return.created', + description: 'Occurs whenever an order return is created.', }, { - 'name': 'Payment Intent.amount_capturable_updated', - 'value': 'payment_intent.amount_capturable_updated', - 'description': 'Occurs when a PaymentIntent has funds to be captured. Check the amount_capturable property on the PaymentIntent to determine the amount that can be captured. You may capture the PaymentIntent with an amount_to_capture value up to the specified amount. Learn more about capturing PaymentIntents.', + name: 'Payment Intent.amount_capturable_updated', + value: 'payment_intent.amount_capturable_updated', + description: + 'Occurs when a PaymentIntent has funds to be captured. Check the amount_capturable property on the PaymentIntent to determine the amount that can be captured. You may capture the PaymentIntent with an amount_to_capture value up to the specified amount. Learn more about capturing PaymentIntents.', }, { - 'name': 'Payment Intent.canceled', - 'value': 'payment_intent.canceled', - 'description': 'Occurs when a PaymentIntent is canceled.', + name: 'Payment Intent.canceled', + value: 'payment_intent.canceled', + description: 'Occurs when a PaymentIntent is canceled.', }, { - 'name': 'Payment Intent.created', - 'value': 'payment_intent.created', - 'description': 'Occurs when a new PaymentIntent is created.', + name: 'Payment Intent.created', + value: 'payment_intent.created', + description: 'Occurs when a new PaymentIntent is created.', }, { - 'name': 'Payment Intent.payment_failed', - 'value': 'payment_intent.payment_failed', - 'description': 'Occurs when a PaymentIntent has failed the attempt to create a source or a payment.', + name: 'Payment Intent.payment_failed', + value: 'payment_intent.payment_failed', + description: + 'Occurs when a PaymentIntent has failed the attempt to create a source or a payment.', }, { - 'name': 'Payment Intent.succeeded', - 'value': 'payment_intent.succeeded', - 'description': 'Occurs when a PaymentIntent has been successfully fulfilled.', + name: 'Payment Intent.succeeded', + value: 'payment_intent.succeeded', + description: 'Occurs when a PaymentIntent has been successfully fulfilled.', }, { - 'name': 'Payment Method.attached', - 'value': 'payment_method.attached', - 'description': 'Occurs whenever a new payment method is attached to a customer.', + name: 'Payment Method.attached', + value: 'payment_method.attached', + description: 'Occurs whenever a new payment method is attached to a customer.', }, { - 'name': 'Payment Method.card_automatically_updated', - 'value': 'payment_method.card_automatically_updated', - 'description': 'Occurs whenever a card payment method\'s details are automatically updated by the network.', + name: 'Payment Method.card_automatically_updated', + value: 'payment_method.card_automatically_updated', + description: + "Occurs whenever a card payment method's details are automatically updated by the network.", }, { - 'name': 'Payment Method.detached', - 'value': 'payment_method.detached', - 'description': 'Occurs whenever a payment method is detached from a customer.', + name: 'Payment Method.detached', + value: 'payment_method.detached', + description: 'Occurs whenever a payment method is detached from a customer.', }, { - 'name': 'Payment Method.updated', - 'value': 'payment_method.updated', - 'description': 'Occurs whenever a payment method is updated via the PaymentMethod update API.', + name: 'Payment Method.updated', + value: 'payment_method.updated', + description: + 'Occurs whenever a payment method is updated via the PaymentMethod update API.', }, { - 'name': 'Payout Canceled', - 'value': 'payout.canceled', - 'description': 'Occurs whenever a payout is canceled.', + name: 'Payout Canceled', + value: 'payout.canceled', + description: 'Occurs whenever a payout is canceled.', }, { - 'name': 'Payout Created', - 'value': 'payout.created', - 'description': 'Occurs whenever a payout is created.', + name: 'Payout Created', + value: 'payout.created', + description: 'Occurs whenever a payout is created.', }, { - 'name': 'Payout Failed', - 'value': 'payout.failed', - 'description': 'Occurs whenever a payout attempt fails.', + name: 'Payout Failed', + value: 'payout.failed', + description: 'Occurs whenever a payout attempt fails.', }, { - 'name': 'Payout Paid', - 'value': 'payout.paid', - 'description': 'Occurs whenever a payout is expected to be available in the destination account. If the payout fails, a payout.failed notification is also sent, at a later time.', + name: 'Payout Paid', + value: 'payout.paid', + description: + 'Occurs whenever a payout is expected to be available in the destination account. If the payout fails, a payout.failed notification is also sent, at a later time.', }, { - 'name': 'Payout Updated', - 'value': 'payout.updated', - 'description': 'Occurs whenever a payout is updated.', + name: 'Payout Updated', + value: 'payout.updated', + description: 'Occurs whenever a payout is updated.', }, { - 'name': 'Person Created', - 'value': 'person.created', - 'description': 'Occurs whenever a person associated with an account is created.', + name: 'Person Created', + value: 'person.created', + description: 'Occurs whenever a person associated with an account is created.', }, { - 'name': 'Person Deleted', - 'value': 'person.deleted', - 'description': 'Occurs whenever a person associated with an account is deleted.', + name: 'Person Deleted', + value: 'person.deleted', + description: 'Occurs whenever a person associated with an account is deleted.', }, { - 'name': 'Person Updated', - 'value': 'person.updated', - 'description': 'Occurs whenever a person associated with an account is updated.', + name: 'Person Updated', + value: 'person.updated', + description: 'Occurs whenever a person associated with an account is updated.', }, { - 'name': 'Plan Created', - 'value': 'plan.created', - 'description': 'Occurs whenever a plan is created.', + name: 'Plan Created', + value: 'plan.created', + description: 'Occurs whenever a plan is created.', }, { - 'name': 'Plan Deleted', - 'value': 'plan.deleted', - 'description': 'Occurs whenever a plan is deleted.', + name: 'Plan Deleted', + value: 'plan.deleted', + description: 'Occurs whenever a plan is deleted.', }, { - 'name': 'Plan Updated', - 'value': 'plan.updated', - 'description': 'Occurs whenever a plan is updated.', + name: 'Plan Updated', + value: 'plan.updated', + description: 'Occurs whenever a plan is updated.', }, { - 'name': 'Product Created', - 'value': 'product.created', - 'description': 'Occurs whenever a product is created.', + name: 'Product Created', + value: 'product.created', + description: 'Occurs whenever a product is created.', }, { - 'name': 'Product Deleted', - 'value': 'product.deleted', - 'description': 'Occurs whenever a product is deleted.', + name: 'Product Deleted', + value: 'product.deleted', + description: 'Occurs whenever a product is deleted.', }, { - 'name': 'Product Updated', - 'value': 'product.updated', - 'description': 'Occurs whenever a product is updated.', + name: 'Product Updated', + value: 'product.updated', + description: 'Occurs whenever a product is updated.', }, { - 'name': 'Radar Early_fraud_warning.created', - 'value': 'radar.early_fraud_warning.created', - 'description': 'Occurs whenever an early fraud warning is created.', + name: 'Radar Early_fraud_warning.created', + value: 'radar.early_fraud_warning.created', + description: 'Occurs whenever an early fraud warning is created.', }, { - 'name': 'Radar Early_fraud_warning.updated', - 'value': 'radar.early_fraud_warning.updated', - 'description': 'Occurs whenever an early fraud warning is updated.', + name: 'Radar Early_fraud_warning.updated', + value: 'radar.early_fraud_warning.updated', + description: 'Occurs whenever an early fraud warning is updated.', }, { - 'name': 'Recipient Created', - 'value': 'recipient.created', - 'description': 'Occurs whenever a recipient is created.', + name: 'Recipient Created', + value: 'recipient.created', + description: 'Occurs whenever a recipient is created.', }, { - 'name': 'Recipient Deleted', - 'value': 'recipient.deleted', - 'description': 'Occurs whenever a recipient is deleted.', + name: 'Recipient Deleted', + value: 'recipient.deleted', + description: 'Occurs whenever a recipient is deleted.', }, { - 'name': 'Recipient Updated', - 'value': 'recipient.updated', - 'description': 'Occurs whenever a recipient is updated.', + name: 'Recipient Updated', + value: 'recipient.updated', + description: 'Occurs whenever a recipient is updated.', }, { - 'name': 'Reporting Report_run.failed', - 'value': 'reporting.report_run.failed', - 'description': 'Occurs whenever a requested **ReportRun** failed to complete.', + name: 'Reporting Report_run.failed', + value: 'reporting.report_run.failed', + description: 'Occurs whenever a requested **ReportRun** failed to complete.', }, { - 'name': 'Reporting Report_run.succeeded', - 'value': 'reporting.report_run.succeeded', - 'description': 'Occurs whenever a requested **ReportRun** completed succesfully.', + name: 'Reporting Report_run.succeeded', + value: 'reporting.report_run.succeeded', + description: 'Occurs whenever a requested **ReportRun** completed succesfully.', }, { - 'name': 'Reporting Report_type.updated', - 'value': 'reporting.report_type.updated', - 'description': 'Occurs whenever a **ReportType** is updated (typically to indicate that a new day\'s data has come available).', + name: 'Reporting Report_type.updated', + value: 'reporting.report_type.updated', + description: + "Occurs whenever a **ReportType** is updated (typically to indicate that a new day's data has come available).", }, { - 'name': 'Review Closed', - 'value': 'review.closed', - 'description': 'Occurs whenever a review is closed. The review\'s reason field indicates why: approved, disputed, refunded, or refunded_as_fraud.', + name: 'Review Closed', + value: 'review.closed', + description: + "Occurs whenever a review is closed. The review's reason field indicates why: approved, disputed, refunded, or refunded_as_fraud.", }, { - 'name': 'Review Opened', - 'value': 'review.opened', - 'description': 'Occurs whenever a review is opened.', + name: 'Review Opened', + value: 'review.opened', + description: 'Occurs whenever a review is opened.', }, { - 'name': 'Setup Intent.canceled', - 'value': 'setup_intent.canceled', - 'description': 'Occurs when a SetupIntent is canceled.', + name: 'Setup Intent.canceled', + value: 'setup_intent.canceled', + description: 'Occurs when a SetupIntent is canceled.', }, { - 'name': 'Setup Intent.created', - 'value': 'setup_intent.created', - 'description': 'Occurs when a new SetupIntent is created.', + name: 'Setup Intent.created', + value: 'setup_intent.created', + description: 'Occurs when a new SetupIntent is created.', }, { - 'name': 'Setup Intent.setup_failed', - 'value': 'setup_intent.setup_failed', - 'description': 'Occurs when a SetupIntent has failed the attempt to setup a payment method.', + name: 'Setup Intent.setup_failed', + value: 'setup_intent.setup_failed', + description: + 'Occurs when a SetupIntent has failed the attempt to setup a payment method.', }, { - 'name': 'Setup Intent.succeeded', - 'value': 'setup_intent.succeeded', - 'description': 'Occurs when an SetupIntent has successfully setup a payment method.', + name: 'Setup Intent.succeeded', + value: 'setup_intent.succeeded', + description: 'Occurs when an SetupIntent has successfully setup a payment method.', }, { - 'name': 'Sigma Scheduled_query_run.created', - 'value': 'sigma.scheduled_query_run.created', - 'description': 'Occurs whenever a Sigma scheduled query run finishes.', + name: 'Sigma Scheduled_query_run.created', + value: 'sigma.scheduled_query_run.created', + description: 'Occurs whenever a Sigma scheduled query run finishes.', }, { - 'name': 'Sku Created', - 'value': 'sku.created', - 'description': 'Occurs whenever a SKU is created.', + name: 'Sku Created', + value: 'sku.created', + description: 'Occurs whenever a SKU is created.', }, { - 'name': 'Sku Deleted', - 'value': 'sku.deleted', - 'description': 'Occurs whenever a SKU is deleted.', + name: 'Sku Deleted', + value: 'sku.deleted', + description: 'Occurs whenever a SKU is deleted.', }, { - 'name': 'Sku Updated', - 'value': 'sku.updated', - 'description': 'Occurs whenever a SKU is updated.', + name: 'Sku Updated', + value: 'sku.updated', + description: 'Occurs whenever a SKU is updated.', }, { - 'name': 'Source Canceled', - 'value': 'source.canceled', - 'description': 'Occurs whenever a source is canceled.', + name: 'Source Canceled', + value: 'source.canceled', + description: 'Occurs whenever a source is canceled.', }, { - 'name': 'Source Chargeable', - 'value': 'source.chargeable', - 'description': 'Occurs whenever a source transitions to chargeable.', + name: 'Source Chargeable', + value: 'source.chargeable', + description: 'Occurs whenever a source transitions to chargeable.', }, { - 'name': 'Source Failed', - 'value': 'source.failed', - 'description': 'Occurs whenever a source fails.', + name: 'Source Failed', + value: 'source.failed', + description: 'Occurs whenever a source fails.', }, { - 'name': 'Source Mandate_notification', - 'value': 'source.mandate_notification', - 'description': 'Occurs whenever a source mandate notification method is set to manual.', + name: 'Source Mandate_notification', + value: 'source.mandate_notification', + description: 'Occurs whenever a source mandate notification method is set to manual.', }, { - 'name': 'Source Refund_attributes_required', - 'value': 'source.refund_attributes_required', - 'description': 'Occurs whenever the refund attributes are required on a receiver source to process a refund or a mispayment.', + name: 'Source Refund_attributes_required', + value: 'source.refund_attributes_required', + description: + 'Occurs whenever the refund attributes are required on a receiver source to process a refund or a mispayment.', }, { - 'name': 'Source Transaction.created', - 'value': 'source.transaction.created', - 'description': 'Occurs whenever a source transaction is created.', + name: 'Source Transaction.created', + value: 'source.transaction.created', + description: 'Occurs whenever a source transaction is created.', }, { - 'name': 'Source Transaction.updated', - 'value': 'source.transaction.updated', - 'description': 'Occurs whenever a source transaction is updated.', + name: 'Source Transaction.updated', + value: 'source.transaction.updated', + description: 'Occurs whenever a source transaction is updated.', }, { - 'name': 'Subscription Schedule.aborted', - 'value': 'subscription_schedule.aborted', - 'description': 'Occurs whenever a subscription schedule is canceled due to the underlying subscription being canceled because of delinquency.', + name: 'Subscription Schedule.aborted', + value: 'subscription_schedule.aborted', + description: + 'Occurs whenever a subscription schedule is canceled due to the underlying subscription being canceled because of delinquency.', }, { - 'name': 'Subscription Schedule.canceled', - 'value': 'subscription_schedule.canceled', - 'description': 'Occurs whenever a subscription schedule is canceled.', + name: 'Subscription Schedule.canceled', + value: 'subscription_schedule.canceled', + description: 'Occurs whenever a subscription schedule is canceled.', }, { - 'name': 'Subscription Schedule.completed', - 'value': 'subscription_schedule.completed', - 'description': 'Occurs whenever a new subscription schedule is completed.', + name: 'Subscription Schedule.completed', + value: 'subscription_schedule.completed', + description: 'Occurs whenever a new subscription schedule is completed.', }, { - 'name': 'Subscription Schedule.created', - 'value': 'subscription_schedule.created', - 'description': 'Occurs whenever a new subscription schedule is created.', + name: 'Subscription Schedule.created', + value: 'subscription_schedule.created', + description: 'Occurs whenever a new subscription schedule is created.', }, { - 'name': 'Subscription Schedule.expiring', - 'value': 'subscription_schedule.expiring', - 'description': 'Occurs 7 days before a subscription schedule will expire.', + name: 'Subscription Schedule.expiring', + value: 'subscription_schedule.expiring', + description: 'Occurs 7 days before a subscription schedule will expire.', }, { - 'name': 'Subscription Schedule.released', - 'value': 'subscription_schedule.released', - 'description': 'Occurs whenever a new subscription schedule is released.', + name: 'Subscription Schedule.released', + value: 'subscription_schedule.released', + description: 'Occurs whenever a new subscription schedule is released.', }, { - 'name': 'Subscription Schedule.updated', - 'value': 'subscription_schedule.updated', - 'description': 'Occurs whenever a subscription schedule is updated.', + name: 'Subscription Schedule.updated', + value: 'subscription_schedule.updated', + description: 'Occurs whenever a subscription schedule is updated.', }, { - 'name': 'Tax Rate.created', - 'value': 'tax_rate.created', - 'description': 'Occurs whenever a new tax rate is created.', + name: 'Tax Rate.created', + value: 'tax_rate.created', + description: 'Occurs whenever a new tax rate is created.', }, { - 'name': 'Tax Rate.updated', - 'value': 'tax_rate.updated', - 'description': 'Occurs whenever a tax rate is updated.', + name: 'Tax Rate.updated', + value: 'tax_rate.updated', + description: 'Occurs whenever a tax rate is updated.', }, { - 'name': 'Topup Canceled', - 'value': 'topup.canceled', - 'description': 'Occurs whenever a top-up is canceled.', + name: 'Topup Canceled', + value: 'topup.canceled', + description: 'Occurs whenever a top-up is canceled.', }, { - 'name': 'Topup Created', - 'value': 'topup.created', - 'description': 'Occurs whenever a top-up is created.', + name: 'Topup Created', + value: 'topup.created', + description: 'Occurs whenever a top-up is created.', }, { - 'name': 'Topup Failed', - 'value': 'topup.failed', - 'description': 'Occurs whenever a top-up fails.', + name: 'Topup Failed', + value: 'topup.failed', + description: 'Occurs whenever a top-up fails.', }, { - 'name': 'Topup Reversed', - 'value': 'topup.reversed', - 'description': 'Occurs whenever a top-up is reversed.', + name: 'Topup Reversed', + value: 'topup.reversed', + description: 'Occurs whenever a top-up is reversed.', }, { - 'name': 'Topup Succeeded', - 'value': 'topup.succeeded', - 'description': 'Occurs whenever a top-up succeeds.', + name: 'Topup Succeeded', + value: 'topup.succeeded', + description: 'Occurs whenever a top-up succeeds.', }, { - 'name': 'Transfer Created', - 'value': 'transfer.created', - 'description': 'Occurs whenever a transfer is created.', + name: 'Transfer Created', + value: 'transfer.created', + description: 'Occurs whenever a transfer is created.', }, { - 'name': 'Transfer Failed', - 'value': 'transfer.failed', - 'description': 'Occurs whenever a transfer failed.', + name: 'Transfer Failed', + value: 'transfer.failed', + description: 'Occurs whenever a transfer failed.', }, { - 'name': 'Transfer Paid', - 'value': 'transfer.paid', - 'description': 'Occurs after a transfer is paid. For Instant Payouts, the event will be sent on the next business day, although the funds should be received well beforehand.', + name: 'Transfer Paid', + value: 'transfer.paid', + description: + 'Occurs after a transfer is paid. For Instant Payouts, the event will be sent on the next business day, although the funds should be received well beforehand.', }, { - 'name': 'Transfer Reversed', - 'value': 'transfer.reversed', - 'description': 'Occurs whenever a transfer is reversed, including partial reversals.', + name: 'Transfer Reversed', + value: 'transfer.reversed', + description: 'Occurs whenever a transfer is reversed, including partial reversals.', }, { - 'name': 'Transfer Updated', - 'value': 'transfer.updated', - 'description': 'Occurs whenever a transfer\'s description or metadata is updated.', + name: 'Transfer Updated', + value: 'transfer.updated', + description: "Occurs whenever a transfer's description or metadata is updated.", }, ], }, @@ -854,9 +877,15 @@ export class StripeTrigger implements INodeType { throw error; } - if (responseData.id === undefined || responseData.secret === undefined || responseData.status !== 'enabled') { + if ( + responseData.id === undefined || + responseData.secret === undefined || + responseData.status !== 'enabled' + ) { // Required data is missing so was not successful - throw new NodeApiError(this.getNode(), responseData, { message: 'Stripe webhook creation response did not contain the expected data.' }); + throw new NodeApiError(this.getNode(), responseData, { + message: 'Stripe webhook creation response did not contain the expected data.', + }); } const webhookData = this.getWorkflowStaticData('node'); @@ -899,16 +928,14 @@ export class StripeTrigger implements INodeType { const eventType = bodyData.type as string | undefined; - if (eventType === undefined || !events.includes('*') && !events.includes(eventType)) { + if (eventType === undefined || (!events.includes('*') && !events.includes(eventType))) { // If not eventType is defined or when one is defined but we are not // listening to it do not start the workflow. return {}; } return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/Stripe/descriptions/BalanceDescription.ts b/packages/nodes-base/nodes/Stripe/descriptions/BalanceDescription.ts index 7dea13cb59..6e5a944d04 100644 --- a/packages/nodes-base/nodes/Stripe/descriptions/BalanceDescription.ts +++ b/packages/nodes-base/nodes/Stripe/descriptions/BalanceDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const balanceOperations: INodeProperties[] = [ { @@ -19,9 +17,7 @@ export const balanceOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'balance', - ], + resource: ['balance'], }, }, }, diff --git a/packages/nodes-base/nodes/Stripe/descriptions/ChargeDescription.ts b/packages/nodes-base/nodes/Stripe/descriptions/ChargeDescription.ts index f93335b220..5b0ab3a5b9 100644 --- a/packages/nodes-base/nodes/Stripe/descriptions/ChargeDescription.ts +++ b/packages/nodes-base/nodes/Stripe/descriptions/ChargeDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const chargeOperations: INodeProperties[] = [ { @@ -37,9 +35,7 @@ export const chargeOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'charge', - ], + resource: ['charge'], }, }, }, @@ -58,12 +54,8 @@ export const chargeFields: INodeProperties[] = [ description: 'ID of the customer to be associated with this charge', displayOptions: { show: { - resource: [ - 'charge', - ], - operation: [ - 'create', - ], + resource: ['charge'], + operation: ['create'], }, }, }, @@ -73,19 +65,16 @@ export const chargeFields: INodeProperties[] = [ type: 'number', required: true, default: 0, - description: 'Amount in cents to be collected for this charge, e.g. enter 100 for $1.00', + description: + 'Amount in cents to be collected for this charge, e.g. enter 100 for $1.00', typeOptions: { minValue: 0, maxValue: 99999999, }, displayOptions: { show: { - resource: [ - 'charge', - ], - operation: [ - 'create', - ], + resource: ['charge'], + operation: ['create'], }, }, }, @@ -98,15 +87,12 @@ export const chargeFields: INodeProperties[] = [ }, required: true, default: '', - description: 'Three-letter ISO currency code, e.g. USD or EUR. It must be a Stripe-supported currency. Choose from the list, or specify an ID using an expression.', + description: + 'Three-letter ISO currency code, e.g. USD or EUR. It must be a Stripe-supported currency. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'charge', - ], - operation: [ - 'create', - ], + resource: ['charge'], + operation: ['create'], }, }, }, @@ -116,15 +102,11 @@ export const chargeFields: INodeProperties[] = [ type: 'string', required: true, default: '', - description: 'ID of the customer\'s payment source to be charged', + description: "ID of the customer's payment source to be charged", displayOptions: { show: { - resource: [ - 'charge', - ], - operation: [ - 'create', - ], + resource: ['charge'], + operation: ['create'], }, }, }, @@ -136,12 +118,8 @@ export const chargeFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'charge', - ], - operation: [ - 'create', - ], + resource: ['charge'], + operation: ['create'], }, }, options: [ @@ -254,7 +232,8 @@ export const chargeFields: INodeProperties[] = [ { displayName: 'Country', name: 'country', - description: 'Two-letter country code (ISO 3166-1 alpha-2)', + description: + 'Two-letter country code (ISO 3166-1 alpha-2)', type: 'string', default: '', }, @@ -288,12 +267,8 @@ export const chargeFields: INodeProperties[] = [ description: 'ID of the charge to retrieve', displayOptions: { show: { - resource: [ - 'charge', - ], - operation: [ - 'get', - ], + resource: ['charge'], + operation: ['get'], }, }, }, @@ -309,12 +284,8 @@ export const chargeFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'charge', - ], - operation: [ - 'getAll', - ], + resource: ['charge'], + operation: ['getAll'], }, }, }, @@ -330,15 +301,9 @@ export const chargeFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'charge', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['charge'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -355,12 +320,8 @@ export const chargeFields: INodeProperties[] = [ description: 'ID of the charge to update', displayOptions: { show: { - resource: [ - 'charge', - ], - operation: [ - 'update', - ], + resource: ['charge'], + operation: ['update'], }, }, }, @@ -372,12 +333,8 @@ export const chargeFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'charge', - ], - operation: [ - 'update', - ], + resource: ['charge'], + operation: ['update'], }, }, options: [ @@ -490,7 +447,8 @@ export const chargeFields: INodeProperties[] = [ { displayName: 'Country', name: 'country', - description: 'Two-letter country code (ISO 3166-1 alpha-2)', + description: + 'Two-letter country code (ISO 3166-1 alpha-2)', type: 'string', default: '', }, @@ -511,5 +469,4 @@ export const chargeFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Stripe/descriptions/CouponDescription.ts b/packages/nodes-base/nodes/Stripe/descriptions/CouponDescription.ts index 490cf201e9..7fc0032070 100644 --- a/packages/nodes-base/nodes/Stripe/descriptions/CouponDescription.ts +++ b/packages/nodes-base/nodes/Stripe/descriptions/CouponDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const couponOperations: INodeProperties[] = [ { @@ -25,9 +23,7 @@ export const couponOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'coupon', - ], + resource: ['coupon'], }, }, }, @@ -56,12 +52,8 @@ export const couponFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - 'create', - ], + resource: ['coupon'], + operation: ['create'], }, }, }, @@ -84,12 +76,8 @@ export const couponFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - 'create', - ], + resource: ['coupon'], + operation: ['create'], }, }, }, @@ -99,22 +87,17 @@ export const couponFields: INodeProperties[] = [ type: 'number', required: true, default: 0, - description: 'Amount in cents to subtract from an invoice total, e.g. enter 100 for $1.00', + description: + 'Amount in cents to subtract from an invoice total, e.g. enter 100 for $1.00', typeOptions: { minValue: 0, maxValue: 99999999, }, displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - 'create', - ], - type: [ - 'fixedAmount', - ], + resource: ['coupon'], + operation: ['create'], + type: ['fixedAmount'], }, }, }, @@ -127,18 +110,13 @@ export const couponFields: INodeProperties[] = [ }, required: true, default: '', - description: 'Three-letter ISO currency code, e.g. USD or EUR. It must be a Stripe-supported currency. Choose from the list, or specify an ID using an expression.', + description: + 'Three-letter ISO currency code, e.g. USD or EUR. It must be a Stripe-supported currency. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - 'create', - ], - type: [ - 'fixedAmount', - ], + resource: ['coupon'], + operation: ['create'], + type: ['fixedAmount'], }, }, }, @@ -155,15 +133,9 @@ export const couponFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - 'create', - ], - type: [ - 'percent', - ], + resource: ['coupon'], + operation: ['create'], + type: ['percent'], }, }, }, @@ -179,12 +151,8 @@ export const couponFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - 'getAll', - ], + resource: ['coupon'], + operation: ['getAll'], }, }, }, @@ -200,15 +168,9 @@ export const couponFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'coupon', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['coupon'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Stripe/descriptions/CustomerCardDescription.ts b/packages/nodes-base/nodes/Stripe/descriptions/CustomerCardDescription.ts index 75e99e9fc5..2ec4e63951 100644 --- a/packages/nodes-base/nodes/Stripe/descriptions/CustomerCardDescription.ts +++ b/packages/nodes-base/nodes/Stripe/descriptions/CustomerCardDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const customerCardOperations: INodeProperties[] = [ { @@ -31,9 +29,7 @@ export const customerCardOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'customerCard', - ], + resource: ['customerCard'], }, }, }, @@ -52,12 +48,8 @@ export const customerCardFields: INodeProperties[] = [ description: 'ID of the customer to be associated with this card', displayOptions: { show: { - resource: [ - 'customerCard', - ], - operation: [ - 'add', - ], + resource: ['customerCard'], + operation: ['add'], }, }, }, @@ -71,12 +63,8 @@ export const customerCardFields: INodeProperties[] = [ description: 'Token representing sensitive card information', displayOptions: { show: { - resource: [ - 'customerCard', - ], - operation: [ - 'add', - ], + resource: ['customerCard'], + operation: ['add'], }, }, }, @@ -93,12 +81,8 @@ export const customerCardFields: INodeProperties[] = [ description: 'ID of the customer whose card to remove', displayOptions: { show: { - resource: [ - 'customerCard', - ], - operation: [ - 'remove', - ], + resource: ['customerCard'], + operation: ['remove'], }, }, }, @@ -111,12 +95,8 @@ export const customerCardFields: INodeProperties[] = [ description: 'ID of the card to remove', displayOptions: { show: { - resource: [ - 'customerCard', - ], - operation: [ - 'remove', - ], + resource: ['customerCard'], + operation: ['remove'], }, }, }, @@ -133,12 +113,8 @@ export const customerCardFields: INodeProperties[] = [ description: 'ID of the customer whose card to retrieve', displayOptions: { show: { - resource: [ - 'customerCard', - ], - operation: [ - 'get', - ], + resource: ['customerCard'], + operation: ['get'], }, }, }, @@ -151,12 +127,8 @@ export const customerCardFields: INodeProperties[] = [ description: 'ID of the source to retrieve', displayOptions: { show: { - resource: [ - 'customerCard', - ], - operation: [ - 'get', - ], + resource: ['customerCard'], + operation: ['get'], }, }, }, diff --git a/packages/nodes-base/nodes/Stripe/descriptions/CustomerDescription.ts b/packages/nodes-base/nodes/Stripe/descriptions/CustomerDescription.ts index 57166e0dc9..bc2c596c5d 100644 --- a/packages/nodes-base/nodes/Stripe/descriptions/CustomerDescription.ts +++ b/packages/nodes-base/nodes/Stripe/descriptions/CustomerDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const customerOperations: INodeProperties[] = [ { @@ -43,9 +41,7 @@ export const customerOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'customer', - ], + resource: ['customer'], }, }, }, @@ -64,12 +60,8 @@ export const customerFields: INodeProperties[] = [ description: 'Full name or business name of the customer to create', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'create', - ], + resource: ['customer'], + operation: ['create'], }, }, }, @@ -81,12 +73,8 @@ export const customerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'create', - ], + resource: ['customer'], + operation: ['create'], }, }, options: [ @@ -133,7 +121,8 @@ export const customerFields: INodeProperties[] = [ { displayName: 'Country', name: 'country', - description: 'Two-letter country code (ISO 3166-1 alpha-2)', + description: + 'Two-letter country code (ISO 3166-1 alpha-2)', type: 'string', default: '', }, @@ -264,7 +253,8 @@ export const customerFields: INodeProperties[] = [ { displayName: 'Country', name: 'country', - description: 'Two-letter country code (ISO 3166-1 alpha-2)', + description: + 'Two-letter country code (ISO 3166-1 alpha-2)', type: 'string', default: '', }, @@ -304,12 +294,8 @@ export const customerFields: INodeProperties[] = [ description: 'ID of the customer to delete', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'delete', - ], + resource: ['customer'], + operation: ['delete'], }, }, }, @@ -326,12 +312,8 @@ export const customerFields: INodeProperties[] = [ description: 'ID of the customer to retrieve', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'get', - ], + resource: ['customer'], + operation: ['get'], }, }, }, @@ -347,12 +329,8 @@ export const customerFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'getAll', - ], + resource: ['customer'], + operation: ['getAll'], }, }, }, @@ -368,15 +346,9 @@ export const customerFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['customer'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -388,12 +360,8 @@ export const customerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'getAll', - ], + resource: ['customer'], + operation: ['getAll'], }, }, options: [ @@ -403,7 +371,7 @@ export const customerFields: INodeProperties[] = [ type: 'string', placeholder: 'name@email.com', default: '', - description: 'Customer\'s email to filter by', + description: "Customer's email to filter by", }, ], }, @@ -420,12 +388,8 @@ export const customerFields: INodeProperties[] = [ description: 'ID of the customer to update', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'update', - ], + resource: ['customer'], + operation: ['update'], }, }, }, @@ -437,12 +401,8 @@ export const customerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'update', - ], + resource: ['customer'], + operation: ['update'], }, }, options: [ @@ -489,7 +449,8 @@ export const customerFields: INodeProperties[] = [ { displayName: 'Country', name: 'country', - description: 'Two-letter country code (ISO 3166-1 alpha-2)', + description: + 'Two-letter country code (ISO 3166-1 alpha-2)', type: 'string', default: '', }, @@ -628,7 +589,8 @@ export const customerFields: INodeProperties[] = [ { displayName: 'Country', name: 'country', - description: 'Two-letter country code (ISO 3166-1 alpha-2)', + description: + 'Two-letter country code (ISO 3166-1 alpha-2)', type: 'string', default: '', }, diff --git a/packages/nodes-base/nodes/Stripe/descriptions/SourceDescription.ts b/packages/nodes-base/nodes/Stripe/descriptions/SourceDescription.ts index 4b07e2ab51..e8610a41a8 100644 --- a/packages/nodes-base/nodes/Stripe/descriptions/SourceDescription.ts +++ b/packages/nodes-base/nodes/Stripe/descriptions/SourceDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const sourceOperations: INodeProperties[] = [ { @@ -31,9 +29,7 @@ export const sourceOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'source', - ], + resource: ['source'], }, }, }, @@ -52,12 +48,8 @@ export const sourceFields: INodeProperties[] = [ description: 'ID of the customer to attach the source to', displayOptions: { show: { - resource: [ - 'source', - ], - operation: [ - 'create', - ], + resource: ['source'], + operation: ['create'], }, }, }, @@ -76,12 +68,8 @@ export const sourceFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'source', - ], - operation: [ - 'create', - ], + resource: ['source'], + operation: ['create'], }, }, }, @@ -90,19 +78,16 @@ export const sourceFields: INodeProperties[] = [ name: 'amount', type: 'number', default: 0, - description: 'Amount in cents to be collected for this charge, e.g. enter 100 for $1.00', + description: + 'Amount in cents to be collected for this charge, e.g. enter 100 for $1.00', typeOptions: { minValue: 0, maxValue: 99999999, }, displayOptions: { show: { - resource: [ - 'source', - ], - operation: [ - 'create', - ], + resource: ['source'], + operation: ['create'], }, }, }, @@ -114,15 +99,12 @@ export const sourceFields: INodeProperties[] = [ loadOptionsMethod: 'getCurrencies', }, default: '', - description: 'Three-letter ISO currency code, e.g. USD or EUR. It must be a Stripe-supported currency. Choose from the list, or specify an ID using an expression.', + description: + 'Three-letter ISO currency code, e.g. USD or EUR. It must be a Stripe-supported currency. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'source', - ], - operation: [ - 'create', - ], + resource: ['source'], + operation: ['create'], }, }, }, @@ -134,12 +116,8 @@ export const sourceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'source', - ], - operation: [ - 'create', - ], + resource: ['source'], + operation: ['create'], }, }, options: [ @@ -179,7 +157,7 @@ export const sourceFields: INodeProperties[] = [ name: 'statement_descriptor', type: 'string', default: '', - description: 'Arbitrary text to display on the customer\'s statement', + description: "Arbitrary text to display on the customer's statement", }, ], }, @@ -196,12 +174,8 @@ export const sourceFields: INodeProperties[] = [ description: 'ID of the customer whose source to delete', displayOptions: { show: { - resource: [ - 'source', - ], - operation: [ - 'delete', - ], + resource: ['source'], + operation: ['delete'], }, }, }, @@ -214,12 +188,8 @@ export const sourceFields: INodeProperties[] = [ description: 'ID of the source to delete', displayOptions: { show: { - resource: [ - 'source', - ], - operation: [ - 'delete', - ], + resource: ['source'], + operation: ['delete'], }, }, }, @@ -236,14 +206,9 @@ export const sourceFields: INodeProperties[] = [ description: 'ID of the source to retrieve', displayOptions: { show: { - resource: [ - 'source', - ], - operation: [ - 'get', - ], + resource: ['source'], + operation: ['get'], }, }, }, - ]; diff --git a/packages/nodes-base/nodes/Stripe/descriptions/TokenDescription.ts b/packages/nodes-base/nodes/Stripe/descriptions/TokenDescription.ts index 9bbaa66f10..c891fa113f 100644 --- a/packages/nodes-base/nodes/Stripe/descriptions/TokenDescription.ts +++ b/packages/nodes-base/nodes/Stripe/descriptions/TokenDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const tokenOperations: INodeProperties[] = [ { @@ -19,9 +17,7 @@ export const tokenOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'token', - ], + resource: ['token'], }, }, }, @@ -46,12 +42,8 @@ export const tokenFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'token', - ], - operation: [ - 'create', - ], + resource: ['token'], + operation: ['create'], }, }, }, @@ -61,15 +53,9 @@ export const tokenFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'token', - ], - operation: [ - 'create', - ], - type: [ - 'cardToken', - ], + resource: ['token'], + operation: ['create'], + type: ['cardToken'], }, }, placeholder: '4242424242424242', @@ -81,15 +67,9 @@ export const tokenFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'token', - ], - operation: [ - 'create', - ], - type: [ - 'cardToken', - ], + resource: ['token'], + operation: ['create'], + type: ['cardToken'], }, }, default: '', @@ -103,15 +83,9 @@ export const tokenFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'token', - ], - operation: [ - 'create', - ], - type: [ - 'cardToken', - ], + resource: ['token'], + operation: ['create'], + type: ['cardToken'], }, }, default: '', @@ -124,15 +98,9 @@ export const tokenFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'token', - ], - operation: [ - 'create', - ], - type: [ - 'cardToken', - ], + resource: ['token'], + operation: ['create'], + type: ['cardToken'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Stripe/helpers.ts b/packages/nodes-base/nodes/Stripe/helpers.ts index a550387697..0577e4040b 100644 --- a/packages/nodes-base/nodes/Stripe/helpers.ts +++ b/packages/nodes-base/nodes/Stripe/helpers.ts @@ -1,24 +1,10 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - flow, - isEmpty, - omit, -} from 'lodash'; +import { flow, isEmpty, omit } from 'lodash'; -import { - IDataObject, - ILoadOptionsFunctions, - INodePropertyOptions, -} from 'n8n-workflow'; +import { IDataObject, ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow'; /** * Make an API request to Stripe @@ -36,7 +22,6 @@ export async function stripeApiRequest( body: object, query?: object, ) { - const options = { method, form: body, @@ -59,26 +44,17 @@ export async function stripeApiRequest( /** * Make n8n's charge fields compliant with the Stripe API request object. */ -export const adjustChargeFields = flow([ - adjustShipping, - adjustMetadata, -]); +export const adjustChargeFields = flow([adjustShipping, adjustMetadata]); /** * Make n8n's customer fields compliant with the Stripe API request object. */ -export const adjustCustomerFields = flow([ - adjustShipping, - adjustAddress, - adjustMetadata, -]); +export const adjustCustomerFields = flow([adjustShipping, adjustAddress, adjustMetadata]); /** * Convert n8n's address object into a Stripe API request shipping object. */ -function adjustAddress( - addressFields: { address: { details: IDataObject } }, -) { +function adjustAddress(addressFields: { address: { details: IDataObject } }) { if (!addressFields.address) return addressFields; return { @@ -90,14 +66,14 @@ function adjustAddress( /** * Convert n8n's `fixedCollection` metadata object into a Stripe API request metadata object. */ -export function adjustMetadata( - fields: { metadata?: { metadataProperties: Array<{ key: string; value: string }> } }, -) { +export function adjustMetadata(fields: { + metadata?: { metadataProperties: Array<{ key: string; value: string }> }; +}) { if (!fields.metadata || isEmpty(fields.metadata)) return fields; const adjustedMetadata: Record = {}; - fields.metadata.metadataProperties.forEach(pair => { + fields.metadata.metadataProperties.forEach((pair) => { adjustedMetadata[pair.key] = pair.value; }); @@ -110,9 +86,9 @@ export function adjustMetadata( /** * Convert n8n's shipping object into a Stripe API request shipping object. */ -function adjustShipping( - shippingFields: { shipping?: { shippingProperties: Array<{ address: { details: IDataObject }; name: string }> } }, -) { +function adjustShipping(shippingFields: { + shipping?: { shippingProperties: Array<{ address: { details: IDataObject }; name: string }> }; +}) { const shippingProperties = shippingFields.shipping?.shippingProperties[0]; if (!shippingProperties?.address || isEmpty(shippingProperties.address)) return shippingFields; @@ -135,7 +111,7 @@ export async function loadResource( ): Promise { const responseData = await stripeApiRequest.call(this, 'GET', `/${resource}s`, {}, {}); - return responseData.data.map(({ name, id }: { name: string, id: string }) => ({ + return responseData.data.map(({ name, id }: { name: string; id: string }) => ({ name, value: id, })); diff --git a/packages/nodes-base/nodes/Supabase/GenericFunctions.ts b/packages/nodes-base/nodes/Supabase/GenericFunctions.ts index de3bedf53f..36b4f88a35 100644 --- a/packages/nodes-base/nodes/Supabase/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Supabase/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -18,8 +16,26 @@ import { NodeApiError, } from 'n8n-workflow'; -export async function supabaseApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any - const credentials = await this.getCredentials('supabaseApi') as { host: string, serviceRole: string }; +export async function supabaseApiRequest( + this: + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IHookFunctions + | IWebhookFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { + const credentials = (await this.getCredentials('supabaseApi')) as { + host: string; + serviceRole: string; + }; const options: OptionsWithUri = { headers: { @@ -42,17 +58,16 @@ export async function supabaseApiRequest(this: IExecuteFunctions | IExecuteSingl } //@ts-ignore return await this.helpers?.request(options); - } catch (error) { throw new NodeApiError(this.getNode(), error); } } const mapOperations: { [key: string]: string } = { - 'create': 'created', - 'update': 'updated', - 'getAll': 'retrieved', - 'delete': 'deleted', + create: 'created', + update: 'updated', + getAll: 'retrieved', + delete: 'deleted', }; export function getFilters( @@ -73,7 +88,8 @@ export function getFilters( value: 'allFilters', }, ], - }): INodeProperties[] { + }, +): INodeProperties[] { return [ { displayName: filterTypeDisplayName, @@ -107,9 +123,7 @@ export function getFilters( show: { resource: resources, operation: operations, - filterType: [ - 'manual', - ], + filterType: ['manual'], }, }, default: 'anyFilter', @@ -125,9 +139,7 @@ export function getFilters( show: { resource: resources, operation: operations, - filterType: [ - 'manual', - ], + filterType: ['manual'], }, }, default: {}, @@ -141,11 +153,10 @@ export function getFilters( displayName: 'Field Name or ID', name: 'keyName', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'tableId', - ], + loadOptionsDependsOn: ['tableId'], loadOptionsMethod: 'getTableColumns', }, default: '', @@ -207,9 +218,7 @@ export function getFilters( type: 'options', displayOptions: { show: { - condition: [ - 'fullText', - ], + condition: ['fullText'], }, }, options: [ @@ -244,16 +253,15 @@ export function getFilters( description: `Filter to decide which rows get ${mapOperations[operations[0] as string]}`, }, { - displayName: 'See PostgREST guide to creating filters', + displayName: + 'See PostgREST guide to creating filters', name: 'jsonNotice', type: 'notice', displayOptions: { show: { resource: resources, operation: operations, - filterType: [ - 'string', - ], + filterType: ['string'], }, }, default: '', @@ -269,9 +277,7 @@ export function getFilters( show: { resource: resources, operation: operations, - filterType: [ - 'string', - ], + filterType: ['string'], }, }, default: '', @@ -282,7 +288,9 @@ export function getFilters( export const buildQuery = (obj: IDataObject, value: IDataObject) => { if (value.condition === 'fullText') { - return Object.assign(obj, { [`${value.keyName}`]: `${value.searchFunction}.${value.keyValue}` }); + return Object.assign(obj, { + [`${value.keyName}`]: `${value.searchFunction}.${value.keyValue}`, + }); } return Object.assign(obj, { [`${value.keyName}`]: `${value.condition}.${value.keyValue}` }); }; @@ -300,12 +308,13 @@ export const buildGetQuery = (obj: IDataObject, value: IDataObject) => { export async function validateCredentials( this: ICredentialTestFunctions, - decryptedCredentials: ICredentialDataDecryptedObject): Promise { // tslint:disable-line:no-any - + decryptedCredentials: ICredentialDataDecryptedObject, + // tslint:disable-next-line:no-any +): Promise { const credentials = decryptedCredentials; const { serviceRole } = credentials as { - serviceRole: string, + serviceRole: string; }; const options: OptionsWithUri = { diff --git a/packages/nodes-base/nodes/Supabase/RowDescription.ts b/packages/nodes-base/nodes/Supabase/RowDescription.ts index b38fd00590..94a67e487c 100644 --- a/packages/nodes-base/nodes/Supabase/RowDescription.ts +++ b/packages/nodes-base/nodes/Supabase/RowDescription.ts @@ -1,11 +1,6 @@ +import { INodeProperties } from 'n8n-workflow'; -import { - INodeProperties, -} from 'n8n-workflow'; - -import { - getFilters, -} from './GenericFunctions'; +import { getFilters } from './GenericFunctions'; export const rowOperations: INodeProperties[] = [ { @@ -15,9 +10,7 @@ export const rowOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'row', - ], + resource: ['row'], }, }, options: [ @@ -57,7 +50,6 @@ export const rowOperations: INodeProperties[] = [ ]; export const rowFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* row:create */ /* -------------------------------------------------------------------------- */ @@ -65,46 +57,36 @@ export const rowFields: INodeProperties[] = [ displayName: 'Table Name or ID', name: 'tableId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTables', }, required: true, displayOptions: { show: { - resource: [ - 'row', - ], - operation: [ - 'create', - 'delete', - 'get', - 'getAll', - 'update', - ], + resource: ['row'], + operation: ['create', 'delete', 'get', 'getAll', 'update'], }, }, default: '', }, - ...getFilters( - ['row'], - ['update'], - { - includeNoneOption: false, - filterTypeDisplayName: 'Select Type', - filterStringDisplayName: 'Select Condition (String)', - filterFixedCollectionDisplayName: 'Select Conditions', - mustMatchOptions: [ - { - name: 'Any Select Condition', - value: 'anyFilter', - }, - { - name: 'All Select Conditions', - value: 'allFilters', - }, - ], - }), + ...getFilters(['row'], ['update'], { + includeNoneOption: false, + filterTypeDisplayName: 'Select Type', + filterStringDisplayName: 'Select Condition (String)', + filterFixedCollectionDisplayName: 'Select Conditions', + mustMatchOptions: [ + { + name: 'Any Select Condition', + value: 'anyFilter', + }, + { + name: 'All Select Conditions', + value: 'allFilters', + }, + ], + }), { displayName: 'Data to Send', name: 'dataToSend', @@ -123,13 +105,8 @@ export const rowFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'row', - ], - operation: [ - 'create', - 'update', - ], + resource: ['row'], + operation: ['create', 'update'], }, }, default: 'defineBelow', @@ -140,20 +117,14 @@ export const rowFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'row', - ], - operation: [ - 'create', - 'update', - ], - dataToSend: [ - 'autoMapInputData', - ], + resource: ['row'], + operation: ['create', 'update'], + dataToSend: ['autoMapInputData'], }, }, default: '', - description: 'List of input properties to avoid sending, separated by commas. Leave empty to send all properties.', + description: + 'List of input properties to avoid sending, separated by commas. Leave empty to send all properties.', placeholder: 'Enter properties...', }, { @@ -167,16 +138,9 @@ export const rowFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'row', - ], - operation: [ - 'create', - 'update', - ], - dataToSend: [ - 'defineBelow', - ], + resource: ['row'], + operation: ['create', 'update'], + dataToSend: ['defineBelow'], }, }, default: {}, @@ -189,11 +153,10 @@ export const rowFields: INodeProperties[] = [ displayName: 'Field Name or ID', name: 'fieldId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'tableId', - ], + loadOptionsDependsOn: ['tableId'], loadOptionsMethod: 'getTableColumns', }, default: '', @@ -211,24 +174,22 @@ export const rowFields: INodeProperties[] = [ /* -------------------------------------------------------------------------- */ /* row:delete */ /* -------------------------------------------------------------------------- */ - ...getFilters( - ['row'], - ['delete'], - { - includeNoneOption: false, - filterTypeDisplayName: 'Select Type', - filterStringDisplayName: 'Select Condition (String)', - filterFixedCollectionDisplayName: 'Select Conditions', - mustMatchOptions: [ - { - name: 'Any Select Condition', - value: 'anyFilter', - }, - { - name: 'All Select Conditions', - value: 'allFilters', - }, - ]}), + ...getFilters(['row'], ['delete'], { + includeNoneOption: false, + filterTypeDisplayName: 'Select Type', + filterStringDisplayName: 'Select Condition (String)', + filterFixedCollectionDisplayName: 'Select Conditions', + mustMatchOptions: [ + { + name: 'Any Select Condition', + value: 'anyFilter', + }, + { + name: 'All Select Conditions', + value: 'allFilters', + }, + ], + }), /* -------------------------------------------------------------------------- */ /* row:get */ /* -------------------------------------------------------------------------- */ @@ -241,12 +202,8 @@ export const rowFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'row', - ], - operation: [ - 'get', - ], + resource: ['row'], + operation: ['get'], }, }, default: {}, @@ -261,13 +218,12 @@ export const rowFields: INodeProperties[] = [ name: 'keyName', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'tableId', - ], + loadOptionsDependsOn: ['tableId'], loadOptionsMethod: 'getTableColumns', }, default: '', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', }, { displayName: 'Value', @@ -289,12 +245,8 @@ export const rowFields: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'row', - ], - operation: [ - 'getAll', - ], + resource: ['row'], + operation: ['getAll'], }, }, default: false, @@ -306,15 +258,9 @@ export const rowFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'row', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['row'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Supabase/Supabase.node.ts b/packages/nodes-base/nodes/Supabase/Supabase.node.ts index 49006f02c2..cfbb42ce4c 100644 --- a/packages/nodes-base/nodes/Supabase/Supabase.node.ts +++ b/packages/nodes-base/nodes/Supabase/Supabase.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -24,10 +22,7 @@ import { validateCredentials, } from './GenericFunctions'; -import { - rowFields, - rowOperations, -} from './RowDescription'; +import { rowFields, rowOperations } from './RowDescription'; export type FieldsUiValues = Array<{ fieldId: string; @@ -79,7 +74,7 @@ export class Supabase implements INodeType { loadOptions: { async getTables(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { paths } = await supabaseApiRequest.call(this, 'GET', '/',); + const { paths } = await supabaseApiRequest.call(this, 'GET', '/'); for (const path of Object.keys(paths)) { //omit introspection path if (path === '/') continue; @@ -93,7 +88,7 @@ export class Supabase implements INodeType { async getTableColumns(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const tableName = this.getCurrentNodeParameter('tableId') as string; - const { definitions } = await supabaseApiRequest.call(this, 'GET', '/',); + const { definitions } = await supabaseApiRequest.call(this, 'GET', '/'); for (const column of Object.keys(definitions[tableName].properties)) { returnData.push({ name: `${column} - (${definitions[tableName].properties[column].type})`, @@ -104,7 +99,10 @@ export class Supabase implements INodeType { }, }, credentialTest: { - async supabaseApiCredentialTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { + async supabaseApiCredentialTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { try { await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject); } catch (error) { @@ -136,12 +134,14 @@ export class Supabase implements INodeType { const tableId = this.getNodeParameter('tableId', 0) as string; for (let i = 0; i < length; i++) { const record: IDataObject = {}; - const dataToSend = this.getNodeParameter('dataToSend', 0) as 'defineBelow' | 'autoMapInputData'; + const dataToSend = this.getNodeParameter('dataToSend', 0) as + | 'defineBelow' + | 'autoMapInputData'; if (dataToSend === 'autoMapInputData') { const incomingKeys = Object.keys(items[i].json); const rawInputsToIgnore = this.getNodeParameter('inputsToIgnore', i) as string; - const inputDataToIgnore = rawInputsToIgnore.split(',').map(c => c.trim()); + const inputDataToIgnore = rawInputsToIgnore.split(',').map((c) => c.trim()); for (const key of incomingKeys) { if (inputDataToIgnore.includes(key)) continue; @@ -175,13 +175,16 @@ export class Supabase implements INodeType { const filterType = this.getNodeParameter('filterType', 0) as string; let endpoint = `/${tableId}`; for (let i = 0; i < length; i++) { - if (filterType === 'manual') { const matchType = this.getNodeParameter('matchType', 0) as string; const keys = this.getNodeParameter('filters.conditions', i, []) as IDataObject[]; if (!keys.length) { - throw new NodeOperationError(this.getNode(), 'At least one select condition must be defined', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'At least one select condition must be defined', + { itemIndex: i }, + ); } if (matchType === 'allFilters') { @@ -224,7 +227,11 @@ export class Supabase implements INodeType { let rows; if (!keys.length) { - throw new NodeOperationError(this.getNode(), 'At least one select condition must be defined', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'At least one select condition must be defined', + { itemIndex: i }, + ); } try { @@ -245,7 +252,6 @@ export class Supabase implements INodeType { const filterType = this.getNodeParameter('filterType', 0) as string; let endpoint = `/${tableId}`; for (let i = 0; i < length; i++) { - if (filterType === 'manual') { const matchType = this.getNodeParameter('matchType', 0) as string; const keys = this.getNodeParameter('filters.conditions', i, []) as IDataObject[]; @@ -290,13 +296,16 @@ export class Supabase implements INodeType { const filterType = this.getNodeParameter('filterType', 0) as string; let endpoint = `/${tableId}`; for (let i = 0; i < length; i++) { - if (filterType === 'manual') { const matchType = this.getNodeParameter('matchType', 0) as string; const keys = this.getNodeParameter('filters.conditions', i, []) as IDataObject[]; if (!keys.length) { - throw new NodeOperationError(this.getNode(), 'At least one select condition must be defined', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'At least one select condition must be defined', + { itemIndex: i }, + ); } if (matchType === 'allFilters') { @@ -315,12 +324,14 @@ export class Supabase implements INodeType { } const record: IDataObject = {}; - const dataToSend = this.getNodeParameter('dataToSend', 0) as 'defineBelow' | 'autoMapInputData'; + const dataToSend = this.getNodeParameter('dataToSend', 0) as + | 'defineBelow' + | 'autoMapInputData'; if (dataToSend === 'autoMapInputData') { const incomingKeys = Object.keys(items[i].json); const rawInputsToIgnore = this.getNodeParameter('inputsToIgnore', i) as string; - const inputDataToIgnore = rawInputsToIgnore.split(',').map(c => c.trim()); + const inputDataToIgnore = rawInputsToIgnore.split(',').map((c) => c.trim()); for (const key of incomingKeys) { if (inputDataToIgnore.includes(key)) continue; diff --git a/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts b/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts index 85134811db..7df2925ea9 100644 --- a/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts @@ -1,11 +1,6 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject, @@ -15,7 +10,17 @@ import { NodeOperationError, } from 'n8n-workflow'; -export async function surveyMonkeyApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function surveyMonkeyApiRequest( + this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0); const endpoint = 'https://api.surveymonkey.com/v3'; @@ -40,13 +45,12 @@ export async function surveyMonkeyApiRequest(this: IExecuteFunctions | IWebhookF options = Object.assign({}, options, option); try { - if ( authenticationMethod === 'accessToken') { + if (authenticationMethod === 'accessToken') { const credentials = await this.getCredentials('surveyMonkeyApi'); // @ts-ignore options.headers['Authorization'] = `bearer ${credentials.accessToken}`; return await this.helpers.request!(options); - } else { return await this.helpers.requestOAuth2?.call(this, 'surveyMonkeyOAuth2Api', options); } @@ -55,8 +59,16 @@ export async function surveyMonkeyApiRequest(this: IExecuteFunctions | IWebhookF } } -export async function surveyMonkeyRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function surveyMonkeyRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -68,9 +80,7 @@ export async function surveyMonkeyRequestAllItems(this: IHookFunctions | IExecut responseData = await surveyMonkeyApiRequest.call(this, method, endpoint, body, query, uri); uri = responseData.links.next; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData.links.next - ); + } while (responseData.links.next); return returnData; } diff --git a/packages/nodes-base/nodes/SurveyMonkey/Interfaces.ts b/packages/nodes-base/nodes/SurveyMonkey/Interfaces.ts index 56c4e03a29..7837a9b353 100644 --- a/packages/nodes-base/nodes/SurveyMonkey/Interfaces.ts +++ b/packages/nodes-base/nodes/SurveyMonkey/Interfaces.ts @@ -1,6 +1,4 @@ -import { - IDataObject, - } from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export interface IImage { url: string; diff --git a/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts b/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts index 1e2c777792..6a7a603a1b 100644 --- a/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts +++ b/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -15,23 +12,11 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - idsExist, - surveyMonkeyApiRequest, - surveyMonkeyRequestAllItems, -} from './GenericFunctions'; +import { idsExist, surveyMonkeyApiRequest, surveyMonkeyRequestAllItems } from './GenericFunctions'; -import { - IAnswer, - IChoice, - IOther, - IQuestion, - IRow, -} from './Interfaces'; +import { IAnswer, IChoice, IOther, IQuestion, IRow } from './Interfaces'; -import { - createHmac, -} from 'crypto'; +import { createHmac } from 'crypto'; export class SurveyMonkeyTrigger implements INodeType { description: INodeTypeDescription = { @@ -52,9 +37,7 @@ export class SurveyMonkeyTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -63,9 +46,7 @@ export class SurveyMonkeyTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -123,9 +104,7 @@ export class SurveyMonkeyTrigger implements INodeType { name: 'event', displayOptions: { show: { - objectType: [ - 'survey', - ], + objectType: ['survey'], }, }, type: 'options', @@ -200,9 +179,7 @@ export class SurveyMonkeyTrigger implements INodeType { type: 'options', displayOptions: { show: { - objectType: [ - 'collector', - ], + objectType: ['collector'], }, }, options: [ @@ -254,17 +231,14 @@ export class SurveyMonkeyTrigger implements INodeType { displayName: 'Survey Names or IDs', name: 'surveyIds', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', displayOptions: { show: { - objectType: [ - 'survey', - ], + objectType: ['survey'], }, hide: { - event: [ - 'survey_created', - ], + event: ['survey_created'], }, }, typeOptions: { @@ -278,12 +252,11 @@ export class SurveyMonkeyTrigger implements INodeType { displayName: 'Survey Name or ID', name: 'surveyId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', displayOptions: { show: { - objectType: [ - 'collector', - ], + objectType: ['collector'], }, }, typeOptions: { @@ -296,19 +269,16 @@ export class SurveyMonkeyTrigger implements INodeType { displayName: 'Collector Names or IDs', name: 'collectorIds', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', displayOptions: { show: { - objectType: [ - 'collector', - ], + objectType: ['collector'], }, }, typeOptions: { loadOptionsMethod: 'getCollectors', - loadOptionsDependsOn: [ - 'surveyId', - ], + loadOptionsDependsOn: ['surveyId'], }, options: [], default: [], @@ -320,26 +290,21 @@ export class SurveyMonkeyTrigger implements INodeType { type: 'boolean', displayOptions: { show: { - event: [ - 'response_completed', - ], + event: ['response_completed'], }, }, default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default the webhook-data only contain the IDs. If this option gets activated, it will resolve the data automatically.', + description: + 'By default the webhook-data only contain the IDs. If this option gets activated, it will resolve the data automatically.', }, { displayName: 'Only Answers', name: 'onlyAnswers', displayOptions: { show: { - resolveData: [ - true, - ], - event: [ - 'response_completed', - ], + resolveData: [true], + event: ['response_completed'], }, }, type: 'boolean', @@ -356,7 +321,12 @@ export class SurveyMonkeyTrigger implements INodeType { async getCollectors(this: ILoadOptionsFunctions): Promise { const surveyId = this.getCurrentNodeParameter('surveyId'); const returnData: INodePropertyOptions[] = []; - const collectors = await surveyMonkeyRequestAllItems.call(this, 'data', 'GET', `/surveys/${surveyId}/collectors`); + const collectors = await surveyMonkeyRequestAllItems.call( + this, + 'data', + 'GET', + `/surveys/${surveyId}/collectors`, + ); for (const collector of collectors) { const collectorName = collector.name; const collectorId = collector.id; @@ -396,7 +366,13 @@ export class SurveyMonkeyTrigger implements INodeType { // one that is supposed to get created. const endpoint = '/webhooks'; - const responseData = await surveyMonkeyRequestAllItems.call(this, 'data', 'GET', endpoint, {}); + const responseData = await surveyMonkeyRequestAllItems.call( + this, + 'data', + 'GET', + endpoint, + {}, + ); const webhookUrl = this.getNodeWebhookUrl('default'); @@ -411,10 +387,16 @@ export class SurveyMonkeyTrigger implements INodeType { } for (const webhook of responseData) { - const webhookDetails = await surveyMonkeyApiRequest.call(this, 'GET', `/webhooks/${webhook.id}`); - if (webhookDetails.subscription_url === webhookUrl - && idsExist(webhookDetails.object_ids as string[], ids as string[]) - && webhookDetails.event_type === event) { + const webhookDetails = await surveyMonkeyApiRequest.call( + this, + 'GET', + `/webhooks/${webhook.id}`, + ); + if ( + webhookDetails.subscription_url === webhookUrl && + idsExist(webhookDetails.object_ids as string[], ids as string[]) && + webhookDetails.event_type === event + ) { // Set webhook-id to be sure that it can be deleted const webhookData = this.getWorkflowStaticData('node'); webhookData.webhookId = webhook.id as string; @@ -470,7 +452,6 @@ export class SurveyMonkeyTrigger implements INodeType { async delete(this: IHookFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); if (webhookData.webhookId !== undefined) { - const endpoint = `/webhooks/${webhookData.webhookId}`; try { @@ -493,7 +474,7 @@ export class SurveyMonkeyTrigger implements INodeType { const event = this.getNodeParameter('event') as string; const objectType = this.getNodeParameter('objectType') as string; const authenticationMethod = this.getNodeParameter('authentication') as string; - let credentials : IDataObject; + let credentials: IDataObject; const headerData = this.getHeaderData() as IDataObject; const req = this.getRequestObject(); const webhookName = this.getWebhookName(); @@ -521,9 +502,14 @@ export class SurveyMonkeyTrigger implements INodeType { }); req.on('end', async () => { - const computedSignature = createHmac('sha1', `${credentials.clientId}&${credentials.clientSecret}`).update(data.join('')).digest('base64'); + const computedSignature = createHmac( + 'sha1', + `${credentials.clientId}&${credentials.clientSecret}`, + ) + .update(data.join('')) + .digest('base64'); if (headerData['sm-signature'] !== computedSignature) { - // Signature is not valid so ignore call + // Signature is not valid so ignore call return {}; } @@ -550,7 +536,11 @@ export class SurveyMonkeyTrigger implements INodeType { const questions: IQuestion[] = []; const answers = new Map(); - const { pages } = await surveyMonkeyApiRequest.call(this, 'GET', `/surveys/${surveyId}/details`); + const { pages } = await surveyMonkeyApiRequest.call( + this, + 'GET', + `/surveys/${surveyId}/details`, + ); for (const page of pages) { questions.push.apply(questions, page.questions); @@ -565,7 +555,6 @@ export class SurveyMonkeyTrigger implements INodeType { const responseQuestions = new Map(); for (const question of questions) { - /* TODO: add support for premium components - File Upload @@ -583,10 +572,9 @@ export class SurveyMonkeyTrigger implements INodeType { if (question.subtype !== 'multi') { responseQuestions.set(heading, answers.get(question.id)![0].text as string); } else { - const results: IDataObject = {}; - const keys = (question.answers.rows as IRow[]).map(e => e.text) as string[]; - const values = answers.get(question.id)?.map(e => e.text) as string[]; + const keys = (question.answers.rows as IRow[]).map((e) => e.text) as string[]; + const values = answers.get(question.id)?.map((e) => e.text) as string[]; for (let i = 0; i < keys.length; i++) { // if for some reason there are questions texts repeted add the index to the key if (results[keys[i]] !== undefined) { @@ -601,23 +589,28 @@ export class SurveyMonkeyTrigger implements INodeType { if (question.family === 'single_choice') { const other = question.answers.other as IOther; - if (other && other.visible && other.is_answer_choice && answers.get(question.id)![0].other_id) { + if ( + other && + other.visible && + other.is_answer_choice && + answers.get(question.id)![0].other_id + ) { responseQuestions.set(heading, answers.get(question.id)![0].text as string); - - } else if (other && other.visible && !other.is_answer_choice){ + } else if (other && other.visible && !other.is_answer_choice) { const choiceId = answers.get(question.id)![0].choice_id; - const choice = (question.answers.choices as IChoice[]) - .filter(e => e.id === choiceId)[0]; + const choice = (question.answers.choices as IChoice[]).filter( + (e) => e.id === choiceId, + )[0]; - const comment = answers.get(question.id) - ?.find(e => e.other_id === other.id)?.text as string; + const comment = answers.get(question.id)?.find((e) => e.other_id === other.id) + ?.text as string; responseQuestions.set(heading, { value: choice.text, comment }); - } else { const choiceId = answers.get(question.id)![0].choice_id; - const choice = (question.answers.choices as IChoice[]) - .filter(e => e.id === choiceId)[0]; + const choice = (question.answers.choices as IChoice[]).filter( + (e) => e.id === choiceId, + )[0]; responseQuestions.set(heading, choice.text); } } @@ -626,12 +619,12 @@ export class SurveyMonkeyTrigger implements INodeType { const other = question.answers.other as IOther; const choiceIds = answers.get(question.id)?.map((e) => e.choice_id); const value = (question.answers.choices as IChoice[]) - .filter(e => choiceIds?.includes(e.id)) - .map(e => e.text) as string[]; + .filter((e) => choiceIds?.includes(e.id)) + .map((e) => e.text) as string[]; // if "Add an "Other" Answer Option for Comments" is active and was selected if (other && other.is_answer_choice && other.visible) { - const text = answers.get(question.id) - ?.find(e => e.other_id === other.id)?.text as string; + const text = answers.get(question.id)?.find((e) => e.other_id === other.id) + ?.text as string; value.push(text); } responseQuestions.set(heading, value); @@ -642,18 +635,17 @@ export class SurveyMonkeyTrigger implements INodeType { const rows = question.answers.rows as IRow[]; if (rows.length > 1) { - const results: IDataObject = {}; - const choiceIds = answers.get(question.id)?.map(e => e.choice_id) as string[]; - const rowIds = answers.get(question.id)?.map(e => e.row_id) as string[]; + const choiceIds = answers.get(question.id)?.map((e) => e.choice_id) as string[]; + const rowIds = answers.get(question.id)?.map((e) => e.row_id) as string[]; const rowsValues = (question.answers.rows as IRow[]) - .filter(e => rowIds!.includes(e.id as string)) - .map(e => e.text); + .filter((e) => rowIds!.includes(e.id as string)) + .map((e) => e.text); const choicesValues = (question.answers.choices as IChoice[]) - .filter(e => choiceIds!.includes(e.id as string)) - .map(e => e.text); + .filter((e) => choiceIds!.includes(e.id as string)) + .map((e) => e.text); for (let i = 0; i < rowsValues.length; i++) { results[rowsValues[i]] = choicesValues[i] || ''; @@ -672,12 +664,11 @@ export class SurveyMonkeyTrigger implements INodeType { } responseQuestions.set(heading, results); - } else { const choiceIds = answers.get(question.id)?.map((e) => e.choice_id); const value = (question.answers.choices as IChoice[]) - .filter(e => choiceIds!.includes(e.id as string)) - .map(e => (e.text === '') ? e.weight : e.text)[0]; + .filter((e) => choiceIds!.includes(e.id as string)) + .map((e) => (e.text === '' ? e.weight : e.text))[0]; responseQuestions.set(heading, value); // if "Add an Other Answer Option for Comments" is active then add comment to the answer @@ -735,9 +726,7 @@ export class SurveyMonkeyTrigger implements INodeType { } return resolve({ - workflowData: [ - returnItem, - ], + workflowData: [returnItem], }); }); diff --git a/packages/nodes-base/nodes/Switch/Switch.node.ts b/packages/nodes-base/nodes/Switch/Switch.node.ts index 7d5d24dfdd..db6e176367 100644 --- a/packages/nodes-base/nodes/Switch/Switch.node.ts +++ b/packages/nodes-base/nodes/Switch/Switch.node.ts @@ -8,7 +8,6 @@ import { NodeParameterValue, } from 'n8n-workflow'; - export class Switch implements INodeType { description: INodeTypeDescription = { displayName: 'Switch', @@ -46,7 +45,6 @@ export class Switch implements INodeType { description: 'How data should be routed', }, - // ---------------------------------- // mode:expression // ---------------------------------- @@ -60,16 +58,13 @@ export class Switch implements INodeType { }, displayOptions: { show: { - mode: [ - 'expression', - ], + mode: ['expression'], }, }, default: 0, description: 'The index of output to which to send data to', }, - // ---------------------------------- // mode:rules // ---------------------------------- @@ -79,9 +74,7 @@ export class Switch implements INodeType { type: 'options', displayOptions: { show: { - mode: [ - 'rules', - ], + mode: ['rules'], }, }, options: [ @@ -115,12 +108,8 @@ export class Switch implements INodeType { type: 'boolean', displayOptions: { show: { - dataType: [ - 'boolean', - ], - mode: [ - 'rules', - ], + dataType: ['boolean'], + mode: ['rules'], }, }, default: false, @@ -137,12 +126,8 @@ export class Switch implements INodeType { }, displayOptions: { show: { - dataType: [ - 'boolean', - ], - mode: [ - 'rules', - ], + dataType: ['boolean'], + mode: ['rules'], }, }, default: {}, @@ -202,12 +187,8 @@ export class Switch implements INodeType { type: 'dateTime', displayOptions: { show: { - dataType: [ - 'dateTime', - ], - mode: [ - 'rules', - ], + dataType: ['dateTime'], + mode: ['rules'], }, }, default: '', @@ -223,12 +204,8 @@ export class Switch implements INodeType { }, displayOptions: { show: { - dataType: [ - 'dateTime', - ], - mode: [ - 'rules', - ], + dataType: ['dateTime'], + mode: ['rules'], }, }, default: {}, @@ -287,12 +264,8 @@ export class Switch implements INodeType { type: 'number', displayOptions: { show: { - dataType: [ - 'number', - ], - mode: [ - 'rules', - ], + dataType: ['number'], + mode: ['rules'], }, }, default: 0, @@ -308,12 +281,8 @@ export class Switch implements INodeType { }, displayOptions: { show: { - dataType: [ - 'number', - ], - mode: [ - 'rules', - ], + dataType: ['number'], + mode: ['rules'], }, }, default: {}, @@ -389,12 +358,8 @@ export class Switch implements INodeType { type: 'string', displayOptions: { show: { - dataType: [ - 'string', - ], - mode: [ - 'rules', - ], + dataType: ['string'], + mode: ['rules'], }, }, default: '', @@ -410,12 +375,8 @@ export class Switch implements INodeType { }, displayOptions: { show: { - dataType: [ - 'string', - ], - mode: [ - 'rules', - ], + dataType: ['string'], + mode: ['rules'], }, }, default: {}, @@ -481,10 +442,7 @@ export class Switch implements INodeType { type: 'string', displayOptions: { hide: { - operation: [ - 'regex', - 'notRegex', - ], + operation: ['regex', 'notRegex'], }, }, default: '', @@ -496,10 +454,7 @@ export class Switch implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'regex', - 'notRegex', - ], + operation: ['regex', 'notRegex'], }, }, default: '', @@ -522,7 +477,6 @@ export class Switch implements INodeType { ], }, - // eslint-disable-next-line n8n-nodes-base/node-param-default-missing { displayName: 'Fallback Output', @@ -530,9 +484,7 @@ export class Switch implements INodeType { type: 'options', displayOptions: { show: { - mode: [ - 'rules', - ], + mode: ['rules'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items @@ -561,18 +513,11 @@ export class Switch implements INodeType { default: -1, description: 'The output to which to route all items which do not match any of the rules', }, - ], }; - async execute(this: IExecuteFunctions): Promise { - const returnData: INodeExecutionData[][] = [ - [], - [], - [], - [], - ]; + const returnData: INodeExecutionData[][] = [[], [], [], []]; const items = this.getInputData(); @@ -587,20 +532,32 @@ export class Switch implements INodeType { const compareOperationFunctions: { [key: string]: (value1: NodeParameterValue, value2: NodeParameterValue) => boolean; } = { - after: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) > (value2 || 0), - before: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) < (value2 || 0), - contains: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || '').toString().includes((value2 || '').toString()), - notContains: (value1: NodeParameterValue, value2: NodeParameterValue) => !(value1 || '').toString().includes((value2 || '').toString()), - endsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 as string).endsWith(value2 as string), - notEndsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => !(value1 as string).endsWith(value2 as string), + after: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 || 0) > (value2 || 0), + before: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 || 0) < (value2 || 0), + contains: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 || '').toString().includes((value2 || '').toString()), + notContains: (value1: NodeParameterValue, value2: NodeParameterValue) => + !(value1 || '').toString().includes((value2 || '').toString()), + endsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 as string).endsWith(value2 as string), + notEndsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => + !(value1 as string).endsWith(value2 as string), equal: (value1: NodeParameterValue, value2: NodeParameterValue) => value1 === value2, notEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => value1 !== value2, - larger: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) > (value2 || 0), - largerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) >= (value2 || 0), - smaller: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) < (value2 || 0), - smallerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 || 0) <= (value2 || 0), - startsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => (value1 as string).startsWith(value2 as string), - notStartsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => !(value1 as string).startsWith(value2 as string), + larger: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 || 0) > (value2 || 0), + largerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 || 0) >= (value2 || 0), + smaller: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 || 0) < (value2 || 0), + smallerEqual: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 || 0) <= (value2 || 0), + startsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => + (value1 as string).startsWith(value2 as string), + notStartsWith: (value1: NodeParameterValue, value2: NodeParameterValue) => + !(value1 as string).startsWith(value2 as string), regex: (value1: NodeParameterValue, value2: NodeParameterValue) => { const regexMatch = (value2 || '').toString().match(new RegExp('^/(.*?)/([gimusy]*)$')); @@ -638,12 +595,16 @@ export class Switch implements INodeType { returnValue = new Date(value).getTime(); } else if (typeof value === 'number') { returnValue = value; - } if ((value as unknown as object) instanceof Date) { + } + if ((value as unknown as object) instanceof Date) { returnValue = (value as unknown as Date).getTime(); } if (returnValue === undefined || isNaN(returnValue)) { - throw new NodeOperationError(this.getNode(), `The value "${value}" is not a valid DateTime.`); + throw new NodeOperationError( + this.getNode(), + `The value "${value}" is not a valid DateTime.`, + ); } return returnValue; @@ -651,15 +612,16 @@ export class Switch implements INodeType { const checkIndexRange = (index: number) => { if (index < 0 || index >= returnData.length) { - throw new NodeOperationError(this.getNode(), `The ouput ${index} is not allowed. It has to be between 0 and ${returnData.length - 1}!`); + throw new NodeOperationError( + this.getNode(), + `The ouput ${index} is not allowed. It has to be between 0 and ${returnData.length - 1}!`, + ); } }; // Itterate over all items to check to which output they should be routed to - itemLoop: - for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { + itemLoop: for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { try { - item = items[itemIndex]; mode = this.getNodeParameter('mode', itemIndex) as string; @@ -680,7 +642,11 @@ export class Switch implements INodeType { value1 = convertDateTime(value1); } - for (ruleData of this.getNodeParameter('rules.rules', itemIndex, []) as INodeParameters[]) { + for (ruleData of this.getNodeParameter( + 'rules.rules', + itemIndex, + [], + ) as INodeParameters[]) { // Check if the values passes value2 = ruleData.value2 as NodeParameterValue; @@ -688,7 +654,10 @@ export class Switch implements INodeType { value2 = convertDateTime(value2); } - compareOperationResult = compareOperationFunctions[ruleData.operation as string](value1, value2); + compareOperationResult = compareOperationFunctions[ruleData.operation as string]( + value1, + value2, + ); if (compareOperationResult === true) { // If rule matches add it to the correct output and continue with next item @@ -705,10 +674,9 @@ export class Switch implements INodeType { returnData[outputIndex].push(item); } } - } catch (error) { if (this.continueOnFail()) { - returnData[0].push({json:{ error: error.message }}); + returnData[0].push({ json: { error: error.message } }); continue; } throw error; diff --git a/packages/nodes-base/nodes/SyncroMSP/SyncroMsp.node.ts b/packages/nodes-base/nodes/SyncroMSP/SyncroMsp.node.ts index 63ce1575bc..5ddd430d4a 100644 --- a/packages/nodes-base/nodes/SyncroMSP/SyncroMsp.node.ts +++ b/packages/nodes-base/nodes/SyncroMSP/SyncroMsp.node.ts @@ -1,7 +1,4 @@ -import { - INodeTypeBaseDescription, - INodeVersionedType, -} from 'n8n-workflow'; +import { INodeTypeBaseDescription, INodeVersionedType } from 'n8n-workflow'; import { NodeVersionedType } from '../../src/NodeVersionedType'; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/SyncroMspV1.node.ts b/packages/nodes-base/nodes/SyncroMSP/v1/SyncroMspV1.node.ts index 0b6b71ebb9..f5c139ec91 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/SyncroMspV1.node.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/SyncroMspV1.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -18,7 +16,6 @@ import { router } from './actions/router'; import { validateCredentials } from './transport'; export class SyncroMspV1 implements INodeType { - description: INodeTypeDescription; constructor(baseDescription: INodeTypeBaseDescription) { @@ -31,7 +28,10 @@ export class SyncroMspV1 implements INodeType { methods = { loadOptions, credentialTest: { - async syncroMspApiCredentialTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { + async syncroMspApiCredentialTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { try { await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject); } catch (error) { diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/Interfaces.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/Interfaces.ts index 027776e50a..e18bf5789a 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/Interfaces.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/Interfaces.ts @@ -1,14 +1,10 @@ -import { - AllEntities, - Entity, - PropertiesOf, -} from 'n8n-workflow'; +import { AllEntities, Entity, PropertiesOf } from 'n8n-workflow'; type SyncroMspMap = { - contact: 'create'|'delete'|'get'|'getAll'|'update'; - customer: 'create'|'delete'|'get'|'getAll'|'update'; - rmm: 'create'|'delete'|'get'|'getAll'|'mute' ; - ticket: 'create'|'delete'|'get'|'getAll'|'update'; + contact: 'create' | 'delete' | 'get' | 'getAll' | 'update'; + customer: 'create' | 'delete' | 'get' | 'getAll' | 'update'; + rmm: 'create' | 'delete' | 'get' | 'getAll' | 'mute'; + ticket: 'create' | 'delete' | 'get' | 'getAll' | 'update'; }; export type SyncroMsp = AllEntities; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/description.ts index 63c9aae90b..38623747a6 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/description.ts @@ -1,10 +1,6 @@ -import { - ContactProperties, -} from '../../Interfaces'; +import { ContactProperties } from '../../Interfaces'; -import { - addressFixedCollection -} from '../../../methods/sharedFields'; +import { addressFixedCollection } from '../../../methods/sharedFields'; export const contactCreateDescription: ContactProperties = [ { @@ -14,12 +10,8 @@ export const contactCreateDescription: ContactProperties = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, default: '', @@ -31,12 +23,8 @@ export const contactCreateDescription: ContactProperties = [ placeholder: 'name@email.com', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, default: '', @@ -48,12 +36,8 @@ export const contactCreateDescription: ContactProperties = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/execute.ts index 9d99aa1b4e..b4a36f73a1 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/execute.ts @@ -1,21 +1,19 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; - -export async function createContact(this: IExecuteFunctions, index: number): Promise { +export async function createContact( + this: IExecuteFunctions, + index: number, +): Promise { const id = this.getNodeParameter('customerId', index) as IDataObject; const email = this.getNodeParameter('email', index) as IDataObject; - const { address, notes, phone, name } = this.getNodeParameter('additionalFields', index) as IDataObject; + const { address, notes, phone, name } = this.getNodeParameter( + 'additionalFields', + index, + ) as IDataObject; const qs = {} as IDataObject; const requestMethod = 'POST'; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/index.ts index b2b821f766..37a8c233e9 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/index.ts @@ -1,7 +1,4 @@ import { createContact as execute } from './execute'; import { contactCreateDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/description.ts index fda202b287..8e4552cfdc 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/description.ts @@ -1,6 +1,4 @@ -import { - ContactProperties, -} from '../../Interfaces'; +import { ContactProperties } from '../../Interfaces'; export const contactDeleteDescription: ContactProperties = [ { @@ -10,12 +8,8 @@ export const contactDeleteDescription: ContactProperties = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'delete', - ], + resource: ['contact'], + operation: ['delete'], }, }, default: '', diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/execute.ts index 9809370eac..935270004e 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/execute.ts @@ -1,18 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest -} from '../../../transport'; +import { apiRequest } from '../../../transport'; - -export async function deleteContact(this: IExecuteFunctions, index: number): Promise { +export async function deleteContact( + this: IExecuteFunctions, + index: number, +): Promise { const id = this.getNodeParameter('contactId', index) as string; const qs = {} as IDataObject; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/index.ts index d87102feae..59582e0e22 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/index.ts @@ -1,7 +1,4 @@ import { deleteContact as execute } from './execute'; import { contactDeleteDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/description.ts index 5dd45d33bc..afddc90a6e 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/description.ts @@ -1,6 +1,4 @@ -import { - ContactProperties, -} from '../../Interfaces'; +import { ContactProperties } from '../../Interfaces'; export const contactGetDescription: ContactProperties = [ { @@ -10,12 +8,8 @@ export const contactGetDescription: ContactProperties = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], + resource: ['contact'], + operation: ['get'], }, }, default: '', diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/execute.ts index cc3420e1d2..5c0688d367 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/execute.ts @@ -1,18 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest -} from '../../../transport'; +import { apiRequest } from '../../../transport'; - -export async function getContact(this: IExecuteFunctions, index: number): Promise { +export async function getContact( + this: IExecuteFunctions, + index: number, +): Promise { const id = this.getNodeParameter('contactId', index) as string; const qs = {} as IDataObject; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/index.ts index 00abd8c120..e5e9388e5f 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/index.ts @@ -1,7 +1,4 @@ import { getContact as execute } from './execute'; import { contactGetDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/getAll/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/getAll/description.ts index f69f1672fb..0bfc703726 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/getAll/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/getAll/description.ts @@ -1,6 +1,4 @@ -import { - ContactProperties, -} from '../../Interfaces'; +import { ContactProperties } from '../../Interfaces'; export const contactGetAllDescription: ContactProperties = [ { @@ -9,12 +7,8 @@ export const contactGetAllDescription: ContactProperties = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, noDataExpression: true, @@ -31,15 +25,9 @@ export const contactGetAllDescription: ContactProperties = [ description: 'Max number of results to return', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['contact'], + operation: ['getAll'], + returnAll: [false], }, }, default: 25, diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/getAll/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/getAll/execute.ts index 4b6a8dac46..22b61b43f7 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/getAll/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/getAll/execute.ts @@ -1,17 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, apiRequestAllItems -} from '../../../transport'; +import { apiRequest, apiRequestAllItems } from '../../../transport'; -export async function getAll(this: IExecuteFunctions, index: number): Promise { +export async function getAll( + this: IExecuteFunctions, + index: number, +): Promise { const returnAll = this.getNodeParameter('returnAll', index) as boolean; const qs = {} as IDataObject; @@ -26,6 +22,6 @@ export async function getAll(this: IExecuteFunctions, index: number): Promise { +export async function updateContact( + this: IExecuteFunctions, + index: number, +): Promise { const id = this.getNodeParameter('contactId', index) as IDataObject; - const { address, customerId, email, name, notes, phone } = this.getNodeParameter('updateFields', index) as IDataObject; + const { address, customerId, email, name, notes, phone } = this.getNodeParameter( + 'updateFields', + index, + ) as IDataObject; const qs = {} as IDataObject; const requestMethod = 'PUT'; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/update/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/update/index.ts index 76e1c8b3f3..55a3a16158 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/update/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/update/index.ts @@ -1,7 +1,4 @@ import { updateContact as execute } from './execute'; import { contactUpdateDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/description.ts index 3e8bc25cee..c94e9812f0 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/description.ts @@ -1,10 +1,6 @@ -import { - CustomerProperties, -} from '../../Interfaces'; +import { CustomerProperties } from '../../Interfaces'; -import { - addressFixedCollection -} from '../../../methods/sharedFields'; +import { addressFixedCollection } from '../../../methods/sharedFields'; export const customerCreateDescription: CustomerProperties = [ { @@ -14,12 +10,8 @@ export const customerCreateDescription: CustomerProperties = [ placeholder: 'name@email.com', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'create', - ], + resource: ['customer'], + operation: ['create'], }, }, default: '', @@ -31,12 +23,8 @@ export const customerCreateDescription: CustomerProperties = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'create', - ], + resource: ['customer'], + operation: ['create'], }, }, default: {}, @@ -95,9 +83,7 @@ export const customerCreateDescription: CustomerProperties = [ default: '', displayOptions: { show: { - noEmail: [ - false, - ], + noEmail: [false], }, }, }, @@ -112,7 +98,8 @@ export const customerCreateDescription: CustomerProperties = [ name: 'referredBy', type: 'string', default: '', - description: 'Source from which customer is referred to the platform like Linkedin, Google, Customer name etc', + description: + 'Source from which customer is referred to the platform like Linkedin, Google, Customer name etc', }, ], }, diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/execute.ts index 51fd1e81b6..e3db8c6665 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/execute.ts @@ -1,19 +1,27 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; -export async function addCustomer(this: IExecuteFunctions, index: number): Promise { +export async function addCustomer( + this: IExecuteFunctions, + index: number, +): Promise { const email = this.getNodeParameter('email', index) as IDataObject; - const { address, getSms, businessName, lastname, firstName, invoiceCcEmails, noEmail, notes, notificationEmail, phone, referredBy } = this.getNodeParameter('additionalFields', index) as IDataObject; + const { + address, + getSms, + businessName, + lastname, + firstName, + invoiceCcEmails, + noEmail, + notes, + notificationEmail, + phone, + referredBy, + } = this.getNodeParameter('additionalFields', index) as IDataObject; const qs = {} as IDataObject; const requestMethod = 'POST'; @@ -32,7 +40,7 @@ export async function addCustomer(this: IExecuteFunctions, index: number): Promi email, firstname: firstName, get_sms: getSms, - invoice_cc_emails: (invoiceCcEmails as string[] || []).join(','), + invoice_cc_emails: ((invoiceCcEmails as string[]) || []).join(','), lastname, no_email: noEmail, notes, diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/index.ts index eb10582aa7..2d14aaa37a 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/index.ts @@ -1,7 +1,4 @@ import { addCustomer as execute } from './execute'; import { customerCreateDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/description.ts index bcc6c86cd9..9905147fb2 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/description.ts @@ -1,6 +1,4 @@ -import { - CustomerProperties, -} from '../../Interfaces'; +import { CustomerProperties } from '../../Interfaces'; export const customerDeleteDescription: CustomerProperties = [ { @@ -10,12 +8,8 @@ export const customerDeleteDescription: CustomerProperties = [ required: true, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'delete', - ], + resource: ['customer'], + operation: ['delete'], }, }, default: '', diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/execute.ts index 9544e90460..80d02e3eff 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/execute.ts @@ -1,18 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest -} from '../../../transport'; +import { apiRequest } from '../../../transport'; - -export async function deleteCustomer(this: IExecuteFunctions, index: number): Promise { +export async function deleteCustomer( + this: IExecuteFunctions, + index: number, +): Promise { const id = this.getNodeParameter('customerId', index) as string; const qs = {} as IDataObject; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/index.ts index 432674f0bc..b2a8983763 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/index.ts @@ -1,7 +1,4 @@ import { deleteCustomer as execute } from './execute'; import { customerDeleteDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/description.ts index 97219de6c5..ae46d4b69c 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/description.ts @@ -1,6 +1,4 @@ -import { - CustomerProperties, -} from '../../Interfaces'; +import { CustomerProperties } from '../../Interfaces'; export const customerGetDescription: CustomerProperties = [ { @@ -10,12 +8,8 @@ export const customerGetDescription: CustomerProperties = [ required: true, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'get', - ], + resource: ['customer'], + operation: ['get'], }, }, default: '', diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/execute.ts index ef19b46939..150901c698 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/execute.ts @@ -1,18 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest -} from '../../../transport'; +import { apiRequest } from '../../../transport'; - -export async function getCustomer(this: IExecuteFunctions, index: number): Promise { +export async function getCustomer( + this: IExecuteFunctions, + index: number, +): Promise { const id = this.getNodeParameter('customerId', index) as string; const qs = {} as IDataObject; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/index.ts index 5f17c92b2e..bbe397550b 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/index.ts @@ -1,7 +1,4 @@ import { getCustomer as execute } from './execute'; import { customerGetDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/description.ts index 7eed7a077e..846b07e482 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/description.ts @@ -1,6 +1,4 @@ -import { - CustomerProperties, -} from '../../Interfaces'; +import { CustomerProperties } from '../../Interfaces'; export const customerGetAllDescription: CustomerProperties = [ { @@ -9,12 +7,8 @@ export const customerGetAllDescription: CustomerProperties = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'getAll', - ], + resource: ['customer'], + operation: ['getAll'], }, }, default: false, @@ -30,15 +24,9 @@ export const customerGetAllDescription: CustomerProperties = [ }, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['customer'], + operation: ['getAll'], + returnAll: [false], }, }, default: 25, @@ -51,12 +39,8 @@ export const customerGetAllDescription: CustomerProperties = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'getAll', - ], + resource: ['customer'], + operation: ['getAll'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/execute.ts index ec2ab11915..7a883e7606 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/execute.ts @@ -1,18 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, apiRequestAllItems -} from '../../../transport'; +import { apiRequest, apiRequestAllItems } from '../../../transport'; - -export async function getAll(this: IExecuteFunctions, index: number): Promise { +export async function getAll( + this: IExecuteFunctions, + index: number, +): Promise { const returnAll = this.getNodeParameter('returnAll', index) as boolean; const filters = this.getNodeParameter('filters', index) as IDataObject; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/index.ts index 0c41710eb5..974c0543b3 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/index.ts @@ -1,7 +1,4 @@ import { getAll as execute } from './execute'; import { customerGetAllDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/index.ts index 899e31e76e..edf38925ff 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/index.ts @@ -1,4 +1,3 @@ - import * as getAll from './getAll'; import * as create from './create'; import * as del from './del'; @@ -7,14 +6,7 @@ import * as get from './get'; import { INodeProperties } from 'n8n-workflow'; -export { - getAll, - create, - del as delete, - update, - get, -}; - +export { getAll, create, del as delete, update, get }; export const descriptions = [ { @@ -24,9 +16,7 @@ export const descriptions = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'customer', - ], + resource: ['customer'], }, }, options: [ @@ -69,4 +59,3 @@ export const descriptions = [ ...del.description, ...update.description, ] as INodeProperties[]; - diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/description.ts index dc01880546..815c47ab77 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/description.ts @@ -1,10 +1,6 @@ -import { - CustomerProperties, -} from '../../Interfaces'; +import { CustomerProperties } from '../../Interfaces'; -import { - addressFixedCollection -} from '../../../methods/sharedFields'; +import { addressFixedCollection } from '../../../methods/sharedFields'; export const customerUpdateDescription: CustomerProperties = [ { @@ -13,12 +9,8 @@ export const customerUpdateDescription: CustomerProperties = [ type: 'string', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'update', - ], + resource: ['customer'], + operation: ['update'], }, }, default: '', @@ -30,12 +22,8 @@ export const customerUpdateDescription: CustomerProperties = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'update', - ], + resource: ['customer'], + operation: ['update'], }, }, default: {}, @@ -101,9 +89,7 @@ export const customerUpdateDescription: CustomerProperties = [ default: '', displayOptions: { show: { - noEmail: [ - false, - ], + noEmail: [false], }, }, }, @@ -118,7 +104,8 @@ export const customerUpdateDescription: CustomerProperties = [ name: 'referredBy', type: 'string', default: '', - description: 'Source from which customer is referred to the platform like Linkedin, Google, Customer name etc', + description: + 'Source from which customer is referred to the platform like Linkedin, Google, Customer name etc', }, ], }, diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/execute.ts index b68fddd7e7..ddd6887e66 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/execute.ts @@ -1,22 +1,28 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, NodeApiError } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; - -export async function updateCustomer(this: IExecuteFunctions, index: number): Promise { +export async function updateCustomer( + this: IExecuteFunctions, + index: number, +): Promise { const id = this.getNodeParameter('customerId', index) as IDataObject; - const { address, businessName, email, firstName, getSms, invoiceCcEmails, - lastName, noEmail, notes, notificationEmail, phone, referredBy } = this.getNodeParameter('updateFields', index) as IDataObject; + const { + address, + businessName, + email, + firstName, + getSms, + invoiceCcEmails, + lastName, + noEmail, + notes, + notificationEmail, + phone, + referredBy, + } = this.getNodeParameter('updateFields', index) as IDataObject; const qs = {} as IDataObject; const requestMethod = 'PUT'; @@ -35,7 +41,7 @@ export async function updateCustomer(this: IExecuteFunctions, index: number): Pr email, firstname: firstName, get_sms: getSms, - invoice_cc_emails: (invoiceCcEmails as string[] || []).join(','), + invoice_cc_emails: ((invoiceCcEmails as string[]) || []).join(','), lastname: lastName, no_email: noEmail, notes, @@ -47,7 +53,10 @@ export async function updateCustomer(this: IExecuteFunctions, index: number): Pr let responseData; responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); if (!responseData.customer) { - throw new NodeApiError(this.getNode(), responseData, { httpCode: '404', message: 'Customer ID not found' }); + throw new NodeApiError(this.getNode(), responseData, { + httpCode: '404', + message: 'Customer ID not found', + }); } return this.helpers.returnJsonArray(responseData.customer); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/index.ts index 4c952aecf5..145cbcc32b 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/index.ts @@ -1,7 +1,4 @@ import { updateCustomer as execute } from './execute'; import { customerUpdateDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/description.ts index 251f20a057..e98ac9c76f 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/description.ts @@ -1,6 +1,4 @@ -import { - RmmProperties, -} from '../../Interfaces'; +import { RmmProperties } from '../../Interfaces'; export const rmmCreateDescription: RmmProperties = [ { @@ -9,12 +7,8 @@ export const rmmCreateDescription: RmmProperties = [ type: 'string', displayOptions: { show: { - resource: [ - 'rmm', - ], - operation: [ - 'create', - ], + resource: ['rmm'], + operation: ['create'], }, }, default: '', @@ -25,12 +19,8 @@ export const rmmCreateDescription: RmmProperties = [ type: 'string', displayOptions: { show: { - resource: [ - 'rmm', - ], - operation: [ - 'create', - ], + resource: ['rmm'], + operation: ['create'], }, }, default: '', @@ -41,12 +31,8 @@ export const rmmCreateDescription: RmmProperties = [ type: 'string', displayOptions: { show: { - resource: [ - 'rmm', - ], - operation: [ - 'create', - ], + resource: ['rmm'], + operation: ['create'], }, }, default: '', @@ -58,12 +44,8 @@ export const rmmCreateDescription: RmmProperties = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'rmm', - ], - operation: [ - 'create', - ], + resource: ['rmm'], + operation: ['create'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/execute.ts index 56e9f4235d..e5c874fb16 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/execute.ts @@ -1,18 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; - -export async function addAlert(this: IExecuteFunctions, index: number): Promise { +export async function addAlert( + this: IExecuteFunctions, + index: number, +): Promise { const customerId = this.getNodeParameter('customerId', index) as IDataObject; const assetId = this.getNodeParameter('assetId', index) as IDataObject; const description = this.getNodeParameter('description', index) as IDataObject; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/index.ts index 386e536b3a..6b44825e55 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/index.ts @@ -1,7 +1,4 @@ import { addAlert as execute } from './execute'; import { rmmCreateDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/description.ts index 48a34c8ded..9da28d50b4 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/description.ts @@ -1,6 +1,4 @@ -import { - RmmProperties, -} from '../../Interfaces'; +import { RmmProperties } from '../../Interfaces'; export const rmmDeleteDescription: RmmProperties = [ { @@ -10,12 +8,8 @@ export const rmmDeleteDescription: RmmProperties = [ required: true, displayOptions: { show: { - resource: [ - 'rmm', - ], - operation: [ - 'delete', - ], + resource: ['rmm'], + operation: ['delete'], }, }, default: '', diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/execute.ts index 787fa91b19..7647eab89f 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/execute.ts @@ -1,18 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest -} from '../../../transport'; +import { apiRequest } from '../../../transport'; - -export async function deleteAlert(this: IExecuteFunctions, index: number): Promise { +export async function deleteAlert( + this: IExecuteFunctions, + index: number, +): Promise { const id = this.getNodeParameter('alertId', index) as string; const qs = {} as IDataObject; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/index.ts index 38e9ec4508..cfedcddc59 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/index.ts @@ -1,7 +1,4 @@ import { deleteAlert as execute } from './execute'; import { rmmDeleteDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/description.ts index 492f77824d..0a4daed161 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/description.ts @@ -1,6 +1,4 @@ -import { - RmmProperties, -} from '../../Interfaces'; +import { RmmProperties } from '../../Interfaces'; export const rmmGetDescription: RmmProperties = [ { @@ -10,12 +8,8 @@ export const rmmGetDescription: RmmProperties = [ required: true, displayOptions: { show: { - resource: [ - 'rmm', - ], - operation: [ - 'get', - ], + resource: ['rmm'], + operation: ['get'], }, }, default: '', diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/execute.ts index 8784b2ec9c..5c8ccec151 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/execute.ts @@ -1,18 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest -} from '../../../transport'; +import { apiRequest } from '../../../transport'; - -export async function getAlert(this: IExecuteFunctions, index: number): Promise { +export async function getAlert( + this: IExecuteFunctions, + index: number, +): Promise { const id = this.getNodeParameter('alertId', index) as string; const qs = {} as IDataObject; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/index.ts index 6313d25479..df6bf2174c 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/index.ts @@ -1,7 +1,4 @@ import { getAlert as execute } from './execute'; import { rmmGetDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/description.ts index ed611d186c..1373bf9aba 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/description.ts @@ -1,6 +1,4 @@ -import { - RmmProperties, -} from '../../Interfaces'; +import { RmmProperties } from '../../Interfaces'; export const rmmGetAllDescription: RmmProperties = [ { @@ -9,12 +7,8 @@ export const rmmGetAllDescription: RmmProperties = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'rmm', - ], - operation: [ - 'getAll', - ], + resource: ['rmm'], + operation: ['getAll'], }, }, default: false, @@ -30,15 +24,9 @@ export const rmmGetAllDescription: RmmProperties = [ }, displayOptions: { show: { - resource: [ - 'rmm', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['rmm'], + operation: ['getAll'], + returnAll: [false], }, }, default: 25, @@ -51,12 +39,8 @@ export const rmmGetAllDescription: RmmProperties = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'rmm', - ], - operation: [ - 'getAll', - ], + resource: ['rmm'], + operation: ['getAll'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/execute.ts index 7a740b74e8..96e5eb249e 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/execute.ts @@ -1,17 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, apiRequestAllItems -} from '../../../transport'; +import { apiRequest, apiRequestAllItems } from '../../../transport'; -export async function getAll(this: IExecuteFunctions, index: number): Promise { +export async function getAll( + this: IExecuteFunctions, + index: number, +): Promise { const returnAll = this.getNodeParameter('returnAll', index) as boolean; const filters = this.getNodeParameter('filters', index) as IDataObject; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/index.ts index 473b835756..ad77601d55 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/index.ts @@ -1,7 +1,4 @@ import { getAll as execute } from './execute'; import { rmmGetAllDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/index.ts index c64d316835..cb39d724b3 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/index.ts @@ -1,4 +1,3 @@ - import * as get from './get'; import * as getAll from './getAll'; import * as create from './create'; @@ -7,14 +6,7 @@ import * as mute from './mute'; import { INodeProperties } from 'n8n-workflow'; -export { - getAll, - get, - mute, - del as delete, - create, -}; - +export { getAll, get, mute, del as delete, create }; export const descriptions = [ { @@ -24,9 +16,7 @@ export const descriptions = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'rmm', - ], + resource: ['rmm'], }, }, options: [ diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/description.ts index 38f17f4058..1fc7c22739 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/description.ts @@ -1,6 +1,4 @@ -import { - RmmProperties, -} from '../../Interfaces'; +import { RmmProperties } from '../../Interfaces'; export const rmmMuteDescription: RmmProperties = [ { @@ -10,12 +8,8 @@ export const rmmMuteDescription: RmmProperties = [ required: true, displayOptions: { show: { - resource: [ - 'rmm', - ], - operation: [ - 'mute', - ], + resource: ['rmm'], + operation: ['mute'], }, }, default: '', @@ -27,12 +21,8 @@ export const rmmMuteDescription: RmmProperties = [ type: 'options', displayOptions: { show: { - resource: [ - 'rmm', - ], - operation: [ - 'mute', - ], + resource: ['rmm'], + operation: ['mute'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/execute.ts index 3cc2d5cd76..4195529221 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/execute.ts @@ -1,18 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest -} from '../../../transport'; +import { apiRequest } from '../../../transport'; - -export async function muteAlert(this: IExecuteFunctions, index: number): Promise { +export async function muteAlert( + this: IExecuteFunctions, + index: number, +): Promise { const id = this.getNodeParameter('alertId', index) as string; const mute = this.getNodeParameter('muteFor', index) as string; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/index.ts index d38bfec5a3..d39e22fffb 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/index.ts @@ -1,7 +1,4 @@ import { muteAlert as execute } from './execute'; import { rmmMuteDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/router.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/router.ts index 73522cbbc5..4e35bb8d69 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/router.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/router.ts @@ -1,10 +1,6 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - INodeExecutionData, NodeApiError, -} from 'n8n-workflow'; +import { INodeExecutionData, NodeApiError } from 'n8n-workflow'; import * as customer from './customer'; import * as ticket from './ticket'; @@ -31,13 +27,13 @@ export async function router(this: IExecuteFunctions): Promise { +export async function createTicket( + this: IExecuteFunctions, + index: number, +): Promise { const id = this.getNodeParameter('customerId', index) as IDataObject; const subject = this.getNodeParameter('subject', index) as IDataObject; - const { assetId, dueDate, issueType, status, contactId } = this.getNodeParameter('additionalFields', index) as IDataObject; + const { assetId, dueDate, issueType, status, contactId } = this.getNodeParameter( + 'additionalFields', + index, + ) as IDataObject; const qs = {} as IDataObject; const requestMethod = 'POST'; @@ -33,7 +32,7 @@ export async function createTicket(this: IExecuteFunctions, index: number): Prom body.subject = subject; let responseData; - + responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData.ticket); diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/create/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/create/index.ts index e0423e0b0d..0a3b178def 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/create/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/create/index.ts @@ -1,7 +1,4 @@ import { createTicket as execute } from './execute'; import { ticketCreateDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/description.ts index 90453c9673..c44e33e019 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/description.ts @@ -1,6 +1,4 @@ -import { - TicketProperties, -} from '../../Interfaces'; +import { TicketProperties } from '../../Interfaces'; export const ticketDeleteDescription: TicketProperties = [ { @@ -10,12 +8,8 @@ export const ticketDeleteDescription: TicketProperties = [ type: 'string', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'delete', - ], + resource: ['ticket'], + operation: ['delete'], }, }, default: '', diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/execute.ts index a646e9f52a..d7935a270e 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/execute.ts @@ -1,18 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest -} from '../../../transport'; +import { apiRequest } from '../../../transport'; - -export async function deleteTicket(this: IExecuteFunctions, index: number): Promise { +export async function deleteTicket( + this: IExecuteFunctions, + index: number, +): Promise { const id = this.getNodeParameter('ticketId', index) as string; const qs = {} as IDataObject; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/index.ts index b30a627649..8919e1726f 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/del/index.ts @@ -1,7 +1,4 @@ import { deleteTicket as execute } from './execute'; import { ticketDeleteDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/description.ts index fa220e6e11..95e0e55be3 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/description.ts @@ -1,6 +1,4 @@ -import { - TicketProperties, -} from '../../Interfaces'; +import { TicketProperties } from '../../Interfaces'; export const ticketGetDescription: TicketProperties = [ { @@ -9,12 +7,8 @@ export const ticketGetDescription: TicketProperties = [ type: 'string', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'get', - ], + resource: ['ticket'], + operation: ['get'], }, }, default: '', diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/execute.ts index b87f461769..e9264f70b0 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/execute.ts @@ -1,18 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest -} from '../../../transport'; +import { apiRequest } from '../../../transport'; - -export async function getTicket(this: IExecuteFunctions, index: number): Promise { +export async function getTicket( + this: IExecuteFunctions, + index: number, +): Promise { const id = this.getNodeParameter('ticketId', index) as string; const qs = {} as IDataObject; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/index.ts index 8987de0091..530eec20d8 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/get/index.ts @@ -1,7 +1,4 @@ import { getTicket as execute } from './execute'; import { ticketGetDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/description.ts index 72d8bef357..e2b3bb1810 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/description.ts @@ -1,6 +1,4 @@ -import { - TicketProperties, -} from '../../Interfaces'; +import { TicketProperties } from '../../Interfaces'; export const ticketGetAllDescription: TicketProperties = [ { @@ -9,12 +7,8 @@ export const ticketGetAllDescription: TicketProperties = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], + resource: ['ticket'], + operation: ['getAll'], }, }, default: false, @@ -30,15 +24,9 @@ export const ticketGetAllDescription: TicketProperties = [ }, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['ticket'], + operation: ['getAll'], + returnAll: [false], }, }, default: 25, @@ -51,12 +39,8 @@ export const ticketGetAllDescription: TicketProperties = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], + resource: ['ticket'], + operation: ['getAll'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/execute.ts index ff29e46e39..60cf089286 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/execute.ts @@ -1,18 +1,13 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - apiRequest, apiRequestAllItems -} from '../../../transport'; +import { apiRequest, apiRequestAllItems } from '../../../transport'; - -export async function getAll(this: IExecuteFunctions, index: number): Promise { +export async function getAll( + this: IExecuteFunctions, + index: number, +): Promise { const returnAll = this.getNodeParameter('returnAll', index) as boolean; const filters = this.getNodeParameter('filters', index) as IDataObject; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/index.ts index 3a74352f14..93420f25d4 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/getAll/index.ts @@ -1,7 +1,4 @@ import { getAll as execute } from './execute'; import { ticketGetAllDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/index.ts index aeb0a10bd2..f7fe083efc 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/index.ts @@ -1,4 +1,3 @@ - import * as getAll from './getAll'; import * as create from './create'; import * as get from './get'; @@ -7,13 +6,7 @@ import * as update from './update'; import { INodeProperties } from 'n8n-workflow'; -export { - getAll, - create, - get, - del as delete, - update, -}; +export { getAll, create, get, del as delete, update }; export const descriptions = [ { @@ -23,9 +16,7 @@ export const descriptions = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'ticket', - ], + resource: ['ticket'], }, }, options: [ diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/description.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/description.ts index 72549038be..112915c2b2 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/description.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/description.ts @@ -1,6 +1,4 @@ -import { - TicketProperties, -} from '../../Interfaces'; +import { TicketProperties } from '../../Interfaces'; export const ticketUpdateDescription: TicketProperties = [ { @@ -10,12 +8,8 @@ export const ticketUpdateDescription: TicketProperties = [ required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'update', - ], + resource: ['ticket'], + operation: ['update'], }, }, default: '', @@ -27,12 +21,8 @@ export const ticketUpdateDescription: TicketProperties = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'update', - ], + resource: ['ticket'], + operation: ['update'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/execute.ts index 696a65e130..85a5dec98c 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/execute.ts @@ -1,22 +1,16 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, NodeOperationError } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; - -export async function updateTicket(this: IExecuteFunctions, index: number): Promise { +export async function updateTicket( + this: IExecuteFunctions, + index: number, +): Promise { const id = this.getNodeParameter('ticketId', index) as IDataObject; - const { assetId, customerId, dueDate, issueType, status, subject, ticketType, contactId } = this.getNodeParameter('updateFields', index) as IDataObject; - + const { assetId, customerId, dueDate, issueType, status, subject, ticketType, contactId } = + this.getNodeParameter('updateFields', index) as IDataObject; const qs = {} as IDataObject; const requestMethod = 'PUT'; @@ -35,7 +29,9 @@ export async function updateTicket(this: IExecuteFunctions, index: number): Prom }; if (!Object.keys(body).length) { - throw new NodeOperationError(this.getNode(), 'At least one update fields has to be defined', { itemIndex: index }); + throw new NodeOperationError(this.getNode(), 'At least one update fields has to be defined', { + itemIndex: index, + }); } let responseData; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/index.ts index 96e02e7207..98547072fe 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/update/index.ts @@ -1,7 +1,4 @@ import { updateTicket as execute } from './execute'; import { ticketUpdateDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/versionDescription.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/versionDescription.ts index 986948c0a5..1096519851 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/versionDescription.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/versionDescription.ts @@ -1,7 +1,5 @@ /* eslint-disable n8n-nodes-base/node-filename-against-convention */ -import { - INodeTypeDescription, -} from 'n8n-workflow'; +import { INodeTypeDescription } from 'n8n-workflow'; import * as customer from './customer'; import * as ticket from './ticket'; diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/methods/loadOptions.ts b/packages/nodes-base/nodes/SyncroMSP/v1/methods/loadOptions.ts index 2cc28e2156..71fbb0c3fa 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/methods/loadOptions.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/methods/loadOptions.ts @@ -5,9 +5,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - apiRequestAllItems, -} from '../transport'; +import { apiRequestAllItems } from '../transport'; // Get all the available channels @@ -28,11 +26,14 @@ export async function getCustomers(this: ILoadOptionsFunctions): Promise { - if (a.name < b.name) { return -1; } - if (a.name > b.name) { return 1; } + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } return 0; }); return returnData; } - diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/methods/sharedFields.ts b/packages/nodes-base/nodes/SyncroMSP/v1/methods/sharedFields.ts index 2afea1f686..a832cecafa 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/methods/sharedFields.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/methods/sharedFields.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const addressFixedCollection: INodeProperties = { displayName: 'Address', diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/transport/index.ts b/packages/nodes-base/nodes/SyncroMSP/v1/transport/index.ts index 890e56ec54..28ffee3493 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/transport/index.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/transport/index.ts @@ -1,8 +1,4 @@ -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { GenericValue, @@ -50,7 +46,6 @@ export async function apiRequestAllItems( body: IDataObject = {}, query: IDataObject = {}, ) { - let returnData: IDataObject[] = []; let responseData; @@ -60,21 +55,20 @@ export async function apiRequestAllItems( responseData = await apiRequest.call(this, method, endpoint, body, query); query.page++; returnData = returnData.concat(responseData[endpoint]); - } while ( - responseData[endpoint].length !== 0 - ); + } while (responseData[endpoint].length !== 0); return returnData; } -export async function validateCredentials(this: ICredentialTestFunctions, decryptedCredentials: ICredentialDataDecryptedObject): Promise { // tslint:disable-line:no-any +export async function validateCredentials( + this: ICredentialTestFunctions, + decryptedCredentials: ICredentialDataDecryptedObject, + // tslint:disable-next-line:no-any +): Promise { const credentials = decryptedCredentials; - const { - subdomain, - apiKey, - } = credentials as { - subdomain: string, - apiKey: string, + const { subdomain, apiKey } = credentials as { + subdomain: string; + apiKey: string; }; const options: IHttpRequestOptions = { diff --git a/packages/nodes-base/nodes/Taiga/GenericFunctions.ts b/packages/nodes-base/nodes/Taiga/GenericFunctions.ts index 0b9996e198..73870df262 100644 --- a/packages/nodes-base/nodes/Taiga/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Taiga/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -17,12 +15,15 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - createHash, -} from 'crypto'; +import { createHash } from 'crypto'; export async function getAuthorization( - this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, + this: + | IHookFunctions + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IWebhookFunctions, credentials?: ICredentialDataDecryptedObject, ): Promise { if (credentials === undefined) { @@ -38,7 +39,7 @@ export async function getAuthorization( password, username, }, - uri: (credentials.url) ? `${credentials.url}/api/v1/auth` : 'https://api.taiga.io/api/v1/auth', + uri: credentials.url ? `${credentials.url}/api/v1/auth` : 'https://api.taiga.io/api/v1/auth', json: true, }; @@ -52,14 +53,20 @@ export async function getAuthorization( } export async function taigaApiRequest( - this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, + this: + | IHookFunctions + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IWebhookFunctions, method: string, resource: string, body = {}, query = {}, uri?: string | undefined, option = {}, -): Promise { // tslint:disable-line:no-any + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('taigaApi'); const authToken = await getAuthorization.call(this, credentials); @@ -74,7 +81,10 @@ export async function taigaApiRequest( qs: query, method, body, - uri: uri || (credentials.url) ? `${credentials.url}/api/v1${resource}` : `https://api.taiga.io/api/v1${resource}`, + uri: + uri || credentials.url + ? `${credentials.url}/api/v1${resource}` + : `https://api.taiga.io/api/v1${resource}`, json: true, }; @@ -89,8 +99,15 @@ export async function taigaApiRequest( } } -export async function taigaApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function taigaApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -98,7 +115,9 @@ export async function taigaApiRequestAllItems(this: IHookFunctions | IExecuteFun let uri: string | undefined; do { - responseData = await taigaApiRequest.call(this, method, resource, body, query, uri, { resolveWithFullResponse: true }); + responseData = await taigaApiRequest.call(this, method, resource, body, query, uri, { + resolveWithFullResponse: true, + }); returnData.push.apply(returnData, responseData.body); uri = responseData.headers['x-pagination-next']; if (query.limit && returnData.length >= query.limit) { @@ -140,19 +159,13 @@ export async function handleListing( export const toOptions = (items: LoadedResource[]) => items.map(({ name, id }) => ({ name, value: id })); -export function throwOnEmptyUpdate( - this: IExecuteFunctions, - resource: Resource, -) { +export function throwOnEmptyUpdate(this: IExecuteFunctions, resource: Resource) { throw new NodeOperationError( this.getNode(), `Please enter at least one field to update for the ${resource}.`, ); } -export async function getVersionForUpdate( - this: IExecuteFunctions, - endpoint: string, -) { - return await taigaApiRequest.call(this, 'GET', endpoint).then(response => response.version); +export async function getVersionForUpdate(this: IExecuteFunctions, endpoint: string) { + return await taigaApiRequest.call(this, 'GET', endpoint).then((response) => response.version); } diff --git a/packages/nodes-base/nodes/Taiga/Taiga.node.ts b/packages/nodes-base/nodes/Taiga/Taiga.node.ts index 33d3776bc7..9bdc61135e 100644 --- a/packages/nodes-base/nodes/Taiga/Taiga.node.ts +++ b/packages/nodes-base/nodes/Taiga/Taiga.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -91,70 +89,128 @@ export class Taiga implements INodeType { loadOptions: { async getEpics(this: ILoadOptionsFunctions): Promise { const project = this.getCurrentNodeParameter('projectId') as string; - const epics = await taigaApiRequest.call(this, 'GET', '/epics', {}, { project }) as LoadedEpic[]; + const epics = (await taigaApiRequest.call( + this, + 'GET', + '/epics', + {}, + { project }, + )) as LoadedEpic[]; return epics.map(({ subject, id }) => ({ name: subject, value: id })); }, async getMilestones(this: ILoadOptionsFunctions): Promise { const project = this.getCurrentNodeParameter('projectId') as string; - const milestones = await taigaApiRequest.call(this, 'GET', '/milestones', {}, { project }) as LoadedResource[]; + const milestones = (await taigaApiRequest.call( + this, + 'GET', + '/milestones', + {}, + { project }, + )) as LoadedResource[]; return toOptions(milestones); }, async getPriorities(this: ILoadOptionsFunctions): Promise { const project = this.getCurrentNodeParameter('projectId') as string; - const priorities = await taigaApiRequest.call(this, 'GET', '/priorities', {}, { project }) as LoadedResource[]; + const priorities = (await taigaApiRequest.call( + this, + 'GET', + '/priorities', + {}, + { project }, + )) as LoadedResource[]; return toOptions(priorities); }, async getProjects(this: ILoadOptionsFunctions): Promise { - const { id } = await taigaApiRequest.call(this, 'GET', '/users/me') as { id: string }; - const projects = await taigaApiRequest.call(this, 'GET', '/projects', {}, { member: id }) as LoadedResource[]; + const { id } = (await taigaApiRequest.call(this, 'GET', '/users/me')) as { id: string }; + const projects = (await taigaApiRequest.call( + this, + 'GET', + '/projects', + {}, + { member: id }, + )) as LoadedResource[]; return toOptions(projects); }, async getRoles(this: ILoadOptionsFunctions): Promise { const project = this.getCurrentNodeParameter('projectId') as string; - const roles = await taigaApiRequest.call(this, 'GET', '/roles', {}, { project }) as LoadedResource[]; + const roles = (await taigaApiRequest.call( + this, + 'GET', + '/roles', + {}, + { project }, + )) as LoadedResource[]; return toOptions(roles); }, async getSeverities(this: ILoadOptionsFunctions): Promise { const project = this.getCurrentNodeParameter('projectId') as string; - const severities = await taigaApiRequest.call(this, 'GET', '/severities', {}, { project }) as LoadedResource[]; + const severities = (await taigaApiRequest.call( + this, + 'GET', + '/severities', + {}, + { project }, + )) as LoadedResource[]; return toOptions(severities); }, async getTags(this: ILoadOptionsFunctions): Promise { const project = this.getCurrentNodeParameter('projectId') as string; - const tags = await taigaApiRequest.call(this, 'GET', `/projects/${project}/tags_colors`) as LoadedTags; + const tags = (await taigaApiRequest.call( + this, + 'GET', + `/projects/${project}/tags_colors`, + )) as LoadedTags; - return Object.keys(tags).map(tag => ({ name: tag, value: tag })); + return Object.keys(tags).map((tag) => ({ name: tag, value: tag })); }, async getTypes(this: ILoadOptionsFunctions): Promise { const project = this.getCurrentNodeParameter('projectId') as string; - const types = await taigaApiRequest.call(this, 'GET', '/issue-types', {}, { project }) as LoadedResource[]; + const types = (await taigaApiRequest.call( + this, + 'GET', + '/issue-types', + {}, + { project }, + )) as LoadedResource[]; return toOptions(types); }, async getUsers(this: ILoadOptionsFunctions): Promise { const project = this.getCurrentNodeParameter('projectId') as string; - const users = await taigaApiRequest.call(this, 'GET', '/users', {}, { project }) as LoadedUser[]; + const users = (await taigaApiRequest.call( + this, + 'GET', + '/users', + {}, + { project }, + )) as LoadedUser[]; return users.map(({ full_name_display, id }) => ({ name: full_name_display, value: id })); }, async getUserStories(this: ILoadOptionsFunctions): Promise { const project = this.getCurrentNodeParameter('projectId') as string; - const userStories = await taigaApiRequest.call(this, 'GET', '/userstories', {}, { project }) as LoadedUserStory[]; + const userStories = (await taigaApiRequest.call( + this, + 'GET', + '/userstories', + {}, + { project }, + )) as LoadedUserStory[]; return userStories.map(({ subject, id }) => ({ name: subject, value: id })); }, @@ -163,21 +219,39 @@ export class Taiga implements INodeType { async getIssueStatuses(this: ILoadOptionsFunctions): Promise { const project = this.getCurrentNodeParameter('projectId') as string; - const statuses = await taigaApiRequest.call(this, 'GET', '/issue-statuses', {}, { project }) as LoadedResource[]; + const statuses = (await taigaApiRequest.call( + this, + 'GET', + '/issue-statuses', + {}, + { project }, + )) as LoadedResource[]; return toOptions(statuses); }, async getTaskStatuses(this: ILoadOptionsFunctions): Promise { const project = this.getCurrentNodeParameter('projectId') as string; - const statuses = await taigaApiRequest.call(this, 'GET', '/task-statuses', {}, { project }) as LoadedResource[]; + const statuses = (await taigaApiRequest.call( + this, + 'GET', + '/task-statuses', + {}, + { project }, + )) as LoadedResource[]; return toOptions(statuses); }, async getUserStoryStatuses(this: ILoadOptionsFunctions): Promise { const project = this.getCurrentNodeParameter('projectId') as string; - const statuses = await taigaApiRequest.call(this, 'GET', '/userstory-statuses', {}, { project }) as LoadedResource[]; + const statuses = (await taigaApiRequest.call( + this, + 'GET', + '/userstory-statuses', + {}, + { project }, + )) as LoadedResource[]; return toOptions(statuses); }, @@ -194,17 +268,13 @@ export class Taiga implements INodeType { let responseData; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'epic') { - // ********************************************************************** // epic // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // epic: create // ---------------------------------------- @@ -221,9 +291,7 @@ export class Taiga implements INodeType { } responseData = await taigaApiRequest.call(this, 'POST', '/epics', body); - } else if (operation === 'delete') { - // ---------------------------------------- // epic: delete // ---------------------------------------- @@ -232,9 +300,7 @@ export class Taiga implements INodeType { responseData = await taigaApiRequest.call(this, 'DELETE', `/epics/${epicId}`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // epic: get // ---------------------------------------- @@ -242,9 +308,7 @@ export class Taiga implements INodeType { const epicId = this.getNodeParameter('epicId', i); responseData = await taigaApiRequest.call(this, 'GET', `/epics/${epicId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // epic: getAll // ---------------------------------------- @@ -257,9 +321,7 @@ export class Taiga implements INodeType { } responseData = await handleListing.call(this, 'GET', '/epics', {}, qs, i); - } else if (operation === 'update') { - // ---------------------------------------- // epic: update // ---------------------------------------- @@ -277,17 +339,13 @@ export class Taiga implements INodeType { body.version = await getVersionForUpdate.call(this, `/epics/${epicId}`); responseData = await taigaApiRequest.call(this, 'PATCH', `/epics/${epicId}`, body); - } - } else if (resource === 'issue') { - // ********************************************************************** // issue // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // issue: create // ---------------------------------------- @@ -304,9 +362,7 @@ export class Taiga implements INodeType { } responseData = await taigaApiRequest.call(this, 'POST', '/issues', body); - } else if (operation === 'delete') { - // ---------------------------------------- // issue: delete // ---------------------------------------- @@ -315,9 +371,7 @@ export class Taiga implements INodeType { responseData = await taigaApiRequest.call(this, 'DELETE', `/issues/${issueId}`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // issue: get // ---------------------------------------- @@ -325,9 +379,7 @@ export class Taiga implements INodeType { const issueId = this.getNodeParameter('issueId', i); responseData = await taigaApiRequest.call(this, 'GET', `/issues/${issueId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // issue: getAll // ---------------------------------------- @@ -340,9 +392,7 @@ export class Taiga implements INodeType { } responseData = await handleListing.call(this, 'GET', '/issues', {}, qs, i); - } else if (operation === 'update') { - // ---------------------------------------- // issue: update // ---------------------------------------- @@ -360,17 +410,13 @@ export class Taiga implements INodeType { body.version = await getVersionForUpdate.call(this, `/issues/${issueId}`); responseData = await taigaApiRequest.call(this, 'PATCH', `/issues/${issueId}`, body); - } - } else if (resource === 'task') { - // ********************************************************************** // task // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // task: create // ---------------------------------------- @@ -387,9 +433,7 @@ export class Taiga implements INodeType { } responseData = await taigaApiRequest.call(this, 'POST', '/tasks', body); - } else if (operation === 'delete') { - // ---------------------------------------- // task: delete // ---------------------------------------- @@ -398,9 +442,7 @@ export class Taiga implements INodeType { responseData = await taigaApiRequest.call(this, 'DELETE', `/tasks/${taskId}`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // task: get // ---------------------------------------- @@ -408,9 +450,7 @@ export class Taiga implements INodeType { const taskId = this.getNodeParameter('taskId', i); responseData = await taigaApiRequest.call(this, 'GET', `/tasks/${taskId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // task: getAll // ---------------------------------------- @@ -423,9 +463,7 @@ export class Taiga implements INodeType { } responseData = await handleListing.call(this, 'GET', '/tasks', {}, qs, i); - } else if (operation === 'update') { - // ---------------------------------------- // task: update // ---------------------------------------- @@ -443,17 +481,13 @@ export class Taiga implements INodeType { body.version = await getVersionForUpdate.call(this, `/tasks/${taskId}`); responseData = await taigaApiRequest.call(this, 'PATCH', `/tasks/${taskId}`, body); - } - } else if (resource === 'userStory') { - // ********************************************************************** // userStory // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // userStory: create // ---------------------------------------- @@ -470,9 +504,7 @@ export class Taiga implements INodeType { } responseData = await taigaApiRequest.call(this, 'POST', '/userstories', body); - } else if (operation === 'delete') { - // ---------------------------------------- // userStory: delete // ---------------------------------------- @@ -482,9 +514,7 @@ export class Taiga implements INodeType { const endpoint = `/userstories/${userStoryId}`; responseData = await taigaApiRequest.call(this, 'DELETE', endpoint); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // userStory: get // ---------------------------------------- @@ -493,9 +523,7 @@ export class Taiga implements INodeType { const endpoint = `/userstories/${userStoryId}`; responseData = await taigaApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // userStory: getAll // ---------------------------------------- @@ -508,9 +536,7 @@ export class Taiga implements INodeType { } responseData = await handleListing.call(this, 'GET', '/userstories', {}, qs, i); - } else if (operation === 'update') { - // ---------------------------------------- // userStory: update // ---------------------------------------- @@ -527,12 +553,14 @@ export class Taiga implements INodeType { const userStoryId = this.getNodeParameter('userStoryId', i); body.version = await getVersionForUpdate.call(this, `/userstories/${userStoryId}`); - responseData = await taigaApiRequest.call(this, 'PATCH', `/userstories/${userStoryId}`, body); - + responseData = await taigaApiRequest.call( + this, + 'PATCH', + `/userstories/${userStoryId}`, + body, + ); } - } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -545,9 +573,8 @@ export class Taiga implements INodeType { Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } return [this.helpers.returnJsonArray(returnData)]; } -} \ No newline at end of file +} diff --git a/packages/nodes-base/nodes/Taiga/TaigaTrigger.node.ts b/packages/nodes-base/nodes/Taiga/TaigaTrigger.node.ts index 77114c3b4d..45e8c19c78 100644 --- a/packages/nodes-base/nodes/Taiga/TaigaTrigger.node.ts +++ b/packages/nodes-base/nodes/Taiga/TaigaTrigger.node.ts @@ -9,14 +9,9 @@ import { IWebhookResponseData, } from 'n8n-workflow'; -import { - IHookFunctions, -} from 'n8n-core'; +import { IHookFunctions } from 'n8n-core'; -import { - getAutomaticSecret, - taigaApiRequest, -} from './GenericFunctions'; +import { getAutomaticSecret, taigaApiRequest } from './GenericFunctions'; // import { // createHmac, @@ -55,7 +50,8 @@ export class TaigaTrigger implements INodeType { displayName: 'Project Name or ID', name: 'projectId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getUserProjects', }, @@ -67,9 +63,7 @@ export class TaigaTrigger implements INodeType { name: 'resources', type: 'multiOptions', required: true, - default: [ - 'all', - ], + default: ['all'], options: [ { name: 'All', @@ -103,9 +97,7 @@ export class TaigaTrigger implements INodeType { name: 'operations', type: 'multiOptions', required: true, - default: [ - 'all', - ], + default: ['all'], description: 'Operations to listen to', options: [ { @@ -246,9 +238,7 @@ export class TaigaTrigger implements INodeType { // } return { - workflowData: [ - this.helpers.returnJsonArray(body), - ], + workflowData: [this.helpers.returnJsonArray(body)], }; } } diff --git a/packages/nodes-base/nodes/Taiga/descriptions/EpicDescription.ts b/packages/nodes-base/nodes/Taiga/descriptions/EpicDescription.ts index 410a0e8b0a..7e3383affc 100644 --- a/packages/nodes-base/nodes/Taiga/descriptions/EpicDescription.ts +++ b/packages/nodes-base/nodes/Taiga/descriptions/EpicDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const epicOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const epicOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'epic', - ], + resource: ['epic'], }, }, options: [ @@ -58,7 +54,8 @@ export const epicFields: INodeProperties[] = [ { displayName: 'Project Name or ID', name: 'projectId', - description: 'ID of the project to which the epic belongs. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the project to which the epic belongs. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { loadOptionsMethod: 'getProjects', @@ -67,12 +64,8 @@ export const epicFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'epic', - ], - operation: [ - 'create', - ], + resource: ['epic'], + operation: ['create'], }, }, }, @@ -84,12 +77,8 @@ export const epicFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'epic', - ], - operation: [ - 'create', - ], + resource: ['epic'], + operation: ['create'], }, }, }, @@ -101,12 +90,8 @@ export const epicFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'epic', - ], - operation: [ - 'create', - ], + resource: ['epic'], + operation: ['create'], }, }, options: [ @@ -115,13 +100,12 @@ export const epicFields: INodeProperties[] = [ name: 'assigned_to', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the user to assign the epic to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to assign the epic to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Blocked Note', @@ -154,11 +138,10 @@ export const epicFields: INodeProperties[] = [ displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTags', }, default: [], @@ -178,12 +161,8 @@ export const epicFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'epic', - ], - operation: [ - 'delete', - ], + resource: ['epic'], + operation: ['delete'], }, }, }, @@ -200,12 +179,8 @@ export const epicFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'epic', - ], - operation: [ - 'get', - ], + resource: ['epic'], + operation: ['get'], }, }, }, @@ -216,7 +191,8 @@ export const epicFields: INodeProperties[] = [ { displayName: 'Project Name or ID', name: 'projectId', - description: 'ID of the project to which the epic belongs. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the project to which the epic belongs. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { loadOptionsMethod: 'getProjects', @@ -225,12 +201,8 @@ export const epicFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'epic', - ], - operation: [ - 'getAll', - ], + resource: ['epic'], + operation: ['getAll'], }, }, }, @@ -242,12 +214,8 @@ export const epicFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'epic', - ], - operation: [ - 'getAll', - ], + resource: ['epic'], + operation: ['getAll'], }, }, }, @@ -262,15 +230,9 @@ export const epicFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'epic', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['epic'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -281,12 +243,8 @@ export const epicFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'epic', - ], - operation: [ - 'getAll', - ], + resource: ['epic'], + operation: ['getAll'], }, }, default: {}, @@ -296,13 +254,12 @@ export const epicFields: INodeProperties[] = [ name: 'assigned_to', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the user whom the epic is assigned to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user whom the epic is assigned to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Is Closed', @@ -325,15 +282,12 @@ export const epicFields: INodeProperties[] = [ loadOptionsMethod: 'getProjects', }, default: '', - description: 'ID of the project to set the epic to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the project to set the epic to. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'epic', - ], - operation: [ - 'update', - ], + resource: ['epic'], + operation: ['update'], }, }, }, @@ -346,12 +300,8 @@ export const epicFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'epic', - ], - operation: [ - 'update', - ], + resource: ['epic'], + operation: ['update'], }, }, }, @@ -363,12 +313,8 @@ export const epicFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'epic', - ], - operation: [ - 'update', - ], + resource: ['epic'], + operation: ['update'], }, }, options: [ @@ -377,13 +323,12 @@ export const epicFields: INodeProperties[] = [ name: 'assigned_to', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the user to whom the epic is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to whom the epic is assigned. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Blocked Note', @@ -422,11 +367,10 @@ export const epicFields: INodeProperties[] = [ displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTags', }, default: [], diff --git a/packages/nodes-base/nodes/Taiga/descriptions/IssueDescription.ts b/packages/nodes-base/nodes/Taiga/descriptions/IssueDescription.ts index 020c6f86a5..0fce4089d2 100644 --- a/packages/nodes-base/nodes/Taiga/descriptions/IssueDescription.ts +++ b/packages/nodes-base/nodes/Taiga/descriptions/IssueDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const issueOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const issueOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'issue', - ], + resource: ['issue'], }, }, options: [ @@ -58,7 +54,8 @@ export const issueFields: INodeProperties[] = [ { displayName: 'Project Name or ID', name: 'projectId', - description: 'ID of the project to which the issue belongs. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the project to which the issue belongs. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { loadOptionsMethod: 'getProjects', @@ -67,12 +64,8 @@ export const issueFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'create', - ], + resource: ['issue'], + operation: ['create'], }, }, }, @@ -84,12 +77,8 @@ export const issueFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'create', - ], + resource: ['issue'], + operation: ['create'], }, }, }, @@ -101,12 +90,8 @@ export const issueFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'create', - ], + resource: ['issue'], + operation: ['create'], }, }, options: [ @@ -116,13 +101,12 @@ export const issueFields: INodeProperties[] = [ name: 'assigned_to', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the user to whom the issue is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to whom the issue is assigned. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Blocked Note', @@ -149,23 +133,21 @@ export const issueFields: INodeProperties[] = [ name: 'milestone', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getMilestones', }, default: '', - description: 'ID of the milestone of the issue. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the milestone of the issue. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Priority Name or ID', name: 'priority', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getPriorities', }, default: '', @@ -174,11 +156,10 @@ export const issueFields: INodeProperties[] = [ displayName: 'Severity Name or ID', name: 'severity', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getSeverities', }, default: '', @@ -188,23 +169,21 @@ export const issueFields: INodeProperties[] = [ name: 'status', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getIssueStatuses', }, default: '', - description: 'ID of the status of the issue. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the status of the issue. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTags', }, default: [], @@ -213,11 +192,10 @@ export const issueFields: INodeProperties[] = [ displayName: 'Type Name or ID', name: 'type', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTypes', }, default: '', @@ -237,12 +215,8 @@ export const issueFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'delete', - ], + resource: ['issue'], + operation: ['delete'], }, }, }, @@ -259,12 +233,8 @@ export const issueFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'get', - ], + resource: ['issue'], + operation: ['get'], }, }, }, @@ -275,7 +245,8 @@ export const issueFields: INodeProperties[] = [ { displayName: 'Project Name or ID', name: 'projectId', - description: 'ID of the project to which the issue belongs. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the project to which the issue belongs. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { loadOptionsMethod: 'getProjects', @@ -284,12 +255,8 @@ export const issueFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'getAll', - ], + resource: ['issue'], + operation: ['getAll'], }, }, }, @@ -301,12 +268,8 @@ export const issueFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'getAll', - ], + resource: ['issue'], + operation: ['getAll'], }, }, }, @@ -321,15 +284,9 @@ export const issueFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['issue'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -340,12 +297,8 @@ export const issueFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'getAll', - ], + resource: ['issue'], + operation: ['getAll'], }, }, default: {}, @@ -353,12 +306,11 @@ export const issueFields: INodeProperties[] = [ { displayName: 'Asignee Name or ID', name: 'assigned_to', - description: 'ID of the user to assign the issue to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to assign the issue to. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUsers', }, default: '', @@ -411,12 +363,11 @@ export const issueFields: INodeProperties[] = [ { displayName: 'Owner Name or ID', name: 'owner', - description: 'ID of the owner of the issue. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the owner of the issue. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUsers', }, default: '', @@ -425,11 +376,10 @@ export const issueFields: INodeProperties[] = [ displayName: 'Priority Name or ID', name: 'priority', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getPriorities', }, default: '', @@ -438,11 +388,10 @@ export const issueFields: INodeProperties[] = [ displayName: 'Role Name or ID', name: 'role', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getRoles', }, default: '', @@ -451,11 +400,10 @@ export const issueFields: INodeProperties[] = [ displayName: 'Severity Name or ID', name: 'severity', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getSeverities', }, default: '', @@ -463,12 +411,11 @@ export const issueFields: INodeProperties[] = [ { displayName: 'Status Name or ID', name: 'status', - description: 'ID of the status of the issue. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the status of the issue. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getIssueStatuses', }, default: '', @@ -477,11 +424,10 @@ export const issueFields: INodeProperties[] = [ displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTags', }, default: [], @@ -490,11 +436,10 @@ export const issueFields: INodeProperties[] = [ displayName: 'Type Name or ID', name: 'type', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTypes', }, default: '', @@ -513,15 +458,12 @@ export const issueFields: INodeProperties[] = [ loadOptionsMethod: 'getProjects', }, default: '', - description: 'ID of the project to set the issue to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the project to set the issue to. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'update', - ], + resource: ['issue'], + operation: ['update'], }, }, }, @@ -534,12 +476,8 @@ export const issueFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'update', - ], + resource: ['issue'], + operation: ['update'], }, }, }, @@ -551,12 +489,8 @@ export const issueFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'issue', - ], - operation: [ - 'update', - ], + resource: ['issue'], + operation: ['update'], }, }, options: [ @@ -565,13 +499,12 @@ export const issueFields: INodeProperties[] = [ name: 'assigned_to', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the user whom the issue is assigned to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user whom the issue is assigned to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Blocked Note', @@ -598,23 +531,21 @@ export const issueFields: INodeProperties[] = [ name: 'milestone', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getMilestones', }, default: '', - description: 'ID of the milestone of the issue. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the milestone of the issue. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Priority Name or ID', name: 'priority', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getPriorities', }, default: '', @@ -623,11 +554,10 @@ export const issueFields: INodeProperties[] = [ displayName: 'Severity Name or ID', name: 'severity', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getSeverities', }, default: '', @@ -637,13 +567,12 @@ export const issueFields: INodeProperties[] = [ name: 'status', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getIssueStatuses', }, default: '', - description: 'ID of the status of the issue. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the status of the issue. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Subject', @@ -655,11 +584,10 @@ export const issueFields: INodeProperties[] = [ displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTags', }, default: [], @@ -668,11 +596,10 @@ export const issueFields: INodeProperties[] = [ displayName: 'Type Name or ID', name: 'type', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTypes', }, default: '', diff --git a/packages/nodes-base/nodes/Taiga/descriptions/TaskDescription.ts b/packages/nodes-base/nodes/Taiga/descriptions/TaskDescription.ts index 923e2435ab..d4e71f29f5 100644 --- a/packages/nodes-base/nodes/Taiga/descriptions/TaskDescription.ts +++ b/packages/nodes-base/nodes/Taiga/descriptions/TaskDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const taskOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const taskOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'task', - ], + resource: ['task'], }, }, options: [ @@ -58,7 +54,8 @@ export const taskFields: INodeProperties[] = [ { displayName: 'Project Name or ID', name: 'projectId', - description: 'ID of the project to which the task belongs. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the project to which the task belongs. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { loadOptionsMethod: 'getProjects', @@ -67,12 +64,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, }, @@ -84,12 +77,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, }, @@ -101,12 +90,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, options: [ @@ -115,13 +100,12 @@ export const taskFields: INodeProperties[] = [ name: 'assigned_to', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the user to whom the task is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to whom the task is assigned. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Blocked Note', @@ -148,36 +132,33 @@ export const taskFields: INodeProperties[] = [ name: 'milestone', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getMilestones', }, default: '', - description: 'ID of the milestone of the task. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the milestone of the task. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Status Name or ID', name: 'status', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTaskStatuses', }, default: '', - description: 'ID of the status of the task. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the status of the task. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTags', }, default: [], @@ -197,13 +178,12 @@ export const taskFields: INodeProperties[] = [ name: 'user_story', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUserStories', }, default: '', - description: 'ID of the user story of the task. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user story of the task. Choose from the list, or specify an ID using an expression.', }, { displayName: 'User Story Order', @@ -230,12 +210,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'delete', - ], + resource: ['task'], + operation: ['delete'], }, }, }, @@ -252,12 +228,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'get', - ], + resource: ['task'], + operation: ['get'], }, }, }, @@ -268,7 +240,8 @@ export const taskFields: INodeProperties[] = [ { displayName: 'Project Name or ID', name: 'projectId', - description: 'ID of the project to which the task belongs. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the project to which the task belongs. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { loadOptionsMethod: 'getProjects', @@ -277,12 +250,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, }, @@ -294,12 +263,8 @@ export const taskFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, }, @@ -314,15 +279,9 @@ export const taskFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['task'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -333,12 +292,8 @@ export const taskFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, default: {}, @@ -348,13 +303,12 @@ export const taskFields: INodeProperties[] = [ name: 'assigned_to', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the user whom the task is assigned to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user whom the task is assigned to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Is Closed', @@ -368,23 +322,21 @@ export const taskFields: INodeProperties[] = [ name: 'milestone', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getMilestones', }, default: '', - description: 'ID of the milestone of the task. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the milestone of the task. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Owner Name or ID', name: 'owner', - description: 'ID of the owner of the task. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the owner of the task. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUsers', }, default: '', @@ -393,11 +345,10 @@ export const taskFields: INodeProperties[] = [ displayName: 'Role Name or ID', name: 'role', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getRoles', }, default: '', @@ -405,12 +356,11 @@ export const taskFields: INodeProperties[] = [ { displayName: 'Status Name or ID', name: 'status', - description: 'ID of the status of the task. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the status of the task. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTaskStatuses', }, default: '', @@ -419,11 +369,10 @@ export const taskFields: INodeProperties[] = [ displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTags', }, default: [], @@ -431,12 +380,11 @@ export const taskFields: INodeProperties[] = [ { displayName: 'User Story Name or ID', name: 'userStory', - description: 'ID of the user story to which the task belongs. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user story to which the task belongs. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUserStories', }, default: '', @@ -450,7 +398,8 @@ export const taskFields: INodeProperties[] = [ { displayName: 'Project Name or ID', name: 'projectId', - description: 'ID of the project to set the task to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the project to set the task to. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { loadOptionsMethod: 'getProjects', @@ -458,12 +407,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, }, @@ -476,12 +421,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, }, @@ -493,12 +434,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, options: [ @@ -507,13 +444,12 @@ export const taskFields: INodeProperties[] = [ name: 'assigned_to', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTypes', }, default: '', - description: 'ID of the user to assign the task to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to assign the task to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Blocked Note', @@ -540,26 +476,24 @@ export const taskFields: INodeProperties[] = [ name: 'milestone', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getMilestones', }, default: '', - description: 'ID of the milestone of the task. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the milestone of the task. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Status Name or ID', name: 'status', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTaskStatuses', }, default: '', - description: 'ID of the status of the task. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the status of the task. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Subject', @@ -572,13 +506,12 @@ export const taskFields: INodeProperties[] = [ name: 'user_story', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUserStories', }, default: '', - description: 'ID of the user story of the task. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user story of the task. Choose from the list, or specify an ID using an expression.', }, { displayName: 'User Story Order', @@ -594,11 +527,10 @@ export const taskFields: INodeProperties[] = [ displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTags', }, default: [], diff --git a/packages/nodes-base/nodes/Taiga/descriptions/UserStoryDescription.ts b/packages/nodes-base/nodes/Taiga/descriptions/UserStoryDescription.ts index a60b0b98d1..3efc4376a6 100644 --- a/packages/nodes-base/nodes/Taiga/descriptions/UserStoryDescription.ts +++ b/packages/nodes-base/nodes/Taiga/descriptions/UserStoryDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userStoryOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userStoryOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'userStory', - ], + resource: ['userStory'], }, }, options: [ @@ -58,7 +54,8 @@ export const userStoryFields: INodeProperties[] = [ { displayName: 'Project Name or ID', name: 'projectId', - description: 'ID of the project to which the user story belongs. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the project to which the user story belongs. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { loadOptionsMethod: 'getProjects', @@ -67,12 +64,8 @@ export const userStoryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'userStory', - ], - operation: [ - 'create', - ], + resource: ['userStory'], + operation: ['create'], }, }, }, @@ -84,12 +77,8 @@ export const userStoryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'userStory', - ], - operation: [ - 'create', - ], + resource: ['userStory'], + operation: ['create'], }, }, }, @@ -101,12 +90,8 @@ export const userStoryFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'userStory', - ], - operation: [ - 'create', - ], + resource: ['userStory'], + operation: ['create'], }, }, options: [ @@ -115,13 +100,12 @@ export const userStoryFields: INodeProperties[] = [ name: 'assigned_to', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the user to whom the user story is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to whom the user story is assigned. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Backlog Order', @@ -138,7 +122,8 @@ export const userStoryFields: INodeProperties[] = [ name: 'blocked_note', type: 'string', default: '', - description: 'Reason why the user story is blocked. Requires "Is Blocked" toggle to be enabled.', + description: + 'Reason why the user story is blocked. Requires "Is Blocked" toggle to be enabled.', }, { displayName: 'Description', @@ -168,13 +153,12 @@ export const userStoryFields: INodeProperties[] = [ name: 'milestone', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getMilestones', }, default: '', - description: 'ID of the milestone of the user story. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the milestone of the user story. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Sprint Order', @@ -191,23 +175,21 @@ export const userStoryFields: INodeProperties[] = [ name: 'status', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUserStoryStatuses', }, default: '', - description: 'ID of the status of the user story. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the status of the user story. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTags', }, default: [], @@ -216,11 +198,10 @@ export const userStoryFields: INodeProperties[] = [ displayName: 'Type Name or ID', name: 'type', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTypes', }, default: '', @@ -240,12 +221,8 @@ export const userStoryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'userStory', - ], - operation: [ - 'delete', - ], + resource: ['userStory'], + operation: ['delete'], }, }, }, @@ -262,12 +239,8 @@ export const userStoryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'userStory', - ], - operation: [ - 'get', - ], + resource: ['userStory'], + operation: ['get'], }, }, }, @@ -278,7 +251,8 @@ export const userStoryFields: INodeProperties[] = [ { displayName: 'Project Name or ID', name: 'projectId', - description: 'ID of the project to which the user story belongs. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the project to which the user story belongs. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { loadOptionsMethod: 'getProjects', @@ -287,12 +261,8 @@ export const userStoryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'userStory', - ], - operation: [ - 'getAll', - ], + resource: ['userStory'], + operation: ['getAll'], }, }, }, @@ -304,12 +274,8 @@ export const userStoryFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'userStory', - ], - operation: [ - 'getAll', - ], + resource: ['userStory'], + operation: ['getAll'], }, }, }, @@ -324,15 +290,9 @@ export const userStoryFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'userStory', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['userStory'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -343,12 +303,8 @@ export const userStoryFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'userStory', - ], - operation: [ - 'getAll', - ], + resource: ['userStory'], + operation: ['getAll'], }, }, default: {}, @@ -356,12 +312,11 @@ export const userStoryFields: INodeProperties[] = [ { displayName: 'Asignee Name or ID', name: 'assigned_to', - description: 'ID of the user whom the user story is assigned to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user whom the user story is assigned to. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUsers', }, default: '', @@ -369,12 +324,11 @@ export const userStoryFields: INodeProperties[] = [ { displayName: 'Epic Name or ID', name: 'epic', - description: 'ID of the epic to which the user story belongs. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the epic to which the user story belongs. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getEpics', }, default: '', @@ -398,23 +352,21 @@ export const userStoryFields: INodeProperties[] = [ name: 'milestone', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getMilestones', }, default: '', - description: 'ID of the milestone of the user story. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the milestone of the user story. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Role Name or ID', name: 'role', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getRoles', }, default: '', @@ -422,12 +374,11 @@ export const userStoryFields: INodeProperties[] = [ { displayName: 'Status Name or ID', name: 'status', - description: 'ID of the status of the user story. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the status of the user story. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUserStoryStatuses', }, default: '', @@ -436,11 +387,10 @@ export const userStoryFields: INodeProperties[] = [ displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTags', }, default: [], @@ -459,15 +409,12 @@ export const userStoryFields: INodeProperties[] = [ loadOptionsMethod: 'getProjects', }, default: '', - description: 'ID of the project to set the user story to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the project to set the user story to. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'userStory', - ], - operation: [ - 'update', - ], + resource: ['userStory'], + operation: ['update'], }, }, }, @@ -480,12 +427,8 @@ export const userStoryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'userStory', - ], - operation: [ - 'update', - ], + resource: ['userStory'], + operation: ['update'], }, }, }, @@ -497,12 +440,8 @@ export const userStoryFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'userStory', - ], - operation: [ - 'update', - ], + resource: ['userStory'], + operation: ['update'], }, }, options: [ @@ -511,13 +450,12 @@ export const userStoryFields: INodeProperties[] = [ name: 'assigned_to', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUsers', }, default: '', - description: 'ID of the user to assign the the user story to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to assign the the user story to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Backlog Order', @@ -534,7 +472,8 @@ export const userStoryFields: INodeProperties[] = [ name: 'blocked_note', type: 'string', default: '', - description: 'Reason why the user story is blocked. Requires "Is Blocked" toggle to be enabled.', + description: + 'Reason why the user story is blocked. Requires "Is Blocked" toggle to be enabled.', }, { displayName: 'Description', @@ -564,13 +503,12 @@ export const userStoryFields: INodeProperties[] = [ name: 'milestone', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getMilestones', }, default: '', - description: 'ID of the milestone of the user story. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the milestone of the user story. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Subject', @@ -593,23 +531,21 @@ export const userStoryFields: INodeProperties[] = [ name: 'status', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getUserStoryStatuses', }, default: '', - description: 'ID of the status of the user story. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the status of the user story. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Tag Names or IDs', name: 'tags', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTags', }, default: [], @@ -618,11 +554,10 @@ export const userStoryFields: INodeProperties[] = [ displayName: 'Type Name or ID', name: 'type', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getTypes', }, default: '', diff --git a/packages/nodes-base/nodes/Taiga/types.d.ts b/packages/nodes-base/nodes/Taiga/types.d.ts index 4a136dc822..9528d0db34 100644 --- a/packages/nodes-base/nodes/Taiga/types.d.ts +++ b/packages/nodes-base/nodes/Taiga/types.d.ts @@ -1,6 +1,6 @@ type Resource = 'epic' | 'issue' | 'task' | 'userStory'; -type Operation = 'create' | 'delete' | 'update' | 'get' | 'getAll' +type Operation = 'create' | 'delete' | 'update' | 'get' | 'getAll'; type LoadedResource = { id: string; @@ -26,7 +26,7 @@ type LoadedEpic = LoadedUserStory; type LoadedTags = { [tagName: string]: string | null; // hex color -} +}; type Operations = 'all' | 'create' | 'delete' | 'change'; @@ -38,4 +38,4 @@ type WebhookPayload = { by: Record; date: string; data: Record; -} +}; diff --git a/packages/nodes-base/nodes/Tapfiliate/AffiliateDescription.ts b/packages/nodes-base/nodes/Tapfiliate/AffiliateDescription.ts index 7a341f27e2..c897a61524 100644 --- a/packages/nodes-base/nodes/Tapfiliate/AffiliateDescription.ts +++ b/packages/nodes-base/nodes/Tapfiliate/AffiliateDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const affiliateOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const affiliateOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'affiliate', - ], + resource: ['affiliate'], }, }, options: [ @@ -58,12 +54,8 @@ export const affiliateFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'affiliate', - ], + operation: ['create'], + resource: ['affiliate'], }, }, description: 'The affiliate’s email', @@ -75,12 +67,8 @@ export const affiliateFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'affiliate', - ], + operation: ['create'], + resource: ['affiliate'], }, }, default: '', @@ -93,12 +81,8 @@ export const affiliateFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'affiliate', - ], + operation: ['create'], + resource: ['affiliate'], }, }, default: '', @@ -112,12 +96,8 @@ export const affiliateFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'affiliate', - ], - operation: [ - 'create', - ], + resource: ['affiliate'], + operation: ['create'], }, }, options: [ @@ -170,7 +150,8 @@ export const affiliateFields: INodeProperties[] = [ name: 'country', type: 'string', default: '', - description: 'The country’s ISO_3166-1 code. Codes.', + description: + 'The country’s ISO_3166-1 code. Codes.', }, ], }, @@ -197,12 +178,8 @@ export const affiliateFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'affiliate', - ], - operation: [ - 'delete', - ], + resource: ['affiliate'], + operation: ['delete'], }, }, description: 'The ID of the affiliate', @@ -219,12 +196,8 @@ export const affiliateFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'affiliate', - ], - operation: [ - 'get', - ], + resource: ['affiliate'], + operation: ['get'], }, }, description: 'The ID of the affiliate', @@ -239,12 +212,8 @@ export const affiliateFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'affiliate', - ], - operation: [ - 'getAll', - ], + resource: ['affiliate'], + operation: ['getAll'], }, }, default: false, @@ -256,15 +225,9 @@ export const affiliateFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'affiliate', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['affiliate'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -282,12 +245,8 @@ export const affiliateFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'affiliate', - ], - operation: [ - 'getAll', - ], + resource: ['affiliate'], + operation: ['getAll'], }, }, options: [ @@ -324,7 +283,8 @@ export const affiliateFields: INodeProperties[] = [ name: 'referral_code', type: 'string', default: '', - description: 'An affiliate’s referral code. This corresponds to the value of ref= in their referral link.', + description: + 'An affiliate’s referral code. This corresponds to the value of ref= in their referral link.', }, { displayName: 'Source ID', diff --git a/packages/nodes-base/nodes/Tapfiliate/AffiliateMetadataDescription.ts b/packages/nodes-base/nodes/Tapfiliate/AffiliateMetadataDescription.ts index 385976fb58..2da570c3d8 100644 --- a/packages/nodes-base/nodes/Tapfiliate/AffiliateMetadataDescription.ts +++ b/packages/nodes-base/nodes/Tapfiliate/AffiliateMetadataDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const affiliateMetadataOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const affiliateMetadataOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'affiliateMetadata', - ], + resource: ['affiliateMetadata'], }, }, options: [ @@ -31,7 +27,7 @@ export const affiliateMetadataOperations: INodeProperties[] = [ { name: 'Update', value: 'update', - description: 'Update affiliate\'s metadata', + description: "Update affiliate's metadata", action: 'Update metadata for an affiliate', }, ], @@ -51,12 +47,8 @@ export const affiliateMetadataFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'affiliateMetadata', - ], - operation: [ - 'add', - ], + resource: ['affiliateMetadata'], + operation: ['add'], }, }, description: 'The ID of the affiliate', @@ -68,12 +60,8 @@ export const affiliateMetadataFields: INodeProperties[] = [ type: 'fixedCollection', displayOptions: { show: { - resource: [ - 'affiliateMetadata', - ], - operation: [ - 'add', - ], + resource: ['affiliateMetadata'], + operation: ['add'], }, }, default: {}, @@ -116,12 +104,8 @@ export const affiliateMetadataFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'affiliateMetadata', - ], - operation: [ - 'remove', - ], + resource: ['affiliateMetadata'], + operation: ['remove'], }, }, description: 'The ID of the affiliate', @@ -132,12 +116,8 @@ export const affiliateMetadataFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'affiliateMetadata', - ], - operation: [ - 'remove', - ], + resource: ['affiliateMetadata'], + operation: ['remove'], }, }, default: '', @@ -155,12 +135,8 @@ export const affiliateMetadataFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'affiliateMetadata', - ], - operation: [ - 'update', - ], + resource: ['affiliateMetadata'], + operation: ['update'], }, }, description: 'The ID of the affiliate', @@ -171,12 +147,8 @@ export const affiliateMetadataFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'affiliateMetadata', - ], - operation: [ - 'update', - ], + resource: ['affiliateMetadata'], + operation: ['update'], }, }, default: '', @@ -188,12 +160,8 @@ export const affiliateMetadataFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'affiliateMetadata', - ], - operation: [ - 'update', - ], + resource: ['affiliateMetadata'], + operation: ['update'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts b/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts index 686ec4de20..b82619db11 100644 --- a/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,11 +7,19 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function tapfiliateApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, qs: IDataObject = {}, uri?: string | undefined, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function tapfiliateApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string | undefined, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('tapfiliateApi'); const options: OptionsWithUri = { @@ -41,8 +47,15 @@ export async function tapfiliateApiRequest(this: IHookFunctions | IExecuteFuncti } } -export async function tapfiliateApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function tapfiliateApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -50,13 +63,12 @@ export async function tapfiliateApiRequestAllItems(this: IExecuteFunctions | ILo query.page = 1; do { - responseData = await tapfiliateApiRequest.call(this, method, endpoint, body, query, '', { resolveWithFullResponse: true }); + responseData = await tapfiliateApiRequest.call(this, method, endpoint, body, query, '', { + resolveWithFullResponse: true, + }); returnData.push.apply(returnData, responseData.body); query.page++; - - } while ( - responseData.headers.link.includes('next') - ); + } while (responseData.headers.link.includes('next')); return returnData; } diff --git a/packages/nodes-base/nodes/Tapfiliate/ProgramAffiliateDescription.ts b/packages/nodes-base/nodes/Tapfiliate/ProgramAffiliateDescription.ts index 988a313d35..528732b185 100644 --- a/packages/nodes-base/nodes/Tapfiliate/ProgramAffiliateDescription.ts +++ b/packages/nodes-base/nodes/Tapfiliate/ProgramAffiliateDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const programAffiliateOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const programAffiliateOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'programAffiliate', - ], + resource: ['programAffiliate'], }, }, options: [ @@ -66,15 +62,12 @@ export const programAffiliateFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'programAffiliate', - ], + operation: ['add'], + resource: ['programAffiliate'], }, }, - description: 'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Affiliate ID', @@ -84,12 +77,8 @@ export const programAffiliateFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'programAffiliate', - ], - operation: [ - 'add', - ], + resource: ['programAffiliate'], + operation: ['add'], }, }, description: 'The ID of the affiliate', @@ -102,12 +91,8 @@ export const programAffiliateFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'programAffiliate', - ], - operation: [ - 'add', - ], + resource: ['programAffiliate'], + operation: ['add'], }, }, options: [ @@ -142,15 +127,12 @@ export const programAffiliateFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'approve', - ], - resource: [ - 'programAffiliate', - ], + operation: ['approve'], + resource: ['programAffiliate'], }, }, - description: 'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Affiliate ID', @@ -159,12 +141,8 @@ export const programAffiliateFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'programAffiliate', - ], - operation: [ - 'approve', - ], + resource: ['programAffiliate'], + operation: ['approve'], }, }, description: 'The ID of the affiliate', @@ -183,15 +161,12 @@ export const programAffiliateFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'disapprove', - ], - resource: [ - 'programAffiliate', - ], + operation: ['disapprove'], + resource: ['programAffiliate'], }, }, - description: 'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Affiliate ID', @@ -200,12 +175,8 @@ export const programAffiliateFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'programAffiliate', - ], - operation: [ - 'disapprove', - ], + resource: ['programAffiliate'], + operation: ['disapprove'], }, }, description: 'The ID of the affiliate', @@ -225,15 +196,12 @@ export const programAffiliateFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'programAffiliate', - ], + operation: ['get'], + resource: ['programAffiliate'], }, }, - description: 'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Affiliate ID', @@ -243,12 +211,8 @@ export const programAffiliateFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'programAffiliate', - ], - operation: [ - 'get', - ], + resource: ['programAffiliate'], + operation: ['get'], }, }, description: 'The ID of the affiliate', @@ -268,15 +232,12 @@ export const programAffiliateFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'programAffiliate', - ], + operation: ['getAll'], + resource: ['programAffiliate'], }, }, - description: 'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the Program to add the affiliate to. This ID can be found as part of the URL when viewing the program on the platform. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -284,12 +245,8 @@ export const programAffiliateFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'programAffiliate', - ], - operation: [ - 'getAll', - ], + resource: ['programAffiliate'], + operation: ['getAll'], }, }, default: false, @@ -301,15 +258,9 @@ export const programAffiliateFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'programAffiliate', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['programAffiliate'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -327,12 +278,8 @@ export const programAffiliateFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'programAffiliate', - ], - operation: [ - 'getAll', - ], + resource: ['programAffiliate'], + operation: ['getAll'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Tapfiliate/Tapfiliate.node.ts b/packages/nodes-base/nodes/Tapfiliate/Tapfiliate.node.ts index ee8fdf4de2..46c8e8874b 100644 --- a/packages/nodes-base/nodes/Tapfiliate/Tapfiliate.node.ts +++ b/packages/nodes-base/nodes/Tapfiliate/Tapfiliate.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,25 +10,16 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - affiliateFields, - affiliateOperations -} from './AffiliateDescription'; +import { affiliateFields, affiliateOperations } from './AffiliateDescription'; import { affiliateMetadataFields, affiliateMetadataOperations, } from './AffiliateMetadataDescription'; -import { - programAffiliateFields, - programAffiliateOperations, -} from './ProgramAffiliateDescription'; +import { programAffiliateFields, programAffiliateOperations } from './ProgramAffiliateDescription'; -import { - tapfiliateApiRequest, - tapfiliateApiRequestAllItems, -} from './GenericFunctions'; +import { tapfiliateApiRequest, tapfiliateApiRequestAllItems } from './GenericFunctions'; export class Tapfiliate implements INodeType { description: INodeTypeDescription = { @@ -87,7 +76,7 @@ export class Tapfiliate implements INodeType { methods = { loadOptions: { // Get custom fields to display to user so that they can select them easily - async getPrograms(this: ILoadOptionsFunctions,): Promise { + async getPrograms(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const programs = await tapfiliateApiRequestAllItems.call(this, 'GET', '/programs/'); for (const program of programs) { @@ -147,13 +136,21 @@ export class Tapfiliate implements INodeType { if (operation === 'delete') { //https://tapfiliate.com/docs/rest/#affiliates-affiliate-delete const affiliateId = this.getNodeParameter('affiliateId', i) as string; - responseData = await tapfiliateApiRequest.call(this, 'DELETE', `/affiliates/${affiliateId}/`); + responseData = await tapfiliateApiRequest.call( + this, + 'DELETE', + `/affiliates/${affiliateId}/`, + ); returnData.push({ success: true }); } if (operation === 'get') { //https://tapfiliate.com/docs/rest/#affiliates-affiliate-get const affiliateId = this.getNodeParameter('affiliateId', i) as string; - responseData = await tapfiliateApiRequest.call(this, 'GET', `/affiliates/${affiliateId}/`); + responseData = await tapfiliateApiRequest.call( + this, + 'GET', + `/affiliates/${affiliateId}/`, + ); returnData.push(responseData); } if (operation === 'getAll') { @@ -162,7 +159,13 @@ export class Tapfiliate implements INodeType { const filters = this.getNodeParameter('filters', i) as IDataObject; Object.assign(qs, filters); if (returnAll) { - responseData = await tapfiliateApiRequestAllItems.call(this, 'GET', `/affiliates/`, {}, qs); + responseData = await tapfiliateApiRequestAllItems.call( + this, + 'GET', + `/affiliates/`, + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; responseData = await tapfiliateApiRequest.call(this, 'GET', `/affiliates/`, {}, qs); @@ -175,12 +178,21 @@ export class Tapfiliate implements INodeType { if (operation === 'add') { //https://tapfiliate.com/docs/rest/#affiliates-meta-data-key-put const affiliateId = this.getNodeParameter('affiliateId', i) as string; - const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject || {}).metadataValues as IDataObject[] || []; + const metadata = + (((this.getNodeParameter('metadataUi', i) as IDataObject) || {}) + .metadataValues as IDataObject[]) || []; if (metadata.length === 0) { - throw new NodeOperationError(this.getNode(), 'Metadata cannot be empty.', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Metadata cannot be empty.', { + itemIndex: i, + }); } for (const { key, value } of metadata) { - await tapfiliateApiRequest.call(this, 'PUT', `/affiliates/${affiliateId}/meta-data/${key}/`, { value }); + await tapfiliateApiRequest.call( + this, + 'PUT', + `/affiliates/${affiliateId}/meta-data/${key}/`, + { value }, + ); } returnData.push({ success: true }); } @@ -188,7 +200,11 @@ export class Tapfiliate implements INodeType { //https://tapfiliate.com/docs/rest/#affiliates-meta-data-key-delete const affiliateId = this.getNodeParameter('affiliateId', i) as string; const key = this.getNodeParameter('key', i) as string; - responseData = await tapfiliateApiRequest.call(this, 'DELETE', `/affiliates/${affiliateId}/meta-data/${key}/`); + responseData = await tapfiliateApiRequest.call( + this, + 'DELETE', + `/affiliates/${affiliateId}/meta-data/${key}/`, + ); returnData.push({ success: true }); } if (operation === 'update') { @@ -196,7 +212,12 @@ export class Tapfiliate implements INodeType { const affiliateId = this.getNodeParameter('affiliateId', i) as string; const key = this.getNodeParameter('key', i) as string; const value = this.getNodeParameter('value', i) as string; - responseData = await tapfiliateApiRequest.call(this, 'PUT', `/affiliates/${affiliateId}/meta-data/`, { [key]: value }); + responseData = await tapfiliateApiRequest.call( + this, + 'PUT', + `/affiliates/${affiliateId}/meta-data/`, + { [key]: value }, + ); returnData.push(responseData); } } @@ -213,28 +234,45 @@ export class Tapfiliate implements INodeType { }; Object.assign(body, additionalFields); - responseData = await tapfiliateApiRequest.call(this, 'POST', `/programs/${programId}/affiliates/`, body); + responseData = await tapfiliateApiRequest.call( + this, + 'POST', + `/programs/${programId}/affiliates/`, + body, + ); returnData.push(responseData); } if (operation === 'approve') { //https://tapfiliate.com/docs/rest/#programs-approve-an-affiliate-for-a-program-put const programId = this.getNodeParameter('programId', i) as string; const affiliateId = this.getNodeParameter('affiliateId', i) as string; - responseData = await tapfiliateApiRequest.call(this, 'PUT', `/programs/${programId}/affiliates/${affiliateId}/approved/`); + responseData = await tapfiliateApiRequest.call( + this, + 'PUT', + `/programs/${programId}/affiliates/${affiliateId}/approved/`, + ); returnData.push(responseData); } if (operation === 'disapprove') { //https://tapfiliate.com/docs/rest/#programs-approve-an-affiliate-for-a-program-delete const programId = this.getNodeParameter('programId', i) as string; const affiliateId = this.getNodeParameter('affiliateId', i) as string; - responseData = await tapfiliateApiRequest.call(this, 'DELETE', `/programs/${programId}/affiliates/${affiliateId}/approved/`); + responseData = await tapfiliateApiRequest.call( + this, + 'DELETE', + `/programs/${programId}/affiliates/${affiliateId}/approved/`, + ); returnData.push(responseData); } if (operation === 'get') { //https://tapfiliate.com/docs/rest/#programs-affiliate-in-program-get const programId = this.getNodeParameter('programId', i) as string; const affiliateId = this.getNodeParameter('affiliateId', i) as string; - responseData = await tapfiliateApiRequest.call(this, 'GET', `/programs/${programId}/affiliates/${affiliateId}/`); + responseData = await tapfiliateApiRequest.call( + this, + 'GET', + `/programs/${programId}/affiliates/${affiliateId}/`, + ); returnData.push(responseData); } if (operation === 'getAll') { @@ -244,10 +282,22 @@ export class Tapfiliate implements INodeType { const filters = this.getNodeParameter('filters', i) as IDataObject; Object.assign(qs, filters); if (returnAll) { - responseData = await tapfiliateApiRequestAllItems.call(this, 'GET', `/programs/${programId}/affiliates/`, {}, qs); + responseData = await tapfiliateApiRequestAllItems.call( + this, + 'GET', + `/programs/${programId}/affiliates/`, + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; - responseData = await tapfiliateApiRequest.call(this, 'GET', `/programs/${programId}/affiliates/`, {}, qs); + responseData = await tapfiliateApiRequest.call( + this, + 'GET', + `/programs/${programId}/affiliates/`, + {}, + qs, + ); responseData = responseData.splice(0, limit); } returnData.push.apply(returnData, responseData); diff --git a/packages/nodes-base/nodes/Telegram/GenericFunctions.ts b/packages/nodes-base/nodes/Telegram/GenericFunctions.ts index 363bcc0048..16f7fc0f7f 100644 --- a/packages/nodes-base/nodes/Telegram/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Telegram/GenericFunctions.ts @@ -5,15 +5,9 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IDataObject, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; // Interface in n8n export interface IMarkupKeyboard { @@ -33,7 +27,6 @@ export interface IMarkupKeyboardButton { additionalFields?: IDataObject; } - // Interface in Telegram export interface ITelegramInlineReply { inline_keyboard?: ITelegramKeyboardButton[][]; @@ -47,7 +40,6 @@ export interface ITelegramReplyKeyboard extends IMarkupReplyKeyboardOptions { keyboard: ITelegramKeyboardButton[][]; } - // Shared interfaces export interface IMarkupForceReply { force_reply?: boolean; @@ -65,7 +57,6 @@ export interface IMarkupReplyKeyboardRemove { selective?: boolean; } - /** * Add the additional fields to the body * @@ -90,7 +81,11 @@ export function addAdditionalFields(this: IExecuteFunctions, body: IDataObject, } } - body.reply_markup = {} as IMarkupForceReply | IMarkupReplyKeyboardRemove | ITelegramInlineReply | ITelegramReplyKeyboard; + body.reply_markup = {} as + | IMarkupForceReply + | IMarkupReplyKeyboardRemove + | ITelegramInlineReply + | ITelegramReplyKeyboard; if (['inlineKeyboard', 'replyKeyboard'].includes(replyMarkupOption)) { let setParameterName = 'inline_keyboard'; if (replyMarkupOption === 'replyKeyboard') { @@ -100,7 +95,8 @@ export function addAdditionalFields(this: IExecuteFunctions, body: IDataObject, const keyboardData = this.getNodeParameter(replyMarkupOption, index) as IMarkupKeyboard; // @ts-ignore - (body.reply_markup as ITelegramInlineReply | ITelegramReplyKeyboard)[setParameterName] = [] as ITelegramKeyboardButton[][]; + (body.reply_markup as ITelegramInlineReply | ITelegramReplyKeyboard)[setParameterName] = + [] as ITelegramKeyboardButton[][]; let sendButtonData: ITelegramKeyboardButton; if (keyboardData.rows !== undefined) { for (const row of keyboardData.rows) { @@ -117,6 +113,7 @@ export function addAdditionalFields(this: IExecuteFunctions, body: IDataObject, sendRows.push(sendButtonData); } // @ts-ignore + // prettier-ignore ((body.reply_markup as ITelegramInlineReply | ITelegramReplyKeyboard)[setParameterName] as ITelegramKeyboardButton[][]).push(sendRows); } } @@ -124,17 +121,22 @@ export function addAdditionalFields(this: IExecuteFunctions, body: IDataObject, const forceReply = this.getNodeParameter('forceReply', index) as IMarkupForceReply; body.reply_markup = forceReply; } else if (replyMarkupOption === 'replyKeyboardRemove') { - const forceReply = this.getNodeParameter('replyKeyboardRemove', index) as IMarkupReplyKeyboardRemove; + const forceReply = this.getNodeParameter( + 'replyKeyboardRemove', + index, + ) as IMarkupReplyKeyboardRemove; body.reply_markup = forceReply; } if (replyMarkupOption === 'replyKeyboard') { - const replyKeyboardOptions = this.getNodeParameter('replyKeyboardOptions', index) as IMarkupReplyKeyboardOptions; + const replyKeyboardOptions = this.getNodeParameter( + 'replyKeyboardOptions', + index, + ) as IMarkupReplyKeyboardOptions; Object.assign(body.reply_markup, replyKeyboardOptions); } } - /** * Make an API request to Telegram * @@ -144,7 +146,15 @@ export function addAdditionalFields(this: IExecuteFunctions, body: IDataObject, * @param {object} body * @returns {Promise} */ -export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function apiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + method: string, + endpoint: string, + body: IDataObject, + query?: IDataObject, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('telegramApi'); query = query || {}; @@ -178,12 +188,11 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa } export function getImageBySize(photos: IDataObject[], size: string): IDataObject | undefined { - const sizes = { - 'small': 0, - 'medium': 1, - 'large': 2, - 'extraLarge': 3, + small: 0, + medium: 1, + large: 2, + extraLarge: 3, } as IDataObject; const index = sizes[size] as number; diff --git a/packages/nodes-base/nodes/Telegram/IEvent.ts b/packages/nodes-base/nodes/Telegram/IEvent.ts index 9abfbd0b29..55f9e2f7b9 100644 --- a/packages/nodes-base/nodes/Telegram/IEvent.ts +++ b/packages/nodes-base/nodes/Telegram/IEvent.ts @@ -1,8 +1,7 @@ - interface EventBody { photo?: [ { - file_id: string, + file_id: string; }, ]; document?: { diff --git a/packages/nodes-base/nodes/Telegram/Telegram.node.ts b/packages/nodes-base/nodes/Telegram/Telegram.node.ts index d8aa07d51e..26e4fa3cce 100644 --- a/packages/nodes-base/nodes/Telegram/Telegram.node.ts +++ b/packages/nodes-base/nodes/Telegram/Telegram.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryData, @@ -11,11 +9,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - addAdditionalFields, - apiRequest, - getPropertyName, -} from './GenericFunctions'; +import { addAdditionalFields, apiRequest, getPropertyName } from './GenericFunctions'; export class Telegram implements INodeType { description: INodeTypeDescription = { @@ -105,9 +99,7 @@ export class Telegram implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'chat', - ], + resource: ['chat'], }, }, options: [ @@ -158,9 +150,7 @@ export class Telegram implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'callback', - ], + resource: ['callback'], }, }, options: [ @@ -186,9 +176,7 @@ export class Telegram implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'file', - ], + resource: ['file'], }, }, options: [ @@ -209,9 +197,7 @@ export class Telegram implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'message', - ], + resource: ['message'], }, }, options: [ @@ -303,7 +289,6 @@ export class Telegram implements INodeType { default: 'sendMessage', }, - // ---------------------------------- // chat / message // ---------------------------------- @@ -336,14 +321,12 @@ export class Telegram implements INodeType { 'sendVideo', 'unpinChatMessage', ], - resource: [ - 'chat', - 'message', - ], + resource: ['chat', 'message'], }, }, required: true, - description: 'Unique identifier for the target chat or username of the target channel (in the format @channelusername)', + description: + 'Unique identifier for the target chat or username of the target channel (in the format @channelusername)', }, // ---------------------------------- @@ -356,12 +339,8 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'deleteMessage', - ], - resource: [ - 'message', - ], + operation: ['deleteMessage'], + resource: ['message'], }, }, required: true, @@ -378,13 +357,8 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'pinChatMessage', - 'unpinChatMessage', - ], - resource: [ - 'message', - ], + operation: ['pinChatMessage', 'unpinChatMessage'], + resource: ['message'], }, }, required: true, @@ -397,12 +371,8 @@ export class Telegram implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'pinChatMessage', - ], - resource: [ - 'message', - ], + operation: ['pinChatMessage'], + resource: ['message'], }, }, default: {}, @@ -412,7 +382,8 @@ export class Telegram implements INodeType { name: 'disable_notification', type: 'boolean', default: false, - description: 'Whether to send a notification to all chat members about the new pinned message', + description: + 'Whether to send a notification to all chat members about the new pinned message', }, ], }, @@ -431,19 +402,14 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'member', - ], - resource: [ - 'chat', - ], + operation: ['member'], + resource: ['chat'], }, }, required: true, description: 'Unique identifier of the target user', }, - // ---------------------------------- // chat:setDescription // ---------------------------------- @@ -454,19 +420,14 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'setDescription', - ], - resource: [ - 'chat', - ], + operation: ['setDescription'], + resource: ['chat'], }, }, required: true, description: 'New chat description, 0-255 characters', }, - // ---------------------------------- // chat:setTitle // ---------------------------------- @@ -477,19 +438,14 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'setTitle', - ], - resource: [ - 'chat', - ], + operation: ['setTitle'], + resource: ['chat'], }, }, required: true, description: 'New chat title, 1-255 characters', }, - // ---------------------------------- // callback // ---------------------------------- @@ -504,12 +460,8 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'answerQuery', - ], - resource: [ - 'callback', - ], + operation: ['answerQuery'], + resource: ['callback'], }, }, required: true, @@ -523,12 +475,8 @@ export class Telegram implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'answerQuery', - ], - resource: [ - 'callback', - ], + operation: ['answerQuery'], + resource: ['callback'], }, }, default: {}, @@ -541,14 +489,16 @@ export class Telegram implements INodeType { minValue: 0, }, default: 0, - description: 'The maximum amount of time in seconds that the result of the callback query may be cached client-side', + description: + 'The maximum amount of time in seconds that the result of the callback query may be cached client-side', }, { displayName: 'Show Alert', name: 'show_alert', type: 'boolean', default: false, - description: 'Whether an alert will be shown by the client instead of a notification at the top of the chat screen', + description: + 'Whether an alert will be shown by the client instead of a notification at the top of the chat screen', }, { displayName: 'Text', @@ -558,14 +508,15 @@ export class Telegram implements INodeType { alwaysOpenEditWindow: true, }, default: '', - description: 'Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.', + description: + 'Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.', }, { displayName: 'URL', name: 'url', type: 'string', default: '', - description: 'URL that will be opened by the user\'s client', + description: "URL that will be opened by the user's client", }, ], }, @@ -580,12 +531,8 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'answerInlineQuery', - ], - resource: [ - 'callback', - ], + operation: ['answerInlineQuery'], + resource: ['callback'], }, }, required: true, @@ -598,12 +545,8 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'answerInlineQuery', - ], - resource: [ - 'callback', - ], + operation: ['answerInlineQuery'], + resource: ['callback'], }, }, required: true, @@ -616,12 +559,8 @@ export class Telegram implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'answerInlineQuery', - ], - resource: [ - 'callback', - ], + operation: ['answerInlineQuery'], + resource: ['callback'], }, }, default: {}, @@ -634,14 +573,16 @@ export class Telegram implements INodeType { minValue: 0, }, default: 0, - description: 'The maximum amount of time in seconds that the result of the callback query may be cached client-side', + description: + 'The maximum amount of time in seconds that the result of the callback query may be cached client-side', }, { displayName: 'Show Alert', name: 'show_alert', type: 'boolean', default: false, - description: 'Whether an alert will be shown by the client instead of a notification at the top of the chat screen', + description: + 'Whether an alert will be shown by the client instead of a notification at the top of the chat screen', }, { displayName: 'Text', @@ -651,19 +592,19 @@ export class Telegram implements INodeType { alwaysOpenEditWindow: true, }, default: '', - description: 'Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.', + description: + 'Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters.', }, { displayName: 'URL', name: 'url', type: 'string', default: '', - description: 'URL that will be opened by the user\'s client', + description: "URL that will be opened by the user's client", }, ], }, - // ---------------------------------- // file // ---------------------------------- @@ -679,12 +620,8 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'file', - ], + operation: ['get'], + resource: ['file'], }, }, required: true, @@ -696,12 +633,8 @@ export class Telegram implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'file', - ], + operation: ['get'], + resource: ['file'], }, }, default: true, @@ -722,12 +655,8 @@ export class Telegram implements INodeType { type: 'options', displayOptions: { show: { - operation: [ - 'editMessageText', - ], - resource: [ - 'message', - ], + operation: ['editMessageText'], + resource: ['message'], }, }, options: [ @@ -751,19 +680,14 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - messageType: [ - 'message', - ], - operation: [ - 'editMessageText', - ], - resource: [ - 'message', - ], + messageType: ['message'], + operation: ['editMessageText'], + resource: ['message'], }, }, required: true, - description: 'Unique identifier for the target chat or username of the target channel (in the format @channelusername). To find your chat ID ask @get_id_bot.', + description: + 'Unique identifier for the target chat or username of the target channel (in the format @channelusername). To find your chat ID ask @get_id_bot.', }, // ---------------------------------- // message:sendAnimation/sendAudio/sendDocument/sendPhoto/sendSticker/sendVideo @@ -785,9 +709,7 @@ export class Telegram implements INodeType { 'sendVideo', 'sendSticker', ], - resource: [ - 'message', - ], + resource: ['message'], }, }, description: 'Whether the data to upload should be taken from binary field', @@ -808,12 +730,8 @@ export class Telegram implements INodeType { 'sendVideo', 'sendSticker', ], - resource: [ - 'message', - ], - binaryData: [ - true, - ], + resource: ['message'], + binaryData: [true], }, }, placeholder: '', @@ -826,15 +744,9 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - messageType: [ - 'message', - ], - operation: [ - 'editMessageText', - ], - resource: [ - 'message', - ], + messageType: ['message'], + operation: ['editMessageText'], + resource: ['message'], }, }, required: true, @@ -847,15 +759,9 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - messageType: [ - 'inlineMessage', - ], - operation: [ - 'editMessageText', - ], - resource: [ - 'message', - ], + messageType: ['inlineMessage'], + operation: ['editMessageText'], + resource: ['message'], }, }, required: true, @@ -866,12 +772,8 @@ export class Telegram implements INodeType { name: 'replyMarkup', displayOptions: { show: { - operation: [ - 'editMessageText', - ], - resource: [ - 'message', - ], + operation: ['editMessageText'], + resource: ['message'], }, }, type: 'options', @@ -889,8 +791,6 @@ export class Telegram implements INodeType { description: 'Additional interface options', }, - - // ---------------------------------- // message:sendAnimation // ---------------------------------- @@ -901,22 +801,15 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'sendAnimation', - ], - resource: [ - 'message', - ], - binaryData: [ - false, - ], + operation: ['sendAnimation'], + resource: ['message'], + binaryData: [false], }, }, - description: 'Animation to send. Pass a file_id to send an animation that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get an animation from the Internet.', + description: + 'Animation to send. Pass a file_id to send an animation that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get an animation from the Internet.', }, - - // ---------------------------------- // message:sendAudio // ---------------------------------- @@ -927,22 +820,15 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'sendAudio', - ], - resource: [ - 'message', - ], - binaryData: [ - false, - ], + operation: ['sendAudio'], + resource: ['message'], + binaryData: [false], }, }, - description: 'Audio file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.', + description: + 'Audio file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.', }, - - // ---------------------------------- // message:sendChatAction // ---------------------------------- @@ -952,12 +838,8 @@ export class Telegram implements INodeType { type: 'options', displayOptions: { show: { - operation: [ - 'sendChatAction', - ], - resource: [ - 'message', - ], + operation: ['sendChatAction'], + resource: ['message'], }, }, options: [ @@ -1013,11 +895,10 @@ export class Telegram implements INodeType { }, ], default: 'typing', - description: 'Type of action to broadcast. Choose one, depending on what the user is about to receive. The status is set for 5 seconds or less (when a message arrives from your bot).', + description: + 'Type of action to broadcast. Choose one, depending on what the user is about to receive. The status is set for 5 seconds or less (when a message arrives from your bot).', }, - - // ---------------------------------- // message:sendDocument // ---------------------------------- @@ -1028,21 +909,15 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'sendDocument', - ], - resource: [ - 'message', - ], - binaryData: [ - false, - ], + operation: ['sendDocument'], + resource: ['message'], + binaryData: [false], }, }, - description: 'Document to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.', + description: + 'Document to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.', }, - // ---------------------------------- // message:sendLocation // ---------------------------------- @@ -1058,12 +933,8 @@ export class Telegram implements INodeType { }, displayOptions: { show: { - operation: [ - 'sendLocation', - ], - resource: [ - 'message', - ], + operation: ['sendLocation'], + resource: ['message'], }, }, description: 'Location latitude', @@ -1081,12 +952,8 @@ export class Telegram implements INodeType { default: 0.0, displayOptions: { show: { - operation: [ - 'sendLocation', - ], - resource: [ - 'message', - ], + operation: ['sendLocation'], + resource: ['message'], }, }, description: 'Location longitude', @@ -1101,12 +968,8 @@ export class Telegram implements INodeType { type: 'fixedCollection', displayOptions: { show: { - operation: [ - 'sendMediaGroup', - ], - resource: [ - 'message', - ], + operation: ['sendMediaGroup'], + resource: ['message'], }, }, description: 'The media to add', @@ -1142,7 +1005,8 @@ export class Telegram implements INodeType { name: 'media', type: 'string', default: '', - description: 'Media to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass an HTTP URL for Telegram to get a file from the Internet.', + description: + 'Media to send. Pass a file_id to send a file that exists on the Telegram servers (recommended) or pass an HTTP URL for Telegram to get a file from the Internet.', }, { displayName: 'Additional Fields', @@ -1178,7 +1042,6 @@ export class Telegram implements INodeType { default: 'HTML', description: 'How to parse the text', }, - ], }, ], @@ -1186,7 +1049,6 @@ export class Telegram implements INodeType { ], }, - // ---------------------------------- // message:sendMessage // ---------------------------------- @@ -1201,19 +1063,13 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'editMessageText', - 'sendMessage', - ], - resource: [ - 'message', - ], + operation: ['editMessageText', 'sendMessage'], + resource: ['message'], }, }, description: 'Text of the message to be sent', }, - // ---------------------------------- // message:sendPhoto // ---------------------------------- @@ -1224,21 +1080,15 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'sendPhoto', - ], - resource: [ - 'message', - ], - binaryData: [ - false, - ], + operation: ['sendPhoto'], + resource: ['message'], + binaryData: [false], }, }, - description: 'Photo to send. Pass a file_id to send a photo that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a photo from the Internet.', + description: + 'Photo to send. Pass a file_id to send a photo that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a photo from the Internet.', }, - // ---------------------------------- // message:sendSticker // ---------------------------------- @@ -1249,21 +1099,15 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'sendSticker', - ], - resource: [ - 'message', - ], - binaryData: [ - false, - ], + operation: ['sendSticker'], + resource: ['message'], + binaryData: [false], }, }, - description: 'Sticker to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a .webp file from the Internet.', + description: + 'Sticker to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a .webp file from the Internet.', }, - // ---------------------------------- // message:sendVideo // ---------------------------------- @@ -1274,18 +1118,13 @@ export class Telegram implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'sendVideo', - ], - resource: [ - 'message', - ], - binaryData: [ - false, - ], + operation: ['sendVideo'], + resource: ['message'], + binaryData: [false], }, }, - description: 'Video file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.', + description: + 'Video file to send. Pass a file_id to send a file that exists on the Telegram servers (recommended), an HTTP URL for Telegram to get a file from the Internet.', }, // ---------------------------------- @@ -1307,9 +1146,7 @@ export class Telegram implements INodeType { 'sendAudio', 'sendLocation', ], - resource: [ - 'message', - ], + resource: ['message'], }, }, type: 'options', @@ -1346,12 +1183,8 @@ export class Telegram implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - replyMarkup: [ - 'forceReply', - ], - resource: [ - 'message', - ], + replyMarkup: ['forceReply'], + resource: ['message'], }, }, default: {}, @@ -1361,7 +1194,8 @@ export class Telegram implements INodeType { name: 'force_reply', type: 'boolean', default: false, - description: 'Whether to show reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply', + description: + 'Whether to show reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply', }, { displayName: 'Selective', @@ -1373,7 +1207,6 @@ export class Telegram implements INodeType { ], }, - { displayName: 'Inline Keyboard', name: 'inlineKeyboard', @@ -1385,12 +1218,8 @@ export class Telegram implements INodeType { }, displayOptions: { show: { - replyMarkup: [ - 'inlineKeyboard', - ], - resource: [ - 'message', - ], + replyMarkup: ['inlineKeyboard'], + resource: ['message'], }, }, default: {}, @@ -1433,7 +1262,8 @@ export class Telegram implements INodeType { name: 'callback_data', type: 'string', default: '', - description: 'Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes', + description: + 'Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes', }, { displayName: 'Pay', @@ -1447,14 +1277,16 @@ export class Telegram implements INodeType { name: 'switch_inline_query_current_chat', type: 'string', default: '', - description: 'If set, pressing the button will insert the bot‘s username and the specified inline query in the current chat\'s input field.Can be empty, in which case only the bot’s username will be inserted', + description: + "If set, pressing the button will insert the bot‘s username and the specified inline query in the current chat's input field.Can be empty, in which case only the bot’s username will be inserted", }, { displayName: 'Switch Inline Query', name: 'switch_inline_query', type: 'string', default: '', - description: 'If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot‘s username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted.', + description: + 'If set, pressing the button will prompt the user to select one of their chats, open that chat and insert the bot‘s username and the specified inline query in the input field. Can be empty, in which case just the bot’s username will be inserted.', }, { displayName: 'URL', @@ -1485,9 +1317,7 @@ export class Telegram implements INodeType { }, displayOptions: { show: { - replyMarkup: [ - 'replyKeyboard', - ], + replyMarkup: ['replyKeyboard'], }, }, default: {}, @@ -1516,7 +1346,8 @@ export class Telegram implements INodeType { name: 'text', type: 'string', default: '', - description: 'Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed.', + description: + 'Text of the button. If none of the optional fields are used, it will be sent as a message when the button is pressed.', }, { displayName: 'Additional Fields', @@ -1530,14 +1361,15 @@ export class Telegram implements INodeType { name: 'request_contact', type: 'boolean', default: false, - description: 'Whether the user\'s phone number will be sent as a contact when the button is pressed.Available in private chats only', + description: + "Whether the user's phone number will be sent as a contact when the button is pressed.Available in private chats only", }, { displayName: 'Request Location', name: 'request_location', type: 'boolean', default: false, - description: 'Whether the user\'s request_location', + description: "Whether the user's request_location", }, ], }, @@ -1557,9 +1389,7 @@ export class Telegram implements INodeType { placeholder: 'Add Option', displayOptions: { show: { - replyMarkup: [ - 'replyKeyboard', - ], + replyMarkup: ['replyKeyboard'], }, }, default: {}, @@ -1569,14 +1399,16 @@ export class Telegram implements INodeType { name: 'resize_keyboard', type: 'boolean', default: false, - description: 'Whether to request clients to resize the keyboard vertically for optimal fit', + description: + 'Whether to request clients to resize the keyboard vertically for optimal fit', }, { displayName: 'One Time Keyboard', name: 'one_time_keyboard', type: 'boolean', default: false, - description: 'Whether to request clients to hide the keyboard as soon as it\'s been used', + description: + "Whether to request clients to hide the keyboard as soon as it's been used", }, { displayName: 'Selective', @@ -1595,9 +1427,7 @@ export class Telegram implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - replyMarkup: [ - 'replyKeyboardRemove', - ], + replyMarkup: ['replyKeyboardRemove'], }, }, default: {}, @@ -1638,9 +1468,7 @@ export class Telegram implements INodeType { 'sendSticker', 'sendVideo', ], - resource: [ - 'message', - ], + resource: ['message'], }, }, default: {}, @@ -1673,12 +1501,11 @@ export class Telegram implements INodeType { default: false, displayOptions: { hide: { - '/operation': [ - 'editMessageText', - ], + '/operation': ['editMessageText'], }, }, - description: 'Whether to send the message silently. Users will receive a notification with no sound.', + description: + 'Whether to send the message silently. Users will receive a notification with no sound.', }, { displayName: 'Disable WebPage Preview', @@ -1686,10 +1513,7 @@ export class Telegram implements INodeType { type: 'boolean', displayOptions: { show: { - '/operation': [ - 'editMessageText', - 'sendMessage', - ], + '/operation': ['editMessageText', 'sendMessage'], }, }, default: false, @@ -1704,11 +1528,7 @@ export class Telegram implements INodeType { }, displayOptions: { show: { - '/operation': [ - 'sendAnimation', - 'sendAudio', - 'sendVideo', - ], + '/operation': ['sendAnimation', 'sendAudio', 'sendVideo'], }, }, default: 0, @@ -1729,12 +1549,8 @@ export class Telegram implements INodeType { 'sendVideo', 'sendSticker', ], - '/resource': [ - 'message', - ], - '/binaryData': [ - true, - ], + '/resource': ['message'], + '/binaryData': [true], }, }, placeholder: 'image.jpeg', @@ -1748,10 +1564,7 @@ export class Telegram implements INodeType { }, displayOptions: { show: { - '/operation': [ - 'sendAnimation', - 'sendVideo', - ], + '/operation': ['sendAnimation', 'sendVideo'], }, }, default: 0, @@ -1792,9 +1605,7 @@ export class Telegram implements INodeType { type: 'string', displayOptions: { show: { - '/operation': [ - 'sendAudio', - ], + '/operation': ['sendAudio'], }, }, default: '', @@ -1806,9 +1617,7 @@ export class Telegram implements INodeType { type: 'number', displayOptions: { hide: { - '/operation': [ - 'editMessageText', - ], + '/operation': ['editMessageText'], }, }, default: 0, @@ -1823,9 +1632,7 @@ export class Telegram implements INodeType { }, displayOptions: { show: { - '/operation': [ - 'sendAudio', - ], + '/operation': ['sendAudio'], }, }, default: '', @@ -1837,16 +1644,12 @@ export class Telegram implements INodeType { type: 'string', displayOptions: { show: { - '/operation': [ - 'sendAnimation', - 'sendAudio', - 'sendDocument', - 'sendVideo', - ], + '/operation': ['sendAnimation', 'sendAudio', 'sendDocument', 'sendVideo'], }, }, default: '', - description: 'Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.', + description: + 'Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.', }, { displayName: 'Width', @@ -1857,10 +1660,7 @@ export class Telegram implements INodeType { }, displayOptions: { show: { - '/operation': [ - 'sendAnimation', - 'sendVideo', - ], + '/operation': ['sendAnimation', 'sendVideo'], }, }, default: 0, @@ -1868,7 +1668,6 @@ export class Telegram implements INodeType { }, ], }, - ], }; @@ -1909,7 +1708,6 @@ export class Telegram implements INodeType { // Add additional fields const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); - } else if (operation === 'answerInlineQuery') { // ----------------------------------------------- // callback:answerInlineQuery @@ -1924,7 +1722,6 @@ export class Telegram implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); } - } else if (resource === 'chat') { if (operation === 'get') { // ---------------------------------- @@ -1934,7 +1731,6 @@ export class Telegram implements INodeType { endpoint = 'getChat'; body.chat_id = this.getNodeParameter('chatId', i) as string; - } else if (operation === 'administrators') { // ---------------------------------- // chat:administrators @@ -1943,7 +1739,6 @@ export class Telegram implements INodeType { endpoint = 'getChatAdministrators'; body.chat_id = this.getNodeParameter('chatId', i) as string; - } else if (operation === 'leave') { // ---------------------------------- // chat:leave @@ -1952,7 +1747,6 @@ export class Telegram implements INodeType { endpoint = 'leaveChat'; body.chat_id = this.getNodeParameter('chatId', i) as string; - } else if (operation === 'member') { // ---------------------------------- // chat:member @@ -1962,7 +1756,6 @@ export class Telegram implements INodeType { body.chat_id = this.getNodeParameter('chatId', i) as string; body.user_id = this.getNodeParameter('userId', i) as string; - } else if (operation === 'setDescription') { // ---------------------------------- // chat:setDescription @@ -1972,7 +1765,6 @@ export class Telegram implements INodeType { body.chat_id = this.getNodeParameter('chatId', i) as string; body.description = this.getNodeParameter('description', i) as string; - } else if (operation === 'setTitle') { // ---------------------------------- // chat:setTitle @@ -1982,14 +1774,12 @@ export class Telegram implements INodeType { body.chat_id = this.getNodeParameter('chatId', i) as string; body.title = this.getNodeParameter('title', i) as string; - } // } else if (resource === 'bot') { // if (operation === 'info') { // endpoint = 'getUpdates'; // } } else if (resource === 'file') { - if (operation === 'get') { // ---------------------------------- // file:get @@ -1999,9 +1789,7 @@ export class Telegram implements INodeType { body.file_id = this.getNodeParameter('fileId', i) as string; } - } else if (resource === 'message') { - if (operation === 'editMessageText') { // ---------------------------------- // message:editMessageText @@ -2022,7 +1810,6 @@ export class Telegram implements INodeType { // Add additional fields and replyMarkup addAdditionalFields.call(this, body, i); - } else if (operation === 'deleteMessage') { // ---------------------------------- // message:deleteMessage @@ -2032,7 +1819,6 @@ export class Telegram implements INodeType { body.chat_id = this.getNodeParameter('chatId', i) as string; body.message_id = this.getNodeParameter('messageId', i) as string; - } else if (operation === 'pinChatMessage') { // ---------------------------------- // message:pinChatMessage @@ -2043,11 +1829,13 @@ export class Telegram implements INodeType { body.chat_id = this.getNodeParameter('chatId', i) as string; body.message_id = this.getNodeParameter('messageId', i) as string; - const { disable_notification } = this.getNodeParameter('additionalFields', i) as IDataObject; + const { disable_notification } = this.getNodeParameter( + 'additionalFields', + i, + ) as IDataObject; if (disable_notification) { body.disable_notification = true; } - } else if (operation === 'unpinChatMessage') { // ---------------------------------- // message:unpinChatMessage @@ -2057,7 +1845,6 @@ export class Telegram implements INodeType { body.chat_id = this.getNodeParameter('chatId', i) as string; body.message_id = this.getNodeParameter('messageId', i) as string; - } else if (operation === 'sendAnimation') { // ---------------------------------- // message:sendAnimation @@ -2070,7 +1857,6 @@ export class Telegram implements INodeType { // Add additional fields and replyMarkup addAdditionalFields.call(this, body, i); - } else if (operation === 'sendAudio') { // ---------------------------------- // message:sendAudio @@ -2083,7 +1869,6 @@ export class Telegram implements INodeType { // Add additional fields and replyMarkup addAdditionalFields.call(this, body, i); - } else if (operation === 'sendChatAction') { // ---------------------------------- // message:sendChatAction @@ -2093,7 +1878,6 @@ export class Telegram implements INodeType { body.chat_id = this.getNodeParameter('chatId', i) as string; body.action = this.getNodeParameter('action', i) as string; - } else if (operation === 'sendDocument') { // ---------------------------------- // message:sendDocument @@ -2106,7 +1890,6 @@ export class Telegram implements INodeType { // Add additional fields and replyMarkup addAdditionalFields.call(this, body, i); - } else if (operation === 'sendLocation') { // ---------------------------------- // message:sendLocation @@ -2120,7 +1903,6 @@ export class Telegram implements INodeType { // Add additional fields and replyMarkup addAdditionalFields.call(this, body, i); - } else if (operation === 'sendMessage') { // ---------------------------------- // message:sendMessage @@ -2133,7 +1915,6 @@ export class Telegram implements INodeType { // Add additional fields and replyMarkup addAdditionalFields.call(this, body, i); - } else if (operation === 'sendMediaGroup') { // ---------------------------------- // message:sendMediaGroup @@ -2155,7 +1936,6 @@ export class Telegram implements INodeType { } (body.media as IDataObject[]).push(mediaItem); } - } else if (operation === 'sendPhoto') { // ---------------------------------- // message:sendPhoto @@ -2168,7 +1948,6 @@ export class Telegram implements INodeType { // Add additional fields and replyMarkup addAdditionalFields.call(this, body, i); - } else if (operation === 'sendSticker') { // ---------------------------------- // message:sendSticker @@ -2181,7 +1960,6 @@ export class Telegram implements INodeType { // Add additional fields and replyMarkup addAdditionalFields.call(this, body, i); - } else if (operation === 'sendVideo') { // ---------------------------------- // message:sendVideo @@ -2196,7 +1974,9 @@ export class Telegram implements INodeType { addAdditionalFields.call(this, body, i); } } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { + itemIndex: i, + }); } let responseData; @@ -2211,10 +1991,12 @@ export class Telegram implements INodeType { const filename = fileName || binaryData.fileName?.toString(); if (!fileName && !binaryData.fileName) { - throw new NodeOperationError(this.getNode(), - `File name is needed to ${operation}. Make sure the property that holds the binary data + throw new NodeOperationError( + this.getNode(), + `File name is needed to ${operation}. Make sure the property that holds the binary data has the file name property set or set it manually in the node using the File Name parameter under - Additional Fields.`); + Additional Fields.`, + ); } body.disable_notification = body.disable_notification?.toString() || 'false'; @@ -2236,14 +2018,29 @@ export class Telegram implements INodeType { } if (resource === 'file' && operation === 'get') { - if (this.getNodeParameter('download', i, false) as boolean === true) { + if ((this.getNodeParameter('download', i, false) as boolean) === true) { const filePath = responseData.result.file_path; const credentials = await this.getCredentials('telegramApi'); - const file = await apiRequest.call(this, 'GET', '', {}, {}, { json: false, encoding: null, uri: `https://api.telegram.org/file/bot${credentials.accessToken}/${filePath}`, resolveWithFullResponse: true }); + const file = await apiRequest.call( + this, + 'GET', + '', + {}, + {}, + { + json: false, + encoding: null, + uri: `https://api.telegram.org/file/bot${credentials.accessToken}/${filePath}`, + resolveWithFullResponse: true, + }, + ); const fileName = filePath.split('/').pop(); - const binaryData = await this.helpers.prepareBinaryData(Buffer.from(file.body as string), fileName); + const binaryData = await this.helpers.prepareBinaryData( + Buffer.from(file.body as string), + fileName, + ); returnData.push({ json: responseData, diff --git a/packages/nodes-base/nodes/Telegram/TelegramTrigger.node.ts b/packages/nodes-base/nodes/Telegram/TelegramTrigger.node.ts index 2f2945bdf4..688532b5e1 100644 --- a/packages/nodes-base/nodes/Telegram/TelegramTrigger.node.ts +++ b/packages/nodes-base/nodes/Telegram/TelegramTrigger.node.ts @@ -1,23 +1,10 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import { - IDataObject, - INodeType, - INodeTypeDescription, - IWebhookResponseData, -} from 'n8n-workflow'; +import { IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; -import { - apiRequest, - getImageBySize, -} from './GenericFunctions'; +import { apiRequest, getImageBySize } from './GenericFunctions'; -import { - IEvent, -} from './IEvent'; +import { IEvent } from './IEvent'; export class TelegramTrigger implements INodeType { description: INodeTypeDescription = { @@ -66,17 +53,20 @@ export class TelegramTrigger implements INodeType { { name: 'Channel Post', value: 'channel_post', - description: 'Trigger on new incoming channel post of any kind — text, photo, sticker, etc', + description: + 'Trigger on new incoming channel post of any kind — text, photo, sticker, etc', }, { name: 'Edited Channel Post', value: 'edited_channel_post', - description: 'Trigger on new version of a channel post that is known to the bot and was edited', + description: + 'Trigger on new version of a channel post that is known to the bot and was edited', }, { name: 'Edited Message', value: 'edited_message', - description: 'Trigger on new version of a channel post that is known to the bot and was edited', + description: + 'Trigger on new version of a channel post that is known to the bot and was edited', }, { name: 'Inline Query', @@ -91,17 +81,20 @@ export class TelegramTrigger implements INodeType { { name: 'Poll', value: 'poll', - description: 'Trigger on new poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot.', + description: + 'Trigger on new poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot.', }, { name: 'Pre-Checkout Query', value: 'pre_checkout_query', - description: 'Trigger on new incoming pre-checkout query. Contains full information about checkout.', + description: + 'Trigger on new incoming pre-checkout query. Contains full information about checkout.', }, { name: 'Shipping Query', value: 'shipping_query', - description: 'Trigger on new incoming shipping query. Only for invoices with flexible price.', + description: + 'Trigger on new incoming shipping query. Only for invoices with flexible price.', }, ], required: true, @@ -121,7 +114,8 @@ export class TelegramTrigger implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Telegram delivers the image in multiple sizes. By default, just the large image would be downloaded. If you want to change the size, set the field \'Image Size\'.', + description: + "Telegram delivers the image in multiple sizes. By default, just the large image would be downloaded. If you want to change the size, set the field 'Image Size'.", }, { displayName: 'Image Size', @@ -129,9 +123,7 @@ export class TelegramTrigger implements INodeType { type: 'options', displayOptions: { show: { - download: [ - true, - ], + download: [true], }, }, options: [ @@ -210,7 +202,6 @@ export class TelegramTrigger implements INodeType { }; async webhook(this: IWebhookFunctions): Promise { - const credentials = await this.getCredentials('telegramApi'); const bodyData = this.getBodyData() as IEvent; @@ -218,7 +209,6 @@ export class TelegramTrigger implements INodeType { const additionalFields = this.getNodeParameter('additionalFields') as IDataObject; if (additionalFields.download === true) { - let imageSize = 'large'; let key: 'message' | 'channel_post' = 'message'; @@ -227,18 +217,21 @@ export class TelegramTrigger implements INodeType { key = 'channel_post'; } - if ((bodyData[key] && bodyData[key]?.photo && Array.isArray(bodyData[key]?.photo) || bodyData[key]?.document)) { - + if ( + (bodyData[key] && bodyData[key]?.photo && Array.isArray(bodyData[key]?.photo)) || + bodyData[key]?.document + ) { if (additionalFields.imageSize) { - imageSize = additionalFields.imageSize as string; } let fileId; if (bodyData[key]?.photo) { - - let image = getImageBySize(bodyData[key]?.photo as IDataObject[], imageSize) as IDataObject; + let image = getImageBySize( + bodyData[key]?.photo as IDataObject[], + imageSize, + ) as IDataObject; // When the image is sent from the desktop app telegram does not resize the image // So return the only image avaiable @@ -248,21 +241,36 @@ export class TelegramTrigger implements INodeType { } fileId = image.file_id; - } else { - fileId = bodyData[key]?.document?.file_id; } - const { result: { file_path } } = await apiRequest.call(this, 'GET', `getFile?file_id=${fileId}`, {}); + const { + result: { file_path }, + } = await apiRequest.call(this, 'GET', `getFile?file_id=${fileId}`, {}); - const file = await apiRequest.call(this, 'GET', '', {}, {}, { json: false, encoding: null, uri: `https://api.telegram.org/file/bot${credentials.accessToken}/${file_path}`, resolveWithFullResponse: true }); + const file = await apiRequest.call( + this, + 'GET', + '', + {}, + {}, + { + json: false, + encoding: null, + uri: `https://api.telegram.org/file/bot${credentials.accessToken}/${file_path}`, + resolveWithFullResponse: true, + }, + ); const data = Buffer.from(file.body as string); const fileName = file_path.split('/').pop(); - const binaryData = await this.helpers.prepareBinaryData(data as unknown as Buffer, fileName); + const binaryData = await this.helpers.prepareBinaryData( + data as unknown as Buffer, + fileName, + ); return { workflowData: [ @@ -280,9 +288,7 @@ export class TelegramTrigger implements INodeType { } return { - workflowData: [ - this.helpers.returnJsonArray([bodyData as unknown as IDataObject]), - ], + workflowData: [this.helpers.returnJsonArray([bodyData as unknown as IDataObject])], }; } } diff --git a/packages/nodes-base/nodes/TheHive/GenericFunctions.ts b/packages/nodes-base/nodes/TheHive/GenericFunctions.ts index 6a7a11b0f4..68254638e7 100644 --- a/packages/nodes-base/nodes/TheHive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/TheHive/GenericFunctions.ts @@ -1,21 +1,23 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; import moment from 'moment'; import { Eq } from './QueryFunctions'; -export async function theHiveApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function theHiveApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('theHiveApi'); let options: OptionsWithUri = { @@ -39,7 +41,7 @@ export async function theHiveApiRequest(this: IHookFunctions | IExecuteFunctions delete options.qs; } try { - return await this.helpers.requestWithAuthentication.call(this, 'theHiveApi',options); + return await this.helpers.requestWithAuthentication.call(this, 'theHiveApi', options); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -64,7 +66,7 @@ export function mapResource(resource: string): string { } export function splitTags(tags: string): string[] { - return tags.split(',').filter(tag => tag !== ' ' && tag); + return tags.split(',').filter((tag) => tag !== ' ' && tag); } export function prepareOptional(optionals: IDataObject): IDataObject { @@ -73,8 +75,7 @@ export function prepareOptional(optionals: IDataObject): IDataObject { if (optionals[key] !== undefined && optionals[key] !== null && optionals[key] !== '') { if (['customFieldsJson', 'customFieldsUi'].indexOf(key) > -1) { continue; // Ignore customFields, they need special treatment - } - else if (moment(optionals[key] as string, moment.ISO_8601).isValid()) { + } else if (moment(optionals[key] as string, moment.ISO_8601).isValid()) { response[key] = Date.parse(optionals[key] as string); } else if (key === 'artifacts') { response[key] = JSON.parse(optionals[key] as string); @@ -88,7 +89,11 @@ export function prepareOptional(optionals: IDataObject): IDataObject { return response; } -export async function prepareCustomFields(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, additionalFields: IDataObject, jsonParameters = false): Promise { +export async function prepareCustomFields( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + additionalFields: IDataObject, + jsonParameters = false, +): Promise { // Check if the additionalFields object contains customFields if (jsonParameters === true) { const customFieldsJson = additionalFields.customFieldsJson; @@ -109,30 +114,35 @@ export async function prepareCustomFields(this: IHookFunctions | IExecuteFunctio const version = credentials.apiVersion; const endpoint = version === 'v1' ? '/customField' : '/list/custom_fields'; - const requestResult = await theHiveApiRequest.call( - this, - 'GET', - endpoint as string, - ); + const requestResult = await theHiveApiRequest.call(this, 'GET', endpoint as string); // Convert TheHive3 response to the same format as TheHive 4 // [{name, reference, type}] - const hiveCustomFields = version === 'v1' ? requestResult : Object.keys(requestResult).map(key => requestResult[key]); + const hiveCustomFields = + version === 'v1' + ? requestResult + : Object.keys(requestResult).map((key) => requestResult[key]); // Build reference to type mapping object - const referenceTypeMapping = hiveCustomFields.reduce((acc: IDataObject, curr: IDataObject) => (acc[curr.reference as string] = curr.type, acc), {}); + const referenceTypeMapping = hiveCustomFields.reduce( + (acc: IDataObject, curr: IDataObject) => ((acc[curr.reference as string] = curr.type), acc), + {}, + ); // Build "fieldName": {"type": "value"} objects - const customFieldsUi = (additionalFields.customFieldsUi as IDataObject); - const customFields : IDataObject = (customFieldsUi?.customFields as IDataObject[]).reduce((acc: IDataObject, curr: IDataObject) => { - const fieldName = curr.field as string; + const customFieldsUi = additionalFields.customFieldsUi as IDataObject; + const customFields: IDataObject = (customFieldsUi?.customFields as IDataObject[]).reduce( + (acc: IDataObject, curr: IDataObject) => { + const fieldName = curr.field as string; - // Might be able to do some type conversions here if needed, TODO + // Might be able to do some type conversions here if needed, TODO - acc[fieldName] = { - [referenceTypeMapping[fieldName]]: curr.value, - }; - return acc; - }, {} as IDataObject); + acc[fieldName] = { + [referenceTypeMapping[fieldName]]: curr.value, + }; + return acc; + }, + {} as IDataObject, + ); delete additionalFields.customFieldsUi; return customFields; @@ -143,12 +153,13 @@ export async function prepareCustomFields(this: IHookFunctions | IExecuteFunctio export function buildCustomFieldSearch(customFields: IDataObject): IDataObject[] { const customFieldTypes = ['boolean', 'date', 'float', 'integer', 'number', 'string']; const searchQueries: IDataObject[] = []; - Object.keys(customFields).forEach(customFieldName => { + Object.keys(customFields).forEach((customFieldName) => { const customField = customFields[customFieldName] as IDataObject; // Figure out the field type from the object's keys - const fieldType = Object.keys(customField) - .filter(key => customFieldTypes.indexOf(key) > -1)[0]; + const fieldType = Object.keys(customField).filter( + (key) => customFieldTypes.indexOf(key) > -1, + )[0]; const fieldValue = customField[fieldType]; searchQueries.push(Eq(`customFields.${customFieldName}.${fieldType}`, fieldValue)); @@ -162,25 +173,19 @@ export function prepareSortQuery(sort: string, body: { query: [IDataObject] }) { const value = sort.charAt(0) === '+' ? 'asc' : 'desc'; const sortOption: IDataObject = {}; sortOption[field] = value; - body.query.push( - { - '_name': 'sort', - '_fields': [ - sortOption, - ], - }, - ); + body.query.push({ + _name: 'sort', + _fields: [sortOption], + }); } } -export function prepareRangeQuery(range: string, body: { 'query': Array<{}> }) { +export function prepareRangeQuery(range: string, body: { query: Array<{}> }) { if (range && range !== 'all') { - body['query'].push( - { - '_name': 'page', - 'from': parseInt(range.split('-')[0], 10), - 'to': parseInt(range.split('-')[1], 10), - }, - ); + body['query'].push({ + _name: 'page', + from: parseInt(range.split('-')[0], 10), + to: parseInt(range.split('-')[1], 10), + }); } } diff --git a/packages/nodes-base/nodes/TheHive/QueryFunctions.ts b/packages/nodes-base/nodes/TheHive/QueryFunctions.ts index b9cf7a2830..c1fd08e6a7 100644 --- a/packages/nodes-base/nodes/TheHive/QueryFunctions.ts +++ b/packages/nodes-base/nodes/TheHive/QueryFunctions.ts @@ -1,75 +1,102 @@ // Query types -export declare type queryIndexSignature = '_field' | '_gt' | '_value' | '_gte' | '_lt' | '_lte' | '_and' | '_or' | '_not' | '_in' | '_contains' | '_id' | '_between' | '_parent' | '_parent' | '_child' | '_type' | '_string' | '_like' | '_wildcard'; +export declare type queryIndexSignature = + | '_field' + | '_gt' + | '_value' + | '_gte' + | '_lt' + | '_lte' + | '_and' + | '_or' + | '_not' + | '_in' + | '_contains' + | '_id' + | '_between' + | '_parent' + | '_parent' + | '_child' + | '_type' + | '_string' + | '_like' + | '_wildcard'; export type IQueryObject = { - [key in queryIndexSignature]?: IQueryObject | IQueryObject[] | string | number | object + [key in queryIndexSignature]?: IQueryObject | IQueryObject[] | string | number | object; }; // Query Functions -export function Eq(field: string, value: any): IQueryObject { // tslint:disable-line:no-any - return { '_field': field, '_value': value }; +// tslint:disable-next-line:no-any +export function Eq(field: string, value: any): IQueryObject { + return { _field: field, _value: value }; } -export function Gt(field: string, value: any): IQueryObject { // tslint:disable-line:no-any - return { '_gt': { field: value } }; +// tslint:disable-next-line:no-any +export function Gt(field: string, value: any): IQueryObject { + return { _gt: { field: value } }; } -export function Gte(field: string, value: any): IQueryObject { // tslint:disable-line:no-any - return { '_gte': { field: value } }; +// tslint:disable-next-line:no-any +export function Gte(field: string, value: any): IQueryObject { + return { _gte: { field: value } }; } -export function Lt(field: string, value: any): IQueryObject { // tslint:disable-line:no-any - return { '_lt': { field: value } }; +// tslint:disable-next-line:no-any +export function Lt(field: string, value: any): IQueryObject { + return { _lt: { field: value } }; } -export function Lte(field: string, value: any): IQueryObject { // tslint:disable-line:no-any - return { '_lte': { field: value } }; +// tslint:disable-next-line:no-any +export function Lte(field: string, value: any): IQueryObject { + return { _lte: { field: value } }; } export function And(...criteria: IQueryObject[]): IQueryObject { - return { '_and': criteria }; + return { _and: criteria }; } export function Or(...criteria: IQueryObject[]): IQueryObject { - return { '_or': criteria }; + return { _or: criteria }; } export function Not(criteria: IQueryObject[]): IQueryObject { - return { '_not': criteria }; + return { _not: criteria }; } -export function In(field: string, values: any[]): IQueryObject { // tslint:disable-line:no-any - return { '_in': { '_field': field, '_values': values } }; +// tslint:disable-next-line:no-any +export function In(field: string, values: any[]): IQueryObject { + return { _in: { _field: field, _values: values } }; } export function Contains(field: string): IQueryObject { - return { '_contains': field }; + return { _contains: field }; } export function Id(id: string | number): IQueryObject { - return { '_id': id }; + return { _id: id }; } -export function Between(field: string, fromValue: any, toValue: any): IQueryObject { // tslint:disable-line:no-any - return { '_between': { '_field': field, '_from': fromValue, '_to': toValue } }; +// tslint:disable-next-line:no-any +export function Between(field: string, fromValue: any, toValue: any): IQueryObject { + return { _between: { _field: field, _from: fromValue, _to: toValue } }; } export function ParentId(tpe: string, id: string): IQueryObject { - return { '_parent': { '_type': tpe, '_id': id } }; + return { _parent: { _type: tpe, _id: id } }; } export function Parent(tpe: string, criterion: IQueryObject): IQueryObject { - return { '_parent': { '_type': tpe, '_query': criterion } }; + return { _parent: { _type: tpe, _query: criterion } }; } export function Child(tpe: string, criterion: IQueryObject): IQueryObject { - return { '_child': { '_type': tpe, '_query': criterion } }; + return { _child: { _type: tpe, _query: criterion } }; } export function Type(tpe: string): IQueryObject { - return { '_type': tpe }; + return { _type: tpe }; } export function queryString(queryString: string): IQueryObject { - return { '_string': queryString }; + return { _string: queryString }; } export function Like(field: string, value: string): IQueryObject { - return { '_like': { '_field': field, '_value': value } }; + return { _like: { _field: field, _value: value } }; } export function StartsWith(field: string, value: string) { if (!value.startsWith('*')) { value = value + '*'; } - return { '_wildcard': { '_field': field, '_value': value } }; + return { _wildcard: { _field: field, _value: value } }; } export function EndsWith(field: string, value: string) { if (!value.endsWith('*')) { value = '*' + value; } - return { '_wildcard': { '_field': field, '_value': value } }; + return { _wildcard: { _field: field, _value: value } }; } export function ContainsString(field: string, value: string) { if (!value.endsWith('*')) { @@ -78,5 +105,5 @@ export function ContainsString(field: string, value: string) { if (!value.startsWith('*')) { value = '*' + value; } - return { '_wildcard': { '_field': field, '_value': value } }; + return { _wildcard: { _field: field, _value: value } }; } diff --git a/packages/nodes-base/nodes/TheHive/TheHive.node.ts b/packages/nodes-base/nodes/TheHive/TheHive.node.ts index f6dd3692f3..1d78fe5f53 100644 --- a/packages/nodes-base/nodes/TheHive/TheHive.node.ts +++ b/packages/nodes-base/nodes/TheHive/TheHive.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryData, @@ -14,45 +12,19 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - alertFields, - alertOperations, -} from './descriptions/AlertDescription'; +import { alertFields, alertOperations } from './descriptions/AlertDescription'; -import { - observableFields, - observableOperations, -} from './descriptions/ObservableDescription'; +import { observableFields, observableOperations } from './descriptions/ObservableDescription'; -import { - caseFields, - caseOperations, -} from './descriptions/CaseDescription'; +import { caseFields, caseOperations } from './descriptions/CaseDescription'; -import { - taskFields, - taskOperations, -} from './descriptions/TaskDescription'; +import { taskFields, taskOperations } from './descriptions/TaskDescription'; -import { - logFields, - logOperations, -} from './descriptions/LogDescription'; +import { logFields, logOperations } from './descriptions/LogDescription'; -import { - Buffer, -} from 'buffer'; +import { Buffer } from 'buffer'; -import { - And, - Between, - ContainsString, - Eq, - Id, - In, - IQueryObject, - Parent, -} from './QueryFunctions'; +import { And, Between, ContainsString, Eq, Id, In, IQueryObject, Parent } from './QueryFunctions'; import { buildCustomFieldSearch, @@ -141,11 +113,7 @@ export class TheHive implements INodeType { const resourceId = this.getNodeParameter('id'); const endpoint = `/connector/cortex/responder/${resource}/${resourceId}`; - const responders = await theHiveApiRequest.call( - this, - 'GET', - endpoint as string, - ); + const responders = await theHiveApiRequest.call(this, 'GET', endpoint as string); const returnData: INodePropertyOptions[] = []; @@ -163,11 +131,7 @@ export class TheHive implements INodeType { // request the analyzers from instance const dataType = this.getNodeParameter('dataType') as string; const endpoint = `/connector/cortex/analyzer/type/${dataType}`; - const requestResult = await theHiveApiRequest.call( - this, - 'GET', - endpoint as string, - ); + const requestResult = await theHiveApiRequest.call(this, 'GET', endpoint as string); const returnData: INodePropertyOptions[] = []; for (const analyzer of requestResult) { @@ -186,16 +150,15 @@ export class TheHive implements INodeType { const version = credentials.apiVersion; const endpoint = version === 'v1' ? '/customField' : '/list/custom_fields'; - const requestResult = await theHiveApiRequest.call( - this, - 'GET', - endpoint as string, - ); + const requestResult = await theHiveApiRequest.call(this, 'GET', endpoint as string); const returnData: INodePropertyOptions[] = []; // Convert TheHive3 response to the same format as TheHive 4 - const customFields = version === 'v1' ? requestResult : Object.keys(requestResult).map(key => requestResult[key]); + const customFields = + version === 'v1' + ? requestResult + : Object.keys(requestResult).map((key) => requestResult[key]); for (const field of customFields) { returnData.push({ @@ -212,11 +175,25 @@ export class TheHive implements INodeType { const version = (await this.getCredentials('theHiveApi')).apiVersion; const options = [ - ...(version === 'v1') ? [{ name: 'Count', value: 'count', description: 'Count observables' }] : [], + ...(version === 'v1' + ? [{ name: 'Count', value: 'count', description: 'Count observables' }] + : []), { name: 'Create', value: 'create', description: 'Create observable' }, - { name: 'Execute Analyzer', value: 'executeAnalyzer', description: 'Execute an responder on selected observable' }, - { name: 'Execute Responder', value: 'executeResponder', description: 'Execute a responder on selected observable' }, - { name: 'Get All', value: 'getAll', description: 'Get all observables of a specific case' }, + { + name: 'Execute Analyzer', + value: 'executeAnalyzer', + description: 'Execute an responder on selected observable', + }, + { + name: 'Execute Responder', + value: 'executeResponder', + description: 'Execute a responder on selected observable', + }, + { + name: 'Get All', + value: 'getAll', + description: 'Get all observables of a specific case', + }, { name: 'Get', value: 'get', description: 'Get a single observable' }, { name: 'Search', value: 'search', description: 'Search observables' }, { name: 'Update', value: 'update', description: 'Update observable' }, @@ -225,13 +202,10 @@ export class TheHive implements INodeType { }, async loadObservableTypes(this: ILoadOptionsFunctions): Promise { const version = (await this.getCredentials('theHiveApi')).apiVersion; - const endpoint = version === 'v1' ? '/observable/type?range=all' : '/list/list_artifactDataType'; + const endpoint = + version === 'v1' ? '/observable/type?range=all' : '/list/list_artifactDataType'; - const dataTypes = await theHiveApiRequest.call( - this, - 'GET', - endpoint as string, - ); + const dataTypes = await theHiveApiRequest.call(this, 'GET', endpoint as string); let returnData: INodePropertyOptions[] = []; @@ -242,9 +216,8 @@ export class TheHive implements INodeType { value: dataType.name as string, }; }); - } - else { - returnData = Object.keys(dataTypes).map(key => { + } else { + returnData = Object.keys(dataTypes).map((key) => { const dataType = dataTypes[key] as string; return { @@ -271,9 +244,15 @@ export class TheHive implements INodeType { const credentials = await this.getCredentials('theHiveApi'); const version = credentials.apiVersion; const options = [ - ...(version === 'v1') ? [{ name: 'Count', value: 'count', description: 'Count tasks' }] : [], + ...(version === 'v1' + ? [{ name: 'Count', value: 'count', description: 'Count tasks' }] + : []), { name: 'Create', value: 'create', description: 'Create a task' }, - { name: 'Execute Responder', value: 'executeResponder', description: 'Execute a responder on the specified task' }, + { + name: 'Execute Responder', + value: 'executeResponder', + description: 'Execute a responder on the specified task', + }, { name: 'Get All', value: 'getAll', description: 'Get all asks of a specific case' }, { name: 'Get', value: 'get', description: 'Get a single task' }, { name: 'Search', value: 'search', description: 'Search tasks' }, @@ -285,13 +264,23 @@ export class TheHive implements INodeType { const credentials = await this.getCredentials('theHiveApi'); const version = credentials.apiVersion; const options = [ - ...(version === 'v1') ? [{ name: 'Count', value: 'count', description: 'Count alerts' }] : [], + ...(version === 'v1' + ? [{ name: 'Count', value: 'count', description: 'Count alerts' }] + : []), { name: 'Create', value: 'create', description: 'Create alert' }, - { name: 'Execute Responder', value: 'executeResponder', description: 'Execute a responder on the specified alert' }, + { + name: 'Execute Responder', + value: 'executeResponder', + description: 'Execute a responder on the specified alert', + }, { name: 'Get', value: 'get', description: 'Get an alert' }, { name: 'Get All', value: 'getAll', description: 'Get all alerts' }, { name: 'Mark as Read', value: 'markAsRead', description: 'Mark the alert as read' }, - { name: 'Mark as Unread', value: 'markAsUnread', description: 'Mark the alert as unread' }, + { + name: 'Mark as Unread', + value: 'markAsUnread', + description: 'Mark the alert as unread', + }, { name: 'Merge', value: 'merge', description: 'Merge alert into an existing case' }, { name: 'Promote', value: 'promote', description: 'Promote an alert into a case' }, { name: 'Update', value: 'update', description: 'Update alert' }, @@ -302,9 +291,15 @@ export class TheHive implements INodeType { const credentials = await this.getCredentials('theHiveApi'); const version = credentials.apiVersion; const options = [ - ...(version === 'v1') ? [{ name: 'Count', value: 'count', description: 'Count a case' }] : [], + ...(version === 'v1' + ? [{ name: 'Count', value: 'count', description: 'Count a case' }] + : []), { name: 'Create', value: 'create', description: 'Create a case' }, - { name: 'Execute Responder', value: 'executeResponder', description: 'Execute a responder on the specified case' }, + { + name: 'Execute Responder', + value: 'executeResponder', + description: 'Execute a responder on the specified case', + }, { name: 'Get All', value: 'getAll', description: 'Get all cases' }, { name: 'Get', value: 'get', description: 'Get a single case' }, { name: 'Update', value: 'update', description: 'Update a case' }, @@ -333,7 +328,7 @@ export class TheHive implements INodeType { const _countSearchQuery: IQueryObject = And(); if ('customFieldsUi' in filters) { - const customFields = await prepareCustomFields.call(this, filters) as IDataObject; + const customFields = (await prepareCustomFields.call(this, filters)) as IDataObject; const searchQueries = buildCustomFieldSearch(customFields); (_countSearchQuery['_and'] as IQueryObject[]).push(...searchQueries); } @@ -355,41 +350,40 @@ export class TheHive implements INodeType { } const body = { - 'query': [ + query: [ { - '_name': 'listAlert', + _name: 'listAlert', }, { - '_name': 'filter', - '_and': _countSearchQuery['_and'], + _name: 'filter', + _and: _countSearchQuery['_and'], }, ], }; - body['query'].push( - { - '_name': 'count', - }, - ); + body['query'].push({ + _name: 'count', + }); qs.name = 'count-Alert'; - responseData = await theHiveApiRequest.call( - this, - 'POST', - '/v1/query', - body, - qs, - ); + responseData = await theHiveApiRequest.call(this, 'POST', '/v1/query', body, qs); responseData = { count: responseData }; } if (operation === 'create') { - const additionalFields = this.getNodeParameter('additionalFields', i) as INodeParameters; + const additionalFields = this.getNodeParameter( + 'additionalFields', + i, + ) as INodeParameters; const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean; - const customFields = await prepareCustomFields.call(this, additionalFields, jsonParameters); + const customFields = await prepareCustomFields.call( + this, + additionalFields, + jsonParameters, + ); const body: IDataObject = { title: this.getNodeParameter('title', i), description: this.getNodeParameter('description', i), @@ -409,15 +403,12 @@ export class TheHive implements INodeType { const artifactUi = this.getNodeParameter('artifactUi', i) as IDataObject; if (artifactUi) { - const artifactValues = (artifactUi as IDataObject).artifactValues as IDataObject[]; if (artifactValues) { - const artifactData = []; for (const artifactvalue of artifactValues) { - const element: IDataObject = {}; element.message = artifactvalue.message as string; @@ -429,17 +420,24 @@ export class TheHive implements INodeType { element.data = artifactvalue.data as string; if (artifactvalue.dataType === 'file') { - const item = items[i]; if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'No binary data exists on item!', + { itemIndex: i }, + ); } const binaryPropertyName = artifactvalue.binaryProperty as string; if (item.binary[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property '${binaryPropertyName}' does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property '${binaryPropertyName}' does not exists on item!`, + { itemIndex: i }, + ); } const binaryData = item.binary[binaryPropertyName] as IBinaryData; @@ -453,12 +451,7 @@ export class TheHive implements INodeType { } } - responseData = await theHiveApiRequest.call( - this, - 'POST', - '/alert' as string, - body, - ); + responseData = await theHiveApiRequest.call(this, 'POST', '/alert' as string, body); } /* @@ -486,37 +479,30 @@ export class TheHive implements INodeType { body = { query: [ { - '_name': 'listAction', + _name: 'listAction', }, { - '_name': 'filter', - '_and': [ + _name: 'filter', + _and: [ { - '_field': 'cortexId', - '_value': response.cortexId, + _field: 'cortexId', + _value: response.cortexId, }, { - '_field': 'objectId', - '_value': response.objectId, + _field: 'objectId', + _value: response.objectId, }, { - '_field': 'startDate', - '_value': response.startDate, + _field: 'startDate', + _value: response.startDate, }, - ], }, ], }; qs.name = 'log-actions'; do { - response = await theHiveApiRequest.call( - this, - 'POST', - `/v1/query`, - body, - qs, - ); + response = await theHiveApiRequest.call(this, 'POST', `/v1/query`, body, qs); } while (response.status === 'Waiting' || response.status === 'InProgress'); responseData = response; @@ -525,12 +511,7 @@ export class TheHive implements INodeType { if (operation === 'get') { const alertId = this.getNodeParameter('id', i) as string; - responseData = await theHiveApiRequest.call( - this, - 'GET', - `/alert/${alertId}`, - {}, - ); + responseData = await theHiveApiRequest.call(this, 'GET', `/alert/${alertId}`, {}); } if (operation === 'getAll') { const credentials = await this.getCredentials('theHiveApi'); @@ -546,7 +527,7 @@ export class TheHive implements INodeType { const _searchQuery: IQueryObject = And(); if ('customFieldsUi' in filters) { - const customFields = await prepareCustomFields.call(this, filters) as IDataObject; + const customFields = (await prepareCustomFields.call(this, filters)) as IDataObject; const searchQueries = buildCustomFieldSearch(customFields); (_searchQuery['_and'] as IQueryObject[]).push(...searchQueries); } @@ -585,13 +566,13 @@ export class TheHive implements INodeType { method = 'POST'; body = { - 'query': [ + query: [ { - '_name': 'listAlert', + _name: 'listAlert', }, { - '_name': 'filter', - '_and': _searchQuery['_and'], + _name: 'filter', + _and: _searchQuery['_and'], }, ], }; @@ -605,7 +586,6 @@ export class TheHive implements INodeType { } qs.name = 'alerts'; - } else { method = 'POST'; @@ -618,16 +598,9 @@ export class TheHive implements INodeType { body.query = _searchQuery; Object.assign(qs, prepareOptional(options)); - } - responseData = await theHiveApiRequest.call( - this, - method, - endpoint as string, - body, - qs, - ); + responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); } if (operation === 'markAsRead') { @@ -704,7 +677,6 @@ export class TheHive implements INodeType { const artifactData = []; for (const artifactvalue of artifactValues) { - const element: IDataObject = {}; element.message = artifactvalue.message as string; @@ -719,13 +691,21 @@ export class TheHive implements INodeType { const item = items[i]; if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'No binary data exists on item!', + { itemIndex: i }, + ); } const binaryPropertyName = artifactvalue.binaryProperty as string; if (item.binary[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property '${binaryPropertyName}' does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property '${binaryPropertyName}' does not exists on item!`, + { itemIndex: i }, + ); } const binaryData = item.binary[binaryPropertyName] as IBinaryData; @@ -750,8 +730,10 @@ export class TheHive implements INodeType { if (resource === 'observable') { if (operation === 'count') { - const countQueryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); // tslint:disable-line:no-any - + // tslint:disable-next-line:no-any + const countQueryAttributs: any = prepareOptional( + this.getNodeParameter('filters', i, {}) as INodeParameters, + ); const _countSearchQuery: IQueryObject = And(); for (const key of Object.keys(countQueryAttributs)) { @@ -779,46 +761,39 @@ export class TheHive implements INodeType { } const body = { - 'query': [ + query: [ { - '_name': 'listObservable', + _name: 'listObservable', }, { - '_name': 'filter', - '_and': _countSearchQuery['_and'], + _name: 'filter', + _and: _countSearchQuery['_and'], }, ], }; - body['query'].push( - { - '_name': 'count', - }, - ); + body['query'].push({ + _name: 'count', + }); qs.name = 'count-observables'; - responseData = await theHiveApiRequest.call( - this, - 'POST', - '/v1/query', - body, - qs, - ); + responseData = await theHiveApiRequest.call(this, 'POST', '/v1/query', body, qs); responseData = { count: responseData }; } if (operation === 'executeAnalyzer') { const observableId = this.getNodeParameter('id', i); - const analyzers = (this.getNodeParameter('analyzers', i) as string[]) - .map(analyzer => { + const analyzers = (this.getNodeParameter('analyzers', i) as string[]).map( + (analyzer) => { const parts = analyzer.split('::'); return { analyzerId: parts[0], cortexId: parts[1], }; - }); + }, + ); let response: any; // tslint:disable-line:no-any let body: IDataObject; responseData = []; @@ -839,10 +814,15 @@ export class TheHive implements INodeType { qs.name = 'observable-jobs'; // query the job result (including the report) do { - responseData = await theHiveApiRequest.call(this, 'GET', `/connector/cortex/job/${jobId}`, body, qs); + responseData = await theHiveApiRequest.call( + this, + 'GET', + `/connector/cortex/job/${jobId}`, + body, + qs, + ); } while (responseData.status === 'Waiting' || responseData.status === 'InProgress'); } - } if (operation === 'executeResponder') { @@ -865,37 +845,30 @@ export class TheHive implements INodeType { body = { query: [ { - '_name': 'listAction', + _name: 'listAction', }, { - '_name': 'filter', - '_and': [ + _name: 'filter', + _and: [ { - '_field': 'cortexId', - '_value': response.cortexId, + _field: 'cortexId', + _value: response.cortexId, }, { - '_field': 'objectId', - '_value': response.objectId, + _field: 'objectId', + _value: response.objectId, }, { - '_field': 'startDate', - '_value': response.startDate, + _field: 'startDate', + _value: response.startDate, }, - ], }, ], }; qs.name = 'log-actions'; do { - response = await theHiveApiRequest.call( - this, - 'POST', - `/v1/query`, - body, - qs, - ); + response = await theHiveApiRequest.call(this, 'POST', `/v1/query`, body, qs); } while (response.status === 'Waiting' || response.status === 'InProgress'); responseData = response; @@ -921,13 +894,19 @@ export class TheHive implements INodeType { const item = items[i]; if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const binaryPropertyName = this.getNodeParameter('binaryProperty', i) as string; if (item.binary[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property '${binaryPropertyName}' does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property '${binaryPropertyName}' does not exists on item!`, + { itemIndex: i }, + ); } const binaryData = item.binary[binaryPropertyName] as IBinaryData; @@ -975,37 +954,27 @@ export class TheHive implements INodeType { let body: IDataObject = {}; if (version === 'v1') { - endpoint = '/v1/query'; method = 'POST'; body = { - 'query': [ + query: [ { - '_name': 'getObservable', - 'idOrName': observableId, + _name: 'getObservable', + idOrName: observableId, }, ], }; qs.name = `get-observable-${observableId}`; - } else { - method = 'GET'; endpoint = `/case/artifact/${observableId}`; - } - responseData = await theHiveApiRequest.call( - this, - method, - endpoint as string, - body, - qs, - ); + responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); } if (operation === 'getAll') { @@ -1037,13 +1006,13 @@ export class TheHive implements INodeType { method = 'POST'; body = { - 'query': [ + query: [ { - '_name': 'getCase', - 'idOrName': caseId, + _name: 'getCase', + idOrName: caseId, }, { - '_name': 'observables', + _name: 'observables', }, ], }; @@ -1057,7 +1026,6 @@ export class TheHive implements INodeType { } qs.name = 'observables'; - } else { method = 'POST'; @@ -1072,13 +1040,7 @@ export class TheHive implements INodeType { Object.assign(qs, prepareOptional(options)); } - responseData = await theHiveApiRequest.call( - this, - method, - endpoint as string, - body, - qs, - ); + responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); } if (operation === 'search') { @@ -1088,7 +1050,10 @@ export class TheHive implements INodeType { const version = credentials.apiVersion; - const queryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); // tslint:disable-line:no-any + // tslint:disable-next-line:no-any + const queryAttributs: any = prepareOptional( + this.getNodeParameter('filters', i, {}) as INodeParameters, + ); const _searchQuery: IQueryObject = And(); @@ -1136,13 +1101,13 @@ export class TheHive implements INodeType { method = 'POST'; body = { - 'query': [ + query: [ { - '_name': 'listObservable', + _name: 'listObservable', }, { - '_name': 'filter', - '_and': _searchQuery['_and'], + _name: 'filter', + _and: _searchQuery['_and'], }, ], }; @@ -1156,7 +1121,6 @@ export class TheHive implements INodeType { } qs.name = 'observables'; - } else { method = 'POST'; @@ -1169,16 +1133,9 @@ export class TheHive implements INodeType { body.query = _searchQuery; Object.assign(qs, prepareOptional(options)); - } - responseData = await theHiveApiRequest.call( - this, - method, - endpoint as string, - body, - qs, - ); + responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); } if (operation === 'update') { @@ -1208,7 +1165,7 @@ export class TheHive implements INodeType { const _countSearchQuery: IQueryObject = And(); if ('customFieldsUi' in filters) { - const customFields = await prepareCustomFields.call(this, filters) as IDataObject; + const customFields = (await prepareCustomFields.call(this, filters)) as IDataObject; const searchQueries = buildCustomFieldSearch(customFields); (_countSearchQuery['_and'] as IQueryObject[]).push(...searchQueries); } @@ -1230,33 +1187,24 @@ export class TheHive implements INodeType { } const body = { - 'query': [ + query: [ { - '_name': 'listCase', + _name: 'listCase', }, { - '_name': 'filter', - '_and': _countSearchQuery['_and'], + _name: 'filter', + _and: _countSearchQuery['_and'], }, ], }; - body['query'].push( - { - '_name': 'count', - }, - ); + body['query'].push({ + _name: 'count', + }); qs.name = 'count-cases'; - - responseData = await theHiveApiRequest.call( - this, - 'POST', - '/v1/query', - body, - qs, - ); + responseData = await theHiveApiRequest.call(this, 'POST', '/v1/query', body, qs); responseData = { count: responseData }; } @@ -1281,37 +1229,30 @@ export class TheHive implements INodeType { body = { query: [ { - '_name': 'listAction', + _name: 'listAction', }, { - '_name': 'filter', - '_and': [ + _name: 'filter', + _and: [ { - '_field': 'cortexId', - '_value': response.cortexId, + _field: 'cortexId', + _value: response.cortexId, }, { - '_field': 'objectId', - '_value': response.objectId, + _field: 'objectId', + _value: response.objectId, }, { - '_field': 'startDate', - '_value': response.startDate, + _field: 'startDate', + _value: response.startDate, }, - ], }, ], }; qs.name = 'log-actions'; do { - response = await theHiveApiRequest.call( - this, - 'POST', - `/v1/query`, - body, - qs, - ); + response = await theHiveApiRequest.call(this, 'POST', `/v1/query`, body, qs); } while (response.status === 'Waiting' || response.status === 'InProgress'); responseData = response; @@ -1335,12 +1276,7 @@ export class TheHive implements INodeType { ...prepareOptional(options), }; - responseData = await theHiveApiRequest.call( - this, - 'POST', - '/case' as string, - body, - ); + responseData = await theHiveApiRequest.call(this, 'POST', '/case' as string, body); } if (operation === 'get') { @@ -1357,37 +1293,27 @@ export class TheHive implements INodeType { let body: IDataObject = {}; if (version === 'v1') { - endpoint = '/v1/query'; method = 'POST'; body = { - 'query': [ + query: [ { - '_name': 'getCase', - 'idOrName': caseId, + _name: 'getCase', + idOrName: caseId, }, ], }; qs.name = `get-case-${caseId}`; - } else { - method = 'GET'; endpoint = `/case/${caseId}`; - } - responseData = await theHiveApiRequest.call( - this, - method, - endpoint as string, - body, - qs, - ); + responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); } if (operation === 'getAll') { @@ -1405,7 +1331,7 @@ export class TheHive implements INodeType { const options = this.getNodeParameter('options', i) as IDataObject; if ('customFieldsUi' in filters) { - const customFields = await prepareCustomFields.call(this, filters) as IDataObject; + const customFields = (await prepareCustomFields.call(this, filters)) as IDataObject; const searchQueries = buildCustomFieldSearch(customFields); (_searchQuery['_and'] as IQueryObject[]).push(...searchQueries); } @@ -1444,13 +1370,13 @@ export class TheHive implements INodeType { method = 'POST'; body = { - 'query': [ + query: [ { - '_name': 'listCase', + _name: 'listCase', }, { - '_name': 'filter', - '_and': _searchQuery['_and'], + _name: 'filter', + _and: _searchQuery['_and'], }, ], }; @@ -1464,7 +1390,6 @@ export class TheHive implements INodeType { } qs.name = 'cases'; - } else { method = 'POST'; @@ -1479,13 +1404,7 @@ export class TheHive implements INodeType { Object.assign(qs, prepareOptional(options)); } - responseData = await theHiveApiRequest.call( - this, - method, - endpoint as string, - body, - qs, - ); + responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); } if (operation === 'update') { @@ -1511,7 +1430,10 @@ export class TheHive implements INodeType { if (resource === 'task') { if (operation === 'count') { - const countQueryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); // tslint:disable-line:no-any + // tslint:disable-next-line:no-any + const countQueryAttributs: any = prepareOptional( + this.getNodeParameter('filters', i, {}) as INodeParameters, + ); const _countSearchQuery: IQueryObject = And(); @@ -1528,32 +1450,24 @@ export class TheHive implements INodeType { } const body = { - 'query': [ + query: [ { - '_name': 'listTask', + _name: 'listTask', }, { - '_name': 'filter', - '_and': _countSearchQuery['_and'], + _name: 'filter', + _and: _countSearchQuery['_and'], }, ], }; - body['query'].push( - { - '_name': 'count', - }, - ); + body['query'].push({ + _name: 'count', + }); qs.name = 'count-tasks'; - responseData = await theHiveApiRequest.call( - this, - 'POST', - '/v1/query', - body, - qs, - ); + responseData = await theHiveApiRequest.call(this, 'POST', '/v1/query', body, qs); responseData = { count: responseData }; } @@ -1596,37 +1510,30 @@ export class TheHive implements INodeType { body = { query: [ { - '_name': 'listAction', + _name: 'listAction', }, { - '_name': 'filter', - '_and': [ + _name: 'filter', + _and: [ { - '_field': 'cortexId', - '_value': response.cortexId, + _field: 'cortexId', + _value: response.cortexId, }, { - '_field': 'objectId', - '_value': response.objectId, + _field: 'objectId', + _value: response.objectId, }, { - '_field': 'startDate', - '_value': response.startDate, + _field: 'startDate', + _value: response.startDate, }, - ], }, ], }; qs.name = 'task-actions'; do { - response = await theHiveApiRequest.call( - this, - 'POST', - `/v1/query`, - body, - qs, - ); + response = await theHiveApiRequest.call(this, 'POST', `/v1/query`, body, qs); } while (response.status === 'Waiting' || response.status === 'InProgress'); responseData = response; @@ -1651,30 +1558,22 @@ export class TheHive implements INodeType { method = 'POST'; body = { - 'query': [ + query: [ { - '_name': 'getTask', - 'idOrName': taskId, + _name: 'getTask', + idOrName: taskId, }, ], }; qs.name = `get-task-${taskId}`; - } else { method = 'GET'; endpoint = `/case/task/${taskId}`; - } - responseData = await theHiveApiRequest.call( - this, - method, - endpoint as string, - body, - qs, - ); + responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); } if (operation === 'getAll') { @@ -1707,13 +1606,13 @@ export class TheHive implements INodeType { method = 'POST'; body = { - 'query': [ + query: [ { - '_name': 'getCase', - 'idOrName': caseId, + _name: 'getCase', + idOrName: caseId, }, { - '_name': 'tasks', + _name: 'tasks', }, ], }; @@ -1727,13 +1626,11 @@ export class TheHive implements INodeType { } qs.name = 'case-tasks'; - } else { method = 'POST'; endpoint = '/case/task/_search'; - if (limit !== undefined) { qs.range = `0-${limit}`; } @@ -1741,16 +1638,9 @@ export class TheHive implements INodeType { body.query = And(Parent('case', Id(caseId))); Object.assign(qs, prepareOptional(options)); - } - responseData = await theHiveApiRequest.call( - this, - method, - endpoint as string, - body, - qs, - ); + responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); } if (operation === 'search') { @@ -1760,7 +1650,10 @@ export class TheHive implements INodeType { const version = credentials.apiVersion; - const queryAttributs: any = prepareOptional(this.getNodeParameter('filters', i, {}) as INodeParameters); // tslint:disable-line:no-any + // tslint:disable-next-line:no-any + const queryAttributs: any = prepareOptional( + this.getNodeParameter('filters', i, {}) as INodeParameters, + ); const _searchQuery: IQueryObject = And(); @@ -1796,13 +1689,13 @@ export class TheHive implements INodeType { method = 'POST'; body = { - 'query': [ + query: [ { - '_name': 'listTask', + _name: 'listTask', }, { - '_name': 'filter', - '_and': _searchQuery['_and'], + _name: 'filter', + _and: _searchQuery['_and'], }, ], }; @@ -1816,7 +1709,6 @@ export class TheHive implements INodeType { } qs.name = 'tasks'; - } else { method = 'POST'; @@ -1829,16 +1721,9 @@ export class TheHive implements INodeType { body.query = _searchQuery; Object.assign(qs, prepareOptional(options)); - } - responseData = await theHiveApiRequest.call( - this, - method, - endpoint as string, - body, - qs, - ); + responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); } if (operation === 'update') { @@ -1859,7 +1744,6 @@ export class TheHive implements INodeType { if (resource === 'log') { if (operation === 'create') { - const taskId = this.getNodeParameter('taskId', i) as string; let body: IDataObject = { @@ -1872,19 +1756,26 @@ export class TheHive implements INodeType { let options: IDataObject = {}; if (optionals.attachementUi) { - const attachmentValues = (optionals.attachementUi as IDataObject).attachmentValues as IDataObject; + const attachmentValues = (optionals.attachementUi as IDataObject) + .attachmentValues as IDataObject; if (attachmentValues) { const item = items[i]; if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: i, + }); } const binaryPropertyName = attachmentValues.binaryProperty as string; if (item.binary[binaryPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property '${binaryPropertyName}' does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property '${binaryPropertyName}' does not exists on item!`, + { itemIndex: i }, + ); } const binaryData = item.binary[binaryPropertyName] as IBinaryData; @@ -1938,37 +1829,30 @@ export class TheHive implements INodeType { body = { query: [ { - '_name': 'listAction', + _name: 'listAction', }, { - '_name': 'filter', - '_and': [ + _name: 'filter', + _and: [ { - '_field': 'cortexId', - '_value': response.cortexId, + _field: 'cortexId', + _value: response.cortexId, }, { - '_field': 'objectId', - '_value': response.objectId, + _field: 'objectId', + _value: response.objectId, }, { - '_field': 'startDate', - '_value': response.startDate, + _field: 'startDate', + _value: response.startDate, }, - ], }, ], }; qs.name = 'log-actions'; do { - response = await theHiveApiRequest.call( - this, - 'POST', - `/v1/query`, - body, - qs, - ); + response = await theHiveApiRequest.call(this, 'POST', `/v1/query`, body, qs); } while (response.status === 'Waiting' || response.status === 'InProgress'); responseData = response; @@ -1988,7 +1872,6 @@ export class TheHive implements INodeType { let body: IDataObject = {}; if (version === 'v1') { - endpoint = '/v1/query'; method = 'POST'; @@ -2011,13 +1894,7 @@ export class TheHive implements INodeType { body.query = { _id: logId }; } - responseData = await theHiveApiRequest.call( - this, - method, - endpoint as string, - body, - qs, - ); + responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); } if (operation === 'getAll') { @@ -2047,13 +1924,13 @@ export class TheHive implements INodeType { method = 'POST'; body = { - 'query': [ + query: [ { - '_name': 'getTask', - 'idOrName': taskId, + _name: 'getTask', + idOrName: taskId, }, { - '_name': 'logs', + _name: 'logs', }, ], }; @@ -2064,7 +1941,6 @@ export class TheHive implements INodeType { } qs.name = 'case-task-logs'; - } else { method = 'POST'; @@ -2074,25 +1950,15 @@ export class TheHive implements INodeType { qs.range = `0-${limit}`; } - body.query = And(Parent( - 'task', - Id(taskId), - )); + body.query = And(Parent('task', Id(taskId))); } - responseData = await theHiveApiRequest.call( - this, - method, - endpoint as string, - body, - qs, - ); + responseData = await theHiveApiRequest.call(this, method, endpoint as string, body, qs); } } if (Array.isArray(responseData)) { returnData.push.apply(returnData, responseData as IDataObject[]); - } else if (responseData !== undefined) { returnData.push(responseData as IDataObject); } @@ -2107,7 +1973,3 @@ export class TheHive implements INodeType { return [this.helpers.returnJsonArray(returnData)]; } } - - - - diff --git a/packages/nodes-base/nodes/TheHive/TheHiveTrigger.node.ts b/packages/nodes-base/nodes/TheHive/TheHiveTrigger.node.ts index 5341a4ffc6..c6bc31c26d 100644 --- a/packages/nodes-base/nodes/TheHive/TheHiveTrigger.node.ts +++ b/packages/nodes-base/nodes/TheHive/TheHiveTrigger.node.ts @@ -1,6 +1,4 @@ -import { - IWebhookFunctions, -} from 'n8n-core'; +import { IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -158,19 +156,15 @@ export class TheHiveTrigger implements INodeType { // The data to return and so start the workflow with const returnData: IDataObject[] = []; - returnData.push( - { - event, - body: this.getBodyData(), - headers: this.getHeaderData(), - query: this.getQueryData(), - }, - ); + returnData.push({ + event, + body: this.getBodyData(), + headers: this.getHeaderData(), + query: this.getQueryData(), + }); return { - workflowData: [ - this.helpers.returnJsonArray(returnData), - ], + workflowData: [this.helpers.returnJsonArray(returnData)], }; } } diff --git a/packages/nodes-base/nodes/TheHive/descriptions/AlertDescription.ts b/packages/nodes-base/nodes/TheHive/descriptions/AlertDescription.ts index 35ad2aaaa2..642bb259da 100644 --- a/packages/nodes-base/nodes/TheHive/descriptions/AlertDescription.ts +++ b/packages/nodes-base/nodes/TheHive/descriptions/AlertDescription.ts @@ -1,17 +1,14 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - TLP, -} from '../interfaces/AlertInterface'; +import { TLP } from '../interfaces/AlertInterface'; export const alertOperations: INodeProperties[] = [ { displayName: 'Operation Name or ID', name: 'operation', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', noDataExpression: true, required: true, typeOptions: { @@ -19,9 +16,7 @@ export const alertOperations: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'alert', - ], + resource: ['alert'], }, }, default: 'create', @@ -35,12 +30,8 @@ export const alertFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'alert', - ], + operation: ['getAll'], + resource: ['alert'], }, }, default: false, @@ -52,15 +43,9 @@ export const alertFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'alert', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['alert'], + returnAll: [false], }, }, typeOptions: { @@ -79,9 +64,7 @@ export const alertFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'alert', - ], + resource: ['alert'], operation: [ 'promote', 'markAsRead', @@ -103,12 +86,8 @@ export const alertFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'merge', - ], + resource: ['alert'], + operation: ['merge'], }, }, }, @@ -120,12 +99,8 @@ export const alertFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'create', - ], + resource: ['alert'], + operation: ['create'], }, }, description: 'Title of the alert', @@ -138,12 +113,8 @@ export const alertFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'create', - ], + resource: ['alert'], + operation: ['create'], }, }, description: 'Description of the alert', @@ -170,12 +141,8 @@ export const alertFields: INodeProperties[] = [ default: 2, displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'create', - ], + resource: ['alert'], + operation: ['create'], }, }, description: 'Severity of the alert. Default=Medium.', @@ -188,12 +155,8 @@ export const alertFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'create', - ], + resource: ['alert'], + operation: ['create'], }, }, description: 'Date and time when the alert was raised default=now', @@ -207,12 +170,8 @@ export const alertFields: INodeProperties[] = [ placeholder: 'tag,tag2,tag3...', displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'create', - ], + resource: ['alert'], + operation: ['create'], }, }, description: 'Case Tags', @@ -235,19 +194,16 @@ export const alertFields: INodeProperties[] = [ { name: 'Amber', value: TLP.amber, - }, { + }, + { name: 'Red', value: TLP.red, }, ], displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'create', - ], + resource: ['alert'], + operation: ['create'], }, }, description: 'Traffict Light Protocol (TLP). Default=Amber.', @@ -278,12 +234,8 @@ export const alertFields: INodeProperties[] = [ default: 'New', displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'create', - ], + resource: ['alert'], + operation: ['create'], }, }, description: 'Status of the alert', @@ -296,12 +248,8 @@ export const alertFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'create', - ], + resource: ['alert'], + operation: ['create'], }, }, description: 'Type of the alert', @@ -314,12 +262,8 @@ export const alertFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'create', - ], + resource: ['alert'], + operation: ['create'], }, }, description: 'Source of the alert', @@ -332,12 +276,8 @@ export const alertFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'create', - ], + resource: ['alert'], + operation: ['create'], }, }, description: 'Source reference of the alert', @@ -350,12 +290,8 @@ export const alertFields: INodeProperties[] = [ default: true, displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'create', - ], + resource: ['alert'], + operation: ['create'], }, }, description: 'Whether the alert becomes active when updated default=true', @@ -368,12 +304,8 @@ export const alertFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'create', - ], + resource: ['alert'], + operation: ['create'], }, }, typeOptions: { @@ -392,7 +324,8 @@ export const alertFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'loadObservableTypes', }, - description: 'Type of the observable. Choose from the list, or specify an ID using an expression.', + description: + 'Type of the observable. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Data', @@ -400,9 +333,7 @@ export const alertFields: INodeProperties[] = [ type: 'string', displayOptions: { hide: { - dataType: [ - 'file', - ], + dataType: ['file'], }, }, default: '', @@ -413,9 +344,7 @@ export const alertFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - dataType: [ - 'file', - ], + dataType: ['file'], }, }, default: 'data', @@ -442,28 +371,21 @@ export const alertFields: INodeProperties[] = [ displayName: 'Responder Name or ID', name: 'responder', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, default: '', typeOptions: { - loadOptionsDependsOn: [ - 'id', - ], + loadOptionsDependsOn: ['id'], loadOptionsMethod: 'loadResponders', }, displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'executeResponder', - ], + resource: ['alert'], + operation: ['executeResponder'], }, hide: { - id: [ - '', - ], + id: [''], }, }, }, @@ -474,13 +396,8 @@ export const alertFields: INodeProperties[] = [ default: true, displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'create', - 'update', - ], + resource: ['alert'], + operation: ['create', 'update'], }, }, }, @@ -494,12 +411,8 @@ export const alertFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'create', - ], + resource: ['alert'], + operation: ['create'], }, }, options: [ @@ -517,9 +430,7 @@ export const alertFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, typeOptions: { @@ -535,7 +446,8 @@ export const alertFields: INodeProperties[] = [ displayName: 'Field Name or ID', name: 'field', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'loadCustomFields', }, @@ -559,9 +471,7 @@ export const alertFields: INodeProperties[] = [ default: '', displayOptions: { show: { - '/jsonParameters': [ - true, - ], + '/jsonParameters': [true], }, }, description: 'Custom fields in JSON format. Overrides Custom Fields UI if set.', @@ -578,12 +488,8 @@ export const alertFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'promote', - ], + resource: ['alert'], + operation: ['promote'], }, }, options: [ @@ -605,12 +511,8 @@ export const alertFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'update', - ], + resource: ['alert'], + operation: ['update'], }, }, options: [ @@ -636,7 +538,8 @@ export const alertFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'loadObservableTypes', }, - description: 'Type of the observable. Choose from the list, or specify an ID using an expression.', + description: + 'Type of the observable. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Data', @@ -644,9 +547,7 @@ export const alertFields: INodeProperties[] = [ type: 'string', displayOptions: { hide: { - dataType: [ - 'file', - ], + dataType: ['file'], }, }, default: '', @@ -657,9 +558,7 @@ export const alertFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - dataType: [ - 'file', - ], + dataType: ['file'], }, }, default: 'data', @@ -690,9 +589,7 @@ export const alertFields: INodeProperties[] = [ }, displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, placeholder: 'Add Custom Field', @@ -705,7 +602,8 @@ export const alertFields: INodeProperties[] = [ displayName: 'Field Name or ID', name: 'field', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'loadCustomFields', }, @@ -728,9 +626,7 @@ export const alertFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/jsonParameters': [ - true, - ], + '/jsonParameters': [true], }, }, default: '', @@ -849,12 +745,8 @@ export const alertFields: INodeProperties[] = [ name: 'options', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'alert', - ], + operation: ['getAll'], + resource: ['alert'], }, }, type: 'collection', @@ -878,13 +770,8 @@ export const alertFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - resource: [ - 'alert', - ], - operation: [ - 'getAll', - 'count', - ], + resource: ['alert'], + operation: ['getAll', 'count'], }, }, options: [ @@ -906,7 +793,8 @@ export const alertFields: INodeProperties[] = [ displayName: 'Field Name or ID', name: 'field', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'loadCustomFields', }, diff --git a/packages/nodes-base/nodes/TheHive/descriptions/CaseDescription.ts b/packages/nodes-base/nodes/TheHive/descriptions/CaseDescription.ts index 90798b7358..ddd11489bd 100644 --- a/packages/nodes-base/nodes/TheHive/descriptions/CaseDescription.ts +++ b/packages/nodes-base/nodes/TheHive/descriptions/CaseDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - TLP, -} from '../interfaces/AlertInterface'; +import { TLP } from '../interfaces/AlertInterface'; export const caseOperations: INodeProperties[] = [ { @@ -13,20 +9,17 @@ export const caseOperations: INodeProperties[] = [ name: 'operation', default: 'getAll', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', noDataExpression: true, required: true, displayOptions: { show: { - resource: [ - 'case', - ], + resource: ['case'], }, }, typeOptions: { - loadOptionsDependsOn: [ - 'resource', - ], + loadOptionsDependsOn: ['resource'], loadOptionsMethod: 'loadCaseOptions', }, }, @@ -39,12 +32,8 @@ export const caseFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'case', - ], + operation: ['getAll'], + resource: ['case'], }, }, default: false, @@ -56,15 +45,9 @@ export const caseFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'case', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['case'], + returnAll: [false], }, }, typeOptions: { @@ -83,14 +66,8 @@ export const caseFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'update', - 'executeResponder', - 'get', - ], + resource: ['case'], + operation: ['update', 'executeResponder', 'get'], }, }, description: 'ID of the case', @@ -103,12 +80,8 @@ export const caseFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], + resource: ['case'], + operation: ['create'], }, }, description: 'Title of the case', @@ -121,12 +94,8 @@ export const caseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], + resource: ['case'], + operation: ['create'], }, }, description: 'Description of the case', @@ -153,12 +122,8 @@ export const caseFields: INodeProperties[] = [ default: 2, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], + resource: ['case'], + operation: ['create'], }, }, description: 'Severity of the alert. Default=Medium.', @@ -171,12 +136,8 @@ export const caseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], + resource: ['case'], + operation: ['create'], }, }, description: 'Date and time of the begin of the case default=now', @@ -189,12 +150,8 @@ export const caseFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], + resource: ['case'], + operation: ['create'], }, }, }, @@ -206,12 +163,8 @@ export const caseFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], + resource: ['case'], + operation: ['create'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether @@ -243,12 +196,8 @@ export const caseFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], + resource: ['case'], + operation: ['create'], }, }, description: 'Traffict Light Protocol (TLP). Default=Amber.', @@ -261,12 +210,8 @@ export const caseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], + resource: ['case'], + operation: ['create'], }, }, }, @@ -275,28 +220,21 @@ export const caseFields: INodeProperties[] = [ displayName: 'Responder Name or ID', name: 'responder', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: '', required: true, typeOptions: { - loadOptionsDependsOn: [ - 'id', - ], + loadOptionsDependsOn: ['id'], loadOptionsMethod: 'loadResponders', }, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'executeResponder', - ], + resource: ['case'], + operation: ['executeResponder'], }, hide: { - id: [ - '', - ], + id: [''], }, }, }, @@ -307,13 +245,8 @@ export const caseFields: INodeProperties[] = [ default: true, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - 'update', - ], + resource: ['case'], + operation: ['create', 'update'], }, }, }, @@ -325,12 +258,8 @@ export const caseFields: INodeProperties[] = [ placeholder: 'Add options', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], + resource: ['case'], + operation: ['create'], }, }, default: {}, @@ -345,9 +274,7 @@ export const caseFields: INodeProperties[] = [ }, displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, placeholder: 'Add Custom Field', @@ -360,7 +287,8 @@ export const caseFields: INodeProperties[] = [ displayName: 'Field Name or ID', name: 'field', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'loadCustomFields', }, @@ -384,9 +312,7 @@ export const caseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - '/jsonParameters': [ - true, - ], + '/jsonParameters': [true], }, }, description: 'Custom fields in JSON format. Overrides Custom Fields UI if set.', @@ -412,9 +338,7 @@ export const caseFields: INodeProperties[] = [ type: 'json', displayOptions: { show: { - '/jsonParameters': [ - true, - ], + '/jsonParameters': [true], }, }, description: 'List of metrics', @@ -429,12 +353,8 @@ export const caseFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'update', - ], + resource: ['case'], + operation: ['update'], }, }, default: {}, @@ -449,9 +369,7 @@ export const caseFields: INodeProperties[] = [ }, displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, placeholder: 'Add Custom Field', @@ -464,7 +382,8 @@ export const caseFields: INodeProperties[] = [ displayName: 'Field Name or ID', name: 'field', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'loadCustomFields', }, @@ -488,9 +407,7 @@ export const caseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - '/jsonParameters': [ - true, - ], + '/jsonParameters': [true], }, }, description: 'Custom fields in JSON format. Overrides Custom Fields UI if set.', @@ -545,9 +462,7 @@ export const caseFields: INodeProperties[] = [ default: '[]', displayOptions: { show: { - '/jsonParameters': [ - true, - ], + '/jsonParameters': [true], }, }, description: 'List of metrics', @@ -688,12 +603,8 @@ export const caseFields: INodeProperties[] = [ name: 'options', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'case', - ], + operation: ['getAll'], + resource: ['case'], }, }, type: 'collection', @@ -719,13 +630,8 @@ export const caseFields: INodeProperties[] = [ placeholder: 'Add a Filter', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'getAll', - 'count', - ], + resource: ['case'], + operation: ['getAll', 'count'], }, }, options: [ @@ -747,7 +653,8 @@ export const caseFields: INodeProperties[] = [ displayName: 'Field Name or ID', name: 'field', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'loadCustomFields', }, diff --git a/packages/nodes-base/nodes/TheHive/descriptions/LogDescription.ts b/packages/nodes-base/nodes/TheHive/descriptions/LogDescription.ts index af5ac47098..0af5a6f345 100644 --- a/packages/nodes-base/nodes/TheHive/descriptions/LogDescription.ts +++ b/packages/nodes-base/nodes/TheHive/descriptions/LogDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const logOperations: INodeProperties[] = [ { @@ -12,9 +10,7 @@ export const logOperations: INodeProperties[] = [ default: 'getAll', displayOptions: { show: { - resource: [ - 'log', - ], + resource: ['log'], }, }, options: [ @@ -55,13 +51,8 @@ export const logFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'log', - ], - operation: [ - 'create', - 'getAll', - ], + resource: ['log'], + operation: ['create', 'getAll'], }, }, description: 'ID of the task', @@ -72,12 +63,8 @@ export const logFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'log', - ], + operation: ['getAll'], + resource: ['log'], }, }, default: false, @@ -89,15 +76,9 @@ export const logFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'log', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['log'], + returnAll: [false], }, }, typeOptions: { @@ -116,13 +97,8 @@ export const logFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'log', - ], - operation: [ - 'executeResponder', - 'get', - ], + resource: ['log'], + operation: ['executeResponder', 'get'], }, }, }, @@ -134,12 +110,8 @@ export const logFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'log', - ], - operation: [ - 'create', - ], + resource: ['log'], + operation: ['create'], }, }, description: 'Content of the Log', @@ -152,12 +124,8 @@ export const logFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'log', - ], - operation: [ - 'create', - ], + resource: ['log'], + operation: ['create'], }, }, description: 'Date of the log submission default=now', @@ -180,12 +148,8 @@ export const logFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'log', - ], - operation: [ - 'create', - ], + resource: ['log'], + operation: ['create'], }, }, description: 'Status of the log (Ok or Deleted) default=Ok', @@ -195,28 +159,21 @@ export const logFields: INodeProperties[] = [ displayName: 'Responder Name or ID', name: 'responder', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, default: '', typeOptions: { - loadOptionsDependsOn: [ - 'id', - ], + loadOptionsDependsOn: ['id'], loadOptionsMethod: 'loadResponders', }, displayOptions: { show: { - resource: [ - 'log', - ], - operation: [ - 'executeResponder', - ], + resource: ['log'], + operation: ['executeResponder'], }, hide: { - id: [ - '', - ], + id: [''], }, }, }, @@ -228,12 +185,8 @@ export const logFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'log', - ], - operation: [ - 'create', - ], + resource: ['log'], + operation: ['create'], }, }, placeholder: 'Add Option', diff --git a/packages/nodes-base/nodes/TheHive/descriptions/ObservableDescription.ts b/packages/nodes-base/nodes/TheHive/descriptions/ObservableDescription.ts index 3dfb3218b6..aebf0dee2b 100644 --- a/packages/nodes-base/nodes/TheHive/descriptions/ObservableDescription.ts +++ b/packages/nodes-base/nodes/TheHive/descriptions/ObservableDescription.ts @@ -1,31 +1,24 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - TLP, -} from '../interfaces/AlertInterface'; +import { TLP } from '../interfaces/AlertInterface'; export const observableOperations: INodeProperties[] = [ { displayName: 'Operation Name or ID', name: 'operation', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', noDataExpression: true, required: true, default: 'getAll', displayOptions: { show: { - resource: [ - 'observable', - ], + resource: ['observable'], }, }, typeOptions: { - loadOptionsDependsOn: [ - 'resource', - ], + loadOptionsDependsOn: ['resource'], loadOptionsMethod: 'loadObservableOptions', }, }, @@ -40,13 +33,8 @@ export const observableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'create', - 'getAll', - ], + resource: ['observable'], + operation: ['create', 'getAll'], }, }, description: 'ID of the case', @@ -57,13 +45,8 @@ export const observableFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - 'search', - ], - resource: [ - 'observable', - ], + operation: ['getAll', 'search'], + resource: ['observable'], }, }, default: false, @@ -75,16 +58,9 @@ export const observableFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - 'search', - ], - resource: [ - 'observable', - ], - returnAll: [ - false, - ], + operation: ['getAll', 'search'], + resource: ['observable'], + returnAll: [false], }, }, typeOptions: { @@ -103,15 +79,8 @@ export const observableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'update', - 'executeResponder', - 'executeAnalyzer', - 'get', - ], + resource: ['observable'], + operation: ['update', 'executeResponder', 'executeAnalyzer', 'get'], }, }, description: 'ID of the observable', @@ -127,16 +96,12 @@ export const observableFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'create', - 'executeAnalyzer', - ], + resource: ['observable'], + operation: ['create', 'executeAnalyzer'], }, }, - description: 'Type of the observable. Choose from the list, or specify an ID using an expression.', + description: + 'Type of the observable. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Data', @@ -146,17 +111,11 @@ export const observableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'create', - ], + resource: ['observable'], + operation: ['create'], }, hide: { - dataType: [ - 'file', - ], + dataType: ['file'], }, }, }, @@ -169,15 +128,9 @@ export const observableFields: INodeProperties[] = [ description: 'Binary Property that represent the attachment file', displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'create', - ], - dataType: [ - 'file', - ], + resource: ['observable'], + operation: ['create'], + dataType: ['file'], }, }, }, @@ -189,12 +142,8 @@ export const observableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'create', - ], + resource: ['observable'], + operation: ['create'], }, }, description: 'Description of the observable in the context of the case', @@ -207,12 +156,8 @@ export const observableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'create', - ], + resource: ['observable'], + operation: ['create'], }, }, description: 'Date and time of the begin of the case default=now', @@ -225,12 +170,8 @@ export const observableFields: INodeProperties[] = [ default: 2, displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'create', - ], + resource: ['observable'], + operation: ['create'], }, }, options: [ @@ -261,12 +202,8 @@ export const observableFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'create', - ], + resource: ['observable'], + operation: ['create'], }, }, description: 'Whether the observable is an IOC (Indicator of compromise)', @@ -279,12 +216,8 @@ export const observableFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'create', - ], + resource: ['observable'], + operation: ['create'], }, }, description: 'Whether sighted previously', @@ -307,12 +240,8 @@ export const observableFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'create', - ], + resource: ['observable'], + operation: ['create'], }, }, description: 'Status of the observable. Default=Ok.', @@ -322,29 +251,21 @@ export const observableFields: INodeProperties[] = [ displayName: 'Analyzer Names or IDs', name: 'analyzers', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', required: true, default: [], typeOptions: { - loadOptionsDependsOn: [ - 'id', - 'dataType', - ], + loadOptionsDependsOn: ['id', 'dataType'], loadOptionsMethod: 'loadAnalyzers', }, displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'executeAnalyzer', - ], + resource: ['observable'], + operation: ['executeAnalyzer'], }, hide: { - id: [ - '', - ], + id: [''], }, }, }, @@ -354,28 +275,21 @@ export const observableFields: INodeProperties[] = [ displayName: 'Responder Name or ID', name: 'responder', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, default: '', typeOptions: { - loadOptionsDependsOn: [ - 'id', - ], + loadOptionsDependsOn: ['id'], loadOptionsMethod: 'loadResponders', }, displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'executeResponder', - ], + resource: ['observable'], + operation: ['executeResponder'], }, hide: { - id: [ - '', - ], + id: [''], }, }, }, @@ -388,12 +302,8 @@ export const observableFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'create', - ], + resource: ['observable'], + operation: ['create'], }, }, options: [ @@ -414,12 +324,8 @@ export const observableFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'update', - ], + resource: ['observable'], + operation: ['update'], }, }, options: [ @@ -429,7 +335,6 @@ export const observableFields: INodeProperties[] = [ type: 'string', default: '', description: 'Description of the observable in the context of the case', - }, { displayName: 'Observable Tags', @@ -502,13 +407,8 @@ export const observableFields: INodeProperties[] = [ name: 'options', displayOptions: { show: { - operation: [ - 'getAll', - 'search', - ], - resource: [ - 'observable', - ], + operation: ['getAll', 'search'], + resource: ['observable'], }, }, type: 'collection', @@ -534,13 +434,8 @@ export const observableFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'observable', - ], - operation: [ - 'search', - 'count', - ], + resource: ['observable'], + operation: ['search', 'count'], }, }, options: [ @@ -552,7 +447,8 @@ export const observableFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'loadObservableTypes', }, - description: 'Type of the observable. Choose from the list, or specify IDs using an expression.', + description: + 'Type of the observable. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Date Range', diff --git a/packages/nodes-base/nodes/TheHive/descriptions/TaskDescription.ts b/packages/nodes-base/nodes/TheHive/descriptions/TaskDescription.ts index 596c64636a..fa2881c33b 100644 --- a/packages/nodes-base/nodes/TheHive/descriptions/TaskDescription.ts +++ b/packages/nodes-base/nodes/TheHive/descriptions/TaskDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const taskOperations: INodeProperties[] = [ { @@ -8,20 +6,17 @@ export const taskOperations: INodeProperties[] = [ name: 'operation', default: 'getAll', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', noDataExpression: true, required: true, displayOptions: { show: { - resource: [ - 'task', - ], + resource: ['task'], }, }, typeOptions: { - loadOptionsDependsOn: [ - 'operation', - ], + loadOptionsDependsOn: ['operation'], loadOptionsMethod: 'loadTaskOptions', }, }, @@ -36,14 +31,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - 'executeResponder', - 'get', - ], + resource: ['task'], + operation: ['update', 'executeResponder', 'get'], }, }, description: 'ID of the taks', @@ -56,13 +45,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - 'getAll', - ], + resource: ['task'], + operation: ['create', 'getAll'], }, }, }, @@ -72,13 +56,8 @@ export const taskFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'search', - 'getAll', - ], - resource: [ - 'task', - ], + operation: ['search', 'getAll'], + resource: ['task'], }, }, default: false, @@ -90,16 +69,9 @@ export const taskFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'search', - 'getAll', - ], - resource: [ - 'task', - ], - returnAll: [ - false, - ], + operation: ['search', 'getAll'], + resource: ['task'], + returnAll: [false], }, }, typeOptions: { @@ -117,12 +89,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, description: 'Task details', @@ -153,12 +121,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, description: 'Status of the task. Default=Waiting.', @@ -171,12 +135,8 @@ export const taskFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, description: 'Whether to flag the task. Default=false.', @@ -186,28 +146,21 @@ export const taskFields: INodeProperties[] = [ displayName: 'Responder Name or ID', name: 'responder', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, default: '', typeOptions: { - loadOptionsDependsOn: [ - 'id', - ], + loadOptionsDependsOn: ['id'], loadOptionsMethod: 'loadResponders', }, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'executeResponder', - ], + resource: ['task'], + operation: ['executeResponder'], }, hide: { - id: [ - '', - ], + id: [''], }, }, }, @@ -220,12 +173,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, options: [ @@ -241,21 +190,24 @@ export const taskFields: INodeProperties[] = [ name: 'endDate', type: 'dateTime', default: '', - description: 'Date of the end of the task. This is automatically set when status is set to Completed.', + description: + 'Date of the end of the task. This is automatically set when status is set to Completed.', }, { displayName: 'Owner', name: 'owner', type: 'string', default: '', - description: 'User who owns the task. This is automatically set to current user when status is set to InProgress.', + description: + 'User who owns the task. This is automatically set to current user when status is set to InProgress.', }, { displayName: 'Start Date', name: 'startDate', type: 'dateTime', default: '', - description: 'Date of the beginning of the task. This is automatically set when status is set to Open.', + description: + 'Date of the beginning of the task. This is automatically set when status is set to Open.', }, ], }, @@ -269,12 +221,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, options: [ @@ -290,7 +238,8 @@ export const taskFields: INodeProperties[] = [ name: 'endDate', type: 'dateTime', default: '', - description: 'Date of the end of the task. This is automatically set when status is set to Completed.', + description: + 'Date of the end of the task. This is automatically set when status is set to Completed.', }, { displayName: 'Flag', @@ -304,14 +253,16 @@ export const taskFields: INodeProperties[] = [ name: 'owner', type: 'string', default: '', - description: 'User who owns the task. This is automatically set to current user when status is set to InProgress.', + description: + 'User who owns the task. This is automatically set to current user when status is set to InProgress.', }, { displayName: 'Start Date', name: 'startDate', type: 'dateTime', default: '', - description: 'Date of the beginning of the task. This is automatically set when status is set to Open.', + description: + 'Date of the beginning of the task. This is automatically set when status is set to Open.', }, { displayName: 'Status', @@ -357,13 +308,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - 'search', - ], - resource: [ - 'task', - ], + operation: ['getAll', 'search'], + resource: ['task'], }, }, options: [ @@ -386,13 +332,8 @@ export const taskFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'search', - 'count', - ], + resource: ['task'], + operation: ['search', 'count'], }, }, options: [ @@ -408,7 +349,8 @@ export const taskFields: INodeProperties[] = [ name: 'endDate', type: 'dateTime', default: '', - description: 'Date of the end of the task. This is automatically set when status is set to Completed.', + description: + 'Date of the end of the task. This is automatically set when status is set to Completed.', }, { displayName: 'Flag', @@ -422,14 +364,16 @@ export const taskFields: INodeProperties[] = [ name: 'owner', type: 'string', default: '', - description: 'User who owns the task. This is automatically set to current user when status is set to InProgress.', + description: + 'User who owns the task. This is automatically set to current user when status is set to InProgress.', }, { displayName: 'Start Date', name: 'startDate', type: 'dateTime', default: '', - description: 'Date of the beginning of the task. This is automatically set when status is set to Open.', + description: + 'Date of the beginning of the task. This is automatically set when status is set to Open.', }, { displayName: 'Status', diff --git a/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts index 8b3b9ec714..d6602e3ad5 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/AlertInterface.ts @@ -1,6 +1,4 @@ -import { - IDataObject, -} from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export enum AlertStatus { NEW = 'New', UPDATED = 'Updated', diff --git a/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts index 9aae200d9f..51b72af5e4 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/CaseInterface.ts @@ -31,7 +31,6 @@ export interface ICase { upadtedAt?: Date; } - export enum CaseStatus { OPEN = 'Open', RESOLVED = 'Resolved', diff --git a/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts b/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts index 9aedfe7f62..89f540e25b 100644 --- a/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts +++ b/packages/nodes-base/nodes/TheHive/interfaces/ObservableInterface.ts @@ -1,6 +1,4 @@ -import { - TLP -} from './AlertInterface'; +import { TLP } from './AlertInterface'; export enum ObservableStatus { OK = 'Ok', diff --git a/packages/nodes-base/nodes/TimescaleDb/TimescaleDb.node.ts b/packages/nodes-base/nodes/TimescaleDb/TimescaleDb.node.ts index c872eb241e..0ea2949fee 100644 --- a/packages/nodes-base/nodes/TimescaleDb/TimescaleDb.node.ts +++ b/packages/nodes-base/nodes/TimescaleDb/TimescaleDb.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,11 +8,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - pgInsert, - pgQuery, - pgUpdate, -} from '../Postgres/Postgres.node.functions'; +import { pgInsert, pgQuery, pgUpdate } from '../Postgres/Postgres.node.functions'; import pgPromise from 'pg-promise'; @@ -84,7 +78,8 @@ export class TimescaleDb implements INodeType { default: '', placeholder: 'SELECT id, name FROM product WHERE quantity > $1 AND price <= $2', required: true, - description: 'The SQL query to execute. You can use n8n expressions or $1 and $2 in conjunction with query parameters.', + description: + 'The SQL query to execute. You can use n8n expressions or $1 and $2 in conjunction with query parameters.', }, // ---------------------------------- @@ -96,9 +91,7 @@ export class TimescaleDb implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'insert', - ], + operation: ['insert'], }, }, default: 'public', @@ -111,9 +104,7 @@ export class TimescaleDb implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'insert', - ], + operation: ['insert'], }, }, default: '', @@ -126,14 +117,13 @@ export class TimescaleDb implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'insert', - ], + operation: ['insert'], }, }, default: '', placeholder: 'id,name,description', - description: 'Comma-separated list of the properties which should used as columns for the new rows', + description: + 'Comma-separated list of the properties which should used as columns for the new rows', }, // ---------------------------------- @@ -145,9 +135,7 @@ export class TimescaleDb implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: 'public', @@ -160,9 +148,7 @@ export class TimescaleDb implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: '', @@ -175,15 +161,14 @@ export class TimescaleDb implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: 'id', required: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id - description: 'Name of the property which decides which rows in the database should be updated. Normally that would be "id".', + description: + 'Name of the property which decides which rows in the database should be updated. Normally that would be "id".', }, { displayName: 'Columns', @@ -191,14 +176,13 @@ export class TimescaleDb implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: '', placeholder: 'name,description', - description: 'Comma-separated list of the properties which should used as columns for rows to update', + description: + 'Comma-separated list of the properties which should used as columns for rows to update', }, // ---------------------------------- // insert,update @@ -247,7 +231,8 @@ export class TimescaleDb implements INodeType { }, ], default: 'multiple', - description: 'The way queries should be sent to database. Can be used in conjunction with Continue on Fail. See the docs for more examples', + description: + 'The way queries should be sent to database. Can be used in conjunction with Continue on Fail. See the docs for more examples', }, { displayName: 'Query Parameters', @@ -255,14 +240,13 @@ export class TimescaleDb implements INodeType { type: 'string', displayOptions: { show: { - '/operation': [ - 'executeQuery', - ], + '/operation': ['executeQuery'], }, }, default: '', placeholder: 'quantity,price', - description: 'Comma-separated list of properties which should be used as query parameters', + description: + 'Comma-separated list of properties which should be used as query parameters', }, ], }, @@ -296,7 +280,13 @@ export class TimescaleDb implements INodeType { // executeQuery // ---------------------------------- - const queryResult = await pgQuery(this.getNodeParameter, pgp, db, items, this.continueOnFail()); + const queryResult = await pgQuery( + this.getNodeParameter, + pgp, + db, + items, + this.continueOnFail(), + ); returnItems = this.helpers.returnJsonArray(queryResult); } else if (operation === 'insert') { @@ -304,7 +294,13 @@ export class TimescaleDb implements INodeType { // insert // ---------------------------------- - const insertData = await pgInsert(this.getNodeParameter, pgp, db, items, this.continueOnFail()); + const insertData = await pgInsert( + this.getNodeParameter, + pgp, + db, + items, + this.continueOnFail(), + ); // Add the id to the data for (let i = 0; i < insertData.length; i++) { @@ -317,13 +313,21 @@ export class TimescaleDb implements INodeType { // update // ---------------------------------- - const updateItems = await pgUpdate(this.getNodeParameter, pgp, db, items, this.continueOnFail()); + const updateItems = await pgUpdate( + this.getNodeParameter, + pgp, + db, + items, + this.continueOnFail(), + ); returnItems = this.helpers.returnJsonArray(updateItems); - } else { await pgp.end(); - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not supported!`); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not supported!`, + ); } // Close the connection diff --git a/packages/nodes-base/nodes/Todoist/GenericFunctions.ts b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts index a74d8bb6f3..abd9353cfb 100644 --- a/packages/nodes-base/nodes/Todoist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts @@ -1,16 +1,8 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; export type Context = IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions; @@ -24,9 +16,11 @@ export async function todoistApiRequest( this: Context, method: string, resource: string, + // tslint:disable-next-line:no-any body: any = {}, // tslint:disable-line:no-any qs: IDataObject = {}, -): Promise { // tslint:disable-line:no-any + // tslint:disable-next-line:no-any +): Promise { const authentication = this.getNodeParameter('authentication', 0) as string; const endpoint = 'api.todoist.com/rest/v1'; @@ -45,9 +39,8 @@ export async function todoistApiRequest( try { const credentialType = authentication === 'apiKey' ? 'todoistApi' : 'todoistOAuth2Api'; return await this.helpers.requestWithAuthentication.call(this, credentialType, options); - } catch (error) { - throw new NodeApiError(this.getNode(), (error)); + throw new NodeApiError(this.getNode(), error); } } @@ -55,7 +48,8 @@ export async function todoistSyncRequest( this: Context, body: any = {}, // tslint:disable-line:no-any qs: IDataObject = {}, -): Promise { // tslint:disable-line:no-any + // tslint:disable-next-line:no-any +): Promise { const authentication = this.getNodeParameter('authentication', 0, 'oAuth2'); const options: OptionsWithUri = { @@ -73,8 +67,7 @@ export async function todoistSyncRequest( try { const credentialType = authentication === 'oAuth2' ? 'todoistOAuth2Api' : 'todoistApi'; return await this.helpers.requestWithAuthentication.call(this, credentialType, options); - } catch (error) { - throw new NodeApiError(this.getNode(), (error)); + throw new NodeApiError(this.getNode(), error); } } diff --git a/packages/nodes-base/nodes/Todoist/OperationHandler.ts b/packages/nodes-base/nodes/Todoist/OperationHandler.ts index eda191aba7..206e704ea8 100644 --- a/packages/nodes-base/nodes/Todoist/OperationHandler.ts +++ b/packages/nodes-base/nodes/Todoist/OperationHandler.ts @@ -1,14 +1,18 @@ -import {IDataObject} from 'n8n-workflow'; -import {Context, FormatDueDatetime, todoistApiRequest, todoistSyncRequest} from './GenericFunctions'; -import {Section, TodoistResponse} from './Service'; -import {v4 as uuid} from 'uuid'; +import { IDataObject } from 'n8n-workflow'; +import { + Context, + FormatDueDatetime, + todoistApiRequest, + todoistSyncRequest, +} from './GenericFunctions'; +import { Section, TodoistResponse } from './Service'; +import { v4 as uuid } from 'uuid'; export interface OperationHandler { handleOperation(ctx: Context, itemIndex: number): Promise; } export class CreateHandler implements OperationHandler { - async handleOperation(ctx: Context, itemIndex: number): Promise { //https://developer.todoist.com/rest/v1/#create-a-new-task const content = ctx.getNodeParameter('content', itemIndex) as string; @@ -19,7 +23,7 @@ export class CreateHandler implements OperationHandler { const body: CreateTaskRequest = { content, project_id: projectId, - priority: (options.priority!) ? parseInt(options.priority as string, 10) : 1, + priority: options.priority! ? parseInt(options.priority as string, 10) : 1, }; if (options.description) { @@ -52,7 +56,6 @@ export class CreateHandler implements OperationHandler { data, }; } - } export class CloseHandler implements OperationHandler { @@ -127,8 +130,14 @@ export class GetAllHandler implements OperationHandler { } async function getSectionIds(ctx: Context, projectId: number): Promise> { - const sections: Section[] = await todoistApiRequest.call(ctx, 'GET', '/sections', {}, {project_id: projectId}); - return new Map(sections.map(s => [s.name, s.id as unknown as number])); + const sections: Section[] = await todoistApiRequest.call( + ctx, + 'GET', + '/sections', + {}, + { project_id: projectId }, + ); + return new Map(sections.map((s) => [s.name, s.id as unknown as number])); } export class ReopenHandler implements OperationHandler { @@ -171,9 +180,11 @@ export class UpdateHandler implements OperationHandler { body.due_string = updateFields.dueString as string; } - if (updateFields.labels !== undefined && + if ( + updateFields.labels !== undefined && Array.isArray(updateFields.labels) && - updateFields.labels.length !== 0) { + updateFields.labels.length !== 0 + ) { body.label_ids = updateFields.labels as number[]; } @@ -183,7 +194,7 @@ export class UpdateHandler implements OperationHandler { await todoistApiRequest.call(ctx, 'POST', `/tasks/${id}`, body); - return {success: true}; + return { success: true }; } } @@ -208,7 +219,7 @@ export class MoveHandler implements OperationHandler { await todoistSyncRequest.call(ctx, body); - return {success: true}; + return { success: true }; } } @@ -218,14 +229,14 @@ export class SyncHandler implements OperationHandler { const projectId = ctx.getNodeParameter('project', itemIndex) as number; const sections = await getSectionIds(ctx, projectId); const commands: Command[] = JSON.parse(commandsJson); - const tempIdMapping = new Map(); + const tempIdMapping = new Map(); for (let i = 0; i < commands.length; i++) { const command = commands[i]; this.enrichUUID(command); this.enrichSection(command, sections); this.enrichProjectId(command, projectId); - this.enrichTempId(command,tempIdMapping, projectId); + this.enrichTempId(command, tempIdMapping, projectId); } const body: SyncRequest = { @@ -235,7 +246,7 @@ export class SyncHandler implements OperationHandler { await todoistSyncRequest.call(ctx, body); - return {success: true}; + return { success: true }; } private convertToObject(map: Map) { @@ -251,12 +262,12 @@ export class SyncHandler implements OperationHandler { } private enrichSection(command: Command, sections: Map) { - if (command.args!==undefined && command.args.section !== undefined) { + if (command.args !== undefined && command.args.section !== undefined) { const sectionId = sections.get(command.args.section); if (sectionId) { command.args.section_id = sectionId; } else { - throw new Error('Section ' + command.args.section + ' doesn\'t exist on Todoist'); + throw new Error('Section ' + command.args.section + " doesn't exist on Todoist"); } } } @@ -271,7 +282,7 @@ export class SyncHandler implements OperationHandler { return command.type === CommandType.ITEM_ADD; } - private enrichTempId(command: Command, tempIdMapping: Map, projectId: number) { + private enrichTempId(command: Command, tempIdMapping: Map, projectId: number) { if (this.requiresTempId(command)) { command.temp_id = uuid() as string; tempIdMapping.set(command.temp_id, projectId as unknown as string); @@ -308,11 +319,11 @@ export interface Command { uuid: string; temp_id?: string; args: { - id?: number - section_id?: number - project_id?: number | string - section?: string, - content?: string + id?: number; + section_id?: number; + project_id?: number | string; + section?: string; + content?: string; }; } diff --git a/packages/nodes-base/nodes/Todoist/Service.ts b/packages/nodes-base/nodes/Todoist/Service.ts index 078ae92444..5b248b7415 100644 --- a/packages/nodes-base/nodes/Todoist/Service.ts +++ b/packages/nodes-base/nodes/Todoist/Service.ts @@ -7,30 +7,32 @@ import { MoveHandler, ReopenHandler, SyncHandler, - UpdateHandler + UpdateHandler, } from './OperationHandler'; -import {Context} from './GenericFunctions'; +import { Context } from './GenericFunctions'; import { IDataObject } from 'n8n-workflow'; export class TodoistService implements Service { - - async execute(ctx: Context, operation: OperationType, itemIndex: number): Promise { + async execute( + ctx: Context, + operation: OperationType, + itemIndex: number, + ): Promise { return this.handlers[operation].handleOperation(ctx, itemIndex); } private handlers = { - 'create': new CreateHandler(), - 'close': new CloseHandler(), - 'delete': new DeleteHandler(), - 'get': new GetHandler(), - 'getAll': new GetAllHandler(), - 'reopen': new ReopenHandler(), - 'update': new UpdateHandler(), - 'move': new MoveHandler(), - 'sync': new SyncHandler(), + create: new CreateHandler(), + close: new CloseHandler(), + delete: new DeleteHandler(), + get: new GetHandler(), + getAll: new GetAllHandler(), + reopen: new ReopenHandler(), + update: new UpdateHandler(), + move: new MoveHandler(), + sync: new SyncHandler(), }; - } export enum OperationType { diff --git a/packages/nodes-base/nodes/Todoist/Todoist.node.ts b/packages/nodes-base/nodes/Todoist/Todoist.node.ts index f51c89f2f0..812a085c7d 100644 --- a/packages/nodes-base/nodes/Todoist/Todoist.node.ts +++ b/packages/nodes-base/nodes/Todoist/Todoist.node.ts @@ -1,5 +1,5 @@ import { response } from 'express'; -import {IExecuteFunctions,} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,9 +10,9 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import {todoistApiRequest,} from './GenericFunctions'; +import { todoistApiRequest } from './GenericFunctions'; -import {OperationType, TodoistService} from './Service'; +import { OperationType, TodoistService } from './Service'; interface IBodyCreateTask { content?: string; description?: string; @@ -29,7 +29,6 @@ interface IBodyCreateTask { } export class Todoist implements INodeType { - description: INodeTypeDescription = { displayName: 'Todoist', name: 'todoist', @@ -49,9 +48,7 @@ export class Todoist implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'apiKey', - ], + authentication: ['apiKey'], }, }, }, @@ -60,9 +57,7 @@ export class Todoist implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -107,9 +102,7 @@ export class Todoist implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'task', - ], + resource: ['task'], }, }, options: [ @@ -177,17 +170,8 @@ export class Todoist implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'delete', - 'close', - 'get', - 'reopen', - 'update', - 'move', - ], + resource: ['task'], + operation: ['delete', 'close', 'get', 'reopen', 'update', 'move'], }, }, }, @@ -200,18 +184,13 @@ export class Todoist implements INodeType { }, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - 'move', - 'sync', - ], + resource: ['task'], + operation: ['create', 'move', 'sync'], }, }, default: '', - description: 'The project you want to operate on. Choose from the list, or specify an ID using an expression.', + description: + 'The project you want to operate on. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Section Name or ID', @@ -223,16 +202,13 @@ export class Todoist implements INodeType { }, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'move', - ], + resource: ['task'], + operation: ['move'], }, }, default: '', - description: 'Section to which you want move the task. Choose from the list, or specify an ID using an expression.', + description: + 'Section to which you want move the task. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Label Names or IDs', @@ -243,16 +219,13 @@ export class Todoist implements INodeType { }, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, default: [], - description: 'Optional labels that will be assigned to a created task. Choose from the list, or specify IDs using an expression.', + description: + 'Optional labels that will be assigned to a created task. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Content', @@ -263,12 +236,8 @@ export class Todoist implements INodeType { }, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, default: '', @@ -281,12 +250,8 @@ export class Todoist implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'sync', - ], + resource: ['task'], + operation: ['sync'], }, }, default: '[]', @@ -301,12 +266,8 @@ export class Todoist implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, options: [ @@ -329,14 +290,16 @@ export class Todoist implements INodeType { name: 'dueLang', type: 'string', default: '', - description: '2-letter code specifying language in case due_string is not written in English', + description: + '2-letter code specifying language in case due_string is not written in English', }, { displayName: 'Due String', name: 'dueString', type: 'string', default: '', - description: 'Human defined task due date (ex.: “next Monday”, “Tomorrow”). Value is set using local (not UTC) time.', + description: + 'Human defined task due date (ex.: “next Monday”, “Tomorrow”). Value is set using local (not UTC) time.', }, { displayName: 'Parent Name or ID', @@ -344,13 +307,11 @@ export class Todoist implements INodeType { type: 'options', typeOptions: { loadOptionsMethod: 'getItems', - loadOptionsDependsOn: [ - 'project', - 'options.section', - ], + loadOptionsDependsOn: ['project', 'options.section'], }, default: {}, - description: 'The parent task you want to operate on. Choose from the list, or specify an ID using an expression.', + description: + 'The parent task you want to operate on. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Priority', @@ -369,12 +330,11 @@ export class Todoist implements INodeType { type: 'options', typeOptions: { loadOptionsMethod: 'getSections', - loadOptionsDependsOn: [ - 'project', - ], + loadOptionsDependsOn: ['project'], }, default: {}, - description: 'The section you want to operate on. Choose from the list, or specify an ID using an expression.', + description: + 'The section you want to operate on. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -384,12 +344,8 @@ export class Todoist implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], + operation: ['getAll'], + resource: ['task'], }, }, default: false, @@ -401,15 +357,9 @@ export class Todoist implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['task'], + returnAll: [false], }, }, typeOptions: { @@ -427,12 +377,8 @@ export class Todoist implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, options: [ @@ -441,14 +387,16 @@ export class Todoist implements INodeType { name: 'filter', type: 'string', default: '', - description: 'Filter by any supported filter.', + description: + 'Filter by any supported filter.', }, { displayName: 'IDs', name: 'ids', type: 'string', default: '', - description: 'A list of the task IDs to retrieve, this should be a comma-separated list', + description: + 'A list of the task IDs to retrieve, this should be a comma-separated list', }, { displayName: 'Label Name or ID', @@ -458,14 +406,16 @@ export class Todoist implements INodeType { loadOptionsMethod: 'getLabels', }, default: {}, - description: 'Filter tasks by label. Choose from the list, or specify an ID using an expression.', + description: + 'Filter tasks by label. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Lang', name: 'lang', type: 'string', default: '', - description: 'IETF language tag defining what language filter is written in, if differs from default English', + description: + 'IETF language tag defining what language filter is written in, if differs from default English', }, { displayName: 'Parent Name or ID', @@ -473,13 +423,11 @@ export class Todoist implements INodeType { type: 'options', typeOptions: { loadOptionsMethod: 'getItems', - loadOptionsDependsOn: [ - 'filters.projectId', - 'filters.sectionId', - ], + loadOptionsDependsOn: ['filters.projectId', 'filters.sectionId'], }, default: '', - description: 'Filter tasks by parent task ID. Choose from the list, or specify an ID using an expression.', + description: + 'Filter tasks by parent task ID. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Project Name or ID', @@ -489,7 +437,8 @@ export class Todoist implements INodeType { loadOptionsMethod: 'getProjects', }, default: '', - description: 'Filter tasks by project ID. Choose from the list, or specify an ID using an expression.', + description: + 'Filter tasks by project ID. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Section Name or ID', @@ -497,12 +446,11 @@ export class Todoist implements INodeType { type: 'options', typeOptions: { loadOptionsMethod: 'getSections', - loadOptionsDependsOn: [ - 'filters.projectId', - ], + loadOptionsDependsOn: ['filters.projectId'], }, default: '', - description: 'Filter tasks by section ID. Choose from the list, or specify an ID using an expression.', + description: + 'Filter tasks by section ID. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -514,12 +462,8 @@ export class Todoist implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, options: [ @@ -549,27 +493,31 @@ export class Todoist implements INodeType { name: 'dueLang', type: 'string', default: '', - description: '2-letter code specifying language in case due_string is not written in English', + description: + '2-letter code specifying language in case due_string is not written in English', }, { displayName: 'Due String', name: 'dueString', type: 'string', default: '', - description: 'Human defined task due date (ex.: “next Monday”, “Tomorrow”). Value is set using local (not UTC) time.', + description: + 'Human defined task due date (ex.: “next Monday”, “Tomorrow”). Value is set using local (not UTC) time.', }, { displayName: 'Due String Locale', name: 'dueLang', type: 'string', default: '', - description: '2-letter code specifying language in case due_string is not written in English', + description: + '2-letter code specifying language in case due_string is not written in English', }, { displayName: 'Label Names or IDs', name: 'labels', type: 'multiOptions', - description: 'Choose from the list, or specify IDs using an expression', + description: + 'Choose from the list, or specify IDs using an expression', typeOptions: { loadOptionsMethod: 'getLabels', }, @@ -616,15 +564,16 @@ export class Todoist implements INodeType { async getSections(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const options = Object.assign({}, + const options = Object.assign( + {}, this.getNodeParameter('options', {}), this.getNodeParameter('filters', {}), - ) as IDataObject; + ) as IDataObject; - const projectId = options.projectId as number ?? - this.getCurrentNodeParameter('project') as number; + const projectId = + (options.projectId as number) ?? (this.getCurrentNodeParameter('project') as number); if (projectId) { - const qs: IDataObject = {project_id: projectId}; + const qs: IDataObject = { project_id: projectId }; const sections = await todoistApiRequest.call(this, 'GET', '/sections', {}, qs); for (const section of sections) { const sectionName = section.name; @@ -645,20 +594,24 @@ export class Todoist implements INodeType { async getItems(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const options = Object.assign({}, + const options = Object.assign( + {}, this.getNodeParameter('options', {}), this.getNodeParameter('filters', {}), - ) as IDataObject; + ) as IDataObject; - const projectId = options.projectId as number ?? - this.getCurrentNodeParameter('project') as number; + const projectId = + (options.projectId as number) ?? (this.getCurrentNodeParameter('project') as number); - const sectionId = options.sectionId as number || options.section as number || - this.getCurrentNodeParameter('sectionId') as number; + const sectionId = + (options.sectionId as number) || + (options.section as number) || + (this.getCurrentNodeParameter('sectionId') as number); if (projectId) { - const qs: IDataObject = sectionId ? - {project_id: projectId, section_id: sectionId} : {project_id: projectId}; + const qs: IDataObject = sectionId + ? { project_id: projectId, section_id: sectionId } + : { project_id: projectId }; const items = await todoistApiRequest.call(this, 'GET', '/tasks', {}, qs); for (const item of items) { @@ -707,7 +660,11 @@ export class Todoist implements INodeType { for (let i = 0; i < length; i++) { try { if (resource === 'task') { - responseData = (await service.execute(this, OperationType[operation as keyof typeof OperationType], i)); + responseData = await service.execute( + this, + OperationType[operation as keyof typeof OperationType], + i, + ); } if (Array.isArray(responseData?.data)) { returnData.push.apply(returnData, responseData?.data as IDataObject[]); diff --git a/packages/nodes-base/nodes/Toggl/GenericFunctions.ts b/packages/nodes-base/nodes/Toggl/GenericFunctions.ts index 56bdeeb181..5b0c7c928c 100644 --- a/packages/nodes-base/nodes/Toggl/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Toggl/GenericFunctions.ts @@ -9,14 +9,33 @@ import { ITriggerFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function togglApiRequest(this: ITriggerFunctions | IPollFunctions | IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query?: IDataObject, uri?: string): Promise { // tslint:disable-line:no-any +export async function togglApiRequest( + this: + | ITriggerFunctions + | IPollFunctions + | IHookFunctions + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query?: IDataObject, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('togglApi'); - const headerWithAuthentication = Object.assign({}, - { Authorization: ` Basic ${Buffer.from(`${credentials.username}:${credentials.password}`).toString('base64')}` }); + const headerWithAuthentication = Object.assign( + {}, + { + Authorization: ` Basic ${Buffer.from( + `${credentials.username}:${credentials.password}`, + ).toString('base64')}`, + }, + ); const options: OptionsWithUri = { headers: headerWithAuthentication, diff --git a/packages/nodes-base/nodes/Toggl/TogglTrigger.node.ts b/packages/nodes-base/nodes/Toggl/TogglTrigger.node.ts index 08d37a795b..b1eeab8b00 100644 --- a/packages/nodes-base/nodes/Toggl/TogglTrigger.node.ts +++ b/packages/nodes-base/nodes/Toggl/TogglTrigger.node.ts @@ -77,5 +77,4 @@ export class TogglTrigger implements INodeType { return null; } - } diff --git a/packages/nodes-base/nodes/TravisCi/BuildDescription.ts b/packages/nodes-base/nodes/TravisCi/BuildDescription.ts index e8c08633a0..2f4a208c97 100644 --- a/packages/nodes-base/nodes/TravisCi/BuildDescription.ts +++ b/packages/nodes-base/nodes/TravisCi/BuildDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const buildOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const buildOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'build', - ], + resource: ['build'], }, }, options: [ @@ -52,7 +48,6 @@ export const buildOperations: INodeProperties[] = [ ]; export const buildFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* build:cancel */ /* -------------------------------------------------------------------------- */ @@ -62,12 +57,8 @@ export const buildFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'cancel', - ], - resource: [ - 'build', - ], + operation: ['cancel'], + resource: ['build'], }, }, default: '', @@ -83,12 +74,8 @@ export const buildFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'build', - ], + operation: ['get'], + resource: ['build'], }, }, default: '', @@ -102,12 +89,8 @@ export const buildFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'build', - ], - operation: [ - 'get', - ], + resource: ['build'], + operation: ['get'], }, }, options: [ @@ -131,12 +114,8 @@ export const buildFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'build', - ], + operation: ['getAll'], + resource: ['build'], }, }, default: false, @@ -148,15 +127,9 @@ export const buildFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'build', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['build'], + returnAll: [false], }, }, typeOptions: { @@ -174,12 +147,8 @@ export const buildFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'build', - ], - operation: [ - 'getAll', - ], + resource: ['build'], + operation: ['getAll'], }, }, options: [ @@ -248,12 +217,8 @@ export const buildFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'restart', - ], - resource: [ - 'build', - ], + operation: ['restart'], + resource: ['build'], }, }, default: '', @@ -269,12 +234,8 @@ export const buildFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'trigger', - ], - resource: [ - 'build', - ], + operation: ['trigger'], + resource: ['build'], }, }, placeholder: 'n8n-io/n8n', @@ -287,12 +248,8 @@ export const buildFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'trigger', - ], - resource: [ - 'build', - ], + operation: ['trigger'], + resource: ['build'], }, }, default: '', @@ -307,12 +264,8 @@ export const buildFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'build', - ], - operation: [ - 'trigger', - ], + resource: ['build'], + operation: ['trigger'], }, }, options: [ diff --git a/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts b/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts index dbc4146bfb..eef2d2c019 100644 --- a/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,24 +7,30 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - get, -} from 'lodash'; +import { get } from 'lodash'; import querystring from 'querystring'; -export async function travisciApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function travisciApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('travisCiApi'); let options: OptionsWithUri = { headers: { 'Travis-API-Version': '3', - 'Accept': 'application/json', + Accept: 'application/json', 'Content-Type': 'application.json', - 'Authorization': `token ${credentials.apiToken}`, + Authorization: `token ${credentials.apiToken}`, }, method, qs, @@ -49,8 +53,16 @@ export async function travisciApiRequest(this: IHookFunctions | IExecuteFunction * Make an API request to paginated TravisCI endpoint * and return all results */ -export async function travisciApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function travisciApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -62,8 +74,6 @@ export async function travisciApiRequestAllItems(this: IHookFunctions | IExecute query = querystring.parse(path); } returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData['@pagination']['is_last'] !== true - ); + } while (responseData['@pagination']['is_last'] !== true); return returnData; } diff --git a/packages/nodes-base/nodes/TravisCi/TravisCi.node.ts b/packages/nodes-base/nodes/TravisCi/TravisCi.node.ts index c03199b68b..d800f8bdc4 100644 --- a/packages/nodes-base/nodes/TravisCi/TravisCi.node.ts +++ b/packages/nodes-base/nodes/TravisCi/TravisCi.node.ts @@ -1,23 +1,10 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - buildFields, - buildOperations, -} from './BuildDescription'; +import { buildFields, buildOperations } from './BuildDescription'; -import { - travisciApiRequest, - travisciApiRequestAllItems, -} from './GenericFunctions'; +import { travisciApiRequest, travisciApiRequestAllItems } from './GenericFunctions'; export class TravisCi implements INodeType { description: INodeTypeDescription = { @@ -100,8 +87,14 @@ export class TravisCi implements INodeType { } if (returnAll === true) { - responseData = await travisciApiRequestAllItems.call(this, 'builds', 'GET', '/builds', {}, qs); - + responseData = await travisciApiRequestAllItems.call( + this, + 'builds', + 'GET', + '/builds', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await travisciApiRequest.call(this, 'GET', '/builds', {}, qs); @@ -111,12 +104,24 @@ export class TravisCi implements INodeType { //https://developer.travis-ci.com/resource/build#cancel if (operation === 'cancel') { const buildId = this.getNodeParameter('buildId', i) as string; - responseData = await travisciApiRequest.call(this, 'POST', `/build/${buildId}/cancel`, {}, qs); + responseData = await travisciApiRequest.call( + this, + 'POST', + `/build/${buildId}/cancel`, + {}, + qs, + ); } //https://developer.travis-ci.com/resource/build#restart if (operation === 'restart') { const buildId = this.getNodeParameter('buildId', i) as string; - responseData = await travisciApiRequest.call(this, 'POST', `/build/${buildId}/restart`, {}, qs); + responseData = await travisciApiRequest.call( + this, + 'POST', + `/build/${buildId}/restart`, + {}, + qs, + ); } //https://developer.travis-ci.com/resource/requests#create if (operation === 'trigger') { @@ -138,7 +143,12 @@ export class TravisCi implements INodeType { request.merge_mode = additionalFields.mergeMode as string; } - responseData = await travisciApiRequest.call(this, 'POST', `/repo/${slug}/requests`, JSON.stringify({ request })); + responseData = await travisciApiRequest.call( + this, + 'POST', + `/repo/${slug}/requests`, + JSON.stringify({ request }), + ); } } if (Array.isArray(responseData)) { diff --git a/packages/nodes-base/nodes/Trello/AttachmentDescription.ts b/packages/nodes-base/nodes/Trello/AttachmentDescription.ts index 08b6d36cea..75aee8d376 100644 --- a/packages/nodes-base/nodes/Trello/AttachmentDescription.ts +++ b/packages/nodes-base/nodes/Trello/AttachmentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const attachmentOperations: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const attachmentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'attachment', - ], + resource: ['attachment'], }, }, options: [ @@ -46,11 +42,9 @@ export const attachmentOperations: INodeProperties[] = [ ], default: 'getAll', }, - ]; export const attachmentFields: INodeProperties[] = [ - // ---------------------------------- // attachment:create // ---------------------------------- @@ -62,12 +56,8 @@ export const attachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'attachment', - ], + operation: ['create'], + resource: ['attachment'], }, }, description: 'The ID of the card to add attachment to', @@ -80,12 +70,8 @@ export const attachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'attachment', - ], + operation: ['create'], + resource: ['attachment'], }, }, description: 'The URL of the attachment to add', @@ -97,12 +83,8 @@ export const attachmentFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'attachment', - ], + operation: ['create'], + resource: ['attachment'], }, }, default: {}, @@ -136,12 +118,8 @@ export const attachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'attachment', - ], + operation: ['delete'], + resource: ['attachment'], }, }, description: 'The ID of the card that attachment belongs to', @@ -154,12 +132,8 @@ export const attachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'attachment', - ], + operation: ['delete'], + resource: ['attachment'], }, }, description: 'The ID of the attachment to delete', @@ -176,12 +150,8 @@ export const attachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'attachment', - ], + operation: ['getAll'], + resource: ['attachment'], }, }, description: 'The ID of the card to get attachments', @@ -193,12 +163,8 @@ export const attachmentFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'attachment', - ], + operation: ['getAll'], + resource: ['attachment'], }, }, default: {}, @@ -224,12 +190,8 @@ export const attachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'attachment', - ], + operation: ['get'], + resource: ['attachment'], }, }, description: 'The ID of the card to get attachment', @@ -242,12 +204,8 @@ export const attachmentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'attachment', - ], + operation: ['get'], + resource: ['attachment'], }, }, description: 'The ID of the attachment to get', @@ -259,12 +217,8 @@ export const attachmentFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'attachment', - ], + operation: ['get'], + resource: ['attachment'], }, }, default: {}, @@ -278,5 +232,4 @@ export const attachmentFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Trello/BoardDescription.ts b/packages/nodes-base/nodes/Trello/BoardDescription.ts index 57044e0bfe..ccd0f1a60a 100644 --- a/packages/nodes-base/nodes/Trello/BoardDescription.ts +++ b/packages/nodes-base/nodes/Trello/BoardDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const boardOperations: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const boardOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'board', - ], + resource: ['board'], }, }, options: [ @@ -49,7 +45,6 @@ export const boardOperations: INodeProperties[] = [ ]; export const boardFields: INodeProperties[] = [ - // ---------------------------------- // board:create // ---------------------------------- @@ -62,12 +57,8 @@ export const boardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'board', - ], + operation: ['create'], + resource: ['board'], }, }, description: 'The name of the board', @@ -79,12 +70,8 @@ export const boardFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'board', - ], + operation: ['create'], + resource: ['board'], }, }, description: 'The description of the board', @@ -96,12 +83,8 @@ export const boardFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'board', - ], + operation: ['create'], + resource: ['board'], }, }, default: {}, @@ -121,14 +104,16 @@ export const boardFields: INodeProperties[] = [ }, ], default: 'regular', - description: 'Determines the type of card aging that should take place on the board if card aging is enabled', + description: + 'Determines the type of card aging that should take place on the board if card aging is enabled', }, { displayName: 'Background', name: 'prefs_background', type: 'string', default: 'blue', - description: 'The ID of a custom background or one of: blue, orange, green, red, purple, pink, lime, sky, grey', + description: + 'The ID of a custom background or one of: blue, orange, green, red, purple, pink, lime, sky, grey', }, { displayName: 'Comments', @@ -202,7 +187,8 @@ export const boardFields: INodeProperties[] = [ name: 'defaultLists', type: 'boolean', default: true, - description: 'Whether to add the default set of lists to a board(To Do, Doing, Done).It is ignored if idBoardSource is provided', + description: + 'Whether to add the default set of lists to a board(To Do, Doing, Done).It is ignored if idBoardSource is provided', }, { displayName: 'Organization ID', @@ -266,7 +252,8 @@ export const boardFields: INodeProperties[] = [ name: 'prefs_selfJoin', type: 'boolean', default: true, - description: 'Whether users can join the boards themselves or whether they have to be invited', + description: + 'Whether users can join the boards themselves or whether they have to be invited', }, { displayName: 'Source IDs', @@ -318,12 +305,8 @@ export const boardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'board', - ], + operation: ['delete'], + resource: ['board'], }, }, description: 'The ID of the board to delete', @@ -340,12 +323,8 @@ export const boardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'board', - ], + operation: ['get'], + resource: ['board'], }, }, description: 'The ID of the board to get', @@ -357,12 +336,8 @@ export const boardFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'board', - ], + operation: ['get'], + resource: ['board'], }, }, default: {}, @@ -372,7 +347,8 @@ export const boardFields: INodeProperties[] = [ name: 'fields', type: 'string', default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list: closed, dateLastActivity, dateLastView, desc, descData, idOrganization, invitations, invited, labelNames, memberships, name, pinned, powerUps, prefs, shortLink, shortUrl, starred, subscribed, URL.', + description: + 'Fields to return. Either "all" or a comma-separated list: closed, dateLastActivity, dateLastView, desc, descData, idOrganization, invitations, invited, labelNames, memberships, name, pinned, powerUps, prefs, shortLink, shortUrl, starred, subscribed, URL.', }, { displayName: 'Plugin Data', @@ -395,12 +371,8 @@ export const boardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'board', - ], + operation: ['update'], + resource: ['board'], }, }, description: 'The ID of the board to update', @@ -412,12 +384,8 @@ export const boardFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'board', - ], + operation: ['update'], + resource: ['board'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/Trello/BoardMemberDescription.ts b/packages/nodes-base/nodes/Trello/BoardMemberDescription.ts index 54a720b2d3..6ef32d192f 100644 --- a/packages/nodes-base/nodes/Trello/BoardMemberDescription.ts +++ b/packages/nodes-base/nodes/Trello/BoardMemberDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const boardMemberOperations: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const boardMemberOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'boardMember', - ], + resource: ['boardMember'], }, }, options: [ @@ -60,12 +56,8 @@ export const boardMemberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'boardMember', - ], + operation: ['getAll'], + resource: ['boardMember'], }, }, description: 'The ID of the board to get members from', @@ -76,12 +68,8 @@ export const boardMemberFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'boardMember', - ], + operation: ['getAll'], + resource: ['boardMember'], }, }, default: false, @@ -98,15 +86,9 @@ export const boardMemberFields: INodeProperties[] = [ default: 20, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'boardMember', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['boardMember'], + returnAll: [false], }, }, }, @@ -122,12 +104,8 @@ export const boardMemberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'boardMember', - ], + operation: ['add'], + resource: ['boardMember'], }, }, description: 'The ID of the board to add member to', @@ -140,12 +118,8 @@ export const boardMemberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'boardMember', - ], + operation: ['add'], + resource: ['boardMember'], }, }, description: 'The ID of the member to add to the board', @@ -158,12 +132,8 @@ export const boardMemberFields: INodeProperties[] = [ default: 'normal', displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'boardMember', - ], + operation: ['add'], + resource: ['boardMember'], }, }, options: [ @@ -193,12 +163,8 @@ export const boardMemberFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'boardMember', - ], + operation: ['add'], + resource: ['boardMember'], }, }, options: [ @@ -223,12 +189,8 @@ export const boardMemberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'invite', - ], - resource: [ - 'boardMember', - ], + operation: ['invite'], + resource: ['boardMember'], }, }, description: 'The ID of the board to invite member to', @@ -242,12 +204,8 @@ export const boardMemberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'invite', - ], - resource: [ - 'boardMember', - ], + operation: ['invite'], + resource: ['boardMember'], }, }, description: 'The ID of the board to update', @@ -259,12 +217,8 @@ export const boardMemberFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'invite', - ], - resource: [ - 'boardMember', - ], + operation: ['invite'], + resource: ['boardMember'], }, }, default: {}, @@ -298,7 +252,8 @@ export const boardMemberFields: INodeProperties[] = [ name: 'fullName', type: 'string', default: '', - description: 'The full name of the user to add as a member of the board. Must have a length of at least 1 and cannot begin nor end with a space.', + description: + 'The full name of the user to add as a member of the board. Must have a length of at least 1 and cannot begin nor end with a space.', }, ], }, @@ -314,12 +269,8 @@ export const boardMemberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'remove', - ], - resource: [ - 'boardMember', - ], + operation: ['remove'], + resource: ['boardMember'], }, }, description: 'The ID of the board to remove member from', @@ -332,12 +283,8 @@ export const boardMemberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'remove', - ], - resource: [ - 'boardMember', - ], + operation: ['remove'], + resource: ['boardMember'], }, }, description: 'The ID of the member to remove from the board', diff --git a/packages/nodes-base/nodes/Trello/CardCommentDescription.ts b/packages/nodes-base/nodes/Trello/CardCommentDescription.ts index 5a482232e6..b3a7330773 100644 --- a/packages/nodes-base/nodes/Trello/CardCommentDescription.ts +++ b/packages/nodes-base/nodes/Trello/CardCommentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const cardCommentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const cardCommentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'cardComment', - ], + resource: ['cardComment'], }, }, options: [ @@ -51,12 +47,8 @@ export const cardCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'cardComment', - ], + operation: ['create'], + resource: ['cardComment'], }, }, description: 'The ID of the card', @@ -69,12 +61,8 @@ export const cardCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'cardComment', - ], + operation: ['create'], + resource: ['cardComment'], }, }, description: 'Text of the comment', @@ -91,12 +79,8 @@ export const cardCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'cardComment', - ], + operation: ['delete'], + resource: ['cardComment'], }, }, description: 'The ID of the card', @@ -109,12 +93,8 @@ export const cardCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'cardComment', - ], + operation: ['delete'], + resource: ['cardComment'], }, }, description: 'The ID of the comment to delete', @@ -131,12 +111,8 @@ export const cardCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'cardComment', - ], + operation: ['update'], + resource: ['cardComment'], }, }, description: 'The ID of the card to update', @@ -149,12 +125,8 @@ export const cardCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'cardComment', - ], + operation: ['update'], + resource: ['cardComment'], }, }, description: 'The ID of the comment to delete', @@ -167,12 +139,8 @@ export const cardCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'cardComment', - ], + operation: ['update'], + resource: ['cardComment'], }, }, description: 'Text of the comment', diff --git a/packages/nodes-base/nodes/Trello/CardDescription.ts b/packages/nodes-base/nodes/Trello/CardDescription.ts index 2caec8ca28..2acd2ede0e 100644 --- a/packages/nodes-base/nodes/Trello/CardDescription.ts +++ b/packages/nodes-base/nodes/Trello/CardDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const cardOperations: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const cardOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'card', - ], + resource: ['card'], }, }, options: [ @@ -60,12 +56,8 @@ export const cardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'card', - ], + operation: ['create'], + resource: ['card'], }, }, description: 'The ID of the list to create card in', @@ -79,12 +71,8 @@ export const cardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'card', - ], + operation: ['create'], + resource: ['card'], }, }, description: 'The name of the card', @@ -96,12 +84,8 @@ export const cardFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'card', - ], + operation: ['create'], + resource: ['card'], }, }, description: 'The description of the card', @@ -113,12 +97,8 @@ export const cardFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'card', - ], + operation: ['create'], + resource: ['card'], }, }, default: {}, @@ -177,7 +157,8 @@ export const cardFields: INodeProperties[] = [ name: 'keepFromSource', type: 'string', default: 'all', - description: 'If using idCardSource you can specify which properties to copy over. all or comma-separated list of: attachments, checklists, comments, due, labels, members, stickers.', + description: + 'If using idCardSource you can specify which properties to copy over. all or comma-separated list of: attachments, checklists, comments, due, labels, members, stickers.', }, ], }, @@ -193,12 +174,8 @@ export const cardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'card', - ], + operation: ['delete'], + resource: ['card'], }, }, description: 'The ID of the card to delete', @@ -215,12 +192,8 @@ export const cardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'card', - ], + operation: ['get'], + resource: ['card'], }, }, description: 'The ID of the card to get', @@ -232,12 +205,8 @@ export const cardFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'card', - ], + operation: ['get'], + resource: ['card'], }, }, default: {}, @@ -248,7 +217,8 @@ export const cardFields: INodeProperties[] = [ type: 'string', default: 'all', // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-url - description: 'Fields to return. Either "all" or a comma-separated list: badges, checkItemStates, closed, dateLastActivity, desc, descData, due, email, idBoard, idChecklists, idLabels, idList, idMembers, idShort, idAttachmentCover, manualCoverAttachment, labels, name, pos, shortUrl, url.', + description: + 'Fields to return. Either "all" or a comma-separated list: badges, checkItemStates, closed, dateLastActivity, desc, descData, due, email, idBoard, idChecklists, idLabels, idList, idMembers, idShort, idAttachmentCover, manualCoverAttachment, labels, name, pos, shortUrl, url.', }, { displayName: 'Board', @@ -263,7 +233,8 @@ export const cardFields: INodeProperties[] = [ type: 'string', default: 'all', // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-url - description: 'Fields to return. Either "all" or a comma-separated list: name, desc, descData, closed, idOrganization, pinned, url, prefs.', + description: + 'Fields to return. Either "all" or a comma-separated list: name, desc, descData, closed, idOrganization, pinned, url, prefs.', }, { displayName: 'Custom Field Items', @@ -284,7 +255,8 @@ export const cardFields: INodeProperties[] = [ name: 'member_fields', type: 'string', default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list: avatarHash, fullName, initials, username.', + description: + 'Fields to return. Either "all" or a comma-separated list: avatarHash, fullName, initials, username.', }, { displayName: 'Plugin Data', @@ -321,12 +293,8 @@ export const cardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'card', - ], + operation: ['update'], + resource: ['card'], }, }, description: 'The ID of the card to update', @@ -338,12 +306,8 @@ export const cardFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'card', - ], + operation: ['update'], + resource: ['card'], }, }, default: {}, @@ -353,7 +317,8 @@ export const cardFields: INodeProperties[] = [ name: 'idAttachmentCover', type: 'string', default: '', - description: 'The ID of the image attachment the card should use as its cover, or null for none', + description: + 'The ID of the image attachment the card should use as its cover, or null for none', }, { displayName: 'Board ID', diff --git a/packages/nodes-base/nodes/Trello/ChecklistDescription.ts b/packages/nodes-base/nodes/Trello/ChecklistDescription.ts index e8a1ace9e5..83ff9ed988 100644 --- a/packages/nodes-base/nodes/Trello/ChecklistDescription.ts +++ b/packages/nodes-base/nodes/Trello/ChecklistDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const checklistOperations: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const checklistOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'checklist', - ], + resource: ['checklist'], }, }, options: [ @@ -76,7 +72,6 @@ export const checklistOperations: INodeProperties[] = [ ], default: 'getAll', }, - ]; export const checklistFields: INodeProperties[] = [ @@ -91,12 +86,8 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'checklist', - ], + operation: ['create'], + resource: ['checklist'], }, }, description: 'The ID of the card to add checklist to', @@ -109,12 +100,8 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'checklist', - ], + operation: ['create'], + resource: ['checklist'], }, }, description: 'The URL of the checklist to add', @@ -126,12 +113,8 @@ export const checklistFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'checklist', - ], + operation: ['create'], + resource: ['checklist'], }, }, default: {}, @@ -148,7 +131,8 @@ export const checklistFields: INodeProperties[] = [ name: 'pos', type: 'string', default: '', - description: 'The position of the checklist on the card. One of: top, bottom, or a positive number.', + description: + 'The position of the checklist on the card. One of: top, bottom, or a positive number.', }, ], }, @@ -164,12 +148,8 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'checklist', - ], + operation: ['delete'], + resource: ['checklist'], }, }, description: 'The ID of the card that checklist belongs to', @@ -182,18 +162,13 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'checklist', - ], + operation: ['delete'], + resource: ['checklist'], }, }, description: 'The ID of the checklist to delete', }, - // ---------------------------------- // checklist:getAll // ---------------------------------- @@ -205,12 +180,8 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'checklist', - ], + operation: ['getAll'], + resource: ['checklist'], }, }, description: 'The ID of the card to get checklists', @@ -222,12 +193,8 @@ export const checklistFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'checklist', - ], + operation: ['getAll'], + resource: ['checklist'], }, }, default: {}, @@ -253,12 +220,8 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'checklist', - ], + operation: ['get'], + resource: ['checklist'], }, }, description: 'The ID of the checklist to get', @@ -270,12 +233,8 @@ export const checklistFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'checklist', - ], + operation: ['get'], + resource: ['checklist'], }, }, default: {}, @@ -301,12 +260,8 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'createCheckItem', - ], - resource: [ - 'checklist', - ], + operation: ['createCheckItem'], + resource: ['checklist'], }, }, description: 'The ID of the checklist to update', @@ -319,12 +274,8 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'createCheckItem', - ], - resource: [ - 'checklist', - ], + operation: ['createCheckItem'], + resource: ['checklist'], }, }, description: 'The name of the new check item on the checklist', @@ -336,12 +287,8 @@ export const checklistFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'createCheckItem', - ], - resource: [ - 'checklist', - ], + operation: ['createCheckItem'], + resource: ['checklist'], }, }, default: {}, @@ -358,7 +305,8 @@ export const checklistFields: INodeProperties[] = [ name: 'pos', type: 'string', default: '', - description: 'The position of the checklist on the card. One of: top, bottom, or a positive number.', + description: + 'The position of the checklist on the card. One of: top, bottom, or a positive number.', }, ], }, @@ -374,12 +322,8 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'deleteCheckItem', - ], - resource: [ - 'checklist', - ], + operation: ['deleteCheckItem'], + resource: ['checklist'], }, }, description: 'The ID of the card that checklist belongs to', @@ -392,12 +336,8 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'deleteCheckItem', - ], - resource: [ - 'checklist', - ], + operation: ['deleteCheckItem'], + resource: ['checklist'], }, }, description: 'The ID of the checklist item to delete', @@ -414,12 +354,8 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getCheckItem', - ], - resource: [ - 'checklist', - ], + operation: ['getCheckItem'], + resource: ['checklist'], }, }, description: 'The ID of the card that checklist belongs to', @@ -432,12 +368,8 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getCheckItem', - ], - resource: [ - 'checklist', - ], + operation: ['getCheckItem'], + resource: ['checklist'], }, }, description: 'The ID of the checklist item to get', @@ -449,12 +381,8 @@ export const checklistFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getCheckItem', - ], - resource: [ - 'checklist', - ], + operation: ['getCheckItem'], + resource: ['checklist'], }, }, default: {}, @@ -480,12 +408,8 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'updateCheckItem', - ], - resource: [ - 'checklist', - ], + operation: ['updateCheckItem'], + resource: ['checklist'], }, }, description: 'The ID of the card that checklist belongs to', @@ -498,12 +422,8 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'updateCheckItem', - ], - resource: [ - 'checklist', - ], + operation: ['updateCheckItem'], + resource: ['checklist'], }, }, description: 'The ID of the checklist item to update', @@ -515,12 +435,8 @@ export const checklistFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'updateCheckItem', - ], - resource: [ - 'checklist', - ], + operation: ['updateCheckItem'], + resource: ['checklist'], }, }, default: {}, @@ -560,7 +476,8 @@ export const checklistFields: INodeProperties[] = [ name: 'pos', type: 'string', default: '', - description: 'The position of the checklist on the card. One of: top, bottom, or a positive number.', + description: + 'The position of the checklist on the card. One of: top, bottom, or a positive number.', }, ], }, @@ -576,12 +493,8 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'completedCheckItems', - ], - resource: [ - 'checklist', - ], + operation: ['completedCheckItems'], + resource: ['checklist'], }, }, description: 'The ID of the card for checkItems', @@ -593,12 +506,8 @@ export const checklistFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'completedCheckItems', - ], - resource: [ - 'checklist', - ], + operation: ['completedCheckItems'], + resource: ['checklist'], }, }, default: {}, @@ -608,9 +517,9 @@ export const checklistFields: INodeProperties[] = [ name: 'fields', type: 'string', default: 'all', - description: 'Fields to return. Either "all" or a comma-separated list of: "idCheckItem", "state".', + description: + 'Fields to return. Either "all" or a comma-separated list of: "idCheckItem", "state".', }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Trello/GenericFunctions.ts b/packages/nodes-base/nodes/Trello/GenericFunctions.ts index daee29cb49..68ef5a9d11 100644 --- a/packages/nodes-base/nodes/Trello/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Trello/GenericFunctions.ts @@ -1,18 +1,8 @@ -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IDataObject, - JsonObject, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, JsonObject, NodeApiError } from 'n8n-workflow'; /** * Make an API request to Trello @@ -23,7 +13,14 @@ import { * @param {object} body * @returns {Promise} */ -export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, query?: IDataObject): Promise { // tslint:disable-line:no-any +export async function apiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + body: object, + query?: IDataObject, + // tslint:disable-next-line:no-any +): Promise { query = query || {}; const options: OptionsWithUri = { @@ -36,13 +33,19 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa try { return await this.helpers.requestWithAuthentication.call(this, 'trelloApi', options); - } catch(error) { + } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); } } -export async function apiRequestAllItems(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: IDataObject, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function apiRequestAllItems( + this: IHookFunctions | IExecuteFunctions, + method: string, + endpoint: string, + body: IDataObject, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { query.limit = 30; query.sort = '-id'; @@ -57,9 +60,7 @@ export async function apiRequestAllItems(this: IHookFunctions | IExecuteFunction if (responseData.length !== 0) { query.before = responseData[responseData.length - 1].id; } - } while ( - query.limit <= responseData.length - ); + } while (query.limit <= responseData.length); return returnData; } diff --git a/packages/nodes-base/nodes/Trello/LabelDescription.ts b/packages/nodes-base/nodes/Trello/LabelDescription.ts index 2aa4a6a0df..2bb7e4e0c9 100644 --- a/packages/nodes-base/nodes/Trello/LabelDescription.ts +++ b/packages/nodes-base/nodes/Trello/LabelDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const labelOperations: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const labelOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'label', - ], + resource: ['label'], }, }, options: [ @@ -61,11 +57,9 @@ export const labelOperations: INodeProperties[] = [ description: 'Update a label', action: 'Update a label', }, - ], default: 'getAll', }, - ]; export const labelFields: INodeProperties[] = [ @@ -80,12 +74,8 @@ export const labelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'label', - ], + operation: ['create'], + resource: ['label'], }, }, description: 'The ID of the board to create the label on', @@ -98,12 +88,8 @@ export const labelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'label', - ], + operation: ['create'], + resource: ['label'], }, }, description: 'Name for the label', @@ -115,12 +101,8 @@ export const labelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'label', - ], + operation: ['create'], + resource: ['label'], }, }, options: [ @@ -173,7 +155,6 @@ export const labelFields: INodeProperties[] = [ description: 'The color for the label', }, - // ---------------------------------- // label:delete // ---------------------------------- @@ -185,12 +166,8 @@ export const labelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'label', - ], + operation: ['delete'], + resource: ['label'], }, }, description: 'The ID of the label to delete', @@ -207,12 +184,8 @@ export const labelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'label', - ], + operation: ['getAll'], + resource: ['label'], }, }, description: 'The ID of the board to get label', @@ -224,12 +197,8 @@ export const labelFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'label', - ], + operation: ['getAll'], + resource: ['label'], }, }, default: {}, @@ -255,12 +224,8 @@ export const labelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'label', - ], + operation: ['get'], + resource: ['label'], }, }, description: 'Get information about a label by ID', @@ -272,12 +237,8 @@ export const labelFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'label', - ], + operation: ['get'], + resource: ['label'], }, }, default: {}, @@ -303,12 +264,8 @@ export const labelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'addLabel', - ], - resource: [ - 'label', - ], + operation: ['addLabel'], + resource: ['label'], }, }, description: 'The ID of the card to get label', @@ -321,12 +278,8 @@ export const labelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'addLabel', - ], - resource: [ - 'label', - ], + operation: ['addLabel'], + resource: ['label'], }, }, description: 'The ID of the label to add', @@ -343,12 +296,8 @@ export const labelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'removeLabel', - ], - resource: [ - 'label', - ], + operation: ['removeLabel'], + resource: ['label'], }, }, description: 'The ID of the card to remove label from', @@ -361,12 +310,8 @@ export const labelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'removeLabel', - ], - resource: [ - 'label', - ], + operation: ['removeLabel'], + resource: ['label'], }, }, description: 'The ID of the label to remove', @@ -383,12 +328,8 @@ export const labelFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'label', - ], + operation: ['update'], + resource: ['label'], }, }, description: 'The ID of the label to update', @@ -400,12 +341,8 @@ export const labelFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'label', - ], + operation: ['update'], + resource: ['label'], }, }, default: {}, @@ -472,5 +409,4 @@ export const labelFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Trello/ListDescription.ts b/packages/nodes-base/nodes/Trello/ListDescription.ts index f7e8be365f..caef3286b5 100644 --- a/packages/nodes-base/nodes/Trello/ListDescription.ts +++ b/packages/nodes-base/nodes/Trello/ListDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const listOperations: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const listOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'list', - ], + resource: ['list'], }, }, options: [ @@ -72,12 +68,8 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'archive', - ], - resource: [ - 'list', - ], + operation: ['archive'], + resource: ['list'], }, }, description: 'The ID of the list to archive or unarchive', @@ -89,12 +81,8 @@ export const listFields: INodeProperties[] = [ default: false, displayOptions: { show: { - operation: [ - 'archive', - ], - resource: [ - 'list', - ], + operation: ['archive'], + resource: ['list'], }, }, description: 'Whether the list should be archived or unarchived', @@ -111,12 +99,8 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'list', - ], + operation: ['create'], + resource: ['list'], }, }, description: 'The ID of the board the list should be created in', @@ -130,12 +114,8 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'list', - ], + operation: ['create'], + resource: ['list'], }, }, description: 'The name of the list', @@ -147,12 +127,8 @@ export const listFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'list', - ], + operation: ['create'], + resource: ['list'], }, }, default: {}, @@ -169,8 +145,7 @@ export const listFields: INodeProperties[] = [ name: 'pos', type: 'string', default: 'bottom', - description: - 'The position of the new list. top, bottom, or a positive float.', + description: 'The position of the new list. top, bottom, or a positive float.', }, ], }, @@ -186,12 +161,8 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getCards', - ], - resource: [ - 'list', - ], + operation: ['getCards'], + resource: ['list'], }, }, description: 'The ID of the list to get cards', @@ -202,12 +173,8 @@ export const listFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getCards', - ], + resource: ['list'], + operation: ['getCards'], }, }, default: false, @@ -224,15 +191,9 @@ export const listFields: INodeProperties[] = [ default: 20, displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getCards', - ], - returnAll: [ - false, - ], + resource: ['list'], + operation: ['getCards'], + returnAll: [false], }, }, }, @@ -243,12 +204,8 @@ export const listFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getCards', - ], - resource: [ - 'list', - ], + operation: ['getCards'], + resource: ['list'], }, }, default: {}, @@ -273,12 +230,8 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'list', - ], + operation: ['get'], + resource: ['list'], }, }, description: 'The ID of the list to get', @@ -290,12 +243,8 @@ export const listFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'list', - ], + operation: ['get'], + resource: ['list'], }, }, default: {}, @@ -321,12 +270,8 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'list', - ], + operation: ['getAll'], + resource: ['list'], }, }, description: 'The ID of the board', @@ -337,12 +282,8 @@ export const listFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], + resource: ['list'], + operation: ['getAll'], }, }, default: false, @@ -359,15 +300,9 @@ export const listFields: INodeProperties[] = [ default: 20, displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['list'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -378,12 +313,8 @@ export const listFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'list', - ], + operation: ['getAll'], + resource: ['list'], }, }, default: {}, @@ -409,12 +340,8 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'list', - ], + operation: ['update'], + resource: ['list'], }, }, description: 'The ID of the list to update', @@ -426,12 +353,8 @@ export const listFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'list', - ], + operation: ['update'], + resource: ['list'], }, }, default: {}, @@ -462,8 +385,7 @@ export const listFields: INodeProperties[] = [ name: 'pos', type: 'string', default: 'bottom', - description: - 'The position of the list. top, bottom, or a positive float.', + description: 'The position of the list. top, bottom, or a positive float.', }, { displayName: 'Subscribed', diff --git a/packages/nodes-base/nodes/Trello/Trello.node.ts b/packages/nodes-base/nodes/Trello/Trello.node.ts index e586051812..e22c5754ff 100644 --- a/packages/nodes-base/nodes/Trello/Trello.node.ts +++ b/packages/nodes-base/nodes/Trello/Trello.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,50 +8,23 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - apiRequest, - apiRequestAllItems, -} from './GenericFunctions'; +import { apiRequest, apiRequestAllItems } from './GenericFunctions'; -import { - attachmentFields, - attachmentOperations, -} from './AttachmentDescription'; +import { attachmentFields, attachmentOperations } from './AttachmentDescription'; -import { - boardFields, - boardOperations, -} from './BoardDescription'; +import { boardFields, boardOperations } from './BoardDescription'; -import { - boardMemberFields, - boardMemberOperations, -} from './BoardMemberDescription'; +import { boardMemberFields, boardMemberOperations } from './BoardMemberDescription'; -import { - cardFields, - cardOperations, -} from './CardDescription'; +import { cardFields, cardOperations } from './CardDescription'; -import { - cardCommentFields, - cardCommentOperations, -} from './CardCommentDescription'; +import { cardCommentFields, cardCommentOperations } from './CardCommentDescription'; -import { - checklistFields, - checklistOperations, -} from './ChecklistDescription'; +import { checklistFields, checklistOperations } from './ChecklistDescription'; -import { - labelFields, - labelOperations, -} from './LabelDescription'; +import { labelFields, labelOperations } from './LabelDescription'; -import { - listFields, - listOperations, -} from './ListDescription'; +import { listFields, listOperations } from './ListDescription'; export class Trello implements INodeType { description: INodeTypeDescription = { @@ -141,7 +112,6 @@ export class Trello implements INodeType { ...checklistFields, ...labelFields, ...listFields, - ], }; @@ -170,7 +140,6 @@ export class Trello implements INodeType { qs = {}; if (resource === 'board') { - if (operation === 'create') { // ---------------------------------- // create @@ -184,7 +153,6 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -195,7 +163,6 @@ export class Trello implements INodeType { const id = this.getNodeParameter('id', i) as string; endpoint = `boards/${id}`; - } else if (operation === 'get') { // ---------------------------------- // get @@ -209,7 +176,6 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); - } else if (operation === 'update') { // ---------------------------------- // update @@ -223,11 +189,14 @@ export class Trello implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; Object.assign(qs, updateFields); - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } - } else if (resource === 'boardMember') { + } else if (resource === 'boardMember') { if (operation === 'getAll') { // ---------------------------------- // getAll @@ -242,7 +211,6 @@ export class Trello implements INodeType { } endpoint = `boards/${id}/members`; - } else if (operation === 'add') { // ---------------------------------- // add @@ -256,8 +224,11 @@ export class Trello implements INodeType { endpoint = `boards/${id}/members/${idMember}`; qs.type = this.getNodeParameter('type', i) as string; - qs.allowBillableGuest = this.getNodeParameter('additionalFields.allowBillableGuest', i, false) as boolean; - + qs.allowBillableGuest = this.getNodeParameter( + 'additionalFields.allowBillableGuest', + i, + false, + ) as boolean; } else if (operation === 'invite') { // ---------------------------------- // invite @@ -284,13 +255,15 @@ export class Trello implements INodeType { const id = this.getNodeParameter('id', i) as string; const idMember = this.getNodeParameter('idMember', i) as string; - endpoint = `boards/${id}/members/${idMember}`; - + endpoint = `boards/${id}/members/${idMember}`; } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'card') { - if (operation === 'create') { // ---------------------------------- // create @@ -306,7 +279,6 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -317,7 +289,6 @@ export class Trello implements INodeType { const id = this.getNodeParameter('id', i) as string; endpoint = `cards/${id}`; - } else if (operation === 'get') { // ---------------------------------- // get @@ -331,7 +302,6 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); - } else if (operation === 'update') { // ---------------------------------- // update @@ -345,13 +315,14 @@ export class Trello implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; Object.assign(qs, updateFields); - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } - } else if (resource === 'cardComment') { - if (operation === 'create') { // ---------------------------------- // create @@ -364,8 +335,6 @@ export class Trello implements INodeType { requestMethod = 'POST'; endpoint = `cards/${cardId}/actions/comments`; - - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -378,7 +347,6 @@ export class Trello implements INodeType { const commentId = this.getNodeParameter('commentId', i) as string; endpoint = `/cards/${cardId}/actions/${commentId}/comments`; - } else if (operation === 'update') { // ---------------------------------- // update @@ -393,13 +361,14 @@ export class Trello implements INodeType { qs.text = this.getNodeParameter('text', i) as string; endpoint = `cards/${cardId}/actions/${commentId}/comments`; - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } - } else if (resource === 'list') { - if (operation === 'archive') { // ---------------------------------- // archive @@ -411,7 +380,6 @@ export class Trello implements INodeType { qs.value = this.getNodeParameter('archive', i) as boolean; endpoint = `lists/${id}/closed`; - } else if (operation === 'create') { // ---------------------------------- // create @@ -426,7 +394,6 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); - } else if (operation === 'get') { // ---------------------------------- // get @@ -440,7 +407,6 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -460,7 +426,6 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); - } else if (operation === 'getCards') { // ---------------------------------- // getCards @@ -480,7 +445,6 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); - } else if (operation === 'update') { // ---------------------------------- // update @@ -494,13 +458,14 @@ export class Trello implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; Object.assign(qs, updateFields); - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } - } else if (resource === 'attachment') { - if (operation === 'create') { // ---------------------------------- // create @@ -519,7 +484,6 @@ export class Trello implements INodeType { Object.assign(qs, additionalFields); endpoint = `cards/${cardId}/attachments`; - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -531,7 +495,6 @@ export class Trello implements INodeType { const id = this.getNodeParameter('id', i) as string; endpoint = `cards/${cardId}/attachments/${id}`; - } else if (operation === 'get') { // ---------------------------------- // get @@ -546,7 +509,6 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -561,11 +523,13 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } - } else if (resource === 'checklist') { - if (operation === 'create') { // ---------------------------------- // create @@ -582,7 +546,6 @@ export class Trello implements INodeType { Object.assign(qs, additionalFields); endpoint = `cards/${cardId}/checklists`; - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -594,7 +557,6 @@ export class Trello implements INodeType { const id = this.getNodeParameter('id', i) as string; endpoint = `cards/${cardId}/checklists/${id}`; - } else if (operation === 'get') { // ---------------------------------- // get @@ -608,7 +570,6 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -622,7 +583,6 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); - } else if (operation === 'getCheckItem') { // ---------------------------------- // getCheckItem @@ -637,7 +597,6 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); - } else if (operation === 'createCheckItem') { // ---------------------------------- // createCheckItem @@ -652,7 +611,6 @@ export class Trello implements INodeType { const name = this.getNodeParameter('name', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, { name, ...additionalFields }); - } else if (operation === 'deleteCheckItem') { // ---------------------------------- // deleteCheckItem @@ -664,7 +622,6 @@ export class Trello implements INodeType { const checkItemId = this.getNodeParameter('checkItemId', i) as string; endpoint = `cards/${cardId}/checkItem/${checkItemId}`; - } else if (operation === 'updateCheckItem') { // ---------------------------------- // updateCheckItem @@ -679,7 +636,6 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); - } else if (operation === 'completedCheckItems') { // ---------------------------------- // completedCheckItems @@ -693,12 +649,14 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'label') { - if (operation === 'create') { // ---------------------------------- // create @@ -717,7 +675,6 @@ export class Trello implements INodeType { }); endpoint = 'labels'; - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -728,7 +685,6 @@ export class Trello implements INodeType { const id = this.getNodeParameter('id', i) as string; endpoint = `labels/${id}`; - } else if (operation === 'get') { // ---------------------------------- // get @@ -742,7 +698,6 @@ export class Trello implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(qs, additionalFields); - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -770,7 +725,6 @@ export class Trello implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; Object.assign(qs, updateFields); - } else if (operation === 'addLabel') { // ---------------------------------- // addLabel @@ -784,7 +738,6 @@ export class Trello implements INodeType { qs.value = id; endpoint = `/cards/${cardId}/idLabels`; - } else if (operation === 'removeLabel') { // ---------------------------------- // removeLabel @@ -796,20 +749,22 @@ export class Trello implements INodeType { const id = this.getNodeParameter('id', i) as string; endpoint = `/cards/${cardId}/idLabels/${id}`; - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { + itemIndex: i, + }); } - // resources listed here do not support pagination so // paginate them 'manually' - const skipPagination = [ - 'list:getAll', - ]; + const skipPagination = ['list:getAll']; if (returnAll === true && !skipPagination.includes(`${resource}:${operation}`)) { responseData = await apiRequestAllItems.call(this, requestMethod, endpoint, body, qs); diff --git a/packages/nodes-base/nodes/Trello/TrelloTrigger.node.ts b/packages/nodes-base/nodes/Trello/TrelloTrigger.node.ts index 2c3f40461c..c184695249 100644 --- a/packages/nodes-base/nodes/Trello/TrelloTrigger.node.ts +++ b/packages/nodes-base/nodes/Trello/TrelloTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { INodeType, @@ -10,13 +7,10 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - apiRequest, -} from './GenericFunctions'; +import { apiRequest } from './GenericFunctions'; // import { createHmac } from 'crypto'; - export class TrelloTrigger implements INodeType { description: INodeTypeDescription = { displayName: 'Trello Trigger', @@ -61,7 +55,6 @@ export class TrelloTrigger implements INodeType { description: 'ID of the model of which to subscribe to events', }, ], - }; // @ts-ignore (because of request) @@ -143,8 +136,6 @@ export class TrelloTrigger implements INodeType { }, }; - - async webhook(this: IWebhookFunctions): Promise { const webhookName = this.getWebhookName(); @@ -174,9 +165,7 @@ export class TrelloTrigger implements INodeType { // } return { - workflowData: [ - this.helpers.returnJsonArray(bodyData), - ], + workflowData: [this.helpers.returnJsonArray(bodyData)], }; } } diff --git a/packages/nodes-base/nodes/Twake/GenericFunctions.ts b/packages/nodes-base/nodes/Twake/GenericFunctions.ts index 66b182e6f6..f534f3e4a8 100644 --- a/packages/nodes-base/nodes/Twake/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twake/GenericFunctions.ts @@ -1,14 +1,7 @@ -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; -import { NodeApiError, NodeOperationError, } from 'n8n-workflow'; - -import { - OptionsWithUri, -} from 'request'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; +import { NodeApiError, NodeOperationError } from 'n8n-workflow'; +import { OptionsWithUri } from 'request'; /** * Make an API request to Twake @@ -19,8 +12,15 @@ import { * @param {object} body * @returns {Promise} */ -export async function twakeApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: object, query?: object, uri?: string): Promise { // tslint:disable-line:no-any - +export async function twakeApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + body: object, + query?: object, + uri?: string, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('twakeVersion', 0, 'twakeCloudApi') as string; const options: OptionsWithUri = { @@ -32,7 +32,6 @@ export async function twakeApiRequest(this: IHookFunctions | IExecuteFunctions | json: true, }; - // if (authenticationMethod === 'cloud') { // } else { // const credentials = await this.getCredentials('twakeServerApi'); diff --git a/packages/nodes-base/nodes/Twake/Twake.node.ts b/packages/nodes-base/nodes/Twake/Twake.node.ts index be4722cbae..be6c5de01d 100644 --- a/packages/nodes-base/nodes/Twake/Twake.node.ts +++ b/packages/nodes-base/nodes/Twake/Twake.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,9 +10,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - twakeApiRequest, -} from './GenericFunctions'; +import { twakeApiRequest } from './GenericFunctions'; export class Twake implements INodeType { description: INodeTypeDescription = { @@ -93,9 +89,7 @@ export class Twake implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'message', - ], + resource: ['message'], }, }, options: [ @@ -117,13 +111,12 @@ export class Twake implements INodeType { }, displayOptions: { show: { - operation: [ - 'send', - ], + operation: ['send'], }, }, default: '', - description: 'Channel\'s ID. Choose from the list, or specify an ID using an expression.', + description: + 'Channel\'s ID. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Content', @@ -132,9 +125,7 @@ export class Twake implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'send', - ], + operation: ['send'], }, }, default: '', @@ -147,9 +138,7 @@ export class Twake implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'send', - ], + operation: ['send'], }, }, default: {}, @@ -203,7 +192,6 @@ export class Twake implements INodeType { for (let i = 0; i < length; i++) { if (resource === 'message') { if (operation === 'send') { - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const message: IDataObject = { diff --git a/packages/nodes-base/nodes/Twilio/GenericFunctions.ts b/packages/nodes-base/nodes/Twilio/GenericFunctions.ts index 2d0a37a72c..d0e8670572 100644 --- a/packages/nodes-base/nodes/Twilio/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twilio/GenericFunctions.ts @@ -1,15 +1,8 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; /** * Make an API request to Twilio @@ -20,8 +13,15 @@ import { * @param {object} body * @returns {Promise} */ -export async function twilioApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject): Promise { // tslint:disable-line:no-any - const credentials = await this.getCredentials('twilioApi') as { +export async function twilioApiRequest( + this: IHookFunctions | IExecuteFunctions, + method: string, + endpoint: string, + body: IDataObject, + query?: IDataObject, + // tslint:disable-next-line:no-any +): Promise { + const credentials = (await this.getCredentials('twilioApi')) as { accountSid: string; authType: 'authToken' | 'apiKey'; authToken: string; @@ -53,7 +53,7 @@ const XML_CHAR_MAP: { [key: string]: string } = { '>': '>', '&': '&', '"': '"', - '\'': ''', + "'": ''', }; export function escapeXml(str: string) { diff --git a/packages/nodes-base/nodes/Twilio/Twilio.node.ts b/packages/nodes-base/nodes/Twilio/Twilio.node.ts index 5237c6d53a..694fbed196 100644 --- a/packages/nodes-base/nodes/Twilio/Twilio.node.ts +++ b/packages/nodes-base/nodes/Twilio/Twilio.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, INodeExecutionData, @@ -9,10 +7,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - escapeXml, - twilioApiRequest, -} from './GenericFunctions'; +import { escapeXml, twilioApiRequest } from './GenericFunctions'; export class Twilio implements INodeType { description: INodeTypeDescription = { @@ -60,9 +55,7 @@ export class Twilio implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'sms', - ], + resource: ['sms'], }, }, options: [ @@ -83,9 +76,7 @@ export class Twilio implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'call', - ], + resource: ['call'], }, }, options: [ @@ -98,7 +89,6 @@ export class Twilio implements INodeType { default: 'make', }, - // ---------------------------------- // sms / call // ---------------------------------- @@ -115,14 +105,8 @@ export class Twilio implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'send', - 'make', - ], - resource: [ - 'sms', - 'call', - ], + operation: ['send', 'make'], + resource: ['sms', 'call'], }, }, description: 'The number from which to send the message', @@ -136,14 +120,8 @@ export class Twilio implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'send', - 'make', - ], - resource: [ - 'sms', - 'call', - ], + operation: ['send', 'make'], + resource: ['sms', 'call'], }, }, description: 'The number to which to send the message', @@ -155,12 +133,8 @@ export class Twilio implements INodeType { default: false, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - ], + operation: ['send'], + resource: ['sms'], }, }, description: 'Whether the message should be sent to WhatsApp', @@ -173,12 +147,8 @@ export class Twilio implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'send', - ], - resource: [ - 'sms', - ], + operation: ['send'], + resource: ['sms'], }, }, description: 'The message to send', @@ -190,15 +160,12 @@ export class Twilio implements INodeType { default: false, displayOptions: { show: { - operation: [ - 'make', - ], - resource: [ - 'call', - ], + operation: ['make'], + resource: ['call'], }, }, - description: 'Whether to use the Twilio Markup Language in the message', + description: + 'Whether to use the Twilio Markup Language in the message', }, { displayName: 'Message', @@ -208,12 +175,8 @@ export class Twilio implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'make', - ], - resource: [ - 'call', - ], + operation: ['make'], + resource: ['call'], }, }, }, @@ -229,7 +192,8 @@ export class Twilio implements INodeType { name: 'statusCallback', type: 'string', default: '', - description: 'Status Callbacks allow you to receive events related to the REST resources managed by Twilio: Rooms, Recordings and Compositions', + description: + 'Status Callbacks allow you to receive events related to the REST resources managed by Twilio: Rooms, Recordings and Compositions', }, ], }, @@ -282,7 +246,11 @@ export class Twilio implements INodeType { body.To = `whatsapp:${body.To}`; } } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'call') { if (operation === 'make') { @@ -306,10 +274,16 @@ export class Twilio implements INodeType { body.StatusCallback = this.getNodeParameter('options.statusCallback', i, '') as string; } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } } else { - throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i }); + throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { + itemIndex: i, + }); } const responseData = await twilioApiRequest.call(this, requestMethod, endpoint, body, qs); diff --git a/packages/nodes-base/nodes/Twist/ChannelDescription.ts b/packages/nodes-base/nodes/Twist/ChannelDescription.ts index 2a1d125ae1..e9fa281a34 100644 --- a/packages/nodes-base/nodes/Twist/ChannelDescription.ts +++ b/packages/nodes-base/nodes/Twist/ChannelDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const channelOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const channelOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'channel', - ], + resource: ['channel'], }, }, options: [ @@ -77,16 +73,13 @@ export const channelFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'channel', - ], + operation: ['create'], + resource: ['channel'], }, }, required: true, - description: 'The ID of the workspace. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the workspace. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Name', @@ -95,12 +88,8 @@ export const channelFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'channel', - ], + operation: ['create'], + resource: ['channel'], }, }, required: true, @@ -114,12 +103,8 @@ export const channelFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'create', - ], + resource: ['channel'], + operation: ['create'], }, }, options: [ @@ -208,12 +193,11 @@ export const channelFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getUsers', - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], }, default: [], - description: 'The users that will participate in the channel. Choose from the list, or specify IDs using an expression.', + description: + 'The users that will participate in the channel. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -228,15 +212,8 @@ export const channelFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'archive', - 'delete', - 'get', - 'unarchive', - ], - resource: [ - 'channel', - ], + operation: ['archive', 'delete', 'get', 'unarchive'], + resource: ['channel'], }, }, required: true, @@ -256,16 +233,13 @@ export const channelFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'channel', - ], + operation: ['getAll'], + resource: ['channel'], }, }, required: true, - description: 'The ID of the workspace. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the workspace. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -273,12 +247,8 @@ export const channelFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'getAll', - ], + resource: ['channel'], + operation: ['getAll'], }, }, default: false, @@ -290,15 +260,9 @@ export const channelFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['channel'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -316,12 +280,8 @@ export const channelFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'getAll', - ], + resource: ['channel'], + operation: ['getAll'], }, }, options: [ @@ -345,12 +305,8 @@ export const channelFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'channel', - ], + operation: ['update'], + resource: ['channel'], }, }, required: true, @@ -364,12 +320,8 @@ export const channelFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'channel', - ], - operation: [ - 'update', - ], + resource: ['channel'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Twist/CommentDescription.ts b/packages/nodes-base/nodes/Twist/CommentDescription.ts index f53ff87531..6c6badf219 100644 --- a/packages/nodes-base/nodes/Twist/CommentDescription.ts +++ b/packages/nodes-base/nodes/Twist/CommentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const commentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const commentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'comment', - ], + resource: ['comment'], }, }, options: [ @@ -62,12 +58,8 @@ export const commentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'comment', - ], + operation: ['create'], + resource: ['comment'], }, }, required: true, @@ -80,12 +72,8 @@ export const commentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'comment', - ], + operation: ['create'], + resource: ['comment'], }, }, required: true, @@ -99,12 +87,8 @@ export const commentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'comment', - ], - operation: [ - 'create', - ], + resource: ['comment'], + operation: ['create'], }, }, options: [ @@ -156,10 +140,7 @@ export const commentFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - action: [ - 'send_reply', - 'prefill_message', - ], + action: ['send_reply', 'prefill_message'], }, }, description: 'The text for the action button', @@ -169,7 +150,8 @@ export const commentFields: INodeProperties[] = [ displayName: 'Type', name: 'type', type: 'options', - description: 'The type of the button. (Currently only action is available).', + description: + 'The type of the button. (Currently only action is available).', options: [ { name: 'Action', @@ -184,9 +166,7 @@ export const commentFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - action: [ - 'open_url', - ], + action: ['open_url'], }, }, description: 'URL to redirect', @@ -201,7 +181,8 @@ export const commentFields: INodeProperties[] = [ name: 'binaryProperties', type: 'string', default: 'data', - description: 'Name of the property that holds the binary data. Multiple can be defined separated by comma.', + description: + 'Name of the property that holds the binary data. Multiple can be defined separated by comma.', }, { displayName: 'Direct Mention Names or IDs', @@ -209,12 +190,11 @@ export const commentFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getUsers', - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], }, default: [], - description: 'The users that are directly mentioned. Choose from the list, or specify IDs using an expression.', + description: + 'The users that are directly mentioned. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Mark Thread Position', @@ -229,12 +209,11 @@ export const commentFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getUsers', - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], }, default: [], - description: 'The users that will attached to the comment. Choose from the list, or specify IDs using an expression.', + description: + 'The users that will attached to the comment. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Temporary ID', @@ -263,13 +242,8 @@ export const commentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'get', - 'delete', - ], - resource: [ - 'comment', - ], + operation: ['get', 'delete'], + resource: ['comment'], }, }, required: true, @@ -286,12 +260,8 @@ export const commentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'comment', - ], + operation: ['getAll'], + resource: ['comment'], }, }, required: true, @@ -303,12 +273,8 @@ export const commentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'comment', - ], - operation: [ - 'getAll', - ], + resource: ['comment'], + operation: ['getAll'], }, }, default: false, @@ -320,15 +286,9 @@ export const commentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'comment', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['comment'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -346,12 +306,8 @@ export const commentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'comment', - ], - operation: [ - 'getAll', - ], + resource: ['comment'], + operation: ['getAll'], }, }, options: [ @@ -420,12 +376,8 @@ export const commentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'comment', - ], + operation: ['update'], + resource: ['comment'], }, }, required: true, @@ -439,12 +391,8 @@ export const commentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'comment', - ], - operation: [ - 'update', - ], + resource: ['comment'], + operation: ['update'], }, }, options: [ @@ -496,10 +444,7 @@ export const commentFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - action: [ - 'send_reply', - 'prefill_message', - ], + action: ['send_reply', 'prefill_message'], }, }, description: 'The text for the action button', @@ -509,7 +454,8 @@ export const commentFields: INodeProperties[] = [ displayName: 'Type', name: 'type', type: 'options', - description: 'The type of the button. (Currently only action is available).', + description: + 'The type of the button. (Currently only action is available).', options: [ { name: 'Action', @@ -524,9 +470,7 @@ export const commentFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - action: [ - 'open_url', - ], + action: ['open_url'], }, }, description: 'URL to redirect', @@ -541,7 +485,8 @@ export const commentFields: INodeProperties[] = [ name: 'binaryProperties', type: 'string', default: 'data', - description: 'Name of the property that holds the binary data. Multiple can be defined separated by comma.', + description: + 'Name of the property that holds the binary data. Multiple can be defined separated by comma.', }, { displayName: 'Content', @@ -556,12 +501,11 @@ export const commentFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getUsers', - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], }, default: [], - description: 'The users that are directly mentioned. Choose from the list, or specify IDs using an expression.', + description: + 'The users that are directly mentioned. Choose from the list, or specify IDs using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/Twist/GenericFunctions.ts b/packages/nodes-base/nodes/Twist/GenericFunctions.ts index cece7d263c..0ad9dd44a7 100644 --- a/packages/nodes-base/nodes/Twist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twist/GenericFunctions.ts @@ -1,18 +1,19 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; - -export async function twistApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, qs: IDataObject = {}, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError } from 'n8n-workflow'; +export async function twistApiRequest( + this: IExecuteFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { method, body, @@ -34,7 +35,6 @@ export async function twistApiRequest(this: IExecuteFunctions | ILoadOptionsFunc try { //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'twistOAuth2Api', options); - } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Twist/MessageConversationDescription.ts b/packages/nodes-base/nodes/Twist/MessageConversationDescription.ts index 414320bde1..d254e81469 100644 --- a/packages/nodes-base/nodes/Twist/MessageConversationDescription.ts +++ b/packages/nodes-base/nodes/Twist/MessageConversationDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const messageConversationOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const messageConversationOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'messageConversation', - ], + resource: ['messageConversation'], }, }, options: [ @@ -52,7 +48,6 @@ export const messageConversationOperations: INodeProperties[] = [ ]; export const messageConversationFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* messageConversation:create */ /* -------------------------------------------------------------------------- */ @@ -66,16 +61,13 @@ export const messageConversationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'messageConversation', - ], + operation: ['create'], + resource: ['messageConversation'], }, }, required: true, - description: 'The ID of the workspace. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the workspace. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Conversation Name or ID', @@ -83,23 +75,18 @@ export const messageConversationFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getConversations', - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], }, default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'messageConversation', - ], + operation: ['create'], + resource: ['messageConversation'], }, }, required: true, - description: 'The ID of the conversation. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the conversation. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Content', @@ -108,15 +95,12 @@ export const messageConversationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'messageConversation', - ], + operation: ['create'], + resource: ['messageConversation'], }, }, - description: 'The content of the new message. Mentions can be used as [Name](twist-mention://user_id) for users or [Group name](twist-group-mention://group_id) for groups.', + description: + 'The content of the new message. Mentions can be used as [Name](twist-mention://user_id) for users or [Group name](twist-group-mention://group_id) for groups.', }, { displayName: 'Additional Fields', @@ -124,12 +108,8 @@ export const messageConversationFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'messageConversation', - ], + operation: ['create'], + resource: ['messageConversation'], }, }, default: {}, @@ -184,10 +164,7 @@ export const messageConversationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - action: [ - 'send_reply', - 'prefill_message', - ], + action: ['send_reply', 'prefill_message'], }, }, description: 'The text for the action button', @@ -197,7 +174,8 @@ export const messageConversationFields: INodeProperties[] = [ displayName: 'Type', name: 'type', type: 'options', - description: 'The type of the button. (Currently only action is available).', + description: + 'The type of the button. (Currently only action is available).', options: [ { name: 'Action', @@ -212,9 +190,7 @@ export const messageConversationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - action: [ - 'open_url', - ], + action: ['open_url'], }, }, description: 'URL to redirect', @@ -229,7 +205,8 @@ export const messageConversationFields: INodeProperties[] = [ name: 'binaryProperties', type: 'string', default: 'data', - description: 'Name of the property that holds the binary data. Multiple can be defined separated by comma.', + description: + 'Name of the property that holds the binary data. Multiple can be defined separated by comma.', }, { displayName: 'Direct Mention Names or IDs', @@ -239,7 +216,8 @@ export const messageConversationFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: [], - description: 'The users that are directly mentioned. Choose from the list, or specify IDs using an expression.', + description: + 'The users that are directly mentioned. Choose from the list, or specify IDs using an expression.', }, // { // displayName: 'Direct Group Mentions ', @@ -267,16 +245,13 @@ export const messageConversationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'messageConversation', - ], + operation: ['getAll'], + resource: ['messageConversation'], }, }, required: true, - description: 'The ID of the workspace. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the workspace. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Conversation Name or ID', @@ -284,23 +259,18 @@ export const messageConversationFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getConversations', - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], }, default: '', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'messageConversation', - ], + operation: ['getAll'], + resource: ['messageConversation'], }, }, required: true, - description: 'The ID of the conversation. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the conversation. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Additional Fields', @@ -308,12 +278,8 @@ export const messageConversationFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'messageConversation', - ], + operation: ['getAll'], + resource: ['messageConversation'], }, }, default: {}, @@ -373,13 +339,8 @@ export const messageConversationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'delete', - 'get', - ], - resource: [ - 'messageConversation', - ], + operation: ['delete', 'get'], + resource: ['messageConversation'], }, }, required: true, @@ -396,12 +357,8 @@ export const messageConversationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'messageConversation', - ], + operation: ['update'], + resource: ['messageConversation'], }, }, required: true, @@ -413,12 +370,8 @@ export const messageConversationFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'messageConversation', - ], + operation: ['update'], + resource: ['messageConversation'], }, }, default: {}, @@ -472,10 +425,7 @@ export const messageConversationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - action: [ - 'send_reply', - 'prefill_message', - ], + action: ['send_reply', 'prefill_message'], }, }, description: 'The text for the action button', @@ -485,7 +435,8 @@ export const messageConversationFields: INodeProperties[] = [ displayName: 'Type', name: 'type', type: 'options', - description: 'The type of the button. (Currently only action is available).', + description: + 'The type of the button. (Currently only action is available).', options: [ { name: 'Action', @@ -500,9 +451,7 @@ export const messageConversationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - action: [ - 'open_url', - ], + action: ['open_url'], }, }, description: 'URL to redirect', @@ -517,14 +466,16 @@ export const messageConversationFields: INodeProperties[] = [ name: 'binaryProperties', type: 'string', default: 'data', - description: 'Name of the property that holds the binary data. Multiple can be defined separated by comma.', + description: + 'Name of the property that holds the binary data. Multiple can be defined separated by comma.', }, { displayName: 'Content', name: 'content', type: 'string', default: '', - description: 'The content of the new message. Mentions can be used as [Name](twist-mention://user_id) for users or [Group name](twist-group-mention://group_id) for groups.', + description: + 'The content of the new message. Mentions can be used as [Name](twist-mention://user_id) for users or [Group name](twist-group-mention://group_id) for groups.', }, { displayName: 'Direct Mention Names or IDs', @@ -534,7 +485,8 @@ export const messageConversationFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: [], - description: 'The users that are directly mentioned. Choose from the list, or specify IDs using an expression.', + description: + 'The users that are directly mentioned. Choose from the list, or specify IDs using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/Twist/ThreadDescription.ts b/packages/nodes-base/nodes/Twist/ThreadDescription.ts index 9fea04dede..c0e50d21e8 100644 --- a/packages/nodes-base/nodes/Twist/ThreadDescription.ts +++ b/packages/nodes-base/nodes/Twist/ThreadDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const threadOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const threadOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'thread', - ], + resource: ['thread'], }, }, options: [ @@ -62,12 +58,8 @@ export const threadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'thread', - ], + operation: ['create'], + resource: ['thread'], }, }, required: true, @@ -80,12 +72,8 @@ export const threadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'thread', - ], + operation: ['create'], + resource: ['thread'], }, }, required: true, @@ -98,12 +86,8 @@ export const threadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'thread', - ], + operation: ['create'], + resource: ['thread'], }, }, required: true, @@ -117,12 +101,8 @@ export const threadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'thread', - ], - operation: [ - 'create', - ], + resource: ['thread'], + operation: ['create'], }, }, options: [ @@ -174,10 +154,7 @@ export const threadFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - action: [ - 'send_reply', - 'prefill_message', - ], + action: ['send_reply', 'prefill_message'], }, }, description: 'The text for the action button', @@ -187,7 +164,8 @@ export const threadFields: INodeProperties[] = [ displayName: 'Type', name: 'type', type: 'options', - description: 'The type of the button. (Currently only action is available).', + description: + 'The type of the button. (Currently only action is available).', options: [ { name: 'Action', @@ -202,9 +180,7 @@ export const threadFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - action: [ - 'open_url', - ], + action: ['open_url'], }, }, description: 'URL to redirect', @@ -219,7 +195,8 @@ export const threadFields: INodeProperties[] = [ name: 'binaryProperties', type: 'string', default: 'data', - description: 'Name of the property that holds the binary data. Multiple can be defined separated by comma.', + description: + 'Name of the property that holds the binary data. Multiple can be defined separated by comma.', }, { displayName: 'Direct Mention Names or IDs', @@ -227,12 +204,11 @@ export const threadFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getUsers', - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], }, default: [], - description: 'The users that are directly mentioned. Choose from the list, or specify IDs using an expression.', + description: + 'The users that are directly mentioned. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Recipient Names or IDs', @@ -240,12 +216,11 @@ export const threadFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getUsers', - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], }, default: [], - description: 'The users that will attached to the thread. Choose from the list, or specify IDs using an expression.', + description: + 'The users that will attached to the thread. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Send as Integration', @@ -273,13 +248,8 @@ export const threadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'get', - 'delete', - ], - resource: [ - 'thread', - ], + operation: ['get', 'delete'], + resource: ['thread'], }, }, required: true, @@ -295,12 +265,8 @@ export const threadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'thread', - ], + operation: ['getAll'], + resource: ['thread'], }, }, required: true, @@ -312,12 +278,8 @@ export const threadFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'thread', - ], - operation: [ - 'getAll', - ], + resource: ['thread'], + operation: ['getAll'], }, }, default: false, @@ -329,15 +291,9 @@ export const threadFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'thread', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['thread'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -355,12 +311,8 @@ export const threadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'thread', - ], - operation: [ - 'getAll', - ], + resource: ['thread'], + operation: ['getAll'], }, }, options: [ @@ -390,7 +342,8 @@ export const threadFields: INodeProperties[] = [ }, ], default: '', - description: 'A filter can be one of attached_to_me, everyone and is_starred', + description: + 'A filter can be one of attached_to_me, everyone and is_starred', }, { displayName: 'Newer Than', @@ -419,12 +372,8 @@ export const threadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'thread', - ], + operation: ['update'], + resource: ['thread'], }, }, required: true, @@ -438,12 +387,8 @@ export const threadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'thread', - ], - operation: [ - 'update', - ], + resource: ['thread'], + operation: ['update'], }, }, options: [ @@ -495,10 +440,7 @@ export const threadFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - action: [ - 'send_reply', - 'prefill_message', - ], + action: ['send_reply', 'prefill_message'], }, }, description: 'The text for the action button', @@ -508,7 +450,8 @@ export const threadFields: INodeProperties[] = [ displayName: 'Type', name: 'type', type: 'options', - description: 'The type of the button. (Currently only action is available).', + description: + 'The type of the button. (Currently only action is available).', options: [ { name: 'Action', @@ -523,9 +466,7 @@ export const threadFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - action: [ - 'open_url', - ], + action: ['open_url'], }, }, description: 'URL to redirect', @@ -540,7 +481,8 @@ export const threadFields: INodeProperties[] = [ name: 'binaryProperties', type: 'string', default: 'data', - description: 'Name of the property that holds the binary data. Multiple can be defined separated by comma.', + description: + 'Name of the property that holds the binary data. Multiple can be defined separated by comma.', }, { displayName: 'Content', @@ -555,12 +497,11 @@ export const threadFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getUsers', - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], }, default: [], - description: 'The users that are directly mentioned. Choose from the list, or specify IDs using an expression.', + description: + 'The users that are directly mentioned. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Title', diff --git a/packages/nodes-base/nodes/Twist/Twist.node.ts b/packages/nodes-base/nodes/Twist/Twist.node.ts index 0ce6e57393..de402acd97 100644 --- a/packages/nodes-base/nodes/Twist/Twist.node.ts +++ b/packages/nodes-base/nodes/Twist/Twist.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryData, @@ -14,28 +12,17 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - twistApiRequest, -} from './GenericFunctions'; +import { twistApiRequest } from './GenericFunctions'; -import { - channelFields, - channelOperations, -} from './ChannelDescription'; +import { channelFields, channelOperations } from './ChannelDescription'; import { messageConversationFields, messageConversationOperations, } from './MessageConversationDescription'; -import { - threadFields, - threadOperations -} from './ThreadDescription'; -import { - commentFields, - commentOperations -} from './CommentDescription'; +import { threadFields, threadOperations } from './ThreadDescription'; +import { commentFields, commentOperations } from './CommentDescription'; import { v4 as uuid } from 'uuid'; import moment from 'moment'; @@ -268,35 +255,40 @@ export class Twist implements INodeType { const attachments: IDataObject[] = []; for (const binaryProperty of binaryProperties) { - const item = items[i].binary as IBinaryKeyData; const binaryData = item[binaryProperty] as IBinaryData; if (binaryData === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryProperty}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryProperty}" does not exists on item!`, + { itemIndex: i }, + ); } const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); - attachments.push(await twistApiRequest.call( - this, - 'POST', - '/attachments/upload', - {}, - {}, - { - formData: { - file_name: { - value: dataBuffer, - options: { - filename: binaryData.fileName, + attachments.push( + await twistApiRequest.call( + this, + 'POST', + '/attachments/upload', + {}, + {}, + { + formData: { + file_name: { + value: dataBuffer, + options: { + filename: binaryData.fileName, + }, }, + attachment_id: uuid(), }, - attachment_id: uuid(), }, - }, - )); + ), + ); } body.attachments = attachments; @@ -345,7 +337,7 @@ export class Twist implements INodeType { responseData = await twistApiRequest.call(this, 'GET', '/comments/get', {}, qs); if (qs.as_ids) { - responseData = (responseData as number[]).map(id => ({ ID: id })); + responseData = (responseData as number[]).map((id) => ({ ID: id })); } } //https://developer.twist.com/v3/#update-comment @@ -372,35 +364,40 @@ export class Twist implements INodeType { const attachments: IDataObject[] = []; for (const binaryProperty of binaryProperties) { - const item = items[i].binary as IBinaryKeyData; const binaryData = item[binaryProperty] as IBinaryData; if (binaryData === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryProperty}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryProperty}" does not exists on item!`, + { itemIndex: i }, + ); } const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); - attachments.push(await twistApiRequest.call( - this, - 'POST', - '/attachments/upload', - {}, - {}, - { - formData: { - file_name: { - value: dataBuffer, - options: { - filename: binaryData.fileName, + attachments.push( + await twistApiRequest.call( + this, + 'POST', + '/attachments/upload', + {}, + {}, + { + formData: { + file_name: { + value: dataBuffer, + options: { + filename: binaryData.fileName, + }, }, + attachment_id: uuid(), }, - attachment_id: uuid(), }, - }, - )); + ), + ); } body.attachments = attachments; @@ -446,35 +443,40 @@ export class Twist implements INodeType { const attachments: IDataObject[] = []; for (const binaryProperty of binaryProperties) { - const item = items[i].binary as IBinaryKeyData; const binaryData = item[binaryProperty] as IBinaryData; if (binaryData === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryProperty}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryProperty}" does not exists on item!`, + { itemIndex: i }, + ); } const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); - attachments.push(await twistApiRequest.call( - this, - 'POST', - '/attachments/upload', - {}, - {}, - { - formData: { - file_name: { - value: dataBuffer, - options: { - filename: binaryData.fileName, + attachments.push( + await twistApiRequest.call( + this, + 'POST', + '/attachments/upload', + {}, + {}, + { + formData: { + file_name: { + value: dataBuffer, + options: { + filename: binaryData.fileName, + }, }, + attachment_id: uuid(), }, - attachment_id: uuid(), }, - }, - )); + ), + ); } body.attachments = attachments; @@ -496,13 +498,24 @@ export class Twist implements INodeType { // body.content = `${directGroupMentions.join(' ')} ${body.content}`; // } - responseData = await twistApiRequest.call(this, 'POST', '/conversation_messages/add', body); + responseData = await twistApiRequest.call( + this, + 'POST', + '/conversation_messages/add', + body, + ); } //https://developer.twist.com/v3/#get-message if (operation === 'get') { qs.id = this.getNodeParameter('id', i) as string; - responseData = await twistApiRequest.call(this, 'GET', '/conversation_messages/getone', {}, qs); + responseData = await twistApiRequest.call( + this, + 'GET', + '/conversation_messages/getone', + {}, + qs, + ); } //https://developer.twist.com/v3/#get-all-messages if (operation === 'getAll') { @@ -511,13 +524,25 @@ export class Twist implements INodeType { qs.conversation_id = conversationId; Object.assign(qs, additionalFields); - responseData = await twistApiRequest.call(this, 'GET', '/conversation_messages/get', {}, qs); + responseData = await twistApiRequest.call( + this, + 'GET', + '/conversation_messages/get', + {}, + qs, + ); } //https://developer.twist.com/v3/#remove-message-from-conversation if (operation === 'delete') { qs.id = this.getNodeParameter('id', i) as string; - responseData = await twistApiRequest.call(this, 'POST', '/conversation_messages/remove', {}, qs); + responseData = await twistApiRequest.call( + this, + 'POST', + '/conversation_messages/remove', + {}, + qs, + ); } //https://developer.twist.com/v3/#update-message-in-conversation if (operation === 'update') { @@ -543,35 +568,40 @@ export class Twist implements INodeType { const attachments: IDataObject[] = []; for (const binaryProperty of binaryProperties) { - const item = items[i].binary as IBinaryKeyData; const binaryData = item[binaryProperty] as IBinaryData; if (binaryData === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryProperty}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryProperty}" does not exists on item!`, + { itemIndex: i }, + ); } const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); - attachments.push(await twistApiRequest.call( - this, - 'POST', - '/attachments/upload', - {}, - {}, - { - formData: { - file_name: { - value: dataBuffer, - options: { - filename: binaryData.fileName, + attachments.push( + await twistApiRequest.call( + this, + 'POST', + '/attachments/upload', + {}, + {}, + { + formData: { + file_name: { + value: dataBuffer, + options: { + filename: binaryData.fileName, + }, }, + attachment_id: uuid(), }, - attachment_id: uuid(), }, - }, - )); + ), + ); } body.attachments = attachments; @@ -585,7 +615,12 @@ export class Twist implements INodeType { body.content = `${directMentions.join(' ')} ${body.content}`; } - responseData = await twistApiRequest.call(this, 'POST', '/conversation_messages/update', body); + responseData = await twistApiRequest.call( + this, + 'POST', + '/conversation_messages/update', + body, + ); } } if (resource === 'thread') { @@ -617,35 +652,40 @@ export class Twist implements INodeType { const attachments: IDataObject[] = []; for (const binaryProperty of binaryProperties) { - const item = items[i].binary as IBinaryKeyData; const binaryData = item[binaryProperty] as IBinaryData; if (binaryData === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryProperty}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryProperty}" does not exists on item!`, + { itemIndex: i }, + ); } const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); - attachments.push(await twistApiRequest.call( - this, - 'POST', - '/attachments/upload', - {}, - {}, - { - formData: { - file_name: { - value: dataBuffer, - options: { - filename: binaryData.fileName, + attachments.push( + await twistApiRequest.call( + this, + 'POST', + '/attachments/upload', + {}, + {}, + { + formData: { + file_name: { + value: dataBuffer, + options: { + filename: binaryData.fileName, + }, }, + attachment_id: uuid(), }, - attachment_id: uuid(), }, - }, - )); + ), + ); } body.attachments = attachments; @@ -693,7 +733,7 @@ export class Twist implements INodeType { responseData = await twistApiRequest.call(this, 'GET', '/threads/get', {}, qs); if (qs.as_ids) { - responseData = (responseData as number[]).map(id => ({ ID: id })); + responseData = (responseData as number[]).map((id) => ({ ID: id })); } } //https://developer.twist.com/v3/#update-thread @@ -720,35 +760,40 @@ export class Twist implements INodeType { const attachments: IDataObject[] = []; for (const binaryProperty of binaryProperties) { - const item = items[i].binary as IBinaryKeyData; const binaryData = item[binaryProperty] as IBinaryData; if (binaryData === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryProperty}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryProperty}" does not exists on item!`, + { itemIndex: i }, + ); } const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); - attachments.push(await twistApiRequest.call( - this, - 'POST', - '/attachments/upload', - {}, - {}, - { - formData: { - file_name: { - value: dataBuffer, - options: { - filename: binaryData.fileName, + attachments.push( + await twistApiRequest.call( + this, + 'POST', + '/attachments/upload', + {}, + {}, + { + formData: { + file_name: { + value: dataBuffer, + options: { + filename: binaryData.fileName, + }, }, + attachment_id: uuid(), }, - attachment_id: uuid(), }, - }, - )); + ), + ); } body.attachments = attachments; diff --git a/packages/nodes-base/nodes/Twitter/DirectMessageDescription.ts b/packages/nodes-base/nodes/Twitter/DirectMessageDescription.ts index e4648ee4bf..bd29085644 100644 --- a/packages/nodes-base/nodes/Twitter/DirectMessageDescription.ts +++ b/packages/nodes-base/nodes/Twitter/DirectMessageDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const directMessageOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const directMessageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'directMessage', - ], + resource: ['directMessage'], }, }, options: [ @@ -39,12 +35,8 @@ export const directMessageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'directMessage', - ], + operation: ['create'], + resource: ['directMessage'], }, }, description: 'The ID of the user who should receive the direct message', @@ -60,15 +52,12 @@ export const directMessageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'directMessage', - ], + operation: ['create'], + resource: ['directMessage'], }, }, - description: 'The text of your Direct Message. URL encode as necessary. Max length of 10,000 characters.', + description: + 'The text of your Direct Message. URL encode as necessary. Max length of 10,000 characters.', }, { displayName: 'Additional Fields', @@ -78,12 +67,8 @@ export const directMessageFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'directMessage', - ], + operation: ['create'], + resource: ['directMessage'], }, }, options: [ @@ -92,7 +77,8 @@ export const directMessageFields: INodeProperties[] = [ name: 'attachment', type: 'string', default: 'data', - description: 'Name of the binary property which contain data that should be added to the direct message as attachment', + description: + 'Name of the binary property which contain data that should be added to the direct message as attachment', }, ], }, diff --git a/packages/nodes-base/nodes/Twitter/GenericFunctions.ts b/packages/nodes-base/nodes/Twitter/GenericFunctions.ts index a755540f4e..3bef8e0026 100644 --- a/packages/nodes-base/nodes/Twitter/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twitter/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUrl, -} from 'request'; +import { OptionsWithUrl } from 'request'; import { IExecuteFunctions, @@ -17,7 +15,17 @@ import { NodeOperationError, } from 'n8n-workflow'; -export async function twitterApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function twitterApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { let options: OptionsWithUrl = { method, body, @@ -42,8 +50,16 @@ export async function twitterApiRequest(this: IExecuteFunctions | IExecuteSingle } } -export async function twitterApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function twitterApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -54,10 +70,7 @@ export async function twitterApiRequestAllItems(this: IExecuteFunctions | ILoadO responseData = await twitterApiRequest.call(this, method, endpoint, body, query); query.since_id = responseData.search_metadata.max_id; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData.search_metadata && - responseData.search_metadata.next_results - ); + } while (responseData.search_metadata && responseData.search_metadata.next_results); return returnData; } @@ -68,24 +81,31 @@ export function chunks(buffer: Buffer, chunkSize: number) { let i = 0; while (i < len) { - result.push(buffer.slice(i, i += chunkSize)); + result.push(buffer.slice(i, (i += chunkSize))); } return result; } -export async function uploadAttachments(this: IExecuteFunctions, binaryProperties: string[], items: INodeExecutionData[], i: number) { - +export async function uploadAttachments( + this: IExecuteFunctions, + binaryProperties: string[], + items: INodeExecutionData[], + i: number, +) { const uploadUri = 'https://upload.twitter.com/1.1/media/upload.json'; const media: IDataObject[] = []; for (const binaryPropertyName of binaryProperties) { - const binaryData = items[i].binary as IBinaryKeyData; if (binaryData === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data set. So file can not be written!', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'No binary data set. So file can not be written!', + { itemIndex: i }, + ); } if (!binaryData[binaryPropertyName]) { @@ -96,26 +116,29 @@ export async function uploadAttachments(this: IExecuteFunctions, binaryPropertie let response: IDataObject = {}; const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); - const isAnimatedWebp = (dataBuffer.toString().indexOf('ANMF') !== -1); + const isAnimatedWebp = dataBuffer.toString().indexOf('ANMF') !== -1; const isImage = binaryData[binaryPropertyName].mimeType.includes('image'); if (isImage && isAnimatedWebp) { - throw new NodeOperationError(this.getNode(), 'Animated .webp images are not supported use .gif instead', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Animated .webp images are not supported use .gif instead', + { itemIndex: i }, + ); } if (isImage) { - const attachmentBody = { media_data: binaryData[binaryPropertyName].data, }; - response = await twitterApiRequest.call(this, 'POST', '', {}, {}, uploadUri, { form: attachmentBody }); + response = await twitterApiRequest.call(this, 'POST', '', {}, {}, uploadUri, { + form: attachmentBody, + }); media.push(response); - } else { - // https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload-init const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); @@ -126,7 +149,9 @@ export async function uploadAttachments(this: IExecuteFunctions, binaryPropertie media_type: binaryData[binaryPropertyName].mimeType, }; - response = await twitterApiRequest.call(this, 'POST', '', {}, {}, uploadUri, { form: attachmentBody }); + response = await twitterApiRequest.call(this, 'POST', '', {}, {}, uploadUri, { + form: attachmentBody, + }); const mediaId = response.media_id_string; @@ -137,7 +162,6 @@ export async function uploadAttachments(this: IExecuteFunctions, binaryPropertie let index = 0; for (const binaryPart of binaryParts) { - //https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload-append attachmentBody = { @@ -148,7 +172,9 @@ export async function uploadAttachments(this: IExecuteFunctions, binaryPropertie segment_index: index, }; - response = await twitterApiRequest.call(this, 'POST', '', {}, {}, uploadUri, { form: attachmentBody }); + response = await twitterApiRequest.call(this, 'POST', '', {}, {}, uploadUri, { + form: attachmentBody, + }); index++; } @@ -160,11 +186,13 @@ export async function uploadAttachments(this: IExecuteFunctions, binaryPropertie media_id: mediaId, }; - response = await twitterApiRequest.call(this, 'POST', '', {}, {}, uploadUri, { form: attachmentBody }); + response = await twitterApiRequest.call(this, 'POST', '', {}, {}, uploadUri, { + form: attachmentBody, + }); // data has not been uploaded yet, so wait for it to be ready if (response.processing_info) { - const { check_after_secs } = (response.processing_info as IDataObject); + const { check_after_secs } = response.processing_info as IDataObject; await new Promise((resolve, reject) => { setTimeout(() => { // @ts-ignore diff --git a/packages/nodes-base/nodes/Twitter/TweetDescription.ts b/packages/nodes-base/nodes/Twitter/TweetDescription.ts index d7a79af73d..8f3e21bd7b 100644 --- a/packages/nodes-base/nodes/Twitter/TweetDescription.ts +++ b/packages/nodes-base/nodes/Twitter/TweetDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const tweetOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const tweetOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'tweet', - ], + resource: ['tweet'], }, }, options: [ @@ -66,15 +62,12 @@ export const tweetFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'tweet', - ], + operation: ['create'], + resource: ['tweet'], }, }, - description: 'The text of the status update. URL encode as necessary. t.co link wrapping will affect character counts.', + description: + 'The text of the status update. URL encode as necessary. t.co link wrapping will affect character counts.', }, { displayName: 'Additional Fields', @@ -84,12 +77,8 @@ export const tweetFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'tweet', - ], + operation: ['create'], + resource: ['tweet'], }, }, options: [ @@ -98,14 +87,16 @@ export const tweetFields: INodeProperties[] = [ name: 'attachments', type: 'string', default: 'data', - description: 'Name of the binary properties which contain data which should be added to tweet as attachment. Multiple ones can be comma-separated.', + description: + 'Name of the binary properties which contain data which should be added to tweet as attachment. Multiple ones can be comma-separated.', }, { displayName: 'Display Coordinates', name: 'displayCoordinates', type: 'boolean', default: false, - description: 'Whether or not to put a pin on the exact coordinates a Tweet has been sent from', + description: + 'Whether or not to put a pin on the exact coordinates a Tweet has been sent from', }, { displayName: 'In Reply to Tweet', @@ -151,7 +142,8 @@ export const tweetFields: INodeProperties[] = [ name: 'possiblySensitive', type: 'boolean', default: false, - description: 'Whether you are uploading Tweet media that might be considered sensitive content such as nudity, or medical procedures', + description: + 'Whether you are uploading Tweet media that might be considered sensitive content such as nudity, or medical procedures', }, ], }, @@ -167,12 +159,8 @@ export const tweetFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'tweet', - ], + operation: ['delete'], + resource: ['tweet'], }, }, description: 'The ID of the tweet to delete', @@ -192,15 +180,12 @@ export const tweetFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'tweet', - ], + operation: ['search'], + resource: ['tweet'], }, }, - description: 'A UTF-8, URL-encoded search query of 500 characters maximum, including operators. Queries may additionally be limited by complexity. Check the searching examples here.', + description: + 'A UTF-8, URL-encoded search query of 500 characters maximum, including operators. Queries may additionally be limited by complexity. Check the searching examples here.', }, { displayName: 'Return All', @@ -208,12 +193,8 @@ export const tweetFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'tweet', - ], + operation: ['search'], + resource: ['tweet'], }, }, default: false, @@ -225,15 +206,9 @@ export const tweetFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'tweet', - ], - returnAll: [ - false, - ], + operation: ['search'], + resource: ['tweet'], + returnAll: [false], }, }, typeOptions: { @@ -250,12 +225,8 @@ export const tweetFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'tweet', - ], + operation: ['search'], + resource: ['tweet'], }, }, options: [ @@ -274,7 +245,8 @@ export const tweetFields: INodeProperties[] = [ loadOptionsMethod: 'getLanguages', }, default: '', - description: 'Restricts tweets to the given language, given by an ISO 639-1 code. Language detection is best-effort. Choose from the list, or specify an ID using an expression.', + description: + 'Restricts tweets to the given language, given by an ISO 639-1 code. Language detection is best-effort. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Location', @@ -319,7 +291,8 @@ export const tweetFields: INodeProperties[] = [ }, ], required: true, - description: 'Returns tweets by users located within a given radius of the given latitude/longitude', + description: + 'Returns tweets by users located within a given radius of the given latitude/longitude', default: '', }, { @@ -375,7 +348,8 @@ export const tweetFields: INodeProperties[] = [ }, ], default: 'compat', - description: 'When the extended mode is selected, the response contains the entire untruncated text of the Tweet', + description: + 'When the extended mode is selected, the response contains the entire untruncated text of the Tweet', }, { displayName: 'Until', @@ -398,12 +372,8 @@ export const tweetFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'like', - ], - resource: [ - 'tweet', - ], + operation: ['like'], + resource: ['tweet'], }, }, description: 'The ID of the tweet', @@ -416,12 +386,8 @@ export const tweetFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'like', - ], - resource: [ - 'tweet', - ], + operation: ['like'], + resource: ['tweet'], }, }, options: [ @@ -446,12 +412,8 @@ export const tweetFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'retweet', - ], - resource: [ - 'tweet', - ], + operation: ['retweet'], + resource: ['tweet'], }, }, description: 'The ID of the tweet', @@ -464,12 +426,8 @@ export const tweetFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'retweet', - ], - resource: [ - 'tweet', - ], + operation: ['retweet'], + resource: ['tweet'], }, }, options: [ @@ -478,7 +436,8 @@ export const tweetFields: INodeProperties[] = [ name: 'trimUser', type: 'boolean', default: false, - description: 'Whether each tweet returned in a timeline will include a user object including only the status authors numerical ID', + description: + 'Whether each tweet returned in a timeline will include a user object including only the status authors numerical ID', }, ], }, diff --git a/packages/nodes-base/nodes/Twitter/Twitter.node.ts b/packages/nodes-base/nodes/Twitter/Twitter.node.ts index 544439e132..2a2055e885 100644 --- a/packages/nodes-base/nodes/Twitter/Twitter.node.ts +++ b/packages/nodes-base/nodes/Twitter/Twitter.node.ts @@ -1,8 +1,4 @@ - -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject, @@ -12,15 +8,9 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - directMessageFields, - directMessageOperations, -} from './DirectMessageDescription'; +import { directMessageFields, directMessageOperations } from './DirectMessageDescription'; -import { - tweetFields, - tweetOperations, -} from './TweetDescription'; +import { tweetFields, tweetOperations } from './TweetDescription'; import { twitterApiRequest, @@ -28,9 +18,7 @@ import { uploadAttachments, } from './GenericFunctions'; -import { - ITweet, -} from './TweetInterface'; +import { ITweet } from './TweetInterface'; const ISO6391 = require('iso-639-1'); @@ -138,13 +126,22 @@ export class Twitter implements INodeType { const medias = await uploadAttachments.call(this, attachmentProperties, items, i); //@ts-ignore - body.message_create.message_data.attachment = { type: 'media', media: { id: medias[0].media_id_string } }; + body.message_create.message_data.attachment = { + type: 'media', + //@ts-ignore + media: { id: medias[0].media_id_string }, + }; } else { //@ts-ignore delete body.message_create.message_data.attachment; } - responseData = await twitterApiRequest.call(this, 'POST', '/direct_messages/events/new.json', { event: body }); + responseData = await twitterApiRequest.call( + this, + 'POST', + '/direct_messages/events/new.json', + { event: body }, + ); responseData = responseData.event; } @@ -164,7 +161,6 @@ export class Twitter implements INodeType { } if (additionalFields.attachments) { - const attachments = additionalFields.attachments as string; const attachmentProperties: string[] = attachments.split(',').map((propertyName) => { @@ -173,7 +169,9 @@ export class Twitter implements INodeType { const medias = await uploadAttachments.call(this, attachmentProperties, items, i); - body.media_ids = (medias as IDataObject[]).map((media: IDataObject) => media.media_id_string).join(','); + body.media_ids = (medias as IDataObject[]) + .map((media: IDataObject) => media.media_id_string) + .join(','); } if (additionalFields.possiblySensitive) { @@ -193,13 +191,25 @@ export class Twitter implements INodeType { } } - responseData = await twitterApiRequest.call(this, 'POST', '/statuses/update.json', {}, body as unknown as IDataObject); + responseData = await twitterApiRequest.call( + this, + 'POST', + '/statuses/update.json', + {}, + body as unknown as IDataObject, + ); } // https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-destroy-id if (operation === 'delete') { const tweetId = this.getNodeParameter('tweetId', i) as string; - responseData = await twitterApiRequest.call(this, 'POST', `/statuses/destroy/${tweetId}.json`, {}, {}); + responseData = await twitterApiRequest.call( + this, + 'POST', + `/statuses/destroy/${tweetId}.json`, + {}, + {}, + ); } // https://developer.twitter.com/en/docs/tweets/search/api-reference/get-search-tweets if (operation === 'search') { @@ -230,17 +240,32 @@ export class Twitter implements INodeType { const locationUi = additionalFields.locationFieldsUi as IDataObject; if (locationUi.locationFieldsValues) { const values = locationUi.locationFieldsValues as IDataObject; - qs.geocode = `${values.latitude as string},${values.longitude as string},${values.distance}${values.radius}`; + qs.geocode = `${values.latitude as string},${values.longitude as string},${ + values.distance + }${values.radius}`; } } qs.tweet_mode = additionalFields.tweetMode || 'compat'; if (returnAll) { - responseData = await twitterApiRequestAllItems.call(this, 'statuses', 'GET', '/search/tweets.json', {}, qs); + responseData = await twitterApiRequestAllItems.call( + this, + 'statuses', + 'GET', + '/search/tweets.json', + {}, + qs, + ); } else { qs.count = this.getNodeParameter('limit', 0) as number; - responseData = await twitterApiRequest.call(this, 'GET', '/search/tweets.json', {}, qs); + responseData = await twitterApiRequest.call( + this, + 'GET', + '/search/tweets.json', + {}, + qs, + ); responseData = responseData.statuses; } } @@ -257,7 +282,13 @@ export class Twitter implements INodeType { qs.include_entities = additionalFields.includeEntities as boolean; } - responseData = await twitterApiRequest.call(this, 'POST', '/favorites/create.json', {}, qs); + responseData = await twitterApiRequest.call( + this, + 'POST', + '/favorites/create.json', + {}, + qs, + ); } //https://developer.twitter.com/en/docs/twitter-api/v1/tweets/post-and-engage/api-reference/post-statuses-retweet-id if (operation === 'retweet') { @@ -272,7 +303,13 @@ export class Twitter implements INodeType { qs.trim_user = additionalFields.trimUser as boolean; } - responseData = await twitterApiRequest.call(this, 'POST', `/statuses/retweet/${tweetId}.json`, {}, qs); + responseData = await twitterApiRequest.call( + this, + 'POST', + `/statuses/retweet/${tweetId}.json`, + {}, + qs, + ); } } if (Array.isArray(responseData)) { diff --git a/packages/nodes-base/nodes/Typeform/GenericFunctions.ts b/packages/nodes-base/nodes/Typeform/GenericFunctions.ts index 3ba8a6ebac..bc39e50626 100644 --- a/packages/nodes-base/nodes/Typeform/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Typeform/GenericFunctions.ts @@ -1,20 +1,10 @@ -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - INodePropertyOptions, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { INodePropertyOptions, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IDataObject, -} from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; // Interface in Typeform export interface ITypeformDefinition { @@ -48,7 +38,14 @@ export interface ITypeformAnswerField { * @param {object} body * @returns {Promise} */ -export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, query?: IDataObject): Promise { // tslint:disable-line:no-any +export async function apiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + body: object, + query?: IDataObject, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0); const options: OptionsWithUri = { @@ -64,7 +61,7 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa try { if (authenticationMethod === 'accessToken') { - return await this.helpers.requestWithAuthentication.call(this, 'typeformApi',options); + return await this.helpers.requestWithAuthentication.call(this, 'typeformApi', options); } else { return await this.helpers.requestOAuth2!.call(this, 'typeformOAuth2Api', options); } @@ -73,7 +70,6 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa } } - /** * Make an API request to paginated Typeform endpoint * and return all results @@ -86,8 +82,15 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa * @param {IDataObject} [query] * @returns {Promise} */ -export async function apiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject, dataKey?: string): Promise { // tslint:disable-line:no-any - +export async function apiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + body: IDataObject, + query?: IDataObject, + dataKey?: string, + // tslint:disable-next-line:no-any +): Promise { if (query === undefined) { query = {}; } @@ -107,15 +110,11 @@ export async function apiRequestAllItems(this: IHookFunctions | IExecuteFunction responseData = await apiRequest.call(this, method, endpoint, body, query); returnData.items.push.apply(returnData.items, responseData.items); - } while ( - responseData.page_count !== undefined && - responseData.page_count > query.page - ); + } while (responseData.page_count !== undefined && responseData.page_count > query.page); return returnData; } - /** * Returns all the available forms * diff --git a/packages/nodes-base/nodes/Typeform/TypeformTrigger.node.ts b/packages/nodes-base/nodes/Typeform/TypeformTrigger.node.ts index 9a79661839..acb9c3a650 100644 --- a/packages/nodes-base/nodes/Typeform/TypeformTrigger.node.ts +++ b/packages/nodes-base/nodes/Typeform/TypeformTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -43,9 +40,7 @@ export class TypeformTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, testedBy: 'testTypeformTokenAuth', @@ -55,9 +50,7 @@ export class TypeformTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -97,7 +90,8 @@ export class TypeformTrigger implements INodeType { options: [], default: '', required: true, - description: 'Form which should trigger workflow on submission. Choose from the list, or specify an ID using an expression.', + description: + 'Form which should trigger workflow on submission. Choose from the list, or specify an ID using an expression.', }, { // eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-simplify @@ -106,7 +100,8 @@ export class TypeformTrigger implements INodeType { type: 'boolean', default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-simplify - description: 'Whether to convert the answers to a key:value pair ("FIELD_TITLE":"USER_ANSER") to be easily processable', + description: + 'Whether to convert the answers to a key:value pair ("FIELD_TITLE":"USER_ANSER") to be easily processable', }, { displayName: 'Only Answers', @@ -123,7 +118,10 @@ export class TypeformTrigger implements INodeType { getForms, }, credentialTest: { - async testTypeformTokenAuth(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { + async testTypeformTokenAuth( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { const credentials = credential.data; const options = { @@ -141,7 +139,7 @@ export class TypeformTrigger implements INodeType { message: 'Token is not valid.', }; } - } catch(err) { + } catch (err) { return { status: 'Error', message: `Token is not valid; ${err.message}`, @@ -170,8 +168,7 @@ export class TypeformTrigger implements INodeType { const { items } = await apiRequest.call(this, 'GET', endpoint, {}); for (const item of items) { - if (item.form_id === formId - && item.url === webhookUrl) { + if (item.form_id === formId && item.url === webhookUrl) { webhookData.webhookId = item.tag; return true; } @@ -225,35 +222,33 @@ export class TypeformTrigger implements INodeType { }, }; - - async webhook(this: IWebhookFunctions): Promise { const bodyData = this.getBodyData(); const simplifyAnswers = this.getNodeParameter('simplifyAnswers') as boolean; const onlyAnswers = this.getNodeParameter('onlyAnswers') as boolean; - if (bodyData.form_response === undefined || + if ( + bodyData.form_response === undefined || (bodyData.form_response as IDataObject).definition === undefined || (bodyData.form_response as IDataObject).answers === undefined ) { - throw new NodeApiError(this.getNode(), bodyData as JsonObject, { message: 'Expected definition/answers data is missing!' }); + throw new NodeApiError(this.getNode(), bodyData as JsonObject, { + message: 'Expected definition/answers data is missing!', + }); } const answers = (bodyData.form_response as IDataObject).answers as ITypeformAnswer[]; // Some fields contain lower level fields of which we are only interested of the values - const subvalueKeys = [ - 'label', - 'labels', - ]; + const subvalueKeys = ['label', 'labels']; if (simplifyAnswers === true) { // Convert the answers to simple key -> value pairs const definition = (bodyData.form_response as IDataObject).definition as ITypeformDefinition; // Create a dictionary to get the field title by its ID - const defintitionsById: { [key: string]: string; } = {}; + const defintitionsById: { [key: string]: string } = {}; for (const field of definition.fields) { defintitionsById[field.id] = field.title.replace(/\{\{/g, '[').replace(/\}\}/g, ']'); } @@ -276,9 +271,7 @@ export class TypeformTrigger implements INodeType { if (onlyAnswers === true) { // Only the answers should be returned so do it directly return { - workflowData: [ - this.helpers.returnJsonArray([convertedAnswers]), - ], + workflowData: [this.helpers.returnJsonArray([convertedAnswers])], }; } else { // All data should be returned but the answers should still be @@ -290,18 +283,13 @@ export class TypeformTrigger implements INodeType { if (onlyAnswers === true) { // Return only the answer return { - workflowData: [ - this.helpers.returnJsonArray([answers as unknown as IDataObject]), - ], + workflowData: [this.helpers.returnJsonArray([answers as unknown as IDataObject])], }; } else { // Return all the data that got received return { - workflowData: [ - this.helpers.returnJsonArray([bodyData]), - ], + workflowData: [this.helpers.returnJsonArray([bodyData])], }; } - } } diff --git a/packages/nodes-base/nodes/UProc/GenericFunctions.ts b/packages/nodes-base/nodes/UProc/GenericFunctions.ts index 13d169289c..74d648d941 100644 --- a/packages/nodes-base/nodes/UProc/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UProc/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,11 +7,18 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function uprocApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function uprocApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('uprocApi'); const token = Buffer.from(`${credentials.email}:${credentials.apiKey}`).toString('base64'); const options: OptionsWithUri = { diff --git a/packages/nodes-base/nodes/UProc/GroupDescription.ts b/packages/nodes-base/nodes/UProc/GroupDescription.ts index f453e21c41..0619020e82 100644 --- a/packages/nodes-base/nodes/UProc/GroupDescription.ts +++ b/packages/nodes-base/nodes/UProc/GroupDescription.ts @@ -1,11 +1,6 @@ -import { - IDataObject, - INodeProperties -} from 'n8n-workflow'; +import { IDataObject, INodeProperties } from 'n8n-workflow'; -import { - groups, -} from './Json/Groups'; +import { groups } from './Json/Groups'; const finalGroups = { displayName: 'Resource', diff --git a/packages/nodes-base/nodes/UProc/Json/Groups.ts b/packages/nodes-base/nodes/UProc/Json/Groups.ts index 693bc2d221..6169b64840 100644 --- a/packages/nodes-base/nodes/UProc/Json/Groups.ts +++ b/packages/nodes-base/nodes/UProc/Json/Groups.ts @@ -1 +1,15 @@ -export const groups = {groups: [{'translated':'Audio','name':'audio'},{'translated':'Communication','name':'communication'},{'translated':'Company','name':'company'},{'translated':'Finance','name':'finance'},{'translated':'Geographical','name':'geographic'},{'translated':'Image','name':'image'},{'translated':'Internet','name':'internet'},{'translated':'Personal','name':'personal'},{'translated':'Product','name':'product'},{'translated':'Security','name':'security'},{'translated':'Text','name':'text'}]}; \ No newline at end of file +export const groups = { + groups: [ + { translated: 'Audio', name: 'audio' }, + { translated: 'Communication', name: 'communication' }, + { translated: 'Company', name: 'company' }, + { translated: 'Finance', name: 'finance' }, + { translated: 'Geographical', name: 'geographic' }, + { translated: 'Image', name: 'image' }, + { translated: 'Internet', name: 'internet' }, + { translated: 'Personal', name: 'personal' }, + { translated: 'Product', name: 'product' }, + { translated: 'Security', name: 'security' }, + { translated: 'Text', name: 'text' }, + ], +}; diff --git a/packages/nodes-base/nodes/UProc/ToolDescription.ts b/packages/nodes-base/nodes/UProc/ToolDescription.ts index de3c846e72..7e19a31145 100644 --- a/packages/nodes-base/nodes/UProc/ToolDescription.ts +++ b/packages/nodes-base/nodes/UProc/ToolDescription.ts @@ -1,15 +1,8 @@ -import { - IDataObject, - INodeProperties -} from 'n8n-workflow'; +import { IDataObject, INodeProperties } from 'n8n-workflow'; -import { - groups, -} from './Json/Groups'; +import { groups } from './Json/Groups'; -import { - tools, -} from './Json/Tools'; +import { tools } from './Json/Tools'; function capitalize(str: string): string { if (!str) { @@ -29,9 +22,7 @@ for (const group of (groups as IDataObject).groups as IDataObject[]) { description: 'The Operation to consume', displayOptions: { show: { - group: [ - group.name, - ], + group: [group.name], }, }, default: '', @@ -41,7 +32,13 @@ for (const group of (groups as IDataObject).groups as IDataObject[]) { const options = []; for (const tool of (tools as IDataObject).processors as IDataObject[]) { if (tool.g === group.name) { - const link = 'https://app.uproc.io/#/tools/processor/' + (tool.k as string).replace(/([A-Z]+)/g, '-$1').toLowerCase().replace('-', '/').replace('-', '/'); + const link = + 'https://app.uproc.io/#/tools/processor/' + + (tool.k as string) + .replace(/([A-Z]+)/g, '-$1') + .toLowerCase() + .replace('-', '/') + .replace('-', '/'); const option = { name: tool.d as string, value: tool.k, @@ -52,8 +49,8 @@ for (const group of (groups as IDataObject).groups as IDataObject[]) { } //Tool - item.options = (options.sort((a, b) => (a.name > b.name) ? 1 : -1) as any); // tslint:disable-line:no-any - item.default = (options[0].value as string); + item.options = options.sort((a, b) => (a.name > b.name ? 1 : -1)) as any; // tslint:disable-line:no-any + item.default = options[0].value as string; operations.push(item); } @@ -81,9 +78,7 @@ for (const tool of (tools as IDataObject).processors as IDataObject[]) { //@ts-ignore tool.g, ], - tool: [ - tool.k, - ], + tool: [tool.k], }, }, description: JSON.parse(JSON.stringify(description)), diff --git a/packages/nodes-base/nodes/UProc/UProc.node.ts b/packages/nodes-base/nodes/UProc/UProc.node.ts index 51b2518025..90524b205f 100644 --- a/packages/nodes-base/nodes/UProc/UProc.node.ts +++ b/packages/nodes-base/nodes/UProc/UProc.node.ts @@ -1,27 +1,13 @@ /* eslint-disable n8n-nodes-base/node-filename-against-convention */ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - uprocApiRequest, -} from './GenericFunctions'; +import { uprocApiRequest } from './GenericFunctions'; -import { - groupOptions, -} from './GroupDescription'; +import { groupOptions } from './GroupDescription'; -import { - toolOperations, - toolParameters, -} from './ToolDescription'; +import { toolOperations, toolParameters } from './ToolDescription'; export class UProc implements INodeType { description: INodeTypeDescription = { @@ -99,12 +85,21 @@ export class UProc implements INodeType { [key: string]: any; // tslint:disable-line:no-any } - const fields = toolParameters.filter((field) => { - return field && field.displayOptions && field.displayOptions.show && field.displayOptions.show.group && field.displayOptions.show.tool && - field.displayOptions.show.group.indexOf(group) !== -1 && field.displayOptions.show.tool.indexOf(tool) !== -1; - }).map((field) => { - return field.name; - }); + const fields = toolParameters + .filter((field) => { + return ( + field && + field.displayOptions && + field.displayOptions.show && + field.displayOptions.show.group && + field.displayOptions.show.tool && + field.displayOptions.show.group.indexOf(group) !== -1 && + field.displayOptions.show.tool.indexOf(tool) !== -1 + ); + }) + .map((field) => { + return field.name; + }); const requestPromises = []; for (let i = 0; i < length; i++) { diff --git a/packages/nodes-base/nodes/UnleashedSoftware/GenericFunctions.ts b/packages/nodes-base/nodes/UnleashedSoftware/GenericFunctions.ts index 8627445e13..f9aced9c05 100644 --- a/packages/nodes-base/nodes/UnleashedSoftware/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UnleashedSoftware/GenericFunctions.ts @@ -1,7 +1,4 @@ - -import { - OptionsWithUrl, -} from 'request'; +import { OptionsWithUrl } from 'request'; import { IExecuteFunctions, @@ -10,23 +7,28 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - createHmac, -} from 'crypto'; +import { createHmac } from 'crypto'; import qs from 'qs'; -export async function unleashedApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, query: IDataObject = {}, pageNumber?: number, headers?: object): Promise { // tslint:disable-line:no-any - +export async function unleashedApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + path: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + pageNumber?: number, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const paginatedPath = pageNumber ? `/${path}/${pageNumber}` : `/${path}`; const options: OptionsWithUrl = { headers: { - 'Accept': 'application/json', + Accept: 'application/json', 'Content-Type': 'application/json', }, method, @@ -42,7 +44,7 @@ export async function unleashedApiRequest(this: IHookFunctions | IExecuteFunctio const credentials = await this.getCredentials('unleashedSoftwareApi'); - const signature = createHmac('sha256', (credentials.apiKey as string)) + const signature = createHmac('sha256', credentials.apiKey as string) .update(qs.stringify(query)) .digest('base64'); @@ -58,8 +60,16 @@ export async function unleashedApiRequest(this: IHookFunctions | IExecuteFunctio } } -export async function unleashedApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function unleashedApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; let pageNumber = 1; @@ -70,9 +80,9 @@ export async function unleashedApiRequestAllItems(this: IExecuteFunctions | ILoa responseData = await unleashedApiRequest.call(this, method, endpoint, body, query, pageNumber); returnData.push.apply(returnData, responseData[propertyName]); pageNumber++; - } while ( - (responseData.Pagination.PageNumber as number) < (responseData.Pagination.NumberOfPages as number) + (responseData.Pagination.PageNumber as number) < + (responseData.Pagination.NumberOfPages as number) ); return returnData; } @@ -80,8 +90,9 @@ export async function unleashedApiRequestAllItems(this: IExecuteFunctions | ILoa //.NET code is serializing dates in the following format: "/Date(1586833770780)/" //which is useless on JS side and could not treated as a date for other nodes //so we need to convert all of the fields that has it. -export function convertNETDates(item: { [key: string]: any }) { // tslint:disable-line:no-any - Object.keys(item).forEach(path => { +// tslint:disable-next-line:no-any +export function convertNETDates(item: { [key: string]: any }) { + Object.keys(item).forEach((path) => { const type = typeof item[path] as string; if (type === 'string') { const value = item[path] as string; @@ -89,7 +100,8 @@ export function convertNETDates(item: { [key: string]: any }) { // tslint:disabl if (a) { item[path] = new Date(+a[1]); } - } if (type === 'object' && item[path]) { + } + if (type === 'object' && item[path]) { convertNETDates(item[path]); } }); diff --git a/packages/nodes-base/nodes/UnleashedSoftware/SalesOrderDescription.ts b/packages/nodes-base/nodes/UnleashedSoftware/SalesOrderDescription.ts index 090bcd8bb6..ff7a40fa3b 100644 --- a/packages/nodes-base/nodes/UnleashedSoftware/SalesOrderDescription.ts +++ b/packages/nodes-base/nodes/UnleashedSoftware/SalesOrderDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const salesOrderOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const salesOrderOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'salesOrder', - ], + resource: ['salesOrder'], }, }, options: [ @@ -28,7 +24,6 @@ export const salesOrderOperations: INodeProperties[] = [ ]; export const salesOrderFields: INodeProperties[] = [ - /* ------------------------------------------------------------------------- */ /* salesOrder:getAll */ /* ------------------------------------------------------------------------- */ @@ -38,12 +33,8 @@ export const salesOrderFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'salesOrder', - ], + operation: ['getAll'], + resource: ['salesOrder'], }, }, default: false, @@ -55,15 +46,9 @@ export const salesOrderFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'salesOrder', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['salesOrder'], + returnAll: [false], }, }, typeOptions: { @@ -81,12 +66,8 @@ export const salesOrderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'salesOrder', - ], + operation: ['getAll'], + resource: ['salesOrder'], }, }, options: [ @@ -96,7 +77,8 @@ export const salesOrderFields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX', - description: 'Only returns orders for a specified Customer GUID. The CustomerId can be specified as a list of comma-separated GUIDs.', + description: + 'Only returns orders for a specified Customer GUID. The CustomerId can be specified as a list of comma-separated GUIDs.', }, { displayName: 'Customer Code', @@ -124,7 +106,8 @@ export const salesOrderFields: INodeProperties[] = [ name: 'orderNumber', type: 'string', default: '', - description: 'Returns a single order with the specified order number. If set, it overrides all other filters.', + description: + 'Returns a single order with the specified order number. If set, it overrides all other filters.', }, { displayName: 'Order Status', @@ -153,7 +136,8 @@ export const salesOrderFields: INodeProperties[] = [ }, ], default: [], - description: 'Returns orders with the specified status. If no orderStatus filter is specified, then we exclude "Deleted" by default.', + description: + 'Returns orders with the specified status. If no orderStatus filter is specified, then we exclude "Deleted" by default.', }, { displayName: 'Start Date', diff --git a/packages/nodes-base/nodes/UnleashedSoftware/StockOnHandDescription.ts b/packages/nodes-base/nodes/UnleashedSoftware/StockOnHandDescription.ts index 4e1faa30b1..dc525a2638 100644 --- a/packages/nodes-base/nodes/UnleashedSoftware/StockOnHandDescription.ts +++ b/packages/nodes-base/nodes/UnleashedSoftware/StockOnHandDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const stockOnHandOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const stockOnHandOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'stockOnHand', - ], + resource: ['stockOnHand'], }, }, options: [ @@ -34,7 +30,6 @@ export const stockOnHandOperations: INodeProperties[] = [ ]; export const stockOnHandFields: INodeProperties[] = [ - /* ------------------------------------------------------------------------- */ /* stockOnHand:get */ /* ------------------------------------------------------------------------- */ @@ -44,12 +39,8 @@ export const stockOnHandFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'stockOnHand', - ], + operation: ['get'], + resource: ['stockOnHand'], }, }, default: '', @@ -63,12 +54,8 @@ export const stockOnHandFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'stockOnHand', - ], + operation: ['getAll'], + resource: ['stockOnHand'], }, }, default: false, @@ -80,15 +67,9 @@ export const stockOnHandFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'stockOnHand', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['stockOnHand'], + returnAll: [false], }, }, typeOptions: { @@ -106,12 +87,8 @@ export const stockOnHandFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'stockOnHand', - ], + operation: ['getAll'], + resource: ['stockOnHand'], }, }, options: [ @@ -127,7 +104,8 @@ export const stockOnHandFields: INodeProperties[] = [ name: 'IsAssembled', type: 'boolean', default: false, - description: 'Whether the AvailableQty will also include the quantity that can be assembled', + description: + 'Whether the AvailableQty will also include the quantity that can be assembled', }, { displayName: 'Modified Since', @@ -141,14 +119,16 @@ export const stockOnHandFields: INodeProperties[] = [ name: 'orderBy', type: 'string', default: '', - description: 'Orders the list by a specific column, by default the list is ordered by productCode', + description: + 'Orders the list by a specific column, by default the list is ordered by productCode', }, { displayName: 'Product ID', name: 'productId', type: 'string', default: '', - description: 'Returns products with the specific Product Guid. You can enter multiple product IDs separated by commas.', + description: + 'Returns products with the specific Product Guid. You can enter multiple product IDs separated by commas.', }, { displayName: 'Warehouse Code', diff --git a/packages/nodes-base/nodes/UnleashedSoftware/UnleashedSoftware.node.ts b/packages/nodes-base/nodes/UnleashedSoftware/UnleashedSoftware.node.ts index 17222a1c89..403eee6cae 100644 --- a/packages/nodes-base/nodes/UnleashedSoftware/UnleashedSoftware.node.ts +++ b/packages/nodes-base/nodes/UnleashedSoftware/UnleashedSoftware.node.ts @@ -1,13 +1,6 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; import { convertNETDates, @@ -15,15 +8,9 @@ import { unleashedApiRequestAllItems, } from './GenericFunctions'; -import { - salesOrderFields, - salesOrderOperations, -} from './SalesOrderDescription'; +import { salesOrderFields, salesOrderOperations } from './SalesOrderDescription'; -import { - stockOnHandFields, - stockOnHandOperations, -} from './StockOnHandDescription'; +import { stockOnHandFields, stockOnHandOperations } from './StockOnHandDescription'; import moment from 'moment'; @@ -75,7 +62,6 @@ export class UnleashedSoftware implements INodeType { }; async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); const returnData: IDataObject[] = []; const length = items.length; @@ -83,15 +69,12 @@ export class UnleashedSoftware implements INodeType { let responseData; for (let i = 0; i < length; i++) { - const resource = this.getNodeParameter('resource', 0) as string; const operation = this.getNodeParameter('operation', 0) as string; //https://apidocs.unleashedsoftware.com/SalesOrders if (resource === 'salesOrder') { - if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; const filters = this.getNodeParameter('filters', i) as IDataObject; @@ -114,7 +97,14 @@ export class UnleashedSoftware implements INodeType { Object.assign(qs, filters); if (returnAll) { - responseData = await unleashedApiRequestAllItems.call(this, 'Items', 'GET', '/SalesOrders', {}, qs); + responseData = await unleashedApiRequestAllItems.call( + this, + 'Items', + 'GET', + '/SalesOrders', + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.pageSize = limit; @@ -128,7 +118,6 @@ export class UnleashedSoftware implements INodeType { //https://apidocs.unleashedsoftware.com/StockOnHand if (resource === 'stockOnHand') { - if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; @@ -149,7 +138,14 @@ export class UnleashedSoftware implements INodeType { Object.assign(qs, filters); if (returnAll) { - responseData = await unleashedApiRequestAllItems.call(this, 'Items', 'GET', '/StockOnHand', {}, qs); + responseData = await unleashedApiRequestAllItems.call( + this, + 'Items', + 'GET', + '/StockOnHand', + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.pageSize = limit; diff --git a/packages/nodes-base/nodes/Uplead/CompanyDesciption.ts b/packages/nodes-base/nodes/Uplead/CompanyDesciption.ts index 31ca45ac05..76317e3a92 100644 --- a/packages/nodes-base/nodes/Uplead/CompanyDesciption.ts +++ b/packages/nodes-base/nodes/Uplead/CompanyDesciption.ts @@ -8,9 +8,7 @@ export const companyOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'company', - ], + resource: ['company'], }, }, options: [ @@ -25,10 +23,9 @@ export const companyOperations: INodeProperties[] = [ ]; export const companyFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* company:enrich */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* company:enrich */ + /* -------------------------------------------------------------------------- */ { displayName: 'Company', name: 'company', @@ -36,12 +33,8 @@ export const companyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'enrich', - ], + resource: ['company'], + operation: ['enrich'], }, }, description: 'The name of the company (e.g – amazon)', @@ -53,12 +46,8 @@ export const companyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'enrich', - ], + resource: ['company'], + operation: ['enrich'], }, }, description: 'The domain name (e.g – amazon.com)', diff --git a/packages/nodes-base/nodes/Uplead/GenericFunctions.ts b/packages/nodes-base/nodes/Uplead/GenericFunctions.ts index b684265981..8ec8c1d88c 100644 --- a/packages/nodes-base/nodes/Uplead/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Uplead/GenericFunctions.ts @@ -5,16 +5,26 @@ import { IHookFunctions, ILoadOptionsFunctions, } from 'n8n-core'; -import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function upleadApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function upleadApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('upleadApi'); let options: OptionsWithUri = { headers: { Authorization: credentials.apiKey }, method, qs, body, - uri: uri ||`https://api.uplead.com/v2${resource}`, + uri: uri || `https://api.uplead.com/v2${resource}`, json: true, }; options = Object.assign({}, options, option); diff --git a/packages/nodes-base/nodes/Uplead/PersonDescription.ts b/packages/nodes-base/nodes/Uplead/PersonDescription.ts index aea560859f..6a6fbf87a2 100644 --- a/packages/nodes-base/nodes/Uplead/PersonDescription.ts +++ b/packages/nodes-base/nodes/Uplead/PersonDescription.ts @@ -8,9 +8,7 @@ export const personOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'person', - ], + resource: ['person'], }, }, options: [ @@ -25,10 +23,9 @@ export const personOperations: INodeProperties[] = [ ]; export const personFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* person:enrich */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* person:enrich */ + /* -------------------------------------------------------------------------- */ { displayName: 'Email', name: 'email', @@ -37,12 +34,8 @@ export const personFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'enrich', - ], + resource: ['person'], + operation: ['enrich'], }, }, description: 'Email address (e.g – mbenioff@salesforce.com)', @@ -54,12 +47,8 @@ export const personFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'enrich', - ], + resource: ['person'], + operation: ['enrich'], }, }, description: 'First name of the person (e.g – Marc)', @@ -71,12 +60,8 @@ export const personFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'enrich', - ], + resource: ['person'], + operation: ['enrich'], }, }, description: 'Last name of the person (e.g – Benioff)', @@ -88,12 +73,8 @@ export const personFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'enrich', - ], + resource: ['person'], + operation: ['enrich'], }, }, description: 'The domain name (e.g – salesforce.com)', diff --git a/packages/nodes-base/nodes/Uplead/Uplead.node.ts b/packages/nodes-base/nodes/Uplead/Uplead.node.ts index d21638b712..a635935ce5 100644 --- a/packages/nodes-base/nodes/Uplead/Uplead.node.ts +++ b/packages/nodes-base/nodes/Uplead/Uplead.node.ts @@ -1,23 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; -import { - upleadApiRequest, -} from './GenericFunctions'; -import { - companyFields, - companyOperations, -} from './CompanyDesciption'; -import { - personFields, - personOperations, -} from './PersonDescription'; +import { IExecuteFunctions } from 'n8n-core'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; +import { upleadApiRequest } from './GenericFunctions'; +import { companyFields, companyOperations } from './CompanyDesciption'; +import { personFields, personOperations } from './PersonDescription'; export class Uplead implements INodeType { description: INodeTypeDescription = { @@ -50,12 +35,14 @@ export class Uplead implements INodeType { { name: 'Company', value: 'company', - description: 'Company API lets you lookup company data via a domain name or company name', + description: + 'Company API lets you lookup company data via a domain name or company name', }, { name: 'Person', value: 'person', - description: 'Person API lets you lookup a person based on an email address OR based on a domain name + first name + last name', + description: + 'Person API lets you lookup a person based on an email address OR based on a domain name + first name + last name', }, ], default: 'company', diff --git a/packages/nodes-base/nodes/UptimeRobot/AlertContactDescription.ts b/packages/nodes-base/nodes/UptimeRobot/AlertContactDescription.ts index afb70520a9..84cb0bfdcf 100644 --- a/packages/nodes-base/nodes/UptimeRobot/AlertContactDescription.ts +++ b/packages/nodes-base/nodes/UptimeRobot/AlertContactDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const alertContactOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const alertContactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'alertContact', - ], + resource: ['alertContact'], }, }, options: [ @@ -63,12 +59,8 @@ export const alertContactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'alertContact', - ], - operation: [ - 'create', - ], + resource: ['alertContact'], + operation: ['create'], }, }, description: 'The friendly name of the alert contact', @@ -124,12 +116,8 @@ export const alertContactFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'alertContact', - ], - operation: [ - 'create', - ], + resource: ['alertContact'], + operation: ['create'], }, }, description: 'The type of the alert contact', @@ -142,12 +130,8 @@ export const alertContactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'alertContact', - ], - operation: [ - 'create', - ], + resource: ['alertContact'], + operation: ['create'], }, }, description: 'The correspondent value for the alert contact type', @@ -164,13 +148,8 @@ export const alertContactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'alertContact', - ], - operation: [ - 'delete', - 'get', - ], + resource: ['alertContact'], + operation: ['delete', 'get'], }, }, description: 'The ID of the alert contact', @@ -185,12 +164,8 @@ export const alertContactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'alertContact', - ], - operation: [ - 'getAll', - ], + resource: ['alertContact'], + operation: ['getAll'], }, }, default: false, @@ -202,15 +177,9 @@ export const alertContactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'alertContact', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['alertContact'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -228,12 +197,8 @@ export const alertContactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'alertContact', - ], - operation: [ - 'getAll', - ], + resource: ['alertContact'], + operation: ['getAll'], }, }, options: [ @@ -258,12 +223,8 @@ export const alertContactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'alertContact', - ], - operation: [ - 'update', - ], + resource: ['alertContact'], + operation: ['update'], }, }, description: 'The ID of the alert contact', @@ -276,12 +237,8 @@ export const alertContactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'alertContact', - ], - operation: [ - 'update', - ], + resource: ['alertContact'], + operation: ['update'], }, }, options: [ @@ -297,7 +254,8 @@ export const alertContactFields: INodeProperties[] = [ name: 'value', type: 'string', default: '', - description: 'The correspondent value for the alert contact type (can only be used if it is a Webhook alert contact)', + description: + 'The correspondent value for the alert contact type (can only be used if it is a Webhook alert contact)', }, ], }, diff --git a/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts b/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts index 12a08fe687..dfc97e096a 100644 --- a/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts @@ -1,18 +1,18 @@ -import { - OptionsWithUri -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function uptimeRobotApiRequest(this: IExecuteFunctions, method: string, resource: string, body: IDataObject = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}) { +export async function uptimeRobotApiRequest( + this: IExecuteFunctions, + method: string, + resource: string, + body: IDataObject = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, +) { const credentials = await this.getCredentials('uptimeRobotApi'); let options: OptionsWithUri = { diff --git a/packages/nodes-base/nodes/UptimeRobot/MaintenanceWindowDescription.ts b/packages/nodes-base/nodes/UptimeRobot/MaintenanceWindowDescription.ts index ee485d01b6..27ecc42b8e 100644 --- a/packages/nodes-base/nodes/UptimeRobot/MaintenanceWindowDescription.ts +++ b/packages/nodes-base/nodes/UptimeRobot/MaintenanceWindowDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const maintenanceWindowOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const maintenanceWindowOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'maintenanceWindow', - ], + resource: ['maintenanceWindow'], }, }, options: [ @@ -21,7 +17,6 @@ export const maintenanceWindowOperations: INodeProperties[] = [ value: 'create', description: 'Create a maintenance window', action: 'Create a maintenance window', - }, { name: 'Delete', @@ -64,12 +59,8 @@ export const maintenanceWindowFields: INodeProperties[] = [ default: 1, displayOptions: { show: { - resource: [ - 'maintenanceWindow', - ], - operation: [ - 'create', - ], + resource: ['maintenanceWindow'], + operation: ['create'], }, }, description: 'The maintenance window activation period (minutes)', @@ -82,12 +73,8 @@ export const maintenanceWindowFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'maintenanceWindow', - ], - operation: [ - 'create', - ], + resource: ['maintenanceWindow'], + operation: ['create'], }, }, description: 'The friendly name of the maintenance window', @@ -118,12 +105,8 @@ export const maintenanceWindowFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'maintenanceWindow', - ], - operation: [ - 'create', - ], + resource: ['maintenanceWindow'], + operation: ['create'], }, }, description: 'The type of the maintenance window', @@ -134,15 +117,9 @@ export const maintenanceWindowFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'maintenanceWindow', - ], - operation: [ - 'create', - ], - type: [ - 3, - ], + resource: ['maintenanceWindow'], + operation: ['create'], + type: [3], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items @@ -184,15 +161,9 @@ export const maintenanceWindowFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'maintenanceWindow', - ], - operation: [ - 'create', - ], - type: [ - 4, - ], + resource: ['maintenanceWindow'], + operation: ['create'], + type: [4], }, }, typeOptions: { @@ -209,12 +180,8 @@ export const maintenanceWindowFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'maintenanceWindow', - ], - operation: [ - 'create', - ], + resource: ['maintenanceWindow'], + operation: ['create'], }, }, description: 'The maintenance window start datetime', @@ -231,13 +198,8 @@ export const maintenanceWindowFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'maintenanceWindow', - ], - operation: [ - 'delete', - 'get', - ], + resource: ['maintenanceWindow'], + operation: ['delete', 'get'], }, }, description: 'The ID of the maintenance window', @@ -252,12 +214,8 @@ export const maintenanceWindowFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'maintenanceWindow', - ], - operation: [ - 'getAll', - ], + resource: ['maintenanceWindow'], + operation: ['getAll'], }, }, default: false, @@ -269,15 +227,9 @@ export const maintenanceWindowFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'maintenanceWindow', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['maintenanceWindow'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -295,12 +247,8 @@ export const maintenanceWindowFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'maintenanceWindow', - ], - operation: [ - 'getAll', - ], + resource: ['maintenanceWindow'], + operation: ['getAll'], }, }, options: [ @@ -325,12 +273,8 @@ export const maintenanceWindowFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'maintenanceWindow', - ], - operation: [ - 'update', - ], + resource: ['maintenanceWindow'], + operation: ['update'], }, }, description: 'The ID of the maintenance window', @@ -343,12 +287,8 @@ export const maintenanceWindowFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'maintenanceWindow', - ], - operation: [ - 'update', - ], + resource: ['maintenanceWindow'], + operation: ['update'], }, }, description: 'The maintenance window activation period (minutes)', @@ -361,12 +301,8 @@ export const maintenanceWindowFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'maintenanceWindow', - ], - operation: [ - 'update', - ], + resource: ['maintenanceWindow'], + operation: ['update'], }, }, options: [ @@ -415,9 +351,7 @@ export const maintenanceWindowFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - type: [ - 3, - ], + type: [3], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items @@ -459,9 +393,7 @@ export const maintenanceWindowFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - type: [ - 4, - ], + type: [4], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/UptimeRobot/MonitorDescription.ts b/packages/nodes-base/nodes/UptimeRobot/MonitorDescription.ts index a7428f809a..b0523303f9 100644 --- a/packages/nodes-base/nodes/UptimeRobot/MonitorDescription.ts +++ b/packages/nodes-base/nodes/UptimeRobot/MonitorDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const monitorOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const monitorOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'monitor', - ], + resource: ['monitor'], }, }, options: [ @@ -69,12 +65,8 @@ export const monitorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'monitor', - ], - operation: [ - 'create', - ], + resource: ['monitor'], + operation: ['create'], }, }, description: 'The friendly name of the monitor', @@ -109,12 +101,8 @@ export const monitorFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'monitor', - ], - operation: [ - 'create', - ], + resource: ['monitor'], + operation: ['create'], }, }, description: 'The type of the monitor', @@ -127,12 +115,8 @@ export const monitorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'monitor', - ], - operation: [ - 'create', - ], + resource: ['monitor'], + operation: ['create'], }, }, description: 'The URL/IP of the monitor', @@ -149,14 +133,8 @@ export const monitorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'monitor', - ], - operation: [ - 'delete', - 'reset', - 'get', - ], + resource: ['monitor'], + operation: ['delete', 'reset', 'get'], }, }, description: 'The ID of the monitor', @@ -171,12 +149,8 @@ export const monitorFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'monitor', - ], - operation: [ - 'getAll', - ], + resource: ['monitor'], + operation: ['getAll'], }, }, default: false, @@ -188,15 +162,9 @@ export const monitorFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'monitor', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['monitor'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -214,12 +182,8 @@ export const monitorFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'monitor', - ], - operation: [ - 'getAll', - ], + resource: ['monitor'], + operation: ['getAll'], }, }, options: [ @@ -337,12 +301,8 @@ export const monitorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'monitor', - ], - operation: [ - 'update', - ], + resource: ['monitor'], + operation: ['update'], }, }, description: 'The ID of the monitor', @@ -355,12 +315,8 @@ export const monitorFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'monitor', - ], - operation: [ - 'update', - ], + resource: ['monitor'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/UptimeRobot/PublicStatusPageDescription.ts b/packages/nodes-base/nodes/UptimeRobot/PublicStatusPageDescription.ts index 4e087214ae..7c8386f551 100644 --- a/packages/nodes-base/nodes/UptimeRobot/PublicStatusPageDescription.ts +++ b/packages/nodes-base/nodes/UptimeRobot/PublicStatusPageDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const publicStatusPageOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const publicStatusPageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'publicStatusPage', - ], + resource: ['publicStatusPage'], }, }, options: [ @@ -21,7 +17,6 @@ export const publicStatusPageOperations: INodeProperties[] = [ value: 'create', description: 'Create a public status page', action: 'Create a public status page', - }, { name: 'Delete', @@ -65,12 +60,8 @@ export const publicStatusPageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'publicStatusPage', - ], - operation: [ - 'create', - ], + resource: ['publicStatusPage'], + operation: ['create'], }, }, description: 'The friendly name of the status page', @@ -83,15 +74,12 @@ export const publicStatusPageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'publicStatusPage', - ], - operation: [ - 'create', - ], + resource: ['publicStatusPage'], + operation: ['create'], }, }, - description: 'Monitor IDs to be displayed in status page (the values are separated with a dash (-) or 0 for all monitors)', + description: + 'Monitor IDs to be displayed in status page (the values are separated with a dash (-) or 0 for all monitors)', }, { displayName: 'Additional Fields', @@ -101,12 +89,8 @@ export const publicStatusPageFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'publicStatusPage', - ], - operation: [ - 'create', - ], + resource: ['publicStatusPage'], + operation: ['create'], }, }, options: [ @@ -163,13 +147,8 @@ export const publicStatusPageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'publicStatusPage', - ], - operation: [ - 'delete', - 'get', - ], + resource: ['publicStatusPage'], + operation: ['delete', 'get'], }, }, description: 'The ID of the public status page', @@ -184,12 +163,8 @@ export const publicStatusPageFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'publicStatusPage', - ], - operation: [ - 'getAll', - ], + resource: ['publicStatusPage'], + operation: ['getAll'], }, }, default: false, @@ -201,15 +176,9 @@ export const publicStatusPageFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'publicStatusPage', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['publicStatusPage'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -227,12 +196,8 @@ export const publicStatusPageFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'publicStatusPage', - ], - operation: [ - 'getAll', - ], + resource: ['publicStatusPage'], + operation: ['getAll'], }, }, options: [ @@ -257,12 +222,8 @@ export const publicStatusPageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'publicStatusPage', - ], - operation: [ - 'update', - ], + resource: ['publicStatusPage'], + operation: ['update'], }, }, description: 'The ID of the public status page', @@ -275,12 +236,8 @@ export const publicStatusPageFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'publicStatusPage', - ], - operation: [ - 'update', - ], + resource: ['publicStatusPage'], + operation: ['update'], }, }, options: [ @@ -303,7 +260,8 @@ export const publicStatusPageFields: INodeProperties[] = [ name: 'monitors', type: 'string', default: '', - description: 'Monitor IDs to be displayed in status page (the values are separated with a dash (-) or 0 for all monitors)', + description: + 'Monitor IDs to be displayed in status page (the values are separated with a dash (-) or 0 for all monitors)', }, { displayName: 'Password', diff --git a/packages/nodes-base/nodes/UptimeRobot/UptimeRobot.node.ts b/packages/nodes-base/nodes/UptimeRobot/UptimeRobot.node.ts index 66feb85cd8..44e7a5b295 100644 --- a/packages/nodes-base/nodes/UptimeRobot/UptimeRobot.node.ts +++ b/packages/nodes-base/nodes/UptimeRobot/UptimeRobot.node.ts @@ -1,37 +1,19 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - uptimeRobotApiRequest, -} from './GenericFunctions'; +import { uptimeRobotApiRequest } from './GenericFunctions'; -import { - monitorFields, - monitorOperations, -} from './MonitorDescription'; +import { monitorFields, monitorOperations } from './MonitorDescription'; -import { - alertContactFields, - alertContactOperations, -} from './AlertContactDescription'; +import { alertContactFields, alertContactOperations } from './AlertContactDescription'; import { maintenanceWindowFields, maintenanceWindowOperations, } from './MaintenanceWindowDescription'; -import { - publicStatusPageFields, - publicStatusPageOperations, -} from './PublicStatusPageDescription'; +import { publicStatusPageFields, publicStatusPageOperations } from './PublicStatusPageDescription'; import moment from 'moment-timezone'; @@ -95,9 +77,7 @@ export class UptimeRobot implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'account', - ], + resource: ['account'], }, }, options: [ @@ -165,7 +145,6 @@ export class UptimeRobot implements INodeType { } if (operation === 'delete') { - body = { id: this.getNodeParameter('id', i) as string, }; @@ -175,7 +154,9 @@ export class UptimeRobot implements INodeType { } if (operation === 'get') { const monitors = this.getNodeParameter('id', i) as string; - responseData = await uptimeRobotApiRequest.call(this, 'POST', '/getMonitors', { monitors }); + responseData = await uptimeRobotApiRequest.call(this, 'POST', '/getMonitors', { + monitors, + }); responseData = responseData.monitors; } @@ -217,7 +198,6 @@ export class UptimeRobot implements INodeType { } if (operation === 'reset') { - body = { id: this.getNodeParameter('id', i) as string, }; @@ -227,10 +207,9 @@ export class UptimeRobot implements INodeType { } if (operation === 'update') { - body = { id: this.getNodeParameter('id', i) as string, - ...this.getNodeParameter('updateFields', i) as IDataObject, + ...(this.getNodeParameter('updateFields', i) as IDataObject), }; responseData = await uptimeRobotApiRequest.call(this, 'POST', '/editMonitor', body); @@ -240,7 +219,6 @@ export class UptimeRobot implements INodeType { if (resource === 'alertContact') { if (operation === 'create') { - body = { friendly_name: this.getNodeParameter('friendlyName', i) as string, value: this.getNodeParameter('value', i) as string, @@ -251,42 +229,57 @@ export class UptimeRobot implements INodeType { responseData = responseData.alertcontact; } if (operation === 'delete') { - body = { id: this.getNodeParameter('id', i) as string, }; - responseData = await uptimeRobotApiRequest.call(this, 'POST', '/deleteAlertContact', body); + responseData = await uptimeRobotApiRequest.call( + this, + 'POST', + '/deleteAlertContact', + body, + ); responseData = responseData.alert_contact; } if (operation === 'get') { const id = this.getNodeParameter('id', i) as string; - responseData = await uptimeRobotApiRequest.call(this, 'POST', '/getAlertContacts', { alert_contacts: id }); + responseData = await uptimeRobotApiRequest.call(this, 'POST', '/getAlertContacts', { + alert_contacts: id, + }); responseData = responseData.alert_contacts; } if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; body = { - ...this.getNodeParameter('filters', i) as IDataObject, + ...(this.getNodeParameter('filters', i) as IDataObject), }; if (!returnAll) { body.limit = this.getNodeParameter('limit', i) as number; } - responseData = await uptimeRobotApiRequest.call(this, 'POST', '/getAlertContacts', body); + responseData = await uptimeRobotApiRequest.call( + this, + 'POST', + '/getAlertContacts', + body, + ); responseData = responseData.alert_contacts; } if (operation === 'update') { - body = { id: this.getNodeParameter('id', i) as string, - ...this.getNodeParameter('updateFields', i) as IDataObject, + ...(this.getNodeParameter('updateFields', i) as IDataObject), }; - responseData = await uptimeRobotApiRequest.call(this, 'POST', '/editAlertContact', body); + responseData = await uptimeRobotApiRequest.call( + this, + 'POST', + '/editAlertContact', + body, + ); responseData = responseData.alert_contact; } } @@ -295,9 +288,10 @@ export class UptimeRobot implements INodeType { const startTime = this.getNodeParameter('start_time', i) as string; const type = this.getNodeParameter('type', i) as number; - const parsedStartTime = type === 1 - ? moment.tz(startTime, timezone).unix() - : moment.tz(startTime, timezone).format('HH:mm'); + const parsedStartTime = + type === 1 + ? moment.tz(startTime, timezone).unix() + : moment.tz(startTime, timezone).format('HH:mm'); body = { duration: this.getNodeParameter('duration', i) as number, @@ -315,30 +309,28 @@ export class UptimeRobot implements INodeType { responseData = await uptimeRobotApiRequest.call(this, 'POST', '/newMWindow', body); responseData = responseData.mwindow; - } if (operation === 'delete') { - body = { id: this.getNodeParameter('id', i) as string, }; responseData = await uptimeRobotApiRequest.call(this, 'POST', '/deleteMWindow', body); responseData = { status: responseData.message }; - } if (operation === 'get') { const mwindows = this.getNodeParameter('id', i) as string; - responseData = await uptimeRobotApiRequest.call(this, 'POST', '/getMWindows', { mwindows }); + responseData = await uptimeRobotApiRequest.call(this, 'POST', '/getMWindows', { + mwindows, + }); responseData = responseData.mwindows; - } if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; body = { - ...this.getNodeParameter('filters', i) as IDataObject, + ...(this.getNodeParameter('filters', i) as IDataObject), }; if (!returnAll) { @@ -347,14 +339,12 @@ export class UptimeRobot implements INodeType { responseData = await uptimeRobotApiRequest.call(this, 'POST', '/getMWindows', body); responseData = responseData.mwindows; - } if (operation === 'update') { - body = { id: this.getNodeParameter('id', i) as string, duration: this.getNodeParameter('duration', i) as string, - ...this.getNodeParameter('updateFields', i) as IDataObject, + ...(this.getNodeParameter('updateFields', i) as IDataObject), }; if (body.type === 1 && body.start_time) { @@ -373,44 +363,38 @@ export class UptimeRobot implements INodeType { } responseData = await uptimeRobotApiRequest.call(this, 'POST', '/editMWindow', body); responseData = responseData.mwindow; - } } if (resource === 'publicStatusPage') { if (operation === 'create') { - body = { friendly_name: this.getNodeParameter('friendlyName', i) as string, monitors: this.getNodeParameter('monitors', i) as string, - ...this.getNodeParameter('additionalFields', i) as IDataObject, + ...(this.getNodeParameter('additionalFields', i) as IDataObject), }; responseData = await uptimeRobotApiRequest.call(this, 'POST', '/newPSP', body); responseData = responseData.psp; - } if (operation === 'delete') { - body = { id: this.getNodeParameter('id', i) as string, }; responseData = await uptimeRobotApiRequest.call(this, 'POST', '/deletePSP', body); responseData = responseData.psp; - } if (operation === 'get') { const psps = this.getNodeParameter('id', i) as string; responseData = await uptimeRobotApiRequest.call(this, 'POST', '/getPSPs', { psps }); responseData = responseData.psps; - } if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; body = { - ...this.getNodeParameter('filters', i) as IDataObject, + ...(this.getNodeParameter('filters', i) as IDataObject), }; if (!returnAll) { @@ -419,13 +403,11 @@ export class UptimeRobot implements INodeType { responseData = await uptimeRobotApiRequest.call(this, 'POST', '/getPSPs', body); responseData = responseData.psps; - } if (operation === 'update') { - body = { id: this.getNodeParameter('id', i) as string, - ...this.getNodeParameter('updateFields', i) as IDataObject, + ...(this.getNodeParameter('updateFields', i) as IDataObject), }; responseData = await uptimeRobotApiRequest.call(this, 'POST', '/editPSP', body); responseData = responseData.psp; diff --git a/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts b/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts index ea8c9929c2..c3352bdf6b 100644 --- a/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts @@ -1,15 +1,8 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; export async function urlScanIoApiRequest( this: IExecuteFunctions, @@ -35,13 +28,12 @@ export async function urlScanIoApiRequest( } try { - return await this.helpers.requestWithAuthentication.call(this, 'urlScanIoApi',options); + return await this.helpers.requestWithAuthentication.call(this, 'urlScanIoApi', options); } catch (error) { throw new NodeApiError(this.getNode(), error); } } - export async function handleListing( this: IExecuteFunctions, endpoint: string, @@ -64,17 +56,16 @@ export async function handleListing( } if (responseData.results.length) { - const lastResult = responseData.results[responseData.results.length -1]; + const lastResult = responseData.results[responseData.results.length - 1]; qs.search_after = lastResult.sort; } - } while (responseData.total > returnData.length); return returnData; } export const normalizeId = ({ _id, uuid, ...rest }: IDataObject) => { - if (_id) return ({ scanId: _id, ...rest }); - if (uuid) return ({ scanId: uuid, ...rest }); + if (_id) return { scanId: _id, ...rest }; + if (uuid) return { scanId: uuid, ...rest }; return rest; }; diff --git a/packages/nodes-base/nodes/UrlScanIo/UrlScanIo.node.ts b/packages/nodes-base/nodes/UrlScanIo/UrlScanIo.node.ts index 3162458c86..0af23227c6 100644 --- a/packages/nodes-base/nodes/UrlScanIo/UrlScanIo.node.ts +++ b/packages/nodes-base/nodes/UrlScanIo/UrlScanIo.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,20 +8,11 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - scanFields, - scanOperations, -} from './descriptions'; +import { scanFields, scanOperations } from './descriptions'; -import { - handleListing, - normalizeId, - urlScanIoApiRequest, -} from './GenericFunctions'; +import { handleListing, normalizeId, urlScanIoApiRequest } from './GenericFunctions'; export class UrlScanIo implements INodeType { description: INodeTypeDescription = { @@ -33,7 +22,8 @@ export class UrlScanIo implements INodeType { group: ['transform'], version: 1, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', - description: 'Provides various utilities for monitoring websites like health checks or screenshots', + description: + 'Provides various utilities for monitoring websites like health checks or screenshots', defaults: { name: 'urlscan.io', }, @@ -74,26 +64,20 @@ export class UrlScanIo implements INodeType { let responseData; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'scan') { - // ********************************************************************** // scan // ********************************************************************** if (operation === 'get') { - // ---------------------------------------- // scan: get // ---------------------------------------- const scanId = this.getNodeParameter('scanId', i) as string; responseData = await urlScanIoApiRequest.call(this, 'GET', `/result/${scanId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // scan: getAll // ---------------------------------------- @@ -110,19 +94,14 @@ export class UrlScanIo implements INodeType { responseData = await handleListing.call(this, '/search', qs); responseData = responseData.map(normalizeId); - } else if (operation === 'perform') { - // ---------------------------------------- // scan: perform // ---------------------------------------- // https://urlscan.io/docs/search - const { - tags: rawTags, - ...rest - } = this.getNodeParameter('additionalFields', i) as { + const { tags: rawTags, ...rest } = this.getNodeParameter('additionalFields', i) as { customAgent?: string; visibility?: 'public' | 'private' | 'unlisted'; tags?: string; @@ -136,13 +115,12 @@ export class UrlScanIo implements INodeType { }; if (rawTags) { - const tags = rawTags.split(',').map(tag => tag.trim()); + const tags = rawTags.split(',').map((tag) => tag.trim()); if (tags.length > 10) { - throw new NodeOperationError( - this.getNode(), - 'Please enter at most 10 tags', { itemIndex: i }, - ); + throw new NodeOperationError(this.getNode(), 'Please enter at most 10 tags', { + itemIndex: i, + }); } body.tags = tags; @@ -150,15 +128,12 @@ export class UrlScanIo implements INodeType { responseData = await urlScanIoApiRequest.call(this, 'POST', '/scan', body); responseData = normalizeId(responseData); - } - } Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -166,7 +141,6 @@ export class UrlScanIo implements INodeType { } throw error; } - } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/UrlScanIo/descriptions/ScanDescription.ts b/packages/nodes-base/nodes/UrlScanIo/descriptions/ScanDescription.ts index 0147e6ebd8..0cacf66ab0 100644 --- a/packages/nodes-base/nodes/UrlScanIo/descriptions/ScanDescription.ts +++ b/packages/nodes-base/nodes/UrlScanIo/descriptions/ScanDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const scanOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const scanOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'scan', - ], + resource: ['scan'], }, }, options: [ @@ -48,12 +44,8 @@ export const scanFields: INodeProperties[] = [ description: 'ID of the scan to retrieve', displayOptions: { show: { - resource: [ - 'scan', - ], - operation: [ - 'get', - ], + resource: ['scan'], + operation: ['get'], }, }, }, @@ -69,12 +61,8 @@ export const scanFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'scan', - ], - operation: [ - 'getAll', - ], + resource: ['scan'], + operation: ['getAll'], }, }, }, @@ -89,15 +77,9 @@ export const scanFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'scan', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['scan'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -109,12 +91,8 @@ export const scanFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'scan', - ], - operation: [ - 'getAll', - ], + resource: ['scan'], + operation: ['getAll'], }, }, options: [ @@ -122,7 +100,8 @@ export const scanFields: INodeProperties[] = [ displayName: 'Query', name: 'query', type: 'string', - description: 'Query using the Elastic Search Query String syntax. See supported fields in the documentation.', + description: + 'Query using the Elastic Search Query String syntax. See supported fields in the documentation.', default: '', placeholder: 'domain:n8n.io', }, @@ -141,12 +120,8 @@ export const scanFields: INodeProperties[] = [ description: 'URL to scan', displayOptions: { show: { - resource: [ - 'scan', - ], - operation: [ - 'perform', - ], + resource: ['scan'], + operation: ['perform'], }, }, }, @@ -158,19 +133,16 @@ export const scanFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'scan', - ], - operation: [ - 'perform', - ], + resource: ['scan'], + operation: ['perform'], }, }, options: [ { displayName: 'Custom Agent', name: 'customAgent', - description: 'User-Agent header to set for this scan. Defaults to n8n', + description: + 'User-Agent header to set for this scan. Defaults to n8n', type: 'string', default: '', }, @@ -192,7 +164,8 @@ export const scanFields: INodeProperties[] = [ { displayName: 'Tags', name: 'tags', - description: 'Comma-separated list of user-defined tags to add to this scan. Limited to 10 tags.', + description: + 'Comma-separated list of user-defined tags to add to this scan. Limited to 10 tags.', placeholder: 'phishing, malicious', type: 'string', default: '', diff --git a/packages/nodes-base/nodes/Vero/EventDescripion.ts b/packages/nodes-base/nodes/Vero/EventDescripion.ts index bd3e8b7f00..c5794826f7 100644 --- a/packages/nodes-base/nodes/Vero/EventDescripion.ts +++ b/packages/nodes-base/nodes/Vero/EventDescripion.ts @@ -8,9 +8,7 @@ export const eventOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'event', - ], + resource: ['event'], }, }, options: [ @@ -26,10 +24,9 @@ export const eventOperations: INodeProperties[] = [ ]; export const eventFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* event:track */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* event:track */ + /* -------------------------------------------------------------------------- */ { displayName: 'ID', @@ -39,12 +36,8 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'track', - ], + resource: ['event'], + operation: ['track'], }, }, description: 'The unique identifier of the customer', @@ -58,12 +51,8 @@ export const eventFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'track', - ], + resource: ['event'], + operation: ['track'], }, }, }, @@ -75,12 +64,8 @@ export const eventFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'track', - ], + resource: ['event'], + operation: ['track'], }, }, description: 'The name of the event tracked', @@ -92,12 +77,8 @@ export const eventFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'track', - ], + resource: ['event'], + operation: ['track'], }, }, }, @@ -113,15 +94,9 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'track', - ], - jsonParameters: [ - false, - ], + resource: ['event'], + operation: ['track'], + jsonParameters: [false], }, }, options: [ @@ -151,7 +126,8 @@ export const eventFields: INodeProperties[] = [ displayName: 'Extra', name: 'extraAttributesUi', placeholder: 'Add Extra', - description: 'Key value pairs that represent reserved, Vero-specific operators. Refer to the note on “deduplication” below.', + description: + 'Key value pairs that represent reserved, Vero-specific operators. Refer to the note on “deduplication” below.', type: 'fixedCollection', typeOptions: { multipleValues: true, @@ -159,15 +135,9 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'track', - ], - jsonParameters: [ - false, - ], + resource: ['event'], + operation: ['track'], + jsonParameters: [false], }, }, options: [ @@ -204,15 +174,9 @@ export const eventFields: INodeProperties[] = [ description: 'Key value pairs that represent the custom user properties you want to update', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'track', - ], - jsonParameters: [ - true, - ], + resource: ['event'], + operation: ['track'], + jsonParameters: [true], }, }, }, @@ -224,18 +188,13 @@ export const eventFields: INodeProperties[] = [ typeOptions: { alwaysOpenEditWindow: true, }, - description: 'Key value pairs that represent reserved, Vero-specific operators. Refer to the note on “deduplication” below.', + description: + 'Key value pairs that represent reserved, Vero-specific operators. Refer to the note on “deduplication” below.', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'track', - ], - jsonParameters: [ - true, - ], + resource: ['event'], + operation: ['track'], + jsonParameters: [true], }, }, }, diff --git a/packages/nodes-base/nodes/Vero/GenericFunctions.ts b/packages/nodes-base/nodes/Vero/GenericFunctions.ts index ceca8ed940..aeb7593d50 100644 --- a/packages/nodes-base/nodes/Vero/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Vero/GenericFunctions.ts @@ -1,12 +1,18 @@ import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; -import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function veroApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function veroApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('veroApi'); let options: OptionsWithUri = { @@ -17,7 +23,7 @@ export async function veroApiRequest(this: IExecuteFunctions | IExecuteSingleFun auth_token: credentials.authToken, ...body, }, - uri: uri ||`https://api.getvero.com/api/v2${resource}`, + uri: uri || `https://api.getvero.com/api/v2${resource}`, json: true, }; options = Object.assign({}, options, option); @@ -31,7 +37,8 @@ export async function veroApiRequest(this: IExecuteFunctions | IExecuteSingleFun } } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); diff --git a/packages/nodes-base/nodes/Vero/UserDescription.ts b/packages/nodes-base/nodes/Vero/UserDescription.ts index 71fef71350..5530573f93 100644 --- a/packages/nodes-base/nodes/Vero/UserDescription.ts +++ b/packages/nodes-base/nodes/Vero/UserDescription.ts @@ -8,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -24,7 +22,7 @@ export const userOperations: INodeProperties[] = [ name: 'Alias', value: 'alias', description: 'Change a users identifier', - action: 'Change a user\'s alias', + action: "Change a user's alias", }, { name: 'Create or Update', @@ -62,10 +60,9 @@ export const userOperations: INodeProperties[] = [ ]; export const userFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* user:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'ID', @@ -75,12 +72,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, description: 'The unique identifier of the customer', @@ -92,12 +85,8 @@ export const userFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, }, @@ -109,12 +98,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, options: [ @@ -140,15 +125,9 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['user'], + operation: ['create'], + jsonParameters: [false], }, }, options: [ @@ -185,22 +164,16 @@ export const userFields: INodeProperties[] = [ description: 'Key value pairs that represent the custom user properties you want to update', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['user'], + operation: ['create'], + jsonParameters: [true], }, }, }, -/* -------------------------------------------------------------------------- */ -/* user:alias */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:alias */ + /* -------------------------------------------------------------------------- */ { displayName: 'ID', name: 'id', @@ -209,12 +182,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'alias', - ], + resource: ['user'], + operation: ['alias'], }, }, description: 'The old unique identifier of the user', @@ -227,19 +196,15 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'alias', - ], + resource: ['user'], + operation: ['alias'], }, }, description: 'The new unique identifier of the user', }, -/* -------------------------------------------------------------------------- */ -/* user:unsubscribe */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:unsubscribe */ + /* -------------------------------------------------------------------------- */ { displayName: 'ID', name: 'id', @@ -248,19 +213,15 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'unsubscribe', - ], + resource: ['user'], + operation: ['unsubscribe'], }, }, description: 'The unique identifier of the user', }, -/* -------------------------------------------------------------------------- */ -/* user:resubscribe */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:resubscribe */ + /* -------------------------------------------------------------------------- */ { displayName: 'ID', name: 'id', @@ -269,19 +230,15 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'resubscribe', - ], + resource: ['user'], + operation: ['resubscribe'], }, }, description: 'The unique identifier of the user', }, -/* -------------------------------------------------------------------------- */ -/* user:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'ID', name: 'id', @@ -290,19 +247,15 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'delete', - ], + resource: ['user'], + operation: ['delete'], }, }, description: 'The unique identifier of the user', }, -/* -------------------------------------------------------------------------- */ -/* user:addTags */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:addTags */ + /* -------------------------------------------------------------------------- */ { displayName: 'ID', name: 'id', @@ -311,12 +264,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'addTags', - ], + resource: ['user'], + operation: ['addTags'], }, }, description: 'The unique identifier of the user', @@ -329,19 +278,15 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'addTags', - ], + resource: ['user'], + operation: ['addTags'], }, }, description: 'Tags to add separated by ","', }, -/* -------------------------------------------------------------------------- */ -/* user:removeTags */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:removeTags */ + /* -------------------------------------------------------------------------- */ { displayName: 'ID', name: 'id', @@ -350,12 +295,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'removeTags', - ], + resource: ['user'], + operation: ['removeTags'], }, }, description: 'The unique identifier of the user', @@ -368,12 +309,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'removeTags', - ], + resource: ['user'], + operation: ['removeTags'], }, }, description: 'Tags to remove separated by ","', diff --git a/packages/nodes-base/nodes/Vero/Vero.node.ts b/packages/nodes-base/nodes/Vero/Vero.node.ts index 5bbfd5e927..39787de432 100644 --- a/packages/nodes-base/nodes/Vero/Vero.node.ts +++ b/packages/nodes-base/nodes/Vero/Vero.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, INodeExecutionData, @@ -9,18 +7,9 @@ import { NodeApiError, NodeOperationError, } from 'n8n-workflow'; -import { - validateJSON, - veroApiRequest, -} from './GenericFunctions'; -import { - userFields, - userOperations, -} from './UserDescription'; -import { - eventFields, - eventOperations, -} from './EventDescripion'; +import { validateJSON, veroApiRequest } from './GenericFunctions'; +import { userFields, userOperations } from './UserDescription'; +import { eventFields, eventOperations } from './EventDescripion'; export class Vero implements INodeType { description: INodeTypeDescription = { @@ -93,7 +82,9 @@ export class Vero implements INodeType { body.email = additionalFields.email as string; } if (!jsonActive) { - const dataAttributesValues = (this.getNodeParameter('dataAttributesUi', i) as IDataObject).dataAttributesValues as IDataObject[]; + const dataAttributesValues = ( + this.getNodeParameter('dataAttributesUi', i) as IDataObject + ).dataAttributesValues as IDataObject[]; if (dataAttributesValues) { const dataAttributes = {}; for (let i = 0; i < dataAttributesValues.length; i++) { @@ -104,7 +95,9 @@ export class Vero implements INodeType { } } } else { - const dataAttributesJson = validateJSON(this.getNodeParameter('dataAttributesJson', i) as string); + const dataAttributesJson = validateJSON( + this.getNodeParameter('dataAttributesJson', i) as string, + ); if (dataAttributesJson) { // @ts-ignore body.data = dataAttributesJson; @@ -133,9 +126,11 @@ export class Vero implements INodeType { //https://developers.getvero.com/?bash#users-unsubscribe //https://developers.getvero.com/?bash#users-resubscribe //https://developers.getvero.com/?bash#users-delete - if (operation === 'unsubscribe' || + if ( + operation === 'unsubscribe' || operation === 'resubscribe' || - operation === 'delete') { + operation === 'delete' + ) { const id = this.getNodeParameter('id', i) as string; const body = { id, @@ -148,8 +143,7 @@ export class Vero implements INodeType { } //https://developers.getvero.com/?bash#tags-add //https://developers.getvero.com/?bash#tags-remove - if (operation === 'addTags' || - operation === 'removeTags') { + if (operation === 'addTags' || operation === 'removeTags') { const id = this.getNodeParameter('id', i) as string; const tags = (this.getNodeParameter('tags', i) as string).split(',') as string[]; const body = { @@ -184,7 +178,9 @@ export class Vero implements INodeType { email, }; if (!jsonActive) { - const dataAttributesValues = (this.getNodeParameter('dataAttributesUi', i) as IDataObject).dataAttributesValues as IDataObject[]; + const dataAttributesValues = ( + this.getNodeParameter('dataAttributesUi', i) as IDataObject + ).dataAttributesValues as IDataObject[]; if (dataAttributesValues) { const dataAttributes = {}; for (let i = 0; i < dataAttributesValues.length; i++) { @@ -194,7 +190,9 @@ export class Vero implements INodeType { body.data = JSON.stringify(dataAttributes); } } - const extraAttributesValues = (this.getNodeParameter('extraAttributesUi', i) as IDataObject).extraAttributesValues as IDataObject[]; + const extraAttributesValues = ( + this.getNodeParameter('extraAttributesUi', i) as IDataObject + ).extraAttributesValues as IDataObject[]; if (extraAttributesValues) { const extraAttributes = {}; for (let i = 0; i < extraAttributesValues.length; i++) { @@ -205,12 +203,16 @@ export class Vero implements INodeType { } } } else { - const dataAttributesJson = validateJSON(this.getNodeParameter('dataAttributesJson', i) as string); + const dataAttributesJson = validateJSON( + this.getNodeParameter('dataAttributesJson', i) as string, + ); if (dataAttributesJson) { // @ts-ignore body.data = JSON.stringify(dataAttributesJson); } - const extraAttributesJson = validateJSON(this.getNodeParameter('extraAttributesJson', i) as string); + const extraAttributesJson = validateJSON( + this.getNodeParameter('extraAttributesJson', i) as string, + ); if (extraAttributesJson) { // @ts-ignore body.extras = JSON.stringify(extraAttributesJson); diff --git a/packages/nodes-base/nodes/Vonage/GenericFunctions.ts b/packages/nodes-base/nodes/Vonage/GenericFunctions.ts index e462d8c02d..c586b5a800 100644 --- a/packages/nodes-base/nodes/Vonage/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Vonage/GenericFunctions.ts @@ -1,19 +1,19 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; - -export async function vonageApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, option = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError } from 'n8n-workflow'; +export async function vonageApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + path: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + option = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('vonageApi'); body.api_key = credentials.apiKey as string; diff --git a/packages/nodes-base/nodes/Vonage/Vonage.node.ts b/packages/nodes-base/nodes/Vonage/Vonage.node.ts index 330198f4ba..daab2fc53f 100644 --- a/packages/nodes-base/nodes/Vonage/Vonage.node.ts +++ b/packages/nodes-base/nodes/Vonage/Vonage.node.ts @@ -1,17 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - vonageApiRequest, -} from './GenericFunctions'; +import { vonageApiRequest } from './GenericFunctions'; export class Vonage implements INodeType { description: INodeTypeDescription = { @@ -62,9 +53,7 @@ export class Vonage implements INodeType { ], displayOptions: { show: { - resource: [ - 'sms', - ], + resource: ['sms'], }, }, default: 'send', @@ -75,12 +64,8 @@ export class Vonage implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'sms', - ], - operation: [ - 'send', - ], + resource: ['sms'], + operation: ['send'], }, }, default: '', @@ -92,16 +77,13 @@ export class Vonage implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'sms', - ], - operation: [ - 'send', - ], + resource: ['sms'], + operation: ['send'], }, }, default: '', - description: 'The number that the message should be sent to. Numbers are specified in E.164 format.', + description: + 'The number that the message should be sent to. Numbers are specified in E.164 format.', }, // { // displayName: 'Type', @@ -273,12 +255,8 @@ export class Vonage implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'sms', - ], - operation: [ - 'send', - ], + resource: ['sms'], + operation: ['send'], // type: [ // 'text', // 'unicode', @@ -335,12 +313,8 @@ export class Vonage implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'sms', - ], - operation: [ - 'send', - ], + resource: ['sms'], + operation: ['send'], }, }, default: {}, @@ -350,14 +324,16 @@ export class Vonage implements INodeType { name: 'account-ref', type: 'string', default: '', - description: 'An optional string used to identify separate accounts using the SMS endpoint for billing purposes. To use this feature, please email support@nexmo.com.', + description: + 'An optional string used to identify separate accounts using the SMS endpoint for billing purposes. To use this feature, please email support@nexmo.com.', }, { displayName: 'Callback', name: 'callback', type: 'string', default: '', - description: 'The webhook endpoint the delivery receipt for this sms is sent to. This parameter overrides the webhook endpoint you set in Dashboard.', + description: + 'The webhook endpoint the delivery receipt for this sms is sent to. This parameter overrides the webhook endpoint you set in Dashboard.', }, { displayName: 'Client Ref', @@ -396,7 +372,8 @@ export class Vonage implements INodeType { name: 'protocol-id', type: 'string', default: '', - description: 'The value of the protocol identifier to use. Ensure that the value is aligned with udh.', + description: + 'The value of the protocol identifier to use. Ensure that the value is aligned with udh.', }, { displayName: 'Status Report Req', @@ -428,9 +405,7 @@ export class Vonage implements INodeType { for (let i = 0; i < length; i++) { try { if (resource === 'sms') { - if (operation === 'send') { - const from = this.getNodeParameter('from', i) as string; const to = this.getNodeParameter('to', i) as string; diff --git a/packages/nodes-base/nodes/Wait/Wait.node.ts b/packages/nodes-base/nodes/Wait/Wait.node.ts index 9a0ccffe64..9753b2abca 100644 --- a/packages/nodes-base/nodes/Wait/Wait.node.ts +++ b/packages/nodes-base/nodes/Wait/Wait.node.ts @@ -1,8 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions, - WAIT_TIME_UNLIMITED, -} from 'n8n-core'; +import { BINARY_ENCODING, IExecuteFunctions, WAIT_TIME_UNLIMITED } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -62,9 +58,7 @@ export class Wait implements INodeType { required: true, displayOptions: { show: { - incomingAuthentication: [ - 'basicAuth', - ], + incomingAuthentication: ['basicAuth'], }, }, }, @@ -73,9 +67,7 @@ export class Wait implements INodeType { required: true, displayOptions: { show: { - incomingAuthentication: [ - 'headerAuth', - ], + incomingAuthentication: ['headerAuth'], }, }, }, @@ -103,9 +95,7 @@ export class Wait implements INodeType { type: 'options', displayOptions: { show: { - resume: [ - 'webhook', - ], + resume: ['webhook'], }, }, options: [ @@ -123,7 +113,8 @@ export class Wait implements INodeType { }, ], default: 'none', - description: 'If and how incoming resume-webhook-requests to $resumeWebhookUrl should be authenticated for additional security', + description: + 'If and how incoming resume-webhook-requests to $resumeWebhookUrl should be authenticated for additional security', }, { displayName: 'Resume', @@ -159,9 +150,7 @@ export class Wait implements INodeType { type: 'dateTime', displayOptions: { show: { - resume: [ - 'specificTime', - ], + resume: ['specificTime'], }, }, default: '', @@ -177,9 +166,7 @@ export class Wait implements INodeType { type: 'number', displayOptions: { show: { - resume: [ - 'timeInterval', - ], + resume: ['timeInterval'], }, }, typeOptions: { @@ -195,9 +182,7 @@ export class Wait implements INodeType { type: 'options', displayOptions: { show: { - resume: [ - 'timeInterval', - ], + resume: ['timeInterval'], }, }, options: [ @@ -222,19 +207,17 @@ export class Wait implements INodeType { description: 'The time unit of the Wait Amount value', }, - // ---------------------------------- // resume:webhook // ---------------------------------- { - displayName: 'The webhook URL will be generated at run time. It can be referenced with the $resumeWebhookUrl variable. Send it somewhere before getting to this node. More info', + displayName: + 'The webhook URL will be generated at run time. It can be referenced with the $resumeWebhookUrl variable. Send it somewhere before getting to this node. More info', name: 'webhookNotice', type: 'notice', displayOptions: { show: { - resume: [ - 'webhook', - ], + resume: ['webhook'], }, }, default: '', @@ -245,9 +228,7 @@ export class Wait implements INodeType { type: 'options', displayOptions: { show: { - resume: [ - 'webhook', - ], + resume: ['webhook'], }, }, options: [ @@ -285,9 +266,7 @@ export class Wait implements INodeType { type: 'number', displayOptions: { show: { - resume: [ - 'webhook', - ], + resume: ['webhook'], }, }, typeOptions: { @@ -303,9 +282,7 @@ export class Wait implements INodeType { type: 'options', displayOptions: { show: { - resume: [ - 'webhook', - ], + resume: ['webhook'], }, }, options: [ @@ -320,7 +297,7 @@ export class Wait implements INodeType { description: 'Returns data of the last-executed node', }, { - name: 'Using \'Respond to Webhook\' Node', + name: "Using 'Respond to Webhook' Node", value: 'responseNode', description: 'Response defined in that node', }, @@ -334,12 +311,8 @@ export class Wait implements INodeType { type: 'options', displayOptions: { show: { - resume: [ - 'webhook', - ], - responseMode: [ - 'lastNode', - ], + resume: ['webhook'], + responseMode: ['lastNode'], }, }, options: [ @@ -351,16 +324,19 @@ export class Wait implements INodeType { { name: 'First Entry JSON', value: 'firstEntryJson', - description: 'Returns the JSON data of the first entry of the last node. Always returns a JSON object.', + description: + 'Returns the JSON data of the first entry of the last node. Always returns a JSON object.', }, { name: 'First Entry Binary', value: 'firstEntryBinary', - description: 'Returns the binary data of the first entry of the last node. Always returns a binary file.', + description: + 'Returns the binary data of the first entry of the last node. Always returns a binary file.', }, ], default: 'firstEntryJson', - description: 'What data should be returned. If it should return all the items as array or only the first item as object.', + description: + 'What data should be returned. If it should return all the items as array or only the first item as object.', }, { displayName: 'Property Name', @@ -370,12 +346,8 @@ export class Wait implements INodeType { default: 'data', displayOptions: { show: { - resume: [ - 'webhook', - ], - responseData: [ - 'firstEntryBinary', - ], + resume: ['webhook'], + responseData: ['firstEntryBinary'], }, }, description: 'Name of the binary property to return', @@ -386,12 +358,11 @@ export class Wait implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'If no webhook call is received, the workflow will automatically resume execution after the specified limit type', + description: + 'If no webhook call is received, the workflow will automatically resume execution after the specified limit type', displayOptions: { show: { - resume: [ - 'webhook', - ], + resume: ['webhook'], }, }, }, @@ -400,15 +371,12 @@ export class Wait implements INodeType { name: 'limitType', type: 'options', default: 'afterTimeInterval', - description: 'Sets the condition for the execution to resume. Can be a specified date or after some time.', + description: + 'Sets the condition for the execution to resume. Can be a specified date or after some time.', displayOptions: { show: { - limitWaitTime: [ - true, - ], - resume: [ - 'webhook', - ], + limitWaitTime: [true], + resume: ['webhook'], }, }, options: [ @@ -430,15 +398,9 @@ export class Wait implements INodeType { type: 'number', displayOptions: { show: { - limitType: [ - 'afterTimeInterval', - ], - limitWaitTime: [ - true, - ], - resume: [ - 'webhook', - ], + limitType: ['afterTimeInterval'], + limitWaitTime: [true], + resume: ['webhook'], }, }, typeOptions: { @@ -454,15 +416,9 @@ export class Wait implements INodeType { type: 'options', displayOptions: { show: { - limitType: [ - 'afterTimeInterval', - ], - limitWaitTime: [ - true, - ], - resume: [ - 'webhook', - ], + limitType: ['afterTimeInterval'], + limitWaitTime: [true], + resume: ['webhook'], }, }, options: [ @@ -492,15 +448,9 @@ export class Wait implements INodeType { type: 'dateTime', displayOptions: { show: { - limitType: [ - 'atSpecifiedTime', - ], - limitWaitTime: [ - true, - ], - resume: [ - 'webhook', - ], + limitType: ['atSpecifiedTime'], + limitWaitTime: [true], + resume: ['webhook'], }, }, default: '', @@ -512,9 +462,7 @@ export class Wait implements INodeType { type: 'collection', displayOptions: { show: { - resume: [ - 'webhook', - ], + resume: ['webhook'], }, }, placeholder: 'Add Option', @@ -526,11 +474,7 @@ export class Wait implements INodeType { type: 'boolean', displayOptions: { show: { - '/httpMethod': [ - 'PATCH', - 'PUT', - 'POST', - ], + '/httpMethod': ['PATCH', 'PUT', 'POST'], }, }, default: false, @@ -543,19 +487,19 @@ export class Wait implements INodeType { default: 'data', displayOptions: { show: { - binaryData: [ - true, - ], + binaryData: [true], }, }, - description: 'Name of the binary property to which to write the data of the received file. If the data gets received via "Form-Data Multipart" it will be the prefix and a number starting with 0 will be attached to it.', + description: + 'Name of the binary property to which to write the data of the received file. If the data gets received via "Form-Data Multipart" it will be the prefix and a number starting with 0 will be attached to it.', }, { displayName: 'Ignore Bots', name: 'ignoreBots', type: 'boolean', default: false, - description: 'Whether to ignore requests from bots like link previewers and web crawlers', + description: + 'Whether to ignore requests from bots like link previewers and web crawlers', }, { displayName: 'Response Data', @@ -563,9 +507,7 @@ export class Wait implements INodeType { type: 'string', displayOptions: { show: { - '/responseMode': [ - 'onReceived', - ], + '/responseMode': ['onReceived'], }, }, default: '', @@ -578,18 +520,15 @@ export class Wait implements INodeType { type: 'string', displayOptions: { show: { - '/responseData': [ - 'firstEntryJson', - ], - '/responseMode': [ - 'lastNode', - ], + '/responseData': ['firstEntryJson'], + '/responseMode': ['lastNode'], }, }, default: '', placeholder: 'application/xml', // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-json - description: 'Set a custom content-type to return if another one as the "application/json" should be returned', + description: + 'Set a custom content-type to return if another one as the "application/json" should be returned', }, { displayName: 'Response Headers', @@ -630,12 +569,8 @@ export class Wait implements INodeType { type: 'string', displayOptions: { show: { - '/responseData': [ - 'firstEntryJson', - ], - '/responseMode': [ - 'lastNode', - ], + '/responseData': ['firstEntryJson'], + '/responseMode': ['lastNode'], }, }, default: 'data', @@ -647,7 +582,8 @@ export class Wait implements INodeType { type: 'string', default: '', placeholder: 'webhook', - description: 'This suffix path will be appended to the restart URL. Helpful when using multiple wait nodes. Note: Does not support expressions.', + description: + 'This suffix path will be appended to the restart URL. Helpful when using multiple wait nodes. Note: Does not support expressions.', }, // { // displayName: 'Raw Body', @@ -665,7 +601,6 @@ export class Wait implements INodeType { // }, ], }, - ], }; @@ -705,7 +640,10 @@ export class Wait implements INodeType { return authorizationError(resp, realm, 401); } - if (basicAuthData.name !== httpBasicAuth!.user || basicAuthData.pass !== httpBasicAuth!.password) { + if ( + basicAuthData.name !== httpBasicAuth!.user || + basicAuthData.pass !== httpBasicAuth!.password + ) { // Provided authentication data is wrong return authorizationError(resp, realm, 403); } @@ -724,9 +662,12 @@ export class Wait implements INodeType { return authorizationError(resp, realm, 500, 'No authentication data defined on node!'); } const headerName = (httpHeaderAuth.name as string).toLowerCase(); - const headerValue = (httpHeaderAuth.value as string); + const headerValue = httpHeaderAuth.value as string; - if (!headers.hasOwnProperty(headerName) || (headers as IDataObject)[headerName] !== headerValue) { + if ( + !headers.hasOwnProperty(headerName) || + (headers as IDataObject)[headerName] !== headerValue + ) { // Provided authentication data is wrong return authorizationError(resp, realm, 403); } @@ -739,7 +680,6 @@ export class Wait implements INodeType { const form = new formidable.IncomingForm({ multiples: true }); return new Promise((resolve, reject) => { - form.parse(req, async (err, data, files) => { const returnItem: INodeExecutionData = { binary: {}, @@ -756,7 +696,7 @@ export class Wait implements INodeType { const processFiles: formidable.File[] = []; let multiFile = false; if (Array.isArray(files[xfile])) { - processFiles.push(...files[xfile] as formidable.File[]); + processFiles.push(...(files[xfile] as formidable.File[])); multiFile = true; } else { processFiles.push(files[xfile] as formidable.File); @@ -778,20 +718,19 @@ export class Wait implements INodeType { const fileJson = file.toJSON() as unknown as IDataObject; const fileContent = await fs.promises.readFile(file.path); - returnItem.binary![binaryPropertyName] = await this.helpers.prepareBinaryData(Buffer.from(fileContent), fileJson.name as string, fileJson.type as string); + returnItem.binary![binaryPropertyName] = await this.helpers.prepareBinaryData( + Buffer.from(fileContent), + fileJson.name as string, + fileJson.type as string, + ); count += 1; } } resolve({ - workflowData: [ - [ - returnItem, - ], - ], + workflowData: [[returnItem]], }); }); - }); } @@ -815,14 +754,12 @@ export class Wait implements INodeType { }, }; - returnItem.binary![binaryPropertyName as string] = await this.helpers.prepareBinaryData(Buffer.concat(data)); + returnItem.binary![binaryPropertyName as string] = await this.helpers.prepareBinaryData( + Buffer.concat(data), + ); return resolve({ - workflowData: [ - [ - returnItem, - ], - ], + workflowData: [[returnItem]], }); }); @@ -858,15 +795,10 @@ export class Wait implements INodeType { return { webhookResponse, - workflowData: [ - [ - response, - ], - ], + workflowData: [[response]], }; } - async execute(this: IExecuteFunctions): Promise { const resume = this.getNodeParameter('resume', 0) as string; @@ -921,7 +853,6 @@ export class Wait implements INodeType { waitAmount *= 1000; waitTill = new Date(new Date().getTime() + waitAmount); - } else { // resume: dateTime const dateTime = this.getNodeParameter('dateTime', 0) as string; diff --git a/packages/nodes-base/nodes/Webflow/GenericFunctions.ts b/packages/nodes-base/nodes/Webflow/GenericFunctions.ts index a4cb4e4795..aa77597bee 100644 --- a/packages/nodes-base/nodes/Webflow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Webflow/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,10 +7,7 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; export async function webflowApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, @@ -34,7 +29,6 @@ export async function webflowApiRequest( credentialsType = 'webflowOAuth2Api'; } - let options: OptionsWithUri = { headers: { 'accept-version': '1.0.0', @@ -68,7 +62,6 @@ export async function webflowApiRequestAllItems( body: IDataObject = {}, query: IDataObject = {}, ) { - const returnData: IDataObject[] = []; let responseData; @@ -82,10 +75,7 @@ export async function webflowApiRequestAllItems( query.offset += query.limit; } returnData.push.apply(returnData, responseData.items); - } while ( - returnData.length < responseData.total - ); + } while (returnData.length < responseData.total); return returnData; } - diff --git a/packages/nodes-base/nodes/Webflow/ItemDescription.ts b/packages/nodes-base/nodes/Webflow/ItemDescription.ts index 710af77e65..bc9132c30d 100644 --- a/packages/nodes-base/nodes/Webflow/ItemDescription.ts +++ b/packages/nodes-base/nodes/Webflow/ItemDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const itemOperations: INodeProperties[] = [ { @@ -38,9 +36,7 @@ export const itemOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'item', - ], + resource: ['item'], }, }, }, @@ -61,15 +57,12 @@ export const itemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'create', - ], + resource: ['item'], + operation: ['create'], }, }, - description: 'ID of the site containing the collection whose items to add to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the site containing the collection whose items to add to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Collection Name or ID', @@ -78,22 +71,17 @@ export const itemFields: INodeProperties[] = [ required: true, typeOptions: { loadOptionsMethod: 'getCollections', - loadOptionsDependsOn: [ - 'siteId', - ], + loadOptionsDependsOn: ['siteId'], }, default: '', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'create', - ], + resource: ['item'], + operation: ['create'], }, }, - description: 'ID of the collection to add an item to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the collection to add an item to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Live', @@ -103,12 +91,8 @@ export const itemFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'create', - ], + resource: ['item'], + operation: ['create'], }, }, description: 'Whether the item should be published on the live site', @@ -124,12 +108,8 @@ export const itemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'create', - ], + resource: ['item'], + operation: ['create'], }, }, options: [ @@ -143,12 +123,11 @@ export const itemFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getFields', - loadOptionsDependsOn: [ - 'collectionId', - ], + loadOptionsDependsOn: ['collectionId'], }, default: '', - description: 'Field to set for the item to create. Choose from the list, or specify an ID using an expression.', + description: + 'Field to set for the item to create. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Field Value', @@ -176,16 +155,12 @@ export const itemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'delete', - 'get', - ], + resource: ['item'], + operation: ['delete', 'get'], }, }, - description: 'ID of the site containing the collection whose items to operate on. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the site containing the collection whose items to operate on. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Collection Name or ID', @@ -194,23 +169,17 @@ export const itemFields: INodeProperties[] = [ required: true, typeOptions: { loadOptionsMethod: 'getCollections', - loadOptionsDependsOn: [ - 'siteId', - ], + loadOptionsDependsOn: ['siteId'], }, default: '', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'delete', - 'get', - ], + resource: ['item'], + operation: ['delete', 'get'], }, }, - description: 'ID of the collection whose items to operate on. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the collection whose items to operate on. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Item ID', @@ -220,13 +189,8 @@ export const itemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'delete', - 'get', - ], + resource: ['item'], + operation: ['delete', 'get'], }, }, description: 'ID of the item to operate on', @@ -245,15 +209,12 @@ export const itemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'update', - ], + resource: ['item'], + operation: ['update'], }, }, - description: 'ID of the site containing the collection whose items to update. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the site containing the collection whose items to update. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Collection Name or ID', @@ -262,22 +223,17 @@ export const itemFields: INodeProperties[] = [ required: true, typeOptions: { loadOptionsMethod: 'getCollections', - loadOptionsDependsOn: [ - 'siteId', - ], + loadOptionsDependsOn: ['siteId'], }, default: '', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'update', - ], + resource: ['item'], + operation: ['update'], }, }, - description: 'ID of the collection whose items to update. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the collection whose items to update. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Item ID', @@ -287,12 +243,8 @@ export const itemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'update', - ], + resource: ['item'], + operation: ['update'], }, }, description: 'ID of the item to update', @@ -305,12 +257,8 @@ export const itemFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'update', - ], + resource: ['item'], + operation: ['update'], }, }, description: 'Whether the item should be published on the live site', @@ -326,12 +274,8 @@ export const itemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'update', - ], + resource: ['item'], + operation: ['update'], }, }, options: [ @@ -345,12 +289,11 @@ export const itemFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getFields', - loadOptionsDependsOn: [ - 'collectionId', - ], + loadOptionsDependsOn: ['collectionId'], }, default: '', - description: 'Field to set for the item to update. Choose from the list, or specify an ID using an expression.', + description: + 'Field to set for the item to update. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Field Value', @@ -377,15 +320,12 @@ export const itemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'getAll', - ], + resource: ['item'], + operation: ['getAll'], }, }, - description: 'ID of the site containing the collection whose items to retrieve. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the site containing the collection whose items to retrieve. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Collection Name or ID', @@ -394,22 +334,17 @@ export const itemFields: INodeProperties[] = [ required: true, typeOptions: { loadOptionsMethod: 'getCollections', - loadOptionsDependsOn: [ - 'siteId', - ], + loadOptionsDependsOn: ['siteId'], }, default: '', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'getAll', - ], + resource: ['item'], + operation: ['getAll'], }, }, - description: 'ID of the collection whose items to retrieve. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the collection whose items to retrieve. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -417,12 +352,8 @@ export const itemFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'getAll', - ], + resource: ['item'], + operation: ['getAll'], }, }, default: false, @@ -434,15 +365,9 @@ export const itemFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['item'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Webflow/Webflow.node.ts b/packages/nodes-base/nodes/Webflow/Webflow.node.ts index 5579fa64e8..67894654e0 100644 --- a/packages/nodes-base/nodes/Webflow/Webflow.node.ts +++ b/packages/nodes-base/nodes/Webflow/Webflow.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,15 +9,9 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - webflowApiRequest, - webflowApiRequestAllItems, -} from './GenericFunctions'; +import { webflowApiRequest, webflowApiRequestAllItems } from './GenericFunctions'; -import { - itemFields, - itemOperations, -} from './ItemDescription'; +import { itemFields, itemOperations } from './ItemDescription'; export class Webflow implements INodeType { description: INodeTypeDescription = { @@ -41,9 +33,7 @@ export class Webflow implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -52,9 +42,7 @@ export class Webflow implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -110,7 +98,11 @@ export class Webflow implements INodeType { async getCollections(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const siteId = this.getCurrentNodeParameter('siteId'); - const collections = await webflowApiRequest.call(this, 'GET', `/sites/${siteId}/collections`); + const collections = await webflowApiRequest.call( + this, + 'GET', + `/sites/${siteId}/collections`, + ); for (const collection of collections) { returnData.push({ name: collection.name, @@ -122,10 +114,14 @@ export class Webflow implements INodeType { async getFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const collectionId = this.getCurrentNodeParameter('collectionId'); - const { fields } = await webflowApiRequest.call(this, 'GET', `/collections/${collectionId}`); + const { fields } = await webflowApiRequest.call( + this, + 'GET', + `/collections/${collectionId}`, + ); for (const field of fields) { returnData.push({ - name: `${field.name} (${field.type}) ${(field.required) ? ' (required)' : ''}`, + name: `${field.name} (${field.type}) ${field.required ? ' (required)' : ''}`, value: field.slug, }); } @@ -144,10 +140,8 @@ export class Webflow implements INodeType { const returnData: IDataObject[] = []; for (let i = 0; i < items.length; i++) { - try { if (resource === 'item') { - // ********************************************************************* // item // ********************************************************************* @@ -155,7 +149,6 @@ export class Webflow implements INodeType { // https://developers.webflow.com/#item-model if (operation === 'create') { - // ---------------------------------- // item: create // ---------------------------------- @@ -164,22 +157,30 @@ export class Webflow implements INodeType { const collectionId = this.getNodeParameter('collectionId', i) as string; - const properties = this.getNodeParameter('fieldsUi.fieldValues', i, []) as IDataObject[]; + const properties = this.getNodeParameter( + 'fieldsUi.fieldValues', + i, + [], + ) as IDataObject[]; const live = this.getNodeParameter('live', i) as boolean; const fields = {} as IDataObject; - properties.forEach(data => (fields[data.fieldId as string] = data.fieldValue)); + properties.forEach((data) => (fields[data.fieldId as string] = data.fieldValue)); const body: IDataObject = { fields, }; - responseData = await webflowApiRequest.call(this, 'POST', `/collections/${collectionId}/items`, body, { live }); - + responseData = await webflowApiRequest.call( + this, + 'POST', + `/collections/${collectionId}/items`, + body, + { live }, + ); } else if (operation === 'delete') { - // ---------------------------------- // item: delete // ---------------------------------- @@ -188,10 +189,12 @@ export class Webflow implements INodeType { const collectionId = this.getNodeParameter('collectionId', i) as string; const itemId = this.getNodeParameter('itemId', i) as string; - responseData = await webflowApiRequest.call(this, 'DELETE', `/collections/${collectionId}/items/${itemId}`); - + responseData = await webflowApiRequest.call( + this, + 'DELETE', + `/collections/${collectionId}/items/${itemId}`, + ); } else if (operation === 'get') { - // ---------------------------------- // item: get // ---------------------------------- @@ -200,11 +203,13 @@ export class Webflow implements INodeType { const collectionId = this.getNodeParameter('collectionId', i) as string; const itemId = this.getNodeParameter('itemId', i) as string; - responseData = await webflowApiRequest.call(this, 'GET', `/collections/${collectionId}/items/${itemId}`); + responseData = await webflowApiRequest.call( + this, + 'GET', + `/collections/${collectionId}/items/${itemId}`, + ); responseData = responseData.items; - } else if (operation === 'getAll') { - // ---------------------------------- // item: getAll // ---------------------------------- @@ -216,15 +221,25 @@ export class Webflow implements INodeType { const qs: IDataObject = {}; if (returnAll === true) { - responseData = await webflowApiRequestAllItems.call(this, 'GET', `/collections/${collectionId}/items`, {}, qs); + responseData = await webflowApiRequestAllItems.call( + this, + 'GET', + `/collections/${collectionId}/items`, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; - responseData = await webflowApiRequest.call(this, 'GET', `/collections/${collectionId}/items`, {}, qs); + responseData = await webflowApiRequest.call( + this, + 'GET', + `/collections/${collectionId}/items`, + {}, + qs, + ); responseData = responseData.items; } - } else if (operation === 'update') { - // ---------------------------------- // item: update // ---------------------------------- @@ -235,19 +250,29 @@ export class Webflow implements INodeType { const itemId = this.getNodeParameter('itemId', i) as string; - const properties = this.getNodeParameter('fieldsUi.fieldValues', i, []) as IDataObject[]; + const properties = this.getNodeParameter( + 'fieldsUi.fieldValues', + i, + [], + ) as IDataObject[]; const live = this.getNodeParameter('live', i) as boolean; const fields = {} as IDataObject; - properties.forEach(data => (fields[data.fieldId as string] = data.fieldValue)); + properties.forEach((data) => (fields[data.fieldId as string] = data.fieldValue)); const body: IDataObject = { fields, }; - responseData = await webflowApiRequest.call(this, 'PUT', `/collections/${collectionId}/items/${itemId}`, body, { live }); + responseData = await webflowApiRequest.call( + this, + 'PUT', + `/collections/${collectionId}/items/${itemId}`, + body, + { live }, + ); } } diff --git a/packages/nodes-base/nodes/Webflow/WebflowTrigger.node.ts b/packages/nodes-base/nodes/Webflow/WebflowTrigger.node.ts index f1d9a4c49b..403077681a 100644 --- a/packages/nodes-base/nodes/Webflow/WebflowTrigger.node.ts +++ b/packages/nodes-base/nodes/Webflow/WebflowTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -12,9 +9,7 @@ import { IWebhookResponseData, } from 'n8n-workflow'; -import { - webflowApiRequest, -} from './GenericFunctions'; +import { webflowApiRequest } from './GenericFunctions'; export class WebflowTrigger implements INodeType { description: INodeTypeDescription = { @@ -35,9 +30,7 @@ export class WebflowTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -46,9 +39,7 @@ export class WebflowTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -87,7 +78,8 @@ export class WebflowTrigger implements INodeType { typeOptions: { loadOptionsMethod: 'getSites', }, - description: 'Site that will trigger the events. Choose from the list, or specify an ID using an expression.', + description: + 'Site that will trigger the events. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Event', @@ -212,7 +204,11 @@ export class WebflowTrigger implements INodeType { const siteId = this.getNodeParameter('site') as string; const event = this.getNodeParameter('event') as string; - const registeredWebhooks = await webflowApiRequest.call(this, 'GET', `/sites/${siteId}/webhooks`) as IDataObject[]; + const registeredWebhooks = (await webflowApiRequest.call( + this, + 'GET', + `/sites/${siteId}/webhooks`, + )) as IDataObject[]; for (const webhook of registeredWebhooks) { if (webhook.url === webhookUrl && webhook.triggerType === event) { @@ -234,7 +230,6 @@ export class WebflowTrigger implements INodeType { site_id: siteId, triggerType: event, url: webhookUrl, - }; // if (event.startsWith('collection')) { @@ -273,9 +268,7 @@ export class WebflowTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/Webhook/Webhook.node.ts b/packages/nodes-base/nodes/Webhook/Webhook.node.ts index d995998e7d..d25a1997a6 100644 --- a/packages/nodes-base/nodes/Webhook/Webhook.node.ts +++ b/packages/nodes-base/nodes/Webhook/Webhook.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IWebhookFunctions, -} from 'n8n-core'; +import { BINARY_ENCODING, IWebhookFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -56,10 +53,13 @@ export class Webhook implements INodeType { triggerPanel: { header: '', executionsHelp: { - inactive: 'Webhooks have two modes: test and production.

Use test mode while you build your workflow. Click the \'listen\' button, then make a request to the test URL. The executions will show up in the editor.

Use production mode to run your workflow automatically. Activate the workflow, then make requests to the production URL. These executions will show up in the executions list, but not in the editor.', - active: 'Webhooks have two modes: test and production.

Use test mode while you build your workflow. Click the \'listen\' button, then make a request to the test URL. The executions will show up in the editor.

Use production mode to run your workflow automatically. Since the workflow is activated, you can make requests to the production URL. These executions will show up in the executions list, but not in the editor.', + inactive: + 'Webhooks have two modes: test and production.

Use test mode while you build your workflow. Click the \'listen\' button, then make a request to the test URL. The executions will show up in the editor.

Use production mode to run your workflow automatically. Activate the workflow, then make requests to the production URL. These executions will show up in the executions list, but not in the editor.', + active: + 'Webhooks have two modes: test and production.

Use test mode while you build your workflow. Click the \'listen\' button, then make a request to the test URL. The executions will show up in the editor.

Use production mode to run your workflow automatically. Since the workflow is activated, you can make requests to the production URL. These executions will show up in the executions list, but not in the editor.', }, - activationHint: 'Once you’ve finished building your workflow, run it without having to click this button by using the production webhook URL.', + activationHint: + 'Once you’ve finished building your workflow, run it without having to click this button by using the production webhook URL.', }, // eslint-disable-next-line n8n-nodes-base/node-class-description-inputs-wrong-regular-node inputs: [], @@ -70,9 +70,7 @@ export class Webhook implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'basicAuth', - ], + authentication: ['basicAuth'], }, }, }, @@ -81,9 +79,7 @@ export class Webhook implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'headerAuth', - ], + authentication: ['headerAuth'], }, }, }, @@ -95,7 +91,8 @@ export class Webhook implements INodeType { isFullPath: true, responseCode: '={{$parameter["responseCode"]}}', responseMode: '={{$parameter["responseMode"]}}', - responseData: '={{$parameter["responseData"] || ($parameter.options.noResponseBody ? "noData" : undefined) }}', + responseData: + '={{$parameter["responseData"] || ($parameter.options.noResponseBody ? "noData" : undefined) }}', responseBinaryPropertyName: '={{$parameter["responseBinaryPropertyName"]}}', responseContentType: '={{$parameter["options"]["responseContentType"]}}', responsePropertyName: '={{$parameter["options"]["responsePropertyName"]}}', @@ -183,7 +180,7 @@ export class Webhook implements INodeType { description: 'Returns data of the last-executed node', }, { - name: 'Using \'Respond to Webhook\' Node', + name: "Using 'Respond to Webhook' Node", value: 'responseNode', description: 'Response defined in that node', }, @@ -192,14 +189,13 @@ export class Webhook implements INodeType { description: 'When and how to respond to the webhook', }, { - displayName: 'Insert a \'Respond to Webhook\' node to control when and how you respond. More details', + displayName: + 'Insert a \'Respond to Webhook\' node to control when and how you respond. More details', name: 'webhookNotice', type: 'notice', displayOptions: { show: { - responseMode: [ - 'responseNode', - ], + responseMode: ['responseNode'], }, }, default: '', @@ -210,9 +206,7 @@ export class Webhook implements INodeType { type: 'number', displayOptions: { hide: { - responseMode: [ - 'responseNode', - ], + responseMode: ['responseNode'], }, }, typeOptions: { @@ -228,9 +222,7 @@ export class Webhook implements INodeType { type: 'options', displayOptions: { show: { - responseMode: [ - 'lastNode', - ], + responseMode: ['lastNode'], }, }, options: [ @@ -242,12 +234,14 @@ export class Webhook implements INodeType { { name: 'First Entry JSON', value: 'firstEntryJson', - description: 'Returns the JSON data of the first entry of the last node. Always returns a JSON object.', + description: + 'Returns the JSON data of the first entry of the last node. Always returns a JSON object.', }, { name: 'First Entry Binary', value: 'firstEntryBinary', - description: 'Returns the binary data of the first entry of the last node. Always returns a binary file.', + description: + 'Returns the binary data of the first entry of the last node. Always returns a binary file.', }, { name: 'No Response Body', @@ -256,7 +250,8 @@ export class Webhook implements INodeType { }, ], default: 'firstEntryJson', - description: 'What data should be returned. If it should return all items as an array or only the first item as object.', + description: + 'What data should be returned. If it should return all items as an array or only the first item as object.', }, { displayName: 'Property Name', @@ -266,9 +261,7 @@ export class Webhook implements INodeType { default: 'data', displayOptions: { show: { - responseData: [ - 'firstEntryBinary', - ], + responseData: ['firstEntryBinary'], }, }, description: 'Name of the binary property to return', @@ -286,11 +279,7 @@ export class Webhook implements INodeType { type: 'boolean', displayOptions: { show: { - '/httpMethod': [ - 'PATCH', - 'PUT', - 'POST', - ], + '/httpMethod': ['PATCH', 'PUT', 'POST'], }, }, default: false, @@ -304,19 +293,19 @@ export class Webhook implements INodeType { required: true, displayOptions: { show: { - binaryData: [ - true, - ], + binaryData: [true], }, }, - description: 'Name of the binary property to write the data of the received file to. If the data gets received via "Form-Data Multipart" it will be the prefix and a number starting with 0 will be attached to it.', + description: + 'Name of the binary property to write the data of the received file to. If the data gets received via "Form-Data Multipart" it will be the prefix and a number starting with 0 will be attached to it.', }, { displayName: 'Ignore Bots', name: 'ignoreBots', type: 'boolean', default: false, - description: 'Whether to ignore requests from bots like link previewers and web crawlers', + description: + 'Whether to ignore requests from bots like link previewers and web crawlers', }, { displayName: 'No Response Body', @@ -326,14 +315,10 @@ export class Webhook implements INodeType { description: 'Whether to send any body in the response', displayOptions: { hide: { - 'rawBody': [ - true, - ], + rawBody: [true], }, show: { - '/responseMode': [ - 'onReceived', - ], + '/responseMode': ['onReceived'], }, }, }, @@ -343,12 +328,8 @@ export class Webhook implements INodeType { type: 'boolean', displayOptions: { hide: { - binaryData: [ - true, - ], - 'noResponseBody': [ - true, - ], + binaryData: [true], + noResponseBody: [true], }, }, default: false, @@ -361,14 +342,10 @@ export class Webhook implements INodeType { type: 'string', displayOptions: { show: { - '/responseMode': [ - 'onReceived', - ], + '/responseMode': ['onReceived'], }, hide: { - 'noResponseBody': [ - true, - ], + noResponseBody: [true], }, }, default: '', @@ -381,18 +358,15 @@ export class Webhook implements INodeType { type: 'string', displayOptions: { show: { - '/responseData': [ - 'firstEntryJson', - ], - '/responseMode': [ - 'lastNode', - ], + '/responseData': ['firstEntryJson'], + '/responseMode': ['lastNode'], }, }, default: '', placeholder: 'application/xml', // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-json - description: 'Set a custom content-type to return if another one as the "application/json" should be returned', + description: + 'Set a custom content-type to return if another one as the "application/json" should be returned', }, { displayName: 'Response Headers', @@ -433,12 +407,8 @@ export class Webhook implements INodeType { type: 'string', displayOptions: { show: { - '/responseData': [ - 'firstEntryJson', - ], - '/responseMode': [ - 'lastNode', - ], + '/responseData': ['firstEntryJson'], + '/responseMode': ['lastNode'], }, }, default: 'data', @@ -483,7 +453,10 @@ export class Webhook implements INodeType { return authorizationError(resp, realm, 401); } - if (basicAuthData.name !== httpBasicAuth!.user || basicAuthData.pass !== httpBasicAuth!.password) { + if ( + basicAuthData.name !== httpBasicAuth!.user || + basicAuthData.pass !== httpBasicAuth!.password + ) { // Provided authentication data is wrong return authorizationError(resp, realm, 403); } @@ -496,15 +469,17 @@ export class Webhook implements INodeType { // Do nothing } - if (httpHeaderAuth === undefined || !httpHeaderAuth.name || !httpHeaderAuth.value) { // Data is not defined on node so can not authenticate return authorizationError(resp, realm, 500, 'No authentication data defined on node!'); } const headerName = (httpHeaderAuth.name as string).toLowerCase(); - const headerValue = (httpHeaderAuth.value as string); + const headerValue = httpHeaderAuth.value as string; - if (!headers.hasOwnProperty(headerName) || (headers as IDataObject)[headerName] !== headerValue) { + if ( + !headers.hasOwnProperty(headerName) || + (headers as IDataObject)[headerName] !== headerValue + ) { // Provided authentication data is wrong return authorizationError(resp, realm, 403); } @@ -517,7 +492,6 @@ export class Webhook implements INodeType { const form = new formidable.IncomingForm({ multiples: true }); return new Promise((resolve, reject) => { - form.parse(req, async (err, data, files) => { const returnItem: INodeExecutionData = { binary: {}, @@ -534,7 +508,7 @@ export class Webhook implements INodeType { const processFiles: formidable.File[] = []; let multiFile = false; if (Array.isArray(files[xfile])) { - processFiles.push(...files[xfile] as formidable.File[]); + processFiles.push(...(files[xfile] as formidable.File[])); multiFile = true; } else { processFiles.push(files[xfile] as formidable.File); @@ -556,20 +530,19 @@ export class Webhook implements INodeType { const fileJson = file.toJSON() as unknown as IDataObject; const fileContent = await fs.promises.readFile(file.path); - returnItem.binary![binaryPropertyName] = await this.helpers.prepareBinaryData(Buffer.from(fileContent), fileJson.name as string, fileJson.type as string); + returnItem.binary![binaryPropertyName] = await this.helpers.prepareBinaryData( + Buffer.from(fileContent), + fileJson.name as string, + fileJson.type as string, + ); count += 1; } } resolve({ - workflowData: [ - [ - returnItem, - ], - ], + workflowData: [[returnItem]], }); }); - }); } @@ -593,14 +566,12 @@ export class Webhook implements INodeType { }, }; - returnItem.binary![binaryPropertyName as string] = await this.helpers.prepareBinaryData(Buffer.concat(data)); + returnItem.binary![binaryPropertyName as string] = await this.helpers.prepareBinaryData( + Buffer.concat(data), + ); return resolve({ - workflowData: [ - [ - returnItem, - ], - ], + workflowData: [[returnItem]], }); }); @@ -636,11 +607,7 @@ export class Webhook implements INodeType { return { webhookResponse, - workflowData: [ - [ - response, - ], - ], + workflowData: [[response]], }; } } diff --git a/packages/nodes-base/nodes/Wekan/BoardDescription.ts b/packages/nodes-base/nodes/Wekan/BoardDescription.ts index 9c8aa9a93a..8c50955d64 100644 --- a/packages/nodes-base/nodes/Wekan/BoardDescription.ts +++ b/packages/nodes-base/nodes/Wekan/BoardDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const boardOperations: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const boardOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'board', - ], + resource: ['board'], }, }, options: [ @@ -49,7 +45,6 @@ export const boardOperations: INodeProperties[] = [ ]; export const boardFields: INodeProperties[] = [ - // ---------------------------------- // board:create // ---------------------------------- @@ -62,12 +57,8 @@ export const boardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'board', - ], + operation: ['create'], + resource: ['board'], }, }, description: 'The title of the board', @@ -83,15 +74,12 @@ export const boardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'board', - ], + operation: ['create'], + resource: ['board'], }, }, - description: 'The user ID in Wekan. Choose from the list, or specify an ID using an expression.', + description: + 'The user ID in Wekan. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Additional Fields', @@ -100,12 +88,8 @@ export const boardFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'board', - ], + operation: ['create'], + resource: ['board'], }, }, default: {}, @@ -209,12 +193,8 @@ export const boardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'board', - ], + operation: ['delete'], + resource: ['board'], }, }, description: 'The ID of the board to delete', @@ -231,12 +211,8 @@ export const boardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'board', - ], + operation: ['get'], + resource: ['board'], }, }, description: 'The ID of the board to get', @@ -256,15 +232,12 @@ export const boardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'board', - ], + operation: ['getAll'], + resource: ['board'], }, }, - description: 'The ID of the user that boards are attached. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the user that boards are attached. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -272,12 +245,8 @@ export const boardFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'board', - ], + operation: ['getAll'], + resource: ['board'], }, }, default: false, @@ -289,15 +258,9 @@ export const boardFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'board', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['board'], + returnAll: [false], }, }, typeOptions: { @@ -307,5 +270,4 @@ export const boardFields: INodeProperties[] = [ default: 100, description: 'Max number of results to return', }, - ]; diff --git a/packages/nodes-base/nodes/Wekan/CardCommentDescription.ts b/packages/nodes-base/nodes/Wekan/CardCommentDescription.ts index 22fdf25b2f..3f2ac4ee22 100644 --- a/packages/nodes-base/nodes/Wekan/CardCommentDescription.ts +++ b/packages/nodes-base/nodes/Wekan/CardCommentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const cardCommentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const cardCommentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'cardComment', - ], + resource: ['cardComment'], }, }, options: [ @@ -60,15 +56,12 @@ export const cardCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'cardComment', - ], + operation: ['create'], + resource: ['cardComment'], }, }, - description: 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Name or ID', @@ -76,23 +69,18 @@ export const cardCommentFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'cardComment', - ], + operation: ['create'], + resource: ['cardComment'], }, }, - description: 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Card Name or ID', @@ -100,24 +88,18 @@ export const cardCommentFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCards', - loadOptionsDependsOn: [ - 'boardId', - 'listId', - ], + loadOptionsDependsOn: ['boardId', 'listId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'cardComment', - ], + operation: ['create'], + resource: ['cardComment'], }, }, - description: 'The ID of the card. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the card. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Author Name or ID', @@ -130,15 +112,12 @@ export const cardCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'cardComment', - ], + operation: ['create'], + resource: ['cardComment'], }, }, - description: 'The user who posted the comment. Choose from the list, or specify an ID using an expression.', + description: + 'The user who posted the comment. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Comment', @@ -148,12 +127,8 @@ export const cardCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'cardComment', - ], + operation: ['create'], + resource: ['cardComment'], }, }, description: 'The comment text', @@ -173,15 +148,12 @@ export const cardCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'cardComment', - ], + operation: ['delete'], + resource: ['cardComment'], }, }, - description: 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Name or ID', @@ -189,23 +161,18 @@ export const cardCommentFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'cardComment', - ], + operation: ['delete'], + resource: ['cardComment'], }, }, - description: 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Card Name or ID', @@ -213,24 +180,18 @@ export const cardCommentFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCards', - loadOptionsDependsOn: [ - 'boardId', - 'listId', - ], + loadOptionsDependsOn: ['boardId', 'listId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'cardComment', - ], + operation: ['delete'], + resource: ['cardComment'], }, }, - description: 'The ID of the card. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the card. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Comment Name or ID', @@ -238,24 +199,18 @@ export const cardCommentFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getComments', - loadOptionsDependsOn: [ - 'boardId', - 'cardId', - ], + loadOptionsDependsOn: ['boardId', 'cardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'cardComment', - ], + operation: ['delete'], + resource: ['cardComment'], }, }, - description: 'The ID of the comment to delete. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the comment to delete. Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- @@ -269,12 +224,8 @@ export const cardCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'cardComment', - ], + operation: ['get'], + resource: ['cardComment'], }, }, description: 'The ID of the board that card belongs to', @@ -285,23 +236,18 @@ export const cardCommentFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'cardComment', - ], + operation: ['get'], + resource: ['cardComment'], }, }, - description: 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Card Name or ID', @@ -309,24 +255,18 @@ export const cardCommentFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCards', - loadOptionsDependsOn: [ - 'boardId', - 'listId', - ], + loadOptionsDependsOn: ['boardId', 'listId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'cardComment', - ], + operation: ['get'], + resource: ['cardComment'], }, }, - description: 'The ID of the card. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the card. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Comment ID', @@ -336,12 +276,8 @@ export const cardCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'cardComment', - ], + operation: ['get'], + resource: ['cardComment'], }, }, description: 'The ID of the comment to get', @@ -361,15 +297,12 @@ export const cardCommentFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'cardComment', - ], + operation: ['getAll'], + resource: ['cardComment'], }, }, - description: 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Name or ID', @@ -377,23 +310,18 @@ export const cardCommentFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'cardComment', - ], + operation: ['getAll'], + resource: ['cardComment'], }, }, - description: 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Card Name or ID', @@ -401,24 +329,18 @@ export const cardCommentFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCards', - loadOptionsDependsOn: [ - 'boardId', - 'listId', - ], + loadOptionsDependsOn: ['boardId', 'listId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'cardComment', - ], + operation: ['getAll'], + resource: ['cardComment'], }, }, - description: 'The ID of the card. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the card. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -426,12 +348,8 @@ export const cardCommentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'cardComment', - ], + operation: ['getAll'], + resource: ['cardComment'], }, }, default: false, @@ -443,15 +361,9 @@ export const cardCommentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'cardComment', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['cardComment'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Wekan/CardDescription.ts b/packages/nodes-base/nodes/Wekan/CardDescription.ts index cbe6f16179..97718e78ed 100644 --- a/packages/nodes-base/nodes/Wekan/CardDescription.ts +++ b/packages/nodes-base/nodes/Wekan/CardDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const cardOperations: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const cardOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'card', - ], + resource: ['card'], }, }, options: [ @@ -69,15 +65,12 @@ export const cardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'card', - ], + operation: ['create'], + resource: ['card'], }, }, - description: 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Name or ID', @@ -85,23 +78,18 @@ export const cardFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'card', - ], + operation: ['create'], + resource: ['card'], }, }, - description: 'The ID of the list to create card in. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list to create card in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Title', @@ -112,12 +100,8 @@ export const cardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'card', - ], + operation: ['create'], + resource: ['card'], }, }, description: 'The title of the card', @@ -128,29 +112,25 @@ export const cardFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getSwimlanes', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'card', - ], + operation: ['create'], + resource: ['card'], }, }, - description: 'The swimlane ID of the new card. Choose from the list, or specify an ID using an expression.', + description: + 'The swimlane ID of the new card. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Author Name or ID', name: 'authorId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getUsers', }, @@ -158,12 +138,8 @@ export const cardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'card', - ], + operation: ['create'], + resource: ['card'], }, }, }, @@ -174,12 +150,8 @@ export const cardFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'card', - ], + operation: ['create'], + resource: ['card'], }, }, default: {}, @@ -192,7 +164,8 @@ export const cardFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: [], - description: 'The new list of assignee IDs attached to the card. Choose from the list, or specify IDs using an expression.', + description: + 'The new list of assignee IDs attached to the card. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Description', @@ -209,7 +182,8 @@ export const cardFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: [], - description: 'The new list of member IDs attached to the card. Choose from the list, or specify IDs using an expression.', + description: + 'The new list of member IDs attached to the card. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -228,15 +202,12 @@ export const cardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'card', - ], + operation: ['delete'], + resource: ['card'], }, }, - description: 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Name or ID', @@ -244,23 +215,18 @@ export const cardFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'card', - ], + operation: ['delete'], + resource: ['card'], }, }, - description: 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Card Name or ID', @@ -268,24 +234,18 @@ export const cardFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCards', - loadOptionsDependsOn: [ - 'boardId', - 'listId', - ], + loadOptionsDependsOn: ['boardId', 'listId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'card', - ], + operation: ['delete'], + resource: ['card'], }, }, - description: 'The ID of the card to delete. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the card to delete. Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- @@ -302,15 +262,12 @@ export const cardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'card', - ], + operation: ['get'], + resource: ['card'], }, }, - description: 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Name or ID', @@ -318,23 +275,18 @@ export const cardFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'card', - ], + operation: ['get'], + resource: ['card'], }, }, - description: 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Card ID', @@ -344,12 +296,8 @@ export const cardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'card', - ], + operation: ['get'], + resource: ['card'], }, }, description: 'The ID of the card to get', @@ -369,15 +317,12 @@ export const cardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'card', - ], + operation: ['getAll'], + resource: ['card'], }, }, - description: 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'From Object', @@ -386,12 +331,8 @@ export const cardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'card', - ], + operation: ['getAll'], + resource: ['card'], }, }, options: [ @@ -412,26 +353,19 @@ export const cardFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - fromObject: [ - 'list', - ], - operation: [ - 'getAll', - ], - resource: [ - 'card', - ], + fromObject: ['list'], + operation: ['getAll'], + resource: ['card'], }, }, - description: 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Swimlane Name or ID', @@ -439,25 +373,18 @@ export const cardFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getSwimlanes', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', displayOptions: { show: { - fromObject: [ - 'swimlane', - ], - operation: [ - 'getAll', - ], - resource: [ - 'card', - ], + fromObject: ['swimlane'], + operation: ['getAll'], + resource: ['card'], }, }, - description: 'The ID of the swimlane that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the swimlane that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -465,12 +392,8 @@ export const cardFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'card', - ], + operation: ['getAll'], + resource: ['card'], }, }, default: false, @@ -482,15 +405,9 @@ export const cardFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'card', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['card'], + returnAll: [false], }, }, typeOptions: { @@ -515,15 +432,12 @@ export const cardFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'card', - ], + operation: ['update'], + resource: ['card'], }, }, - description: 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Name or ID', @@ -531,23 +445,18 @@ export const cardFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'card', - ], + operation: ['update'], + resource: ['card'], }, }, - description: 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Card Name or ID', @@ -555,24 +464,18 @@ export const cardFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCards', - loadOptionsDependsOn: [ - 'boardId', - 'listId', - ], + loadOptionsDependsOn: ['boardId', 'listId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'card', - ], + operation: ['update'], + resource: ['card'], }, }, - description: 'The ID of the card to update. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the card to update. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Update Fields', @@ -581,12 +484,8 @@ export const cardFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'card', - ], + operation: ['update'], + resource: ['card'], }, }, default: {}, @@ -599,7 +498,8 @@ export const cardFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: '', - description: 'Update the owner of the card. Choose from the list, or specify an ID using an expression.', + description: + 'Update the owner of the card. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Assignee Names or IDs', @@ -609,7 +509,8 @@ export const cardFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: [], - description: 'The new list of assignee IDs attached to the card. Choose from the list, or specify IDs using an expression.', + description: + 'The new list of assignee IDs attached to the card. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Color', @@ -754,12 +655,11 @@ export const cardFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', - description: 'The new list ID of the card (move operation). Choose from the list, or specify an ID using an expression.', + description: + 'The new list ID of the card (move operation). Choose from the list, or specify an ID using an expression.', }, { displayName: 'Member Names or IDs', @@ -769,7 +669,8 @@ export const cardFields: INodeProperties[] = [ loadOptionsMethod: 'getUsers', }, default: [], - description: 'The new list of member IDs attached to the card. Choose from the list, or specify IDs using an expression.', + description: + 'The new list of member IDs attached to the card. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Over Time', @@ -785,13 +686,11 @@ export const cardFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCards', - loadOptionsDependsOn: [ - 'boardId', - 'listId', - ], + loadOptionsDependsOn: ['boardId', 'listId'], }, default: '', - description: 'The parent of the card. Choose from the list, or specify an ID using an expression.', + description: + 'The parent of the card. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Received At', @@ -830,12 +729,11 @@ export const cardFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getSwimlanes', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', - description: 'The new swimlane ID of the card. Choose from the list, or specify an ID using an expression.', + description: + 'The new swimlane ID of the card. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Title', diff --git a/packages/nodes-base/nodes/Wekan/ChecklistDescription.ts b/packages/nodes-base/nodes/Wekan/ChecklistDescription.ts index 3e3abd26ac..3d044cdbb4 100644 --- a/packages/nodes-base/nodes/Wekan/ChecklistDescription.ts +++ b/packages/nodes-base/nodes/Wekan/ChecklistDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const checklistOperations: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const checklistOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'checklist', - ], + resource: ['checklist'], }, }, options: [ @@ -46,7 +42,6 @@ export const checklistOperations: INodeProperties[] = [ ], default: 'getAll', }, - ]; export const checklistFields: INodeProperties[] = [ @@ -64,15 +59,12 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'checklist', - ], + operation: ['create'], + resource: ['checklist'], }, }, - description: 'The ID of the board where the card is in. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board where the card is in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Name or ID', @@ -80,23 +72,18 @@ export const checklistFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'checklist', - ], + operation: ['create'], + resource: ['checklist'], }, }, - description: 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Card Name or ID', @@ -104,24 +91,18 @@ export const checklistFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCards', - loadOptionsDependsOn: [ - 'boardId', - 'listId', - ], + loadOptionsDependsOn: ['boardId', 'listId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'checklist', - ], + operation: ['create'], + resource: ['checklist'], }, }, - description: 'The ID of the card to add checklist to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the card to add checklist to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Title', @@ -131,12 +112,8 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'checklist', - ], + operation: ['create'], + resource: ['checklist'], }, }, description: 'The title of the checklist to add', @@ -151,12 +128,8 @@ export const checklistFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'checklist', - ], + operation: ['create'], + resource: ['checklist'], }, }, default: [], @@ -177,15 +150,12 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'checklist', - ], + operation: ['delete'], + resource: ['checklist'], }, }, - description: 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Name or ID', @@ -193,23 +163,18 @@ export const checklistFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'checklist', - ], + operation: ['delete'], + resource: ['checklist'], }, }, - description: 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Card Name or ID', @@ -217,24 +182,18 @@ export const checklistFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCards', - loadOptionsDependsOn: [ - 'boardId', - 'listId', - ], + loadOptionsDependsOn: ['boardId', 'listId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'checklist', - ], + operation: ['delete'], + resource: ['checklist'], }, }, - description: 'The ID of the card that checklist belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the card that checklist belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Checklist Name or ID', @@ -242,24 +201,18 @@ export const checklistFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getChecklists', - loadOptionsDependsOn: [ - 'boardId', - 'cardId', - ], + loadOptionsDependsOn: ['boardId', 'cardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'checklist', - ], + operation: ['delete'], + resource: ['checklist'], }, }, - description: 'The ID of the checklist to delete. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the checklist to delete. Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- @@ -276,15 +229,12 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'checklist', - ], + operation: ['get'], + resource: ['checklist'], }, }, - description: 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Name or ID', @@ -292,23 +242,18 @@ export const checklistFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'checklist', - ], + operation: ['get'], + resource: ['checklist'], }, }, - description: 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Card Name or ID', @@ -316,24 +261,18 @@ export const checklistFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCards', - loadOptionsDependsOn: [ - 'boardId', - 'listId', - ], + loadOptionsDependsOn: ['boardId', 'listId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'checklist', - ], + operation: ['get'], + resource: ['checklist'], }, }, - description: 'The ID of the card that checklist belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the card that checklist belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Checklist Name or ID', @@ -341,24 +280,18 @@ export const checklistFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getChecklists', - loadOptionsDependsOn: [ - 'boardId', - 'cardId', - ], + loadOptionsDependsOn: ['boardId', 'cardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'checklist', - ], + operation: ['get'], + resource: ['checklist'], }, }, - description: 'The ID of the checklist to get. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the checklist to get. Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- @@ -375,15 +308,12 @@ export const checklistFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'checklist', - ], + operation: ['getAll'], + resource: ['checklist'], }, }, - description: 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Name or ID', @@ -391,23 +321,18 @@ export const checklistFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'checklist', - ], + operation: ['getAll'], + resource: ['checklist'], }, }, - description: 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Card Name or ID', @@ -415,24 +340,18 @@ export const checklistFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCards', - loadOptionsDependsOn: [ - 'boardId', - 'listId', - ], + loadOptionsDependsOn: ['boardId', 'listId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'checklist', - ], + operation: ['getAll'], + resource: ['checklist'], }, }, - description: 'The ID of the card to get checklists. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the card to get checklists. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -440,12 +359,8 @@ export const checklistFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'checklist', - ], + operation: ['getAll'], + resource: ['checklist'], }, }, default: false, @@ -457,15 +372,9 @@ export const checklistFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'checklist', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['checklist'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Wekan/ChecklistItemDescription.ts b/packages/nodes-base/nodes/Wekan/ChecklistItemDescription.ts index 54e8de8640..25c756cd94 100644 --- a/packages/nodes-base/nodes/Wekan/ChecklistItemDescription.ts +++ b/packages/nodes-base/nodes/Wekan/ChecklistItemDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const checklistItemOperations: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const checklistItemOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'checklistItem', - ], + resource: ['checklistItem'], }, }, options: [ @@ -40,7 +36,6 @@ export const checklistItemOperations: INodeProperties[] = [ ], default: 'getAll', }, - ]; export const checklistItemFields: INodeProperties[] = [ @@ -58,15 +53,12 @@ export const checklistItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'checklistItem', - ], + operation: ['delete'], + resource: ['checklistItem'], }, }, - description: 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Name or ID', @@ -74,23 +66,18 @@ export const checklistItemFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'checklistItem', - ], + operation: ['delete'], + resource: ['checklistItem'], }, }, - description: 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Card Name or ID', @@ -98,24 +85,18 @@ export const checklistItemFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCards', - loadOptionsDependsOn: [ - 'boardId', - 'listId', - ], + loadOptionsDependsOn: ['boardId', 'listId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'checklistItem', - ], + operation: ['delete'], + resource: ['checklistItem'], }, }, - description: 'The ID of the card that checklistItem belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the card that checklistItem belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Checklist Name or ID', @@ -123,24 +104,18 @@ export const checklistItemFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getChecklists', - loadOptionsDependsOn: [ - 'boardId', - 'cardId', - ], + loadOptionsDependsOn: ['boardId', 'cardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'checklistItem', - ], + operation: ['delete'], + resource: ['checklistItem'], }, }, - description: 'The ID of the checklistItem that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the checklistItem that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Checklist Item Name or ID', @@ -148,25 +123,18 @@ export const checklistItemFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getChecklistItems', - loadOptionsDependsOn: [ - 'boardId', - 'cardId', - 'checklistId', - ], + loadOptionsDependsOn: ['boardId', 'cardId', 'checklistId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'checklistItem', - ], + operation: ['delete'], + resource: ['checklistItem'], }, }, - description: 'The ID of the checklistItem item to get. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the checklistItem item to get. Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- @@ -183,15 +151,12 @@ export const checklistItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'checklistItem', - ], + operation: ['get'], + resource: ['checklistItem'], }, }, - description: 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Name or ID', @@ -199,23 +164,18 @@ export const checklistItemFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'checklistItem', - ], + operation: ['get'], + resource: ['checklistItem'], }, }, - description: 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Card Name or ID', @@ -223,24 +183,18 @@ export const checklistItemFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCards', - loadOptionsDependsOn: [ - 'boardId', - 'listId', - ], + loadOptionsDependsOn: ['boardId', 'listId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'checklistItem', - ], + operation: ['get'], + resource: ['checklistItem'], }, }, - description: 'The ID of the card that checklistItem belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the card that checklistItem belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Checklist ID', @@ -250,12 +204,8 @@ export const checklistItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'checklistItem', - ], + operation: ['get'], + resource: ['checklistItem'], }, }, description: 'The ID of the checklistItem that card belongs to', @@ -266,25 +216,18 @@ export const checklistItemFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getChecklistItems', - loadOptionsDependsOn: [ - 'boardId', - 'cardId', - 'checklistId', - ], + loadOptionsDependsOn: ['boardId', 'cardId', 'checklistId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'checklistItem', - ], + operation: ['get'], + resource: ['checklistItem'], }, }, - description: 'The ID of the checklistItem item to get. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the checklistItem item to get. Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- @@ -301,15 +244,12 @@ export const checklistItemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'checklistItem', - ], + operation: ['update'], + resource: ['checklistItem'], }, }, - description: 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Name or ID', @@ -317,23 +257,18 @@ export const checklistItemFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'checklistItem', - ], + operation: ['update'], + resource: ['checklistItem'], }, }, - description: 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Card Name or ID', @@ -341,24 +276,18 @@ export const checklistItemFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getCards', - loadOptionsDependsOn: [ - 'boardId', - 'listId', - ], + loadOptionsDependsOn: ['boardId', 'listId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'checklistItem', - ], + operation: ['update'], + resource: ['checklistItem'], }, }, - description: 'The ID of the card that checklistItem belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the card that checklistItem belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'CheckList Name or ID', @@ -366,24 +295,18 @@ export const checklistItemFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getChecklists', - loadOptionsDependsOn: [ - 'boardId', - 'cardId', - ], + loadOptionsDependsOn: ['boardId', 'cardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'checklistItem', - ], + operation: ['update'], + resource: ['checklistItem'], }, }, - description: 'The ID of the checklistItem that card belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the checklistItem that card belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Checklist Item Name or ID', @@ -391,25 +314,18 @@ export const checklistItemFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getChecklistItems', - loadOptionsDependsOn: [ - 'boardId', - 'cardId', - 'checklistId', - ], + loadOptionsDependsOn: ['boardId', 'cardId', 'checklistId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'checklistItem', - ], + operation: ['update'], + resource: ['checklistItem'], }, }, - description: 'The ID of the checklistItem item to update. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the checklistItem item to update. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Update Fields', @@ -418,12 +334,8 @@ export const checklistItemFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'checklistItem', - ], + operation: ['update'], + resource: ['checklistItem'], }, }, default: {}, @@ -444,5 +356,4 @@ export const checklistItemFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Wekan/GenericFunctions.ts b/packages/nodes-base/nodes/Wekan/GenericFunctions.ts index 598ed8f7c3..7142aea3ef 100644 --- a/packages/nodes-base/nodes/Wekan/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wekan/GenericFunctions.ts @@ -6,9 +6,7 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { ICredentialDataDecryptedObject, @@ -18,7 +16,12 @@ import { } from 'n8n-workflow'; export async function getAuthorization( - this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, + this: + | IHookFunctions + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IWebhookFunctions, credentials?: ICredentialDataDecryptedObject, ): Promise { if (credentials === undefined) { @@ -45,7 +48,14 @@ export async function getAuthorization( } } -export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, query?: IDataObject): Promise { // tslint:disable-line:no-any +export async function apiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + body: object, + query?: IDataObject, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('wekanApi'); query = query || {}; @@ -54,8 +64,8 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa const options: OptionsWithUri = { headers: { - 'Accept':'application/json', - 'Authorization': `Bearer ${token}`, + Accept: 'application/json', + Authorization: `Bearer ${token}`, }, method, body, diff --git a/packages/nodes-base/nodes/Wekan/ListDescription.ts b/packages/nodes-base/nodes/Wekan/ListDescription.ts index 6cbf871ddc..c5bdc2c4b6 100644 --- a/packages/nodes-base/nodes/Wekan/ListDescription.ts +++ b/packages/nodes-base/nodes/Wekan/ListDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const listOperations: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const listOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'list', - ], + resource: ['list'], }, }, options: [ @@ -63,15 +59,12 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'list', - ], + operation: ['create'], + resource: ['list'], }, }, - description: 'The ID of the board the list should be created in. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board the list should be created in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Title', @@ -82,12 +75,8 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'list', - ], + operation: ['create'], + resource: ['list'], }, }, description: 'The title of the list', @@ -107,15 +96,12 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'list', - ], + operation: ['delete'], + resource: ['list'], }, }, - description: 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Name or ID', @@ -123,23 +109,18 @@ export const listFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'boardId', - ], + loadOptionsDependsOn: ['boardId'], }, default: '', required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'list', - ], + operation: ['delete'], + resource: ['list'], }, }, - description: 'The ID of the list to delete. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the list to delete. Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- @@ -156,15 +137,12 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'list', - ], + operation: ['get'], + resource: ['list'], }, }, - description: 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the board that list belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List ID', @@ -174,12 +152,8 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'list', - ], + operation: ['get'], + resource: ['list'], }, }, description: 'The ID of the list to get', @@ -199,15 +173,12 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'list', - ], + operation: ['getAll'], + resource: ['list'], }, }, - description: 'ID of the board where the lists are in. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the board where the lists are in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -215,12 +186,8 @@ export const listFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'list', - ], + operation: ['getAll'], + resource: ['list'], }, }, default: false, @@ -232,15 +199,9 @@ export const listFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'list', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['list'], + returnAll: [false], }, }, typeOptions: { @@ -250,5 +211,4 @@ export const listFields: INodeProperties[] = [ default: 100, description: 'Max number of results to return', }, - ]; diff --git a/packages/nodes-base/nodes/Wekan/Wekan.node.ts b/packages/nodes-base/nodes/Wekan/Wekan.node.ts index 609a52a6cf..a9e011fdd9 100644 --- a/packages/nodes-base/nodes/Wekan/Wekan.node.ts +++ b/packages/nodes-base/nodes/Wekan/Wekan.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,39 +10,19 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - apiRequest, -} from './GenericFunctions'; +import { apiRequest } from './GenericFunctions'; -import { - boardFields, - boardOperations, -} from './BoardDescription'; +import { boardFields, boardOperations } from './BoardDescription'; -import { - cardFields, - cardOperations, -} from './CardDescription'; +import { cardFields, cardOperations } from './CardDescription'; -import { - cardCommentFields, - cardCommentOperations, -} from './CardCommentDescription'; +import { cardCommentFields, cardCommentOperations } from './CardCommentDescription'; -import { - checklistFields, - checklistOperations, -} from './ChecklistDescription'; +import { checklistFields, checklistOperations } from './ChecklistDescription'; -import { - checklistItemFields, - checklistItemOperations, -} from './ChecklistItemDescription'; +import { checklistItemFields, checklistItemOperations } from './ChecklistItemDescription'; -import { - listFields, - listOperations, -} from './ListDescription'; +import { listFields, listOperations } from './ListDescription'; // https://wekan.github.io/api/v4.41/ @@ -179,7 +157,13 @@ export class Wekan implements INodeType { const returnData: INodePropertyOptions[] = []; const boardId = this.getCurrentNodeParameter('boardId') as string; const listId = this.getCurrentNodeParameter('listId') as string; - const cards = await apiRequest.call(this, 'GET', `boards/${boardId}/lists/${listId}/cards`, {}, {}); + const cards = await apiRequest.call( + this, + 'GET', + `boards/${boardId}/lists/${listId}/cards`, + {}, + {}, + ); for (const card of cards) { returnData.push({ name: card.title, @@ -192,7 +176,13 @@ export class Wekan implements INodeType { const returnData: INodePropertyOptions[] = []; const boardId = this.getCurrentNodeParameter('boardId') as string; const cardId = this.getCurrentNodeParameter('cardId') as string; - const checklists = await apiRequest.call(this, 'GET', `boards/${boardId}/cards/${cardId}/checklists`, {}, {}); + const checklists = await apiRequest.call( + this, + 'GET', + `boards/${boardId}/cards/${cardId}/checklists`, + {}, + {}, + ); for (const checklist of checklists) { returnData.push({ name: checklist.title, @@ -206,7 +196,13 @@ export class Wekan implements INodeType { const boardId = this.getCurrentNodeParameter('boardId') as string; const cardId = this.getCurrentNodeParameter('cardId') as string; const checklistId = this.getCurrentNodeParameter('checklistId') as string; - const checklist = await apiRequest.call(this, 'GET', `boards/${boardId}/cards/${cardId}/checklists/${checklistId}`, {}, {}); + const checklist = await apiRequest.call( + this, + 'GET', + `boards/${boardId}/cards/${cardId}/checklists/${checklistId}`, + {}, + {}, + ); for (const item of checklist.items) { returnData.push({ name: item.title, @@ -219,7 +215,13 @@ export class Wekan implements INodeType { const returnData: INodePropertyOptions[] = []; const boardId = this.getCurrentNodeParameter('boardId') as string; const cardId = this.getCurrentNodeParameter('cardId') as string; - const comments = await apiRequest.call(this, 'GET', `boards/${boardId}/cards/${cardId}/comments`, {}, {}); + const comments = await apiRequest.call( + this, + 'GET', + `boards/${boardId}/cards/${cardId}/comments`, + {}, + {}, + ); for (const comment of comments) { returnData.push({ name: comment.comment, @@ -256,7 +258,6 @@ export class Wekan implements INodeType { qs = {}; if (resource === 'board') { - if (operation === 'create') { // ---------------------------------- // create @@ -270,7 +271,6 @@ export class Wekan implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -281,7 +281,6 @@ export class Wekan implements INodeType { const boardId = this.getNodeParameter('boardId', i) as string; endpoint = `boards/${boardId}`; - } else if (operation === 'get') { // ---------------------------------- // get @@ -292,7 +291,6 @@ export class Wekan implements INodeType { const boardId = this.getNodeParameter('boardId', i) as string; endpoint = `boards/${boardId}`; - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -305,13 +303,14 @@ export class Wekan implements INodeType { returnAll = this.getNodeParameter('returnAll', i) as boolean; endpoint = `users/${userId}/boards`; - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } - } else if (resource === 'card') { - if (operation === 'create') { // ---------------------------------- // create @@ -330,7 +329,6 @@ export class Wekan implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -343,7 +341,6 @@ export class Wekan implements INodeType { const cardId = this.getNodeParameter('cardId', i) as string; endpoint = `boards/${boardId}/lists/${listId}/cards/${cardId}`; - } else if (operation === 'get') { // ---------------------------------- // get @@ -356,7 +353,6 @@ export class Wekan implements INodeType { const cardId = this.getNodeParameter('cardId', i) as string; endpoint = `boards/${boardId}/lists/${listId}/cards/${cardId}`; - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -379,7 +375,6 @@ export class Wekan implements INodeType { endpoint = `boards/${boardId}/swimlanes/${swimlaneId}/cards`; } - } else if (operation === 'update') { // ---------------------------------- // update @@ -395,13 +390,14 @@ export class Wekan implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; Object.assign(body, updateFields); - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } - } else if (resource === 'cardComment') { - if (operation === 'create') { // ---------------------------------- // create @@ -416,7 +412,6 @@ export class Wekan implements INodeType { body.authorId = this.getNodeParameter('authorId', i) as string; body.comment = this.getNodeParameter('comment', i) as string; - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -429,7 +424,6 @@ export class Wekan implements INodeType { const commentId = this.getNodeParameter('commentId', i) as string; endpoint = `boards/${boardId}/cards/${cardId}/comments/${commentId}`; - } else if (operation === 'get') { // ---------------------------------- // get @@ -442,7 +436,6 @@ export class Wekan implements INodeType { const commentId = this.getNodeParameter('commentId', i) as string; endpoint = `boards/${boardId}/cards/${cardId}/comments/${commentId}`; - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -454,13 +447,14 @@ export class Wekan implements INodeType { const cardId = this.getNodeParameter('cardId', i) as string; endpoint = `boards/${boardId}/cards/${cardId}/comments`; - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } - } else if (resource === 'list') { - if (operation === 'create') { // ---------------------------------- // create @@ -473,7 +467,6 @@ export class Wekan implements INodeType { endpoint = `boards/${boardId}/lists`; body.title = this.getNodeParameter('title', i) as string; - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -485,7 +478,6 @@ export class Wekan implements INodeType { const listId = this.getNodeParameter('listId', i) as string; endpoint = `boards/${boardId}/lists/${listId}`; - } else if (operation === 'get') { // ---------------------------------- // get @@ -497,7 +489,6 @@ export class Wekan implements INodeType { const listId = this.getNodeParameter('listId', i) as string; endpoint = `boards/${boardId}/lists/${listId}`; - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -509,13 +500,14 @@ export class Wekan implements INodeType { returnAll = this.getNodeParameter('returnAll', i) as boolean; endpoint = `boards/${boardId}/lists`; - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } - } else if (resource === 'checklist') { - if (operation === 'create') { // ---------------------------------- // create @@ -531,7 +523,6 @@ export class Wekan implements INodeType { body.title = this.getNodeParameter('title', i) as string; body.items = this.getNodeParameter('items', i) as string[]; - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -544,7 +535,6 @@ export class Wekan implements INodeType { const checklistId = this.getNodeParameter('checklistId', i) as string; endpoint = `boards/${boardId}/cards/${cardId}/checklists/${checklistId}`; - } else if (operation === 'get') { // ---------------------------------- // get @@ -557,7 +547,6 @@ export class Wekan implements INodeType { const checklistId = this.getNodeParameter('checklistId', i) as string; endpoint = `boards/${boardId}/cards/${cardId}/checklists/${checklistId}`; - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -569,9 +558,7 @@ export class Wekan implements INodeType { const cardId = this.getNodeParameter('cardId', i) as string; returnAll = this.getNodeParameter('returnAll', i) as boolean; - endpoint = `boards/${boardId}/cards/${cardId}/checklists`; - } else if (operation === 'getCheckItem') { // ---------------------------------- // getCheckItem @@ -585,7 +572,6 @@ export class Wekan implements INodeType { const itemId = this.getNodeParameter('itemId', i) as string; endpoint = `boards/${boardId}/cards/${cardId}/checklists/${checklistId}/items/${itemId}`; - } else if (operation === 'deleteCheckItem') { // ---------------------------------- // deleteCheckItem @@ -599,7 +585,6 @@ export class Wekan implements INodeType { const itemId = this.getNodeParameter('itemId', i) as string; endpoint = `boards/${boardId}/cards/${cardId}/checklists/${checklistId}/items/${itemId}`; - } else if (operation === 'updateCheckItem') { // ---------------------------------- // updateCheckItem @@ -616,14 +601,14 @@ export class Wekan implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; Object.assign(body, updateFields); - - - } else { - throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The operation "${operation}" is not known!`, + { itemIndex: i }, + ); } } else if (resource === 'checklistItem') { - if (operation === 'get') { // ---------------------------------- // get @@ -637,7 +622,6 @@ export class Wekan implements INodeType { const itemId = this.getNodeParameter('checklistItemId', i) as string; endpoint = `boards/${boardId}/cards/${cardId}/checklists/${checklistId}/items/${itemId}`; - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -651,7 +635,6 @@ export class Wekan implements INodeType { const itemId = this.getNodeParameter('checklistItemId', i) as string; endpoint = `boards/${boardId}/cards/${cardId}/checklists/${checklistId}/items/${itemId}`; - } else if (operation === 'update') { // ---------------------------------- // update diff --git a/packages/nodes-base/nodes/Wise/GenericFunctions.ts b/packages/nodes-base/nodes/Wise/GenericFunctions.ts index 93ab1422a9..59219a1dfa 100644 --- a/packages/nodes-base/nodes/Wise/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wise/GenericFunctions.ts @@ -1,11 +1,6 @@ -import { - createSign, -} from 'crypto'; +import { createSign } from 'crypto'; -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; import { IDataObject, @@ -26,20 +21,21 @@ export async function wiseApiRequest( qs: IDataObject = {}, option: IDataObject = {}, ) { - const { apiToken, environment, privateKey } = await this.getCredentials('wiseApi') as { - apiToken: string, - environment: 'live' | 'test', - privateKey?: string, + const { apiToken, environment, privateKey } = (await this.getCredentials('wiseApi')) as { + apiToken: string; + environment: 'live' | 'test'; + privateKey?: string; }; - const rootUrl = environment === 'live' - ? 'https://api.transferwise.com/' - : 'https://api.sandbox.transferwise.tech/'; + const rootUrl = + environment === 'live' + ? 'https://api.transferwise.com/' + : 'https://api.sandbox.transferwise.tech/'; const options: IHttpRequestOptions = { headers: { 'user-agent': 'n8n', - 'Authorization': `Bearer ${apiToken}`, + Authorization: `Bearer ${apiToken}`, }, method, url: `${rootUrl}${endpoint}`, @@ -82,7 +78,8 @@ export async function wiseApiRequest( if (response.statusCode === 403 && response.headers['x-2fa-approval']) { if (!privateKey) { throw new NodeApiError(this.getNode(), { - message: 'This request requires Strong Customer Authentication (SCA). Please add a key pair to your account and n8n credentials. See https://api-docs.transferwise.com/#strong-customer-authentication-personal-token', + message: + 'This request requires Strong Customer Authentication (SCA). Please add a key pair to your account and n8n credentials. See https://api-docs.transferwise.com/#strong-customer-authentication-personal-token', headers: response.headers, body: response.body, }); @@ -91,10 +88,7 @@ export async function wiseApiRequest( const oneTimeToken = response.headers['x-2fa-approval'] as string; const signerObject = createSign('RSA-SHA256').update(oneTimeToken); try { - const signature = signerObject.sign( - privateKey, - 'base64', - ); + const signature = signerObject.sign(privateKey, 'base64'); delete option.ignoreHttpStatusErrors; options.headers = { ...options.headers, @@ -102,14 +96,19 @@ export async function wiseApiRequest( 'x-2fa-approval': oneTimeToken, }; } catch (error) { - throw new NodeApiError(this.getNode(), {message: 'Error signing SCA request, check your private key', ...error}); + throw new NodeApiError(this.getNode(), { + message: 'Error signing SCA request, check your private key', + ...error, + }); } // Retry the request with signed token try { response = await this.helpers.httpRequest!(options); return response.body; } catch (error) { - throw new NodeApiError(this.getNode(), {message: 'SCA request failed, check your private key is valid'}); + throw new NodeApiError(this.getNode(), { + message: 'SCA request failed, check your private key is valid', + }); } } else { throw new NodeApiError(this.getNode(), { ...response, message: response.statusMessage }); @@ -118,55 +117,55 @@ export async function wiseApiRequest( export function getTriggerName(eventName: string) { const events: IDataObject = { - 'tranferStateChange': 'transfers#state-change', - 'transferActiveCases': 'transfers#active-cases', - 'balanceCredit': 'balances#credit', + tranferStateChange: 'transfers#state-change', + transferActiveCases: 'transfers#active-cases', + balanceCredit: 'balances#credit', }; return events[eventName]; } export type BorderlessAccount = { - id: number, - balances: Array<{ currency: string }> + id: number; + balances: Array<{ currency: string }>; }; export type ExchangeRateAdditionalFields = { - interval: 'day' | 'hour' | 'minute', + interval: 'day' | 'hour' | 'minute'; range: { - rangeProperties: { from: string, to: string } - }, - time: string, + rangeProperties: { from: string; to: string }; + }; + time: string; }; export type Profile = { - id: number, - type: 'business' | 'personal', + id: number; + type: 'business' | 'personal'; }; export type Recipient = { - active: boolean, - id: number, - accountHolderName: string, - country: string | null, - currency: string, - type: string, + active: boolean; + id: number; + accountHolderName: string; + country: string | null; + currency: string; + type: string; }; export type StatementAdditionalFields = { - lineStyle: 'COMPACT' | 'FLAT', + lineStyle: 'COMPACT' | 'FLAT'; range: { - rangeProperties: { intervalStart: string, intervalEnd: string } - }, + rangeProperties: { intervalStart: string; intervalEnd: string }; + }; }; export type TransferFilters = { [key: string]: string | IDataObject; range: { - rangeProperties: { createdDateStart: string, createdDateEnd: string } - }, - sourceCurrency: string, - status: string, - targetCurrency: string, + rangeProperties: { createdDateStart: string; createdDateEnd: string }; + }; + sourceCurrency: string; + status: string; + targetCurrency: string; }; export const livePublicKey = ` diff --git a/packages/nodes-base/nodes/Wise/Wise.node.ts b/packages/nodes-base/nodes/Wise/Wise.node.ts index f80f614573..f70daa60bd 100644 --- a/packages/nodes-base/nodes/Wise/Wise.node.ts +++ b/packages/nodes-base/nodes/Wise/Wise.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -35,9 +33,7 @@ import { wiseApiRequest, } from './GenericFunctions'; -import { - omit, -} from 'lodash'; +import { omit } from 'lodash'; import moment from 'moment-timezone'; @@ -141,25 +137,29 @@ export class Wise implements INodeType { profileId: this.getNodeParameter('profileId', 0), }; - const recipients = await wiseApiRequest.call(this, 'GET', 'v1/accounts', {}, qs) as Recipient[]; + const recipients = (await wiseApiRequest.call( + this, + 'GET', + 'v1/accounts', + {}, + qs, + )) as Recipient[]; - return recipients.reduce((activeRecipients, { - active, - id, - accountHolderName, - currency, - country, - type, - }) => { - if (active) { - const recipient = { - name: `[${currency}] ${accountHolderName} - (${country !== null ? country + ' - ' : '' }${type})`, - value: id, - }; - activeRecipients.push(recipient); - } - return activeRecipients; - }, []); + return recipients.reduce( + (activeRecipients, { active, id, accountHolderName, currency, country, type }) => { + if (active) { + const recipient = { + name: `[${currency}] ${accountHolderName} - (${ + country !== null ? country + ' - ' : '' + }${type})`, + value: id, + }; + activeRecipients.push(recipient); + } + return activeRecipients; + }, + [], + ); }, }, }; @@ -177,17 +177,13 @@ export class Wise implements INodeType { let binaryOutput = false; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'account') { - // ********************************************************************* // account // ********************************************************************* if (operation === 'getBalances') { - // ---------------------------------- // account: getBalances // ---------------------------------- @@ -199,19 +195,19 @@ export class Wise implements INodeType { }; responseData = await wiseApiRequest.call(this, 'GET', 'v1/borderless-accounts', {}, qs); - } else if (operation === 'getCurrencies') { - // ---------------------------------- // account: getCurrencies // ---------------------------------- // https://api-docs.transferwise.com/#borderless-accounts-get-available-currencies - responseData = await wiseApiRequest.call(this, 'GET', 'v1/borderless-accounts/balance-currencies'); - + responseData = await wiseApiRequest.call( + this, + 'GET', + 'v1/borderless-accounts/balance-currencies', + ); } else if (operation === 'getStatement') { - // ---------------------------------- // account: getStatement // ---------------------------------- @@ -227,15 +223,24 @@ export class Wise implements INodeType { currency: this.getNodeParameter('currency', i), } as IDataObject; - const { lineStyle, range } = this.getNodeParameter('additionalFields', i) as StatementAdditionalFields; + const { lineStyle, range } = this.getNodeParameter( + 'additionalFields', + i, + ) as StatementAdditionalFields; if (lineStyle !== undefined) { qs.type = lineStyle; } if (range !== undefined) { - qs.intervalStart = moment.tz(range.rangeProperties.intervalStart, timezone).utc().format(); - qs.intervalEnd = moment.tz(range.rangeProperties.intervalEnd, timezone).utc().format(); + qs.intervalStart = moment + .tz(range.rangeProperties.intervalStart, timezone) + .utc() + .format(); + qs.intervalEnd = moment + .tz(range.rangeProperties.intervalEnd, timezone) + .utc() + .format(); } else { qs.intervalStart = moment().subtract(1, 'months').utc().format(); qs.intervalEnd = moment().utc().format(); @@ -243,27 +248,28 @@ export class Wise implements INodeType { if (format === 'json') { responseData = await wiseApiRequest.call(this, 'GET', endpoint, {}, qs); - } - else { - const data = await wiseApiRequest.call(this, 'GET', endpoint, {}, qs, {encoding: 'arraybuffer'}); + } else { + const data = await wiseApiRequest.call(this, 'GET', endpoint, {}, qs, { + encoding: 'arraybuffer', + }); const binaryProperty = this.getNodeParameter('binaryProperty', i) as string; items[i].binary = items[i].binary ?? {}; - items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData(data, this.getNodeParameter('fileName', i) as string); + items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData( + data, + this.getNodeParameter('fileName', i) as string, + ); responseData = items; binaryOutput = true; } } - } else if (resource === 'exchangeRate') { - // ********************************************************************* // exchangeRate // ********************************************************************* if (operation === 'get') { - // ---------------------------------- // exchangeRate: get // ---------------------------------- @@ -275,11 +281,10 @@ export class Wise implements INodeType { target: this.getNodeParameter('target', i), } as IDataObject; - const { - interval, - range, - time, - } = this.getNodeParameter('additionalFields', i) as ExchangeRateAdditionalFields; + const { interval, range, time } = this.getNodeParameter( + 'additionalFields', + i, + ) as ExchangeRateAdditionalFields; if (interval !== undefined) { qs.group = interval; @@ -299,15 +304,12 @@ export class Wise implements INodeType { responseData = await wiseApiRequest.call(this, 'GET', 'v1/rates', {}, qs); } - } else if (resource === 'profile') { - // ********************************************************************* // profile // ********************************************************************* if (operation === 'get') { - // ---------------------------------- // profile: get // ---------------------------------- @@ -316,9 +318,7 @@ export class Wise implements INodeType { const profileId = this.getNodeParameter('profileId', i); responseData = await wiseApiRequest.call(this, 'GET', `v1/profiles/${profileId}`); - } else if (operation === 'getAll') { - // ---------------------------------- // profile: getAll // ---------------------------------- @@ -326,17 +326,13 @@ export class Wise implements INodeType { // https://api-docs.transferwise.com/#user-profiles-list responseData = await wiseApiRequest.call(this, 'GET', 'v1/profiles'); - } - } else if (resource === 'recipient') { - // ********************************************************************* // recipient // ********************************************************************* if (operation === 'getAll') { - // ---------------------------------- // recipient: getAll // ---------------------------------- @@ -352,15 +348,12 @@ export class Wise implements INodeType { responseData = responseData.slice(0, limit); } } - } else if (resource === 'quote') { - // ********************************************************************* // quote // ********************************************************************* if (operation === 'create') { - // ---------------------------------- // quote: create // ---------------------------------- @@ -382,9 +375,7 @@ export class Wise implements INodeType { } responseData = await wiseApiRequest.call(this, 'POST', 'v2/quotes', body, {}); - } else if (operation === 'get') { - // ---------------------------------- // quote: get // ---------------------------------- @@ -394,15 +385,12 @@ export class Wise implements INodeType { const quoteId = this.getNodeParameter('quoteId', i); responseData = await wiseApiRequest.call(this, 'GET', `v2/quotes/${quoteId}`); } - } else if (resource === 'transfer') { - // ********************************************************************* // transfer // ********************************************************************* if (operation === 'create') { - // ---------------------------------- // transfer: create // ---------------------------------- @@ -415,16 +403,16 @@ export class Wise implements INodeType { customerTransactionId: uuid(), } as IDataObject; - const { reference } = this.getNodeParameter('additionalFields', i) as { reference: string }; + const { reference } = this.getNodeParameter('additionalFields', i) as { + reference: string; + }; if (reference !== undefined) { body.details = { reference }; } responseData = await wiseApiRequest.call(this, 'POST', 'v1/transfers', body, {}); - } else if (operation === 'delete') { - // ---------------------------------- // transfer: delete // ---------------------------------- @@ -432,10 +420,12 @@ export class Wise implements INodeType { // https://api-docs.transferwise.com/#transfers-cancel const transferId = this.getNodeParameter('transferId', i); - responseData = await wiseApiRequest.call(this, 'PUT', `v1/transfers/${transferId}/cancel`); - + responseData = await wiseApiRequest.call( + this, + 'PUT', + `v1/transfers/${transferId}/cancel`, + ); } else if (operation === 'execute') { - // ---------------------------------- // transfer: execute // ---------------------------------- @@ -446,7 +436,13 @@ export class Wise implements INodeType { const transferId = this.getNodeParameter('transferId', i) as string; const endpoint = `v3/profiles/${profileId}/transfers/${transferId}/payments`; - responseData = await wiseApiRequest.call(this, 'POST', endpoint, { type: 'BALANCE' }, {}); + responseData = await wiseApiRequest.call( + this, + 'POST', + endpoint, + { type: 'BALANCE' }, + {}, + ); // in sandbox, simulate transfer completion so that PDF receipt can be downloaded @@ -454,40 +450,48 @@ export class Wise implements INodeType { if (environment === 'test') { for (const endpoint of ['processing', 'funds_converted', 'outgoing_payment_sent']) { - await wiseApiRequest.call(this, 'GET', `v1/simulation/transfers/${transferId}/${endpoint}`); + await wiseApiRequest.call( + this, + 'GET', + `v1/simulation/transfers/${transferId}/${endpoint}`, + ); } } - } else if (operation === 'get') { - // ---------------------------------- // transfer: get // ---------------------------------- const transferId = this.getNodeParameter('transferId', i); const downloadReceipt = this.getNodeParameter('downloadReceipt', i) as boolean; - - if (downloadReceipt) { + if (downloadReceipt) { // https://api-docs.transferwise.com/#transfers-get-receipt-pdf - const data = await wiseApiRequest.call(this, 'GET', `v1/transfers/${transferId}/receipt.pdf`, {}, {}, {encoding: 'arraybuffer'}); + const data = await wiseApiRequest.call( + this, + 'GET', + `v1/transfers/${transferId}/receipt.pdf`, + {}, + {}, + { encoding: 'arraybuffer' }, + ); const binaryProperty = this.getNodeParameter('binaryProperty', i) as string; items[i].binary = items[i].binary ?? {}; - items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData(data, this.getNodeParameter('fileName', i) as string); + items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData( + data, + this.getNodeParameter('fileName', i) as string, + ); responseData = items; binaryOutput = true; } else { - // https://api-docs.transferwise.com/#transfers-get-by-id responseData = await wiseApiRequest.call(this, 'GET', `v1/transfers/${transferId}`); } - } else if (operation === 'getAll') { - // ---------------------------------- // transfer: getAll // ---------------------------------- @@ -500,7 +504,7 @@ export class Wise implements INodeType { const filters = this.getNodeParameter('filters', i) as TransferFilters; - Object.keys(omit(filters, 'range')).forEach(key => { + Object.keys(omit(filters, 'range')).forEach((key) => { qs[key] = filters[key]; }); diff --git a/packages/nodes-base/nodes/Wise/WiseTrigger.node.ts b/packages/nodes-base/nodes/Wise/WiseTrigger.node.ts index 9e6cd55ac8..27ea6c30ca 100644 --- a/packages/nodes-base/nodes/Wise/WiseTrigger.node.ts +++ b/packages/nodes-base/nodes/Wise/WiseTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -19,9 +16,7 @@ import { wiseApiRequest, } from './GenericFunctions'; -import { - createVerify, -} from 'crypto'; +import { createVerify } from 'crypto'; export class WiseTrigger implements INodeType { description: INodeTypeDescription = { @@ -56,7 +51,8 @@ export class WiseTrigger implements INodeType { displayName: 'Profile Name or ID', name: 'profileId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, typeOptions: { loadOptionsMethod: 'getProfiles', @@ -78,12 +74,12 @@ export class WiseTrigger implements INodeType { { name: 'Transfer Active Case', value: 'transferActiveCases', - description: 'Triggered every time a transfer\'s list of active cases is updated', + description: "Triggered every time a transfer's list of active cases is updated", }, { name: 'Transfer State Changed', value: 'tranferStateChange', - description: 'Triggered every time a transfer\'s status is updated', + description: "Triggered every time a transfer's status is updated", }, ], }, @@ -109,10 +105,18 @@ export class WiseTrigger implements INodeType { const webhookUrl = this.getNodeWebhookUrl('default'); const profileId = this.getNodeParameter('profileId') as string; const event = this.getNodeParameter('event') as string; - const webhooks = await wiseApiRequest.call(this, 'GET', `v3/profiles/${profileId}/subscriptions`); + const webhooks = await wiseApiRequest.call( + this, + 'GET', + `v3/profiles/${profileId}/subscriptions`, + ); const trigger = getTriggerName(event); for (const webhook of webhooks) { - if (webhook.delivery.url === webhookUrl && webhook.scope.id === profileId && webhook.trigger_on === trigger) { + if ( + webhook.delivery.url === webhookUrl && + webhook.scope.id === profileId && + webhook.trigger_on === trigger + ) { webhookData.webhookId = webhook.id; return true; } @@ -133,7 +137,12 @@ export class WiseTrigger implements INodeType { url: webhookUrl, }, }; - const webhook = await wiseApiRequest.call(this, 'POST', `v3/profiles/${profileId}/subscriptions`, body); + const webhook = await wiseApiRequest.call( + this, + 'POST', + `v3/profiles/${profileId}/subscriptions`, + body, + ); webhookData.webhookId = webhook.id; return true; }, @@ -141,7 +150,11 @@ export class WiseTrigger implements INodeType { const webhookData = this.getWorkflowStaticData('node'); const profileId = this.getNodeParameter('profileId') as string; try { - await wiseApiRequest.call(this, 'DELETE', `v3/profiles/${profileId}/subscriptions/${webhookData.webhookId}`); + await wiseApiRequest.call( + this, + 'DELETE', + `v3/profiles/${profileId}/subscriptions/${webhookData.webhookId}`, + ); } catch (error) { return false; } @@ -166,24 +179,19 @@ export class WiseTrigger implements INodeType { const signature = headers['x-signature'] as string; - const publicKey = (credentials.environment === 'test') ? testPublicKey : livePublicKey as string; + const publicKey = + credentials.environment === 'test' ? testPublicKey : (livePublicKey as string); //@ts-ignore const sig = createVerify('RSA-SHA1').update(req.rawBody); - const verified = sig.verify( - publicKey, - signature, - 'base64', - ); + const verified = sig.verify(publicKey, signature, 'base64'); if (verified === false) { return {}; } return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/Wise/descriptions/AccountDescription.ts b/packages/nodes-base/nodes/Wise/descriptions/AccountDescription.ts index 55ea13489d..9791921bc5 100644 --- a/packages/nodes-base/nodes/Wise/descriptions/AccountDescription.ts +++ b/packages/nodes-base/nodes/Wise/descriptions/AccountDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const accountOperations: INodeProperties[] = [ { @@ -31,9 +29,7 @@ export const accountOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'account', - ], + resource: ['account'], }, }, }, @@ -52,15 +48,12 @@ export const accountFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getProfiles', }, - description: 'ID of the user profile to retrieve the balance of. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user profile to retrieve the balance of. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getBalances', - ], + resource: ['account'], + operation: ['getBalances'], }, }, }, @@ -76,15 +69,12 @@ export const accountFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getProfiles', }, - description: 'ID of the user profile whose account to retrieve the statement of. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user profile whose account to retrieve the statement of. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getStatement', - ], + resource: ['account'], + operation: ['getStatement'], }, }, }, @@ -96,19 +86,14 @@ export const accountFields: INodeProperties[] = [ required: true, typeOptions: { loadOptionsMethod: 'getBorderlessAccounts', - loadOptionsDependsOn: [ - 'profileId', - ], + loadOptionsDependsOn: ['profileId'], }, - description: 'ID of the borderless account to retrieve the statement of. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the borderless account to retrieve the statement of. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getStatement', - ], + resource: ['account'], + operation: ['getStatement'], }, }, }, @@ -121,12 +106,8 @@ export const accountFields: INodeProperties[] = [ description: 'Code of the currency of the borderless account to retrieve the statement of', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getStatement', - ], + resource: ['account'], + operation: ['getStatement'], }, }, }, @@ -138,12 +119,8 @@ export const accountFields: INodeProperties[] = [ description: 'File format to retrieve the statement in', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getStatement', - ], + resource: ['account'], + operation: ['getStatement'], }, }, options: [ @@ -170,16 +147,9 @@ export const accountFields: INodeProperties[] = [ description: 'Name of the binary property to which to write to', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getStatement', - ], - format: [ - 'csv', - 'pdf', - ], + resource: ['account'], + operation: ['getStatement'], + format: ['csv', 'pdf'], }, }, }, @@ -193,16 +163,9 @@ export const accountFields: INodeProperties[] = [ description: 'Name of the file that will be downloaded', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getStatement', - ], - format: [ - 'csv', - 'pdf', - ], + resource: ['account'], + operation: ['getStatement'], + format: ['csv', 'pdf'], }, }, }, @@ -214,12 +177,8 @@ export const accountFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getStatement', - ], + resource: ['account'], + operation: ['getStatement'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Wise/descriptions/ExchangeRateDescription.ts b/packages/nodes-base/nodes/Wise/descriptions/ExchangeRateDescription.ts index bbcf0d94ec..6517deb1ee 100644 --- a/packages/nodes-base/nodes/Wise/descriptions/ExchangeRateDescription.ts +++ b/packages/nodes-base/nodes/Wise/descriptions/ExchangeRateDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const exchangeRateOperations: INodeProperties[] = [ { @@ -18,9 +16,7 @@ export const exchangeRateOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'exchangeRate', - ], + resource: ['exchangeRate'], }, }, }, @@ -38,12 +34,8 @@ export const exchangeRateFields: INodeProperties[] = [ description: 'Code of the source currency to retrieve the exchange rate for', displayOptions: { show: { - resource: [ - 'exchangeRate', - ], - operation: [ - 'get', - ], + resource: ['exchangeRate'], + operation: ['get'], }, }, }, @@ -55,12 +47,8 @@ export const exchangeRateFields: INodeProperties[] = [ description: 'Code of the target currency to retrieve the exchange rate for', displayOptions: { show: { - resource: [ - 'exchangeRate', - ], - operation: [ - 'get', - ], + resource: ['exchangeRate'], + operation: ['get'], }, }, }, @@ -72,12 +60,8 @@ export const exchangeRateFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'exchangeRate', - ], - operation: [ - 'get', - ], + resource: ['exchangeRate'], + operation: ['get'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Wise/descriptions/ProfileDescription.ts b/packages/nodes-base/nodes/Wise/descriptions/ProfileDescription.ts index 0987ea216e..1eba3d70b5 100644 --- a/packages/nodes-base/nodes/Wise/descriptions/ProfileDescription.ts +++ b/packages/nodes-base/nodes/Wise/descriptions/ProfileDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const profileOperations: INodeProperties[] = [ { @@ -23,9 +21,7 @@ export const profileOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'profile', - ], + resource: ['profile'], }, }, }, @@ -44,15 +40,12 @@ export const profileFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getProfiles', }, - description: 'ID of the user profile to retrieve. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user profile to retrieve. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'profile', - ], - operation: [ - 'get', - ], + resource: ['profile'], + operation: ['get'], }, }, }, diff --git a/packages/nodes-base/nodes/Wise/descriptions/QuoteDescription.ts b/packages/nodes-base/nodes/Wise/descriptions/QuoteDescription.ts index 8c8545b35f..5d73bee875 100644 --- a/packages/nodes-base/nodes/Wise/descriptions/QuoteDescription.ts +++ b/packages/nodes-base/nodes/Wise/descriptions/QuoteDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const quoteOperations: INodeProperties[] = [ { @@ -23,9 +21,7 @@ export const quoteOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'quote', - ], + resource: ['quote'], }, }, }, @@ -44,15 +40,12 @@ export const quoteFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getProfiles', }, - description: 'ID of the user profile to create the quote under. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user profile to create the quote under. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'create', - ], + resource: ['quote'], + operation: ['create'], }, }, }, @@ -65,15 +58,12 @@ export const quoteFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getRecipients', }, - description: 'ID of the account that will receive the funds. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the account that will receive the funds. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'create', - ], + resource: ['quote'], + operation: ['create'], }, }, }, @@ -95,12 +85,8 @@ export const quoteFields: INodeProperties[] = [ description: 'Whether the amount is to be sent or received', displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'create', - ], + resource: ['quote'], + operation: ['create'], }, }, }, @@ -115,12 +101,8 @@ export const quoteFields: INodeProperties[] = [ description: 'Amount of funds for the quote to create', displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'create', - ], + resource: ['quote'], + operation: ['create'], }, }, }, @@ -132,12 +114,8 @@ export const quoteFields: INodeProperties[] = [ description: 'Code of the currency to send for the quote to create', displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'create', - ], + resource: ['quote'], + operation: ['create'], }, }, }, @@ -149,12 +127,8 @@ export const quoteFields: INodeProperties[] = [ description: 'Code of the currency to receive for the quote to create', displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'create', - ], + resource: ['quote'], + operation: ['create'], }, }, }, @@ -171,12 +145,8 @@ export const quoteFields: INodeProperties[] = [ description: 'ID of the quote to retrieve', displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'get', - ], + resource: ['quote'], + operation: ['get'], }, }, }, diff --git a/packages/nodes-base/nodes/Wise/descriptions/RecipientDescription.ts b/packages/nodes-base/nodes/Wise/descriptions/RecipientDescription.ts index 5442c6330c..9ffd49346d 100644 --- a/packages/nodes-base/nodes/Wise/descriptions/RecipientDescription.ts +++ b/packages/nodes-base/nodes/Wise/descriptions/RecipientDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const recipientOperations: INodeProperties[] = [ { @@ -18,9 +16,7 @@ export const recipientOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'recipient', - ], + resource: ['recipient'], }, }, }, @@ -38,12 +34,8 @@ export const recipientFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'recipient', - ], - operation: [ - 'getAll', - ], + resource: ['recipient'], + operation: ['getAll'], }, }, }, @@ -59,15 +51,9 @@ export const recipientFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'recipient', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['recipient'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Wise/descriptions/TransferDescription.ts b/packages/nodes-base/nodes/Wise/descriptions/TransferDescription.ts index 55e5bb13d5..bef2d10788 100644 --- a/packages/nodes-base/nodes/Wise/descriptions/TransferDescription.ts +++ b/packages/nodes-base/nodes/Wise/descriptions/TransferDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const transferOperations: INodeProperties[] = [ { @@ -38,9 +36,7 @@ export const transferOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'transfer', - ], + resource: ['transfer'], }, }, }, @@ -58,19 +54,14 @@ export const transferFields: INodeProperties[] = [ default: [], typeOptions: { loadOptionsMethod: 'getProfiles', - loadOptionsDependsOn: [ - 'profileId', - ], + loadOptionsDependsOn: ['profileId'], }, - description: 'ID of the user profile to retrieve the balance of. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user profile to retrieve the balance of. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'transfer', - ], - operation: [ - 'create', - ], + resource: ['transfer'], + operation: ['create'], }, }, }, @@ -83,12 +74,8 @@ export const transferFields: INodeProperties[] = [ description: 'ID of the quote based on which to create the transfer', displayOptions: { show: { - resource: [ - 'transfer', - ], - operation: [ - 'create', - ], + resource: ['transfer'], + operation: ['create'], }, }, }, @@ -101,15 +88,12 @@ export const transferFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getRecipients', }, - description: 'ID of the account that will receive the funds. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the account that will receive the funds. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'transfer', - ], - operation: [ - 'create', - ], + resource: ['transfer'], + operation: ['create'], }, }, }, @@ -121,12 +105,8 @@ export const transferFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'transfer', - ], - operation: [ - 'create', - ], + resource: ['transfer'], + operation: ['create'], }, }, options: [ @@ -135,7 +115,7 @@ export const transferFields: INodeProperties[] = [ name: 'reference', type: 'string', default: '', - description: 'Reference text to show in the recipient\'s bank statement', + description: "Reference text to show in the recipient's bank statement", }, ], }, @@ -152,12 +132,8 @@ export const transferFields: INodeProperties[] = [ description: 'ID of the transfer to delete', displayOptions: { show: { - resource: [ - 'transfer', - ], - operation: [ - 'delete', - ], + resource: ['transfer'], + operation: ['delete'], }, }, }, @@ -174,15 +150,12 @@ export const transferFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getProfiles', }, - description: 'ID of the user profile to execute the transfer under. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user profile to execute the transfer under. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'transfer', - ], - operation: [ - 'execute', - ], + resource: ['transfer'], + operation: ['execute'], }, }, }, @@ -195,12 +168,8 @@ export const transferFields: INodeProperties[] = [ description: 'ID of the transfer to execute', displayOptions: { show: { - resource: [ - 'transfer', - ], - operation: [ - 'execute', - ], + resource: ['transfer'], + operation: ['execute'], }, }, }, @@ -217,12 +186,8 @@ export const transferFields: INodeProperties[] = [ description: 'ID of the transfer to retrieve', displayOptions: { show: { - resource: [ - 'transfer', - ], - operation: [ - 'get', - ], + resource: ['transfer'], + operation: ['get'], }, }, }, @@ -232,15 +197,12 @@ export const transferFields: INodeProperties[] = [ type: 'boolean', required: true, default: false, - description: 'Whether to download the transfer receipt as a PDF file. Only for executed transfers, having status \'Outgoing Payment Sent\'.', + description: + "Whether to download the transfer receipt as a PDF file. Only for executed transfers, having status 'Outgoing Payment Sent'.", displayOptions: { show: { - resource: [ - 'transfer', - ], - operation: [ - 'get', - ], + resource: ['transfer'], + operation: ['get'], }, }, }, @@ -253,15 +215,9 @@ export const transferFields: INodeProperties[] = [ description: 'Name of the binary property to which to write to', displayOptions: { show: { - resource: [ - 'transfer', - ], - operation: [ - 'get', - ], - downloadReceipt: [ - true, - ], + resource: ['transfer'], + operation: ['get'], + downloadReceipt: [true], }, }, }, @@ -275,15 +231,9 @@ export const transferFields: INodeProperties[] = [ description: 'Name of the file that will be downloaded', displayOptions: { show: { - resource: [ - 'transfer', - ], - operation: [ - 'get', - ], - downloadReceipt: [ - true, - ], + resource: ['transfer'], + operation: ['get'], + downloadReceipt: [true], }, }, }, @@ -300,15 +250,12 @@ export const transferFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getProfiles', }, - description: 'ID of the user profile to retrieve. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user profile to retrieve. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'transfer', - ], - operation: [ - 'getAll', - ], + resource: ['transfer'], + operation: ['getAll'], }, }, }, @@ -320,12 +267,8 @@ export const transferFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'transfer', - ], - operation: [ - 'getAll', - ], + resource: ['transfer'], + operation: ['getAll'], }, }, }, @@ -341,15 +284,9 @@ export const transferFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'transfer', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['transfer'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -361,12 +298,8 @@ export const transferFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'transfer', - ], - operation: [ - 'getAll', - ], + resource: ['transfer'], + operation: ['getAll'], }, }, options: [ diff --git a/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts b/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts index 68ec401477..d6add88075 100644 --- a/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts +++ b/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -17,26 +15,30 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - ICouponLine, - IFeeLine, - ILineItem, - IShoppingLine, -} from './OrderInterface'; +import { ICouponLine, IFeeLine, ILineItem, IShoppingLine } from './OrderInterface'; -import { - createHash, -} from 'crypto'; +import { createHash } from 'crypto'; -import { - snakeCase, -} from 'change-case'; +import { snakeCase } from 'change-case'; -import { - omit -} from 'lodash'; +import { omit } from 'lodash'; -export async function woocommerceApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function woocommerceApiRequest( + this: + | IHookFunctions + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IWebhookFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('wooCommerceApi'); let options: OptionsWithUri = { @@ -52,21 +54,30 @@ export async function woocommerceApiRequest(this: IHookFunctions | IExecuteFunct } options = Object.assign({}, options, option); try { - return await this.helpers.requestWithAuthentication.call(this,'wooCommerceApi', options); + return await this.helpers.requestWithAuthentication.call(this, 'wooCommerceApi', options); } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function woocommerceApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function woocommerceApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; let uri: string | undefined; query.per_page = 100; do { - responseData = await woocommerceApiRequest.call(this, method, endpoint, body, query, uri, { resolveWithFullResponse: true }); + responseData = await woocommerceApiRequest.call(this, method, endpoint, body, query, uri, { + resolveWithFullResponse: true, + }); const links = responseData.headers.link.split(','); const nextLink = links.find((link: string) => link.indexOf('rel="next"') !== -1); if (nextLink) { @@ -93,12 +104,9 @@ export function getAutomaticSecret(credentials: ICredentialDataDecryptedObject) return createHash('md5').update(data).digest('hex'); } -export function setMetadata(data: - IShoppingLine[] | - IShoppingLine[] | - IFeeLine[] | - ILineItem[] | - ICouponLine[]) { +export function setMetadata( + data: IShoppingLine[] | IShoppingLine[] | IFeeLine[] | ILineItem[] | ICouponLine[], +) { for (let i = 0; i < data.length; i++) { //@ts-ignore\ if (data[i].metadataUi && data[i].metadataUi.metadataValues) { @@ -113,13 +121,9 @@ export function setMetadata(data: } } -export function toSnakeCase(data: - IShoppingLine[] | - IShoppingLine[] | - IFeeLine[] | - ILineItem[] | - ICouponLine[] | - IDataObject) { +export function toSnakeCase( + data: IShoppingLine[] | IShoppingLine[] | IFeeLine[] | ILineItem[] | ICouponLine[] | IDataObject, +) { if (!Array.isArray(data)) { data = [data]; } @@ -142,13 +146,12 @@ export function toSnakeCase(data: } export function setFields(fieldsToSet: IDataObject, body: IDataObject) { - for(const fields in fieldsToSet) { + for (const fields in fieldsToSet) { if (fields === 'tags') { - body['tags'] = (fieldsToSet[fields] as string[]).map(tag => ({id: parseInt(tag, 10)})); + body['tags'] = (fieldsToSet[fields] as string[]).map((tag) => ({ id: parseInt(tag, 10) })); } else { body[snakeCase(fields.toString())] = fieldsToSet[fields]; } - } } @@ -164,5 +167,5 @@ export function adjustMetadata(fields: IDataObject & Metadata) { type Metadata = { meta_data?: { meta_data_fields: Array<{ key: string; value: string }>; - } + }; }; diff --git a/packages/nodes-base/nodes/WooCommerce/OrderDescription.ts b/packages/nodes-base/nodes/WooCommerce/OrderDescription.ts index 88d79c5bd9..903a32bdd9 100644 --- a/packages/nodes-base/nodes/WooCommerce/OrderDescription.ts +++ b/packages/nodes-base/nodes/WooCommerce/OrderDescription.ts @@ -8,9 +8,7 @@ export const orderOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'order', - ], + resource: ['order'], }, }, options: [ @@ -50,10 +48,9 @@ export const orderOperations: INodeProperties[] = [ ]; export const orderFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* order:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* order:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Additional Fields', name: 'additionalFields', @@ -62,12 +59,8 @@ export const orderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'create', - ], + resource: ['order'], + operation: ['create'], }, }, options: [ @@ -119,7 +112,8 @@ export const orderFields: INodeProperties[] = [ name: 'setPaid', type: 'boolean', default: false, - description: 'Whether the order is paid. It will set the status to processing and reduce stock items.', + description: + 'Whether the order is paid. It will set the status to processing and reduce stock items.', }, { displayName: 'Status', @@ -182,12 +176,8 @@ export const orderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'create', - ], + resource: ['order'], + operation: ['create'], }, }, description: 'Billing address', @@ -273,12 +263,8 @@ export const orderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'create', - ], + resource: ['order'], + operation: ['create'], }, }, description: 'Coupons line data', @@ -342,12 +328,8 @@ export const orderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'create', - ], + resource: ['order'], + operation: ['create'], }, }, description: 'Fee line data', @@ -442,12 +424,8 @@ export const orderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'create', - ], + resource: ['order'], + operation: ['create'], }, }, description: 'Line item data', @@ -552,12 +530,8 @@ export const orderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'create', - ], + resource: ['order'], + operation: ['create'], }, }, description: 'Meta data', @@ -595,12 +569,8 @@ export const orderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'create', - ], + resource: ['order'], + operation: ['create'], }, }, description: 'Shipping address', @@ -673,12 +643,8 @@ export const orderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'create', - ], + resource: ['order'], + operation: ['create'], }, }, description: 'Shipping line data', @@ -745,21 +711,17 @@ export const orderFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* order:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* order:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'Order ID', name: 'orderId', type: 'string', displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'update', - ], + resource: ['order'], + operation: ['update'], }, }, default: '', @@ -772,12 +734,8 @@ export const orderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'update', - ], + resource: ['order'], + operation: ['update'], }, }, options: [ @@ -885,12 +843,8 @@ export const orderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'update', - ], + resource: ['order'], + operation: ['update'], }, }, description: 'Billing address', @@ -976,12 +930,8 @@ export const orderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'update', - ], + resource: ['order'], + operation: ['update'], }, }, description: 'Coupons line data', @@ -1045,12 +995,8 @@ export const orderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'update', - ], + resource: ['order'], + operation: ['update'], }, }, description: 'Fee line data', @@ -1145,12 +1091,8 @@ export const orderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'update', - ], + resource: ['order'], + operation: ['update'], }, }, description: 'Line item data', @@ -1255,12 +1197,8 @@ export const orderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'update', - ], + resource: ['order'], + operation: ['update'], }, }, description: 'Meta data', @@ -1298,12 +1236,8 @@ export const orderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'update', - ], + resource: ['order'], + operation: ['update'], }, }, description: 'Shipping address', @@ -1376,12 +1310,8 @@ export const orderFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'update', - ], + resource: ['order'], + operation: ['update'], }, }, description: 'Shipping line data', @@ -1448,40 +1378,32 @@ export const orderFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* order:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* order:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Order ID', name: 'orderId', type: 'string', displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'get', - ], + resource: ['order'], + operation: ['get'], }, }, default: '', }, -/* -------------------------------------------------------------------------- */ -/* order:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* order:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'getAll', - ], + resource: ['order'], + operation: ['getAll'], }, }, default: false, @@ -1493,15 +1415,9 @@ export const orderFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['order'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -1519,12 +1435,8 @@ export const orderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'getAll', - ], + resource: ['order'], + operation: ['getAll'], }, }, options: [ @@ -1667,21 +1579,17 @@ export const orderFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* order:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* order:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Order ID', name: 'orderId', type: 'string', displayOptions: { show: { - resource: [ - 'order', - ], - operation: [ - 'delete', - ], + resource: ['order'], + operation: ['delete'], }, }, default: '', diff --git a/packages/nodes-base/nodes/WooCommerce/ProductDescription.ts b/packages/nodes-base/nodes/WooCommerce/ProductDescription.ts index b5812cc240..48617395f2 100644 --- a/packages/nodes-base/nodes/WooCommerce/ProductDescription.ts +++ b/packages/nodes-base/nodes/WooCommerce/ProductDescription.ts @@ -8,9 +8,7 @@ export const productOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'product', - ], + resource: ['product'], }, }, options: [ @@ -50,10 +48,9 @@ export const productOperations: INodeProperties[] = [ ]; export const productFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* product:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* product:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Name', name: 'name', @@ -62,12 +59,8 @@ export const productFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'create', - ], + resource: ['product'], + operation: ['create'], }, }, description: 'Product name', @@ -80,12 +73,8 @@ export const productFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'create', - ], + resource: ['product'], + operation: ['create'], }, }, options: [ @@ -149,7 +138,8 @@ export const productFields: INodeProperties[] = [ loadOptionsMethod: 'getCategories', }, default: [], - description: 'List of categories. Choose from the list, or specify IDs using an expression.', + description: + 'List of categories. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Cross Sell IDs', @@ -163,14 +153,14 @@ export const productFields: INodeProperties[] = [ name: 'dateOnSaleFrom', type: 'dateTime', default: '', - description: 'Start date of sale price, in the site\'s timezone', + description: "Start date of sale price, in the site's timezone", }, { displayName: 'Date On Sale To', name: 'dateOnSaleTo', type: 'dateTime', default: '', - description: 'Ennd date of sale price, in the site\'s timezone', + description: "Ennd date of sale price, in the site's timezone", }, { displayName: 'Description', @@ -348,7 +338,8 @@ export const productFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'List of tags. Choose from the list, or specify IDs using an expression.', + description: + 'List of tags. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Tax Class', @@ -435,12 +426,8 @@ export const productFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'create', - ], + resource: ['product'], + operation: ['create'], }, }, description: 'Product dimensions', @@ -485,12 +472,8 @@ export const productFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'create', - ], + resource: ['product'], + operation: ['create'], }, }, description: 'Product Image', @@ -535,12 +518,8 @@ export const productFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'create', - ], + resource: ['product'], + operation: ['create'], }, }, description: 'Meta data', @@ -567,21 +546,17 @@ export const productFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* product:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* product:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'Product ID', name: 'productId', type: 'string', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'update', - ], + resource: ['product'], + operation: ['update'], }, }, default: '', @@ -594,12 +569,8 @@ export const productFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'update', - ], + resource: ['product'], + operation: ['update'], }, }, options: [ @@ -663,7 +634,8 @@ export const productFields: INodeProperties[] = [ loadOptionsMethod: 'getCategories', }, default: [], - description: 'List of categories. Choose from the list, or specify IDs using an expression.', + description: + 'List of categories. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Cross Sell IDs', @@ -677,14 +649,14 @@ export const productFields: INodeProperties[] = [ name: 'dateOnSaleFrom', type: 'dateTime', default: '', - description: 'Start date of sale price, in the site\'s timezone', + description: "Start date of sale price, in the site's timezone", }, { displayName: 'Date On Sale To', name: 'dateOnSaleTo', type: 'dateTime', default: '', - description: 'Ennd date of sale price, in the site\'s timezone', + description: "Ennd date of sale price, in the site's timezone", }, { displayName: 'Description', @@ -869,7 +841,8 @@ export const productFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'List of tags. Choose from the list, or specify IDs using an expression.', + description: + 'List of tags. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Tax Class', @@ -956,12 +929,8 @@ export const productFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'update', - ], + resource: ['product'], + operation: ['update'], }, }, description: 'Product dimensions', @@ -1006,12 +975,8 @@ export const productFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'update', - ], + resource: ['product'], + operation: ['update'], }, }, description: 'Product Image', @@ -1056,12 +1021,8 @@ export const productFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'update', - ], + resource: ['product'], + operation: ['update'], }, }, description: 'Meta data', @@ -1088,40 +1049,32 @@ export const productFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* product:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* product:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Product ID', name: 'productId', type: 'string', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'get', - ], + resource: ['product'], + operation: ['get'], }, }, default: '', }, -/* -------------------------------------------------------------------------- */ -/* product:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* product:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'getAll', - ], + resource: ['product'], + operation: ['getAll'], }, }, default: false, @@ -1133,15 +1086,9 @@ export const productFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['product'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -1159,12 +1106,8 @@ export const productFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'getAll', - ], + resource: ['product'], + operation: ['getAll'], }, }, options: [ @@ -1190,7 +1133,8 @@ export const productFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCategories', }, - description: 'Limit result set to products assigned a specific category ID. Choose from the list, or specify an ID using an expression.', + description: + 'Limit result set to products assigned a specific category ID. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Context', @@ -1359,7 +1303,8 @@ export const productFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTags', }, - description: 'Limit result set to products assigned a specific tag ID. Choose from the list, or specify an ID using an expression.', + description: + 'Limit result set to products assigned a specific tag ID. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Tax Class', @@ -1409,21 +1354,17 @@ export const productFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* product:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* product:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Product ID', name: 'productId', type: 'string', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'delete', - ], + resource: ['product'], + operation: ['delete'], }, }, default: '', diff --git a/packages/nodes-base/nodes/WooCommerce/ProductInterface.ts b/packages/nodes-base/nodes/WooCommerce/ProductInterface.ts index b4382677cb..b68e2a4661 100644 --- a/packages/nodes-base/nodes/WooCommerce/ProductInterface.ts +++ b/packages/nodes-base/nodes/WooCommerce/ProductInterface.ts @@ -13,5 +13,13 @@ export interface IImage { } export interface IProduct { - [index: string]: string | number | string[] | number[] | IDataObject | IDataObject[] | IImage[] | IDimension; + [index: string]: + | string + | number + | string[] + | number[] + | IDataObject + | IDataObject[] + | IImage[] + | IDimension; } diff --git a/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts b/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts index ebf0463652..d71d472324 100644 --- a/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts +++ b/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, ILoadOptionsFunctions, @@ -17,19 +15,9 @@ import { woocommerceApiRequest, woocommerceApiRequestAllItems, } from './GenericFunctions'; -import { - productFields, - productOperations, -} from './ProductDescription'; -import { - orderFields, - orderOperations, -} from './OrderDescription'; -import { - IDimension, - IImage, - IProduct, -} from './ProductInterface'; +import { productFields, productOperations } from './ProductDescription'; +import { orderFields, orderOperations } from './OrderDescription'; +import { IDimension, IImage, IProduct } from './ProductInterface'; import { IAddress, ICouponLine, @@ -39,10 +27,7 @@ import { IShoppingLine, } from './OrderInterface'; -import { - customerFields, - customerOperations, -} from './descriptions'; +import { customerFields, customerOperations } from './descriptions'; export class WooCommerce implements INodeType { description: INodeTypeDescription = { @@ -101,7 +86,12 @@ export class WooCommerce implements INodeType { // select them easily async getCategories(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const categories = await woocommerceApiRequestAllItems.call(this, 'GET', '/products/categories', {}); + const categories = await woocommerceApiRequestAllItems.call( + this, + 'GET', + '/products/categories', + {}, + ); for (const category of categories) { const categoryName = category.name; const categoryId = category.id; @@ -140,9 +130,7 @@ export class WooCommerce implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < length; i++) { - if (resource === 'customer') { - // ********************************************************************** // customer // ********************************************************************** @@ -150,7 +138,6 @@ export class WooCommerce implements INodeType { // https://woocommerce.github.io/woocommerce-rest-api-docs/?shell#customer-properties if (operation === 'create') { - // ---------------------------------------- // customer: create // ---------------------------------------- @@ -168,9 +155,7 @@ export class WooCommerce implements INodeType { } responseData = await woocommerceApiRequest.call(this, 'POST', '/customers', body); - } else if (operation === 'delete') { - // ---------------------------------------- // customer: delete // ---------------------------------------- @@ -185,9 +170,7 @@ export class WooCommerce implements INodeType { const endpoint = `/customers/${customerId}`; responseData = await woocommerceApiRequest.call(this, 'DELETE', endpoint, {}, qs); - } else if (operation === 'get') { - // ---------------------------------------- // customer: get // ---------------------------------------- @@ -198,9 +181,7 @@ export class WooCommerce implements INodeType { const endpoint = `/customers/${customerId}`; responseData = await woocommerceApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // customer: getAll // ---------------------------------------- @@ -216,14 +197,18 @@ export class WooCommerce implements INodeType { } if (returnAll) { - responseData = await woocommerceApiRequestAllItems.call(this, 'GET', '/customers', {}, qs); + responseData = await woocommerceApiRequestAllItems.call( + this, + 'GET', + '/customers', + {}, + qs, + ); } else { qs.per_page = this.getNodeParameter('limit', i) as number; responseData = await woocommerceApiRequest.call(this, 'GET', '/customers', {}, qs); } - } else if (operation === 'update') { - // ---------------------------------------- // customer: update // ---------------------------------------- @@ -241,9 +226,7 @@ export class WooCommerce implements INodeType { const endpoint = `/customers/${customerId}`; responseData = await woocommerceApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'product') { //https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-product if (operation === 'create') { @@ -256,18 +239,23 @@ export class WooCommerce implements INodeType { setFields(additionalFields, body); if (additionalFields.categories) { - body.categories = (additionalFields.categories as string[]).map(category => ({ id: parseInt(category, 10) })) as unknown as IDataObject[]; + body.categories = (additionalFields.categories as string[]).map((category) => ({ + id: parseInt(category, 10), + })) as unknown as IDataObject[]; } - const images = (this.getNodeParameter('imagesUi', i) as IDataObject).imagesValues as IImage[]; + const images = (this.getNodeParameter('imagesUi', i) as IDataObject) + .imagesValues as IImage[]; if (images) { body.images = images; } - const dimension = (this.getNodeParameter('dimensionsUi', i) as IDataObject).dimensionsValues as IDimension; + const dimension = (this.getNodeParameter('dimensionsUi', i) as IDataObject) + .dimensionsValues as IDimension; if (dimension) { body.dimensions = dimension; } - const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject).metadataValues as IDataObject[]; + const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject) + .metadataValues as IDataObject[]; if (metadata) { body.meta_data = metadata; } @@ -281,24 +269,38 @@ export class WooCommerce implements INodeType { setFields(updateFields, body); - const images = (this.getNodeParameter('imagesUi', i) as IDataObject).imagesValues as IImage[]; + const images = (this.getNodeParameter('imagesUi', i) as IDataObject) + .imagesValues as IImage[]; if (images) { body.images = images; } - const dimension = (this.getNodeParameter('dimensionsUi', i) as IDataObject).dimensionsValues as IDimension; + const dimension = (this.getNodeParameter('dimensionsUi', i) as IDataObject) + .dimensionsValues as IDimension; if (dimension) { body.dimensions = dimension; } - const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject).metadataValues as IDataObject[]; + const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject) + .metadataValues as IDataObject[]; if (metadata) { body.meta_data = metadata; } - responseData = await woocommerceApiRequest.call(this, 'PUT', `/products/${productId}`, body); + responseData = await woocommerceApiRequest.call( + this, + 'PUT', + `/products/${productId}`, + body, + ); } //https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-a-product if (operation === 'get') { const productId = this.getNodeParameter('productId', i) as string; - responseData = await woocommerceApiRequest.call(this, 'GET', `/products/${productId}`, {}, qs); + responseData = await woocommerceApiRequest.call( + this, + 'GET', + `/products/${productId}`, + {}, + qs, + ); } //https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-products if (operation === 'getAll') { @@ -356,7 +358,13 @@ export class WooCommerce implements INodeType { qs.type = options.type as string; } if (returnAll === true) { - responseData = await woocommerceApiRequestAllItems.call(this, 'GET', '/products', {}, qs); + responseData = await woocommerceApiRequestAllItems.call( + this, + 'GET', + '/products', + {}, + qs, + ); } else { qs.per_page = this.getNodeParameter('limit', i) as number; responseData = await woocommerceApiRequest.call(this, 'GET', '/products', {}, qs); @@ -365,7 +373,13 @@ export class WooCommerce implements INodeType { //https://woocommerce.github.io/woocommerce-rest-api-docs/#delete-a-product if (operation === 'delete') { const productId = this.getNodeParameter('productId', i) as string; - responseData = await woocommerceApiRequest.call(this, 'DELETE', `/products/${productId}`, {}, { force: true }); + responseData = await woocommerceApiRequest.call( + this, + 'DELETE', + `/products/${productId}`, + {}, + { force: true }, + ); } } if (resource === 'order') { @@ -376,40 +390,47 @@ export class WooCommerce implements INodeType { setFields(additionalFields, body); - const billing = (this.getNodeParameter('billingUi', i) as IDataObject).billingValues as IAddress; + const billing = (this.getNodeParameter('billingUi', i) as IDataObject) + .billingValues as IAddress; if (billing !== undefined) { body.billing = billing; toSnakeCase(billing as IDataObject); } - const shipping = (this.getNodeParameter('shippingUi', i) as IDataObject).shippingValues as IAddress; + const shipping = (this.getNodeParameter('shippingUi', i) as IDataObject) + .shippingValues as IAddress; if (shipping !== undefined) { body.shipping = shipping; toSnakeCase(shipping as IDataObject); } - const couponLines = (this.getNodeParameter('couponLinesUi', i) as IDataObject).couponLinesValues as ICouponLine[]; + const couponLines = (this.getNodeParameter('couponLinesUi', i) as IDataObject) + .couponLinesValues as ICouponLine[]; if (couponLines) { body.coupon_lines = couponLines; setMetadata(couponLines); toSnakeCase(couponLines); } - const feeLines = (this.getNodeParameter('feeLinesUi', i) as IDataObject).feeLinesValues as IFeeLine[]; + const feeLines = (this.getNodeParameter('feeLinesUi', i) as IDataObject) + .feeLinesValues as IFeeLine[]; if (feeLines) { body.fee_lines = feeLines; setMetadata(feeLines); toSnakeCase(feeLines); } - const lineItems = (this.getNodeParameter('lineItemsUi', i) as IDataObject).lineItemsValues as ILineItem[]; + const lineItems = (this.getNodeParameter('lineItemsUi', i) as IDataObject) + .lineItemsValues as ILineItem[]; if (lineItems) { body.line_items = lineItems; setMetadata(lineItems); toSnakeCase(lineItems); //@ts-ignore } - const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject).metadataValues as IDataObject[]; + const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject) + .metadataValues as IDataObject[]; if (metadata) { body.meta_data = metadata; } - const shippingLines = (this.getNodeParameter('shippingLinesUi', i) as IDataObject).shippingLinesValues as IShoppingLine[]; + const shippingLines = (this.getNodeParameter('shippingLinesUi', i) as IDataObject) + .shippingLinesValues as IShoppingLine[]; if (shippingLines) { body.shipping_lines = shippingLines; setMetadata(shippingLines); @@ -448,39 +469,46 @@ export class WooCommerce implements INodeType { if (updateFields.transactionID) { body.transaction_id = updateFields.transactionID as string; } - const billing = (this.getNodeParameter('billingUi', i) as IDataObject).billingValues as IAddress; + const billing = (this.getNodeParameter('billingUi', i) as IDataObject) + .billingValues as IAddress; if (billing !== undefined) { body.billing = billing; toSnakeCase(billing as IDataObject); } - const shipping = (this.getNodeParameter('shippingUi', i) as IDataObject).shippingValues as IAddress; + const shipping = (this.getNodeParameter('shippingUi', i) as IDataObject) + .shippingValues as IAddress; if (shipping !== undefined) { body.shipping = shipping; toSnakeCase(shipping as IDataObject); } - const couponLines = (this.getNodeParameter('couponLinesUi', i) as IDataObject).couponLinesValues as ICouponLine[]; + const couponLines = (this.getNodeParameter('couponLinesUi', i) as IDataObject) + .couponLinesValues as ICouponLine[]; if (couponLines) { body.coupon_lines = couponLines; setMetadata(couponLines); toSnakeCase(couponLines); } - const feeLines = (this.getNodeParameter('feeLinesUi', i) as IDataObject).feeLinesValues as IFeeLine[]; + const feeLines = (this.getNodeParameter('feeLinesUi', i) as IDataObject) + .feeLinesValues as IFeeLine[]; if (feeLines) { body.fee_lines = feeLines; setMetadata(feeLines); toSnakeCase(feeLines); } - const lineItems = (this.getNodeParameter('lineItemsUi', i) as IDataObject).lineItemsValues as ILineItem[]; + const lineItems = (this.getNodeParameter('lineItemsUi', i) as IDataObject) + .lineItemsValues as ILineItem[]; if (lineItems) { body.line_items = lineItems; setMetadata(lineItems); toSnakeCase(lineItems); } - const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject).metadataValues as IDataObject[]; + const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject) + .metadataValues as IDataObject[]; if (metadata) { body.meta_data = metadata; } - const shippingLines = (this.getNodeParameter('shippingLinesUi', i) as IDataObject).shippingLinesValues as IShoppingLine[]; + const shippingLines = (this.getNodeParameter('shippingLinesUi', i) as IDataObject) + .shippingLinesValues as IShoppingLine[]; if (shippingLines) { body.shipping_lines = shippingLines; setMetadata(shippingLines); @@ -492,7 +520,13 @@ export class WooCommerce implements INodeType { //https://woocommerce.github.io/woocommerce-rest-api-docs/#retrieve-an-order if (operation === 'get') { const orderId = this.getNodeParameter('orderId', i) as string; - responseData = await woocommerceApiRequest.call(this, 'GET', `/orders/${orderId}`, {}, qs); + responseData = await woocommerceApiRequest.call( + this, + 'GET', + `/orders/${orderId}`, + {}, + qs, + ); } //https://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-orders if (operation === 'getAll') { @@ -538,7 +572,13 @@ export class WooCommerce implements INodeType { //https://woocommerce.github.io/woocommerce-rest-api-docs/#delete-an-order if (operation === 'delete') { const orderId = this.getNodeParameter('orderId', i) as string; - responseData = await woocommerceApiRequest.call(this, 'DELETE', `/orders/${orderId}`, {}, { force: true }); + responseData = await woocommerceApiRequest.call( + this, + 'DELETE', + `/orders/${orderId}`, + {}, + { force: true }, + ); } } if (Array.isArray(responseData)) { diff --git a/packages/nodes-base/nodes/WooCommerce/WooCommerceTrigger.node.ts b/packages/nodes-base/nodes/WooCommerce/WooCommerceTrigger.node.ts index 7bf86cf510..0a74994678 100644 --- a/packages/nodes-base/nodes/WooCommerce/WooCommerceTrigger.node.ts +++ b/packages/nodes-base/nodes/WooCommerce/WooCommerceTrigger.node.ts @@ -1,23 +1,10 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import { - IDataObject, - INodeType, - INodeTypeDescription, - IWebhookResponseData, -} from 'n8n-workflow'; +import { IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; -import { - getAutomaticSecret, - woocommerceApiRequest, -} from './GenericFunctions'; +import { getAutomaticSecret, woocommerceApiRequest } from './GenericFunctions'; -import { - createHmac, -} from 'crypto'; +import { createHmac } from 'crypto'; export class WooCommerceTrigger implements INodeType { description: INodeTypeDescription = { @@ -106,7 +93,6 @@ export class WooCommerceTrigger implements INodeType { description: 'Determines which resource events the webhook is triggered for', }, ], - }; // @ts-ignore @@ -118,12 +104,20 @@ export class WooCommerceTrigger implements INodeType { const currentEvent = this.getNodeParameter('event') as string; const endpoint = `/webhooks`; - const webhooks = await woocommerceApiRequest.call(this, 'GET', endpoint, {}, { status: 'active', per_page: 100 }); + const webhooks = await woocommerceApiRequest.call( + this, + 'GET', + endpoint, + {}, + { status: 'active', per_page: 100 }, + ); for (const webhook of webhooks) { - if (webhook.status === 'active' - && webhook.delivery_url === webhookUrl - && webhook.topic === currentEvent) { + if ( + webhook.status === 'active' && + webhook.delivery_url === webhookUrl && + webhook.topic === currentEvent + ) { webhookData.webhookId = webhook.id; return true; } @@ -152,7 +146,7 @@ export class WooCommerceTrigger implements INodeType { const endpoint = `/webhooks/${webhookData.webhookId}`; try { await woocommerceApiRequest.call(this, 'DELETE', endpoint, {}, { force: true }); - } catch(error) { + } catch (error) { return false; } delete webhookData.webhookId; @@ -171,17 +165,18 @@ export class WooCommerceTrigger implements INodeType { if (headerData['x-wc-webhook-id'] === undefined) { return {}; } - //@ts-ignore - const computedSignature = createHmac('sha256',webhookData.secret as string).update(req.rawBody).digest('base64'); + + const computedSignature = createHmac('sha256', webhookData.secret as string) + //@ts-ignore + .update(req.rawBody) + .digest('base64'); //@ts-ignore if (headerData['x-wc-webhook-signature'] !== computedSignature) { // Signature is not valid so ignore call return {}; } return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/WooCommerce/descriptions/CustomerDescription.ts b/packages/nodes-base/nodes/WooCommerce/descriptions/CustomerDescription.ts index e9b0220b2e..fd944e150a 100644 --- a/packages/nodes-base/nodes/WooCommerce/descriptions/CustomerDescription.ts +++ b/packages/nodes-base/nodes/WooCommerce/descriptions/CustomerDescription.ts @@ -1,11 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - customerCreateFields, - customerUpdateFields, -} from './shared'; +import { customerCreateFields, customerUpdateFields } from './shared'; export const customerOperations: INodeProperties[] = [ { @@ -15,9 +10,7 @@ export const customerOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'customer', - ], + resource: ['customer'], }, }, options: [ @@ -69,12 +62,8 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'create', - ], + resource: ['customer'], + operation: ['create'], }, }, }, @@ -92,12 +81,8 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'delete', - ], + resource: ['customer'], + operation: ['delete'], }, }, }, @@ -114,12 +99,8 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'get', - ], + resource: ['customer'], + operation: ['get'], }, }, }, @@ -135,12 +116,8 @@ export const customerFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'getAll', - ], + resource: ['customer'], + operation: ['getAll'], }, }, }, @@ -155,15 +132,9 @@ export const customerFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['customer'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -175,12 +146,8 @@ export const customerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'getAll', - ], + resource: ['customer'], + operation: ['getAll'], }, }, options: [ @@ -249,12 +216,8 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'update', - ], + resource: ['customer'], + operation: ['update'], }, }, }, diff --git a/packages/nodes-base/nodes/WooCommerce/descriptions/shared.ts b/packages/nodes-base/nodes/WooCommerce/descriptions/shared.ts index e52a38acfb..834867b5c9 100644 --- a/packages/nodes-base/nodes/WooCommerce/descriptions/shared.ts +++ b/packages/nodes-base/nodes/WooCommerce/descriptions/shared.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; const customerAddressOptions: INodeProperties[] = [ { @@ -129,12 +127,8 @@ const customerUpdateOptions: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/resource': [ - 'customer', - ], - '/operation': [ - 'create', - ], + '/resource': ['customer'], + '/operation': ['create'], }, }, default: '', @@ -167,12 +161,8 @@ export const customerCreateFields: INodeProperties = { default: {}, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'create', - ], + resource: ['customer'], + operation: ['create'], }, }, options: customerCreateOptions, @@ -186,12 +176,8 @@ export const customerUpdateFields: INodeProperties = { default: {}, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'update', - ], + resource: ['customer'], + operation: ['update'], }, }, options: customerUpdateOptions, diff --git a/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts b/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts index 145e482247..506a8fb942 100644 --- a/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts @@ -1,18 +1,20 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function wordpressApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function wordpressApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('wordpressApi'); let options: OptionsWithUri = { @@ -39,8 +41,15 @@ export async function wordpressApiRequest(this: IExecuteFunctions | IExecuteSing } } -export async function wordpressApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function wordpressApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -50,7 +59,9 @@ export async function wordpressApiRequestAllItems(this: IExecuteFunctions | ILoa do { query.page++; - responseData = await wordpressApiRequest.call(this, method, endpoint, body, query, undefined, { resolveWithFullResponse: true }); + responseData = await wordpressApiRequest.call(this, method, endpoint, body, query, undefined, { + resolveWithFullResponse: true, + }); returnData.push.apply(returnData, responseData.body); } while ( responseData.headers['x-wp-totalpages'] !== undefined && diff --git a/packages/nodes-base/nodes/Wordpress/PostDescription.ts b/packages/nodes-base/nodes/Wordpress/PostDescription.ts index d124bd8e1e..d0967a71f2 100644 --- a/packages/nodes-base/nodes/Wordpress/PostDescription.ts +++ b/packages/nodes-base/nodes/Wordpress/PostDescription.ts @@ -8,9 +8,7 @@ export const postOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'post', - ], + resource: ['post'], }, }, options: [ @@ -49,10 +47,9 @@ export const postOperations: INodeProperties[] = [ ]; export const postFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* post:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* post:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Title', name: 'title', @@ -61,12 +58,8 @@ export const postFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], + resource: ['post'], + operation: ['create'], }, }, description: 'The title for the post', @@ -79,12 +72,8 @@ export const postFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], + resource: ['post'], + operation: ['create'], }, }, options: [ @@ -96,7 +85,8 @@ export const postFields: INodeProperties[] = [ loadOptionsMethod: 'getAuthors', }, default: '', - description: 'The ID for the author of the object. Choose from the list, or specify an ID using an expression.', + description: + 'The ID for the author of the object. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Content', @@ -249,7 +239,8 @@ export const postFields: INodeProperties[] = [ loadOptionsMethod: 'getCategories', }, default: [], - description: 'The terms assigned to the object in the category taxonomy. Choose from the list, or specify IDs using an expression.', + description: + 'The terms assigned to the object in the category taxonomy. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Tag Names or IDs', @@ -259,7 +250,8 @@ export const postFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'The terms assigned to the object in the post_tag taxonomy. Choose from the list, or specify IDs using an expression.', + description: + 'The terms assigned to the object in the post_tag taxonomy. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Template', @@ -289,7 +281,7 @@ export const postFields: INodeProperties[] = [ description: 'The theme file to use', displayOptions: { show: { - elementor: [ false ], + elementor: [false], }, }, }, @@ -319,7 +311,7 @@ export const postFields: INodeProperties[] = [ description: 'The Elementor template to use', displayOptions: { show: { - elementor: [ true ], + elementor: [true], }, }, }, @@ -329,9 +321,9 @@ export const postFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* post:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* post:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'Post ID', name: 'postId', @@ -340,12 +332,8 @@ export const postFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'update', - ], + resource: ['post'], + operation: ['update'], }, }, description: 'Unique identifier for the object', @@ -358,12 +346,8 @@ export const postFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'update', - ], + resource: ['post'], + operation: ['update'], }, }, options: [ @@ -375,7 +359,8 @@ export const postFields: INodeProperties[] = [ loadOptionsMethod: 'getAuthors', }, default: '', - description: 'The ID for the author of the object. Choose from the list, or specify an ID using an expression.', + description: + 'The ID for the author of the object. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Title', @@ -535,7 +520,8 @@ export const postFields: INodeProperties[] = [ loadOptionsMethod: 'getCategories', }, default: [], - description: 'The terms assigned to the object in the category taxonomy. Choose from the list, or specify IDs using an expression.', + description: + 'The terms assigned to the object in the category taxonomy. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Tag Names or IDs', @@ -545,7 +531,8 @@ export const postFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'The terms assigned to the object in the post_tag taxonomy. Choose from the list, or specify IDs using an expression.', + description: + 'The terms assigned to the object in the post_tag taxonomy. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Template', @@ -575,7 +562,7 @@ export const postFields: INodeProperties[] = [ description: 'The theme file to use', displayOptions: { show: { - elementor: [ false ], + elementor: [false], }, }, }, @@ -605,7 +592,7 @@ export const postFields: INodeProperties[] = [ description: 'The Elementor template to use', displayOptions: { show: { - elementor: [ true ], + elementor: [true], }, }, }, @@ -615,9 +602,9 @@ export const postFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* post:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* post:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Post ID', name: 'postId', @@ -626,12 +613,8 @@ export const postFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'get', - ], + resource: ['post'], + operation: ['get'], }, }, description: 'Unique identifier for the object', @@ -644,12 +627,8 @@ export const postFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'get', - ], + resource: ['post'], + operation: ['get'], }, }, options: [ @@ -683,21 +662,17 @@ export const postFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* post:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* post:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'getAll', - ], + resource: ['post'], + operation: ['getAll'], }, }, default: false, @@ -709,15 +684,9 @@ export const postFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['post'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -735,12 +704,8 @@ export const postFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'getAll', - ], + resource: ['post'], + operation: ['getAll'], }, }, options: [ @@ -759,7 +724,8 @@ export const postFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getAuthors', }, - description: 'Limit result set to posts assigned to specific authors. Choose from the list, or specify IDs using an expression.', + description: + 'Limit result set to posts assigned to specific authors. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Before', @@ -776,7 +742,8 @@ export const postFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCategories', }, - description: 'Limit result set to all items that have the specified term assigned in the categories taxonomy. Choose from the list, or specify IDs using an expression.', + description: + 'Limit result set to all items that have the specified term assigned in the categories taxonomy. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Context', @@ -808,7 +775,8 @@ export const postFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCategories', }, - description: 'Limit result set to all items except those that have the specified term assigned in the categories taxonomy. Choose from the list, or specify IDs using an expression.', + description: + 'Limit result set to all items except those that have the specified term assigned in the categories taxonomy. Choose from the list, or specify IDs using an expression.', }, { // eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-dynamic-multi-options @@ -819,7 +787,8 @@ export const postFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTags', }, - description: 'Limit result set to all items except those that have the specified term assigned in the tags taxonomy. Choose from the list, or specify IDs using an expression.', + description: + 'Limit result set to all items except those that have the specified term assigned in the tags taxonomy. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Order', @@ -938,13 +907,14 @@ export const postFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTags', }, - description: 'Limit result set to all items that have the specified term assigned in the tags taxonomy. Choose from the list, or specify IDs using an expression.', + description: + 'Limit result set to all items that have the specified term assigned in the tags taxonomy. Choose from the list, or specify IDs using an expression.', }, ], }, -/* -------------------------------------------------------------------------- */ -/* post:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* post:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Post ID', name: 'postId', @@ -953,12 +923,8 @@ export const postFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'delete', - ], + resource: ['post'], + operation: ['delete'], }, }, description: 'Unique identifier for the object', @@ -971,12 +937,8 @@ export const postFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'delete', - ], + resource: ['post'], + operation: ['delete'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Wordpress/PostInterface.ts b/packages/nodes-base/nodes/Wordpress/PostInterface.ts index 995ed6aec6..7c27c8345b 100644 --- a/packages/nodes-base/nodes/Wordpress/PostInterface.ts +++ b/packages/nodes-base/nodes/Wordpress/PostInterface.ts @@ -1,4 +1,3 @@ - export interface IPost { author?: number; id?: number; diff --git a/packages/nodes-base/nodes/Wordpress/UserDescription.ts b/packages/nodes-base/nodes/Wordpress/UserDescription.ts index 8b46c17054..8a33811455 100644 --- a/packages/nodes-base/nodes/Wordpress/UserDescription.ts +++ b/packages/nodes-base/nodes/Wordpress/UserDescription.ts @@ -8,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -49,10 +47,9 @@ export const userOperations: INodeProperties[] = [ ]; export const userFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* user:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Username', name: 'username', @@ -61,12 +58,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, description: 'Login name for the user', @@ -79,12 +72,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, description: 'Display name for the user', @@ -97,12 +86,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, description: 'First name for the user', @@ -115,12 +100,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, description: 'Last name for the user', @@ -134,12 +115,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, description: 'The email address for the user', @@ -152,12 +129,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, description: 'Password for the user (never included)', @@ -170,12 +143,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, options: [ @@ -212,9 +181,9 @@ export const userFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* user:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'User ID', name: 'userId', @@ -223,12 +192,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, description: 'Unique identifier for the user', @@ -241,12 +206,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, options: [ @@ -326,9 +287,9 @@ export const userFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* user:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'User ID', name: 'userId', @@ -337,12 +298,8 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, description: 'Unique identifier for the user', @@ -355,12 +312,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, options: [ @@ -387,171 +340,157 @@ export const userFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* user:getAll */ -/* -------------------------------------------------------------------------- */ -{ - displayName: 'Return All', - name: 'returnAll', - type: 'boolean', - displayOptions: { - show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + /* -------------------------------------------------------------------------- */ + /* user:getAll */ + /* -------------------------------------------------------------------------- */ + { + displayName: 'Return All', + name: 'returnAll', + type: 'boolean', + displayOptions: { + show: { + resource: ['user'], + operation: ['getAll'], + }, }, + default: false, + description: 'Whether to return all results or only up to a given limit', }, - default: false, - description: 'Whether to return all results or only up to a given limit', -}, -{ - displayName: 'Limit', - name: 'limit', - type: 'number', - displayOptions: { - show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + { + displayName: 'Limit', + name: 'limit', + type: 'number', + displayOptions: { + show: { + resource: ['user'], + operation: ['getAll'], + returnAll: [false], + }, }, + typeOptions: { + minValue: 1, + maxValue: 10, + }, + default: 5, + description: 'Max number of results to return', }, - typeOptions: { - minValue: 1, - maxValue: 10, + { + displayName: 'Options', + name: 'options', + type: 'collection', + placeholder: 'Add Option', + default: {}, + displayOptions: { + show: { + resource: ['user'], + operation: ['getAll'], + }, + }, + options: [ + { + displayName: 'Context', + name: 'context', + type: 'options', + options: [ + { + name: 'View', + value: 'view', + }, + { + name: 'Embed', + value: 'embed', + }, + { + name: 'Edit', + value: 'edit', + }, + ], + default: 'view', + description: 'Scope under which the request is made; determines fields present in response', + }, + { + displayName: 'Order By', + name: 'orderBy', + type: 'options', + options: [ + { + name: 'Email', + value: 'email', + }, + { + name: 'ID', + value: 'id', + }, + { + name: 'Include', + value: 'include', + }, + { + name: 'Include Slugs', + value: 'include_slugs', + }, + { + name: 'Name', + value: 'name', + }, + { + name: 'Registered Date', + value: 'registered_date', + }, + { + name: 'Slug', + value: 'slug', + }, + { + name: 'URL', + value: 'url', + }, + ], + default: 'id', + description: 'Sort collection by object attribute', + }, + { + displayName: 'Order', + name: 'order', + type: 'options', + options: [ + { + name: 'ASC', + value: 'asc', + }, + { + name: 'DESC', + value: 'desc', + }, + ], + default: 'desc', + description: 'Order sort attribute ascending or descending', + }, + { + displayName: 'Search', + name: 'search', + type: 'string', + default: '', + description: 'Limit results to those matching a string', + }, + { + displayName: 'Who', + name: 'who', + type: 'options', + options: [ + { + name: 'Authors', + value: 'authors', + }, + ], + default: 'authors', + description: 'Limit result set to users who are considered authors', + }, + ], }, - default: 5, - description: 'Max number of results to return', -}, -{ - displayName: 'Options', - name: 'options', - type: 'collection', - placeholder: 'Add Option', - default: {}, - displayOptions: { - show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - }, - }, - options: [ - { - displayName: 'Context', - name: 'context', - type: 'options', - options: [ - { - name: 'View', - value: 'view', - }, - { - name: 'Embed', - value: 'embed', - }, - { - name: 'Edit', - value: 'edit', - }, - ], - default: 'view', - description: 'Scope under which the request is made; determines fields present in response', - }, - { - displayName: 'Order By', - name: 'orderBy', - type: 'options', - options: [ - { - name: 'Email', - value: 'email', - }, - { - name: 'ID', - value: 'id', - }, - { - name: 'Include', - value: 'include', - }, - { - name: 'Include Slugs', - value: 'include_slugs', - }, - { - name: 'Name', - value: 'name', - }, - { - name: 'Registered Date', - value: 'registered_date', - }, - { - name: 'Slug', - value: 'slug', - }, - { - name: 'URL', - value: 'url', - }, - ], - default: 'id', - description: 'Sort collection by object attribute', - }, - { - displayName: 'Order', - name: 'order', - type: 'options', - options: [ - { - name: 'ASC', - value: 'asc', - }, - { - name: 'DESC', - value: 'desc', - }, - ], - default: 'desc', - description: 'Order sort attribute ascending or descending', - }, - { - displayName: 'Search', - name: 'search', - type: 'string', - default: '', - description: 'Limit results to those matching a string', - }, - { - displayName: 'Who', - name: 'who', - type: 'options', - options: [ - { - name: 'Authors', - value: 'authors', - }, - ], - default: 'authors', - description: 'Limit result set to users who are considered authors', - }, - ], -}, -/* -------------------------------------------------------------------------- */ -/* user:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Reassign', name: 'reassign', @@ -560,14 +499,10 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'delete', - ], + resource: ['user'], + operation: ['delete'], }, }, - description: 'Reassign the deleted user\'s posts and links to this user ID', + description: "Reassign the deleted user's posts and links to this user ID", }, ]; diff --git a/packages/nodes-base/nodes/Wordpress/UserInterface.ts b/packages/nodes-base/nodes/Wordpress/UserInterface.ts index 9bcf3cdeac..93e36335de 100644 --- a/packages/nodes-base/nodes/Wordpress/UserInterface.ts +++ b/packages/nodes-base/nodes/Wordpress/UserInterface.ts @@ -1,4 +1,3 @@ - export interface IUser { id?: number; username?: string; diff --git a/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts b/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts index a9fb305b50..b7334f37a6 100644 --- a/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts +++ b/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, ILoadOptionsFunctions, @@ -9,24 +7,11 @@ import { INodeType, INodeTypeDescription, } from 'n8n-workflow'; -import { - wordpressApiRequest, - wordpressApiRequestAllItems, -} from './GenericFunctions'; -import { - postFields, - postOperations, -} from './PostDescription'; -import { - userFields, - userOperations, -} from './UserDescription'; -import { - IPost, -} from './PostInterface'; -import { - IUser, -} from './UserInterface'; +import { wordpressApiRequest, wordpressApiRequestAllItems } from './GenericFunctions'; +import { postFields, postOperations } from './PostDescription'; +import { userFields, userOperations } from './UserDescription'; +import { IPost } from './PostInterface'; +import { IUser } from './UserInterface'; export class Wordpress implements INodeType { description: INodeTypeDescription = { @@ -111,7 +96,13 @@ export class Wordpress implements INodeType { // select them easily async getAuthors(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const authors = await wordpressApiRequestAllItems.call(this, 'GET', '/users', {}, { who: 'authors' }); + const authors = await wordpressApiRequestAllItems.call( + this, + 'GET', + '/users', + {}, + { who: 'authors' }, + ); for (const author of authors) { const authorName = author.name; const authorId = author.id; @@ -170,7 +161,11 @@ export class Wordpress implements INodeType { body.sticky = additionalFields.sticky as boolean; } if (additionalFields.postTemplate) { - body.template = this.getNodeParameter('additionalFields.postTemplate.values.template', i, '') as string; + body.template = this.getNodeParameter( + 'additionalFields.postTemplate.values.template', + i, + '', + ) as string; } if (additionalFields.categories) { body.categories = additionalFields.categories as number[]; @@ -218,7 +213,11 @@ export class Wordpress implements INodeType { body.sticky = updateFields.sticky as boolean; } if (updateFields.postTemplate) { - body.template = this.getNodeParameter('updateFields.postTemplate.values.template', i, '') as string; + body.template = this.getNodeParameter( + 'updateFields.postTemplate.values.template', + i, + '', + ) as string; } if (updateFields.categories) { body.categories = updateFields.categories as number[]; @@ -297,7 +296,13 @@ export class Wordpress implements INodeType { if (options.force) { qs.force = options.force as boolean; } - responseData = await wordpressApiRequest.call(this, 'DELETE', `/posts/${postId}`, {}, qs); + responseData = await wordpressApiRequest.call( + this, + 'DELETE', + `/posts/${postId}`, + {}, + qs, + ); } } if (resource === 'user') { diff --git a/packages/nodes-base/nodes/Workable/GenericFunctions.ts b/packages/nodes-base/nodes/Workable/GenericFunctions.ts index 3f2829cfa9..a847340f0d 100644 --- a/packages/nodes-base/nodes/Workable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Workable/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,16 +7,26 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function workableApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any - const credentials = await this.getCredentials('workableApi') as { accessToken: string, subdomain: string }; +export async function workableApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { + const credentials = (await this.getCredentials('workableApi')) as { + accessToken: string; + subdomain: string; + }; let options: OptionsWithUri = { - headers: { 'Authorization': `Bearer ${credentials.accessToken}` }, + headers: { Authorization: `Bearer ${credentials.accessToken}` }, method, qs, body, diff --git a/packages/nodes-base/nodes/Workable/WorkableTrigger.node.ts b/packages/nodes-base/nodes/Workable/WorkableTrigger.node.ts index da5611cdbd..84c1e18463 100644 --- a/packages/nodes-base/nodes/Workable/WorkableTrigger.node.ts +++ b/packages/nodes-base/nodes/Workable/WorkableTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -12,13 +9,9 @@ import { IWebhookResponseData, } from 'n8n-workflow'; -import { - workableApiRequest, -} from './GenericFunctions'; +import { workableApiRequest } from './GenericFunctions'; -import { - snakeCase, -} from 'change-case'; +import { snakeCase } from 'change-case'; export class WorkableTrigger implements INodeType { description: INodeTypeDescription = { @@ -82,7 +75,8 @@ export class WorkableTrigger implements INodeType { loadOptionsMethod: 'getJobs', }, default: '', - description: 'Get notifications only for one job. Choose from the list, or specify an ID using an expression.', + description: + 'Get notifications only for one job. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Stage Name or ID', @@ -92,7 +86,8 @@ export class WorkableTrigger implements INodeType { loadOptionsMethod: 'getStages', }, default: '', - description: 'Get notifications for specific stages. e.g. \'hired\'. Choose from the list, or specify an ID using an expression.', + description: + 'Get notifications for specific stages. e.g. \'hired\'. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -144,7 +139,10 @@ export class WorkableTrigger implements INodeType { return false; }, async create(this: IHookFunctions): Promise { - const credentials = await this.getCredentials('workableApi') as { accessToken: string, subdomain: string }; + const credentials = (await this.getCredentials('workableApi')) as { + accessToken: string; + subdomain: string; + }; const webhookData = this.getWorkflowStaticData('node'); const webhookUrl = this.getNodeWebhookUrl('default'); const triggerOn = this.getNodeParameter('triggerOn') as string; @@ -155,8 +153,8 @@ export class WorkableTrigger implements INodeType { event: snakeCase(triggerOn).toLowerCase(), args: { account_id: credentials.subdomain, - ...(job) && { job_shortcode: job }, - ...(stage) && { stage_slug: stage }, + ...(job && { job_shortcode: job }), + ...(stage && { stage_slug: stage }), }, target: webhookUrl, }; @@ -174,7 +172,6 @@ export class WorkableTrigger implements INodeType { async delete(this: IHookFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); if (webhookData.webhookId !== undefined) { - const endpoint = `/subscriptions/${webhookData.webhookId}`; try { await workableApiRequest.call(this, 'DELETE', endpoint); @@ -193,9 +190,7 @@ export class WorkableTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const bodyData = this.getBodyData(); return { - workflowData: [ - this.helpers.returnJsonArray(bodyData), - ], + workflowData: [this.helpers.returnJsonArray(bodyData)], }; } } diff --git a/packages/nodes-base/nodes/WorkflowTrigger/WorkflowTrigger.node.ts b/packages/nodes-base/nodes/WorkflowTrigger/WorkflowTrigger.node.ts index e4202738e6..c9a0a0edb7 100644 --- a/packages/nodes-base/nodes/WorkflowTrigger/WorkflowTrigger.node.ts +++ b/packages/nodes-base/nodes/WorkflowTrigger/WorkflowTrigger.node.ts @@ -1,9 +1,5 @@ import { ITriggerFunctions } from 'n8n-core'; -import { - INodeType, - INodeTypeDescription, - ITriggerResponse, -} from 'n8n-workflow'; +import { INodeType, INodeTypeDescription, ITriggerResponse } from 'n8n-workflow'; type eventType = 'Workflow activated' | 'Workflow updated' | undefined; type activationType = 'activate' | 'update'; @@ -53,7 +49,6 @@ export class WorkflowTrigger implements INodeType { ], }; - async trigger(this: ITriggerFunctions): Promise { const events = this.getNodeParameter('events', []) as activationType[]; @@ -69,14 +64,22 @@ export class WorkflowTrigger implements INodeType { } this.emit([ this.helpers.returnJsonArray([ - { event, timestamp: (new Date()).toISOString(), workflow_id: this.getWorkflow().id }, + { event, timestamp: new Date().toISOString(), workflow_id: this.getWorkflow().id }, ]), ]); } const self = this; async function manualTriggerFunction() { - self.emit([self.helpers.returnJsonArray([{ event: 'Manual execution', timestamp: (new Date()).toISOString(), workflow_id: self.getWorkflow().id }])]); + self.emit([ + self.helpers.returnJsonArray([ + { + event: 'Manual execution', + timestamp: new Date().toISOString(), + workflow_id: self.getWorkflow().id, + }, + ]), + ]); } return { diff --git a/packages/nodes-base/nodes/WriteBinaryFile/WriteBinaryFile.node.ts b/packages/nodes-base/nodes/WriteBinaryFile/WriteBinaryFile.node.ts index 81275dfd63..c6cb87e152 100644 --- a/packages/nodes-base/nodes/WriteBinaryFile/WriteBinaryFile.node.ts +++ b/packages/nodes-base/nodes/WriteBinaryFile/WriteBinaryFile.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, INodeExecutionData, @@ -9,10 +7,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - writeFile as fsWriteFile, -} from 'fs/promises'; - +import { writeFile as fsWriteFile } from 'fs/promises'; export class WriteBinaryFile implements INodeType { description: INodeTypeDescription = { @@ -44,14 +39,13 @@ export class WriteBinaryFile implements INodeType { type: 'string', default: 'data', required: true, - description: 'Name of the binary property which contains the data for the file to be written', + description: + 'Name of the binary property which contains the data for the file to be written', }, ], }; - async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); const returnData: INodeExecutionData[] = []; @@ -67,11 +61,19 @@ export class WriteBinaryFile implements INodeType { item = items[itemIndex]; if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data set. So file can not be written!', { itemIndex }); + throw new NodeOperationError( + this.getNode(), + 'No binary data set. So file can not be written!', + { itemIndex }, + ); } if (item.binary[dataPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `The binary property "${dataPropertyName}" does not exist. So no file can be written!`, { itemIndex }); + throw new NodeOperationError( + this.getNode(), + `The binary property "${dataPropertyName}" does not exist. So no file can be written!`, + { itemIndex }, + ); } const newItem: INodeExecutionData = { @@ -82,7 +84,10 @@ export class WriteBinaryFile implements INodeType { }; Object.assign(newItem.json, item.json); - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, dataPropertyName); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + itemIndex, + dataPropertyName, + ); // Write the file to disk await fsWriteFile(fileName, binaryDataBuffer, 'binary'); @@ -100,7 +105,6 @@ export class WriteBinaryFile implements INodeType { (newItem.json as IDataObject).fileName = fileName; returnData.push(newItem); - } catch (error) { if (this.continueOnFail()) { returnData.push({ @@ -118,5 +122,4 @@ export class WriteBinaryFile implements INodeType { } return this.prepareOutputData(returnData); } - } diff --git a/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts b/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts index c9a930f4a1..acb64f82e0 100644 --- a/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,11 +7,19 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function wufooApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function wufooApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('wufooApi'); let options: OptionsWithUri = { diff --git a/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts b/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts index 4d6924acc7..03efdfc10d 100644 --- a/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts +++ b/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -12,19 +9,11 @@ import { IWebhookResponseData, } from 'n8n-workflow'; -import { - wufooApiRequest, -} from './GenericFunctions'; +import { wufooApiRequest } from './GenericFunctions'; -import { - IField, - IFormQuery, - IWebhook, -} from './Interface'; +import { IField, IFormQuery, IWebhook } from './Interface'; -import { - randomBytes, -} from 'crypto'; +import { randomBytes } from 'crypto'; export class WufooTrigger implements INodeType { description: INodeTypeDescription = { @@ -64,7 +53,8 @@ export class WufooTrigger implements INodeType { typeOptions: { loadOptionsMethod: 'getForms', }, - description: 'The form upon which will trigger this node when a new entry is made. Choose from the list, or specify an ID using an expression.', + description: + 'The form upon which will trigger this node when a new entry is made. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Only Answers', @@ -166,14 +156,11 @@ export class WufooTrigger implements INodeType { const fieldsObject = JSON.parse(req.body.FieldStructure); fieldsObject.Fields.map((field: IField) => { - // TODO // Handle docusign field if (field.Type === 'file') { - entries[field.Title] = req.body[`${field.ID}-url`]; - } else if (field.Type === 'address') { const address: IDataObject = {}; @@ -182,9 +169,7 @@ export class WufooTrigger implements INodeType { } entries[field.Title] = address; - } else if (field.Type === 'checkbox') { - const responses: string[] = []; for (const subfield of field.SubFields) { @@ -194,9 +179,7 @@ export class WufooTrigger implements INodeType { } entries[field.Title] = responses; - } else if (field.Type === 'likert') { - const likert: IDataObject = {}; for (const subfield of field.SubFields) { @@ -204,9 +187,7 @@ export class WufooTrigger implements INodeType { } entries[field.Title] = likert; - } else if (field.Type === 'shortname') { - const shortname: IDataObject = {}; for (const subfield of field.SubFields) { @@ -214,7 +195,6 @@ export class WufooTrigger implements INodeType { } entries[field.Title] = shortname; - } else { entries[field.Title] = req.body[field.ID]; } @@ -232,16 +212,11 @@ export class WufooTrigger implements INodeType { }; return { - workflowData: [ - this.helpers.returnJsonArray([returnObject as unknown as IDataObject]), - ], + workflowData: [this.helpers.returnJsonArray([returnObject as unknown as IDataObject])], }; - } else { return { - workflowData: [ - this.helpers.returnJsonArray(entries as unknown as IDataObject), - ], + workflowData: [this.helpers.returnJsonArray(entries as unknown as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/Xero/ContactDescription.ts b/packages/nodes-base/nodes/Xero/ContactDescription.ts index 93fbc4bada..1edf9cdea2 100644 --- a/packages/nodes-base/nodes/Xero/ContactDescription.ts +++ b/packages/nodes-base/nodes/Xero/ContactDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const contactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contact', - ], + resource: ['contact'], }, }, options: [ @@ -46,7 +42,6 @@ export const contactOperations: INodeProperties[] = [ ]; export const contactFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* contact:create */ /* -------------------------------------------------------------------------- */ @@ -54,19 +49,16 @@ export const contactFields: INodeProperties[] = [ displayName: 'Organization Name or ID', name: 'organizationId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTenants', }, default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, required: true, @@ -78,12 +70,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, description: 'Full name of contact/organisation', @@ -97,12 +85,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, options: [ @@ -201,7 +185,8 @@ export const contactFields: INodeProperties[] = [ name: 'contactNumber', type: 'string', default: '', - description: 'This field is read only on the Xero contact screen, used to identify contacts in external systems', + description: + 'This field is read only on the Xero contact screen, used to identify contacts in external systems', }, { displayName: 'Contact Status', @@ -323,7 +308,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getAccountCodes', }, default: '', - description: 'The default purchases account code for contacts. Choose from the list, or specify an ID using an expression.', + description: + 'The default purchases account code for contacts. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Sales Default Account Code Name or ID', @@ -333,7 +319,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getAccountCodes', }, default: '', - description: 'The default sales account code for contacts. Choose from the list, or specify an ID using an expression.', + description: + 'The default sales account code for contacts. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Skype', @@ -365,19 +352,16 @@ export const contactFields: INodeProperties[] = [ displayName: 'Organization Name or ID', name: 'organizationId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTenants', }, default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], + resource: ['contact'], + operation: ['get'], }, }, required: true, @@ -389,12 +373,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], + resource: ['contact'], + operation: ['get'], }, }, required: true, @@ -406,19 +386,16 @@ export const contactFields: INodeProperties[] = [ displayName: 'Organization Name or ID', name: 'organizationId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTenants', }, default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, required: true, @@ -429,12 +406,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, default: false, @@ -446,15 +419,9 @@ export const contactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['contact'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -472,12 +439,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, options: [ @@ -521,7 +484,8 @@ export const contactFields: INodeProperties[] = [ }, placeholder: 'EmailAddress!=null&&EmailAddress.StartsWith("boom")', default: '', - description: 'The where parameter allows you to filter on endpoints and elements that don\'t have explicit parameters. Examples Here.', + description: + 'The where parameter allows you to filter on endpoints and elements that don\'t have explicit parameters. Examples Here.', }, ], }, @@ -532,19 +496,16 @@ export const contactFields: INodeProperties[] = [ displayName: 'Organization Name or ID', name: 'organizationId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTenants', }, default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, required: true, @@ -556,12 +517,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, required: true, @@ -574,12 +531,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, options: [ @@ -678,7 +631,8 @@ export const contactFields: INodeProperties[] = [ name: 'contactNumber', type: 'string', default: '', - description: 'This field is read only on the Xero contact screen, used to identify contacts in external systems', + description: + 'This field is read only on the Xero contact screen, used to identify contacts in external systems', }, { displayName: 'Contact Status', @@ -807,7 +761,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getAccountCodes', }, default: '', - description: 'The default purchases account code for contacts. Choose from the list, or specify an ID using an expression.', + description: + 'The default purchases account code for contacts. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Sales Default Account Code Name or ID', @@ -817,7 +772,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getAccountCodes', }, default: '', - description: 'The default sales account code for contacts. Choose from the list, or specify an ID using an expression.', + description: + 'The default sales account code for contacts. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Skype', diff --git a/packages/nodes-base/nodes/Xero/GenericFunctions.ts b/packages/nodes-base/nodes/Xero/GenericFunctions.ts index fc8fb75272..0e05a22db0 100644 --- a/packages/nodes-base/nodes/Xero/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Xero/GenericFunctions.ts @@ -1,20 +1,20 @@ -import { - OptionsWithUri, - } from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - JsonObject, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, JsonObject, NodeApiError } from 'n8n-workflow'; -export async function xeroApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function xeroApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + headers: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -43,8 +43,16 @@ export async function xeroApiRequest(this: IExecuteFunctions | IExecuteSingleFun } } -export async function xeroApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string ,method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function xeroApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -54,9 +62,7 @@ export async function xeroApiRequestAllItems(this: IExecuteFunctions | ILoadOpti responseData = await xeroApiRequest.call(this, method, endpoint, body, query); query.page++; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData[propertyName].length !== 0 - ); + } while (responseData[propertyName].length !== 0); return returnData; } diff --git a/packages/nodes-base/nodes/Xero/IContactInterface.ts b/packages/nodes-base/nodes/Xero/IContactInterface.ts index 4f2ecc71ea..5c7f016817 100644 --- a/packages/nodes-base/nodes/Xero/IContactInterface.ts +++ b/packages/nodes-base/nodes/Xero/IContactInterface.ts @@ -1,4 +1,3 @@ - export interface IAddress { AddressType?: string; AddressLine1?: string; diff --git a/packages/nodes-base/nodes/Xero/InvoiceDescription.ts b/packages/nodes-base/nodes/Xero/InvoiceDescription.ts index 1c0b799954..104aa62ca0 100644 --- a/packages/nodes-base/nodes/Xero/InvoiceDescription.ts +++ b/packages/nodes-base/nodes/Xero/InvoiceDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, - } from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const invoiceOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const invoiceOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'invoice', - ], + resource: ['invoice'], }, }, options: [ @@ -46,27 +42,23 @@ export const invoiceOperations: INodeProperties[] = [ ]; export const invoiceFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* invoice:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* invoice:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Organization Name or ID', name: 'organizationId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTenants', }, default: '', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'create', - ], + resource: ['invoice'], + operation: ['create'], }, }, required: true, @@ -90,12 +82,8 @@ export const invoiceFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'create', - ], + resource: ['invoice'], + operation: ['create'], }, }, required: true, @@ -108,12 +96,8 @@ export const invoiceFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'create', - ], + resource: ['invoice'], + operation: ['create'], }, }, required: true, @@ -129,12 +113,8 @@ export const invoiceFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'create', - ], + resource: ['invoice'], + operation: ['create'], }, }, description: 'Line item data', @@ -165,18 +145,18 @@ export const invoiceFields: INodeProperties[] = [ name: 'unitAmount', type: 'string', default: '', - description: 'Lineitem unit amount. By default, unit amount will be rounded to two decimal places.', + description: + 'Lineitem unit amount. By default, unit amount will be rounded to two decimal places.', }, { displayName: 'Item Code Name or ID', name: 'itemCode', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getItemCodes', - loadOptionsDependsOn: [ - 'organizationId', - ], + loadOptionsDependsOn: ['organizationId'], }, default: '', }, @@ -184,12 +164,11 @@ export const invoiceFields: INodeProperties[] = [ displayName: 'Account Code Name or ID', name: 'accountCode', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getAccountCodes', - loadOptionsDependsOn: [ - 'organizationId', - ], + loadOptionsDependsOn: ['organizationId'], }, default: '', }, @@ -223,21 +202,24 @@ export const invoiceFields: INodeProperties[] = [ name: 'taxAmount', type: 'string', default: '', - description: 'The tax amount is auto calculated as a percentage of the line amount based on the tax rate', + description: + 'The tax amount is auto calculated as a percentage of the line amount based on the tax rate', }, { displayName: 'Line Amount', name: 'lineAmount', type: 'string', default: '', - description: 'The line amount reflects the discounted price if a DiscountRate has been used', + description: + 'The line amount reflects the discounted price if a DiscountRate has been used', }, { displayName: 'Discount Rate', name: 'discountRate', type: 'string', default: '', - description: 'Percentage discount or discount amount being applied to a line item. Only supported on ACCREC invoices - ACCPAY invoices and credit notes in Xero do not support discounts.', + description: + 'Percentage discount or discount amount being applied to a line item. Only supported on ACCREC invoices - ACCPAY invoices and credit notes in Xero do not support discounts.', }, // { // displayName: 'Tracking', @@ -296,12 +278,8 @@ export const invoiceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'create', - ], + resource: ['invoice'], + operation: ['create'], }, }, options: [ @@ -309,12 +287,11 @@ export const invoiceFields: INodeProperties[] = [ displayName: 'Branding Theme Name or ID', name: 'brandingThemeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getBrandingThemes', - loadOptionsDependsOn: [ - 'organizationId', - ], + loadOptionsDependsOn: ['organizationId'], }, default: '', }, @@ -322,12 +299,11 @@ export const invoiceFields: INodeProperties[] = [ displayName: 'Currency Name or ID', name: 'currency', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCurrencies', - loadOptionsDependsOn: [ - 'organizationId', - ], + loadOptionsDependsOn: ['organizationId'], }, default: '', }, @@ -336,14 +312,16 @@ export const invoiceFields: INodeProperties[] = [ name: 'currencyRate', type: 'string', default: '', - description: 'The currency rate for a multicurrency invoice. If no rate is specified, the XE.com day rate is used.', + description: + 'The currency rate for a multicurrency invoice. If no rate is specified, the XE.com day rate is used.', }, { displayName: 'Date', name: 'date', type: 'dateTime', default: '', - description: 'Date invoice was issued - YYYY-MM-DD. If the Date element is not specified it will default to the current date based on the timezone setting of the organisation.', + description: + 'Date invoice was issued - YYYY-MM-DD. If the Date element is not specified it will default to the current date based on the timezone setting of the organisation.', }, { displayName: 'Due Date', @@ -407,7 +385,8 @@ export const invoiceFields: INodeProperties[] = [ name: 'sendToContact', type: 'boolean', default: false, - description: 'Whether the invoice in the Xero app should be marked as "sent". This can be set only on invoices that have been approved.', + description: + 'Whether the invoice in the Xero app should be marked as "sent". This can be set only on invoices that have been approved.', }, { displayName: 'Status', @@ -438,26 +417,23 @@ export const invoiceFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* invoice:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* invoice:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'Organization Name or ID', name: 'organizationId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTenants', }, default: '', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'update', - ], + resource: ['invoice'], + operation: ['update'], }, }, required: true, @@ -470,12 +446,8 @@ export const invoiceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'update', - ], + resource: ['invoice'], + operation: ['update'], }, }, }, @@ -487,12 +459,8 @@ export const invoiceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'update', - ], + resource: ['invoice'], + operation: ['update'], }, }, options: [ @@ -500,12 +468,11 @@ export const invoiceFields: INodeProperties[] = [ displayName: 'Branding Theme Name or ID', name: 'brandingThemeId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getBrandingThemes', - loadOptionsDependsOn: [ - 'organizationId', - ], + loadOptionsDependsOn: ['organizationId'], }, default: '', }, @@ -519,12 +486,11 @@ export const invoiceFields: INodeProperties[] = [ displayName: 'Currency Name or ID', name: 'currency', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCurrencies', - loadOptionsDependsOn: [ - 'organizationId', - ], + loadOptionsDependsOn: ['organizationId'], }, default: '', }, @@ -533,14 +499,16 @@ export const invoiceFields: INodeProperties[] = [ name: 'currencyRate', type: 'string', default: '', - description: 'The currency rate for a multicurrency invoice. If no rate is specified, the XE.com day rate is used.', + description: + 'The currency rate for a multicurrency invoice. If no rate is specified, the XE.com day rate is used.', }, { displayName: 'Date', name: 'date', type: 'dateTime', default: '', - description: 'Date invoice was issued - YYYY-MM-DD. If the Date element is not specified it will default to the current date based on the timezone setting of the organisation.', + description: + 'Date invoice was issued - YYYY-MM-DD. If the Date element is not specified it will default to the current date based on the timezone setting of the organisation.', }, { displayName: 'Due Date', @@ -629,18 +597,18 @@ export const invoiceFields: INodeProperties[] = [ name: 'unitAmount', type: 'string', default: '', - description: 'Lineitem unit amount. By default, unit amount will be rounded to two decimal places.', + description: + 'Lineitem unit amount. By default, unit amount will be rounded to two decimal places.', }, { displayName: 'Item Code Name or ID', name: 'itemCode', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getItemCodes', - loadOptionsDependsOn: [ - 'organizationId', - ], + loadOptionsDependsOn: ['organizationId'], }, default: '', }, @@ -648,12 +616,11 @@ export const invoiceFields: INodeProperties[] = [ displayName: 'Account Code Name or ID', name: 'accountCode', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getAccountCodes', - loadOptionsDependsOn: [ - 'organizationId', - ], + loadOptionsDependsOn: ['organizationId'], }, default: '', }, @@ -687,21 +654,24 @@ export const invoiceFields: INodeProperties[] = [ name: 'taxAmount', type: 'string', default: '', - description: 'The tax amount is auto calculated as a percentage of the line amount based on the tax rate', + description: + 'The tax amount is auto calculated as a percentage of the line amount based on the tax rate', }, { displayName: 'Line Amount', name: 'lineAmount', type: 'string', default: '', - description: 'The line amount reflects the discounted price if a DiscountRate has been used', + description: + 'The line amount reflects the discounted price if a DiscountRate has been used', }, { displayName: 'Discount Rate', name: 'discountRate', type: 'string', default: '', - description: 'Percentage discount or discount amount being applied to a line item. Only supported on ACCREC invoices - ACCPAY invoices and credit notes in Xero do not support discounts.', + description: + 'Percentage discount or discount amount being applied to a line item. Only supported on ACCREC invoices - ACCPAY invoices and credit notes in Xero do not support discounts.', }, // { // displayName: 'Tracking', @@ -771,7 +741,8 @@ export const invoiceFields: INodeProperties[] = [ name: 'sendToContact', type: 'boolean', default: false, - description: 'Whether the invoice in the Xero app should be marked as "sent". This can be set only on invoices that have been approved.', + description: + 'Whether the invoice in the Xero app should be marked as "sent". This can be set only on invoices that have been approved.', }, { displayName: 'Status', @@ -802,26 +773,23 @@ export const invoiceFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* invoice:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* invoice:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Organization Name or ID', name: 'organizationId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTenants', }, default: '', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'get', - ], + resource: ['invoice'], + operation: ['get'], }, }, required: true, @@ -834,35 +802,28 @@ export const invoiceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'get', - ], + resource: ['invoice'], + operation: ['get'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* invoice:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* invoice:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Organization Name or ID', name: 'organizationId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getTenants', }, default: '', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'getAll', - ], + resource: ['invoice'], + operation: ['getAll'], }, }, required: true, @@ -873,12 +834,8 @@ export const invoiceFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'getAll', - ], + resource: ['invoice'], + operation: ['getAll'], }, }, default: false, @@ -890,15 +847,9 @@ export const invoiceFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['invoice'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -916,12 +867,8 @@ export const invoiceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'getAll', - ], + resource: ['invoice'], + operation: ['getAll'], }, }, options: [ @@ -930,7 +877,7 @@ export const invoiceFields: INodeProperties[] = [ name: 'createdByMyApp', type: 'boolean', default: false, - description: 'Whether you\'ll only retrieve Invoices created by your app', + description: "Whether you'll only retrieve Invoices created by your app", }, { displayName: 'Order By', @@ -985,7 +932,8 @@ export const invoiceFields: INodeProperties[] = [ }, placeholder: 'EmailAddress!=null&&EmailAddress.StartsWith("boom")', default: '', - description: 'The where parameter allows you to filter on endpoints and elements that don\'t have explicit parameters. Examples Here.', + description: + 'The where parameter allows you to filter on endpoints and elements that don\'t have explicit parameters. Examples Here.', }, ], }, diff --git a/packages/nodes-base/nodes/Xero/InvoiceInterface.ts b/packages/nodes-base/nodes/Xero/InvoiceInterface.ts index 6d6da63fb9..1c86f8b560 100644 --- a/packages/nodes-base/nodes/Xero/InvoiceInterface.ts +++ b/packages/nodes-base/nodes/Xero/InvoiceInterface.ts @@ -1,8 +1,6 @@ -import { - IDataObject, - } from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; - export interface ILineItem { +export interface ILineItem { Description?: string; Quantity?: string; UnitAmount?: string; diff --git a/packages/nodes-base/nodes/Xero/Xero.node.ts b/packages/nodes-base/nodes/Xero/Xero.node.ts index fb71ce8184..143248a565 100644 --- a/packages/nodes-base/nodes/Xero/Xero.node.ts +++ b/packages/nodes-base/nodes/Xero/Xero.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,31 +10,15 @@ import { JsonObject, } from 'n8n-workflow'; -import { - xeroApiRequest, - xeroApiRequestAllItems, -} from './GenericFunctions'; +import { xeroApiRequest, xeroApiRequestAllItems } from './GenericFunctions'; -import { - invoiceFields, - invoiceOperations -} from './InvoiceDescription'; +import { invoiceFields, invoiceOperations } from './InvoiceDescription'; -import { - contactFields, - contactOperations, -} from './ContactDescription'; +import { contactFields, contactOperations } from './ContactDescription'; -import { - IInvoice, - ILineItem, -} from './InvoiceInterface'; +import { IInvoice, ILineItem } from './InvoiceInterface'; -import { - IAddress, - IContact, - IPhone, -} from './IContactInterface'; +import { IAddress, IContact, IPhone } from './IContactInterface'; export class Xero implements INodeType { description: INodeTypeDescription = { @@ -92,7 +74,9 @@ export class Xero implements INodeType { async getItemCodes(this: ILoadOptionsFunctions): Promise { const organizationId = this.getCurrentNodeParameter('organizationId'); const returnData: INodePropertyOptions[] = []; - const { Items: items } = await xeroApiRequest.call(this, 'GET', '/items', { organizationId }); + const { Items: items } = await xeroApiRequest.call(this, 'GET', '/items', { + organizationId, + }); for (const item of items) { const itemName = item.Description; const itemId = item.Code; @@ -108,7 +92,9 @@ export class Xero implements INodeType { async getAccountCodes(this: ILoadOptionsFunctions): Promise { const organizationId = this.getCurrentNodeParameter('organizationId'); const returnData: INodePropertyOptions[] = []; - const { Accounts: accounts } = await xeroApiRequest.call(this, 'GET', '/Accounts', { organizationId }); + const { Accounts: accounts } = await xeroApiRequest.call(this, 'GET', '/Accounts', { + organizationId, + }); for (const account of accounts) { const accountName = account.Name; const accountId = account.Code; @@ -123,7 +109,14 @@ export class Xero implements INodeType { // select them easily async getTenants(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const tenants = await xeroApiRequest.call(this, 'GET', '', {}, {}, 'https://api.xero.com/connections'); + const tenants = await xeroApiRequest.call( + this, + 'GET', + '', + {}, + {}, + 'https://api.xero.com/connections', + ); for (const tenant of tenants) { const tenantName = tenant.tenantName; const tenantId = tenant.tenantId; @@ -139,7 +132,12 @@ export class Xero implements INodeType { async getBrandingThemes(this: ILoadOptionsFunctions): Promise { const organizationId = this.getCurrentNodeParameter('organizationId'); const returnData: INodePropertyOptions[] = []; - const { BrandingThemes: themes } = await xeroApiRequest.call(this, 'GET', '/BrandingThemes', { organizationId }); + const { BrandingThemes: themes } = await xeroApiRequest.call( + this, + 'GET', + '/BrandingThemes', + { organizationId }, + ); for (const theme of themes) { const themeName = theme.Name; const themeId = theme.BrandingThemeID; @@ -155,7 +153,9 @@ export class Xero implements INodeType { async getCurrencies(this: ILoadOptionsFunctions): Promise { const organizationId = this.getCurrentNodeParameter('organizationId'); const returnData: INodePropertyOptions[] = []; - const { Currencies: currencies } = await xeroApiRequest.call(this, 'GET', '/Currencies', { organizationId }); + const { Currencies: currencies } = await xeroApiRequest.call(this, 'GET', '/Currencies', { + organizationId, + }); for (const currency of currencies) { const currencyName = currency.Code; const currencyId = currency.Description; @@ -171,7 +171,12 @@ export class Xero implements INodeType { async getTrakingCategories(this: ILoadOptionsFunctions): Promise { const organizationId = this.getCurrentNodeParameter('organizationId'); const returnData: INodePropertyOptions[] = []; - const { TrackingCategories: categories } = await xeroApiRequest.call(this, 'GET', '/TrackingCategories', { organizationId }); + const { TrackingCategories: categories } = await xeroApiRequest.call( + this, + 'GET', + '/TrackingCategories', + { organizationId }, + ); for (const category of categories) { const categoryName = category.Name; const categoryId = category.TrackingCategoryID; @@ -220,7 +225,8 @@ export class Xero implements INodeType { const type = this.getNodeParameter('type', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const contactId = this.getNodeParameter('contactId', i) as string; - const lineItemsValues = ((this.getNodeParameter('lineItemsUi', i) as IDataObject).lineItemsValues as IDataObject[]); + const lineItemsValues = (this.getNodeParameter('lineItemsUi', i) as IDataObject) + .lineItemsValues as IDataObject[]; const body: IInvoice = { organizationId, @@ -316,7 +322,8 @@ export class Xero implements INodeType { }; if (updateFields.lineItemsUi) { - const lineItemsValues = (updateFields.lineItemsUi as IDataObject).lineItemsValues as IDataObject[]; + const lineItemsValues = (updateFields.lineItemsUi as IDataObject) + .lineItemsValues as IDataObject[]; if (lineItemsValues) { const lineItems: ILineItem[] = []; for (const lineItemValue of lineItemsValues) { @@ -405,7 +412,9 @@ export class Xero implements INodeType { if (operation === 'get') { const organizationId = this.getNodeParameter('organizationId', i) as string; const invoiceId = this.getNodeParameter('invoiceId', i) as string; - responseData = await xeroApiRequest.call(this, 'GET', `/Invoices/${invoiceId}`, { organizationId }); + responseData = await xeroApiRequest.call(this, 'GET', `/Invoices/${invoiceId}`, { + organizationId, + }); responseData = responseData.Invoices; } if (operation === 'getAll') { @@ -416,7 +425,9 @@ export class Xero implements INodeType { qs.statuses = (options.statuses as string[]).join(','); } if (options.orderBy) { - qs.order = `${options.orderBy} ${(options.sortOrder === undefined) ? 'DESC' : options.sortOrder}`; + qs.order = `${options.orderBy} ${ + options.sortOrder === undefined ? 'DESC' : options.sortOrder + }`; } if (options.where) { qs.where = options.where; @@ -425,10 +436,23 @@ export class Xero implements INodeType { qs.createdByMyApp = options.createdByMyApp as boolean; } if (returnAll) { - responseData = await xeroApiRequestAllItems.call(this, 'Invoices', 'GET', '/Invoices', { organizationId }, qs); + responseData = await xeroApiRequestAllItems.call( + this, + 'Invoices', + 'GET', + '/Invoices', + { organizationId }, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; - responseData = await xeroApiRequest.call(this, 'GET', `/Invoices`, { organizationId }, qs); + responseData = await xeroApiRequest.call( + this, + 'GET', + `/Invoices`, + { organizationId }, + qs, + ); responseData = responseData.Invoices; responseData = responseData.splice(0, limit); } @@ -479,7 +503,8 @@ export class Xero implements INodeType { } if (additionalFields.purchasesDefaultAccountCode) { - body.PurchasesDefaultAccountCode = additionalFields.purchasesDefaultAccountCode as string; + body.PurchasesDefaultAccountCode = + additionalFields.purchasesDefaultAccountCode as string; } if (additionalFields.salesDefaultAccountCode) { @@ -534,13 +559,18 @@ export class Xero implements INodeType { } } - responseData = await xeroApiRequest.call(this, 'POST', '/Contacts', { organizationId, Contacts: [body] }); + responseData = await xeroApiRequest.call(this, 'POST', '/Contacts', { + organizationId, + Contacts: [body], + }); responseData = responseData.Contacts; } if (operation === 'get') { const organizationId = this.getNodeParameter('organizationId', i) as string; const contactId = this.getNodeParameter('contactId', i) as string; - responseData = await xeroApiRequest.call(this, 'GET', `/Contacts/${contactId}`, { organizationId }); + responseData = await xeroApiRequest.call(this, 'GET', `/Contacts/${contactId}`, { + organizationId, + }); responseData = responseData.Contacts; } if (operation === 'getAll') { @@ -551,20 +581,34 @@ export class Xero implements INodeType { qs.includeArchived = options.includeArchived as boolean; } if (options.orderBy) { - qs.order = `${options.orderBy} ${(options.sortOrder === undefined) ? 'DESC' : options.sortOrder}`; + qs.order = `${options.orderBy} ${ + options.sortOrder === undefined ? 'DESC' : options.sortOrder + }`; } if (options.where) { qs.where = options.where; } if (returnAll) { - responseData = await xeroApiRequestAllItems.call(this, 'Contacts', 'GET', '/Contacts', { organizationId }, qs); + responseData = await xeroApiRequestAllItems.call( + this, + 'Contacts', + 'GET', + '/Contacts', + { organizationId }, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; - responseData = await xeroApiRequest.call(this, 'GET', `/Contacts`, { organizationId }, qs); + responseData = await xeroApiRequest.call( + this, + 'GET', + `/Contacts`, + { organizationId }, + qs, + ); responseData = responseData.Contacts; responseData = responseData.splice(0, limit); } - } if (operation === 'update') { const organizationId = this.getNodeParameter('organizationId', i) as string; @@ -667,7 +711,10 @@ export class Xero implements INodeType { } } - responseData = await xeroApiRequest.call(this, 'POST', `/Contacts/${contactId}`, { organizationId, Contacts: [body] }); + responseData = await xeroApiRequest.call(this, 'POST', `/Contacts/${contactId}`, { + organizationId, + Contacts: [body], + }); responseData = responseData.Contacts; } } diff --git a/packages/nodes-base/nodes/Xml/Xml.node.ts b/packages/nodes-base/nodes/Xml/Xml.node.ts index 593adada82..1453126659 100644 --- a/packages/nodes-base/nodes/Xml/Xml.node.ts +++ b/packages/nodes-base/nodes/Xml/Xml.node.ts @@ -8,7 +8,6 @@ import { NodeOperationError, } from 'n8n-workflow'; - export class Xml implements INodeType { description: INodeTypeDescription = { displayName: 'XML', @@ -54,9 +53,7 @@ export class Xml implements INodeType { type: 'string', displayOptions: { show: { - mode: [ - 'jsonToxml', - ], + mode: ['jsonToxml'], }, }, default: 'data', @@ -70,9 +67,7 @@ export class Xml implements INodeType { placeholder: 'Add Option', displayOptions: { show: { - mode: [ - 'jsonToxml', - ], + mode: ['jsonToxml'], }, }, default: {}, @@ -96,7 +91,8 @@ export class Xml implements INodeType { name: 'cdata', type: 'boolean', default: false, - description: 'Whether to wrap text nodes in <![CDATA[ ... ]]> instead of escaping when necessary. Does not add <![CDATA[ ... ]]> if it is not required.', + description: + 'Whether to wrap text nodes in <![CDATA[ ... ]]> instead of escaping when necessary. Does not add <![CDATA[ ... ]]> if it is not required.', }, { displayName: 'Character Key', @@ -122,8 +118,6 @@ export class Xml implements INodeType { ], }, - - // ---------------------------------- // option:xmlToJson // ---------------------------------- @@ -133,9 +127,7 @@ export class Xml implements INodeType { type: 'string', displayOptions: { show: { - mode: [ - 'xmlToJson', - ], + mode: ['xmlToJson'], }, }, default: 'data', @@ -149,9 +141,7 @@ export class Xml implements INodeType { placeholder: 'Add Option', displayOptions: { show: { - mode: [ - 'xmlToJson', - ], + mode: ['xmlToJson'], }, }, default: {}, @@ -175,14 +165,16 @@ export class Xml implements INodeType { name: 'explicitArray', type: 'boolean', default: false, - description: 'Whether to always put child nodes in an array if true; otherwise an array is created only if there is more than one', + description: + 'Whether to always put child nodes in an array if true; otherwise an array is created only if there is more than one', }, { displayName: 'Explicit Root', name: 'explicitRoot', type: 'boolean', default: true, - description: 'Whether to set this if you want to get the root node in the resulting object', + description: + 'Whether to set this if you want to get the root node in the resulting object', }, { displayName: 'Ignore Attributes', @@ -196,7 +188,8 @@ export class Xml implements INodeType { name: 'mergeAttrs', type: 'boolean', default: true, - description: 'Whether to merge attributes and child elements as properties of the parent, instead of keying attributes off a child attribute object. This option is ignored if ignoreAttrs is true.', + description: + 'Whether to merge attributes and child elements as properties of the parent, instead of keying attributes off a child attribute object. This option is ignored if ignoreAttrs is true.', }, { displayName: 'Normalize', @@ -224,7 +217,6 @@ export class Xml implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); @@ -232,24 +224,29 @@ export class Xml implements INodeType { const dataPropertyName = this.getNodeParameter('dataPropertyName', 0) as string; const options = this.getNodeParameter('options', 0, {}) as IDataObject; - let item: INodeExecutionData; const returnData: INodeExecutionData[] = []; for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { try { - item = items[itemIndex]; if (mode === 'xmlToJson') { - const parserOptions = Object.assign({ - mergeAttrs: true, - explicitArray: false, - }, options); + const parserOptions = Object.assign( + { + mergeAttrs: true, + explicitArray: false, + }, + options, + ); const parser = new Parser(parserOptions); if (item.json[dataPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `No json property "${dataPropertyName}" does not exists on item!`, { itemIndex }); + throw new NodeOperationError( + this.getNode(), + `No json property "${dataPropertyName}" does not exists on item!`, + { itemIndex }, + ); } // @ts-ignore @@ -267,18 +264,20 @@ export class Xml implements INodeType { }, }); } else { - throw new NodeOperationError(this.getNode(), `The operation "${mode}" is not known!`, { itemIndex }); + throw new NodeOperationError(this.getNode(), `The operation "${mode}" is not known!`, { + itemIndex, + }); } } catch (error) { if (this.continueOnFail()) { - items[itemIndex] = ({ + items[itemIndex] = { json: { error: error.message, }, pairedItem: { item: itemIndex, }, - }); + }; continue; } throw error; @@ -286,6 +285,5 @@ export class Xml implements INodeType { } return this.prepareOutputData(returnData); - } } diff --git a/packages/nodes-base/nodes/Yourls/GenericFunctions.ts b/packages/nodes-base/nodes/Yourls/GenericFunctions.ts index 4bed81295c..729eedeab6 100644 --- a/packages/nodes-base/nodes/Yourls/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Yourls/GenericFunctions.ts @@ -1,19 +1,17 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; - -export async function yourlsApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, body: any = {}, qs: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; +export async function yourlsApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('yourlsApi'); qs.signature = credentials.signature as string; @@ -31,7 +29,8 @@ export async function yourlsApiRequest(this: IExecuteFunctions | IExecuteSingleF const response = await this.helpers.request.call(this, options); if (response.status === 'fail') { - throw new NodeOperationError(this.getNode(), + throw new NodeOperationError( + this.getNode(), `Yourls error response [400]: ${response.message}`, ); } diff --git a/packages/nodes-base/nodes/Yourls/UrlDescription.ts b/packages/nodes-base/nodes/Yourls/UrlDescription.ts index e80d05e4de..2abb1155fd 100644 --- a/packages/nodes-base/nodes/Yourls/UrlDescription.ts +++ b/packages/nodes-base/nodes/Yourls/UrlDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const urlOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const urlOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'url', - ], + resource: ['url'], }, }, options: [ @@ -40,7 +36,6 @@ export const urlOperations: INodeProperties[] = [ ]; export const urlFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* url:shorten */ /* -------------------------------------------------------------------------- */ @@ -51,12 +46,8 @@ export const urlFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'url', - ], - operation: [ - 'shorten', - ], + resource: ['url'], + operation: ['shorten'], }, }, default: '', @@ -70,12 +61,8 @@ export const urlFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'url', - ], - operation: [ - 'shorten', - ], + resource: ['url'], + operation: ['shorten'], }, }, options: [ @@ -104,12 +91,8 @@ export const urlFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'url', - ], - operation: [ - 'expand', - ], + resource: ['url'], + operation: ['expand'], }, }, default: '', @@ -126,12 +109,8 @@ export const urlFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'url', - ], - operation: [ - 'stats', - ], + resource: ['url'], + operation: ['stats'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Yourls/Yourls.node.ts b/packages/nodes-base/nodes/Yourls/Yourls.node.ts index 11d2d74240..6e2f899db0 100644 --- a/packages/nodes-base/nodes/Yourls/Yourls.node.ts +++ b/packages/nodes-base/nodes/Yourls/Yourls.node.ts @@ -1,22 +1,10 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; -import { - yourlsApiRequest, -} from './GenericFunctions'; +import { yourlsApiRequest } from './GenericFunctions'; -import { - urlFields, - urlOperations, -} from './UrlDescription'; +import { urlFields, urlOperations } from './UrlDescription'; export class Yourls implements INodeType { description: INodeTypeDescription = { diff --git a/packages/nodes-base/nodes/Zammad/GenericFunctions.ts b/packages/nodes-base/nodes/Zammad/GenericFunctions.ts index 43786c8b0b..50fef6e6fc 100644 --- a/packages/nodes-base/nodes/Zammad/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zammad/GenericFunctions.ts @@ -1,21 +1,10 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - ILoadOptionsFunctions, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, ILoadOptionsFunctions, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - flow, -} from 'lodash'; +import { flow } from 'lodash'; import type { Zammad } from './types'; @@ -37,8 +26,9 @@ export async function zammadApiRequest( const authentication = this.getNodeParameter('authentication', 0) as 'basicAuth' | 'tokenAuth'; if (authentication === 'basicAuth') { - - const credentials = await this.getCredentials('zammadBasicAuthApi') as Zammad.BasicAuthCredentials; + const credentials = (await this.getCredentials( + 'zammadBasicAuthApi', + )) as Zammad.BasicAuthCredentials; const baseUrl = tolerateTrailingSlash(credentials.baseUrl); @@ -50,10 +40,10 @@ export async function zammadApiRequest( }; options.rejectUnauthorized = !credentials.allowUnauthorizedCerts; - } else { - - const credentials = await this.getCredentials('zammadTokenAuthApi') as Zammad.TokenAuthCredentials; + const credentials = (await this.getCredentials( + 'zammadTokenAuthApi', + )) as Zammad.TokenAuthCredentials; const baseUrl = tolerateTrailingSlash(credentials.baseUrl); @@ -64,7 +54,6 @@ export async function zammadApiRequest( }; options.rejectUnauthorized = !credentials.allowUnauthorizedCerts; - } if (!Object.keys(body).length) { @@ -117,9 +106,7 @@ export async function zammadApiRequestAllItems( } export function tolerateTrailingSlash(url: string) { - return url.endsWith('/') - ? url.substr(0, url.length - 1) - : url; + return url.endsWith('/') ? url.substr(0, url.length - 1) : url; } export function throwOnEmptyUpdate(this: IExecuteFunctions, resource: string) { @@ -143,18 +130,19 @@ export const isCustomer = (user: Zammad.User) => user.role_ids.includes(3) && !user.email.endsWith('@zammad.org'); export async function getAllFields(this: ILoadOptionsFunctions) { - return await zammadApiRequest.call(this, 'GET', '/object_manager_attributes') as Zammad.Field[]; + return (await zammadApiRequest.call(this, 'GET', '/object_manager_attributes')) as Zammad.Field[]; } -const isTypeField = (resource: 'Group' | 'Organization' | 'Ticket' | 'User') => - (arr: Zammad.Field[]) => arr.filter(i => i.object === resource); +const isTypeField = + (resource: 'Group' | 'Organization' | 'Ticket' | 'User') => (arr: Zammad.Field[]) => + arr.filter((i) => i.object === resource); export const getGroupFields = isTypeField('Group'); export const getOrganizationFields = isTypeField('Organization'); export const getUserFields = isTypeField('User'); export const getTicketFields = isTypeField('Ticket'); -const getCustomFields = (arr: Zammad.Field[]) => arr.filter(i => i.created_by_id !== 1); +const getCustomFields = (arr: Zammad.Field[]) => arr.filter((i) => i.created_by_id !== 1); export const getGroupCustomFields = flow(getGroupFields, getCustomFields); export const getOrganizationCustomFields = flow(getOrganizationFields, getCustomFields); @@ -163,4 +151,5 @@ export const getTicketCustomFields = flow(getTicketFields, getCustomFields); export const isNotZammadFoundation = (i: Zammad.Organization) => i.name !== 'Zammad Foundation'; -export const doesNotBelongToZammad = (i: Zammad.User) => !i.email.endsWith('@zammad.org') && i.login !== '-'; +export const doesNotBelongToZammad = (i: Zammad.User) => + !i.email.endsWith('@zammad.org') && i.login !== '-'; diff --git a/packages/nodes-base/nodes/Zammad/Zammad.node.ts b/packages/nodes-base/nodes/Zammad/Zammad.node.ts index e449f8aef8..bfe21ed805 100644 --- a/packages/nodes-base/nodes/Zammad/Zammad.node.ts +++ b/packages/nodes-base/nodes/Zammad/Zammad.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -14,9 +12,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { groupDescription, @@ -59,12 +55,8 @@ export class Zammad implements INodeType { defaults: { name: 'Zammad', }, - inputs: [ - 'main', - ], - outputs: [ - 'main', - ], + inputs: ['main'], + outputs: ['main'], credentials: [ { name: 'zammadBasicAuthApi', @@ -72,9 +64,7 @@ export class Zammad implements INodeType { testedBy: 'zammadBasicAuthApiTest', displayOptions: { show: { - authentication: [ - 'basicAuth', - ], + authentication: ['basicAuth'], }, }, }, @@ -84,9 +74,7 @@ export class Zammad implements INodeType { testedBy: 'zammadTokenAuthApiTest', displayOptions: { show: { - authentication: [ - 'tokenAuth', - ], + authentication: ['tokenAuth'], }, }, }, @@ -209,47 +197,55 @@ export class Zammad implements INodeType { * POST /tickets requires group name instead of group ID. */ async loadGroupNames(this: ILoadOptionsFunctions) { - const groups = await zammadApiRequest.call(this, 'GET', '/groups') as ZammadTypes.Group[]; + const groups = (await zammadApiRequest.call(this, 'GET', '/groups')) as ZammadTypes.Group[]; - return groups.map(i => ({ name: i.name, value: i.name })); + return groups.map((i) => ({ name: i.name, value: i.name })); }, /** * PUT /users requires organization name instead of organization ID. */ async loadOrganizationNames(this: ILoadOptionsFunctions) { - const orgs = await zammadApiRequest.call(this, 'GET', '/organizations') as ZammadTypes.Group[]; + const orgs = (await zammadApiRequest.call( + this, + 'GET', + '/organizations', + )) as ZammadTypes.Group[]; - return orgs.filter(isNotZammadFoundation).map(i => ({ name: i.name, value: i.name })); + return orgs.filter(isNotZammadFoundation).map((i) => ({ name: i.name, value: i.name })); }, /** * POST & PUT /tickets requires customer email instead of customer ID. */ async loadCustomerEmails(this: ILoadOptionsFunctions) { - const users = await zammadApiRequest.call(this, 'GET', '/users') as ZammadTypes.User[]; + const users = (await zammadApiRequest.call(this, 'GET', '/users')) as ZammadTypes.User[]; - return users.filter(isCustomer).map(i => ({ name: i.email, value: i.email })); + return users.filter(isCustomer).map((i) => ({ name: i.email, value: i.email })); }, // by ID async loadGroups(this: ILoadOptionsFunctions) { - const groups = await zammadApiRequest.call(this, 'GET', '/groups') as ZammadTypes.Group[]; + const groups = (await zammadApiRequest.call(this, 'GET', '/groups')) as ZammadTypes.Group[]; - return groups.map(i => ({ name: i.name, value: i.id })); + return groups.map((i) => ({ name: i.name, value: i.id })); }, async loadOrganizations(this: ILoadOptionsFunctions) { - const orgs = await zammadApiRequest.call(this, 'GET', '/organizations') as ZammadTypes.Organization[]; + const orgs = (await zammadApiRequest.call( + this, + 'GET', + '/organizations', + )) as ZammadTypes.Organization[]; - return orgs.filter(isNotZammadFoundation).map(i => ({ name: i.name, value: i.id })); + return orgs.filter(isNotZammadFoundation).map((i) => ({ name: i.name, value: i.id })); }, async loadUsers(this: ILoadOptionsFunctions) { - const users = await zammadApiRequest.call(this, 'GET', '/users') as ZammadTypes.User[]; + const users = (await zammadApiRequest.call(this, 'GET', '/users')) as ZammadTypes.User[]; - return users.filter(doesNotBelongToZammad).map(i => ({ name: i.login, value: i.id })); + return users.filter(doesNotBelongToZammad).map((i) => ({ name: i.login, value: i.id })); }, }, credentialTest: { @@ -330,17 +326,13 @@ export class Zammad implements INodeType { const returnData: IDataObject[] = []; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'user') { - // ********************************************************************** // user // ********************************************************************** if (operation === 'create') { - // ---------------------------------- // user:create // ---------------------------------- @@ -352,11 +344,10 @@ export class Zammad implements INodeType { lastname: this.getNodeParameter('lastname', i), }; - const { - addressUi, - customFieldsUi, - ...rest - } = this.getNodeParameter('additionalFields', i) as ZammadTypes.UserAdditionalFields; + const { addressUi, customFieldsUi, ...rest } = this.getNodeParameter( + 'additionalFields', + i, + ) as ZammadTypes.UserAdditionalFields; Object.assign(body, addressUi?.addressDetails); @@ -367,9 +358,7 @@ export class Zammad implements INodeType { Object.assign(body, rest); responseData = await zammadApiRequest.call(this, 'POST', '/users', body); - } else if (operation === 'update') { - // ---------------------------------- // user:update // ---------------------------------- @@ -380,7 +369,10 @@ export class Zammad implements INodeType { const body: IDataObject = {}; - const updateFields = this.getNodeParameter('updateFields', i) as ZammadTypes.UserUpdateFields; + const updateFields = this.getNodeParameter( + 'updateFields', + i, + ) as ZammadTypes.UserUpdateFields; if (!Object.keys(updateFields).length) { throwOnEmptyUpdate.call(this, resource); @@ -397,9 +389,7 @@ export class Zammad implements INodeType { Object.assign(body, rest); responseData = await zammadApiRequest.call(this, 'PUT', `/users/${id}`, body); - } else if (operation === 'delete') { - // ---------------------------------- // user:delete // ---------------------------------- @@ -411,9 +401,7 @@ export class Zammad implements INodeType { await zammadApiRequest.call(this, 'DELETE', `/users/${id}`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------- // user:get // ---------------------------------- @@ -423,9 +411,7 @@ export class Zammad implements INodeType { const id = this.getNodeParameter('id', i) as string; responseData = await zammadApiRequest.call(this, 'GET', `/users/${id}`); - } else if (operation === 'getAll') { - // ---------------------------------- // user:getAll // ---------------------------------- @@ -435,7 +421,10 @@ export class Zammad implements INodeType { const qs: IDataObject = {}; - const { sortUi, ...rest } = this.getNodeParameter('filters', i) as ZammadTypes.UserFilterFields; + const { sortUi, ...rest } = this.getNodeParameter( + 'filters', + i, + ) as ZammadTypes.UserFilterFields; Object.assign(qs, sortUi?.sortDetails); @@ -445,19 +434,17 @@ export class Zammad implements INodeType { const returnAll = this.getNodeParameter('returnAll', i) as boolean; - const limit = returnAll ? 0 : this.getNodeParameter('limit', i) as number; + const limit = returnAll ? 0 : (this.getNodeParameter('limit', i) as number); - responseData = await zammadApiRequestAllItems.call( - this, 'GET', '/users/search', {}, qs, limit, - ).then(responseData => { - return responseData.map(user => { - const { preferences, ...rest } = user; - return rest; + responseData = await zammadApiRequestAllItems + .call(this, 'GET', '/users/search', {}, qs, limit) + .then((responseData) => { + return responseData.map((user) => { + const { preferences, ...rest } = user; + return rest; + }); }); - }); - } else if (operation === 'getSelf') { - // ---------------------------------- // user:me // ---------------------------------- @@ -466,15 +453,12 @@ export class Zammad implements INodeType { responseData = await zammadApiRequest.call(this, 'GET', '/users/me'); } - } else if (resource === 'organization') { - // ********************************************************************** // organization // ********************************************************************** if (operation === 'create') { - // ---------------------------------- // organization:create // ---------------------------------- @@ -485,10 +469,10 @@ export class Zammad implements INodeType { name: this.getNodeParameter('name', i), }; - const { - customFieldsUi, - ...rest - } = this.getNodeParameter('additionalFields', i) as ZammadTypes.UserAdditionalFields; + const { customFieldsUi, ...rest } = this.getNodeParameter( + 'additionalFields', + i, + ) as ZammadTypes.UserAdditionalFields; customFieldsUi?.customFieldPairs.forEach((pair) => { body[pair['name']] = pair['value']; @@ -497,9 +481,7 @@ export class Zammad implements INodeType { Object.assign(body, rest); responseData = await zammadApiRequest.call(this, 'POST', '/organizations', body); - } else if (operation === 'update') { - // ---------------------------------- // organization:update // ---------------------------------- @@ -510,7 +492,10 @@ export class Zammad implements INodeType { const body: IDataObject = {}; - const updateFields = this.getNodeParameter('updateFields', i) as ZammadTypes.UserUpdateFields; + const updateFields = this.getNodeParameter( + 'updateFields', + i, + ) as ZammadTypes.UserUpdateFields; if (!Object.keys(updateFields).length) { throwOnEmptyUpdate.call(this, resource); @@ -525,9 +510,7 @@ export class Zammad implements INodeType { Object.assign(body, rest); responseData = await zammadApiRequest.call(this, 'PUT', `/organizations/${id}`, body); - } else if (operation === 'delete') { - // ---------------------------------- // organization:delete // ---------------------------------- @@ -539,9 +522,7 @@ export class Zammad implements INodeType { await zammadApiRequest.call(this, 'DELETE', `/organizations/${id}`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------- // organization:get // ---------------------------------- @@ -551,9 +532,7 @@ export class Zammad implements INodeType { const id = this.getNodeParameter('id', i) as string; responseData = await zammadApiRequest.call(this, 'GET', `/organizations/${id}`); - } else if (operation === 'getAll') { - // ---------------------------------- // organization:getAll // ---------------------------------- @@ -563,22 +542,23 @@ export class Zammad implements INodeType { const returnAll = this.getNodeParameter('returnAll', i) as boolean; - const limit = returnAll ? 0 : this.getNodeParameter('limit', i) as number; + const limit = returnAll ? 0 : (this.getNodeParameter('limit', i) as number); responseData = await zammadApiRequestAllItems.call( - this, 'GET', '/organizations', {}, {}, limit, + this, + 'GET', + '/organizations', + {}, + {}, + limit, ); - } - } else if (resource === 'group') { - // ********************************************************************** // group // ********************************************************************** if (operation === 'create') { - // ---------------------------------- // group:create // ---------------------------------- @@ -589,10 +569,10 @@ export class Zammad implements INodeType { name: this.getNodeParameter('name', i) as string, }; - const { - customFieldsUi, - ...rest - } = this.getNodeParameter('additionalFields', i) as ZammadTypes.UserAdditionalFields; + const { customFieldsUi, ...rest } = this.getNodeParameter( + 'additionalFields', + i, + ) as ZammadTypes.UserAdditionalFields; customFieldsUi?.customFieldPairs.forEach((pair) => { body[pair['name']] = pair['value']; @@ -601,9 +581,7 @@ export class Zammad implements INodeType { Object.assign(body, rest); responseData = await zammadApiRequest.call(this, 'POST', '/groups', body); - } else if (operation === 'update') { - // ---------------------------------- // group:update // ---------------------------------- @@ -614,7 +592,10 @@ export class Zammad implements INodeType { const body: IDataObject = {}; - const updateFields = this.getNodeParameter('updateFields', i) as ZammadTypes.GroupUpdateFields; + const updateFields = this.getNodeParameter( + 'updateFields', + i, + ) as ZammadTypes.GroupUpdateFields; if (!Object.keys(updateFields).length) { throwOnEmptyUpdate.call(this, resource); @@ -629,9 +610,7 @@ export class Zammad implements INodeType { Object.assign(body, rest); responseData = await zammadApiRequest.call(this, 'PUT', `/groups/${id}`, body); - } else if (operation === 'delete') { - // ---------------------------------- // group:delete // ---------------------------------- @@ -643,9 +622,7 @@ export class Zammad implements INodeType { await zammadApiRequest.call(this, 'DELETE', `/groups/${id}`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------- // group:get // ---------------------------------- @@ -655,9 +632,7 @@ export class Zammad implements INodeType { const id = this.getNodeParameter('id', i) as string; responseData = await zammadApiRequest.call(this, 'GET', `/groups/${id}`); - } else if (operation === 'getAll') { - // ---------------------------------- // group:getAll // ---------------------------------- @@ -666,22 +641,23 @@ export class Zammad implements INodeType { const returnAll = this.getNodeParameter('returnAll', i) as boolean; - const limit = returnAll ? 0 : this.getNodeParameter('limit', i) as number; + const limit = returnAll ? 0 : (this.getNodeParameter('limit', i) as number); responseData = await zammadApiRequestAllItems.call( - this, 'GET', '/groups', {}, {}, limit, + this, + 'GET', + '/groups', + {}, + {}, + limit, ); - } - } else if (resource === 'ticket') { - // ********************************************************************** // ticket // ********************************************************************** if (operation === 'create') { - // ---------------------------------- // ticket:create // ---------------------------------- @@ -714,10 +690,12 @@ export class Zammad implements INodeType { const { id } = responseData; - responseData.articles = await zammadApiRequest.call(this, 'GET', `/ticket_articles/by_ticket/${id}`); - + responseData.articles = await zammadApiRequest.call( + this, + 'GET', + `/ticket_articles/by_ticket/${id}`, + ); } else if (operation === 'delete') { - // ---------------------------------- // ticket:delete // ---------------------------------- @@ -729,9 +707,7 @@ export class Zammad implements INodeType { await zammadApiRequest.call(this, 'DELETE', `/tickets/${id}`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------- // ticket:get // ---------------------------------- @@ -741,10 +717,12 @@ export class Zammad implements INodeType { const id = this.getNodeParameter('id', i) as string; responseData = await zammadApiRequest.call(this, 'GET', `/tickets/${id}`); - responseData.articles = await zammadApiRequest.call(this, 'GET', `/ticket_articles/by_ticket/${id}`); - + responseData.articles = await zammadApiRequest.call( + this, + 'GET', + `/ticket_articles/by_ticket/${id}`, + ); } else if (operation === 'getAll') { - // ---------------------------------- // ticket:getAll // ---------------------------------- @@ -754,20 +732,22 @@ export class Zammad implements INodeType { const returnAll = this.getNodeParameter('returnAll', i) as boolean; - const limit = returnAll ? 0 : this.getNodeParameter('limit', i) as number; + const limit = returnAll ? 0 : (this.getNodeParameter('limit', i) as number); responseData = await zammadApiRequestAllItems.call( - this, 'GET', '/tickets', {}, {}, limit, + this, + 'GET', + '/tickets', + {}, + {}, + limit, ); - } - } Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/Zammad/descriptions/GroupDescription.ts b/packages/nodes-base/nodes/Zammad/descriptions/GroupDescription.ts index 7bf899efbe..9a1b4dc39b 100644 --- a/packages/nodes-base/nodes/Zammad/descriptions/GroupDescription.ts +++ b/packages/nodes-base/nodes/Zammad/descriptions/GroupDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const groupDescription: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const groupDescription: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'group', - ], + resource: ['group'], }, }, options: [ @@ -64,12 +60,8 @@ export const groupDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'group', - ], + operation: ['create'], + resource: ['group'], }, }, }, @@ -77,17 +69,14 @@ export const groupDescription: INodeProperties[] = [ displayName: 'Group ID', name: 'id', type: 'string', - description: 'Group to update. Specify an ID using an expression.', + description: + 'Group to update. Specify an ID using an expression.', default: '', required: true, displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'update', - ], + resource: ['group'], + operation: ['update'], }, }, }, @@ -95,17 +84,14 @@ export const groupDescription: INodeProperties[] = [ displayName: 'Group ID', name: 'id', type: 'string', - description: 'Group to delete. Specify an ID using an expression.', + description: + 'Group to delete. Specify an ID using an expression.', default: '', required: true, displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'delete', - ], + resource: ['group'], + operation: ['delete'], }, }, }, @@ -113,17 +99,14 @@ export const groupDescription: INodeProperties[] = [ displayName: 'Group ID', name: 'id', type: 'string', - description: 'Group to retrieve. Specify an ID using an expression.', + description: + 'Group to retrieve. Specify an ID using an expression.', default: '', required: true, displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'get', - ], + resource: ['group'], + operation: ['get'], }, }, }, @@ -134,12 +117,8 @@ export const groupDescription: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'create', - ], + resource: ['group'], + operation: ['create'], }, }, default: {}, @@ -173,7 +152,8 @@ export const groupDescription: INodeProperties[] = [ loadOptionsMethod: 'loadGroupCustomFields', }, default: '', - description: 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Field Value', @@ -203,12 +183,8 @@ export const groupDescription: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'group', - ], + operation: ['update'], + resource: ['group'], }, }, default: {}, @@ -242,7 +218,8 @@ export const groupDescription: INodeProperties[] = [ loadOptionsMethod: 'loadGroupCustomFields', }, default: '', - description: 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Field Value', @@ -280,12 +257,8 @@ export const groupDescription: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'getAll', - ], + resource: ['group'], + operation: ['getAll'], }, }, }, @@ -300,15 +273,9 @@ export const groupDescription: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['group'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Zammad/descriptions/OrganizationDescription.ts b/packages/nodes-base/nodes/Zammad/descriptions/OrganizationDescription.ts index adffa7e784..cf5fbd61fb 100644 --- a/packages/nodes-base/nodes/Zammad/descriptions/OrganizationDescription.ts +++ b/packages/nodes-base/nodes/Zammad/descriptions/OrganizationDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const organizationDescription: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const organizationDescription: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'organization', - ], + resource: ['organization'], }, }, options: [ @@ -64,12 +60,8 @@ export const organizationDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'organization', - ], + operation: ['create'], + resource: ['organization'], }, }, }, @@ -77,17 +69,14 @@ export const organizationDescription: INodeProperties[] = [ displayName: 'Organization ID', name: 'id', type: 'string', - description: 'Organization to update. Specify an ID using an expression.', + description: + 'Organization to update. Specify an ID using an expression.', default: '', required: true, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'update', - ], + resource: ['organization'], + operation: ['update'], }, }, }, @@ -95,17 +84,14 @@ export const organizationDescription: INodeProperties[] = [ displayName: 'Organization ID', name: 'id', type: 'string', - description: 'Organization to delete. Specify an ID using an expression.', + description: + 'Organization to delete. Specify an ID using an expression.', default: '', required: true, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'delete', - ], + resource: ['organization'], + operation: ['delete'], }, }, }, @@ -113,17 +99,14 @@ export const organizationDescription: INodeProperties[] = [ displayName: 'Organization ID', name: 'id', type: 'string', - description: 'Organization to retrieve. Specify an ID using an expression.', + description: + 'Organization to retrieve. Specify an ID using an expression.', default: '', required: true, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'get', - ], + resource: ['organization'], + operation: ['get'], }, }, }, @@ -133,12 +116,8 @@ export const organizationDescription: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'organization', - ], + operation: ['create'], + resource: ['organization'], }, }, default: {}, @@ -172,7 +151,8 @@ export const organizationDescription: INodeProperties[] = [ loadOptionsMethod: 'loadOrganizationCustomFields', }, default: '', - description: 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -202,12 +182,8 @@ export const organizationDescription: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'organization', - ], + operation: ['update'], + resource: ['organization'], }, }, default: {}, @@ -241,7 +217,8 @@ export const organizationDescription: INodeProperties[] = [ loadOptionsMethod: 'loadOrganizationCustomFields', }, default: '', - description: 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -279,12 +256,8 @@ export const organizationDescription: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'getAll', - ], + resource: ['organization'], + operation: ['getAll'], }, }, }, @@ -299,15 +272,9 @@ export const organizationDescription: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['organization'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Zammad/descriptions/TicketDescription.ts b/packages/nodes-base/nodes/Zammad/descriptions/TicketDescription.ts index 74c8e77b93..8a128a306f 100644 --- a/packages/nodes-base/nodes/Zammad/descriptions/TicketDescription.ts +++ b/packages/nodes-base/nodes/Zammad/descriptions/TicketDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const ticketDescription: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const ticketDescription: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'ticket', - ], + resource: ['ticket'], }, }, options: [ @@ -59,12 +55,8 @@ export const ticketDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, }, @@ -76,17 +68,14 @@ export const ticketDescription: INodeProperties[] = [ loadOptionsMethod: 'loadGroupNames', }, placeholder: 'First-Level Helpdesk', - description: 'Group that will own the ticket to create. Choose from the list, or specify an ID using an expression.', + description: + 'Group that will own the ticket to create. Choose from the list, or specify an ID using an expression.', default: '', required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, }, @@ -97,18 +86,15 @@ export const ticketDescription: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'loadCustomerEmails', }, - description: 'Email address of the customer concerned in the ticket to create. Choose from the list, or specify an ID using an expression.', + description: + 'Email address of the customer concerned in the ticket to create. Choose from the list, or specify an ID using an expression.', default: '', placeholder: 'hello@n8n.io', required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, }, @@ -116,17 +102,14 @@ export const ticketDescription: INodeProperties[] = [ displayName: 'Ticket ID', name: 'id', type: 'string', - description: 'Ticket to retrieve. Specify an ID using an expression.', + description: + 'Ticket to retrieve. Specify an ID using an expression.', default: '', required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'get', - ], + resource: ['ticket'], + operation: ['get'], }, }, }, @@ -135,16 +118,13 @@ export const ticketDescription: INodeProperties[] = [ name: 'id', type: 'string', default: '', - description: 'Ticket to delete. Specify an ID using an expression.', + description: + 'Ticket to delete. Specify an ID using an expression.', required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'delete', - ], + resource: ['ticket'], + operation: ['delete'], }, }, }, @@ -157,12 +137,8 @@ export const ticketDescription: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, options: [ @@ -246,12 +222,8 @@ export const ticketDescription: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, default: {}, @@ -279,7 +251,8 @@ export const ticketDescription: INodeProperties[] = [ loadOptionsMethod: 'loadTicketCustomFields', }, default: '', - description: 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -302,12 +275,8 @@ export const ticketDescription: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], + resource: ['ticket'], + operation: ['getAll'], }, }, }, @@ -322,15 +291,9 @@ export const ticketDescription: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['ticket'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Zammad/descriptions/UserDescription.ts b/packages/nodes-base/nodes/Zammad/descriptions/UserDescription.ts index ab047c90dd..6f081890b4 100644 --- a/packages/nodes-base/nodes/Zammad/descriptions/UserDescription.ts +++ b/packages/nodes-base/nodes/Zammad/descriptions/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userDescription: INodeProperties[] = [ // ---------------------------------- @@ -13,9 +11,7 @@ export const userDescription: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -71,12 +67,8 @@ export const userDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, }, @@ -89,12 +81,8 @@ export const userDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, }, @@ -102,17 +90,14 @@ export const userDescription: INodeProperties[] = [ displayName: 'User ID', name: 'id', type: 'string', - description: 'User to update. Specify an ID using an expression.', + description: + 'User to update. Specify an ID using an expression.', default: '', required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, }, @@ -120,17 +105,14 @@ export const userDescription: INodeProperties[] = [ displayName: 'User ID', name: 'id', type: 'string', - description: 'User to delete. Specify an ID using an expression.', + description: + 'User to delete. Specify an ID using an expression.', default: '', required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'delete', - ], + resource: ['user'], + operation: ['delete'], }, }, }, @@ -138,17 +120,14 @@ export const userDescription: INodeProperties[] = [ displayName: 'User ID', name: 'id', type: 'string', - description: 'User to retrieve. Specify an ID using an expression.', + description: + 'User to retrieve. Specify an ID using an expression.', default: '', required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, }, @@ -158,12 +137,8 @@ export const userDescription: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, default: {}, @@ -240,7 +215,8 @@ export const userDescription: INodeProperties[] = [ loadOptionsMethod: 'loadUserCustomFields', }, default: '', - description: 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Field Value', @@ -287,7 +263,8 @@ export const userDescription: INodeProperties[] = [ displayName: 'Organization Name or ID', name: 'organization', type: 'options', - description: 'Name of the organization to assign to the user. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the organization to assign to the user. Choose from the list, or specify an ID using an expression.', default: '', typeOptions: { loadOptionsMethod: 'loadOrganizations', @@ -336,12 +313,8 @@ export const userDescription: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'user', - ], + operation: ['update'], + resource: ['user'], }, }, default: {}, @@ -418,7 +391,8 @@ export const userDescription: INodeProperties[] = [ loadOptionsMethod: 'loadUserCustomFields', }, default: '', - description: 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the custom field to set. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Field Value', @@ -479,7 +453,8 @@ export const userDescription: INodeProperties[] = [ displayName: 'Organization Name or ID', name: 'organization', type: 'options', - description: 'Name of the organization to assign to the user. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the organization to assign to the user. Choose from the list, or specify an ID using an expression.', default: '', typeOptions: { loadOptionsMethod: 'loadOrganizationNames', @@ -530,12 +505,8 @@ export const userDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'user', - ], + operation: ['search'], + resource: ['user'], }, }, }, @@ -549,12 +520,8 @@ export const userDescription: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'user', - ], + operation: ['search'], + resource: ['user'], }, }, description: 'Max number of results to return', @@ -567,12 +534,8 @@ export const userDescription: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, }, @@ -587,15 +550,9 @@ export const userDescription: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['user'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -605,12 +562,8 @@ export const userDescription: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, default: {}, @@ -639,7 +592,8 @@ export const userDescription: INodeProperties[] = [ displayName: 'Sort Key Name or ID', name: 'sort_by', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'loadUserFields', }, diff --git a/packages/nodes-base/nodes/Zammad/types.d.ts b/packages/nodes-base/nodes/Zammad/types.d.ts index 07aa6f1ca3..e92a2ee6ff 100644 --- a/packages/nodes-base/nodes/Zammad/types.d.ts +++ b/packages/nodes-base/nodes/Zammad/types.d.ts @@ -1,6 +1,4 @@ -import { - IDataObject, -} from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export declare namespace Zammad { export type Resource = 'group' | 'organization' | 'ticket' | 'user'; @@ -12,7 +10,7 @@ export declare namespace Zammad { type CredentialsBase = { baseUrl: string; allowUnauthorizedCerts: boolean; - } + }; export type BasicAuthCredentials = CredentialsBase & { authType: 'basicAuth'; @@ -48,7 +46,7 @@ export declare namespace Zammad { }; export type Field = { - id: number, + id: number; display: string; name: string; object: string; @@ -62,7 +60,7 @@ export declare namespace Zammad { export type CustomFieldsUi = { customFieldsUi?: { - customFieldPairs: Array<{ name: string, value: string }>; + customFieldPairs: Array<{ name: string; value: string }>; }; }; @@ -88,10 +86,10 @@ export declare namespace Zammad { export type Article = { articleDetails: { - visibility: 'external' | 'internal', - subject: string, - body: string, - type: 'chat' | 'email' | 'fax' | 'note' | 'phone' | 'sms', + visibility: 'external' | 'internal'; + subject: string; + body: string; + type: 'chat' | 'email' | 'fax' | 'note' | 'phone' | 'sms'; }; }; } diff --git a/packages/nodes-base/nodes/Zendesk/ConditionDescription.ts b/packages/nodes-base/nodes/Zendesk/ConditionDescription.ts index f0f4c7f088..cccffc0a65 100644 --- a/packages/nodes-base/nodes/Zendesk/ConditionDescription.ts +++ b/packages/nodes-base/nodes/Zendesk/ConditionDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, - } from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const conditionFields: INodeProperties[] = [ { @@ -22,9 +20,7 @@ export const conditionFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - 'resource': [ - 'ticket', - ], + resource: ['ticket'], }, }, options: [ @@ -100,9 +96,7 @@ export const conditionFields: INodeProperties[] = [ ], displayOptions: { hide: { - field: [ - 'assignee', - ], + field: ['assignee'], }, }, default: 'is', @@ -148,9 +142,7 @@ export const conditionFields: INodeProperties[] = [ ], displayOptions: { show: { - field: [ - 'assignee', - ], + field: ['assignee'], }, }, default: 'is', @@ -161,21 +153,11 @@ export const conditionFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - field: [ - 'status', - ], + field: ['status'], }, hide: { - operation:[ - 'changed', - 'not_changed', - ], - field: [ - 'assignee', - 'group', - 'priority', - 'type', - ], + operation: ['changed', 'not_changed'], + field: ['assignee', 'group', 'priority', 'type'], }, }, options: [ @@ -208,21 +190,11 @@ export const conditionFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - field: [ - 'type', - ], + field: ['type'], }, hide: { - operation:[ - 'changed', - 'not_changed', - ], - field: [ - 'assignee', - 'group', - 'priority', - 'status', - ], + operation: ['changed', 'not_changed'], + field: ['assignee', 'group', 'priority', 'status'], }, }, options: [ @@ -251,21 +223,11 @@ export const conditionFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - field: [ - 'priority', - ], + field: ['priority'], }, hide: { - operation:[ - 'changed', - 'not_changed', - ], - field: [ - 'assignee', - 'group', - 'type', - 'status', - ], + operation: ['changed', 'not_changed'], + field: ['assignee', 'group', 'type', 'status'], }, }, options: [ @@ -293,23 +255,17 @@ export const conditionFields: INodeProperties[] = [ displayName: 'Value', name: 'value', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getGroups', }, displayOptions: { show: { - field: [ - 'group', - ], + field: ['group'], }, hide: { - field: [ - 'assignee', - 'priority', - 'type', - 'status', - ], + field: ['assignee', 'priority', 'type', 'status'], }, }, default: '', @@ -319,23 +275,17 @@ export const conditionFields: INodeProperties[] = [ displayName: 'Value', name: 'value', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getUsers', }, displayOptions: { show: { - field: [ - 'assignee', - ], + field: ['assignee'], }, hide: { - field: [ - 'group', - 'priority', - 'type', - 'status', - ], + field: ['group', 'priority', 'type', 'status'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts b/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts index 0b16128529..edc4d15fc8 100644 --- a/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, - } from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,21 +7,27 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, - JsonObject, - NodeApiError, - } from 'n8n-workflow'; +import { IDataObject, JsonObject, NodeApiError } from 'n8n-workflow'; -export async function zendeskApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function zendeskApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0); let credentials; if (authenticationMethod === 'apiToken') { - credentials = await this.getCredentials('zendeskApi') as { subdomain: string }; + credentials = (await this.getCredentials('zendeskApi')) as { subdomain: string }; } else { - credentials = await this.getCredentials('zendeskOAuth2Api') as { subdomain: string }; + credentials = (await this.getCredentials('zendeskOAuth2Api')) as { subdomain: string }; } let options: OptionsWithUri = { @@ -46,7 +50,7 @@ export async function zendeskApiRequest(this: IHookFunctions | IExecuteFunctions try { return await this.helpers.requestWithAuthentication.call(this, credentialType, options); - } catch(error) { + } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -55,8 +59,16 @@ export async function zendeskApiRequest(this: IHookFunctions | IExecuteFunctions * Make an API request to paginated flow endpoint * and return all results */ -export async function zendeskApiRequestAllItems(this: IHookFunctions | IExecuteFunctions| ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function zendeskApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + propertyName: string, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -70,15 +82,13 @@ export async function zendeskApiRequestAllItems(this: IHookFunctions | IExecuteF if (query.limit && query.limit <= returnData.length) { return returnData; } - } while ( - responseData.next_page !== undefined && - responseData.next_page !== null - ); + } while (responseData.next_page !== undefined && responseData.next_page !== null); return returnData; } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); diff --git a/packages/nodes-base/nodes/Zendesk/OrganizationDescription.ts b/packages/nodes-base/nodes/Zendesk/OrganizationDescription.ts index ec53994e2b..7dc883509e 100644 --- a/packages/nodes-base/nodes/Zendesk/OrganizationDescription.ts +++ b/packages/nodes-base/nodes/Zendesk/OrganizationDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, - } from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const organizationOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const organizationOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'organization', - ], + resource: ['organization'], }, }, options: [ @@ -64,10 +60,9 @@ export const organizationOperations: INodeProperties[] = [ ]; export const organizationFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* organization:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* organization:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Name', name: 'name', @@ -75,12 +70,8 @@ export const organizationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'create', - ], + resource: ['organization'], + operation: ['create'], }, }, required: true, @@ -93,12 +84,8 @@ export const organizationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'create', - ], + resource: ['organization'], + operation: ['create'], }, }, options: [ @@ -126,7 +113,7 @@ export const organizationFields: INodeProperties[] = [ displayName: 'Organization Fields', name: 'organizationFieldsUi', placeholder: 'Add Organization Field', - description: 'Values of custom fields in the organization\'s profile', + description: "Values of custom fields in the organization's profile", type: 'fixedCollection', typeOptions: { multipleValues: true, @@ -141,7 +128,8 @@ export const organizationFields: INodeProperties[] = [ displayName: 'Field Name or ID', name: 'field', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getOrganizationFields', }, @@ -165,13 +153,14 @@ export const organizationFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'IDs of tags applied to this organization. Choose from the list, or specify IDs using an expression.', + description: + 'IDs of tags applied to this organization. Choose from the list, or specify IDs using an expression.', }, ], }, -/* -------------------------------------------------------------------------- */ -/* organization:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* organization:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'Organization ID', name: 'id', @@ -180,12 +169,8 @@ export const organizationFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'update', - ], + resource: ['organization'], + operation: ['update'], }, }, }, @@ -197,12 +182,8 @@ export const organizationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'update', - ], + resource: ['organization'], + operation: ['update'], }, }, options: [ @@ -236,7 +217,7 @@ export const organizationFields: INodeProperties[] = [ displayName: 'Organization Fields', name: 'organizationFieldsUi', placeholder: 'Add Organization Field', - description: 'Values of custom fields in the organization\'s profile', + description: "Values of custom fields in the organization's profile", type: 'fixedCollection', typeOptions: { multipleValues: true, @@ -251,7 +232,8 @@ export const organizationFields: INodeProperties[] = [ displayName: 'Field Name or ID', name: 'field', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getOrganizationFields', }, @@ -275,13 +257,14 @@ export const organizationFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'IDs of tags applied to this organization. Choose from the list, or specify IDs using an expression.', + description: + 'IDs of tags applied to this organization. Choose from the list, or specify IDs using an expression.', }, ], }, -/* -------------------------------------------------------------------------- */ -/* organization:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* organization:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Organization ID', name: 'id', @@ -290,30 +273,22 @@ export const organizationFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'get', - ], + resource: ['organization'], + operation: ['get'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* organization:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* organization:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'getAll', - ], + resource: ['organization'], + operation: ['getAll'], }, }, default: false, @@ -325,15 +300,9 @@ export const organizationFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['organization'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -343,9 +312,9 @@ export const organizationFields: INodeProperties[] = [ default: 100, description: 'Max number of results to return', }, -/* -------------------------------------------------------------------------- */ -/* organization:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* organization:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Organization ID', name: 'id', @@ -354,18 +323,14 @@ export const organizationFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'delete', - ], + resource: ['organization'], + operation: ['delete'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* organization:getRelatedData */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* organization:getRelatedData */ + /* -------------------------------------------------------------------------- */ { displayName: 'Organization ID', name: 'id', @@ -374,12 +339,8 @@ export const organizationFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'getRelatedData', - ], + resource: ['organization'], + operation: ['getRelatedData'], }, }, }, diff --git a/packages/nodes-base/nodes/Zendesk/TicketDescription.ts b/packages/nodes-base/nodes/Zendesk/TicketDescription.ts index 5b8ab347a5..fa9d1559d6 100644 --- a/packages/nodes-base/nodes/Zendesk/TicketDescription.ts +++ b/packages/nodes-base/nodes/Zendesk/TicketDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const ticketOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const ticketOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'ticket', - ], + resource: ['ticket'], }, }, options: [ @@ -58,7 +54,6 @@ export const ticketOperations: INodeProperties[] = [ ]; export const ticketFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* ticket:create */ /* -------------------------------------------------------------------------- */ @@ -72,12 +67,8 @@ export const ticketFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, required: true, @@ -90,12 +81,8 @@ export const ticketFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, }, @@ -107,15 +94,9 @@ export const ticketFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['ticket'], + operation: ['create'], + jsonParameters: [false], }, }, options: [ @@ -141,7 +122,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'Custom field ID. Choose from the list, or specify an ID using an expression.', + description: + 'Custom field ID. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -169,7 +151,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getGroups', }, default: '', - description: 'The group this ticket is assigned to. Choose from the list, or specify an ID using an expression.', + description: + 'The group this ticket is assigned to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Recipient', @@ -226,7 +209,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'The array of tags applied to this ticket. Choose from the list, or specify IDs using an expression.', + description: + 'The array of tags applied to this ticket. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Type', @@ -265,18 +249,13 @@ export const ticketFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['ticket'], + operation: ['create'], + jsonParameters: [true], }, }, - description: 'Object of values to set as described here', + description: + 'Object of values to set as described here', }, /* -------------------------------------------------------------------------- */ @@ -290,12 +269,8 @@ export const ticketFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'update', - ], + resource: ['ticket'], + operation: ['update'], }, }, }, @@ -306,12 +281,8 @@ export const ticketFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'update', - ], + resource: ['ticket'], + operation: ['update'], }, }, }, @@ -323,15 +294,9 @@ export const ticketFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'update', - ], - jsonParameters: [ - false, - ], + resource: ['ticket'], + operation: ['update'], + jsonParameters: [false], }, }, options: [ @@ -364,7 +329,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getCustomFields', }, default: '', - description: 'Custom field ID. Choose from the list, or specify an ID using an expression.', + description: + 'Custom field ID. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -392,7 +358,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getGroups', }, default: '', - description: 'The group this ticket is assigned to. Choose from the list, or specify an ID using an expression.', + description: + 'The group this ticket is assigned to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Internal Note', @@ -463,7 +430,8 @@ export const ticketFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'The array of tags applied to this ticket. Choose from the list, or specify IDs using an expression.', + description: + 'The array of tags applied to this ticket. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Type', @@ -502,18 +470,13 @@ export const ticketFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['ticket'], + operation: ['update'], + jsonParameters: [true], }, }, - description: 'Object of values to update as described here', + description: + 'Object of values to update as described here', }, { displayName: 'Ticket Type', @@ -533,14 +496,8 @@ export const ticketFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'get', - 'delete', - 'getAll', - ], + resource: ['ticket'], + operation: ['get', 'delete', 'getAll'], }, }, }, @@ -555,15 +512,9 @@ export const ticketFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'get', - ], - ticketType: [ - 'regular', - ], + resource: ['ticket'], + operation: ['get'], + ticketType: ['regular'], }, }, }, @@ -575,15 +526,9 @@ export const ticketFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'get', - ], - ticketType: [ - 'suspended', - ], + resource: ['ticket'], + operation: ['get'], + ticketType: ['suspended'], }, }, description: 'Ticket ID', @@ -597,12 +542,8 @@ export const ticketFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], + resource: ['ticket'], + operation: ['getAll'], }, }, default: false, @@ -614,15 +555,9 @@ export const ticketFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['ticket'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -640,12 +575,8 @@ export const ticketFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], + resource: ['ticket'], + operation: ['getAll'], }, }, options: [ @@ -658,13 +589,12 @@ export const ticketFields: INodeProperties[] = [ }, displayOptions: { show: { - '/ticketType': [ - 'regular', - ], + '/ticketType': ['regular'], }, }, default: '', - description: 'The group to search. Choose from the list, or specify an ID using an expression.', + description: + 'The group to search. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Query', @@ -672,13 +602,12 @@ export const ticketFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/ticketType': [ - 'regular', - ], + '/ticketType': ['regular'], }, }, default: '', - description: 'Query syntax to search tickets', + description: + 'Query syntax to search tickets', }, { displayName: 'Sort By', @@ -731,9 +660,7 @@ export const ticketFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - '/ticketType': [ - 'regular', - ], + '/ticketType': ['regular'], }, }, options: [ @@ -779,15 +706,9 @@ export const ticketFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'delete', - ], - ticketType: [ - 'regular', - ], + resource: ['ticket'], + operation: ['delete'], + ticketType: ['regular'], }, }, }, @@ -799,15 +720,9 @@ export const ticketFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'delete', - ], - ticketType: [ - 'suspended', - ], + resource: ['ticket'], + operation: ['delete'], + ticketType: ['suspended'], }, }, description: 'Ticket ID', @@ -823,12 +738,8 @@ export const ticketFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'recover', - ], + resource: ['ticket'], + operation: ['recover'], }, }, }, diff --git a/packages/nodes-base/nodes/Zendesk/TicketFieldDescription.ts b/packages/nodes-base/nodes/Zendesk/TicketFieldDescription.ts index 9f66675d8a..0871320981 100644 --- a/packages/nodes-base/nodes/Zendesk/TicketFieldDescription.ts +++ b/packages/nodes-base/nodes/Zendesk/TicketFieldDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, - } from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const ticketFieldOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const ticketFieldOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'ticketField', - ], + resource: ['ticketField'], }, }, options: [ @@ -34,10 +30,9 @@ export const ticketFieldOperations: INodeProperties[] = [ ]; export const ticketFieldFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* ticketField:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* ticketField:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Ticket Field ID', name: 'ticketFieldId', @@ -46,31 +41,23 @@ export const ticketFieldFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'ticketField', - ], - operation: [ - 'get', - ], + resource: ['ticketField'], + operation: ['get'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* ticketField:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* ticketField:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'ticketField', - ], - operation: [ - 'getAll', - ], + resource: ['ticketField'], + operation: ['getAll'], }, }, default: false, @@ -82,15 +69,9 @@ export const ticketFieldFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'ticketField', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['ticketField'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Zendesk/TicketInterface.ts b/packages/nodes-base/nodes/Zendesk/TicketInterface.ts index da79435aba..daaf0085a6 100644 --- a/packages/nodes-base/nodes/Zendesk/TicketInterface.ts +++ b/packages/nodes-base/nodes/Zendesk/TicketInterface.ts @@ -1,8 +1,6 @@ -import { - IDataObject, - } from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; - export interface IComment { +export interface IComment { body?: string; html_body?: string; public?: boolean; diff --git a/packages/nodes-base/nodes/Zendesk/TriggerPlaceholders.ts b/packages/nodes-base/nodes/Zendesk/TriggerPlaceholders.ts index fc7ca10c44..402e910961 100644 --- a/packages/nodes-base/nodes/Zendesk/TriggerPlaceholders.ts +++ b/packages/nodes-base/nodes/Zendesk/TriggerPlaceholders.ts @@ -1,72 +1,70 @@ -import { - INodePropertyOptions, -} from 'n8n-workflow'; +import { INodePropertyOptions } from 'n8n-workflow'; export const triggerPlaceholders = [ { name: 'Title', value: 'ticket.title', - description: 'Ticket\'s subject', + description: "Ticket's subject", }, { name: 'Description', value: 'ticket.description', - description: 'Ticket\'s description', + description: "Ticket's description", }, { name: 'URL', value: 'ticket.url', - description: 'Ticket\'s URL', + description: "Ticket's URL", }, { name: 'ID', value: 'ticket.id', - description: 'Ticket\'s ID', + description: "Ticket's ID", }, { name: 'External ID', value: 'ticket.external_id', - description: 'Ticket\'s external ID', + description: "Ticket's external ID", }, { name: 'Via', value: 'ticket.via', - description: 'Ticket\'s source', + description: "Ticket's source", }, { name: 'Status', value: 'ticket.status', - description: 'Ticket\'s status', + description: "Ticket's status", }, { name: 'Priority', value: 'ticket.priority', - description: 'Ticket\'s priority', + description: "Ticket's priority", }, { name: 'Type', value: 'ticket.ticket_type', - description: 'Ticket\'s type', + description: "Ticket's type", }, { name: 'Group Name', value: 'ticket.group.name', - description: 'Ticket\'s assigned group', + description: "Ticket's assigned group", }, { name: 'Brand Name', value: 'ticket.brand.name', - description: 'Ticket\'s brand', + description: "Ticket's brand", }, { name: 'Due Date', value: 'ticket.due_date', - description: 'Ticket\'s due date (relevant for tickets of type Task)', + description: "Ticket's due date (relevant for tickets of type Task)", }, { name: 'Account', value: 'ticket.account', - description: 'This Zendesk Support\'s account name', + description: "This Zendesk Support's account name", }, { name: 'Assignee Email', @@ -76,52 +74,52 @@ export const triggerPlaceholders = [ { name: 'Assignee Name', value: 'ticket.assignee.name', - description: 'Assignee\'s full name', + description: "Assignee's full name", }, { name: 'Assignee First Name', value: 'ticket.assignee.first_name', - description: 'Assignee\'s first name', + description: "Assignee's first name", }, { name: 'Assignee Last Name', value: 'ticket.assignee.last_name', - description: 'Assignee\'s last name', + description: "Assignee's last name", }, { name: 'Requester Full Name', value: 'ticket.requester.name', - description: 'Requester\'s full name', + description: "Requester's full name", }, { name: 'Requester First Name', value: 'ticket.requester.first_name', - description: 'Requester\'s first name', + description: "Requester's first name", }, { name: 'Requester Last Name', value: 'ticket.requester.last_name', - description: 'Requester\'s last name', + description: "Requester's last name", }, { name: 'Requester Email', value: 'ticket.requester.email', - description: 'Requester\'s email', + description: "Requester's email", }, { name: 'Requester Language', value: 'ticket.requester.language', - description: 'Requester\'s language', + description: "Requester's language", }, { name: 'Requester Phone', value: 'ticket.requester.phone', - description: 'Requester\'s phone number', + description: "Requester's phone number", }, { name: 'Requester External ID', value: 'ticket.requester.external_id', - description: 'Requester\'s external ID', + description: "Requester's external ID", }, { name: 'Requester Field', @@ -131,47 +129,47 @@ export const triggerPlaceholders = [ { name: 'Requester Details', value: 'ticket.requester.details', - description: 'Detailed information about the ticket\'s requester', + description: "Detailed information about the ticket's requester", }, { name: 'Requester Organization', value: 'ticket.organization.name', - description: 'Requester\'s organization', + description: "Requester's organization", }, { name: `Ticket's Organization External ID`, value: 'ticket.organization.external_id', - description: 'Ticket\'s organization external ID', + description: "Ticket's organization external ID", }, { name: `Organization details`, value: 'ticket.organization.details', - description: 'The details about the organization of the ticket\'s requester', + description: "The details about the organization of the ticket's requester", }, { name: `Organization Note`, value: 'ticket.organization.notes', - description: 'The notes about the organization of the ticket\'s requester', + description: "The notes about the organization of the ticket's requester", }, { name: `Ticket's CCs`, value: 'ticket.ccs', - description: 'Ticket\'s CCs', + description: "Ticket's CCs", }, { name: `Ticket's CCs names`, value: 'ticket.cc_names', - description: 'Ticket\'s CCs names', + description: "Ticket's CCs names", }, { name: `Ticket's tags`, value: 'ticket.tags', - description: 'Ticket\'s tags', + description: "Ticket's tags", }, { name: `Current Holiday Name`, value: 'ticket.current_holiday_name', - description: 'Displays the name of the current holiday on the ticket\'s schedule', + description: "Displays the name of the current holiday on the ticket's schedule", }, { name: `Current User Name `, @@ -196,12 +194,12 @@ export const triggerPlaceholders = [ { name: `Current User Organization Details `, value: 'current_user.organization.details', - description: 'Your default organization\'s details', + description: "Your default organization's details", }, { name: `Current User Organization Notes `, value: 'current_user.organization.notes', - description: 'Your default organization\'s note', + description: "Your default organization's note", }, { name: `Current User Language `, diff --git a/packages/nodes-base/nodes/Zendesk/UserDescription.ts b/packages/nodes-base/nodes/Zendesk/UserDescription.ts index 00774e1069..a4971f4532 100644 --- a/packages/nodes-base/nodes/Zendesk/UserDescription.ts +++ b/packages/nodes-base/nodes/Zendesk/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, - } from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -43,8 +39,8 @@ export const userOperations: INodeProperties[] = [ { name: 'Get Organizations', value: 'getOrganizations', - description: 'Get a user\'s organizations', - action: 'Get a user\'s organizations', + description: "Get a user's organizations", + action: "Get a user's organizations", }, { name: 'Get Related Data', @@ -70,10 +66,9 @@ export const userOperations: INodeProperties[] = [ ]; export const userFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* user:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Name', name: 'name', @@ -81,16 +76,12 @@ export const userFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, required: true, - description: 'The user\'s name', + description: "The user's name", }, { displayName: 'Additional Fields', @@ -100,12 +91,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, options: [ @@ -136,7 +123,7 @@ export const userFields: INodeProperties[] = [ type: 'string', placeholder: 'name@email.com', default: '', - description: 'The user\'s primary email address', + description: "The user's primary email address", }, { displayName: 'External ID', @@ -154,7 +141,8 @@ export const userFields: INodeProperties[] = [ loadOptionsMethod: 'getLocales', }, default: '', - description: 'The user\'s locale. Choose from the list, or specify an ID using an expression.', + description: + 'The user\'s locale. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Moderator', @@ -185,28 +173,31 @@ export const userFields: INodeProperties[] = [ }, type: 'options', default: '', - description: 'The ID of the user\'s organization. If the user has more than one organization memberships, the ID of the user\'s default organization. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the user\'s organization. If the user has more than one organization memberships, the ID of the user\'s default organization. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Phone', name: 'phone', type: 'string', default: '', - description: 'The user\'s primary phone number', + description: "The user's primary phone number", }, { displayName: 'Report CSV', name: 'report_csv', type: 'boolean', default: false, - description: 'Whether or not the user can access the CSV report on the Search tab of the Reporting page in the Support admin interface', + description: + 'Whether or not the user can access the CSV report on the Search tab of the Reporting page in the Support admin interface', }, { displayName: 'Restricted Agent', name: 'restricted_agent', type: 'boolean', default: false, - description: 'Whether the agent has any restrictions; false for admins and unrestricted agents, true for other agents', + description: + 'Whether the agent has any restrictions; false for admins and unrestricted agents, true for other agents', }, { displayName: 'Role', @@ -227,21 +218,22 @@ export const userFields: INodeProperties[] = [ }, ], default: '', - description: 'The user\'s role', + description: "The user's role", }, { displayName: 'Signature', name: 'signature', type: 'string', default: '', - description: 'The user\'s signature. Only agents and admins can have signatures.', + description: "The user's signature. Only agents and admins can have signatures.", }, { displayName: 'Suspended', name: 'suspended', type: 'boolean', default: false, - description: 'Whether the agent is suspended. Tickets from suspended users are also suspended, and these users cannot sign in to the end user portal.', + description: + 'Whether the agent is suspended. Tickets from suspended users are also suspended, and these users cannot sign in to the end user portal.', }, { displayName: 'Tag Names or IDs', @@ -251,7 +243,8 @@ export const userFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'The array of tags applied to this user. Choose from the list, or specify IDs using an expression.', + description: + 'The array of tags applied to this user. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Ticket Restriction', @@ -283,13 +276,13 @@ export const userFields: INodeProperties[] = [ name: 'time_zone', type: 'string', default: '', - description: 'The user\'s time zone', + description: "The user's time zone", }, { displayName: 'User Fields', name: 'userFieldsUi', placeholder: 'Add User Field', - description: 'Values of custom fields in the user\'s profile', + description: "Values of custom fields in the user's profile", type: 'fixedCollection', typeOptions: { multipleValues: true, @@ -308,7 +301,8 @@ export const userFields: INodeProperties[] = [ loadOptionsMethod: 'getUserFields', }, default: '', - description: 'Name of the field to sort on. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the field to sort on. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -326,13 +320,13 @@ export const userFields: INodeProperties[] = [ name: 'verified', type: 'boolean', default: false, - description: 'Whether the user\'s primary identity is verified or not', + description: "Whether the user's primary identity is verified or not", }, ], }, -/* -------------------------------------------------------------------------- */ -/* user:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'User ID', name: 'id', @@ -341,12 +335,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, }, @@ -358,12 +348,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, options: [ @@ -394,7 +380,7 @@ export const userFields: INodeProperties[] = [ type: 'string', placeholder: 'name@email.com', default: '', - description: 'The user\'s primary email address', + description: "The user's primary email address", }, { displayName: 'External ID', @@ -412,7 +398,8 @@ export const userFields: INodeProperties[] = [ loadOptionsMethod: 'getLocales', }, default: '', - description: 'The user\'s locale. Choose from the list, or specify an ID using an expression.', + description: + 'The user\'s locale. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Moderator', @@ -426,7 +413,7 @@ export const userFields: INodeProperties[] = [ name: 'name', type: 'string', default: '', - description: 'The user\'s name', + description: "The user's name", }, { displayName: 'Notes', @@ -450,28 +437,31 @@ export const userFields: INodeProperties[] = [ }, type: 'options', default: '', - description: 'The ID of the user\'s organization. If the user has more than one organization memberships, the ID of the user\'s default organization. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the user\'s organization. If the user has more than one organization memberships, the ID of the user\'s default organization. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Phone', name: 'phone', type: 'string', default: '', - description: 'The user\'s primary phone number', + description: "The user's primary phone number", }, { displayName: 'Report CSV', name: 'report_csv', type: 'boolean', default: false, - description: 'Whether or not the user can access the CSV report on the Search tab of the Reporting page in the Support admin interface', + description: + 'Whether or not the user can access the CSV report on the Search tab of the Reporting page in the Support admin interface', }, { displayName: 'Restricted Agent', name: 'restricted_agent', type: 'boolean', default: false, - description: 'Whether the agent has any restrictions; false for admins and unrestricted agents, true for other agents', + description: + 'Whether the agent has any restrictions; false for admins and unrestricted agents, true for other agents', }, { displayName: 'Role', @@ -492,21 +482,22 @@ export const userFields: INodeProperties[] = [ }, ], default: '', - description: 'The user\'s role', + description: "The user's role", }, { displayName: 'Signature', name: 'signature', type: 'string', default: '', - description: 'The user\'s signature. Only agents and admins can have signatures.', + description: "The user's signature. Only agents and admins can have signatures.", }, { displayName: 'Suspended', name: 'suspended', type: 'boolean', default: false, - description: 'Whether the agent is suspended. Tickets from suspended users are also suspended, and these users cannot sign in to the end user portal.', + description: + 'Whether the agent is suspended. Tickets from suspended users are also suspended, and these users cannot sign in to the end user portal.', }, { displayName: 'Tag Names or IDs', @@ -516,7 +507,8 @@ export const userFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'The array of tags applied to this user. Choose from the list, or specify IDs using an expression.', + description: + 'The array of tags applied to this user. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Ticket Restriction', @@ -548,13 +540,13 @@ export const userFields: INodeProperties[] = [ name: 'time_zone', type: 'string', default: '', - description: 'The user\'s time zone', + description: "The user's time zone", }, { displayName: 'User Fields', name: 'userFieldsUi', placeholder: 'Add User Field', - description: 'Values of custom fields in the user\'s profile', + description: "Values of custom fields in the user's profile", type: 'fixedCollection', typeOptions: { multipleValues: true, @@ -573,7 +565,8 @@ export const userFields: INodeProperties[] = [ loadOptionsMethod: 'getUserFields', }, default: '', - description: 'Name of the field to sort on. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the field to sort on. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -591,13 +584,13 @@ export const userFields: INodeProperties[] = [ name: 'verified', type: 'boolean', default: false, - description: 'Whether the user\'s primary identity is verified or not', + description: "Whether the user's primary identity is verified or not", }, ], }, -/* -------------------------------------------------------------------------- */ -/* user:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'User ID', name: 'id', @@ -606,30 +599,22 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* user:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, default: false, @@ -641,15 +626,9 @@ export const userFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['user'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -667,12 +646,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, options: [ @@ -698,21 +673,17 @@ export const userFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* user:search */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:search */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'search', - ], + resource: ['user'], + operation: ['search'], }, }, default: false, @@ -724,15 +695,9 @@ export const userFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'search', - ], - returnAll: [ - false, - ], + resource: ['user'], + operation: ['search'], + returnAll: [false], }, }, typeOptions: { @@ -750,12 +715,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'search', - ], + resource: ['user'], + operation: ['search'], }, }, options: [ @@ -773,9 +734,9 @@ export const userFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* user:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'User ID', name: 'id', @@ -784,18 +745,14 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'delete', - ], + resource: ['user'], + operation: ['delete'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* user:getRelatedData */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:getRelatedData */ + /* -------------------------------------------------------------------------- */ { displayName: 'User ID', name: 'id', @@ -804,18 +761,14 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getRelatedData', - ], + resource: ['user'], + operation: ['getRelatedData'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* user:getOrganizations */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* user:getOrganizations */ + /* -------------------------------------------------------------------------- */ { displayName: 'User ID', name: 'id', @@ -824,12 +777,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getOrganizations', - ], + resource: ['user'], + operation: ['getOrganizations'], }, }, }, diff --git a/packages/nodes-base/nodes/Zendesk/Zendesk.node.ts b/packages/nodes-base/nodes/Zendesk/Zendesk.node.ts index 944d374424..c11e280afa 100644 --- a/packages/nodes-base/nodes/Zendesk/Zendesk.node.ts +++ b/packages/nodes-base/nodes/Zendesk/Zendesk.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -13,36 +11,17 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - validateJSON, - zendeskApiRequest, - zendeskApiRequestAllItems, -} from './GenericFunctions'; +import { validateJSON, zendeskApiRequest, zendeskApiRequestAllItems } from './GenericFunctions'; -import { - ticketFields, - ticketOperations -} from './TicketDescription'; +import { ticketFields, ticketOperations } from './TicketDescription'; -import { - ticketFieldFields, - ticketFieldOperations -} from './TicketFieldDescription'; +import { ticketFieldFields, ticketFieldOperations } from './TicketFieldDescription'; -import { - userFields, - userOperations -} from './UserDescription'; +import { userFields, userOperations } from './UserDescription'; -import { - organizationFields, - organizationOperations -} from './OrganizationDescription'; +import { organizationFields, organizationOperations } from './OrganizationDescription'; -import { - IComment, - ITicket, -} from './TicketInterface'; +import { IComment, ITicket } from './TicketInterface'; export class Zendesk implements INodeType { description: INodeTypeDescription = { @@ -64,9 +43,7 @@ export class Zendesk implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'apiToken', - ], + authentication: ['apiToken'], }, }, }, @@ -75,9 +52,7 @@ export class Zendesk implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -108,7 +83,8 @@ export class Zendesk implements INodeType { { name: 'Ticket', value: 'ticket', - description: 'Tickets are the means through which your end users (customers) communicate with agents in Zendesk Support', + description: + 'Tickets are the means through which your end users (customers) communicate with agents in Zendesk Support', }, { name: 'Ticket Field', @@ -159,7 +135,12 @@ export class Zendesk implements INodeType { 'multiselect', 'tagger', ]; - const fields = await zendeskApiRequestAllItems.call(this, 'ticket_fields', 'GET', '/ticket_fields'); + const fields = await zendeskApiRequestAllItems.call( + this, + 'ticket_fields', + 'GET', + '/ticket_fields', + ); for (const field of fields) { if (customFields.includes(field.type)) { const fieldName = field.title; @@ -223,7 +204,12 @@ export class Zendesk implements INodeType { // select them easily async getUserFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const fields = await zendeskApiRequestAllItems.call(this, 'user_fields', 'GET', '/user_fields'); + const fields = await zendeskApiRequestAllItems.call( + this, + 'user_fields', + 'GET', + '/user_fields', + ); for (const field of fields) { const fieldName = field.title; const fieldId = field.key; @@ -238,7 +224,12 @@ export class Zendesk implements INodeType { // Get all the organization fields to display them to the user for easy selection async getOrganizationFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const fields = await zendeskApiRequestAllItems.call(this, 'organization_fields', 'GET', '/organization_fields'); + const fields = await zendeskApiRequestAllItems.call( + this, + 'organization_fields', + 'GET', + '/organization_fields', + ); for (const field of fields) { const fieldName = field.title; const fieldId = field.key; @@ -252,7 +243,14 @@ export class Zendesk implements INodeType { async getOrganizations(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const fields = await zendeskApiRequestAllItems.call(this, 'organizations', 'GET', `/organizations`, {}, {}); + const fields = await zendeskApiRequestAllItems.call( + this, + 'organizations', + 'GET', + `/organizations`, + {}, + {}, + ); for (const field of fields) { returnData.push({ name: field.name, @@ -287,21 +285,23 @@ export class Zendesk implements INodeType { comment, }; if (jsonParameters) { - const additionalFieldsJson = this.getNodeParameter('additionalFieldsJson', i) as string; + const additionalFieldsJson = this.getNodeParameter( + 'additionalFieldsJson', + i, + ) as string; if (additionalFieldsJson !== '') { - if (validateJSON(additionalFieldsJson) !== undefined) { - Object.assign(body, JSON.parse(additionalFieldsJson)); - } else { - throw new NodeOperationError(this.getNode(), 'Additional fields must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Additional fields must be a valid JSON', + { itemIndex: i }, + ); } } - } else { - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (additionalFields.type) { @@ -326,7 +326,8 @@ export class Zendesk implements INodeType { body.tags = additionalFields.tags as string[]; } if (additionalFields.customFieldsUi) { - body.custom_fields = (additionalFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + body.custom_fields = (additionalFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; } } responseData = await zendeskApiRequest.call(this, 'POST', '/tickets', { ticket: body }); @@ -342,18 +343,17 @@ export class Zendesk implements INodeType { const updateFieldsJson = this.getNodeParameter('updateFieldsJson', i) as string; if (updateFieldsJson !== '') { - if (validateJSON(updateFieldsJson) !== undefined) { - Object.assign(body, JSON.parse(updateFieldsJson)); - } else { - throw new NodeOperationError(this.getNode(), 'Additional fields must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Additional fields must be a valid JSON', + { itemIndex: i }, + ); } } - } else { - const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; if (updateFields.type) { @@ -378,7 +378,8 @@ export class Zendesk implements INodeType { body.tags = updateFields.tags as string[]; } if (updateFields.customFieldsUi) { - body.custom_fields = (updateFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + body.custom_fields = (updateFields.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; } if (updateFields.assigneeEmail) { body.assignee_email = updateFields.assigneeEmail as string; @@ -398,9 +399,10 @@ export class Zendesk implements INodeType { }; body.comment = comment; } - } - responseData = await zendeskApiRequest.call(this, 'PUT', `/tickets/${ticketId}`, { ticket: body }); + responseData = await zendeskApiRequest.call(this, 'PUT', `/tickets/${ticketId}`, { + ticket: body, + }); responseData = responseData.ticket; } //https://developer.zendesk.com/rest_api/docs/support/tickets#show-ticket @@ -408,7 +410,8 @@ export class Zendesk implements INodeType { if (operation === 'get') { const ticketType = this.getNodeParameter('ticketType', i) as string; const ticketId = this.getNodeParameter('id', i) as string; - const endpoint = (ticketType === 'regular') ? `/tickets/${ticketId}` : `/suspended_tickets/${ticketId}`; + const endpoint = + ticketType === 'regular' ? `/tickets/${ticketId}` : `/suspended_tickets/${ticketId}`; responseData = await zendeskApiRequest.call(this, 'GET', endpoint, {}); responseData = responseData.ticket || responseData.suspended_ticket; } @@ -435,10 +438,17 @@ export class Zendesk implements INodeType { if (options.sortOrder) { qs.sort_order = options.sortOrder; } - const endpoint = (ticketType === 'regular') ? `/search` : `/suspended_tickets`; - const property = (ticketType === 'regular') ? 'results' : 'suspended_tickets'; + const endpoint = ticketType === 'regular' ? `/search` : `/suspended_tickets`; + const property = ticketType === 'regular' ? 'results' : 'suspended_tickets'; if (returnAll) { - responseData = await zendeskApiRequestAllItems.call(this, property, 'GET', endpoint, {}, qs); + responseData = await zendeskApiRequestAllItems.call( + this, + property, + 'GET', + endpoint, + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.per_page = limit; @@ -451,7 +461,8 @@ export class Zendesk implements INodeType { if (operation === 'delete') { const ticketType = this.getNodeParameter('ticketType', i) as string; const ticketId = this.getNodeParameter('id', i) as string; - const endpoint = (ticketType === 'regular') ? `/tickets/${ticketId}` : `/suspended_tickets/${ticketId}`; + const endpoint = + ticketType === 'regular' ? `/tickets/${ticketId}` : `/suspended_tickets/${ticketId}`; responseData = await zendeskApiRequest.call(this, 'DELETE', endpoint, {}); responseData = { success: true }; } @@ -459,7 +470,12 @@ export class Zendesk implements INodeType { if (operation === 'recover') { const ticketId = this.getNodeParameter('id', i) as string; try { - responseData = await zendeskApiRequest.call(this, 'PUT', `/suspended_tickets/${ticketId}/recover`, {}); + responseData = await zendeskApiRequest.call( + this, + 'PUT', + `/suspended_tickets/${ticketId}/recover`, + {}, + ); responseData = responseData.ticket; } catch (error) { throw new NodeApiError(this.getNode(), error); @@ -471,18 +487,37 @@ export class Zendesk implements INodeType { //https://developer.zendesk.com/rest_api/docs/support/tickets#show-ticket if (operation === 'get') { const ticketFieldId = this.getNodeParameter('ticketFieldId', i) as string; - responseData = await zendeskApiRequest.call(this, 'GET', `/ticket_fields/${ticketFieldId}`, {}); + responseData = await zendeskApiRequest.call( + this, + 'GET', + `/ticket_fields/${ticketFieldId}`, + {}, + ); responseData = responseData.ticket_field; } //https://developer.zendesk.com/rest_api/docs/support/ticket_fields#list-ticket-fields if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll) { - responseData = await zendeskApiRequestAllItems.call(this, 'ticket_fields', 'GET', '/ticket_fields', {}, qs); + responseData = await zendeskApiRequestAllItems.call( + this, + 'ticket_fields', + 'GET', + '/ticket_fields', + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.limit = limit; - responseData = await zendeskApiRequestAllItems.call(this, 'ticket_fields', 'GET', '/ticket_fields', {}, qs); + responseData = await zendeskApiRequestAllItems.call( + this, + 'ticket_fields', + 'GET', + '/ticket_fields', + {}, + qs, + ); responseData = responseData.slice(0, limit); } } @@ -501,7 +536,8 @@ export class Zendesk implements INodeType { Object.assign(body, additionalFields); if (body.userFieldsUi) { - const userFields = (body.userFieldsUi as IDataObject).userFieldValues as IDataObject[]; + const userFields = (body.userFieldsUi as IDataObject) + .userFieldValues as IDataObject[]; if (userFields) { body.user_fields = {}; for (const userField of userFields) { @@ -524,7 +560,8 @@ export class Zendesk implements INodeType { Object.assign(body, updateFields); if (body.userFieldsUi) { - const userFields = (body.userFieldsUi as IDataObject).userFieldValues as IDataObject[]; + const userFields = (body.userFieldsUi as IDataObject) + .userFieldValues as IDataObject[]; if (userFields) { body.user_fields = {}; for (const userField of userFields) { @@ -535,7 +572,9 @@ export class Zendesk implements INodeType { } } - responseData = await zendeskApiRequest.call(this, 'PUT', `/users/${userId}`, { user: body }); + responseData = await zendeskApiRequest.call(this, 'PUT', `/users/${userId}`, { + user: body, + }); responseData = responseData.user; } //https://developer.zendesk.com/api-reference/ticketing/users/users/#show-user @@ -552,7 +591,14 @@ export class Zendesk implements INodeType { Object.assign(qs, options); if (returnAll) { - responseData = await zendeskApiRequestAllItems.call(this, 'users', 'GET', `/users`, {}, qs); + responseData = await zendeskApiRequestAllItems.call( + this, + 'users', + 'GET', + `/users`, + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.per_page = limit; @@ -563,7 +609,12 @@ export class Zendesk implements INodeType { //https://developer.zendesk.com/api-reference/ticketing/organizations/organizations/#list-organizations if (operation === 'getOrganizations') { const userId = this.getNodeParameter('id', i) as string; - responseData = await zendeskApiRequest.call(this, 'GET', `/users/${userId}/organizations`, {}); + responseData = await zendeskApiRequest.call( + this, + 'GET', + `/users/${userId}/organizations`, + {}, + ); responseData = responseData.organizations; } //https://developer.zendesk.com/api-reference/ticketing/users/users/#search-users @@ -574,7 +625,14 @@ export class Zendesk implements INodeType { Object.assign(qs, options); if (returnAll) { - responseData = await zendeskApiRequestAllItems.call(this, 'users', 'GET', `/users/search`, {}, qs); + responseData = await zendeskApiRequestAllItems.call( + this, + 'users', + 'GET', + `/users/search`, + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.per_page = limit; @@ -591,7 +649,12 @@ export class Zendesk implements INodeType { //https://developer.zendesk.com/api-reference/ticketing/users/users/#show-user-related-information if (operation === 'getRelatedData') { const userId = this.getNodeParameter('id', i) as string; - responseData = await zendeskApiRequest.call(this, 'GET', `/users/${userId}/related`, {}); + responseData = await zendeskApiRequest.call( + this, + 'GET', + `/users/${userId}/related`, + {}, + ); responseData = responseData.user_related; } } @@ -601,11 +664,21 @@ export class Zendesk implements INodeType { if (operation === 'create') { const name = this.getNodeParameter('name', i) as string; - const body: IDataObject & { name: string; organization_fields?: { [key: string]: object | string } } = { + const body: IDataObject & { + name: string; + organization_fields?: { [key: string]: object | string }; + } = { name, }; - const { organizationFieldsUi, ...rest } = this.getNodeParameter('additionalFields', i) as IDataObject & { organizationFieldsUi?: { organizationFieldValues: Array<{ field: string; value: string; }> } }; + const { organizationFieldsUi, ...rest } = this.getNodeParameter( + 'additionalFields', + i, + ) as IDataObject & { + organizationFieldsUi?: { + organizationFieldValues: Array<{ field: string; value: string }>; + }; + }; Object.assign(body, rest); @@ -619,7 +692,9 @@ export class Zendesk implements INodeType { } } - responseData = await zendeskApiRequest.call(this, 'POST', '/organizations', { organization: body }); + responseData = await zendeskApiRequest.call(this, 'POST', '/organizations', { + organization: body, + }); responseData = responseData.organization; } //https://developer.zendesk.com/api-reference/ticketing/organizations/organizations/#delete-organization @@ -636,7 +711,12 @@ export class Zendesk implements INodeType { //https://developer.zendesk.com/api-reference/ticketing/organizations/organizations/#show-organization if (operation === 'get') { const organizationId = this.getNodeParameter('id', i) as string; - responseData = await zendeskApiRequest.call(this, 'GET', `/organizations/${organizationId}`, {}); + responseData = await zendeskApiRequest.call( + this, + 'GET', + `/organizations/${organizationId}`, + {}, + ); responseData = responseData.organization; } //https://developer.zendesk.com/api-reference/ticketing/organizations/organizations/#list-organizations @@ -644,7 +724,14 @@ export class Zendesk implements INodeType { const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll) { - responseData = await zendeskApiRequestAllItems.call(this, 'organizations', 'GET', `/organizations`, {}, qs); + responseData = await zendeskApiRequestAllItems.call( + this, + 'organizations', + 'GET', + `/organizations`, + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', i) as number; qs.per_page = limit; @@ -655,16 +742,29 @@ export class Zendesk implements INodeType { //https://developer.zendesk.com/api-reference/ticketing/organizations/organizations/#show-organizations-related-information if (operation === 'getRelatedData') { const organizationId = this.getNodeParameter('id', i) as string; - responseData = await zendeskApiRequest.call(this, 'GET', `/organizations/${organizationId}/related`, {}); + responseData = await zendeskApiRequest.call( + this, + 'GET', + `/organizations/${organizationId}/related`, + {}, + ); responseData = responseData.organization_related; } //https://developer.zendesk.com/api-reference/ticketing/organizations/organizations/#update-organization if (operation === 'update') { const organizationId = this.getNodeParameter('id', i) as string; - const body: IDataObject & { organization_fields?: { [key: string]: object | string } } = {}; + const body: IDataObject & { organization_fields?: { [key: string]: object | string } } = + {}; - const { organizationFieldsUi, ...rest } = this.getNodeParameter('updateFields', i) as IDataObject & { organizationFieldsUi?: { organizationFieldValues: Array<{ field: string; value: string; }> } }; + const { organizationFieldsUi, ...rest } = this.getNodeParameter( + 'updateFields', + i, + ) as IDataObject & { + organizationFieldsUi?: { + organizationFieldValues: Array<{ field: string; value: string }>; + }; + }; Object.assign(body, rest); @@ -678,10 +778,14 @@ export class Zendesk implements INodeType { } } - responseData = await zendeskApiRequest.call(this, 'PUT', `/organizations/${organizationId}`, { organization: body }); + responseData = await zendeskApiRequest.call( + this, + 'PUT', + `/organizations/${organizationId}`, + { organization: body }, + ); responseData = responseData.organization; } - } if (Array.isArray(responseData)) { returnData.push.apply(returnData, responseData as IDataObject[]); diff --git a/packages/nodes-base/nodes/Zendesk/ZendeskTrigger.node.ts b/packages/nodes-base/nodes/Zendesk/ZendeskTrigger.node.ts index fd7fc10d22..2bffd348be 100644 --- a/packages/nodes-base/nodes/Zendesk/ZendeskTrigger.node.ts +++ b/packages/nodes-base/nodes/Zendesk/ZendeskTrigger.node.ts @@ -1,11 +1,6 @@ -import { - parse as urlParse, -} from 'url'; +import { parse as urlParse } from 'url'; -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -17,17 +12,10 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - zendeskApiRequest, - zendeskApiRequestAllItems, -} from './GenericFunctions'; -import { - conditionFields, - } from './ConditionDescription'; +import { zendeskApiRequest, zendeskApiRequestAllItems } from './GenericFunctions'; +import { conditionFields } from './ConditionDescription'; -import { - triggerPlaceholders -} from './TriggerPlaceholders'; +import { triggerPlaceholders } from './TriggerPlaceholders'; export class ZendeskTrigger implements INodeType { description: INodeTypeDescription = { @@ -48,9 +36,7 @@ export class ZendeskTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'apiToken', - ], + authentication: ['apiToken'], }, }, }, @@ -59,9 +45,7 @@ export class ZendeskTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -110,9 +94,7 @@ export class ZendeskTrigger implements INodeType { type: 'collection', displayOptions: { show: { - service: [ - 'support', - ], + service: ['support'], }, }, default: {}, @@ -120,7 +102,8 @@ export class ZendeskTrigger implements INodeType { { displayName: 'Field Names or IDs', name: 'fields', - description: 'The fields to return the values of. Choose from the list, or specify IDs using an expression.', + description: + 'The fields to return the values of. Choose from the list, or specify IDs using an expression.', type: 'multiOptions', default: [], typeOptions: { @@ -140,9 +123,7 @@ export class ZendeskTrigger implements INodeType { }, displayOptions: { show: { - service: [ - 'support', - ], + service: ['support'], }, }, description: 'The condition to set', @@ -151,21 +132,16 @@ export class ZendeskTrigger implements INodeType { { name: 'all', displayName: 'All', - values: [ - ...conditionFields, - ], + values: [...conditionFields], }, { name: 'any', displayName: 'Any', - values: [ - ...conditionFields, - ], + values: [...conditionFields], }, ], }, ], - }; methods = { loadOptions: { @@ -183,7 +159,12 @@ export class ZendeskTrigger implements INodeType { 'multiselect', 'tagger', ]; - const fields = await zendeskApiRequestAllItems.call(this, 'ticket_fields', 'GET', '/ticket_fields'); + const fields = await zendeskApiRequestAllItems.call( + this, + 'ticket_fields', + 'GET', + '/ticket_fields', + ); for (const field of fields) { if (customFields.includes(field.type) && field.removable && field.active) { const fieldName = field.title; @@ -246,7 +227,8 @@ export class ZendeskTrigger implements INodeType { const conditions = this.getNodeParameter('conditions') as IDataObject; let endpoint = ''; - const resultAll = [], resultAny = []; + const resultAll = [], + resultAny = []; const conditionsAll = conditions.all as [IDataObject]; if (conditionsAll) { @@ -254,8 +236,7 @@ export class ZendeskTrigger implements INodeType { const aux: IDataObject = {}; aux.field = conditionAll.field; aux.operator = conditionAll.operation; - if (conditionAll.operation !== 'changed' - && conditionAll.operation !== 'not_changed') { + if (conditionAll.operation !== 'changed' && conditionAll.operation !== 'not_changed') { aux.value = conditionAll.value; } else { aux.value = null; @@ -270,8 +251,7 @@ export class ZendeskTrigger implements INodeType { const aux: IDataObject = {}; aux.field = conditionAny.field; aux.operator = conditionAny.operation; - if (conditionAny.operation !== 'changed' - && conditionAny.operation !== 'not_changed') { + if (conditionAny.operation !== 'changed' && conditionAny.operation !== 'not_changed') { aux.value = conditionAny.value; } else { aux.value = null; @@ -296,18 +276,24 @@ export class ZendeskTrigger implements INodeType { } endpoint = `/triggers/active`; - const triggers = await zendeskApiRequestAllItems.call(this, 'triggers', 'GET', endpoint); + const triggers = await zendeskApiRequestAllItems.call(this, 'triggers', 'GET', endpoint); for (const trigger of triggers) { - const toDeleteTriggers = []; - // this trigger belong to the current target - if (trigger.actions[0].value[0].toString() === webhookData.targetId?.toString()) { - toDeleteTriggers.push(trigger.id); - } - // delete all trigger attach to this target; - if (toDeleteTriggers.length !== 0) { - await zendeskApiRequest.call(this, 'DELETE', '/triggers/destroy_many', {}, { ids: toDeleteTriggers.join(',') } ); - } + const toDeleteTriggers = []; + // this trigger belong to the current target + if (trigger.actions[0].value[0].toString() === webhookData.targetId?.toString()) { + toDeleteTriggers.push(trigger.id); + } + // delete all trigger attach to this target; + if (toDeleteTriggers.length !== 0) { + await zendeskApiRequest.call( + this, + 'DELETE', + '/triggers/destroy_many', + {}, + { ids: toDeleteTriggers.join(',') }, + ); + } } return false; @@ -319,7 +305,8 @@ export class ZendeskTrigger implements INodeType { if (service === 'support') { const message: IDataObject = {}; - const resultAll = [], resultAny = []; + const resultAll = [], + resultAny = []; const conditions = this.getNodeParameter('conditions') as IDataObject; const options = this.getNodeParameter('options') as IDataObject; @@ -342,8 +329,10 @@ export class ZendeskTrigger implements INodeType { const aux: IDataObject = {}; aux.field = conditionAll.field; aux.operator = conditionAll.operation; - if (conditionAll.operation !== 'changed' - && conditionAll.operation !== 'not_changed') { + if ( + conditionAll.operation !== 'changed' && + conditionAll.operation !== 'not_changed' + ) { aux.value = conditionAll.value; } else { aux.value = null; @@ -358,8 +347,10 @@ export class ZendeskTrigger implements INodeType { const aux: IDataObject = {}; aux.field = conditionAny.field; aux.operator = conditionAny.operation; - if (conditionAny.operation !== 'changed' - && conditionAny.operation !== 'not_changed') { + if ( + conditionAny.operation !== 'changed' && + conditionAny.operation !== 'not_changed' + ) { aux.value = conditionAny.value; } else { aux.value = null; @@ -376,7 +367,7 @@ export class ZendeskTrigger implements INodeType { conditions: { all: resultAll, any: resultAny, - }, + }, actions: [ { field: 'notification_webhook', @@ -388,14 +379,12 @@ export class ZendeskTrigger implements INodeType { const bodyTarget: IDataObject = { webhook: { - name:'n8n webhook', + name: 'n8n webhook', endpoint: webhookUrl, - http_method:'POST', - status:'active', - request_format:'json', - subscriptions: [ - 'conditional_ticket_events', - ], + http_method: 'POST', + status: 'active', + request_format: 'json', + subscriptions: ['conditional_ticket_events'], }, }; let target: IDataObject = {}; @@ -407,7 +396,8 @@ export class ZendeskTrigger implements INodeType { } else { // create a webhook // https://developer.zendesk.com/api-reference/event-connectors/webhooks/webhooks/#create-or-clone-webhook - target = (await zendeskApiRequest.call(this, 'POST', '/webhooks', bodyTarget)).webhook as IDataObject; + target = (await zendeskApiRequest.call(this, 'POST', '/webhooks', bodyTarget)) + .webhook as IDataObject; } // @ts-ignore @@ -424,7 +414,7 @@ export class ZendeskTrigger implements INodeType { try { await zendeskApiRequest.call(this, 'DELETE', `/triggers/${webhookData.webhookId}`); await zendeskApiRequest.call(this, 'DELETE', `/webhooks/${webhookData.targetId}`); - } catch(error) { + } catch (error) { return false; } delete webhookData.triggerId; @@ -437,9 +427,7 @@ export class ZendeskTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts index cd691a6d3c..367bd35993 100644 --- a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts @@ -1,23 +1,10 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - IDataObject, - ILoadOptionsFunctions, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, ILoadOptionsFunctions, NodeApiError, NodeOperationError } from 'n8n-workflow'; -import { - flow, - sortBy, -} from 'lodash'; +import { flow, sortBy } from 'lodash'; import { AllFields, @@ -43,13 +30,13 @@ export async function zohoApiRequest( qs: IDataObject = {}, uri?: string, ) { - const { oauthTokenData } = await this.getCredentials('zohoOAuth2Api') as ZohoOAuth2ApiCredentials; + const { oauthTokenData } = (await this.getCredentials( + 'zohoOAuth2Api', + )) as ZohoOAuth2ApiCredentials; const options: OptionsWithUri = { body: { - data: [ - body, - ], + data: [body], }, method, qs, @@ -99,10 +86,7 @@ export async function zohoApiRequestAllItems( if (Array.isArray(responseData) && !responseData.length) return returnData; returnData.push(...responseData.data); qs.page++; - } while ( - responseData.info.more_records !== undefined && - responseData.info.more_records === true - ); + } while (responseData.info.more_records !== undefined && responseData.info.more_records === true); return returnData; } @@ -140,7 +124,7 @@ export function throwOnMissingProducts( this: IExecuteFunctions, resource: CamelCaseResource, productDetails: ProductDetails, - ) { +) { if (!productDetails.length) { throw new NodeOperationError( this.getNode(), @@ -151,7 +135,7 @@ export function throwOnMissingProducts( export function throwOnErrorStatus( this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, - responseData: { data?: Array<{ status: string, message: string }> }, + responseData: { data?: Array<{ status: string; message: string }> }, ) { if (responseData?.data?.[0].status === 'error') { throw new NodeOperationError(this.getNode(), responseData as Error); @@ -166,7 +150,7 @@ export function throwOnErrorStatus( * Place a product ID at a nested position in a product details field. */ export const adjustProductDetails = (productDetails: ProductDetails) => { - return productDetails.map(p => { + return productDetails.map((p) => { return { ...omit('product', p), product: { id: p.id }, @@ -187,7 +171,7 @@ export const adjustProductDetails = (productDetails: ProductDetails) => { export const adjustProductDetailsOnUpdate = (allFields: AllFields) => { if (!allFields.Product_Details) return allFields; - return allFields.Product_Details.map(p => { + return allFields.Product_Details.map((p) => { return { ...omit('product', p), product: { id: p.id }, @@ -219,7 +203,7 @@ const adjustOtherAddressFields = adjustLocationFields('Other_Address'); /** * Remove from a date field the timestamp set by the datepicker. */ - const adjustDateField = (dateType: DateType) => (allFields: AllFields) => { +const adjustDateField = (dateType: DateType) => (allFields: AllFields) => { const dateField = allFields[dateType]; if (!dateField) return allFields; @@ -282,10 +266,7 @@ export const adjustContactPayload = flow( adjustCustomFields, ); -export const adjustDealPayload = flow( - adjustClosingDateField, - adjustCustomFields, -); +export const adjustDealPayload = flow(adjustClosingDateField, adjustCustomFields); export const adjustInvoicePayload = flow( adjustBillingAddressFields, @@ -301,10 +282,7 @@ export const adjustInvoicePayloadOnUpdate = flow( adjustProductDetailsOnUpdate, ); -export const adjustLeadPayload = flow( - adjustAddressFields, - adjustCustomFields, -); +export const adjustLeadPayload = flow(adjustAddressFields, adjustCustomFields); export const adjustPurchaseOrderPayload = flow( adjustBillingAddressFields, @@ -331,10 +309,7 @@ export const adjustSalesOrderPayload = flow( adjustCustomFields, ); -export const adjustVendorPayload = flow( - adjustAddressFields, - adjustCustomFields, -); +export const adjustVendorPayload = flow(adjustAddressFields, adjustCustomFields); export const adjustProductPayload = adjustCustomFields; @@ -345,7 +320,8 @@ export const adjustProductPayload = adjustCustomFields; /** * Create a copy of an object without a specific property. */ -const omit = (propertyToOmit: string, { [propertyToOmit]: _, ...remainingObject }) => remainingObject; +const omit = (propertyToOmit: string, { [propertyToOmit]: _, ...remainingObject }) => + remainingObject; /** * Convert items in a Zoho CRM API response into n8n load options. @@ -363,15 +339,24 @@ export async function getFields( ) { const qs = { module: getModuleName(resource) }; - let { fields } = await zohoApiRequest.call(this, 'GET', '/settings/fields', {}, qs) as LoadedFields; + let { fields } = (await zohoApiRequest.call( + this, + 'GET', + '/settings/fields', + {}, + qs, + )) as LoadedFields; if (onlyCustom) { fields = fields.filter(({ custom_field }) => custom_field); } - const options = fields.map(({ field_label, api_name }) => ({ name: field_label, value: api_name })); + const options = fields.map(({ field_label, api_name }) => ({ + name: field_label, + value: api_name, + })); - return sortBy(options, o => o.name); + return sortBy(options, (o) => o.name); } export function getModuleName(resource: string) { @@ -397,21 +382,26 @@ export async function getPicklistOptions( targetField: string, ) { const qs = { module: getModuleName(resource) }; - const responseData = await zohoApiRequest.call(this, 'GET', '/settings/layouts', {}, qs) as LoadedLayouts; + const responseData = (await zohoApiRequest.call( + this, + 'GET', + '/settings/layouts', + {}, + qs, + )) as LoadedLayouts; - const pickListOptions = responseData.layouts[0] - .sections.find(section => section.api_name === getSectionApiName(resource)) - ?.fields.find(f => f.api_name === targetField) - ?.pick_list_values; + const pickListOptions = responseData.layouts[0].sections + .find((section) => section.api_name === getSectionApiName(resource)) + ?.fields.find((f) => f.api_name === targetField)?.pick_list_values; if (!pickListOptions) return []; - return pickListOptions.map( - (option) => ({ name: option.display_value, value: option.actual_value }), - ); + return pickListOptions.map((option) => ({ + name: option.display_value, + value: option.actual_value, + })); } - function getSectionApiName(resource: string) { if (resource === 'purchaseOrder') return 'Purchase Order Information'; if (resource === 'salesOrder') return 'Sales Order Information'; diff --git a/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts b/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts index a69c693a46..5144e2ce22 100644 --- a/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts +++ b/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -169,27 +167,43 @@ export class ZohoCrm implements INodeType { // ---------------------------------------- async getAccounts(this: ILoadOptionsFunctions) { - const accounts = await zohoApiRequestAllItems.call(this, 'GET', '/accounts') as LoadedAccounts; + const accounts = (await zohoApiRequestAllItems.call( + this, + 'GET', + '/accounts', + )) as LoadedAccounts; return toLoadOptions(accounts, 'Account_Name'); }, async getContacts(this: ILoadOptionsFunctions) { - const contacts = await zohoApiRequestAllItems.call(this, 'GET', '/contacts') as LoadedContacts; + const contacts = (await zohoApiRequestAllItems.call( + this, + 'GET', + '/contacts', + )) as LoadedContacts; return toLoadOptions(contacts, 'Full_Name'); }, async getDeals(this: ILoadOptionsFunctions) { - const deals = await zohoApiRequestAllItems.call(this, 'GET', '/deals') as LoadedDeals; + const deals = (await zohoApiRequestAllItems.call(this, 'GET', '/deals')) as LoadedDeals; return toLoadOptions(deals, 'Deal_Name'); }, async getProducts(this: ILoadOptionsFunctions) { - const products = await zohoApiRequestAllItems.call(this, 'GET', '/products') as LoadedProducts; + const products = (await zohoApiRequestAllItems.call( + this, + 'GET', + '/products', + )) as LoadedProducts; return toLoadOptions(products, 'Product_Name'); }, async getVendors(this: ILoadOptionsFunctions) { - const vendors = await zohoApiRequestAllItems.call(this, 'GET', '/vendors') as LoadedVendors; + const vendors = (await zohoApiRequestAllItems.call( + this, + 'GET', + '/vendors', + )) as LoadedVendors; return toLoadOptions(vendors, 'Vendor_Name'); }, @@ -326,7 +340,6 @@ export class ZohoCrm implements INodeType { let responseData; for (let i = 0; i < items.length; i++) { - // https://www.zoho.com/crm/developer/docs/api/insert-records.html // https://www.zoho.com/crm/developer/docs/api/get-records.html // https://www.zoho.com/crm/developer/docs/api/update-specific-record.html @@ -334,9 +347,7 @@ export class ZohoCrm implements INodeType { // https://www.zoho.com/crm/developer/docs/api/v2/upsert-records.html try { - if (resource === 'account') { - // ********************************************************************** // account // ********************************************************************** @@ -345,7 +356,6 @@ export class ZohoCrm implements INodeType { // https://help.zoho.com/portal/en/kb/crm/customize-crm-account/customizing-fields/articles/standard-modules-fields#Accounts if (operation === 'create') { - // ---------------------------------------- // account: create // ---------------------------------------- @@ -362,9 +372,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/accounts', body); responseData = responseData.data[0].details; - } else if (operation === 'delete') { - // ---------------------------------------- // account: delete // ---------------------------------------- @@ -374,9 +382,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/accounts/${accountId}`; responseData = await zohoApiRequest.call(this, 'DELETE', endpoint); responseData = responseData.data[0].details; - } else if (operation === 'get') { - // ---------------------------------------- // account: get // ---------------------------------------- @@ -386,9 +392,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/accounts/${accountId}`; responseData = await zohoApiRequest.call(this, 'GET', endpoint); responseData = responseData.data; - } else if (operation === 'getAll') { - // ---------------------------------------- // account: getAll // ---------------------------------------- @@ -399,9 +403,7 @@ export class ZohoCrm implements INodeType { addGetAllFilterOptions(qs, options); responseData = await handleListing.call(this, 'GET', '/accounts', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // account: update // ---------------------------------------- @@ -420,9 +422,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/accounts/${accountId}`; responseData = await zohoApiRequest.call(this, 'PUT', endpoint, body); responseData = responseData.data[0].details; - } else if (operation === 'upsert') { - // ---------------------------------------- // account: upsert // ---------------------------------------- @@ -439,11 +439,8 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/accounts/upsert', body); responseData = responseData.data[0].details; - } - } else if (resource === 'contact') { - // ********************************************************************** // contact // ********************************************************************** @@ -452,7 +449,6 @@ export class ZohoCrm implements INodeType { // https://help.zoho.com/portal/en/kb/crm/customize-crm-account/customizing-fields/articles/standard-modules-fields#Contacts if (operation === 'create') { - // ---------------------------------------- // contact: create // ---------------------------------------- @@ -469,9 +465,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/contacts', body); responseData = responseData.data[0].details; - } else if (operation === 'delete') { - // ---------------------------------------- // contact: delete // ---------------------------------------- @@ -481,9 +475,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/contacts/${contactId}`; responseData = await zohoApiRequest.call(this, 'DELETE', endpoint); responseData = responseData.data[0].details; - } else if (operation === 'get') { - // ---------------------------------------- // contact: get // ---------------------------------------- @@ -493,9 +485,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/contacts/${contactId}`; responseData = await zohoApiRequest.call(this, 'GET', endpoint); responseData = responseData.data; - } else if (operation === 'getAll') { - // ---------------------------------------- // contact: getAll // ---------------------------------------- @@ -506,9 +496,7 @@ export class ZohoCrm implements INodeType { addGetAllFilterOptions(qs, options); responseData = await handleListing.call(this, 'GET', '/contacts', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // contact: update // ---------------------------------------- @@ -527,9 +515,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/contacts/${contactId}`; responseData = await zohoApiRequest.call(this, 'PUT', endpoint, body); responseData = responseData.data[0].details; - } else if (operation === 'upsert') { - // ---------------------------------------- // contact: upsert // ---------------------------------------- @@ -546,11 +532,8 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/contacts/upsert', body); responseData = responseData.data[0].details; - } - } else if (resource === 'deal') { - // ********************************************************************** // deal // ********************************************************************** @@ -559,7 +542,6 @@ export class ZohoCrm implements INodeType { // https://help.zoho.com/portal/en/kb/crm/customize-crm-account/customizing-fields/articles/standard-modules-fields#Deals if (operation === 'create') { - // ---------------------------------------- // deal: create // ---------------------------------------- @@ -577,9 +559,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/deals', body); responseData = responseData.data[0].details; - } else if (operation === 'delete') { - // ---------------------------------------- // deal: delete // ---------------------------------------- @@ -588,9 +568,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'DELETE', `/deals/${dealId}`); responseData = responseData.data[0].details; - } else if (operation === 'get') { - // ---------------------------------------- // deal: get // ---------------------------------------- @@ -599,9 +577,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'GET', `/deals/${dealId}`); responseData = responseData.data; - } else if (operation === 'getAll') { - // ---------------------------------------- // deal: getAll // ---------------------------------------- @@ -612,9 +588,7 @@ export class ZohoCrm implements INodeType { addGetAllFilterOptions(qs, options); responseData = await handleListing.call(this, 'GET', '/deals', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // deal: update // ---------------------------------------- @@ -632,9 +606,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'PUT', `/deals/${dealId}`, body); responseData = responseData.data[0].details; - } else if (operation === 'upsert') { - // ---------------------------------------- // deal: upsert // ---------------------------------------- @@ -652,11 +624,8 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/deals/upsert', body); responseData = responseData.data[0].details; - } - } else if (resource === 'invoice') { - // ********************************************************************** // invoice // ********************************************************************** @@ -665,7 +634,6 @@ export class ZohoCrm implements INodeType { // https://help.zoho.com/portal/en/kb/crm/customize-crm-account/customizing-fields/articles/standard-modules-fields#Invoices if (operation === 'create') { - // ---------------------------------------- // invoice: create // ---------------------------------------- @@ -687,9 +655,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/invoices', body); responseData = responseData.data[0].details; - } else if (operation === 'delete') { - // ---------------------------------------- // invoice: delete // ---------------------------------------- @@ -699,9 +665,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/invoices/${invoiceId}`; responseData = await zohoApiRequest.call(this, 'DELETE', endpoint); responseData = responseData.data[0].details; - } else if (operation === 'get') { - // ---------------------------------------- // invoice: get // ---------------------------------------- @@ -711,9 +675,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/invoices/${invoiceId}`; responseData = await zohoApiRequest.call(this, 'GET', endpoint); responseData = responseData.data; - } else if (operation === 'getAll') { - // ---------------------------------------- // invoice: getAll // ---------------------------------------- @@ -724,9 +686,7 @@ export class ZohoCrm implements INodeType { addGetAllFilterOptions(qs, options); responseData = await handleListing.call(this, 'GET', '/invoices', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // invoice: update // ---------------------------------------- @@ -746,9 +706,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'PUT', endpoint, body); responseData = responseData.data[0].details; - } else if (operation === 'upsert') { - // ---------------------------------------- // invoice: upsert // ---------------------------------------- @@ -768,11 +726,8 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/invoices/upsert', body); responseData = responseData.data[0].details; - } - } else if (resource === 'lead') { - // ********************************************************************** // lead // ********************************************************************** @@ -781,7 +736,6 @@ export class ZohoCrm implements INodeType { // https://help.zoho.com/portal/en/kb/crm/customize-crm-account/customizing-fields/articles/standard-modules-fields#Leads if (operation === 'create') { - // ---------------------------------------- // lead: create // ---------------------------------------- @@ -799,9 +753,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/leads', body); responseData = responseData.data[0].details; - } else if (operation === 'delete') { - // ---------------------------------------- // lead: delete // ---------------------------------------- @@ -810,9 +762,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'DELETE', `/leads/${leadId}`); responseData = responseData.data[0].details; - } else if (operation === 'get') { - // ---------------------------------------- // lead: get // ---------------------------------------- @@ -820,9 +770,7 @@ export class ZohoCrm implements INodeType { const leadId = this.getNodeParameter('leadId', i); responseData = await zohoApiRequest.call(this, 'GET', `/leads/${leadId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // lead: getAll // ---------------------------------------- @@ -833,18 +781,20 @@ export class ZohoCrm implements INodeType { addGetAllFilterOptions(qs, options); responseData = await handleListing.call(this, 'GET', '/leads', {}, qs); - } else if (operation === 'getFields') { - // ---------------------------------------- // lead: getFields // ---------------------------------------- - responseData = await zohoApiRequest.call(this, 'GET', '/settings/fields', {}, { module: 'leads' }); + responseData = await zohoApiRequest.call( + this, + 'GET', + '/settings/fields', + {}, + { module: 'leads' }, + ); responseData = responseData.fields; - } else if (operation === 'update') { - // ---------------------------------------- // lead: update // ---------------------------------------- @@ -862,9 +812,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'PUT', `/leads/${leadId}`, body); responseData = responseData.data[0].details; - } else if (operation === 'upsert') { - // ---------------------------------------- // lead: upsert // ---------------------------------------- @@ -882,11 +830,8 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/leads/upsert', body); responseData = responseData.data[0].details; - } - } else if (resource === 'product') { - // ********************************************************************** // product // ********************************************************************** @@ -895,7 +840,6 @@ export class ZohoCrm implements INodeType { // https://help.zoho.com/portal/en/kb/crm/customize-crm-account/customizing-fields/articles/standard-modules-fields#Products if (operation === 'create') { - // ---------------------------------------- // product: create // ---------------------------------------- @@ -912,9 +856,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/products', body); responseData = responseData.data[0].details; - } else if (operation === 'delete') { - // ---------------------------------------- // product: delete // ---------------------------------------- @@ -924,9 +866,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/products/${productId}`; responseData = await zohoApiRequest.call(this, 'DELETE', endpoint); responseData = responseData.data[0].details; - } else if (operation === 'get') { - // ---------------------------------------- // product: get // ---------------------------------------- @@ -936,9 +876,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/products/${productId}`; responseData = await zohoApiRequest.call(this, 'GET', endpoint); responseData = responseData.data; - } else if (operation === 'getAll') { - // ---------------------------------------- // product: getAll // ---------------------------------------- @@ -949,9 +887,7 @@ export class ZohoCrm implements INodeType { addGetAllFilterOptions(qs, options); responseData = await handleListing.call(this, 'GET', '/products', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // product: update // ---------------------------------------- @@ -970,9 +906,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/products/${productId}`; responseData = await zohoApiRequest.call(this, 'PUT', endpoint, body); responseData = responseData.data[0].details; - } else if (operation === 'upsert') { - // ---------------------------------------- // product: upsert // ---------------------------------------- @@ -989,11 +923,8 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/products/upsert', body); responseData = responseData.data[0].details; - } - } else if (resource === 'purchaseOrder') { - // ********************************************************************** // purchaseOrder // ********************************************************************** @@ -1002,7 +933,6 @@ export class ZohoCrm implements INodeType { // https://help.zoho.com/portal/en/kb/crm/customize-crm-account/customizing-fields/articles/standard-modules-fields#Purchase_Order if (operation === 'create') { - // ---------------------------------------- // purchaseOrder: create // ---------------------------------------- @@ -1025,9 +955,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/purchase_orders', body); responseData = responseData.data[0].details; - } else if (operation === 'delete') { - // ---------------------------------------- // purchaseOrder: delete // ---------------------------------------- @@ -1037,9 +965,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/purchase_orders/${purchaseOrderId}`; responseData = await zohoApiRequest.call(this, 'DELETE', endpoint); responseData = responseData.data[0].details; - } else if (operation === 'get') { - // ---------------------------------------- // purchaseOrder: get // ---------------------------------------- @@ -1049,9 +975,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/purchase_orders/${purchaseOrderId}`; responseData = await zohoApiRequest.call(this, 'GET', endpoint); responseData = responseData.data; - } else if (operation === 'getAll') { - // ---------------------------------------- // purchaseOrder: getAll // ---------------------------------------- @@ -1062,9 +986,7 @@ export class ZohoCrm implements INodeType { addGetAllFilterOptions(qs, options); responseData = await handleListing.call(this, 'GET', '/purchase_orders', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // purchaseOrder: update // ---------------------------------------- @@ -1083,9 +1005,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/purchase_orders/${purchaseOrderId}`; responseData = await zohoApiRequest.call(this, 'PUT', endpoint, body); responseData = responseData.data[0].details; - } else if (operation === 'upsert') { - // ---------------------------------------- // purchaseOrder: upsert // ---------------------------------------- @@ -1106,11 +1026,8 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/purchase_orders/upsert', body); responseData = responseData.data[0].details; - } - } else if (resource === 'quote') { - // ********************************************************************** // quote // ********************************************************************** @@ -1119,7 +1036,6 @@ export class ZohoCrm implements INodeType { // https://help.zoho.com/portal/en/kb/crm/customize-crm-account/customizing-fields/articles/standard-modules-fields#Quotes if (operation === 'create') { - // ---------------------------------------- // quote: create // ---------------------------------------- @@ -1141,9 +1057,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/quotes', body); responseData = responseData.data[0].details; - } else if (operation === 'delete') { - // ---------------------------------------- // quote: delete // ---------------------------------------- @@ -1152,9 +1066,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'DELETE', `/quotes/${quoteId}`); responseData = responseData.data[0].details; - } else if (operation === 'get') { - // ---------------------------------------- // quote: get // ---------------------------------------- @@ -1163,9 +1075,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'GET', `/quotes/${quoteId}`); responseData = responseData.data; - } else if (operation === 'getAll') { - // ---------------------------------------- // quote: getAll // ---------------------------------------- @@ -1176,9 +1086,7 @@ export class ZohoCrm implements INodeType { addGetAllFilterOptions(qs, options); responseData = await handleListing.call(this, 'GET', '/quotes', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // quote: update // ---------------------------------------- @@ -1196,9 +1104,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'PUT', `/quotes/${quoteId}`, body); responseData = responseData.data[0].details; - } else if (operation === 'upsert') { - // ---------------------------------------- // quote: upsert // ---------------------------------------- @@ -1218,11 +1124,8 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/quotes/upsert', body); responseData = responseData.data[0].details; - } - } else if (resource === 'salesOrder') { - // ********************************************************************** // salesOrder // ********************************************************************** @@ -1231,7 +1134,6 @@ export class ZohoCrm implements INodeType { // https://help.zoho.com/portal/en/kb/crm/customize-crm-account/customizing-fields/articles/standard-modules-fields#Sales_Orders if (operation === 'create') { - // ---------------------------------------- // salesOrder: create // ---------------------------------------- @@ -1252,9 +1154,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/sales_orders', body); responseData = responseData.data[0].details; - } else if (operation === 'delete') { - // ---------------------------------------- // salesOrder: delete // ---------------------------------------- @@ -1264,9 +1164,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/sales_orders/${salesOrderId}`; responseData = await zohoApiRequest.call(this, 'DELETE', endpoint); responseData = responseData.data[0].details; - } else if (operation === 'get') { - // ---------------------------------------- // salesOrder: get // ---------------------------------------- @@ -1276,9 +1174,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/sales_orders/${salesOrderId}`; responseData = await zohoApiRequest.call(this, 'GET', endpoint); responseData = responseData.data; - } else if (operation === 'getAll') { - // ---------------------------------------- // salesOrder: getAll // ---------------------------------------- @@ -1289,9 +1185,7 @@ export class ZohoCrm implements INodeType { addGetAllFilterOptions(qs, options); responseData = await handleListing.call(this, 'GET', '/sales_orders', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // salesOrder: update // ---------------------------------------- @@ -1310,9 +1204,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/sales_orders/${salesOrderId}`; responseData = await zohoApiRequest.call(this, 'PUT', endpoint, body); responseData = responseData.data[0].details; - } else if (operation === 'upsert') { - // ---------------------------------------- // salesOrder: upsert // ---------------------------------------- @@ -1333,11 +1225,8 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/sales_orders/upsert', body); responseData = responseData.data[0].details; - } - } else if (resource === 'vendor') { - // ********************************************************************** // vendor // ********************************************************************** @@ -1346,7 +1235,6 @@ export class ZohoCrm implements INodeType { // https://help.zoho.com/portal/en/kb/crm/customize-crm-account/customizing-fields/articles/standard-modules-fields#Vendors if (operation === 'create') { - // ---------------------------------------- // vendor: create // ---------------------------------------- @@ -1363,9 +1251,7 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/vendors', body); responseData = responseData.data[0].details; - } else if (operation === 'delete') { - // ---------------------------------------- // vendor: delete // ---------------------------------------- @@ -1375,9 +1261,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/vendors/${vendorId}`; responseData = await zohoApiRequest.call(this, 'DELETE', endpoint); responseData = responseData.data[0].details; - } else if (operation === 'get') { - // ---------------------------------------- // vendor: get // ---------------------------------------- @@ -1387,9 +1271,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/vendors/${vendorId}`; responseData = await zohoApiRequest.call(this, 'GET', endpoint); responseData = responseData.data; - } else if (operation === 'getAll') { - // ---------------------------------------- // vendor: getAll // ---------------------------------------- @@ -1400,9 +1282,7 @@ export class ZohoCrm implements INodeType { addGetAllFilterOptions(qs, options); responseData = await handleListing.call(this, 'GET', '/vendors', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // vendor: update // ---------------------------------------- @@ -1421,9 +1301,7 @@ export class ZohoCrm implements INodeType { const endpoint = `/vendors/${vendorId}`; responseData = await zohoApiRequest.call(this, 'PUT', endpoint, body); responseData = responseData.data[0].details; - } else if (operation === 'upsert') { - // ---------------------------------------- // vendor: upsert // ---------------------------------------- @@ -1440,11 +1318,8 @@ export class ZohoCrm implements INodeType { responseData = await zohoApiRequest.call(this, 'POST', '/vendors/upsert', body); responseData = responseData.data[0].details; - } - } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/Zoho/descriptions/AccountDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/AccountDescription.ts index 754145931e..fe9fee3e49 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/AccountDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/AccountDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import { billingAddress, @@ -18,9 +16,7 @@ export const accountOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'account', - ], + resource: ['account'], }, }, options: [ @@ -77,12 +73,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'create', - ], + resource: ['account'], + operation: ['create'], }, }, }, @@ -93,18 +85,15 @@ export const accountFields: INodeProperties[] = [ { displayName: 'Account Name', name: 'accountName', - description: 'Name of the account. If a record with this account name exists it will be updated, otherwise a new one will be created.', + description: + 'Name of the account. If a record with this account name exists it will be updated, otherwise a new one will be created.', type: 'string', required: true, default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'upsert', - ], + resource: ['account'], + operation: ['upsert'], }, }, }, @@ -120,13 +109,8 @@ export const accountFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['account'], + operation: ['create', 'upsert'], }, }, options: [ @@ -147,10 +131,11 @@ export const accountFields: INodeProperties[] = [ displayName: 'Account Type Name or ID', name: 'Account_Type', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', - typeOptions: { - loadOptionsMethod: 'getAccountType', - }, + description: + 'Choose from the list, or specify an ID using an expression', + typeOptions: { + loadOptionsMethod: 'getAccountType', + }, default: [], }, { @@ -241,12 +226,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'delete', - ], + resource: ['account'], + operation: ['delete'], }, }, }, @@ -263,12 +244,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'get', - ], + resource: ['account'], + operation: ['get'], }, }, }, @@ -290,12 +267,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'update', - ], + resource: ['account'], + operation: ['update'], }, }, }, @@ -307,12 +280,8 @@ export const accountFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'update', - ], + resource: ['account'], + operation: ['update'], }, }, options: [ @@ -339,10 +308,11 @@ export const accountFields: INodeProperties[] = [ displayName: 'Account Type Name or ID', name: 'Account_Type', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', - typeOptions: { - loadOptionsMethod: 'getAccountType', - }, + description: + 'Choose from the list, or specify an ID using an expression', + typeOptions: { + loadOptionsMethod: 'getAccountType', + }, default: [], }, { diff --git a/packages/nodes-base/nodes/Zoho/descriptions/ContactDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/ContactDescription.ts index a9c6190b7e..79f8402e58 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/ContactDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/ContactDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import { currencies, @@ -18,9 +16,7 @@ export const contactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contact', - ], + resource: ['contact'], }, }, options: [ @@ -77,12 +73,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, }, @@ -94,12 +86,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, options: [ @@ -232,12 +220,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'upsert', - ], + resource: ['contact'], + operation: ['upsert'], }, }, }, @@ -249,12 +233,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'upsert', - ], + resource: ['contact'], + operation: ['upsert'], }, }, options: [ @@ -290,7 +270,8 @@ export const contactFields: INodeProperties[] = [ name: 'Email', type: 'string', default: '', - description: 'Email of the contact. If a record with this email exists it will be updated, otherwise a new one will be created.', + description: + 'Email of the contact. If a record with this email exists it will be updated, otherwise a new one will be created.', }, { displayName: 'Email (Secondary)', @@ -389,12 +370,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'delete', - ], + resource: ['contact'], + operation: ['delete'], }, }, }, @@ -411,12 +388,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], + resource: ['contact'], + operation: ['get'], }, }, }, @@ -438,12 +411,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, }, @@ -455,12 +424,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Zoho/descriptions/DealDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/DealDescription.ts index 184cf05303..f9a38f1157 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/DealDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/DealDescription.ts @@ -1,12 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - currencies, - makeCustomFieldsFixedCollection, - makeGetAllFields, -} from './SharedFields'; +import { currencies, makeCustomFieldsFixedCollection, makeGetAllFields } from './SharedFields'; export const dealOperations: INodeProperties[] = [ { @@ -16,9 +10,7 @@ export const dealOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'deal', - ], + resource: ['deal'], }, }, options: [ @@ -75,12 +67,8 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, }, @@ -91,18 +79,15 @@ export const dealFields: INodeProperties[] = [ { displayName: 'Deal Name', name: 'dealName', - description: 'Name of the deal. If a record with this deal name exists it will be updated, otherwise a new one will be created.', + description: + 'Name of the deal. If a record with this deal name exists it will be updated, otherwise a new one will be created.', type: 'string', required: true, default: '', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'upsert', - ], + resource: ['deal'], + operation: ['upsert'], }, }, }, @@ -113,7 +98,8 @@ export const dealFields: INodeProperties[] = [ displayName: 'Stage Name or ID', name: 'stage', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', required: true, default: [], typeOptions: { @@ -121,13 +107,8 @@ export const dealFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['deal'], + operation: ['create', 'upsert'], }, }, }, @@ -139,13 +120,8 @@ export const dealFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['deal'], + operation: ['create', 'upsert'], }, }, options: [ @@ -231,12 +207,8 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'delete', - ], + resource: ['deal'], + operation: ['delete'], }, }, }, @@ -253,12 +225,8 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'get', - ], + resource: ['deal'], + operation: ['get'], }, }, }, @@ -280,12 +248,8 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], + resource: ['deal'], + operation: ['update'], }, }, }, @@ -297,12 +261,8 @@ export const dealFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], + resource: ['deal'], + operation: ['update'], }, }, options: [ @@ -382,10 +342,11 @@ export const dealFields: INodeProperties[] = [ displayName: 'Stage Name or ID', name: 'Stage', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', - typeOptions: { - loadOptionsMethod: 'getDealStage', - }, + description: + 'Choose from the list, or specify an ID using an expression', + typeOptions: { + loadOptionsMethod: 'getDealStage', + }, default: [], }, ], diff --git a/packages/nodes-base/nodes/Zoho/descriptions/InvoiceDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/InvoiceDescription.ts index 68f48cc143..102da05578 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/InvoiceDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/InvoiceDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import { billingAddress, @@ -19,9 +17,7 @@ export const invoiceOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'invoice', - ], + resource: ['invoice'], }, }, options: [ @@ -79,12 +75,8 @@ export const invoiceFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'create', - ], + resource: ['invoice'], + operation: ['create'], }, }, }, @@ -95,18 +87,15 @@ export const invoiceFields: INodeProperties[] = [ { displayName: 'Subject', name: 'subject', - description: 'Subject or title of the invoice. If a record with this subject exists it will be updated, otherwise a new one will be created.', + description: + 'Subject or title of the invoice. If a record with this subject exists it will be updated, otherwise a new one will be created.', type: 'string', required: true, default: '', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'upsert', - ], + resource: ['invoice'], + operation: ['upsert'], }, }, }, @@ -127,13 +116,8 @@ export const invoiceFields: INodeProperties[] = [ options: productDetailsOptions, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['invoice'], + operation: ['create', 'upsert'], }, }, }, @@ -145,13 +129,8 @@ export const invoiceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['invoice'], + operation: ['create', 'upsert'], }, }, options: [ @@ -163,7 +142,8 @@ export const invoiceFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getAccounts', }, - description: 'ID of the account associated with this invoice. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the account associated with this invoice. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Adjustment', @@ -225,7 +205,8 @@ export const invoiceFields: INodeProperties[] = [ name: 'Sales_Commission', type: 'number', default: '', - description: 'Commission of sales person on deal closure as a percentage. For example, enter 12 for 12%.', + description: + 'Commission of sales person on deal closure as a percentage. For example, enter 12 for 12%.', }, shippingAddress, { @@ -270,12 +251,8 @@ export const invoiceFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'delete', - ], + resource: ['invoice'], + operation: ['delete'], }, }, }, @@ -292,12 +269,8 @@ export const invoiceFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'get', - ], + resource: ['invoice'], + operation: ['get'], }, }, }, @@ -319,12 +292,8 @@ export const invoiceFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'update', - ], + resource: ['invoice'], + operation: ['update'], }, }, }, @@ -336,12 +305,8 @@ export const invoiceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'invoice', - ], - operation: [ - 'update', - ], + resource: ['invoice'], + operation: ['update'], }, }, options: [ @@ -353,7 +318,8 @@ export const invoiceFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getAccounts', }, - description: 'ID of the account associated with this invoice. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the account associated with this invoice. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Adjustment', @@ -427,7 +393,8 @@ export const invoiceFields: INodeProperties[] = [ name: 'Sales_Commission', type: 'number', default: '', - description: 'Commission of sales person on deal closure as a percentage. For example, enter 12 for 12%.', + description: + 'Commission of sales person on deal closure as a percentage. For example, enter 12 for 12%.', }, shippingAddress, { diff --git a/packages/nodes-base/nodes/Zoho/descriptions/LeadDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/LeadDescription.ts index ec83cc0b41..56a6215c7d 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/LeadDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/LeadDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import { address, @@ -17,9 +15,7 @@ export const leadOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'lead', - ], + resource: ['lead'], }, }, options: [ @@ -83,12 +79,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - ], + resource: ['lead'], + operation: ['create'], }, }, }, @@ -100,12 +92,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - ], + resource: ['lead'], + operation: ['create'], }, }, }, @@ -117,12 +105,8 @@ export const leadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - ], + resource: ['lead'], + operation: ['create'], }, }, options: [ @@ -277,12 +261,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'upsert', - ], + resource: ['lead'], + operation: ['upsert'], }, }, }, @@ -294,12 +274,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'upsert', - ], + resource: ['lead'], + operation: ['upsert'], }, }, }, @@ -311,12 +287,8 @@ export const leadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'upsert', - ], + resource: ['lead'], + operation: ['upsert'], }, }, options: [ @@ -355,7 +327,8 @@ export const leadFields: INodeProperties[] = [ name: 'Email', type: 'string', default: '', - description: 'Email of the lead. If a record with this email exists it will be updated, otherwise a new one will be created.', + description: + 'Email of the lead. If a record with this email exists it will be updated, otherwise a new one will be created.', }, { displayName: 'Email Opt Out', @@ -472,12 +445,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'delete', - ], + resource: ['lead'], + operation: ['delete'], }, }, }, @@ -494,12 +463,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'get', - ], + resource: ['lead'], + operation: ['get'], }, }, }, @@ -521,12 +486,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'update', - ], + resource: ['lead'], + operation: ['update'], }, }, }, @@ -538,12 +499,8 @@ export const leadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'update', - ], + resource: ['lead'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Zoho/descriptions/ProductDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/ProductDescription.ts index 2b64d2b85d..cef4f1f8e6 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/ProductDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/ProductDescription.ts @@ -1,11 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - makeCustomFieldsFixedCollection, - makeGetAllFields, -} from './SharedFields'; +import { makeCustomFieldsFixedCollection, makeGetAllFields } from './SharedFields'; export const productOperations: INodeProperties[] = [ { @@ -15,9 +10,7 @@ export const productOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'product', - ], + resource: ['product'], }, }, options: [ @@ -74,12 +67,8 @@ export const productFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'create', - ], + resource: ['product'], + operation: ['create'], }, }, }, @@ -90,18 +79,15 @@ export const productFields: INodeProperties[] = [ { displayName: 'Product Name', name: 'productName', - description: 'Name of the product. If a record with this product name exists it will be updated, otherwise a new one will be created.', + description: + 'Name of the product. If a record with this product name exists it will be updated, otherwise a new one will be created.', type: 'string', required: true, default: '', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'upsert', - ], + resource: ['product'], + operation: ['upsert'], }, }, }, @@ -117,13 +103,8 @@ export const productFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['product'], + operation: ['create', 'upsert'], }, }, options: [ @@ -210,12 +191,8 @@ export const productFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'delete', - ], + resource: ['product'], + operation: ['delete'], }, }, }, @@ -232,12 +209,8 @@ export const productFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'get', - ], + resource: ['product'], + operation: ['get'], }, }, }, @@ -259,12 +232,8 @@ export const productFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'update', - ], + resource: ['product'], + operation: ['update'], }, }, }, @@ -276,12 +245,8 @@ export const productFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'update', - ], + resource: ['product'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Zoho/descriptions/PurchaseOrderDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/PurchaseOrderDescription.ts index d05e15871c..bcaf394d74 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/PurchaseOrderDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/PurchaseOrderDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import { billingAddress, @@ -19,9 +17,7 @@ export const purchaseOrderOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'purchaseOrder', - ], + resource: ['purchaseOrder'], }, }, options: [ @@ -79,12 +75,8 @@ export const purchaseOrderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'purchaseOrder', - ], - operation: [ - 'create', - ], + resource: ['purchaseOrder'], + operation: ['create'], }, }, }, @@ -95,18 +87,15 @@ export const purchaseOrderFields: INodeProperties[] = [ { displayName: 'Subject', name: 'subject', - description: 'Subject or title of the purchase order. If a record with this subject exists it will be updated, otherwise a new one will be created.', + description: + 'Subject or title of the purchase order. If a record with this subject exists it will be updated, otherwise a new one will be created.', type: 'string', required: true, default: '', displayOptions: { show: { - resource: [ - 'purchaseOrder', - ], - operation: [ - 'upsert', - ], + resource: ['purchaseOrder'], + operation: ['upsert'], }, }, }, @@ -122,16 +111,12 @@ export const purchaseOrderFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getVendors', }, - description: 'ID of the vendor associated with the purchase order. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the vendor associated with the purchase order. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'purchaseOrder', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['purchaseOrder'], + operation: ['create', 'upsert'], }, }, }, @@ -148,13 +133,8 @@ export const purchaseOrderFields: INodeProperties[] = [ options: productDetailsOptions, displayOptions: { show: { - resource: [ - 'purchaseOrder', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['purchaseOrder'], + operation: ['create', 'upsert'], }, }, }, @@ -166,13 +146,8 @@ export const purchaseOrderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'purchaseOrder', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['purchaseOrder'], + operation: ['create', 'upsert'], }, }, options: [ @@ -311,7 +286,8 @@ export const purchaseOrderFields: INodeProperties[] = [ typeOptions: { minValue: 0, }, - description: 'Commission of sales person on deal closure as a percentage. For example, enter 12 for 12%.', + description: + 'Commission of sales person on deal closure as a percentage. For example, enter 12 for 12%.', }, shippingAddress, { @@ -322,7 +298,8 @@ export const purchaseOrderFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getPurchaseOrderStatus', }, - description: 'Status of the purchase order. Choose from the list, or specify an ID using an expression.', + description: + 'Status of the purchase order. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Sub Total', @@ -372,12 +349,8 @@ export const purchaseOrderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'purchaseOrder', - ], - operation: [ - 'delete', - ], + resource: ['purchaseOrder'], + operation: ['delete'], }, }, }, @@ -394,12 +367,8 @@ export const purchaseOrderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'purchaseOrder', - ], - operation: [ - 'get', - ], + resource: ['purchaseOrder'], + operation: ['get'], }, }, }, @@ -421,12 +390,8 @@ export const purchaseOrderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'purchaseOrder', - ], - operation: [ - 'update', - ], + resource: ['purchaseOrder'], + operation: ['update'], }, }, }, @@ -438,12 +403,8 @@ export const purchaseOrderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'purchaseOrder', - ], - operation: [ - 'update', - ], + resource: ['purchaseOrder'], + operation: ['update'], }, }, options: [ @@ -538,7 +499,8 @@ export const purchaseOrderFields: INodeProperties[] = [ typeOptions: { minValue: 0, }, - description: 'Commission of sales person on deal closure as a percentage. For example, enter 12 for 12%.', + description: + 'Commission of sales person on deal closure as a percentage. For example, enter 12 for 12%.', }, shippingAddress, { @@ -549,7 +511,8 @@ export const purchaseOrderFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getPurchaseOrderStatus', }, - description: 'Status of the purchase order. Choose from the list, or specify an ID using an expression.', + description: + 'Status of the purchase order. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Sub Total', diff --git a/packages/nodes-base/nodes/Zoho/descriptions/QuoteDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/QuoteDescription.ts index ff86bb3ed8..f003ea56db 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/QuoteDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/QuoteDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import { billingAddress, @@ -19,9 +17,7 @@ export const quoteOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'quote', - ], + resource: ['quote'], }, }, options: [ @@ -79,12 +75,8 @@ export const quoteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'create', - ], + resource: ['quote'], + operation: ['create'], }, }, }, @@ -95,18 +87,15 @@ export const quoteFields: INodeProperties[] = [ { displayName: 'Subject', name: 'subject', - description: 'Subject or title of the quote. If a record with this subject exists it will be updated, otherwise a new one will be created.', + description: + 'Subject or title of the quote. If a record with this subject exists it will be updated, otherwise a new one will be created.', type: 'string', required: true, default: '', displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'upsert', - ], + resource: ['quote'], + operation: ['upsert'], }, }, }, @@ -127,13 +116,8 @@ export const quoteFields: INodeProperties[] = [ options: productDetailsOptions, displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['quote'], + operation: ['create', 'upsert'], }, }, }, @@ -145,13 +129,8 @@ export const quoteFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['quote'], + operation: ['create', 'upsert'], }, }, options: [ @@ -215,7 +194,8 @@ export const quoteFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getQuoteStage', }, - description: 'Stage of the quote. Choose from the list, or specify an ID using an expression.', + description: + 'Stage of the quote. Choose from the list, or specify an ID using an expression.', }, shippingAddress, { @@ -274,12 +254,8 @@ export const quoteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'delete', - ], + resource: ['quote'], + operation: ['delete'], }, }, }, @@ -296,12 +272,8 @@ export const quoteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'get', - ], + resource: ['quote'], + operation: ['get'], }, }, }, @@ -323,12 +295,8 @@ export const quoteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'update', - ], + resource: ['quote'], + operation: ['update'], }, }, }, @@ -340,12 +308,8 @@ export const quoteFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'quote', - ], - operation: [ - 'update', - ], + resource: ['quote'], + operation: ['update'], }, }, options: [ @@ -409,7 +373,8 @@ export const quoteFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getQuoteStage', }, - description: 'Stage of the quote. Choose from the list, or specify an ID using an expression.', + description: + 'Stage of the quote. Choose from the list, or specify an ID using an expression.', }, shippingAddress, { diff --git a/packages/nodes-base/nodes/Zoho/descriptions/SalesOrderDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/SalesOrderDescription.ts index 386d096887..7db91df197 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/SalesOrderDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/SalesOrderDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import { billingAddress, @@ -19,9 +17,7 @@ export const salesOrderOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'salesOrder', - ], + resource: ['salesOrder'], }, }, options: [ @@ -75,20 +71,16 @@ export const salesOrderFields: INodeProperties[] = [ name: 'accountId', required: true, type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: [], typeOptions: { loadOptionsMethod: 'getAccounts', }, displayOptions: { show: { - resource: [ - 'salesOrder', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['salesOrder'], + operation: ['create', 'upsert'], }, }, }, @@ -105,12 +97,8 @@ export const salesOrderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'salesOrder', - ], - operation: [ - 'create', - ], + resource: ['salesOrder'], + operation: ['create'], }, }, }, @@ -121,18 +109,15 @@ export const salesOrderFields: INodeProperties[] = [ { displayName: 'Subject', name: 'subject', - description: 'Subject or title of the sales order. If a record with this subject exists it will be updated, otherwise a new one will be created.', + description: + 'Subject or title of the sales order. If a record with this subject exists it will be updated, otherwise a new one will be created.', type: 'string', required: true, default: '', displayOptions: { show: { - resource: [ - 'salesOrder', - ], - operation: [ - 'upsert', - ], + resource: ['salesOrder'], + operation: ['upsert'], }, }, }, @@ -153,13 +138,8 @@ export const salesOrderFields: INodeProperties[] = [ options: productDetailsOptions, displayOptions: { show: { - resource: [ - 'salesOrder', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['salesOrder'], + operation: ['create', 'upsert'], }, }, }, @@ -171,13 +151,8 @@ export const salesOrderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'salesOrder', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['salesOrder'], + operation: ['create', 'upsert'], }, }, options: [ @@ -203,7 +178,8 @@ export const salesOrderFields: INodeProperties[] = [ displayName: 'Contact Name or ID', name: 'contactId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: [], typeOptions: { loadOptionsMethod: 'getContacts', @@ -222,7 +198,8 @@ export const salesOrderFields: INodeProperties[] = [ displayName: 'Deal Name or ID', name: 'dealId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: [], typeOptions: { loadOptionsMethod: 'getDeals', @@ -285,7 +262,8 @@ export const salesOrderFields: INodeProperties[] = [ typeOptions: { minValue: 0, }, - description: 'Commission of sales person on deal closure as a percentage. For example, enter 12 for 12%.', + description: + 'Commission of sales person on deal closure as a percentage. For example, enter 12 for 12%.', }, shippingAddress, { @@ -296,7 +274,8 @@ export const salesOrderFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getSalesOrderStatus', }, - description: 'Status of the sales order. Choose from the list, or specify an ID using an expression.', + description: + 'Status of the sales order. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Sub Total', @@ -340,12 +319,8 @@ export const salesOrderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'salesOrder', - ], - operation: [ - 'delete', - ], + resource: ['salesOrder'], + operation: ['delete'], }, }, }, @@ -362,12 +337,8 @@ export const salesOrderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'salesOrder', - ], - operation: [ - 'get', - ], + resource: ['salesOrder'], + operation: ['get'], }, }, }, @@ -389,12 +360,8 @@ export const salesOrderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'salesOrder', - ], - operation: [ - 'update', - ], + resource: ['salesOrder'], + operation: ['update'], }, }, }, @@ -406,12 +373,8 @@ export const salesOrderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'salesOrder', - ], - operation: [ - 'update', - ], + resource: ['salesOrder'], + operation: ['update'], }, }, options: [ @@ -423,7 +386,8 @@ export const salesOrderFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getAccounts', }, - description: 'ID of the account associated with this invoice. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the account associated with this invoice. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Adjustment', @@ -447,7 +411,8 @@ export const salesOrderFields: INodeProperties[] = [ displayName: 'Contact Name or ID', name: 'contactId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: [], typeOptions: { loadOptionsMethod: 'getContacts', @@ -466,7 +431,8 @@ export const salesOrderFields: INodeProperties[] = [ displayName: 'Deal Name or ID', name: 'dealId', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: [], typeOptions: { loadOptionsMethod: 'getDeals', @@ -528,7 +494,8 @@ export const salesOrderFields: INodeProperties[] = [ typeOptions: { minValue: 0, }, - description: 'Commission of sales person on deal closure as a percentage. For example, enter 12 for 12%.', + description: + 'Commission of sales person on deal closure as a percentage. For example, enter 12 for 12%.', }, shippingAddress, { @@ -539,7 +506,8 @@ export const salesOrderFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getSalesOrderStatus', }, - description: 'Status of the sales order. Choose from the list, or specify an ID using an expression.', + description: + 'Status of the sales order. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Sub Total', diff --git a/packages/nodes-base/nodes/Zoho/descriptions/SharedFields.ts b/packages/nodes-base/nodes/Zoho/descriptions/SharedFields.ts index 1ca7eef1d5..4adcfd1ca2 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/SharedFields.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/SharedFields.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import { capitalizeInitial } from '../GenericFunctions'; import { CamelCaseResource } from '../types'; @@ -259,7 +257,8 @@ export const productDetailsOptions: INodeProperties[] = [ displayName: 'Product Name or ID', name: 'id', type: 'options', - description: 'Choose from the list, or specify an ID using an expression', + description: + 'Choose from the list, or specify an ID using an expression', default: [], typeOptions: { loadOptionsMethod: 'getProducts', @@ -327,12 +326,8 @@ export const makeGetAllFields = (resource: CamelCaseResource): INodeProperties[] description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - resource, - ], - operation: [ - 'getAll', - ], + resource: [resource], + operation: ['getAll'], }, }, }, @@ -348,15 +343,9 @@ export const makeGetAllFields = (resource: CamelCaseResource): INodeProperties[] }, displayOptions: { show: { - resource: [ - resource, - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: [resource], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -368,12 +357,8 @@ export const makeGetAllFields = (resource: CamelCaseResource): INodeProperties[] default: {}, displayOptions: { show: { - resource: [ - resource, - ], - operation: [ - 'getAll', - ], + resource: [resource], + operation: ['getAll'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Zoho/descriptions/VendorDescription.ts b/packages/nodes-base/nodes/Zoho/descriptions/VendorDescription.ts index 251b72a0d9..4a5297acc7 100644 --- a/packages/nodes-base/nodes/Zoho/descriptions/VendorDescription.ts +++ b/packages/nodes-base/nodes/Zoho/descriptions/VendorDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import { address, @@ -17,9 +15,7 @@ export const vendorOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'vendor', - ], + resource: ['vendor'], }, }, options: [ @@ -76,12 +72,8 @@ export const vendorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'vendor', - ], - operation: [ - 'create', - ], + resource: ['vendor'], + operation: ['create'], }, }, }, @@ -92,18 +84,15 @@ export const vendorFields: INodeProperties[] = [ { displayName: 'Vendor Name', name: 'vendorName', - description: 'Name of the vendor. If a record with this vendor name exists it will be updated, otherwise a new one will be created.', + description: + 'Name of the vendor. If a record with this vendor name exists it will be updated, otherwise a new one will be created.', type: 'string', required: true, default: '', displayOptions: { show: { - resource: [ - 'vendor', - ], - operation: [ - 'upsert', - ], + resource: ['vendor'], + operation: ['upsert'], }, }, }, @@ -119,13 +108,8 @@ export const vendorFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'vendor', - ], - operation: [ - 'create', - 'upsert', - ], + resource: ['vendor'], + operation: ['create', 'upsert'], }, }, options: [ @@ -183,12 +167,8 @@ export const vendorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'vendor', - ], - operation: [ - 'delete', - ], + resource: ['vendor'], + operation: ['delete'], }, }, }, @@ -205,12 +185,8 @@ export const vendorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'vendor', - ], - operation: [ - 'get', - ], + resource: ['vendor'], + operation: ['get'], }, }, }, @@ -232,12 +208,8 @@ export const vendorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'vendor', - ], - operation: [ - 'update', - ], + resource: ['vendor'], + operation: ['update'], }, }, }, @@ -249,12 +221,8 @@ export const vendorFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'vendor', - ], - operation: [ - 'update', - ], + resource: ['vendor'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Zoho/types.d.ts b/packages/nodes-base/nodes/Zoho/types.d.ts index 46da58379c..5715facef9 100644 --- a/packages/nodes-base/nodes/Zoho/types.d.ts +++ b/packages/nodes-base/nodes/Zoho/types.d.ts @@ -1,17 +1,25 @@ -import { IDataObject } from "n8n-workflow"; +import { IDataObject } from 'n8n-workflow'; // ---------------------------------------- // for generic functions // ---------------------------------------- -type Resource = 'account' | 'contact' | 'deal' | 'invoice' | 'lead' | 'product' | 'quote' | 'vendor'; +type Resource = + | 'account' + | 'contact' + | 'deal' + | 'invoice' + | 'lead' + | 'product' + | 'quote' + | 'vendor'; export type CamelCaseResource = Resource | 'purchaseOrder' | 'salesOrder'; export type SnakeCaseResource = Resource | 'purchase_order' | 'sales_order'; export type GetAllFilterOptions = { - fields: string[], + fields: string[]; [otherOptions: string]: unknown; }; @@ -33,20 +41,30 @@ export type IdType = 'accountId' | 'contactId' | 'dealId' | 'purchaseOrderId'; export type NameType = 'Account_Name' | 'Full_Name' | 'Deal_Name' | 'Product_Name' | 'Vendor_Name'; -type LocationType = 'Address' | 'Billing_Address' | 'Mailing_Address' | 'Shipping_Address' | 'Other_Address'; +type LocationType = + | 'Address' + | 'Billing_Address' + | 'Mailing_Address' + | 'Shipping_Address' + | 'Other_Address'; -type DateType = 'Date_of_Birth' | 'Closing_Date' | 'Due_Date' | 'Invoice_Date' | 'PO_Date' | 'Valid_Till'; +type DateType = + | 'Date_of_Birth' + | 'Closing_Date' + | 'Due_Date' + | 'Invoice_Date' + | 'PO_Date' + | 'Valid_Till'; -export type AllFields = - { [Date in DateType]?: string } & - { [Location in LocationType]?: { address_fields: { [key: string]: string } } } & - { Account?: { subfields: { id: string; name: string; } } } & - { [key in 'accountId' | 'contactId' | 'dealId']?: string } & - { customFields?: { customFields: Array<{ fieldId: string; value: string; }> } } & - { Product_Details?: ProductDetails } & - IDataObject; +export type AllFields = { [Date in DateType]?: string } & { + [Location in LocationType]?: { address_fields: { [key: string]: string } }; +} & { Account?: { subfields: { id: string; name: string } } } & { + [key in 'accountId' | 'contactId' | 'dealId']?: string; +} & { customFields?: { customFields: Array<{ fieldId: string; value: string }> } } & { + Product_Details?: ProductDetails; +} & IDataObject; -export type ProductDetails = Array<{ id: string, quantity: number }>; +export type ProductDetails = Array<{ id: string; quantity: number }>; export type ResourceItems = Array<{ [key: string]: string }>; @@ -74,7 +92,7 @@ export type LoadedFields = { field_label: string; api_name: string; custom_field: boolean; - }> + }>; }; export type LoadedVendors = Array<{ @@ -96,8 +114,8 @@ export type LoadedLayouts = { pick_list_values: Array<{ display_value: string; actual_value: string; - }> - }> - }> - }> -} + }>; + }>; + }>; + }>; +}; diff --git a/packages/nodes-base/nodes/Zoom/GenericFunctions.ts b/packages/nodes-base/nodes/Zoom/GenericFunctions.ts index f0599962c3..6fc67aef36 100644 --- a/packages/nodes-base/nodes/Zoom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zoom/GenericFunctions.ts @@ -1,19 +1,19 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; - -export async function zoomApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: object = {}, query: object = {}, headers: {} | undefined = undefined, option: {} = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; +export async function zoomApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + body: object = {}, + query: object = {}, + headers: {} | undefined = undefined, + option: {} = {}, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0, 'accessToken') as string; let options: OptionsWithUri = { @@ -36,7 +36,7 @@ export async function zoomApiRequest(this: IExecuteFunctions | IExecuteSingleFun try { if (authenticationMethod === 'accessToken') { - return await this.helpers.requestWithAuthentication.call(this,'zoomApi',options); + return await this.helpers.requestWithAuthentication.call(this, 'zoomApi', options); } else { //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'zoomOAuth2Api', options); @@ -46,7 +46,6 @@ export async function zoomApiRequest(this: IExecuteFunctions | IExecuteSingleFun } } - export async function zoomApiRequestAllItems( this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, @@ -54,26 +53,19 @@ export async function zoomApiRequestAllItems( endpoint: string, body: IDataObject = {}, query: IDataObject = {}, -): Promise { // tslint:disable-line:no-any + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; query.page_number = 0; do { - responseData = await zoomApiRequest.call( - this, - method, - endpoint, - body, - query, - ); + responseData = await zoomApiRequest.call(this, method, endpoint, body, query); query.page_number++; returnData.push.apply(returnData, responseData[propertyName]); // zoom free plan rate limit is 1 request/second // TODO just wait when the plan is free await wait(); - } while ( - responseData.page_count !== responseData.page_number - ); + } while (responseData.page_count !== responseData.page_number); return returnData; } diff --git a/packages/nodes-base/nodes/Zoom/MeetingDescription.ts b/packages/nodes-base/nodes/Zoom/MeetingDescription.ts index 83287870a9..9e8bd8faad 100644 --- a/packages/nodes-base/nodes/Zoom/MeetingDescription.ts +++ b/packages/nodes-base/nodes/Zoom/MeetingDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const meetingOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const meetingOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'meeting', - ], + resource: ['meeting'], }, }, options: [ @@ -65,13 +61,8 @@ export const meetingFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - - ], - resource: [ - 'meeting', - ], + operation: ['create'], + resource: ['meeting'], }, }, description: 'Topic of the meeting', @@ -84,13 +75,8 @@ export const meetingFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - - ], - resource: [ - 'meeting', - ], + operation: ['create'], + resource: ['meeting'], }, }, options: [ @@ -152,7 +138,6 @@ export const meetingFields: INodeProperties[] = [ name: 'VOIP', value: 'voip', }, - ], default: 'both', description: 'Determine how participants can join audio portion of the meeting', @@ -262,7 +247,8 @@ export const meetingFields: INodeProperties[] = [ name: 'startTime', type: 'dateTime', default: '', - description: 'Start time should be used only for scheduled or recurring meetings with fixed time', + description: + 'Start time should be used only for scheduled or recurring meetings with fixed time', }, { displayName: 'Timezone Name or ID', @@ -272,7 +258,8 @@ export const meetingFields: INodeProperties[] = [ loadOptionsMethod: 'getTimezones', }, default: '', - description: 'Time zone used in the response. The default is the time zone of the calendar. Choose from the list, or specify an ID using an expression.', + description: + 'Time zone used in the response. The default is the time zone of the calendar. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Type', @@ -295,7 +282,6 @@ export const meetingFields: INodeProperties[] = [ name: 'Recurring Meeting with Fixed Time', value: 8, }, - ], default: 2, description: 'Meeting type', @@ -313,12 +299,8 @@ export const meetingFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'meeting', - ], + operation: ['get'], + resource: ['meeting'], }, }, description: 'Meeting ID', @@ -331,13 +313,8 @@ export const meetingFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - - ], - resource: [ - 'meeting', - ], + operation: ['get'], + resource: ['meeting'], }, }, options: [ @@ -353,7 +330,8 @@ export const meetingFields: INodeProperties[] = [ name: 'showPreviousOccurrences', type: 'boolean', default: false, - description: 'Whether to view meeting details of all previous occurrences of the recurring meeting', + description: + 'Whether to view meeting details of all previous occurrences of the recurring meeting', }, ], }, @@ -366,12 +344,8 @@ export const meetingFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'meeting', - ], + operation: ['getAll'], + resource: ['meeting'], }, }, default: false, @@ -383,15 +357,9 @@ export const meetingFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'meeting', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['meeting'], + returnAll: [false], }, }, typeOptions: { @@ -409,13 +377,8 @@ export const meetingFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - - ], - resource: [ - 'meeting', - ], + operation: ['getAll'], + resource: ['meeting'], }, }, options: [ @@ -427,7 +390,8 @@ export const meetingFields: INodeProperties[] = [ { name: 'Scheduled', value: 'scheduled', - description: 'This includes all valid past meetings, live meetings and upcoming scheduled meetings', + description: + 'This includes all valid past meetings, live meetings and upcoming scheduled meetings', }, { name: 'Live', @@ -456,12 +420,8 @@ export const meetingFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'meeting', - ], + operation: ['delete'], + resource: ['meeting'], }, }, description: 'Meeting ID', @@ -474,12 +434,8 @@ export const meetingFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'meeting', - ], + operation: ['delete'], + resource: ['meeting'], }, }, options: [ @@ -495,10 +451,10 @@ export const meetingFields: INodeProperties[] = [ name: 'scheduleForReminder', type: 'boolean', default: false, - description: 'Whether to notify hosts and alternative hosts about meeting cancellation via email', + description: + 'Whether to notify hosts and alternative hosts about meeting cancellation via email', }, ], - }, /* -------------------------------------------------------------------------- */ /* meeting:update */ @@ -511,12 +467,8 @@ export const meetingFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'meeting', - ], + operation: ['update'], + resource: ['meeting'], }, }, description: 'Meeting ID', @@ -529,12 +481,8 @@ export const meetingFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'meeting', - ], + operation: ['update'], + resource: ['meeting'], }, }, options: [ @@ -596,7 +544,6 @@ export const meetingFields: INodeProperties[] = [ name: 'VOIP', value: 'voip', }, - ], default: 'both', description: 'Determine how participants can join audio portion of the meeting', @@ -703,7 +650,8 @@ export const meetingFields: INodeProperties[] = [ name: 'startTime', type: 'dateTime', default: '', - description: 'Start time should be used only for scheduled or recurring meetings with fixed time', + description: + 'Start time should be used only for scheduled or recurring meetings with fixed time', }, { displayName: 'Timezone Name or ID', @@ -713,7 +661,8 @@ export const meetingFields: INodeProperties[] = [ loadOptionsMethod: 'getTimezones', }, default: '', - description: 'Time zone used in the response. The default is the time zone of the calendar. Choose from the list, or specify an ID using an expression.', + description: + 'Time zone used in the response. The default is the time zone of the calendar. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Topic', @@ -743,7 +692,6 @@ export const meetingFields: INodeProperties[] = [ name: 'Recurring Meeting with Fixed Time', value: 8, }, - ], default: 2, description: 'Meeting type', diff --git a/packages/nodes-base/nodes/Zoom/MeetingRegistrantDescription.ts b/packages/nodes-base/nodes/Zoom/MeetingRegistrantDescription.ts index 7a92984fe9..d1df1f3c1e 100644 --- a/packages/nodes-base/nodes/Zoom/MeetingRegistrantDescription.ts +++ b/packages/nodes-base/nodes/Zoom/MeetingRegistrantDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const meetingRegistrantOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const meetingRegistrantOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'meetingRegistrant', - ], + resource: ['meetingRegistrant'], }, }, options: [ @@ -34,7 +30,6 @@ export const meetingRegistrantOperations: INodeProperties[] = [ description: 'Retrieve all Meeting Registrants', action: 'Get all meeting registrants', }, - ], default: 'create', }, @@ -52,12 +47,8 @@ export const meetingRegistrantFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'meetingRegistrant', - ], + operation: ['create'], + resource: ['meetingRegistrant'], }, }, }, @@ -70,12 +61,8 @@ export const meetingRegistrantFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'meetingRegistrant', - ], + operation: ['create'], + resource: ['meetingRegistrant'], }, }, description: 'Valid Email-ID', @@ -88,12 +75,8 @@ export const meetingRegistrantFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'meetingRegistrant', - ], + operation: ['create'], + resource: ['meetingRegistrant'], }, }, }, @@ -105,13 +88,8 @@ export const meetingRegistrantFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - - ], - resource: [ - 'meetingRegistrant', - ], + operation: ['create'], + resource: ['meetingRegistrant'], }, }, options: [ @@ -228,7 +206,6 @@ export const meetingRegistrantFields: INodeProperties[] = [ name: 'Not Involved', value: 'Not Involved', }, - ], default: '', }, @@ -246,7 +223,6 @@ export const meetingRegistrantFields: INodeProperties[] = [ default: '', description: 'Valid zip-code of registrant', }, - ], }, /* -------------------------------------------------------------------------- */ @@ -260,12 +236,8 @@ export const meetingRegistrantFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'meetingRegistrant', - ], + operation: ['getAll'], + resource: ['meetingRegistrant'], }, }, }, @@ -275,12 +247,8 @@ export const meetingRegistrantFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'meetingRegistrant', - ], + operation: ['getAll'], + resource: ['meetingRegistrant'], }, }, default: false, @@ -292,15 +260,9 @@ export const meetingRegistrantFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'meetingRegistrant', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['meetingRegistrant'], + returnAll: [false], }, }, typeOptions: { @@ -318,13 +280,8 @@ export const meetingRegistrantFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - - ], - resource: [ - 'meetingRegistrant', - ], + operation: ['getAll'], + resource: ['meetingRegistrant'], }, }, options: [ @@ -355,7 +312,6 @@ export const meetingRegistrantFields: INodeProperties[] = [ default: 'approved', description: 'Registrant Status', }, - ], }, /* -------------------------------------------------------------------------- */ @@ -369,12 +325,8 @@ export const meetingRegistrantFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'meetingRegistrant', - ], + operation: ['update'], + resource: ['meetingRegistrant'], }, }, }, @@ -385,12 +337,8 @@ export const meetingRegistrantFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'meetingRegistrant', - ], + operation: ['update'], + resource: ['meetingRegistrant'], }, }, options: [ @@ -421,12 +369,8 @@ export const meetingRegistrantFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'meetingRegistrant', - ], + operation: ['update'], + resource: ['meetingRegistrant'], }, }, options: [ @@ -436,8 +380,6 @@ export const meetingRegistrantFields: INodeProperties[] = [ type: 'string', default: '', }, - ], }, - ]; diff --git a/packages/nodes-base/nodes/Zoom/WebinarDescription.ts b/packages/nodes-base/nodes/Zoom/WebinarDescription.ts index 27233333a0..50c07d2213 100644 --- a/packages/nodes-base/nodes/Zoom/WebinarDescription.ts +++ b/packages/nodes-base/nodes/Zoom/WebinarDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const webinarOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const webinarOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'webinar', - ], + resource: ['webinar'], }, }, options: [ @@ -63,12 +59,8 @@ export const webinarFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'webinar', - ], + operation: ['create'], + resource: ['webinar'], }, }, description: 'User ID or email ID', @@ -81,13 +73,8 @@ export const webinarFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - - ], - resource: [ - 'webinar', - ], + operation: ['create'], + resource: ['webinar'], }, }, options: [ @@ -142,7 +129,6 @@ export const webinarFields: INodeProperties[] = [ name: 'VOIP', value: 'voip', }, - ], default: 'both', description: 'Determine how participants can join audio portion of the webinar', @@ -230,7 +216,8 @@ export const webinarFields: INodeProperties[] = [ name: 'startTime', type: 'dateTime', default: '', - description: 'Start time should be used only for scheduled or recurring webinar with fixed time', + description: + 'Start time should be used only for scheduled or recurring webinar with fixed time', }, { displayName: 'Timezone Name or ID', @@ -240,7 +227,8 @@ export const webinarFields: INodeProperties[] = [ loadOptionsMethod: 'getTimezones', }, default: '', - description: 'Time zone used in the response. The default is the time zone of the calendar. Choose from the list, or specify an ID using an expression.', + description: + 'Time zone used in the response. The default is the time zone of the calendar. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Webinar Topic', @@ -268,7 +256,6 @@ export const webinarFields: INodeProperties[] = [ ], default: 5, }, - ], }, /* -------------------------------------------------------------------------- */ @@ -282,12 +269,8 @@ export const webinarFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'webinar', - ], + operation: ['get'], + resource: ['webinar'], }, }, }, @@ -299,13 +282,8 @@ export const webinarFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - - ], - resource: [ - 'webinar', - ], + operation: ['get'], + resource: ['webinar'], }, }, options: [ @@ -321,7 +299,8 @@ export const webinarFields: INodeProperties[] = [ name: 'showPreviousOccurrences', type: 'boolean', default: false, - description: 'Whether to view webinar details of all previous occurrences of the recurring webinar', + description: + 'Whether to view webinar details of all previous occurrences of the recurring webinar', }, ], }, @@ -336,12 +315,8 @@ export const webinarFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'webinar', - ], + operation: ['getAll'], + resource: ['webinar'], }, }, description: 'User ID or email-ID', @@ -352,12 +327,8 @@ export const webinarFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'webinar', - ], + operation: ['getAll'], + resource: ['webinar'], }, }, default: false, @@ -369,15 +340,9 @@ export const webinarFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'webinar', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['webinar'], + returnAll: [false], }, }, typeOptions: { @@ -398,12 +363,8 @@ export const webinarFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'webinarId', - ], + operation: ['delete'], + resource: ['webinarId'], }, }, }, @@ -415,12 +376,8 @@ export const webinarFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'webinar', - ], + operation: ['delete'], + resource: ['webinar'], }, }, options: [ @@ -431,9 +388,7 @@ export const webinarFields: INodeProperties[] = [ default: '', description: 'Webinar occurrence ID', }, - ], - }, /* -------------------------------------------------------------------------- */ /* webinar:update */ @@ -446,12 +401,8 @@ export const webinarFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'webinar', - ], + operation: ['update'], + resource: ['webinar'], }, }, description: 'User ID or email address of user', @@ -464,13 +415,8 @@ export const webinarFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - - ], - resource: [ - 'webinar', - ], + operation: ['update'], + resource: ['webinar'], }, }, options: [ @@ -545,7 +491,6 @@ export const webinarFields: INodeProperties[] = [ name: 'VOIP', value: 'voip', }, - ], default: 'both', description: 'Determine how participants can join audio portion of the webinar', @@ -617,7 +562,8 @@ export const webinarFields: INodeProperties[] = [ name: 'startTime', type: 'dateTime', default: '', - description: 'Start time should be used only for scheduled or recurring webinar with fixed time', + description: + 'Start time should be used only for scheduled or recurring webinar with fixed time', }, { displayName: 'Timezone Name or ID', @@ -627,7 +573,8 @@ export const webinarFields: INodeProperties[] = [ loadOptionsMethod: 'getTimezones', }, default: '', - description: 'Time zone used in the response. The default is the time zone of the calendar. Choose from the list, or specify an ID using an expression.', + description: + 'Time zone used in the response. The default is the time zone of the calendar. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Webinar Topic', @@ -657,5 +604,4 @@ export const webinarFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Zoom/Zoom.node.ts b/packages/nodes-base/nodes/Zoom/Zoom.node.ts index 46f6adc46b..684092e91a 100644 --- a/packages/nodes-base/nodes/Zoom/Zoom.node.ts +++ b/packages/nodes-base/nodes/Zoom/Zoom.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,15 +9,9 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - zoomApiRequest, - zoomApiRequestAllItems, -} from './GenericFunctions'; +import { zoomApiRequest, zoomApiRequestAllItems } from './GenericFunctions'; -import { - meetingFields, - meetingOperations, -} from './MeetingDescription'; +import { meetingFields, meetingOperations } from './MeetingDescription'; // import { // meetingRegistrantOperations, @@ -74,9 +66,7 @@ export class Zoom implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -87,9 +77,7 @@ export class Zoom implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -144,14 +132,11 @@ export class Zoom implements INodeType { // ...webinarOperations, // ...webinarFields, ], - }; methods = { loadOptions: { // Get all the timezones to display them to user so that he can select them easily - async getTimezones( - this: ILoadOptionsFunctions, - ): Promise { + async getTimezones(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; for (const timezone of moment.tz.names()) { const timezoneName = timezone; @@ -179,14 +164,10 @@ export class Zoom implements INodeType { qs = {}; //https://marketplace.zoom.us/docs/api-reference/zoom-api/ if (resource === 'meeting') { - if (operation === 'get') { //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meeting const meetingId = this.getNodeParameter('meetingId', i) as string; - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (additionalFields.showPreviousOccurrences) { qs.show_previous_occurrences = additionalFields.showPreviousOccurrences as boolean; @@ -196,42 +177,36 @@ export class Zoom implements INodeType { qs.occurrence_id = additionalFields.occurrenceId as string; } - responseData = await zoomApiRequest.call( - this, - 'GET', - `/meetings/${meetingId}`, - {}, - qs, - ); + responseData = await zoomApiRequest.call(this, 'GET', `/meetings/${meetingId}`, {}, qs); } if (operation === 'getAll') { //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetings const returnAll = this.getNodeParameter('returnAll', i) as boolean; - const filters = this.getNodeParameter( - 'filters', - i, - ) as IDataObject; + const filters = this.getNodeParameter('filters', i) as IDataObject; if (filters.type) { qs.type = filters.type as string; } if (returnAll) { - responseData = await zoomApiRequestAllItems.call(this, 'meetings', 'GET', '/users/me/meetings', {}, qs); + responseData = await zoomApiRequestAllItems.call( + this, + 'meetings', + 'GET', + '/users/me/meetings', + {}, + qs, + ); } else { qs.page_size = this.getNodeParameter('limit', i) as number; responseData = await zoomApiRequest.call(this, 'GET', '/users/me/meetings', {}, qs); responseData = responseData.meetings; } - } if (operation === 'delete') { //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingdelete const meetingId = this.getNodeParameter('meetingId', i) as string; - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (additionalFields.scheduleForReminder) { qs.schedule_for_reminder = additionalFields.scheduleForReminder as boolean; } @@ -314,10 +289,14 @@ export class Zoom implements INodeType { if (additionalFields.startTime) { if (additionalFields.timeZone) { - body.start_time = moment(additionalFields.startTime as string).format('YYYY-MM-DDTHH:mm:ss'); + body.start_time = moment(additionalFields.startTime as string).format( + 'YYYY-MM-DDTHH:mm:ss', + ); } else { // if none timezone it's defined used n8n timezone - body.start_time = moment.tz(additionalFields.startTime as string, this.getTimezone()).format(); + body.start_time = moment + .tz(additionalFields.startTime as string, this.getTimezone()) + .format(); } } @@ -341,21 +320,12 @@ export class Zoom implements INodeType { body.agenda = additionalFields.agenda as string; } - responseData = await zoomApiRequest.call( - this, - 'POST', - `/users/me/meetings`, - body, - qs, - ); + responseData = await zoomApiRequest.call(this, 'POST', `/users/me/meetings`, body, qs); } if (operation === 'update') { //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingupdate const meetingId = this.getNodeParameter('meetingId', i) as string; - const updateFields = this.getNodeParameter( - 'updateFields', - i, - ) as IDataObject; + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const body: IDataObject = {}; @@ -451,7 +421,6 @@ export class Zoom implements INodeType { ); responseData = { success: true }; - } } // if (resource === 'meetingRegistrant') { @@ -568,7 +537,6 @@ export class Zoom implements INodeType { // ) as IDataObject; // const settings: Settings = {}; - // if (additionalFields.audio) { // settings.audio = additionalFields.audio as string; @@ -629,7 +597,6 @@ export class Zoom implements INodeType { // } - // if (additionalFields.timeZone) { // body.timezone = additionalFields.timeZone as string; @@ -698,7 +665,6 @@ export class Zoom implements INodeType { // i // ) as IDataObject; - // if (additionalFields.occurrenceId) { // qs.occurrence_id = additionalFields.occurrenceId; @@ -784,7 +750,6 @@ export class Zoom implements INodeType { // } - // if (additionalFields.timeZone) { // body.timezone = additionalFields.timeZone as string; diff --git a/packages/nodes-base/nodes/Zulip/GenericFunctions.ts b/packages/nodes-base/nodes/Zulip/GenericFunctions.ts index 6f5b5640a1..8220ce49db 100644 --- a/packages/nodes-base/nodes/Zulip/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zulip/GenericFunctions.ts @@ -1,9 +1,6 @@ import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject, @@ -13,8 +10,17 @@ import { NodeOperationError, } from 'n8n-workflow'; -export async function zulipApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function zulipApiRequest( + this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('zulipApi'); const endpoint = `${credentials.url}/api/v1`; @@ -47,7 +53,8 @@ export async function zulipApiRequest(this: IExecuteFunctions | IWebhookFunction } } -export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | undefined): any { let result; try { result = JSON.parse(json!); diff --git a/packages/nodes-base/nodes/Zulip/MessageDescription.ts b/packages/nodes-base/nodes/Zulip/MessageDescription.ts index 3fc6293f34..4fcddb2085 100644 --- a/packages/nodes-base/nodes/Zulip/MessageDescription.ts +++ b/packages/nodes-base/nodes/Zulip/MessageDescription.ts @@ -8,9 +8,7 @@ export const messageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'message', - ], + resource: ['message'], }, }, options: [ @@ -55,7 +53,6 @@ export const messageOperations: INodeProperties[] = [ ]; export const messageFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* message:sendPrivate */ /* -------------------------------------------------------------------------- */ @@ -71,15 +68,12 @@ export const messageFields: INodeProperties[] = [ default: [], displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'sendPrivate', - ], + resource: ['message'], + operation: ['sendPrivate'], }, }, - description: 'The destination stream, or a comma-separated list containing the usernames (emails) of the recipients. Choose from the list, or specify IDs using an expression.', + description: + 'The destination stream, or a comma-separated list containing the usernames (emails) of the recipients. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Content', @@ -92,12 +86,8 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'sendPrivate', - ], + resource: ['message'], + operation: ['sendPrivate'], }, }, description: 'The content of the message', @@ -116,39 +106,31 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'sendStream', - ], + resource: ['message'], + operation: ['sendStream'], }, }, - description: 'The destination stream, or a comma-separated list containing the usernames (emails) of the recipients. Choose from the list, or specify an ID using an expression.', + description: + 'The destination stream, or a comma-separated list containing the usernames (emails) of the recipients. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Topic Name or ID', name: 'topic', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'stream', - ], + loadOptionsDependsOn: ['stream'], loadOptionsMethod: 'getTopics', }, required: true, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'sendStream', - ], + resource: ['message'], + operation: ['sendStream'], }, }, default: '', - description: 'The topic of the message. Only required if type is stream, ignored otherwise. Choose from the list, or specify an ID using an expression.', + description: + 'The topic of the message. Only required if type is stream, ignored otherwise. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Content', @@ -161,12 +143,8 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'sendStream', - ], + resource: ['message'], + operation: ['sendStream'], }, }, description: 'The content of the message', @@ -182,12 +160,8 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], + resource: ['message'], + operation: ['update'], }, }, description: 'Unique identifier for the message', @@ -200,12 +174,8 @@ export const messageFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], + resource: ['message'], + operation: ['update'], }, }, options: [ @@ -238,7 +208,8 @@ export const messageFields: INodeProperties[] = [ }, ], default: 'changeOne', - description: 'Which message(s) should be edited: just the one indicated in message_id, messages in the same topic that had been sent after this one, or all of them', + description: + 'Which message(s) should be edited: just the one indicated in message_id, messages in the same topic that had been sent after this one, or all of them', }, { displayName: 'Topic', @@ -260,12 +231,8 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'get', - ], + resource: ['message'], + operation: ['get'], }, }, description: 'Unique identifier for the message', @@ -281,12 +248,8 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'delete', - ], + resource: ['message'], + operation: ['delete'], }, }, description: 'Unique identifier for the message', @@ -302,12 +265,8 @@ export const messageFields: INodeProperties[] = [ default: 'data', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'updateFile', - ], + resource: ['message'], + operation: ['updateFile'], }, }, description: 'Name of the binary property to which to write the data of the read file', diff --git a/packages/nodes-base/nodes/Zulip/StreamDescription.ts b/packages/nodes-base/nodes/Zulip/StreamDescription.ts index 7ea9469bde..c32f9ba8c3 100644 --- a/packages/nodes-base/nodes/Zulip/StreamDescription.ts +++ b/packages/nodes-base/nodes/Zulip/StreamDescription.ts @@ -8,9 +8,7 @@ export const streamOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'stream', - ], + resource: ['stream'], }, }, options: [ @@ -60,12 +58,8 @@ export const streamFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'stream', - ], - operation: [ - 'create', - ], + resource: ['stream'], + operation: ['create'], }, }, }, @@ -79,15 +73,9 @@ export const streamFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'stream', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['stream'], + operation: ['create'], + jsonParameters: [true], }, }, description: 'JSON format parameters for stream creation', @@ -99,19 +87,14 @@ export const streamFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'stream', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['stream'], + operation: ['create'], + jsonParameters: [false], }, }, required: true, - description: 'A list of dictionaries containing the the key name and value specifying the name of the stream to subscribe. If the stream does not exist a new stream is created.', + description: + 'A list of dictionaries containing the the key name and value specifying the name of the stream to subscribe. If the stream does not exist a new stream is created.', typeOptions: { multipleValues: true, }, @@ -148,15 +131,9 @@ export const streamFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'stream', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['stream'], + operation: ['create'], + jsonParameters: [false], }, }, options: [ @@ -166,21 +143,24 @@ export const streamFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'If announce is True and one of the streams specified in subscriptions has to be created (i.e. doesnt exist to begin with), an announcement will be made notifying that a new stream was created.', + description: + 'If announce is True and one of the streams specified in subscriptions has to be created (i.e. doesnt exist to begin with), an announcement will be made notifying that a new stream was created.', }, { displayName: 'Authorization Errors Fatal', name: 'authorizationErrorsFatal', type: 'boolean', default: false, - description: 'Whether authorization errors (such as when the requesting user is not authorized to access a private stream) should be considered fatal or not. When True, an authorization error is reported as such. When set to False, the returned JSON payload indicates that there was an authorization error, but the response is still considered a successful one.', + description: + 'Whether authorization errors (such as when the requesting user is not authorized to access a private stream) should be considered fatal or not. When True, an authorization error is reported as such. When set to False, the returned JSON payload indicates that there was an authorization error, but the response is still considered a successful one.', }, { displayName: 'History Public to Subscribers', name: 'historyPublicToSubscribers', type: 'boolean', default: false, - description: 'Whether the streams message history should be available to newly subscribed members, or users can only access messages they actually received while subscribed to the stream', + description: + 'Whether the streams message history should be available to newly subscribed members, or users can only access messages they actually received while subscribed to the stream', }, { displayName: 'Invite Only', @@ -194,7 +174,8 @@ export const streamFields: INodeProperties[] = [ name: 'principals', type: 'fixedCollection', default: {}, - description: 'A list of email addresses of the users that will be subscribed/unsubscribed to the streams specified in the subscriptions argument. If not provided, then the requesting user/bot is subscribed.', + description: + 'A list of email addresses of the users that will be subscribed/unsubscribed to the streams specified in the subscriptions argument. If not provided, then the requesting user/bot is subscribed.', typeOptions: { multipleValues: true, }, @@ -254,12 +235,8 @@ export const streamFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'stream', - ], - operation: [ - 'getAll', - ], + resource: ['stream'], + operation: ['getAll'], }, }, options: [ @@ -268,7 +245,8 @@ export const streamFields: INodeProperties[] = [ name: 'includeAllActive', type: 'boolean', default: true, - description: 'Whether to include all active streams. The user must have administrative privileges to use this parameter.', + description: + 'Whether to include all active streams. The user must have administrative privileges to use this parameter.', }, { displayName: 'Include Default', @@ -282,7 +260,8 @@ export const streamFields: INodeProperties[] = [ name: 'includeOwnersubscribed', type: 'boolean', default: true, - description: 'Whether the user is a bot, include all streams that the bots owner is subscribed to', + description: + 'Whether the user is a bot, include all streams that the bots owner is subscribed to', }, { displayName: 'Include Public', @@ -312,12 +291,8 @@ export const streamFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'stream', - ], - operation: [ - 'getSubscribed', - ], + resource: ['stream'], + operation: ['getSubscribed'], }, }, options: [ @@ -326,7 +301,8 @@ export const streamFields: INodeProperties[] = [ name: 'includeSubscribers', type: 'boolean', default: true, - description: 'Whether each returned stream object should include a subscribers field containing a list of the user IDs of its subscribers', + description: + 'Whether each returned stream object should include a subscribers field containing a list of the user IDs of its subscribers', }, ], }, @@ -342,12 +318,8 @@ export const streamFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'stream', - ], - operation: [ - 'update', - ], + resource: ['stream'], + operation: ['update'], }, }, description: 'ID of stream to update', @@ -359,12 +331,8 @@ export const streamFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'stream', - ], - operation: [ - 'update', - ], + resource: ['stream'], + operation: ['update'], }, }, }, @@ -378,15 +346,9 @@ export const streamFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'stream', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['stream'], + operation: ['update'], + jsonParameters: [true], }, }, @@ -401,15 +363,9 @@ export const streamFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'stream', - ], - operation: [ - 'update', - ], - jsonParameters: [ - false, - ], + resource: ['stream'], + operation: ['update'], + jsonParameters: [false], }, }, options: [ @@ -440,7 +396,8 @@ export const streamFields: INodeProperties[] = [ name: 'historyPublicToSubscribers', type: 'boolean', default: false, - description: 'Whether the streams message history should be available to newly subscribed members, or users can only access messages they actually received while subscribed to the stream', + description: + 'Whether the streams message history should be available to newly subscribed members, or users can only access messages they actually received while subscribed to the stream', }, { displayName: 'New Name', @@ -487,15 +444,10 @@ export const streamFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'stream', - ], - operation: [ - 'delete', - ], + resource: ['stream'], + operation: ['delete'], }, }, description: 'ID of stream to delete', }, - ]; diff --git a/packages/nodes-base/nodes/Zulip/UserDescription.ts b/packages/nodes-base/nodes/Zulip/UserDescription.ts index 07d385a540..7300568483 100644 --- a/packages/nodes-base/nodes/Zulip/UserDescription.ts +++ b/packages/nodes-base/nodes/Zulip/UserDescription.ts @@ -8,9 +8,7 @@ export const userOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -61,12 +59,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, default: '', @@ -79,12 +73,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, default: '', @@ -97,12 +87,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, default: '', @@ -115,12 +101,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, default: '', @@ -137,12 +119,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, default: '', @@ -156,12 +134,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', 'getAll', - ], + resource: ['user'], + operation: ['get', 'getAll'], }, }, options: [ @@ -170,14 +144,16 @@ export const userFields: INodeProperties[] = [ name: 'clientGravatar', type: 'boolean', default: false, - description: 'Whether the client supports computing gravatars URLs. If enabled, avatar_url will be included in the response only if there is a Zulip avatar, and will be null for users who are using gravatar as their avatar.', + description: + 'Whether the client supports computing gravatars URLs. If enabled, avatar_url will be included in the response only if there is a Zulip avatar, and will be null for users who are using gravatar as their avatar.', }, { displayName: 'Custom Profile Fields', name: 'includeCustomProfileFields', type: 'boolean', default: false, - description: 'Whether the client wants custom profile field data to be included in the response', + description: + 'Whether the client wants custom profile field data to be included in the response', }, ], }, @@ -192,12 +168,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, default: '', @@ -211,12 +183,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'update', - ], + resource: ['user'], + operation: ['update'], }, }, options: [ @@ -246,7 +214,8 @@ export const userFields: INodeProperties[] = [ name: 'profileData', type: 'fixedCollection', default: {}, - description: 'A dictionary containing the to be updated custom profile field data for the user', + description: + 'A dictionary containing the to be updated custom profile field data for the user', typeOptions: { multipleValues: true, }, @@ -316,12 +285,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'deactivate', - ], + resource: ['user'], + operation: ['deactivate'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Zulip/Zulip.node.ts b/packages/nodes-base/nodes/Zulip/Zulip.node.ts index 1de4968bd3..3e172507a1 100644 --- a/packages/nodes-base/nodes/Zulip/Zulip.node.ts +++ b/packages/nodes-base/nodes/Zulip/Zulip.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, ILoadOptionsFunctions, @@ -10,29 +8,13 @@ import { INodeTypeDescription, NodeOperationError, } from 'n8n-workflow'; -import { - zulipApiRequest, -} from './GenericFunctions'; -import { - messageFields, - messageOperations, -} from './MessageDescription'; -import { - IMessage, -} from './MessageInterface'; +import { zulipApiRequest } from './GenericFunctions'; +import { messageFields, messageOperations } from './MessageDescription'; +import { IMessage } from './MessageInterface'; import { snakeCase } from 'change-case'; -import { - streamFields, - streamOperations, -} from './StreamDescription'; -import { - userFields, - userOperations, -} from './UserDescription'; -import { - IPrincipal, - IStream, -} from './StreamInterface'; +import { streamFields, streamOperations } from './StreamDescription'; +import { userFields, userOperations } from './UserDescription'; +import { IPrincipal, IStream } from './StreamInterface'; import { validateJSON } from './GenericFunctions'; import { IUser } from './UserInterface'; @@ -89,7 +71,6 @@ export class Zulip implements INodeType { // USER ...userOperations, ...userFields, - ], }; @@ -193,7 +174,12 @@ export class Zulip implements INodeType { if (updateFields.topic) { body.topic = updateFields.topic as string; } - responseData = await zulipApiRequest.call(this, 'PATCH', `/messages/${messageId}`, body); + responseData = await zulipApiRequest.call( + this, + 'PATCH', + `/messages/${messageId}`, + body, + ); } //https://zulipchat.com/api/get-raw-message if (operation === 'get') { @@ -214,7 +200,11 @@ export class Zulip implements INodeType { } //@ts-ignore if (items[i].binary[binaryProperty] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${binaryProperty}" does not exists on item!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${binaryProperty}" does not exists on item!`, + { itemIndex: i }, + ); } const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); @@ -230,7 +220,15 @@ export class Zulip implements INodeType { }, }, }; - responseData = await zulipApiRequest.call(this, 'POST', '/user_uploads', {}, {}, undefined, { formData }); + responseData = await zulipApiRequest.call( + this, + 'POST', + '/user_uploads', + {}, + {}, + undefined, + { formData }, + ); responseData.uri = `${credentials.url}${responseData.uri}`; } } @@ -279,16 +277,22 @@ export class Zulip implements INodeType { body.subscriptions = JSON.stringify(subscriptions.properties); if (jsonParameters) { - const additionalFieldsJson = this.getNodeParameter('additionalFieldsJson', i) as string; + const additionalFieldsJson = this.getNodeParameter( + 'additionalFieldsJson', + i, + ) as string; if (additionalFieldsJson !== '') { if (validateJSON(additionalFieldsJson) !== undefined) { Object.assign(body, JSON.parse(additionalFieldsJson)); } else { - throw new NodeOperationError(this.getNode(), 'Additional fields must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Additional fields must be a valid JSON', + { itemIndex: i }, + ); } } - } else { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; @@ -307,10 +311,12 @@ export class Zulip implements INodeType { body.principals = JSON.stringify(principals); } if (additionalFields.authorizationErrorsFatal) { - body.authorization_errors_fatal = additionalFields.authorizationErrorsFatal as boolean; + body.authorization_errors_fatal = + additionalFields.authorizationErrorsFatal as boolean; } if (additionalFields.historyPublicToSubscribers) { - body.history_public_to_subscribers = additionalFields.historyPublicToSubscribers as boolean; + body.history_public_to_subscribers = + additionalFields.historyPublicToSubscribers as boolean; } if (additionalFields.streamPostPolicy) { body.stream_post_policy = additionalFields.streamPostPolicy as number; @@ -320,7 +326,12 @@ export class Zulip implements INodeType { } } - responseData = await zulipApiRequest.call(this, 'POST', `/users/me/subscriptions`, body); + responseData = await zulipApiRequest.call( + this, + 'POST', + `/users/me/subscriptions`, + body, + ); } if (operation === 'delete') { @@ -335,21 +346,23 @@ export class Zulip implements INodeType { const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean; if (jsonParameters) { - const additionalFieldsJson = this.getNodeParameter('additionalFieldsJson', i) as string; + const additionalFieldsJson = this.getNodeParameter( + 'additionalFieldsJson', + i, + ) as string; if (additionalFieldsJson !== '') { - if (validateJSON(additionalFieldsJson) !== undefined) { - Object.assign(body, JSON.parse(additionalFieldsJson)); - } else { - throw new NodeOperationError(this.getNode(), 'Additional fields must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Additional fields must be a valid JSON', + { itemIndex: i }, + ); } } - } else { - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (additionalFields.description) { @@ -368,12 +381,17 @@ export class Zulip implements INodeType { body.stream_post_policy = additionalFields.streamPostPolicy as number; } if (additionalFields.historyPublicToSubscribers) { - body.history_public_to_subscribers = additionalFields.historyPublicToSubscribers as boolean; + body.history_public_to_subscribers = + additionalFields.historyPublicToSubscribers as boolean; } - responseData = await zulipApiRequest.call(this, 'PATCH', `/streams/${streamId}`, body); + responseData = await zulipApiRequest.call( + this, + 'PATCH', + `/streams/${streamId}`, + body, + ); } - } } @@ -388,11 +406,11 @@ export class Zulip implements INodeType { body.client_gravatar = additionalFields.client_gravatar as boolean; } if (additionalFields.includeCustomProfileFields) { - body.include_custom_profile_fields = additionalFields.includeCustomProfileFields as boolean; + body.include_custom_profile_fields = + additionalFields.includeCustomProfileFields as boolean; } responseData = await zulipApiRequest.call(this, 'GET', `/users/${userId}`, body); - } if (operation === 'getAll') { @@ -402,7 +420,8 @@ export class Zulip implements INodeType { body.client_gravatar = additionalFields.client_gravatar as boolean; } if (additionalFields.includeCustomProfileFields) { - body.include_custom_profile_fields = additionalFields.includeCustomProfileFields as boolean; + body.include_custom_profile_fields = + additionalFields.includeCustomProfileFields as boolean; } responseData = await zulipApiRequest.call(this, 'GET', `/users`, body); diff --git a/packages/nodes-base/nodes/utils/allCurrencies.ts b/packages/nodes-base/nodes/utils/allCurrencies.ts index 709509fe67..44b5522a4e 100644 --- a/packages/nodes-base/nodes/utils/allCurrencies.ts +++ b/packages/nodes-base/nodes/utils/allCurrencies.ts @@ -171,4 +171,4 @@ const allCurrencies = [ { name: 'Zambian Kwacha', value: 'zmw' }, { name: 'Zimbabwean Dollar', value: 'zwl' }, // tslint:disable-next-line: semicolon -] +]; diff --git a/packages/nodes-base/nodes/utils/utilities.ts b/packages/nodes-base/nodes/utils/utilities.ts index 0ba469dd10..7bf8d9cd82 100644 --- a/packages/nodes-base/nodes/utils/utilities.ts +++ b/packages/nodes-base/nodes/utils/utilities.ts @@ -14,7 +14,9 @@ * chunk(['a', 'b', 'c', 'd'], 3) * // => [['a', 'b', 'c'], ['d']] */ -export function chunk(array: any[], size = 1) { // tslint:disable-line:no-any + +// tslint:disable-next-line:no-any +export function chunk(array: any[], size = 1) { const length = array == null ? 0 : array.length; if (!length || size < 1) { return []; @@ -40,10 +42,13 @@ export function chunk(array: any[], size = 1) { // tslint:disable-line:no-any * // => ['a', 'b', 'c', 'd'] * */ -export function flatten(nestedArray: any[][]) { // tslint:disable-line:no-any + +// tslint:disable-next-line:no-any +export function flatten(nestedArray: any[][]) { const result = []; - (function loop(array: any[]) { // tslint:disable-line:no-any + // tslint:disable-next-line:no-any + (function loop(array: any[]) { for (let i = 0; i < array.length; i++) { if (Array.isArray(array[i])) { loop(array[i]);