From f316f73990897351e360510d8f74b42420473346 Mon Sep 17 00:00:00 2001 From: Michael Kret <88898367+michael-radency@users.noreply.github.com> Date: Mon, 1 Aug 2022 23:47:55 +0300 Subject: [PATCH] refactor: Format `nodes-base` package (A-F) (#3800) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :hammer: prettier formated nodes - A * :hammer: prettier formated nodes - B * :zap: prettier formated nodes - C * :zap: prettier formated nodes - D * :zap: prettier formated nodes - E-F * :art: Adjust nodes-base formatting command (#3805) * Format additional files in nodes A-F (#3811) * :zap: fixes * :art: Add Mindee to ignored dirs Co-authored-by: Iván Ovejero --- .prettierignore | 77 +- .../credentials/ERPNextApi.credentials.ts | 3 +- .../nodes/ActionNetwork/ActionNetwork.node.ts | 91 +-- .../nodes/ActionNetwork/GenericFunctions.ts | 65 +- .../descriptions/AttendanceDescription.ts | 72 +- .../descriptions/EventDescription.ts | 65 +- .../descriptions/PersonDescription.ts | 77 +- .../descriptions/PersonTagDescription.ts | 53 +- .../descriptions/PetitionDescription.ts | 81 +- .../descriptions/SharedFields.ts | 30 +- .../descriptions/SignatureDescription.ts | 104 +-- .../descriptions/TagDescription.ts | 48 +- .../nodes-base/nodes/ActionNetwork/types.d.ts | 40 +- .../AccountContactDescription.ts | 56 +- .../ActiveCampaign/AccountDescription.ts | 83 +-- .../ActiveCampaign/ActiveCampaign.node.ts | 247 +++--- .../ActiveCampaignTrigger.node.ts | 40 +- .../ActiveCampaign/ConnectionDescription.ts | 101 +-- .../ActiveCampaign/ContactDescription.ts | 88 +-- .../ActiveCampaign/ContactListDescription.ts | 40 +- .../ActiveCampaign/ContactTagDescription.ts | 35 +- .../nodes/ActiveCampaign/DealDescription.ts | 162 ++-- .../ActiveCampaign/EcomCustomerDescription.ts | 79 +- .../ActiveCampaign/EcomOrderDescription.ts | 180 ++--- .../EcomOrderProductsDescription.ts | 34 +- .../nodes/ActiveCampaign/GenericFunctions.ts | 78 +- .../nodes/ActiveCampaign/ListDescription.ts | 12 +- .../nodes/ActiveCampaign/TagDescription.ts | 68 +- .../nodes/ActiveCampaign/currencies.ts | 2 +- .../AcuitySchedulingTrigger.node.ts | 39 +- .../AcuityScheduling/GenericFunctions.ts | 30 +- .../nodes/Affinity/Affinity.node.ts | 150 ++-- .../nodes/Affinity/AffinityTrigger.node.ts | 22 +- .../nodes/Affinity/GenericFunctions.ts | 40 +- .../nodes/Affinity/ListDescription.ts | 36 +- .../nodes/Affinity/ListEntryDescription.ts | 111 +-- .../nodes/Affinity/OrganizationDescription.ts | 110 +-- .../nodes/Affinity/OrganizationInterface.ts | 1 - .../nodes/Affinity/PersonDescription.ts | 126 +--- .../nodes/Affinity/PersonInterface.ts | 1 - .../nodes/AgileCrm/AgileCrm.node.ts | 164 ++-- .../nodes/AgileCrm/CompanyDescription.ts | 208 ++---- .../nodes/AgileCrm/ContactDescription.ts | 208 ++---- .../nodes/AgileCrm/ContactInterface.ts | 4 +- .../nodes/AgileCrm/DealDescription.ts | 184 ++--- .../nodes/AgileCrm/GenericFunctions.ts | 117 ++- .../nodes/Airtable/Airtable.node.ts | 141 ++-- .../nodes/Airtable/AirtableTrigger.node.ts | 36 +- .../nodes/Airtable/GenericFunctions.ts | 58 +- packages/nodes-base/nodes/Amqp/Amqp.node.ts | 30 +- .../nodes-base/nodes/Amqp/AmqpTrigger.node.ts | 48 +- .../nodes/ApiTemplateIo/ApiTemplateIo.node.ts | 191 ++--- .../nodes/ApiTemplateIo/GenericFunctions.ts | 30 +- packages/nodes-base/nodes/Asana/Asana.node.ts | 700 +++++++----------- .../nodes/Asana/AsanaTrigger.node.ts | 37 +- .../nodes/Asana/GenericFunctions.ts | 46 +- .../nodes/Automizy/Automizy.node.ts | 92 +-- .../nodes/Automizy/ContactDescription.ts | 137 ++-- .../nodes/Automizy/GenericFunctions.ts | 46 +- .../nodes/Automizy/ListDescription.ts | 85 +-- .../nodes/Autopilot/Autopilot.node.ts | 107 +-- .../nodes/Autopilot/AutopilotTrigger.node.ts | 24 +- .../nodes/Autopilot/ContactDescription.ts | 76 +- .../Autopilot/ContactJourneyDescription.ts | 28 +- .../nodes/Autopilot/ContactListDescription.ts | 53 +- .../nodes/Autopilot/GenericFunctions.ts | 47 +- .../nodes/Autopilot/ListDescription.ts | 37 +- .../nodes-base/nodes/Aws/AwsLambda.node.ts | 27 +- packages/nodes-base/nodes/Aws/AwsSns.node.ts | 34 +- .../nodes/Aws/AwsSnsTrigger.node.ts | 81 +- .../Aws/Comprehend/AwsComprehend.node.ts | 88 +-- .../nodes/Aws/Comprehend/GenericFunctions.ts | 60 +- .../nodes/Aws/DynamoDB/AwsDynamoDB.node.ts | 109 +-- .../nodes/Aws/DynamoDB/GenericFunctions.ts | 82 +- .../nodes/Aws/DynamoDB/ItemDescription.ts | 255 +++---- .../nodes-base/nodes/Aws/DynamoDB/types.d.ts | 35 +- .../nodes-base/nodes/Aws/DynamoDB/utils.ts | 12 +- .../nodes-base/nodes/Aws/GenericFunctions.ts | 43 +- .../Aws/Rekognition/AwsRekognition.node.ts | 149 ++-- .../nodes/Aws/Rekognition/GenericFunctions.ts | 147 +++- .../nodes-base/nodes/Aws/S3/AwsS3.node.ts | 438 ++++++++--- .../nodes/Aws/S3/BucketDescription.ts | 131 ++-- .../nodes/Aws/S3/FileDescription.ts | 277 +++---- .../nodes/Aws/S3/FolderDescription.ts | 109 +-- .../nodes/Aws/S3/GenericFunctions.ts | 145 +++- .../nodes-base/nodes/Aws/SES/AwsSes.node.ts | 545 +++++++------- .../nodes/Aws/SES/GenericFunctions.ts | 87 ++- .../nodes-base/nodes/Aws/SQS/AwsSqs.node.ts | 108 +-- .../nodes/Aws/Textract/AwsTextract.node.ts | 48 +- .../nodes/Aws/Textract/GenericFunctions.ts | 92 ++- .../Aws/Transcribe/AwsTranscribe.node.ts | 192 +++-- .../nodes/Aws/Transcribe/GenericFunctions.ts | 66 +- .../nodes/BambooHr/BambooHr.node.ts | 10 +- .../nodes/BambooHr/v1/actions/Interfaces.ts | 6 +- .../actions/companyReport/get/description.ts | 39 +- .../v1/actions/companyReport/get/execute.ts | 37 +- .../v1/actions/companyReport/get/index.ts | 5 +- .../v1/actions/companyReport/index.ts | 12 +- .../v1/actions/employee/create/description.ts | 45 +- .../v1/actions/employee/create/execute.ts | 47 +- .../v1/actions/employee/create/index.ts | 5 +- .../employee/create/shareDescription.ts | 33 +- .../v1/actions/employee/get/description.ts | 27 +- .../v1/actions/employee/get/execute.ts | 20 +- .../BambooHr/v1/actions/employee/get/index.ts | 5 +- .../v1/actions/employee/getAll/description.ts | 20 +- .../v1/actions/employee/getAll/execute.ts | 18 +- .../v1/actions/employee/getAll/index.ts | 5 +- .../BambooHr/v1/actions/employee/index.ts | 15 +- .../v1/actions/employee/update/description.ts | 31 +- .../v1/actions/employee/update/execute.ts | 41 +- .../v1/actions/employee/update/index.ts | 5 +- .../employee/update/sharedDescription.ts | 41 +- .../employeeDocument/del/description.ts | 20 +- .../actions/employeeDocument/del/execute.ts | 13 +- .../v1/actions/employeeDocument/del/index.ts | 5 +- .../employeeDocument/download/description.ts | 28 +- .../employeeDocument/download/execute.ts | 28 +- .../employeeDocument/download/index.ts | 5 +- .../employeeDocument/getAll/description.ts | 40 +- .../employeeDocument/getAll/execute.ts | 18 +- .../actions/employeeDocument/getAll/index.ts | 5 +- .../v1/actions/employeeDocument/index.ts | 16 +- .../employeeDocument/update/description.ts | 35 +- .../employeeDocument/update/execute.ts | 20 +- .../actions/employeeDocument/update/index.ts | 5 +- .../employeeDocument/upload/description.ts | 39 +- .../employeeDocument/upload/execute.ts | 27 +- .../actions/employeeDocument/upload/index.ts | 5 +- .../v1/actions/file/del/description.ts | 12 +- .../BambooHr/v1/actions/file/del/execute.ts | 13 +- .../BambooHr/v1/actions/file/del/index.ts | 5 +- .../v1/actions/file/download/description.ts | 20 +- .../v1/actions/file/download/execute.ts | 28 +- .../v1/actions/file/download/index.ts | 5 +- .../v1/actions/file/getAll/description.ts | 32 +- .../v1/actions/file/getAll/execute.ts | 18 +- .../BambooHr/v1/actions/file/getAll/index.ts | 5 +- .../nodes/BambooHr/v1/actions/file/index.ts | 16 +- .../v1/actions/file/update/description.ts | 23 +- .../v1/actions/file/update/execute.ts | 24 +- .../BambooHr/v1/actions/file/update/index.ts | 5 +- .../v1/actions/file/upload/description.ts | 30 +- .../v1/actions/file/upload/execute.ts | 27 +- .../BambooHr/v1/actions/file/upload/index.ts | 5 +- .../nodes/BambooHr/v1/actions/router.ts | 16 +- .../BambooHr/v1/actions/versionDescription.ts | 4 +- .../BambooHr/v1/methods/credentialTest.ts | 20 +- .../nodes/BambooHr/v1/methods/loadOptions.ts | 69 +- .../nodes/BambooHr/v1/transport/index.ts | 16 +- .../nodes/Bannerbear/Bannerbear.node.ts | 28 +- .../nodes/Bannerbear/GenericFunctions.ts | 28 +- .../nodes/Bannerbear/ImageDescription.ts | 70 +- .../nodes/Bannerbear/TemplateDescription.ts | 23 +- .../nodes-base/nodes/Baserow/Baserow.node.ts | 106 ++- .../nodes/Baserow/GenericFunctions.ts | 42 +- .../nodes/Baserow/OperationDescription.ts | 100 +-- packages/nodes-base/nodes/Baserow/types.d.ts | 14 +- .../Beeminder/Beeminder.node.functions.ts | 44 +- .../nodes/Beeminder/Beeminder.node.ts | 93 +-- .../nodes/Beeminder/GenericFunctions.ts | 48 +- .../nodes/Bitbucket/BitbucketTrigger.node.ts | 81 +- .../nodes/Bitbucket/GenericFunctions.ts | 32 +- packages/nodes-base/nodes/Bitly/Bitly.node.ts | 35 +- .../nodes/Bitly/GenericFunctions.ts | 50 +- .../nodes-base/nodes/Bitly/LinkDescription.ts | 99 +-- .../nodes/Bitwarden/Bitwarden.node.ts | 100 +-- .../nodes/Bitwarden/GenericFunctions.ts | 31 +- .../descriptions/CollectionDescription.ts | 49 +- .../descriptions/EventDescription.ts | 37 +- .../descriptions/GroupDescription.ts | 92 +-- .../descriptions/MemberDescription.ts | 94 +-- packages/nodes-base/nodes/Box/Box.node.ts | 146 ++-- .../nodes-base/nodes/Box/BoxTrigger.node.ts | 33 +- .../nodes-base/nodes/Box/FileDescription.ts | 298 +++----- .../nodes-base/nodes/Box/FolderDescription.ts | 278 +++---- .../nodes-base/nodes/Box/GenericFunctions.ts | 40 +- .../nodes/Brandfetch/Brandfetch.node.ts | 82 +- .../nodes/Brandfetch/GenericFunctions.ts | 23 +- .../nodes-base/nodes/Bubble/Bubble.node.ts | 43 +- .../nodes/Bubble/GenericFunctions.ts | 39 +- .../nodes/Bubble/ObjectDescription.ts | 170 ++--- .../nodes-base/nodes/Cal/CalTrigger.node.ts | 198 +++-- .../nodes-base/nodes/Cal/GenericFunctions.ts | 29 +- .../nodes/Calendly/CalendlyTrigger.node.ts | 47 +- .../nodes/Calendly/GenericFunctions.ts | 38 +- .../nodes/Chargebee/Chargebee.node.ts | 122 ++- .../nodes/Chargebee/ChargebeeTrigger.node.ts | 56 +- .../nodes/CircleCi/CircleCi.node.ts | 37 +- .../nodes/CircleCi/GenericFunctions.ts | 41 +- .../nodes/CircleCi/PipelineDescription.ts | 103 +-- .../nodes/Cisco/Webex/CiscoWebex.node.ts | 152 ++-- .../Cisco/Webex/CiscoWebexTrigger.node.ts | 183 ++--- .../nodes/Cisco/Webex/GenericFunctions.ts | 208 +++--- .../Webex/descriptions/MeetingDescription.ts | 225 +++--- .../Webex/descriptions/MeetingTranscript.ts | 68 +- .../Webex/descriptions/MessageDescription.ts | 212 ++---- .../nodes/Clearbit/Clearbit.node.ts | 55 +- .../nodes/Clearbit/CompanyDescription.ts | 29 +- .../nodes/Clearbit/GenericFunctions.ts | 19 +- .../nodes/Clearbit/PersonDescription.ts | 27 +- .../nodes/ClickUp/ChecklistDescription.ts | 49 +- .../nodes/ClickUp/ChecklistItemDescription.ts | 73 +- .../nodes-base/nodes/ClickUp/ClickUp.node.ts | 505 +++++++++---- .../nodes/ClickUp/ClickUpTrigger.node.ts | 32 +- .../nodes/ClickUp/CommentDescription.ts | 92 +-- .../nodes/ClickUp/FolderDescription.ts | 216 ++---- .../nodes/ClickUp/GenericFunctions.ts | 58 +- .../nodes/ClickUp/GoalDescription.ts | 87 +-- .../nodes/ClickUp/GoalKeyResultDescription.ts | 71 +- .../nodes/ClickUp/GuestDescription.ts | 101 +-- .../nodes/ClickUp/ListDescription.ts | 473 ++++-------- .../nodes-base/nodes/ClickUp/ListInterface.ts | 1 - .../nodes/ClickUp/SpaceTagDescription.ts | 89 +-- .../ClickUp/TaskDependencyDescription.ts | 41 +- .../nodes/ClickUp/TaskDescription.ts | 387 +++------- .../nodes-base/nodes/ClickUp/TaskInterface.ts | 4 +- .../nodes/ClickUp/TaskListDescription.ts | 26 +- .../nodes/ClickUp/TaskTagDescription.ts | 40 +- .../nodes/ClickUp/TimeEntryDescription.ts | 417 ++++------- .../nodes/ClickUp/TimeEntryTagDescription.ts | 101 +-- .../nodes/Clockify/ClientDescription.ts | 85 +-- .../nodes/Clockify/Clockify.node.ts | 240 ++---- .../nodes/Clockify/ClockifyTrigger.node.ts | 25 +- .../nodes/Clockify/GenericFunctions.ts | 51 +- .../nodes/Clockify/ProjectDescription.ts | 114 +-- .../nodes/Clockify/ProjectInterfaces.ts | 5 +- .../nodes/Clockify/TagDescription.ts | 69 +- .../nodes/Clockify/TaskDescription.ts | 101 +-- .../nodes/Clockify/TimeEntryDescription.ts | 113 +-- .../nodes/Clockify/UserDescription.ts | 46 +- .../nodes-base/nodes/Clockify/UserDtos.ts | 7 +- .../nodes/Clockify/WorkspaceDescription.ts | 28 +- .../nodes-base/nodes/Cockpit/Cockpit.node.ts | 24 +- .../nodes/Cockpit/CollectionDescription.ts | 88 +-- .../nodes/Cockpit/CollectionFunctions.ts | 29 +- .../nodes/Cockpit/FormDescription.ts | 41 +- .../nodes-base/nodes/Cockpit/FormFunctions.ts | 12 +- .../nodes/Cockpit/GenericFunctions.ts | 24 +- .../nodes/Cockpit/SingletonDescription.ts | 11 +- .../nodes/Cockpit/SingletonFunctions.ts | 16 +- packages/nodes-base/nodes/Coda/Coda.node.ts | 128 ++-- .../nodes/Coda/ControlDescription.ts | 67 +- .../nodes/Coda/FormulaDescription.ts | 67 +- .../nodes-base/nodes/Coda/GenericFunctions.ts | 43 +- .../nodes-base/nodes/Coda/TableDescription.ts | 362 ++++----- .../nodes-base/nodes/Coda/ViewDescription.ts | 361 ++++----- .../nodes/CoinGecko/CoinDescription.ts | 256 ++----- .../nodes/CoinGecko/CoinGecko.node.ts | 121 +-- .../nodes/CoinGecko/EventDescription.ts | 42 +- .../nodes/CoinGecko/GenericFunctions.ts | 46 +- .../nodes/Compression/Compression.node.ts | 101 +-- .../nodes/Contentful/AssetDescription.ts | 81 +- .../Contentful/ContentTypeDescription.ts | 36 +- .../nodes/Contentful/Contentful.node.ts | 127 ++-- .../nodes/Contentful/EntryDescription.ts | 81 +- .../nodes/Contentful/GenericFunctions.ts | 46 +- .../nodes/Contentful/LocaleDescription.ts | 41 +- .../nodes/Contentful/SpaceDescription.ts | 8 +- .../nodes/ConvertKit/ConvertKit.node.ts | 136 ++-- .../ConvertKit/ConvertKitTrigger.node.ts | 58 +- .../ConvertKit/CustomFieldDescription.ts | 46 +- .../nodes/ConvertKit/FormDescription.ts | 75 +- .../nodes/ConvertKit/GenericFunctions.ts | 37 +- .../nodes/ConvertKit/SequenceDescription.ts | 78 +- .../nodes/ConvertKit/TagDescription.ts | 36 +- .../ConvertKit/TagSubscriberDescription.ts | 71 +- .../nodes-base/nodes/Copper/Copper.node.ts | 119 +-- .../nodes/Copper/CopperTrigger.node.ts | 21 +- .../nodes/Copper/GenericFunctions.ts | 29 +- .../Copper/descriptions/CompanyDescription.ts | 93 +-- .../descriptions/CustomerSourceDescription.ts | 28 +- .../Copper/descriptions/LeadDescription.ts | 90 +-- .../descriptions/OpportunityDescription.ts | 92 +-- .../Copper/descriptions/PersonDescription.ts | 84 +-- .../Copper/descriptions/ProjectDescription.ts | 84 +-- .../Copper/descriptions/TaskDescription.ts | 84 +-- .../Copper/descriptions/UserDescription.ts | 28 +- .../nodes/Copper/utils/isoCountryCodes.ts | 6 +- .../nodes/Copper/utils/sharedFields.ts | 4 +- .../nodes-base/nodes/Copper/utils/types.d.ts | 18 +- .../nodes/Cortex/AnalyzerDescriptions.ts | 100 +-- .../nodes/Cortex/AnalyzerInterface.ts | 4 +- .../nodes-base/nodes/Cortex/Cortex.node.ts | 149 ++-- .../nodes/Cortex/GenericFunctions.ts | 26 +- .../nodes-base/nodes/Cortex/JobDescription.ts | 17 +- .../nodes/Cortex/ResponderDescription.ts | 200 ++--- .../nodes-base/nodes/CrateDb/CrateDb.node.ts | 84 ++- packages/nodes-base/nodes/Cron/Cron.node.ts | 62 +- .../nodes-base/nodes/Crypto/Crypto.node.ts | 97 +-- .../nodes/CustomerIo/CampaignDescription.ts | 51 +- .../nodes/CustomerIo/CustomerDescription.ts | 59 +- .../nodes/CustomerIo/CustomerIo.node.ts | 94 ++- .../CustomerIo/CustomerIoTrigger.node.ts | 32 +- .../nodes/CustomerIo/EventDescription.ts | 111 +-- .../nodes/CustomerIo/GenericFunctions.ts | 39 +- .../nodes/CustomerIo/SegmentDescription.ts | 29 +- .../nodes/DateTime/DateTime.node.ts | 111 ++- packages/nodes-base/nodes/DeepL/DeepL.node.ts | 37 +- .../nodes/DeepL/GenericFunctions.ts | 22 +- .../nodes-base/nodes/DeepL/TextDescription.ts | 27 +- packages/nodes-base/nodes/Demio/Demio.node.ts | 65 +- .../nodes/Demio/EventDescription.ts | 105 +-- .../nodes/Demio/GenericFunctions.ts | 20 +- .../nodes/Demio/ReportDescription.ts | 39 +- packages/nodes-base/nodes/Dhl/Dhl.node.ts | 22 +- .../nodes-base/nodes/Dhl/GenericFunctions.ts | 27 +- .../nodes-base/nodes/Discord/Discord.node.ts | 44 +- .../nodes/Discourse/CategoryDescription.ts | 76 +- .../nodes/Discourse/Discourse.node.ts | 130 +--- .../nodes/Discourse/GenericFunctions.ts | 43 +- .../nodes/Discourse/GroupDescription.ts | 53 +- .../nodes/Discourse/PostDescription.ts | 87 +-- .../nodes/Discourse/SearchDescription.ts | 24 +- .../nodes/Discourse/UserDescription.ts | 108 +-- .../nodes/Discourse/UserGroupDescription.ts | 41 +- .../nodes-base/nodes/Disqus/Disqus.node.ts | 194 ++--- .../nodes/Disqus/GenericFunctions.ts | 45 +- .../nodes/Drift/ContactDescription.ts | 77 +- packages/nodes-base/nodes/Drift/Drift.node.ts | 40 +- .../nodes/Drift/GenericFunctions.ts | 17 +- .../nodes-base/nodes/Dropbox/Dropbox.node.ts | 346 ++++----- .../nodes/Dropbox/GenericFunctions.ts | 60 +- .../nodes/Dropcontact/Dropcontact.node.ts | 101 +-- .../nodes/Dropcontact/GenericFunction.ts | 23 +- .../nodes/ERPNext/DocumentDescription.ts | 159 ++-- .../nodes-base/nodes/ERPNext/ERPNext.node.ts | 150 ++-- .../nodes/ERPNext/GenericFunctions.ts | 35 +- packages/nodes-base/nodes/ERPNext/utils.ts | 26 +- .../nodes/EditImage/EditImage.node.ts | 467 +++++------- packages/nodes-base/nodes/Egoi/Egoi.node.ts | 232 +++--- .../nodes-base/nodes/Egoi/GenericFunctions.ts | 48 +- packages/nodes-base/nodes/Egoi/Interfaces.ts | 1 - .../ElasticSecurity/ElasticSecurity.node.ts | 108 +-- .../ElasticSecurity/GenericFunctions.ts | 63 +- .../descriptions/CaseCommentDescription.ts | 135 +--- .../descriptions/CaseDescription.ts | 218 ++---- .../descriptions/CaseTagDescription.ts | 46 +- .../descriptions/ConnectorDescription.ts | 131 +--- .../nodes/Elastic/ElasticSecurity/types.d.ts | 26 +- .../Elasticsearch/Elasticsearch.node.ts | 83 +-- .../Elastic/Elasticsearch/GenericFunctions.ts | 25 +- .../descriptions/DocumentDescription.ts | 284 +++---- .../descriptions/IndexDescription.ts | 101 +-- .../nodes/EmailReadImap/EmailReadImap.node.ts | 171 +++-- .../nodes/EmailSend/EmailSend.node.ts | 15 +- .../nodes/Emelia/CampaignDescription.ts | 117 +-- .../nodes/Emelia/ContactListDescription.ts | 55 +- .../nodes-base/nodes/Emelia/Emelia.node.ts | 73 +- .../nodes/Emelia/EmeliaTrigger.node.ts | 25 +- .../nodes/Emelia/GenericFunctions.ts | 26 +- .../nodes/ErrorTrigger/ErrorTrigger.node.ts | 18 +- .../Eventbrite/EventbriteTrigger.node.ts | 71 +- .../nodes/Eventbrite/GenericFunctions.ts | 39 +- .../ExecuteCommand/ExecuteCommand.node.ts | 43 +- .../ExecuteWorkflow/ExecuteWorkflow.node.ts | 41 +- .../nodes/Facebook/FacebookGraphApi.node.ts | 80 +- .../nodes/Facebook/FacebookTrigger.node.ts | 58 +- .../nodes/Facebook/GenericFunctions.ts | 65 +- .../nodes/Figma/FigmaTrigger.node.ts | 57 +- .../nodes/Figma/GenericFunctions.ts | 21 +- .../nodes/FileMaker/FileMaker.node.ts | 289 +++----- .../nodes/FileMaker/GenericFunctions.ts | 95 ++- packages/nodes-base/nodes/Flow/Flow.node.ts | 32 +- .../nodes-base/nodes/Flow/FlowTrigger.node.ts | 65 +- .../nodes-base/nodes/Flow/GenericFunctions.ts | 39 +- .../nodes-base/nodes/Flow/TaskDescription.ts | 143 ++-- .../nodes-base/nodes/Flow/TaskInterface.ts | 1 - .../nodes/FormIo/FormIoTrigger.node.ts | 58 +- .../nodes/FormIo/GenericFunctions.ts | 33 +- .../nodes/Formstack/FormstackTrigger.node.ts | 34 +- .../nodes/Formstack/GenericFunctions.ts | 52 +- .../nodes/Freshdesk/ContactDescription.ts | 99 +-- .../nodes/Freshdesk/ContactInterface.ts | 4 +- .../nodes/Freshdesk/Freshdesk.node.ts | 271 +++---- .../nodes/Freshdesk/GenericFunctions.ts | 47 +- .../nodes/Freshservice/Freshservice.node.ts | 313 +++----- .../nodes/Freshservice/GenericFunctions.ts | 77 +- .../nodes/Freshservice/constants.ts | 2 +- .../descriptions/AgentDescription.ts | 140 ++-- .../descriptions/AgentGroupDescription.ts | 100 +-- .../descriptions/AgentRoleDescription.ts | 36 +- .../descriptions/AnnouncementDescription.ts | 112 +-- .../descriptions/AssetDescription.ts | 121 +-- .../descriptions/AssetTypeDescription.ts | 79 +- .../descriptions/ChangeDescription.ts | 132 ++-- .../descriptions/DepartmentDescription.ts | 84 +-- .../descriptions/LocationDescription.ts | 76 +- .../descriptions/ProblemDescription.ts | 116 +-- .../descriptions/ProductDescription.ts | 90 +-- .../descriptions/ReleaseDescription.ts | 128 +--- .../descriptions/RequesterDescription.ts | 110 +-- .../descriptions/RequesterGroupDescription.ts | 76 +- .../descriptions/SoftwareDescription.ts | 84 +-- .../descriptions/TicketDescription.ts | 137 ++-- .../nodes-base/nodes/Freshservice/types.d.ts | 8 +- .../nodes/FreshworksCrm/FreshworksCrm.node.ts | 175 ++--- .../nodes/FreshworksCrm/GenericFunctions.ts | 65 +- .../descriptions/AccountDescription.ts | 111 +-- .../descriptions/AppointmentDescription.ts | 162 ++-- .../descriptions/ContactDescription.ts | 148 ++-- .../descriptions/DealDescription.ts | 161 ++-- .../descriptions/NoteDescription.ts | 59 +- .../descriptions/SalesActivityDescription.ts | 154 ++-- .../descriptions/SearchDescription.ts | 104 +-- .../descriptions/TaskDescription.ts | 140 ++-- .../nodes-base/nodes/FreshworksCrm/types.d.ts | 4 +- packages/nodes-base/nodes/Ftp/Ftp.node.ts | 190 ++--- .../nodes/Function/Function.node.ts | 31 +- .../nodes/FunctionItem/FunctionItem.node.ts | 24 +- packages/nodes-base/package.json | 2 +- 411 files changed, 12941 insertions(+), 20183 deletions(-) diff --git a/.prettierignore b/.prettierignore index d07b7c6304782..6fba26b4f0c9a 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,3 +1,4 @@ +dist packages/editor-ui packages/design-system *package.json @@ -6,81 +7,6 @@ packages/design-system !packages/nodes-base/test !packages/nodes-base/nodes -packages/nodes-base/nodes/ActionNetwork -packages/nodes-base/nodes/ActiveCampaign -packages/nodes-base/nodes/AcuityScheduling -packages/nodes-base/nodes/Affinity -packages/nodes-base/nodes/AgileCrm -packages/nodes-base/nodes/Airtable -packages/nodes-base/nodes/Amqp -packages/nodes-base/nodes/ApiTemplateIo -packages/nodes-base/nodes/Asana -packages/nodes-base/nodes/Automizy -packages/nodes-base/nodes/Autopilot -packages/nodes-base/nodes/Aws -packages/nodes-base/nodes/BambooHr -packages/nodes-base/nodes/Bannerbear -packages/nodes-base/nodes/Baserow -packages/nodes-base/nodes/Beeminder -packages/nodes-base/nodes/Bitbucket -packages/nodes-base/nodes/Bitly -packages/nodes-base/nodes/Bitwarden -packages/nodes-base/nodes/Box -packages/nodes-base/nodes/Brandfetch -packages/nodes-base/nodes/Bubble -packages/nodes-base/nodes/Cal -packages/nodes-base/nodes/Calendly -packages/nodes-base/nodes/Chargebee -packages/nodes-base/nodes/CircleCi -packages/nodes-base/nodes/Cisco -packages/nodes-base/nodes/Clearbit -packages/nodes-base/nodes/ClickUp -packages/nodes-base/nodes/Clockify -packages/nodes-base/nodes/Cockpit -packages/nodes-base/nodes/Coda -packages/nodes-base/nodes/CoinGecko -packages/nodes-base/nodes/Compression -packages/nodes-base/nodes/Contentful -packages/nodes-base/nodes/ConvertKit -packages/nodes-base/nodes/Copper -packages/nodes-base/nodes/Cortex -packages/nodes-base/nodes/CrateDb -packages/nodes-base/nodes/Cron -packages/nodes-base/nodes/Crypto -packages/nodes-base/nodes/CustomerIo -packages/nodes-base/nodes/DateTime -packages/nodes-base/nodes/DeepL -packages/nodes-base/nodes/Demio -packages/nodes-base/nodes/Dhl -packages/nodes-base/nodes/Discord -packages/nodes-base/nodes/Discourse -packages/nodes-base/nodes/Disqus -packages/nodes-base/nodes/Drift -packages/nodes-base/nodes/Dropbox -packages/nodes-base/nodes/Dropcontact -packages/nodes-base/nodes/EditImage -packages/nodes-base/nodes/Egoi -packages/nodes-base/nodes/Elastic -packages/nodes-base/nodes/EmailReadImap -packages/nodes-base/nodes/EmailSend -packages/nodes-base/nodes/Emelia -packages/nodes-base/nodes/ERPNext -packages/nodes-base/nodes/ErrorTrigger -packages/nodes-base/nodes/Eventbrite -packages/nodes-base/nodes/ExecuteCommand -packages/nodes-base/nodes/ExecuteWorkflow -packages/nodes-base/nodes/Facebook -packages/nodes-base/nodes/Figma -packages/nodes-base/nodes/FileMaker -packages/nodes-base/nodes/Flow -packages/nodes-base/nodes/FormIo -packages/nodes-base/nodes/Formstack -packages/nodes-base/nodes/Freshdesk -packages/nodes-base/nodes/Freshservice -packages/nodes-base/nodes/FreshworksCrm -packages/nodes-base/nodes/Ftp -packages/nodes-base/nodes/Function -packages/nodes-base/nodes/FunctionItem packages/nodes-base/nodes/GetResponse packages/nodes-base/nodes/Ghost packages/nodes-base/nodes/Git @@ -139,6 +65,7 @@ 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 diff --git a/packages/nodes-base/credentials/ERPNextApi.credentials.ts b/packages/nodes-base/credentials/ERPNextApi.credentials.ts index 9d9b35dc3be6e..f0ff8c5fb596b 100644 --- a/packages/nodes-base/credentials/ERPNextApi.credentials.ts +++ b/packages/nodes-base/credentials/ERPNextApi.credentials.ts @@ -83,7 +83,8 @@ export class ERPNextApi implements ICredentialType { }; test: ICredentialTestRequest = { request: { - baseURL: '={{$credentials.environment === "cloudHosted" ? "https://" + $credentials.subdomain + ".erpnext.com" : $credentials.domain}}', + baseURL: + '={{$credentials.environment === "cloudHosted" ? "https://" + $credentials.subdomain + ".erpnext.com" : $credentials.domain}}', url: '/api/resource/Doctype', skipSslCertificateValidation: '={{ $credentials.allowUnauthorizedCerts }}', }, diff --git a/packages/nodes-base/nodes/ActionNetwork/ActionNetwork.node.ts b/packages/nodes-base/nodes/ActionNetwork/ActionNetwork.node.ts index 259a4528e877f..575f5dae3a473 100644 --- a/packages/nodes-base/nodes/ActionNetwork/ActionNetwork.node.ts +++ b/packages/nodes-base/nodes/ActionNetwork/ActionNetwork.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -138,7 +136,6 @@ export class ActionNetwork implements INodeType { for (let i = 0; i < items.length; i++) { try { if (resource === 'attendance') { - // ********************************************************************** // attendance // ********************************************************************** @@ -146,7 +143,6 @@ export class ActionNetwork implements INodeType { // https://actionnetwork.org/docs/v2/attendances if (operation === 'create') { - // ---------------------------------------- // attendance: create // ---------------------------------------- @@ -158,9 +154,7 @@ export class ActionNetwork implements INodeType { const endpoint = `/events/${eventId}/attendances`; response = await actionNetworkApiRequest.call(this, 'POST', endpoint, body); - } else if (operation === 'get') { - // ---------------------------------------- // attendance: get // ---------------------------------------- @@ -170,9 +164,7 @@ export class ActionNetwork implements INodeType { const endpoint = `/events/${eventId}/attendances/${attendanceId}`; response = await actionNetworkApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // attendance: getAll // ---------------------------------------- @@ -181,11 +173,8 @@ export class ActionNetwork implements INodeType { const endpoint = `/events/${eventId}/attendances`; response = await handleListing.call(this, 'GET', endpoint); - } - } else if (resource === 'event') { - // ********************************************************************** // event // ********************************************************************** @@ -193,7 +182,6 @@ export class ActionNetwork implements INodeType { // https://actionnetwork.org/docs/v2/events if (operation === 'create') { - // ---------------------------------------- // event: create // ---------------------------------------- @@ -210,9 +198,7 @@ export class ActionNetwork implements INodeType { } response = await actionNetworkApiRequest.call(this, 'POST', '/events', body); - } else if (operation === 'get') { - // ---------------------------------------- // event: get // ---------------------------------------- @@ -220,19 +206,14 @@ export class ActionNetwork implements INodeType { const eventId = this.getNodeParameter('eventId', i); response = await actionNetworkApiRequest.call(this, 'GET', `/events/${eventId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // event: getAll // ---------------------------------------- response = await handleListing.call(this, 'GET', '/events'); - } - } else if (resource === 'person') { - // ********************************************************************** // person // ********************************************************************** @@ -240,7 +221,6 @@ export class ActionNetwork implements INodeType { // https://actionnetwork.org/docs/v2/people if (operation === 'create') { - // ---------------------------------------- // person: create // ---------------------------------------- @@ -260,27 +240,25 @@ export class ActionNetwork implements INodeType { } response = await actionNetworkApiRequest.call(this, 'POST', '/people', body); - } else if (operation === 'get') { - // ---------------------------------------- // person: get // ---------------------------------------- const personId = this.getNodeParameter('personId', i); - response = await actionNetworkApiRequest.call(this, 'GET', `/people/${personId}`) as PersonResponse; - + response = (await actionNetworkApiRequest.call( + this, + 'GET', + `/people/${personId}`, + )) as PersonResponse; } else if (operation === 'getAll') { - // ---------------------------------------- // person: getAll // ---------------------------------------- - response = await handleListing.call(this, 'GET', '/people') as PersonResponse[]; - + response = (await handleListing.call(this, 'GET', '/people')) as PersonResponse[]; } else if (operation === 'update') { - // ---------------------------------------- // person: update // ---------------------------------------- @@ -300,11 +278,8 @@ export class ActionNetwork implements INodeType { } response = await actionNetworkApiRequest.call(this, 'PUT', `/people/${personId}`, body); - } - } else if (resource === 'petition') { - // ********************************************************************** // petition // ********************************************************************** @@ -312,7 +287,6 @@ export class ActionNetwork implements INodeType { // https://actionnetwork.org/docs/v2/petitions if (operation === 'create') { - // ---------------------------------------- // petition: create // ---------------------------------------- @@ -329,9 +303,7 @@ export class ActionNetwork implements INodeType { } response = await actionNetworkApiRequest.call(this, 'POST', '/petitions', body); - } else if (operation === 'get') { - // ---------------------------------------- // petition: get // ---------------------------------------- @@ -340,17 +312,13 @@ export class ActionNetwork implements INodeType { const endpoint = `/petitions/${petitionId}`; response = await actionNetworkApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // petition: getAll // ---------------------------------------- response = await handleListing.call(this, 'GET', '/petitions'); - } else if (operation === 'update') { - // ---------------------------------------- // petition: update // ---------------------------------------- @@ -369,12 +337,14 @@ export class ActionNetwork implements INodeType { ); } - response = await actionNetworkApiRequest.call(this, 'PUT', `/petitions/${petitionId}`, body); - + response = await actionNetworkApiRequest.call( + this, + 'PUT', + `/petitions/${petitionId}`, + body, + ); } - } else if (resource === 'signature') { - // ********************************************************************** // signature // ********************************************************************** @@ -382,7 +352,6 @@ export class ActionNetwork implements INodeType { // https://actionnetwork.org/docs/v2/signatures if (operation === 'create') { - // ---------------------------------------- // signature: create // ---------------------------------------- @@ -400,9 +369,7 @@ export class ActionNetwork implements INodeType { const endpoint = `/petitions/${petitionId}/signatures`; response = await actionNetworkApiRequest.call(this, 'POST', endpoint, body); - } else if (operation === 'get') { - // ---------------------------------------- // signature: get // ---------------------------------------- @@ -412,9 +379,7 @@ export class ActionNetwork implements INodeType { const endpoint = `/petitions/${petitionId}/signatures/${signatureId}`; response = await actionNetworkApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // signature: getAll // ---------------------------------------- @@ -423,9 +388,7 @@ export class ActionNetwork implements INodeType { const endpoint = `/petitions/${petitionId}/signatures`; response = await handleListing.call(this, 'GET', endpoint); - } else if (operation === 'update') { - // ---------------------------------------- // signature: update // ---------------------------------------- @@ -447,11 +410,8 @@ export class ActionNetwork implements INodeType { const endpoint = `/petitions/${petitionId}/signatures/${signatureId}`; response = await actionNetworkApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'tag') { - // ********************************************************************** // tag // ********************************************************************** @@ -459,7 +419,6 @@ export class ActionNetwork implements INodeType { // https://actionnetwork.org/docs/v2/tags if (operation === 'create') { - // ---------------------------------------- // tag: create // ---------------------------------------- @@ -469,9 +428,7 @@ export class ActionNetwork implements INodeType { } as IDataObject; response = await actionNetworkApiRequest.call(this, 'POST', '/tags', body); - } else if (operation === 'get') { - // ---------------------------------------- // tag: get // ---------------------------------------- @@ -479,19 +436,14 @@ export class ActionNetwork implements INodeType { const tagId = this.getNodeParameter('tagId', i); response = await actionNetworkApiRequest.call(this, 'GET', `/tags/${tagId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // tag: getAll // ---------------------------------------- response = await handleListing.call(this, 'GET', '/tags'); - } - } else if (resource === 'personTag') { - // ********************************************************************** // personTag // ********************************************************************** @@ -499,7 +451,6 @@ export class ActionNetwork implements INodeType { // https://actionnetwork.org/docs/v2/taggings if (operation === 'add') { - // ---------------------------------------- // personTag: add // ---------------------------------------- @@ -511,9 +462,7 @@ export class ActionNetwork implements INodeType { const endpoint = `/tags/${tagId}/taggings`; response = await actionNetworkApiRequest.call(this, 'POST', endpoint, body); - } else if (operation === 'remove') { - // ---------------------------------------- // personTag: remove // ---------------------------------------- @@ -523,23 +472,19 @@ export class ActionNetwork implements INodeType { const endpoint = `/tags/${tagId}/taggings/${taggingId}`; response = await actionNetworkApiRequest.call(this, 'DELETE', endpoint); - } - } const simplify = this.getNodeParameter('simple', i, false) as boolean; if (simplify) { - response = operation === 'getAll' - ? response.map((i: Response) => simplifyResponse(i, resource)) - : simplifyResponse(response, resource); + response = + operation === 'getAll' + ? response.map((i: Response) => simplifyResponse(i, resource)) + : simplifyResponse(response, resource); } - Array.isArray(response) - ? returnData.push(...response) - : returnData.push(response); - + Array.isArray(response) ? returnData.push(...response) : returnData.push(response); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts b/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts index 72cf055931674..7582335adc471 100644 --- a/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts @@ -1,21 +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 { - flow, - omit, -} from 'lodash'; +import { flow, omit } from 'lodash'; import { AllFieldsUi, @@ -71,7 +60,7 @@ export async function handleListing( qs.perPage = 25; // max qs.page = 1; - const returnAll = options?.returnAll ?? this.getNodeParameter('returnAll', 0, false) as boolean; + const returnAll = options?.returnAll ?? (this.getNodeParameter('returnAll', 0, false) as boolean); const limit = this.getNodeParameter('limit', 0, 0) as number; const itemsKey = toItemsKey(endpoint); @@ -102,7 +91,6 @@ export async function handleListing( * Convert an endpoint to the key needed to access data in the response. */ const toItemsKey = (endpoint: string) => { - // handle two-resource endpoint if ( endpoint.includes('/signatures') || @@ -131,7 +119,6 @@ export const makeOsdiLink = (personId: string) => { export const isPrimary = (field: FieldWithPrimaryField) => field.primary; - // ---------------------------------------- // field adjusters // ---------------------------------------- @@ -150,9 +137,7 @@ function adjustPhoneNumbers(allFields: AllFieldsUi) { return { ...omit(allFields, ['phone_numbers']), - phone_numbers: [ - allFields.phone_numbers.phone_numbers_fields, - ], + phone_numbers: [allFields.phone_numbers.phone_numbers_fields], }; } @@ -209,7 +194,7 @@ function adjustLocation(allFields: AllFieldsUi) { function adjustTargets(allFields: AllFieldsUi) { if (!allFields.target) return allFields; - const adjusted = allFields.target.split(',').map(value => ({ name: value })); + const adjusted = allFields.target.split(',').map((value) => ({ name: value })); return { ...omit(allFields, ['target']), @@ -217,7 +202,6 @@ function adjustTargets(allFields: AllFieldsUi) { }; } - // ---------------------------------------- // payload adjusters // ---------------------------------------- @@ -232,7 +216,6 @@ export const adjustPetitionPayload = adjustTargets; export const adjustEventPayload = adjustLocation; - // ---------------------------------------- // resource loaders // ---------------------------------------- @@ -242,9 +225,10 @@ async function loadResource(this: ILoadOptionsFunctions, resource: string) { } export const resourceLoaders = { - async getTags(this: ILoadOptionsFunctions) { - const tags = await loadResource.call(this, 'tags') as Array<{ name: string } & LinksFieldContainer>; + const tags = (await loadResource.call(this, 'tags')) as Array< + { name: string } & LinksFieldContainer + >; return tags.map((tag) => ({ name: tag.name, value: extractId(tag) })); }, @@ -254,9 +238,14 @@ export const resourceLoaders = { const endpoint = `/tags/${tagId}/taggings`; // two-resource endpoint, so direct call - const taggings = await handleListing.call( - this, 'GET', endpoint, {}, {}, { returnAll: true }, - ) as LinksFieldContainer[]; + const taggings = (await handleListing.call( + this, + 'GET', + endpoint, + {}, + {}, + { returnAll: true }, + )) as LinksFieldContainer[]; return taggings.map((tagging) => { const taggingId = extractId(tagging); @@ -269,7 +258,6 @@ export const resourceLoaders = { }, }; - // ---------------------------------------- // response simplifiers // ---------------------------------------- @@ -281,12 +269,7 @@ export const simplifyResponse = (response: Response, resource: Resource) => { return simplifyPetitionResponse(response as PetitionResponse); } - const fieldsToSimplify = [ - 'identifiers', - '_links', - 'action_network:sponsor', - 'reminders', - ]; + const fieldsToSimplify = ['identifiers', '_links', 'action_network:sponsor', 'reminders']; return { id: extractId(response), @@ -294,14 +277,8 @@ export const simplifyResponse = (response: Response, resource: Resource) => { }; }; - const simplifyPetitionResponse = (response: PetitionResponse) => { - const fieldsToSimplify = [ - 'identifiers', - '_links', - 'action_network:hidden', - '_embedded', - ]; + const fieldsToSimplify = ['identifiers', '_links', 'action_network:hidden', '_embedded']; return { id: extractId(response), @@ -331,7 +308,7 @@ const simplifyPersonResponse = (response: PersonResponse) => { ...{ phone_number: phoneNumber[0].number || '' }, ...{ postal_address: { - ...postalAddress && omit(postalAddress[0], 'address_lines'), + ...(postalAddress && omit(postalAddress[0], 'address_lines')), address_lines: postalAddress[0].address_lines ?? '', }, }, diff --git a/packages/nodes-base/nodes/ActionNetwork/descriptions/AttendanceDescription.ts b/packages/nodes-base/nodes/ActionNetwork/descriptions/AttendanceDescription.ts index 0124675925ff5..2e498181859be 100644 --- a/packages/nodes-base/nodes/ActionNetwork/descriptions/AttendanceDescription.ts +++ b/packages/nodes-base/nodes/ActionNetwork/descriptions/AttendanceDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - makeSimpleField, -} from './SharedFields'; +import { makeSimpleField } from './SharedFields'; export const attendanceOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const attendanceOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'attendance', - ], + resource: ['attendance'], }, }, options: [ @@ -53,12 +47,8 @@ export const attendanceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'attendance', - ], - operation: [ - 'create', - ], + resource: ['attendance'], + operation: ['create'], }, }, }, @@ -71,12 +61,8 @@ export const attendanceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'attendance', - ], - operation: [ - 'create', - ], + resource: ['attendance'], + operation: ['create'], }, }, }, @@ -94,12 +80,8 @@ export const attendanceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'attendance', - ], - operation: [ - 'get', - ], + resource: ['attendance'], + operation: ['get'], }, }, }, @@ -112,12 +94,8 @@ export const attendanceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'attendance', - ], - operation: [ - 'get', - ], + resource: ['attendance'], + operation: ['get'], }, }, }, @@ -135,12 +113,8 @@ export const attendanceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'attendance', - ], - operation: [ - 'getAll', - ], + resource: ['attendance'], + operation: ['getAll'], }, }, }, @@ -152,12 +126,8 @@ export const attendanceFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'attendance', - ], - operation: [ - 'getAll', - ], + resource: ['attendance'], + operation: ['getAll'], }, }, }, @@ -172,15 +142,9 @@ export const attendanceFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'attendance', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['attendance'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/ActionNetwork/descriptions/EventDescription.ts b/packages/nodes-base/nodes/ActionNetwork/descriptions/EventDescription.ts index a13396d08a6e7..eb8af46a559f3 100644 --- a/packages/nodes-base/nodes/ActionNetwork/descriptions/EventDescription.ts +++ b/packages/nodes-base/nodes/ActionNetwork/descriptions/EventDescription.ts @@ -1,11 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - eventAdditionalFieldsOptions, - makeSimpleField, -} from './SharedFields'; +import { eventAdditionalFieldsOptions, makeSimpleField } from './SharedFields'; export const eventOperations: INodeProperties[] = [ { @@ -15,9 +10,7 @@ export const eventOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'event', - ], + resource: ['event'], }, }, options: [ @@ -54,12 +47,8 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'create', - ], + resource: ['event'], + operation: ['create'], }, }, }, @@ -72,12 +61,8 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'create', - ], + resource: ['event'], + operation: ['create'], }, }, }, @@ -90,12 +75,8 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'create', - ], + resource: ['event'], + operation: ['create'], }, }, options: eventAdditionalFieldsOptions, @@ -113,12 +94,8 @@ export const eventFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'get', - ], + resource: ['event'], + operation: ['get'], }, }, }, @@ -135,12 +112,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'], }, }, }, @@ -155,15 +128,9 @@ export const eventFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['event'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/ActionNetwork/descriptions/PersonDescription.ts b/packages/nodes-base/nodes/ActionNetwork/descriptions/PersonDescription.ts index 41797ef7479c5..4e4202a4c0906 100644 --- a/packages/nodes-base/nodes/ActionNetwork/descriptions/PersonDescription.ts +++ b/packages/nodes-base/nodes/ActionNetwork/descriptions/PersonDescription.ts @@ -1,11 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - makeSimpleField, - personAdditionalFieldsOptions, -} from './SharedFields'; +import { makeSimpleField, personAdditionalFieldsOptions } from './SharedFields'; export const personOperations: INodeProperties[] = [ { @@ -15,9 +10,7 @@ export const personOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'person', - ], + resource: ['person'], }, }, options: [ @@ -60,12 +53,8 @@ export const personFields: INodeProperties[] = [ description: 'Person’s email addresses', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'create', - ], + resource: ['person'], + operation: ['create'], }, }, options: [ @@ -78,14 +67,14 @@ export const personFields: INodeProperties[] = [ name: 'address', type: 'string', default: '', - description: 'Person\'s email address', + description: "Person's email address", }, { displayName: 'Primary', name: 'primary', type: 'hidden', default: true, - description: 'Whether this is the person\'s primary email address', + description: "Whether this is the person's primary email address", }, { displayName: 'Status', @@ -132,12 +121,8 @@ export const personFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'create', - ], + resource: ['person'], + operation: ['create'], }, }, options: personAdditionalFieldsOptions, @@ -155,12 +140,8 @@ export const personFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'get', - ], + resource: ['person'], + operation: ['get'], }, }, }, @@ -177,12 +158,8 @@ export const personFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'getAll', - ], + resource: ['person'], + operation: ['getAll'], }, }, }, @@ -198,15 +175,9 @@ export const personFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['person'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -224,12 +195,8 @@ export const personFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'update', - ], + resource: ['person'], + operation: ['update'], }, }, }, @@ -242,12 +209,8 @@ export const personFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'update', - ], + resource: ['person'], + operation: ['update'], }, }, options: personAdditionalFieldsOptions, diff --git a/packages/nodes-base/nodes/ActionNetwork/descriptions/PersonTagDescription.ts b/packages/nodes-base/nodes/ActionNetwork/descriptions/PersonTagDescription.ts index 4c47e1b0587ca..e14555f01aace 100644 --- a/packages/nodes-base/nodes/ActionNetwork/descriptions/PersonTagDescription.ts +++ b/packages/nodes-base/nodes/ActionNetwork/descriptions/PersonTagDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const personTagOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const personTagOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'personTag', - ], + resource: ['personTag'], }, }, options: [ @@ -38,7 +34,8 @@ export const personTagFields: INodeProperties[] = [ { displayName: 'Tag Name or ID', name: 'tagId', - description: 'ID of the tag to add. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the tag to add. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { loadOptionsMethod: 'getTags', @@ -47,12 +44,8 @@ export const personTagFields: INodeProperties[] = [ default: [], displayOptions: { show: { - resource: [ - 'personTag', - ], - operation: [ - 'add', - ], + resource: ['personTag'], + operation: ['add'], }, }, }, @@ -65,12 +58,8 @@ export const personTagFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'personTag', - ], - operation: [ - 'add', - ], + resource: ['personTag'], + operation: ['add'], }, }, }, @@ -81,7 +70,8 @@ export const personTagFields: INodeProperties[] = [ { displayName: 'Tag Name or ID', name: 'tagId', - description: 'ID of the tag whose tagging to delete. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the tag whose tagging to delete. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { loadOptionsMethod: 'getTags', @@ -90,36 +80,27 @@ export const personTagFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'personTag', - ], - operation: [ - 'remove', - ], + resource: ['personTag'], + operation: ['remove'], }, }, }, { displayName: 'Tagging Name or ID', name: 'taggingId', - description: 'ID of the tagging to remove. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the tagging to remove. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'tagId', - ], + loadOptionsDependsOn: ['tagId'], loadOptionsMethod: 'getTaggings', }, required: true, default: [], displayOptions: { show: { - resource: [ - 'personTag', - ], - operation: [ - 'remove', - ], + resource: ['personTag'], + operation: ['remove'], }, }, }, diff --git a/packages/nodes-base/nodes/ActionNetwork/descriptions/PetitionDescription.ts b/packages/nodes-base/nodes/ActionNetwork/descriptions/PetitionDescription.ts index 9a83e21b554d2..463a4851808b5 100644 --- a/packages/nodes-base/nodes/ActionNetwork/descriptions/PetitionDescription.ts +++ b/packages/nodes-base/nodes/ActionNetwork/descriptions/PetitionDescription.ts @@ -1,11 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - makeSimpleField, - petitionAdditionalFieldsOptions, -} from './SharedFields'; +import { makeSimpleField, petitionAdditionalFieldsOptions } from './SharedFields'; export const petitionOperations: INodeProperties[] = [ { @@ -15,9 +10,7 @@ export const petitionOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'petition', - ], + resource: ['petition'], }, }, options: [ @@ -59,12 +52,8 @@ export const petitionFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'petition', - ], - operation: [ - 'create', - ], + resource: ['petition'], + operation: ['create'], }, }, }, @@ -77,12 +66,8 @@ export const petitionFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'petition', - ], - operation: [ - 'create', - ], + resource: ['petition'], + operation: ['create'], }, }, }, @@ -95,12 +80,8 @@ export const petitionFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'petition', - ], - operation: [ - 'create', - ], + resource: ['petition'], + operation: ['create'], }, }, options: petitionAdditionalFieldsOptions, @@ -118,12 +99,8 @@ export const petitionFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'petition', - ], - operation: [ - 'get', - ], + resource: ['petition'], + operation: ['get'], }, }, }, @@ -140,12 +117,8 @@ export const petitionFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'petition', - ], - operation: [ - 'getAll', - ], + resource: ['petition'], + operation: ['getAll'], }, }, }, @@ -160,15 +133,9 @@ export const petitionFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'petition', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['petition'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -186,12 +153,8 @@ export const petitionFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'petition', - ], - operation: [ - 'update', - ], + resource: ['petition'], + operation: ['update'], }, }, }, @@ -204,12 +167,8 @@ export const petitionFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'petition', - ], - operation: [ - 'update', - ], + resource: ['petition'], + operation: ['update'], }, }, options: petitionAdditionalFieldsOptions, diff --git a/packages/nodes-base/nodes/ActionNetwork/descriptions/SharedFields.ts b/packages/nodes-base/nodes/ActionNetwork/descriptions/SharedFields.ts index bb177112944d1..99e6995b011e3 100644 --- a/packages/nodes-base/nodes/ActionNetwork/descriptions/SharedFields.ts +++ b/packages/nodes-base/nodes/ActionNetwork/descriptions/SharedFields.ts @@ -1,11 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - Operation, - Resource, -} from '../types'; +import { Operation, Resource } from '../types'; export const languageOptions: INodeProperties['options'] = [ { @@ -80,21 +75,22 @@ const postalAddressesFields: INodeProperties[] = [ name: 'primary', type: 'boolean', default: false, - description: 'Whether this is the person\'s primary address', + description: "Whether this is the person's primary address", }, { displayName: 'Address Line', name: 'address_lines', type: 'string', // The Action Network API expects a string array but ignores any string beyond the first, so this input field is simplified to string. default: '', - description: 'Line for a person\'s address', + description: "Line for a person's address", }, { displayName: 'Locality', name: 'locality', type: 'string', default: '', - description: 'City or other local administrative area. If blank, this will be filled in based on Action Network\'s geocoding.', + description: + "City or other local administrative area. If blank, this will be filled in based on Action Network's geocoding.", }, { displayName: 'Region', @@ -188,7 +184,7 @@ export const eventAdditionalFieldsOptions: INodeProperties['options'] = [ name: 'instructions', type: 'string', default: '', - description: 'Event\'s instructions for activists, visible after they RSVP. HTML supported.', + description: "Event's instructions for activists, visible after they RSVP. HTML supported.", }, { displayName: 'Location', @@ -265,14 +261,14 @@ export const personAdditionalFieldsOptions: INodeProperties['options'] = [ name: 'number', type: 'string', default: '', - description: 'Person\'s mobile number, in international format without the plus sign', + description: "Person's mobile number, in international format without the plus sign", }, { displayName: 'Primary', name: 'primary', type: 'hidden', default: true, - description: 'Whether this is the person\'s primary phone number', + description: "Whether this is the person's primary phone number", }, { displayName: 'Status', @@ -367,12 +363,8 @@ export const makeSimpleField = (resource: Resource, operation: Operation): INode type: 'boolean', displayOptions: { show: { - resource: [ - resource, - ], - operation: [ - operation, - ], + resource: [resource], + operation: [operation], }, }, default: true, diff --git a/packages/nodes-base/nodes/ActionNetwork/descriptions/SignatureDescription.ts b/packages/nodes-base/nodes/ActionNetwork/descriptions/SignatureDescription.ts index ba8414365820c..f86d867c5fcee 100644 --- a/packages/nodes-base/nodes/ActionNetwork/descriptions/SignatureDescription.ts +++ b/packages/nodes-base/nodes/ActionNetwork/descriptions/SignatureDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - makeSimpleField, -} from './SharedFields'; +import { makeSimpleField } from './SharedFields'; export const signatureOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const signatureOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'signature', - ], + resource: ['signature'], }, }, options: [ @@ -58,12 +52,8 @@ export const signatureFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'signature', - ], - operation: [ - 'create', - ], + resource: ['signature'], + operation: ['create'], }, }, }, @@ -76,12 +66,8 @@ export const signatureFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'signature', - ], - operation: [ - 'create', - ], + resource: ['signature'], + operation: ['create'], }, }, }, @@ -94,12 +80,8 @@ export const signatureFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'signature', - ], - operation: [ - 'create', - ], + resource: ['signature'], + operation: ['create'], }, }, options: [ @@ -125,12 +107,8 @@ export const signatureFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'signature', - ], - operation: [ - 'get', - ], + resource: ['signature'], + operation: ['get'], }, }, }, @@ -143,12 +121,8 @@ export const signatureFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'signature', - ], - operation: [ - 'get', - ], + resource: ['signature'], + operation: ['get'], }, }, }, @@ -166,12 +140,8 @@ export const signatureFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'signature', - ], - operation: [ - 'getAll', - ], + resource: ['signature'], + operation: ['getAll'], }, }, }, @@ -183,12 +153,8 @@ export const signatureFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'signature', - ], - operation: [ - 'getAll', - ], + resource: ['signature'], + operation: ['getAll'], }, }, }, @@ -203,15 +169,9 @@ export const signatureFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'signature', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['signature'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -229,12 +189,8 @@ export const signatureFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'signature', - ], - operation: [ - 'update', - ], + resource: ['signature'], + operation: ['update'], }, }, }, @@ -247,12 +203,8 @@ export const signatureFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'signature', - ], - operation: [ - 'update', - ], + resource: ['signature'], + operation: ['update'], }, }, }, @@ -265,12 +217,8 @@ export const signatureFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'signature', - ], - operation: [ - 'update', - ], + resource: ['signature'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/ActionNetwork/descriptions/TagDescription.ts b/packages/nodes-base/nodes/ActionNetwork/descriptions/TagDescription.ts index 8da632c7ab331..cc50219116a4c 100644 --- a/packages/nodes-base/nodes/ActionNetwork/descriptions/TagDescription.ts +++ b/packages/nodes-base/nodes/ActionNetwork/descriptions/TagDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - makeSimpleField, -} from './SharedFields'; +import { makeSimpleField } from './SharedFields'; export const tagOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const tagOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'tag', - ], + resource: ['tag'], }, }, options: [ @@ -53,12 +47,8 @@ export const tagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'create', - ], + resource: ['tag'], + operation: ['create'], }, }, }, @@ -76,12 +66,8 @@ export const tagFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'get', - ], + resource: ['tag'], + operation: ['get'], }, }, }, @@ -98,12 +84,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'], }, }, }, @@ -118,15 +100,9 @@ export const tagFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['tag'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/ActionNetwork/types.d.ts b/packages/nodes-base/nodes/ActionNetwork/types.d.ts index 3fcb13c05f458..72e79cd5b9910 100644 --- a/packages/nodes-base/nodes/ActionNetwork/types.d.ts +++ b/packages/nodes-base/nodes/ActionNetwork/types.d.ts @@ -1,12 +1,18 @@ import { languageOptions } from './descriptions/SharedFields'; -export type Resource = 'attendance' | 'event' | 'person' | 'personTag' | 'petition' | 'signature' | 'tag'; +export type Resource = + | 'attendance' + | 'event' + | 'person' + | 'personTag' + | 'petition' + | 'signature' + | 'tag'; export type Operation = 'create' | 'delete' | 'get' | 'getAll' | 'update' | 'add' | 'remove'; // @ts-ignore -export type LanguageCodes = typeof languageOptions[number]['value'] - +export type LanguageCodes = typeof languageOptions[number]['value']; // ---------------------------------------- // UI fields @@ -19,25 +25,25 @@ export type AllFieldsUi = { languages_spoken: LanguageCodes; target: string; location: LocationUi; -} +}; export type EmailAddressUi = { - email_addresses_fields: EmailAddressField, -} + email_addresses_fields: EmailAddressField; +}; export type EmailAddressField = { primary: boolean; address: string; status: EmailStatus; -} +}; type BaseStatus = 'subscribed' | 'unsubscribed' | 'bouncing' | 'previous bounce'; type EmailStatus = BaseStatus | 'spam complaint' | 'previous spam complaint'; type PhoneNumberUi = { - phone_numbers_fields: PhoneNumberField[], -} + phone_numbers_fields: PhoneNumberField[]; +}; export type PhoneNumberField = { primary: boolean; @@ -46,12 +52,12 @@ export type PhoneNumberField = { }; type PostalAddressesUi = { - postal_addresses_fields: PostalAddressField[], -} + postal_addresses_fields: PostalAddressField[]; +}; type LocationUi = { - postal_addresses_fields: PostalAddressField, -} + postal_addresses_fields: PostalAddressField; +}; export type PostalAddressField = { primary: boolean; @@ -61,17 +67,16 @@ export type PostalAddressField = { postal_code: string; country: string; language: LanguageCodes; - location: { location_fields: LatitudeLongitude } -} + location: { location_fields: LatitudeLongitude }; +}; type LatitudeLongitude = { latitude: string; longitude: string; -} +}; export type FieldWithPrimaryField = EmailAddressField | PhoneNumberField | PostalAddressField; - // ---------------------------------------- // responses // ---------------------------------------- @@ -90,7 +95,6 @@ export type PersonResponse = Response & { export type PetitionResponse = Response & { _embedded: { 'osdi:creator': PersonResponse } }; - // ---------------------------------------- // utils // ---------------------------------------- diff --git a/packages/nodes-base/nodes/ActiveCampaign/AccountContactDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/AccountContactDescription.ts index 531eef179349f..fa6a7c8e65584 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/AccountContactDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/AccountContactDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const accountContactOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const accountContactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'accountContact', - ], + resource: ['accountContact'], }, }, options: [ @@ -51,12 +47,8 @@ export const accountContactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'accountContact', - ], + operation: ['create'], + resource: ['accountContact'], }, }, }, @@ -68,12 +60,8 @@ export const accountContactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'accountContact', - ], + operation: ['create'], + resource: ['accountContact'], }, }, }, @@ -84,12 +72,8 @@ export const accountContactFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'accountContact', - ], + operation: ['create'], + resource: ['accountContact'], }, }, default: {}, @@ -112,12 +96,8 @@ export const accountContactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'accountContact', - ], + operation: ['delete'], + resource: ['accountContact'], }, }, default: 0, @@ -135,12 +115,8 @@ export const accountContactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'accountContact', - ], + operation: ['update'], + resource: ['accountContact'], }, }, description: 'Account ID', @@ -154,12 +130,8 @@ export const accountContactFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'accountContact', - ], + operation: ['update'], + resource: ['accountContact'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/ActiveCampaign/AccountDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/AccountDescription.ts index c028c0752d905..2ab11a78153bc 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/AccountDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/AccountDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - activeCampaignDefaultGetAllProperties, -} from './GenericFunctions'; +import { activeCampaignDefaultGetAllProperties } from './GenericFunctions'; export const accountOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const accountOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'account', - ], + resource: ['account'], }, }, options: [ @@ -67,15 +61,11 @@ export const accountFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'account', - ], + operation: ['create'], + resource: ['account'], }, }, - description: 'Account\'s name', + description: "Account's name", }, { displayName: 'Additional Fields', @@ -84,12 +74,8 @@ export const accountFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'account', - ], + operation: ['create'], + resource: ['account'], }, }, default: {}, @@ -99,7 +85,7 @@ export const accountFields: INodeProperties[] = [ name: 'accountUrl', type: 'string', default: '', - description: 'Account\'s website', + description: "Account's website", }, { displayName: 'Fields', @@ -124,7 +110,8 @@ export const accountFields: INodeProperties[] = [ loadOptionsMethod: 'getAccountCustomFields', }, 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', @@ -149,12 +136,8 @@ export const accountFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'account', - ], + operation: ['update'], + resource: ['account'], }, }, default: 0, @@ -169,12 +152,8 @@ export const accountFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'account', - ], + operation: ['update'], + resource: ['account'], }, }, default: {}, @@ -184,14 +163,14 @@ export const accountFields: INodeProperties[] = [ name: 'name', type: 'string', default: '', - description: 'Account\'s name', + description: "Account's name", }, { displayName: 'Account URL', name: 'accountUrl', type: 'string', default: '', - description: 'Account\'s website', + description: "Account's website", }, { displayName: 'Fields', @@ -216,7 +195,8 @@ export const accountFields: INodeProperties[] = [ loadOptionsMethod: 'getAccountCustomFields', }, 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', @@ -240,12 +220,8 @@ export const accountFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'account', - ], + operation: ['delete'], + resource: ['account'], }, }, default: 0, @@ -261,12 +237,8 @@ export const accountFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'account', - ], + operation: ['get'], + resource: ['account'], }, }, default: 0, @@ -284,12 +256,8 @@ export const accountFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'account', - ], + operation: ['getAll'], + resource: ['account'], }, }, default: {}, @@ -303,5 +271,4 @@ export const accountFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index d4d5957e7f6e4..f557e8f9661d0 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -18,65 +16,32 @@ import { IProduct, } from './GenericFunctions'; -import { - contactFields, - contactOperations, -} from './ContactDescription'; +import { contactFields, contactOperations } from './ContactDescription'; -import { - dealFields, - dealOperations, -} from './DealDescription'; +import { dealFields, dealOperations } from './DealDescription'; -import { - ecomOrderFields, - ecomOrderOperations, -} from './EcomOrderDescription'; +import { ecomOrderFields, ecomOrderOperations } from './EcomOrderDescription'; -import { - ecomCustomerFields, - ecomCustomerOperations, -} from './EcomCustomerDescription'; +import { ecomCustomerFields, ecomCustomerOperations } from './EcomCustomerDescription'; import { ecomOrderProductsFields, ecomOrderProductsOperations, } from './EcomOrderProductsDescription'; -import { - connectionFields, - connectionOperations, -} from './ConnectionDescription'; +import { connectionFields, connectionOperations } from './ConnectionDescription'; -import { - accountFields, - accountOperations -} from './AccountDescription'; +import { accountFields, accountOperations } from './AccountDescription'; -import { - tagFields, - tagOperations -} from './TagDescription'; +import { tagFields, tagOperations } from './TagDescription'; -import { - accountContactFields, - accountContactOperations -} from './AccountContactDescription'; +import { accountContactFields, accountContactOperations } from './AccountContactDescription'; -import { - contactListFields, - contactListOperations, -} from './ContactListDescription'; +import { contactListFields, contactListOperations } from './ContactListDescription'; -import { - contactTagFields, - contactTagOperations, -} from './ContactTagDescription'; +import { contactTagFields, contactTagOperations } from './ContactTagDescription'; -import { - listFields, - listOperations, -} from './ListDescription'; +import { listFields, listOperations } from './ListDescription'; interface CustomProperty { name: string; @@ -91,13 +56,23 @@ 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 if (key === 'fieldValues' && (additionalFields.fieldValues as IDataObject).property !== undefined) { + } else if ( + key === 'fieldValues' && + (additionalFields.fieldValues as IDataObject).property !== undefined + ) { body.fieldValues = (additionalFields.fieldValues as IDataObject).property; - } else if (key === 'fields' && (additionalFields.fields as IDataObject).property !== undefined) { + } else if ( + key === 'fields' && + (additionalFields.fields as IDataObject).property !== undefined + ) { body.fields = (additionalFields.fields as IDataObject).property; } else { body[key] = additionalFields[key]; @@ -263,7 +238,6 @@ export class ActiveCampaign implements INodeType { // ecommerceOrderProducts // ---------------------------------- ...ecomOrderProductsFields, - ], }; @@ -273,7 +247,13 @@ export class ActiveCampaign implements INodeType { // select them easily async getContactCustomFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { fields } = await activeCampaignApiRequest.call(this, 'GET', '/api/3/fields', {}, { limit: 100 }); + const { fields } = await activeCampaignApiRequest.call( + this, + 'GET', + '/api/3/fields', + {}, + { limit: 100 }, + ); for (const field of fields) { const fieldName = field.title; const fieldId = field.id; @@ -288,7 +268,13 @@ export class ActiveCampaign implements INodeType { // select them easily async getAccountCustomFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { accountCustomFieldMeta: fields } = await activeCampaignApiRequest.call(this, 'GET', '/api/3/accountCustomFieldMeta', {}, { limit: 100 }); + const { accountCustomFieldMeta: fields } = await activeCampaignApiRequest.call( + this, + 'GET', + '/api/3/accountCustomFieldMeta', + {}, + { limit: 100 }, + ); for (const field of fields) { const fieldName = field.fieldLabel; const fieldId = field.id; @@ -303,7 +289,13 @@ export class ActiveCampaign implements INodeType { // select them easily async getTags(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { tags } = await activeCampaignApiRequest.call(this, 'GET', '/api/3/tags', {}, { limit: 100 }); + const { tags } = await activeCampaignApiRequest.call( + this, + 'GET', + '/api/3/tags', + {}, + { limit: 100 }, + ); for (const tag of tags) { returnData.push({ name: tag.tag, @@ -334,7 +326,6 @@ export class ActiveCampaign implements INodeType { for (let i = 0; i < items.length; i++) { try { - dataKey = undefined; resource = this.getNodeParameter('resource', 0) as string; operation = this.getNodeParameter('operation', 0) as string; @@ -367,7 +358,6 @@ export class ActiveCampaign implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body.contact as IDataObject, additionalFields); - } else if (operation === 'delete') { // ---------------------------------- // contact:delete @@ -377,7 +367,6 @@ export class ActiveCampaign implements INodeType { const contactId = this.getNodeParameter('contactId', i) as number; endpoint = `/api/3/contacts/${contactId}`; - } else if (operation === 'get') { // ---------------------------------- // contact:get @@ -387,7 +376,6 @@ export class ActiveCampaign implements INodeType { const contactId = this.getNodeParameter('contactId', i) as number; endpoint = `/api/3/contacts/${contactId}`; - } else if (operation === 'getAll') { // ---------------------------------- // contacts:getAll @@ -415,7 +403,6 @@ export class ActiveCampaign implements INodeType { } endpoint = `/api/3/contacts`; - } else if (operation === 'update') { // ---------------------------------- // contact:update @@ -432,9 +419,12 @@ export class ActiveCampaign implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; addAdditionalFields(body.contact as IDataObject, 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 === 'account') { if (operation === 'create') { @@ -454,7 +444,6 @@ export class ActiveCampaign implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body.account as IDataObject, additionalFields); - } else if (operation === 'delete') { // ---------------------------------- // account:delete @@ -464,7 +453,6 @@ export class ActiveCampaign implements INodeType { const accountId = this.getNodeParameter('accountId', i) as number; endpoint = `/api/3/accounts/${accountId}`; - } else if (operation === 'get') { // ---------------------------------- // account:get @@ -474,7 +462,6 @@ export class ActiveCampaign implements INodeType { const accountId = this.getNodeParameter('accountId', i) as number; endpoint = `/api/3/accounts/${accountId}`; - } else if (operation === 'getAll') { // ---------------------------------- // account:getAll @@ -496,7 +483,6 @@ export class ActiveCampaign implements INodeType { const filters = this.getNodeParameter('filters', i) as IDataObject; Object.assign(qs, filters); - } else if (operation === 'update') { // ---------------------------------- // account:update @@ -513,9 +499,12 @@ export class ActiveCampaign implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; addAdditionalFields(body.account as IDataObject, 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 === 'accountContact') { if (operation === 'create') { @@ -536,7 +525,6 @@ export class ActiveCampaign implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body.account as IDataObject, additionalFields); - } else if (operation === 'update') { // ---------------------------------- // accountContact:update @@ -553,7 +541,6 @@ export class ActiveCampaign implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; addAdditionalFields(body.accountContact as IDataObject, updateFields); - } else if (operation === 'delete') { // ---------------------------------- // accountContact:delete @@ -563,9 +550,12 @@ export class ActiveCampaign implements INodeType { const accountContactId = this.getNodeParameter('accountContactId', i) as number; endpoint = `/api/3/accountContacts/${accountContactId}`; - } 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 === 'contactTag') { if (operation === 'add') { @@ -583,7 +573,6 @@ export class ActiveCampaign implements INodeType { contact: this.getNodeParameter('contactId', i) as string, tag: this.getNodeParameter('tagId', i) as string, } as IDataObject; - } else if (operation === 'remove') { // ---------------------------------- // contactTag:remove @@ -593,9 +582,12 @@ export class ActiveCampaign implements INodeType { const contactTagId = this.getNodeParameter('contactTagId', i) as number; endpoint = `/api/3/contactTags/${contactTagId}`; - } 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 === 'contactList') { if (operation === 'add') { @@ -614,7 +606,6 @@ export class ActiveCampaign implements INodeType { contact: this.getNodeParameter('contactId', i) as string, status: 1, } as IDataObject; - } else if (operation === 'remove') { // ---------------------------------- // contactList:remove @@ -631,9 +622,12 @@ export class ActiveCampaign implements INodeType { } as IDataObject; dataKey = 'contacts'; - } 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 === 'getAll') { @@ -646,7 +640,6 @@ export class ActiveCampaign implements INodeType { returnAll = this.getNodeParameter('returnAll', i) as boolean; const simple = this.getNodeParameter('simple', i, true) as boolean; - if (returnAll === false) { qs.limit = this.getNodeParameter('limit', i) as number; } @@ -657,7 +650,6 @@ export class ActiveCampaign implements INodeType { endpoint = `/api/3/lists`; } - } else if (resource === 'tag') { if (operation === 'create') { // ---------------------------------- @@ -677,7 +669,6 @@ export class ActiveCampaign implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body.tag as IDataObject, additionalFields); - } else if (operation === 'delete') { // ---------------------------------- // tag:delete @@ -687,7 +678,6 @@ export class ActiveCampaign implements INodeType { const tagId = this.getNodeParameter('tagId', i) as number; endpoint = `/api/3/tags/${tagId}`; - } else if (operation === 'get') { // ---------------------------------- // tag:get @@ -697,7 +687,6 @@ export class ActiveCampaign implements INodeType { const tagId = this.getNodeParameter('tagId', i) as number; endpoint = `/api/3/tags/${tagId}`; - } else if (operation === 'getAll') { // ---------------------------------- // tags:getAll @@ -716,7 +705,6 @@ export class ActiveCampaign implements INodeType { } endpoint = `/api/3/tags`; - } else if (operation === 'update') { // ---------------------------------- // tags:update @@ -733,9 +721,12 @@ export class ActiveCampaign implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; addAdditionalFields(body.tag as IDataObject, 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 === 'deal') { if (operation === 'create') { @@ -771,7 +762,6 @@ export class ActiveCampaign implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body.deal as IDataObject, additionalFields); - } else if (operation === 'update') { // ---------------------------------- // deal:update @@ -786,7 +776,6 @@ export class ActiveCampaign implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; addAdditionalFields(body.deal as IDataObject, updateFields); - } else if (operation === 'delete') { // ---------------------------------- // deal:delete @@ -796,7 +785,6 @@ export class ActiveCampaign implements INodeType { const dealId = this.getNodeParameter('dealId', i) as number; endpoint = `/api/3/deals/${dealId}`; - } else if (operation === 'get') { // ---------------------------------- // deal:get @@ -806,7 +794,6 @@ export class ActiveCampaign implements INodeType { const dealId = this.getNodeParameter('dealId', i) as number; endpoint = `/api/3/deals/${dealId}`; - } else if (operation === 'getAll') { // ---------------------------------- // deals:getAll @@ -825,7 +812,6 @@ export class ActiveCampaign implements INodeType { } endpoint = `/api/3/deals`; - } else if (operation === 'createNote') { // ---------------------------------- // deal:createNote @@ -838,7 +824,6 @@ export class ActiveCampaign implements INodeType { const dealId = this.getNodeParameter('dealId', i) as number; endpoint = `/api/3/deals/${dealId}/notes`; - } else if (operation === 'updateNote') { // ---------------------------------- // deal:updateNote @@ -852,9 +837,12 @@ export class ActiveCampaign implements INodeType { const dealId = this.getNodeParameter('dealId', i) as number; const dealNoteId = this.getNodeParameter('dealNoteId', i) as number; endpoint = `/api/3/deals/${dealId}/notes/${dealNoteId}`; - } 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 === 'connection') { if (operation === 'create') { @@ -873,7 +861,6 @@ export class ActiveCampaign implements INodeType { logoUrl: this.getNodeParameter('logoUrl', i) as string, linkUrl: this.getNodeParameter('linkUrl', i) as string, } as IDataObject; - } else if (operation === 'update') { // ---------------------------------- // connection:update @@ -888,7 +875,6 @@ export class ActiveCampaign implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; addAdditionalFields(body.connection as IDataObject, updateFields); - } else if (operation === 'delete') { // ---------------------------------- // connection:delete @@ -898,7 +884,6 @@ export class ActiveCampaign implements INodeType { const connectionId = this.getNodeParameter('connectionId', i) as number; endpoint = `/api/3/connections/${connectionId}`; - } else if (operation === 'get') { // ---------------------------------- // connection:get @@ -908,7 +893,6 @@ export class ActiveCampaign implements INodeType { const connectionId = this.getNodeParameter('connectionId', i) as number; endpoint = `/api/3/connections/${connectionId}`; - } else if (operation === 'getAll') { // ---------------------------------- // connections:getAll @@ -927,9 +911,12 @@ export class ActiveCampaign implements INodeType { } endpoint = `/api/3/connections`; - } 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 === 'ecommerceOrder') { if (operation === 'create') { @@ -966,12 +953,14 @@ export class ActiveCampaign implements INodeType { addAdditionalFields(body.ecomOrder as IDataObject, { abandonedDate }); } - const orderProducts = this.getNodeParameter('orderProducts', i) as unknown as IProduct[]; + const orderProducts = this.getNodeParameter( + 'orderProducts', + i, + ) as unknown as IProduct[]; addAdditionalFields(body.ecomOrder as IDataObject, { orderProducts }); const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; addAdditionalFields(body.ecomOrder as IDataObject, additionalFields); - } else if (operation === 'update') { // ---------------------------------- // ecommerceOrder:update @@ -986,7 +975,6 @@ export class ActiveCampaign implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; addAdditionalFields(body.ecomOrder as IDataObject, updateFields); - } else if (operation === 'delete') { // ---------------------------------- // ecommerceOrder:delete @@ -996,7 +984,6 @@ export class ActiveCampaign implements INodeType { const orderId = this.getNodeParameter('orderId', i) as number; endpoint = `/api/3/ecomOrders/${orderId}`; - } else if (operation === 'get') { // ---------------------------------- // ecommerceOrder:get @@ -1006,7 +993,6 @@ export class ActiveCampaign implements INodeType { const orderId = this.getNodeParameter('orderId', i) as number; endpoint = `/api/3/ecomOrders/${orderId}`; - } else if (operation === 'getAll') { // ---------------------------------- // ecommerceOrders:getAll @@ -1025,9 +1011,12 @@ export class ActiveCampaign implements INodeType { } endpoint = `/api/3/ecomOrders`; - } 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 === 'ecommerceCustomer') { if (operation === 'create') { @@ -1054,7 +1043,6 @@ export class ActiveCampaign implements INodeType { } } addAdditionalFields(body.ecomCustomer as IDataObject, additionalFields); - } else if (operation === 'update') { // ---------------------------------- // ecommerceCustomer:update @@ -1076,7 +1064,6 @@ export class ActiveCampaign implements INodeType { } } addAdditionalFields(body.ecomCustomer as IDataObject, updateFields); - } else if (operation === 'delete') { // ---------------------------------- // ecommerceCustomer:delete @@ -1086,7 +1073,6 @@ export class ActiveCampaign implements INodeType { const ecommerceCustomerId = this.getNodeParameter('ecommerceCustomerId', i) as number; endpoint = `/api/3/ecomCustomers/${ecommerceCustomerId}`; - } else if (operation === 'get') { // ---------------------------------- // ecommerceCustomer:get @@ -1096,7 +1082,6 @@ export class ActiveCampaign implements INodeType { const ecommerceCustomerId = this.getNodeParameter('ecommerceCustomerId', i) as number; endpoint = `/api/3/ecomCustomers/${ecommerceCustomerId}`; - } else if (operation === 'getAll') { // ---------------------------------- // ecommerceCustomers:getAll @@ -1115,9 +1100,12 @@ export class ActiveCampaign implements INodeType { } endpoint = `/api/3/ecomCustomers`; - } 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 === 'ecommerceOrderProducts') { if (operation === 'getByProductId') { @@ -1129,8 +1117,6 @@ export class ActiveCampaign implements INodeType { const procuctId = this.getNodeParameter('procuctId', i) as number; endpoint = `/api/3/ecomOrderProducts/${procuctId}`; - - } else if (operation === 'getByOrderId') { // ---------------------------------- // ecommerceOrderProducts:getByOrderId @@ -1142,7 +1128,6 @@ export class ActiveCampaign implements INodeType { const orderId = this.getNodeParameter('orderId', i) as number; endpoint = `/api/3/ecomOrders/${orderId}/orderProducts`; - } else if (operation === 'getAll') { // ---------------------------------- // ecommerceOrderProductss:getAll @@ -1161,20 +1146,38 @@ export class ActiveCampaign implements INodeType { } endpoint = `/api/3/ecomOrderProducts`; - } 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, + }); } let responseData; if (returnAll === true) { - responseData = await activeCampaignApiRequestAllItems.call(this, requestMethod, endpoint, body, qs, dataKey); + responseData = await activeCampaignApiRequestAllItems.call( + this, + requestMethod, + endpoint, + body, + qs, + dataKey, + ); } else { - responseData = await activeCampaignApiRequest.call(this, requestMethod, endpoint, body, qs, dataKey); + responseData = await activeCampaignApiRequest.call( + this, + requestMethod, + endpoint, + body, + qs, + dataKey, + ); } if (resource === 'contactList' && operation === 'add' && responseData === undefined) { diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaignTrigger.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaignTrigger.node.ts index e575f62f7d0fb..75d13187e07f9 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaignTrigger.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaignTrigger.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 { IWebhookResponseData, } from 'n8n-workflow'; -import { - activeCampaignApiRequest, - activeCampaignApiRequestAllItems, -} from './GenericFunctions'; +import { activeCampaignApiRequest, activeCampaignApiRequestAllItems } from './GenericFunctions'; export class ActiveCampaignTrigger implements INodeType { description: INodeTypeDescription = { @@ -50,7 +44,8 @@ export class ActiveCampaignTrigger 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', typeOptions: { loadOptionsMethod: 'getEvents', }, @@ -93,7 +88,14 @@ export class ActiveCampaignTrigger implements INodeType { // select them easily async getEvents(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const events = await activeCampaignApiRequestAllItems.call(this, 'GET', '/api/3/webhook/events', {}, {}, 'webhookEvents'); + const events = await activeCampaignApiRequestAllItems.call( + this, + 'GET', + '/api/3/webhook/events', + {}, + {}, + 'webhookEvents', + ); for (const event of events) { const eventName = event; const eventId = event; @@ -135,14 +137,24 @@ export class ActiveCampaignTrigger implements INodeType { sources, }, }; - const { webhook } = await activeCampaignApiRequest.call(this, 'POST', '/api/3/webhooks', body); + const { webhook } = await activeCampaignApiRequest.call( + this, + 'POST', + '/api/3/webhooks', + body, + ); webhookData.webhookId = webhook.id; return true; }, async delete(this: IHookFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); try { - await activeCampaignApiRequest.call(this, 'DELETE', `/api/3/webhooks/${webhookData.webhookId}`, {}); + await activeCampaignApiRequest.call( + this, + 'DELETE', + `/api/3/webhooks/${webhookData.webhookId}`, + {}, + ); } catch (error) { return false; } @@ -155,9 +167,7 @@ export class ActiveCampaignTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts index f85f799853566..ca6df7e9bafd7 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ConnectionDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - activeCampaignDefaultGetAllProperties, -} from './GenericFunctions'; +import { activeCampaignDefaultGetAllProperties } from './GenericFunctions'; export const connectionOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const connectionOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'connection', - ], + resource: ['connection'], }, }, options: [ @@ -53,7 +47,6 @@ export const connectionOperations: INodeProperties[] = [ ], default: 'create', }, - ]; export const connectionFields: INodeProperties[] = [ @@ -68,12 +61,8 @@ export const connectionFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'connection', - ], + operation: ['create'], + resource: ['connection'], }, }, description: 'The name of the service', @@ -86,12 +75,8 @@ export const connectionFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'connection', - ], + operation: ['create'], + resource: ['connection'], }, }, description: 'The ID of the account in the external service', @@ -104,15 +89,12 @@ export const connectionFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'connection', - ], + operation: ['create'], + resource: ['connection'], }, }, - description: 'The name associated with the account in the external service. Often this will be a company name (e.g., "My Toystore, Inc.").', + description: + 'The name associated with the account in the external service. Often this will be a company name (e.g., "My Toystore, Inc.").', }, { displayName: 'Logo URL', @@ -122,12 +104,8 @@ export const connectionFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'connection', - ], + operation: ['create'], + resource: ['connection'], }, }, description: 'The URL to a logo image for the external service', @@ -140,15 +118,12 @@ export const connectionFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'connection', - ], + operation: ['create'], + resource: ['connection'], }, }, - description: 'The URL to a page where the integration with the external service can be managed in the third-party\'s website', + description: + "The URL to a page where the integration with the external service can be managed in the third-party's website", }, // ---------------------------------- @@ -160,12 +135,8 @@ export const connectionFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'connection', - ], + operation: ['update'], + resource: ['connection'], }, }, default: 0, @@ -180,12 +151,8 @@ export const connectionFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'connection', - ], + operation: ['update'], + resource: ['connection'], }, }, default: {}, @@ -209,7 +176,8 @@ export const connectionFields: INodeProperties[] = [ name: 'name', type: 'string', default: '', - description: 'The name associated with the account in the external service. Often this will be a company name (e.g., "My Toystore, Inc.").', + description: + 'The name associated with the account in the external service. Often this will be a company name (e.g., "My Toystore, Inc.").', }, { displayName: 'Logo URL', @@ -223,7 +191,8 @@ export const connectionFields: INodeProperties[] = [ name: 'linkUrl', type: 'string', default: '', - description: 'The URL to a page where the integration with the external service can be managed in the third-party\'s website', + description: + "The URL to a page where the integration with the external service can be managed in the third-party's website", }, { displayName: 'Status', @@ -237,7 +206,8 @@ export const connectionFields: INodeProperties[] = [ name: 'syncStatus', type: 'number', default: 1, - description: 'The status of a sync triggered on the connection (0 = sync stopped; 1 = sync running)', + description: + 'The status of a sync triggered on the connection (0 = sync stopped; 1 = sync running)', }, ], }, @@ -251,12 +221,8 @@ export const connectionFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'connection', - ], + operation: ['delete'], + resource: ['connection'], }, }, default: 0, @@ -273,12 +239,8 @@ export const connectionFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'connection', - ], + operation: ['get'], + resource: ['connection'], }, }, default: 0, @@ -290,5 +252,4 @@ export const connectionFields: INodeProperties[] = [ // connection:getAll // ---------------------------------- ...activeCampaignDefaultGetAllProperties('connection', 'getAll'), - ]; diff --git a/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts index 19be729d87045..1934525cca9d4 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ContactDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - activeCampaignDefaultGetAllProperties, -} from './GenericFunctions'; +import { activeCampaignDefaultGetAllProperties } from './GenericFunctions'; export const contactOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const contactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contact', - ], + resource: ['contact'], }, }, options: [ @@ -68,12 +62,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], + operation: ['create'], + resource: ['contact'], }, }, description: 'The email of the contact to create', @@ -84,16 +74,13 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], + operation: ['create'], + resource: ['contact'], }, }, default: false, - description: 'Whether to update user if it exists already. If not set and user exists it will error instead.', + description: + 'Whether to update user if it exists already. If not set and user exists it will error instead.', }, { displayName: 'Additional Fields', @@ -102,12 +89,8 @@ export const contactFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], + operation: ['create'], + resource: ['contact'], }, }, default: {}, @@ -135,7 +118,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactCustomFields', }, 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', @@ -181,12 +165,8 @@ export const contactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'contact', - ], + operation: ['update'], + resource: ['contact'], }, }, default: 0, @@ -201,12 +181,8 @@ export const contactFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'contact', - ], + operation: ['update'], + resource: ['contact'], }, }, default: {}, @@ -234,7 +210,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getContactCustomFields', }, 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', @@ -288,12 +265,8 @@ export const contactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'contact', - ], + operation: ['delete'], + resource: ['contact'], }, }, default: 0, @@ -310,12 +283,8 @@ export const contactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], + operation: ['get'], + resource: ['contact'], }, }, default: 0, @@ -334,12 +303,8 @@ export const contactFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], + operation: ['getAll'], + resource: ['contact'], }, }, default: {}, @@ -392,7 +357,8 @@ export const contactFields: INodeProperties[] = [ name: 'search', type: 'string', default: '', - description: 'Filter contacts that match the given value in the contact names, organization, phone or email', + description: + 'Filter contacts that match the given value in the contact names, organization, phone or email', }, { displayName: 'Segment ID', diff --git a/packages/nodes-base/nodes/ActiveCampaign/ContactListDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/ContactListDescription.ts index 5d5620a5fda0e..15edb24d06b12 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ContactListDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/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: [ @@ -45,12 +41,8 @@ export const contactListFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'contactList', - ], + operation: ['add'], + resource: ['contactList'], }, }, }, @@ -62,12 +54,8 @@ export const contactListFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'contactList', - ], + operation: ['add'], + resource: ['contactList'], }, }, }, @@ -83,12 +71,8 @@ export const contactListFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'remove', - ], - resource: [ - 'contactList', - ], + operation: ['remove'], + resource: ['contactList'], }, }, }, @@ -100,12 +84,8 @@ export const contactListFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'remove', - ], - resource: [ - 'contactList', - ], + operation: ['remove'], + resource: ['contactList'], }, }, }, diff --git a/packages/nodes-base/nodes/ActiveCampaign/ContactTagDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/ContactTagDescription.ts index 73774b582047c..81d896a93c1c1 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ContactTagDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/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: [ @@ -41,7 +37,8 @@ export const contactTagFields: INodeProperties[] = [ displayName: 'Tag Name or ID', name: 'tagId', type: 'options', - 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: 'getTags', }, @@ -49,12 +46,8 @@ export const contactTagFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'contactTag', - ], + operation: ['add'], + resource: ['contactTag'], }, }, }, @@ -66,12 +59,8 @@ export const contactTagFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'contactTag', - ], + operation: ['add'], + resource: ['contactTag'], }, }, }, @@ -84,12 +73,8 @@ export const contactTagFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'remove', - ], - resource: [ - 'contactTag', - ], + operation: ['remove'], + resource: ['contactTag'], }, }, default: 0, diff --git a/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts index 20ac6fc916220..c6c6ba3a3d9ca 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/DealDescription.ts @@ -1,14 +1,8 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - allCurrencies, -} from './currencies'; +import { allCurrencies } from './currencies'; -import { - activeCampaignDefaultGetAllProperties, -} from './GenericFunctions'; +import { activeCampaignDefaultGetAllProperties } from './GenericFunctions'; export const dealOperations: INodeProperties[] = [ { @@ -18,9 +12,7 @@ export const dealOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'deal', - ], + resource: ['deal'], }, }, options: [ @@ -69,7 +61,6 @@ export const dealOperations: INodeProperties[] = [ ], default: 'create', }, - ]; export const dealFields: INodeProperties[] = [ @@ -84,33 +75,25 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], + operation: ['create'], + resource: ['deal'], }, }, description: 'The title of the deal', }, { - displayName: 'Deal\'s Contact ID', + displayName: "Deal's Contact ID", name: 'contact', type: 'number', default: 0, required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], + operation: ['create'], + resource: ['deal'], }, }, - description: 'The ID of the deal\'s contact', + description: "The ID of the deal's contact", }, { displayName: 'Deal Value', @@ -120,12 +103,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], + operation: ['create'], + resource: ['deal'], }, }, description: 'The value of the deal in cents', @@ -138,12 +117,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], + operation: ['create'], + resource: ['deal'], }, }, options: allCurrencies, @@ -156,12 +131,8 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], + operation: ['create'], + resource: ['deal'], }, }, description: 'The pipeline ID of the deal', @@ -173,12 +144,8 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], + operation: ['create'], + resource: ['deal'], }, }, description: 'The stage ID of the deal', @@ -190,12 +157,8 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], + operation: ['create'], + resource: ['deal'], }, }, description: 'The owner ID of the deal', @@ -207,12 +170,8 @@ export const dealFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'deal', - ], + operation: ['create'], + resource: ['deal'], }, }, default: {}, @@ -251,12 +210,8 @@ export const dealFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'deal', - ], + operation: ['update'], + resource: ['deal'], }, }, default: 0, @@ -271,12 +226,8 @@ export const dealFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'deal', - ], + operation: ['update'], + resource: ['deal'], }, }, default: {}, @@ -289,11 +240,11 @@ export const dealFields: INodeProperties[] = [ description: 'The title of the deal', }, { - displayName: 'Deal\'s Contact ID', + displayName: "Deal's Contact ID", name: 'contact', type: 'number', default: 0, - description: 'The ID of the deal\'s contact', + description: "The ID of the deal's contact", }, { displayName: 'Deal Value', @@ -366,12 +317,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'deal', - ], + operation: ['delete'], + resource: ['deal'], }, }, description: 'The ID of the deal to delete', @@ -388,12 +335,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'deal', - ], + operation: ['get'], + resource: ['deal'], }, }, description: 'The ID of the deal to get', @@ -415,12 +358,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'createNote', - ], - resource: [ - 'deal', - ], + operation: ['createNote'], + resource: ['deal'], }, }, description: 'The ID of the deal note', @@ -433,12 +372,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'createNote', - ], - resource: [ - 'deal', - ], + operation: ['createNote'], + resource: ['deal'], }, }, description: 'The content of the deal note', @@ -455,12 +390,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'updateNote', - ], - resource: [ - 'deal', - ], + operation: ['updateNote'], + resource: ['deal'], }, }, description: 'The ID of the deal note', @@ -473,12 +404,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'updateNote', - ], - resource: [ - 'deal', - ], + operation: ['updateNote'], + resource: ['deal'], }, }, description: 'The ID of the deal note', @@ -490,15 +417,10 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'updateNote', - ], - resource: [ - 'deal', - ], + operation: ['updateNote'], + resource: ['deal'], }, }, description: 'The content of the deal note', }, - ]; diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts index ddf946405635d..f3c373e93f89c 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomCustomerDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - activeCampaignDefaultGetAllProperties, -} from './GenericFunctions'; +import { activeCampaignDefaultGetAllProperties } from './GenericFunctions'; export const ecomCustomerOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const ecomCustomerOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'ecommerceCustomer', - ], + resource: ['ecommerceCustomer'], }, }, options: [ @@ -67,12 +61,8 @@ export const ecomCustomerFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceCustomer', - ], + operation: ['create'], + resource: ['ecommerceCustomer'], }, }, description: 'The ID of the connection object for the service where the customer originates', @@ -85,12 +75,8 @@ export const ecomCustomerFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceCustomer', - ], + operation: ['create'], + resource: ['ecommerceCustomer'], }, }, description: 'The ID of the customer in the external service', @@ -104,12 +90,8 @@ export const ecomCustomerFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceCustomer', - ], + operation: ['create'], + resource: ['ecommerceCustomer'], }, }, description: 'The email address of the customer', @@ -121,12 +103,8 @@ export const ecomCustomerFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceCustomer', - ], + operation: ['create'], + resource: ['ecommerceCustomer'], }, }, default: {}, @@ -150,12 +128,8 @@ export const ecomCustomerFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'ecommerceCustomer', - ], + operation: ['update'], + resource: ['ecommerceCustomer'], }, }, default: 0, @@ -170,12 +144,8 @@ export const ecomCustomerFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'ecommerceCustomer', - ], + operation: ['update'], + resource: ['ecommerceCustomer'], }, }, default: {}, @@ -185,7 +155,8 @@ export const ecomCustomerFields: INodeProperties[] = [ name: 'connectionid', type: 'string', default: '', - description: 'The ID of the connection object for the service where the customer originates', + description: + 'The ID of the connection object for the service where the customer originates', }, { displayName: 'Customer ID', @@ -221,12 +192,8 @@ export const ecomCustomerFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'ecommerceCustomer', - ], + operation: ['delete'], + resource: ['ecommerceCustomer'], }, }, default: 0, @@ -243,12 +210,8 @@ export const ecomCustomerFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'ecommerceCustomer', - ], + operation: ['get'], + resource: ['ecommerceCustomer'], }, }, default: 0, diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts index e308cdc63136c..e18de8d7236e7 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderDescription.ts @@ -1,14 +1,8 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - allCurrencies, -} from './currencies'; +import { allCurrencies } from './currencies'; -import { - activeCampaignDefaultGetAllProperties, -} from './GenericFunctions'; +import { activeCampaignDefaultGetAllProperties } from './GenericFunctions'; export const ecomOrderOperations: INodeProperties[] = [ { @@ -18,9 +12,7 @@ export const ecomOrderOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'ecommerceOrder', - ], + resource: ['ecommerceOrder'], }, }, options: [ @@ -70,15 +62,12 @@ export const ecomOrderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, - description: 'The ID of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED.', + description: + 'The ID of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED.', }, { displayName: 'External Checkout ID', @@ -87,15 +76,12 @@ export const ecomOrderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, - description: 'The ID of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', + description: + 'The ID of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', }, { displayName: 'Order Source', @@ -105,15 +91,12 @@ export const ecomOrderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, - description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations)', + description: + 'The order source code (0 - will not trigger automations, 1 - will trigger automations)', }, { displayName: 'Customer Email', @@ -124,12 +107,8 @@ export const ecomOrderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, description: 'The email address of the customer who placed the order', @@ -142,15 +121,12 @@ export const ecomOrderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, - description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + description: + 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', }, { displayName: 'Order Currency', @@ -160,12 +136,8 @@ export const ecomOrderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, options: allCurrencies, @@ -179,12 +151,8 @@ export const ecomOrderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, description: 'The ID of the connection from which this order originated', @@ -197,12 +165,8 @@ export const ecomOrderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, description: 'The ID of the customer associated with this order', @@ -215,12 +179,8 @@ export const ecomOrderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, description: 'The date the order was placed', @@ -232,12 +192,8 @@ export const ecomOrderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', @@ -252,12 +208,8 @@ export const ecomOrderFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, default: {}, @@ -276,7 +228,8 @@ export const ecomOrderFields: INodeProperties[] = [ name: 'price', type: 'number', default: 0, - description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + description: + 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', }, { displayName: 'Product Quantity', @@ -336,12 +289,8 @@ export const ecomOrderFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['create'], + resource: ['ecommerceOrder'], }, }, default: {}, @@ -396,7 +345,6 @@ export const ecomOrderFields: INodeProperties[] = [ default: '', description: 'The order number. This can be different than the externalid.', }, - ], }, @@ -410,12 +358,8 @@ export const ecomOrderFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['update'], + resource: ['ecommerceOrder'], }, }, description: 'The ID of the e-commerce order', @@ -428,12 +372,8 @@ export const ecomOrderFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['update'], + resource: ['ecommerceOrder'], }, }, default: {}, @@ -443,21 +383,24 @@ export const ecomOrderFields: INodeProperties[] = [ name: 'externalid', type: 'string', default: '', - description: 'The ID of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED.', + description: + 'The ID of the order in the external service. ONLY REQUIRED IF EXTERNALCHECKOUTID NOT INCLUDED.', }, { displayName: 'External Checkout ID', name: 'externalcheckoutid', type: 'string', default: '', - description: 'The ID of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', + description: + 'The ID of the cart in the external service. ONLY REQUIRED IF EXTERNALID IS NOT INCLUDED.', }, { displayName: 'Order Source', name: 'source', type: 'number', default: 0, - description: 'The order source code (0 - will not trigger automations, 1 - will trigger automations)', + description: + 'The order source code (0 - will not trigger automations, 1 - will trigger automations)', }, { displayName: 'Customer Email', @@ -472,7 +415,8 @@ export const ecomOrderFields: INodeProperties[] = [ name: 'totalPrice', type: 'number', default: 0, - description: 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + description: + 'The total price of the order in cents, including tax and shipping charges. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', }, { displayName: 'Order Currency', @@ -508,7 +452,8 @@ export const ecomOrderFields: INodeProperties[] = [ name: 'abandonedDate', type: 'dateTime', default: '', - description: 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', + description: + 'The date the cart was abandoned. REQUIRED ONLY IF INCLUDING EXTERNALCHECKOUTID.', }, { displayName: 'Shipping Amount', @@ -585,7 +530,8 @@ export const ecomOrderFields: INodeProperties[] = [ name: 'price', type: 'number', default: 0, - description: 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', + description: + 'The price of the product, in cents. (i.e. $456.78 => 45678). Must be greater than or equal to zero.', }, { displayName: 'Product Quantity', @@ -638,7 +584,6 @@ export const ecomOrderFields: INodeProperties[] = [ }, ], }, - ], }, @@ -652,12 +597,8 @@ export const ecomOrderFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['delete'], + resource: ['ecommerceOrder'], }, }, description: 'The ID of the e-commerce order', @@ -673,12 +614,8 @@ export const ecomOrderFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'ecommerceOrder', - ], + operation: ['get'], + resource: ['ecommerceOrder'], }, }, description: 'The ID of the e-commerce order', @@ -688,5 +625,4 @@ export const ecomOrderFields: INodeProperties[] = [ // ecommerceOrder:getAll // ---------------------------------- ...activeCampaignDefaultGetAllProperties('ecommerceOrder', 'getAll'), - ]; diff --git a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts index 8f4e5061a7f4e..0f940d685a7a5 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/EcomOrderProductsDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - activeCampaignDefaultGetAllProperties, -} from './GenericFunctions'; +import { activeCampaignDefaultGetAllProperties } from './GenericFunctions'; export const ecomOrderProductsOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const ecomOrderProductsOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'ecommerceOrderProducts', - ], + resource: ['ecommerceOrderProducts'], }, }, options: [ @@ -35,7 +29,7 @@ export const ecomOrderProductsOperations: INodeProperties[] = [ { name: 'Get by Order ID', value: 'getByOrderId', - description: 'Get data of an order\'s products', + description: "Get data of an order's products", action: 'Get an e-commerce order product by order ID', }, ], @@ -54,15 +48,11 @@ export const ecomOrderProductsFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - operation: [ - 'getByOrderId', - ], - resource: [ - 'ecommerceOrderProducts', - ], + operation: ['getByOrderId'], + resource: ['ecommerceOrderProducts'], }, }, - description: 'The ID of the order whose products you\'d like returned', + description: "The ID of the order whose products you'd like returned", }, // ---------------------------------- @@ -75,15 +65,11 @@ export const ecomOrderProductsFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - operation: [ - 'getByProductId', - ], - resource: [ - 'ecommerceOrderProducts', - ], + operation: ['getByProductId'], + resource: ['ecommerceOrderProducts'], }, }, - description: 'The ID of the product you\'d like returned', + description: "The ID of the product you'd like returned", }, // ---------------------------------- diff --git a/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts b/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts index 11c747d8221d4..df339c2272251 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts @@ -1,10 +1,11 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; import { - IDataObject, ILoadOptionsFunctions, INodeProperties, NodeApiError, NodeOperationError, + IDataObject, + ILoadOptionsFunctions, + INodeProperties, + NodeApiError, + NodeOperationError, } from 'n8n-workflow'; import { OptionsWithUri } from 'request'; @@ -15,7 +16,6 @@ export interface IProduct { }; } - /** * Make an API request to ActiveCampaign * @@ -25,7 +25,15 @@ export interface IProduct { * @param {object} body * @returns {Promise} */ -export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject, dataKey?: string): Promise { // tslint:disable-line:no-any +export async function activeCampaignApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + body: IDataObject, + query?: IDataObject, + dataKey?: string, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('activeCampaignApi'); if (query === undefined) { @@ -33,8 +41,7 @@ export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFu } const options: OptionsWithUri = { - headers: { - }, + headers: {}, method, qs: query, uri: `${credentials.apiUrl}${endpoint}`, @@ -46,7 +53,11 @@ export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFu } try { - const responseData = await this.helpers.requestWithAuthentication.call(this, 'activeCampaignApi',options); + const responseData = await this.helpers.requestWithAuthentication.call( + this, + 'activeCampaignApi', + options, + ); if (responseData.success === false) { throw new NodeApiError(this.getNode(), responseData); @@ -57,14 +68,11 @@ export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFu } else { return responseData[dataKey] as IDataObject; } - } catch (error) { throw new NodeApiError(this.getNode(), error); } } - - /** * Make an API request to paginated ActiveCampaign endpoint * and return all results @@ -77,8 +85,15 @@ export async function activeCampaignApiRequest(this: IHookFunctions | IExecuteFu * @param {IDataObject} [query] * @returns {Promise} */ -export async function activeCampaignApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject, dataKey?: string): Promise { // tslint:disable-line:no-any - +export async function activeCampaignApiRequestAllItems( + 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 = {}; } @@ -115,7 +130,10 @@ export async function activeCampaignApiRequestAllItems(this: IHookFunctions | IE return returnData; } -export function activeCampaignDefaultGetAllProperties(resource: string, operation: string): INodeProperties[] { +export function activeCampaignDefaultGetAllProperties( + resource: string, + operation: string, +): INodeProperties[] { return [ { displayName: 'Return All', @@ -123,12 +141,8 @@ export function activeCampaignDefaultGetAllProperties(resource: string, operatio type: 'boolean', displayOptions: { show: { - operation: [ - operation, - ], - resource: [ - resource, - ], + operation: [operation], + resource: [resource], }, }, default: false, @@ -140,15 +154,9 @@ export function activeCampaignDefaultGetAllProperties(resource: string, operatio type: 'number', displayOptions: { show: { - operation: [ - operation, - ], - resource: [ - resource, - ], - returnAll: [ - false, - ], + operation: [operation], + resource: [resource], + returnAll: [false], }, }, typeOptions: { @@ -164,12 +172,8 @@ export function activeCampaignDefaultGetAllProperties(resource: string, operatio type: 'boolean', displayOptions: { show: { - operation: [ - operation, - ], - resource: [ - resource, - ], + operation: [operation], + resource: [resource], }, }, default: true, diff --git a/packages/nodes-base/nodes/ActiveCampaign/ListDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/ListDescription.ts index 34270082b27bd..26d332900d8a5 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ListDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ListDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - activeCampaignDefaultGetAllProperties, -} from './GenericFunctions'; +import { activeCampaignDefaultGetAllProperties } from './GenericFunctions'; export const listOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const listOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'list', - ], + resource: ['list'], }, }, options: [ diff --git a/packages/nodes-base/nodes/ActiveCampaign/TagDescription.ts b/packages/nodes-base/nodes/ActiveCampaign/TagDescription.ts index 55ea13bb02b4f..aede888f80b34 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/TagDescription.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/TagDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - activeCampaignDefaultGetAllProperties, -} from './GenericFunctions'; +import { activeCampaignDefaultGetAllProperties } from './GenericFunctions'; export const tagOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const tagOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'tag', - ], + resource: ['tag'], }, }, options: [ @@ -67,12 +61,8 @@ export const tagFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'tag', - ], + operation: ['create'], + resource: ['tag'], }, }, options: [ @@ -97,12 +87,8 @@ export const tagFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'tag', - ], + operation: ['create'], + resource: ['tag'], }, }, description: 'Name of the new tag', @@ -114,12 +100,8 @@ export const tagFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'tag', - ], + operation: ['create'], + resource: ['tag'], }, }, default: {}, @@ -142,12 +124,8 @@ export const tagFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'tag', - ], + operation: ['update'], + resource: ['tag'], }, }, default: 0, @@ -162,12 +140,8 @@ export const tagFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'tag', - ], + operation: ['update'], + resource: ['tag'], }, }, default: {}, @@ -197,12 +171,8 @@ export const tagFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'tag', - ], + operation: ['delete'], + resource: ['tag'], }, }, default: 0, @@ -218,12 +188,8 @@ export const tagFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'tag', - ], + operation: ['get'], + resource: ['tag'], }, }, default: 0, diff --git a/packages/nodes-base/nodes/ActiveCampaign/currencies.ts b/packages/nodes-base/nodes/ActiveCampaign/currencies.ts index 781c9e7c91e0c..2dd1cc3ad9898 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/currencies.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/currencies.ts @@ -144,7 +144,7 @@ export const allCurrencies = [ { name: 'Tajikistani Somoni', value: 'tjs' }, { name: 'Turkmenistani Manat', value: 'tmt' }, { name: 'Tunisian Dinar', value: 'tnd' }, - { name: 'Tongan Pa\'anga', value: 'top' }, + { name: "Tongan Pa'anga", value: 'top' }, { name: 'Turkish Lira', value: 'try' }, { name: 'Trinidad and Tobago Dollar', value: 'ttd' }, { name: 'New Taiwan Dollar', value: 'twd' }, diff --git a/packages/nodes-base/nodes/AcuityScheduling/AcuitySchedulingTrigger.node.ts b/packages/nodes-base/nodes/AcuityScheduling/AcuitySchedulingTrigger.node.ts index d0f475e4520ca..71d090f4cf78b 100644 --- a/packages/nodes-base/nodes/AcuityScheduling/AcuitySchedulingTrigger.node.ts +++ b/packages/nodes-base/nodes/AcuityScheduling/AcuitySchedulingTrigger.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 { - acuitySchedulingApiRequest, -} from './GenericFunctions'; +import { acuitySchedulingApiRequest } from './GenericFunctions'; export class AcuitySchedulingTrigger implements INodeType { description: INodeTypeDescription = { @@ -34,9 +24,7 @@ export class AcuitySchedulingTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'apiKey', - ], + authentication: ['apiKey'], }, }, }, @@ -45,9 +33,7 @@ export class AcuitySchedulingTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -117,7 +103,8 @@ export class AcuitySchedulingTrigger 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 only contain the ID of the object. If this option gets activated, it will resolve the data automatically.', + description: + 'By default does the webhook-data only contain the ID of the object. If this option gets activated, it will resolve the data automatically.', }, ], }; @@ -158,7 +145,7 @@ export class AcuitySchedulingTrigger implements INodeType { const endpoint = `/webhooks/${webhookData.webhookId}`; try { await acuitySchedulingApiRequest.call(this, 'DELETE', endpoint); - } catch(error) { + } catch (error) { return false; } delete webhookData.webhookId; @@ -175,9 +162,7 @@ export class AcuitySchedulingTrigger implements INodeType { if (resolveData === false) { // Return the data as it got received return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } @@ -188,11 +173,7 @@ export class AcuitySchedulingTrigger implements INodeType { const responseData = await acuitySchedulingApiRequest.call(this, 'GET', endpoint, {}); return { - workflowData: [ - this.helpers.returnJsonArray(responseData), - ], + workflowData: [this.helpers.returnJsonArray(responseData)], }; - - } } diff --git a/packages/nodes-base/nodes/AcuityScheduling/GenericFunctions.ts b/packages/nodes-base/nodes/AcuityScheduling/GenericFunctions.ts index 59bce6d4ef9df..c9d42ea5f76ff 100644 --- a/packages/nodes-base/nodes/AcuityScheduling/GenericFunctions.ts +++ b/packages/nodes-base/nodes/AcuityScheduling/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 acuitySchedulingApiRequest(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 acuitySchedulingApiRequest( + 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 authenticationMethod = this.getNodeParameter('authentication', 0); const options: OptionsWithUri = { @@ -19,7 +34,7 @@ export async function acuitySchedulingApiRequest(this: IHookFunctions | IExecute method, qs, body, - uri: uri ||`https://acuityscheduling.com/api/v1${resource}`, + uri: uri || `https://acuityscheduling.com/api/v1${resource}`, json: true, }; @@ -35,8 +50,13 @@ export async function acuitySchedulingApiRequest(this: IHookFunctions | IExecute return await this.helpers.request!(options); } else { delete options.auth; - //@ts-ignore - return await this.helpers.requestOAuth2!.call(this, 'acuitySchedulingOAuth2Api', options, true); + return await this.helpers.requestOAuth2!.call( + this, + 'acuitySchedulingOAuth2Api', + options, + //@ts-ignore + true, + ); } } catch (error) { throw new NodeApiError(this.getNode(), error); diff --git a/packages/nodes-base/nodes/Affinity/Affinity.node.ts b/packages/nodes-base/nodes/Affinity/Affinity.node.ts index 2bebc74e389a3..174e65075e01a 100644 --- a/packages/nodes-base/nodes/Affinity/Affinity.node.ts +++ b/packages/nodes-base/nodes/Affinity/Affinity.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,38 +9,19 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - affinityApiRequest, - affinityApiRequestAllItems, -} from './GenericFunctions'; +import { affinityApiRequest, affinityApiRequestAllItems } from './GenericFunctions'; -import { - organizationFields, - organizationOperations, -} from './OrganizationDescription'; +import { organizationFields, organizationOperations } from './OrganizationDescription'; -import { - personFields, - personOperations, -} from './PersonDescription'; +import { personFields, personOperations } from './PersonDescription'; -import { - listFields, - listOperations, -} from './ListDescription'; +import { listFields, listOperations } from './ListDescription'; -import { - listEntryFields, - listEntryOperations, -} from './ListEntryDescription'; +import { listEntryFields, listEntryOperations } from './ListEntryDescription'; -import { - IOrganization, -} from './OrganizationInterface'; +import { IOrganization } from './OrganizationInterface'; -import { - IPerson, -} from './PersonInterface'; +import { IPerson } from './PersonInterface'; export class Affinity implements INodeType { description: INodeTypeDescription = { @@ -108,7 +87,13 @@ export class Affinity implements INodeType { // select them easily async getOrganizations(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const organizations = await affinityApiRequestAllItems.call(this, 'organizations', 'GET', '/organizations', {}); + const organizations = await affinityApiRequestAllItems.call( + this, + 'organizations', + 'GET', + '/organizations', + {}, + ); for (const organization of organizations) { const organizationName = organization.name; const organizationId = organization.id; @@ -123,7 +108,13 @@ export class Affinity implements INodeType { // select them easily async getPersons(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const persons = await affinityApiRequestAllItems.call(this, 'persons', 'GET', '/persons', {}); + const persons = await affinityApiRequestAllItems.call( + this, + 'persons', + 'GET', + '/persons', + {}, + ); for (const person of persons) { let personName = `${person.first_name} ${person.last_name}`; if (person.primary_email !== null) { @@ -189,23 +180,47 @@ export class Affinity implements INodeType { entity_id: parseInt(entityId, 10), }; Object.assign(body, additionalFields); - responseData = await affinityApiRequest.call(this, 'POST', `/lists/${listId}/list-entries`, body); + responseData = await affinityApiRequest.call( + this, + 'POST', + `/lists/${listId}/list-entries`, + body, + ); } //https://api-docs.affinity.co/#get-a-specific-list-entry if (operation === 'get') { const listId = this.getNodeParameter('listId', i) as string; const listEntryId = this.getNodeParameter('listEntryId', i) as string; - responseData = await affinityApiRequest.call(this, 'GET', `/lists/${listId}/list-entries/${listEntryId}`, {}, qs); + responseData = await affinityApiRequest.call( + this, + 'GET', + `/lists/${listId}/list-entries/${listEntryId}`, + {}, + qs, + ); } //https://api-docs.affinity.co/#get-all-list-entries if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; const listId = this.getNodeParameter('listId', i) as string; if (returnAll === true) { - responseData = await affinityApiRequestAllItems.call(this, 'list_entries', 'GET', `/lists/${listId}/list-entries`, {}, qs); + responseData = await affinityApiRequestAllItems.call( + this, + 'list_entries', + 'GET', + `/lists/${listId}/list-entries`, + {}, + qs, + ); } else { qs.page_size = this.getNodeParameter('limit', i) as number; - responseData = await affinityApiRequest.call(this, 'GET', `/lists/${listId}/list-entries`, {}, qs); + responseData = await affinityApiRequest.call( + this, + 'GET', + `/lists/${listId}/list-entries`, + {}, + qs, + ); responseData = responseData.list_entries; } } @@ -213,7 +228,13 @@ export class Affinity implements INodeType { if (operation === 'delete') { const listId = this.getNodeParameter('listId', i) as string; const listEntryId = this.getNodeParameter('listEntryId', i) as string; - responseData = await affinityApiRequest.call(this, 'DELETE', `/lists/${listId}/list-entries/${listEntryId}`, {}, qs); + responseData = await affinityApiRequest.call( + this, + 'DELETE', + `/lists/${listId}/list-entries/${listEntryId}`, + {}, + qs, + ); } } if (resource === 'person') { @@ -259,7 +280,13 @@ export class Affinity implements INodeType { if (options.withInteractionDates) { qs.with_interaction_dates = options.withInteractionDates as boolean; } - responseData = await affinityApiRequest.call(this, 'GET', `/persons/${personId}`, {}, qs); + responseData = await affinityApiRequest.call( + this, + 'GET', + `/persons/${personId}`, + {}, + qs, + ); } //https://api-docs.affinity.co/#search-for-persons if (operation === 'getAll') { @@ -272,7 +299,14 @@ export class Affinity implements INodeType { qs.with_interaction_dates = options.withInteractionDates as boolean; } if (returnAll === true) { - responseData = await affinityApiRequestAllItems.call(this, 'persons', 'GET', '/persons', {}, qs); + responseData = await affinityApiRequestAllItems.call( + this, + 'persons', + 'GET', + '/persons', + {}, + qs, + ); } else { qs.page_size = this.getNodeParameter('limit', i) as number; responseData = await affinityApiRequest.call(this, 'GET', '/persons', {}, qs); @@ -282,7 +316,13 @@ export class Affinity implements INodeType { //https://api-docs.affinity.co/#delete-a-person if (operation === 'delete') { const personId = this.getNodeParameter('personId', i) as number; - responseData = await affinityApiRequest.call(this, 'DELETE', `/persons/${personId}`, {}, qs); + responseData = await affinityApiRequest.call( + this, + 'DELETE', + `/persons/${personId}`, + {}, + qs, + ); } } if (resource === 'organization') { @@ -314,7 +354,12 @@ export class Affinity implements INodeType { if (updateFields.persons) { body.person_ids = updateFields.persons as number[]; } - responseData = await affinityApiRequest.call(this, 'PUT', `/organizations/${organizationId}`, body); + responseData = await affinityApiRequest.call( + this, + 'PUT', + `/organizations/${organizationId}`, + body, + ); } //https://api-docs.affinity.co/#get-a-specific-organization if (operation === 'get') { @@ -323,7 +368,13 @@ export class Affinity implements INodeType { if (options.withInteractionDates) { qs.with_interaction_dates = options.withInteractionDates as boolean; } - responseData = await affinityApiRequest.call(this, 'GET', `/organizations/${organizationId}`, {}, qs); + responseData = await affinityApiRequest.call( + this, + 'GET', + `/organizations/${organizationId}`, + {}, + qs, + ); } //https://api-docs.affinity.co/#search-for-organizations if (operation === 'getAll') { @@ -336,7 +387,14 @@ export class Affinity implements INodeType { qs.with_interaction_dates = options.withInteractionDates as boolean; } if (returnAll === true) { - responseData = await affinityApiRequestAllItems.call(this, 'organizations', 'GET', '/organizations', {}, qs); + responseData = await affinityApiRequestAllItems.call( + this, + 'organizations', + 'GET', + '/organizations', + {}, + qs, + ); } else { qs.page_size = this.getNodeParameter('limit', i) as number; responseData = await affinityApiRequest.call(this, 'GET', '/organizations', {}, qs); @@ -346,7 +404,13 @@ export class Affinity implements INodeType { //https://api-docs.affinity.co/#delete-an-organization if (operation === 'delete') { const organizationId = this.getNodeParameter('organizationId', i) as number; - responseData = await affinityApiRequest.call(this, 'DELETE', `/organizations/${organizationId}`, {}, qs); + responseData = await affinityApiRequest.call( + this, + 'DELETE', + `/organizations/${organizationId}`, + {}, + qs, + ); } } if (Array.isArray(responseData)) { diff --git a/packages/nodes-base/nodes/Affinity/AffinityTrigger.node.ts b/packages/nodes-base/nodes/Affinity/AffinityTrigger.node.ts index 69578bbfefe6a..336502e78a6b6 100644 --- a/packages/nodes-base/nodes/Affinity/AffinityTrigger.node.ts +++ b/packages/nodes-base/nodes/Affinity/AffinityTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -11,11 +8,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - affinityApiRequest, - eventsExist, - mapResource, -} from './GenericFunctions'; +import { affinityApiRequest, eventsExist, mapResource } from './GenericFunctions'; export class AffinityTrigger implements INodeType { description: INodeTypeDescription = { @@ -157,7 +150,6 @@ export class AffinityTrigger implements INodeType { description: 'Webhook events that will be enabled for that endpoint', }, ], - }; // @ts-ignore (because of request) @@ -188,7 +180,10 @@ export class AffinityTrigger implements INodeType { const webhookUrl = this.getNodeWebhookUrl('default') as string; if (webhookUrl.includes('%20')) { - throw new NodeOperationError(this.getNode(), 'The name of the Affinity Trigger Node is not allowed to contain any spaces!'); + throw new NodeOperationError( + this.getNode(), + 'The name of the Affinity Trigger Node is not allowed to contain any spaces!', + ); } const events = this.getNodeParameter('events') as string[]; @@ -214,7 +209,6 @@ export class AffinityTrigger implements INodeType { async delete(this: IHookFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); if (webhookData.webhookId !== undefined) { - const endpoint = `/webhook/${webhookData.webhookId}`; const responseData = await affinityApiRequest.call(this, 'DELETE', endpoint); @@ -249,9 +243,7 @@ export class AffinityTrigger implements INodeType { } return { - workflowData: [ - this.helpers.returnJsonArray(responseData), - ], + workflowData: [this.helpers.returnJsonArray(responseData)], }; } } diff --git a/packages/nodes-base/nodes/Affinity/GenericFunctions.ts b/packages/nodes-base/nodes/Affinity/GenericFunctions.ts index da80ce7718a8c..7b792269fcfdc 100644 --- a/packages/nodes-base/nodes/Affinity/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Affinity/GenericFunctions.ts @@ -1,12 +1,6 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - BINARY_ENCODING, - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { BINARY_ENCODING, IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject, @@ -16,8 +10,17 @@ import { NodeOperationError, } from 'n8n-workflow'; -export async function affinityApiRequest(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 affinityApiRequest( + 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('affinityApi'); const apiKey = `:${credentials.apiKey}`; @@ -49,8 +52,16 @@ export async function affinityApiRequest(this: IExecuteFunctions | IWebhookFunct } } -export async function affinityApiRequestAllItems(this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function affinityApiRequestAllItems( + 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; @@ -62,10 +73,7 @@ export async function affinityApiRequestAllItems(this: IHookFunctions | ILoadOpt // @ts-ignore query.page_token = responseData.page_token; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData.page_token !== undefined && - responseData.page_token !== null - ); + } while (responseData.page_token !== undefined && responseData.page_token !== null); return returnData; } diff --git a/packages/nodes-base/nodes/Affinity/ListDescription.ts b/packages/nodes-base/nodes/Affinity/ListDescription.ts index 015b965a1624d..88bc0ae0dabc4 100644 --- a/packages/nodes-base/nodes/Affinity/ListDescription.ts +++ b/packages/nodes-base/nodes/Affinity/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: [ @@ -45,12 +41,8 @@ export const listFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'get', - ], + resource: ['list'], + operation: ['get'], }, }, description: 'The unique ID of the list object to be retrieved', @@ -64,12 +56,8 @@ export const listFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], + resource: ['list'], + operation: ['getAll'], }, }, default: false, @@ -81,15 +69,9 @@ export const listFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['list'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Affinity/ListEntryDescription.ts b/packages/nodes-base/nodes/Affinity/ListEntryDescription.ts index 8cf8c5bf181d5..f7cfa26c288be 100644 --- a/packages/nodes-base/nodes/Affinity/ListEntryDescription.ts +++ b/packages/nodes-base/nodes/Affinity/ListEntryDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const listEntryOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const listEntryOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'listEntry', - ], + resource: ['listEntry'], }, }, options: [ @@ -46,7 +42,6 @@ export const listEntryOperations: INodeProperties[] = [ ]; export const listEntryFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* listEntry:create */ /* -------------------------------------------------------------------------- */ @@ -61,15 +56,12 @@ export const listEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'listEntry', - ], - operation: [ - 'create', - ], + resource: ['listEntry'], + operation: ['create'], }, }, - description: 'The unique ID of the list whose list entries are to be retrieved. Choose from the list, or specify an ID using an expression.', + description: + 'The unique ID of the list whose list entries are to be retrieved. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Entity ID', @@ -79,15 +71,12 @@ export const listEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'listEntry', - ], - operation: [ - 'create', - ], + resource: ['listEntry'], + operation: ['create'], }, }, - description: 'The unique ID of the entity (person, organization, or opportunity) to add to this list', + description: + 'The unique ID of the entity (person, organization, or opportunity) to add to this list', }, { displayName: 'Additional Fields', @@ -97,12 +86,8 @@ export const listEntryFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'listEntry', - ], - operation: [ - 'create', - ], + resource: ['listEntry'], + operation: ['create'], }, }, options: [ @@ -111,7 +96,8 @@ export const listEntryFields: INodeProperties[] = [ name: 'creator_id', type: 'string', default: '', - description: 'The ID of a Person resource who should be recorded as adding the entry to the list. Must be a person who can access Affinity. If not provided the creator defaults to the owner of the API key.', + description: + 'The ID of a Person resource who should be recorded as adding the entry to the list. Must be a person who can access Affinity. If not provided the creator defaults to the owner of the API key.', }, ], }, @@ -129,15 +115,12 @@ export const listEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'listEntry', - ], - operation: [ - 'get', - ], + resource: ['listEntry'], + operation: ['get'], }, }, - description: 'The unique ID of the list that contains the specified list_entry_id. Choose from the list, or specify an ID using an expression.', + description: + 'The unique ID of the list that contains the specified list_entry_id. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Entry ID', @@ -147,12 +130,8 @@ export const listEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'listEntry', - ], - operation: [ - 'get', - ], + resource: ['listEntry'], + operation: ['get'], }, }, description: 'The unique ID of the list entry object to be retrieved', @@ -169,16 +148,13 @@ export const listEntryFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'listEntry', - ], - operation: [ - 'getAll', - ], + resource: ['listEntry'], + operation: ['getAll'], }, }, default: '', - description: 'The unique ID of the list whose list entries are to be retrieved. Choose from the list, or specify an ID using an expression.', + description: + 'The unique ID of the list whose list entries are to be retrieved. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -186,12 +162,8 @@ export const listEntryFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'listEntry', - ], - operation: [ - 'getAll', - ], + resource: ['listEntry'], + operation: ['getAll'], }, }, default: false, @@ -203,15 +175,9 @@ export const listEntryFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'listEntry', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['listEntry'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -235,15 +201,12 @@ export const listEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'listEntry', - ], - operation: [ - 'delete', - ], + resource: ['listEntry'], + operation: ['delete'], }, }, - description: 'The unique ID of the list that contains the specified list_entry_id. Choose from the list, or specify an ID using an expression.', + description: + 'The unique ID of the list that contains the specified list_entry_id. Choose from the list, or specify an ID using an expression.', }, { displayName: 'List Entry ID', @@ -253,12 +216,8 @@ export const listEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'listEntry', - ], - operation: [ - 'delete', - ], + resource: ['listEntry'], + operation: ['delete'], }, }, description: 'The unique ID of the list entry object to be deleted', diff --git a/packages/nodes-base/nodes/Affinity/OrganizationDescription.ts b/packages/nodes-base/nodes/Affinity/OrganizationDescription.ts index 21182a1aec0d3..2b940f2f7cb5e 100644 --- a/packages/nodes-base/nodes/Affinity/OrganizationDescription.ts +++ b/packages/nodes-base/nodes/Affinity/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: [ @@ -52,7 +48,6 @@ export const organizationOperations: INodeProperties[] = [ ]; export const organizationFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* organization:create */ /* -------------------------------------------------------------------------- */ @@ -64,12 +59,8 @@ export const organizationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'create', - ], + resource: ['organization'], + operation: ['create'], }, }, description: 'The name of the organization', @@ -82,12 +73,8 @@ export const organizationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'create', - ], + resource: ['organization'], + operation: ['create'], }, }, description: 'The domain name of the organization', @@ -100,12 +87,8 @@ export const organizationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'create', - ], + resource: ['organization'], + operation: ['create'], }, }, options: [ @@ -117,7 +100,8 @@ export const organizationFields: INodeProperties[] = [ loadOptionsMethod: 'getPersons', }, default: [], - description: 'Persons that the new organization will be associated with. Choose from the list, or specify IDs using an expression.', + description: + 'Persons that the new organization will be associated with. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -132,12 +116,8 @@ export const organizationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'update', - ], + resource: ['organization'], + operation: ['update'], }, }, description: 'Unique identifier for the organization', @@ -150,12 +130,8 @@ export const organizationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'update', - ], + resource: ['organization'], + operation: ['update'], }, }, options: [ @@ -181,7 +157,8 @@ export const organizationFields: INodeProperties[] = [ loadOptionsMethod: 'getPersons', }, default: [], - description: 'Persons that the new organization will be associated with. Choose from the list, or specify IDs using an expression.', + description: + 'Persons that the new organization will be associated with. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -196,12 +173,8 @@ export const organizationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'get', - ], + resource: ['organization'], + operation: ['get'], }, }, description: 'Unique identifier for the organization', @@ -214,12 +187,8 @@ export const organizationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'get', - ], + resource: ['organization'], + operation: ['get'], }, }, options: [ @@ -241,12 +210,8 @@ export const organizationFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'getAll', - ], + resource: ['organization'], + operation: ['getAll'], }, }, default: false, @@ -258,15 +223,9 @@ export const organizationFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['organization'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -284,12 +243,8 @@ export const organizationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'getAll', - ], + resource: ['organization'], + operation: ['getAll'], }, }, options: [ @@ -298,7 +253,8 @@ export const organizationFields: INodeProperties[] = [ name: 'term', type: 'string', default: '', - description: 'A string used to search all the organizations in your team’s address book. This could be an email address, a first name or a last name.', + description: + 'A string used to search all the organizations in your team’s address book. This could be an email address, a first name or a last name.', }, { displayName: 'With Interaction Dates', @@ -320,12 +276,8 @@ export const organizationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'organization', - ], - operation: [ - 'delete', - ], + resource: ['organization'], + operation: ['delete'], }, }, description: 'Unique identifier for the organization', diff --git a/packages/nodes-base/nodes/Affinity/OrganizationInterface.ts b/packages/nodes-base/nodes/Affinity/OrganizationInterface.ts index ae29e598aea78..872e354212ecf 100644 --- a/packages/nodes-base/nodes/Affinity/OrganizationInterface.ts +++ b/packages/nodes-base/nodes/Affinity/OrganizationInterface.ts @@ -1,4 +1,3 @@ - export interface IOrganization { name?: string; domain?: string; diff --git a/packages/nodes-base/nodes/Affinity/PersonDescription.ts b/packages/nodes-base/nodes/Affinity/PersonDescription.ts index 253c101b1ca3d..1aa2a106b2300 100644 --- a/packages/nodes-base/nodes/Affinity/PersonDescription.ts +++ b/packages/nodes-base/nodes/Affinity/PersonDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const personOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const personOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'person', - ], + resource: ['person'], }, }, options: [ @@ -52,7 +48,6 @@ export const personOperations: INodeProperties[] = [ ]; export const personFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* person:create */ /* -------------------------------------------------------------------------- */ @@ -64,12 +59,8 @@ export const personFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'create', - ], + resource: ['person'], + operation: ['create'], }, }, description: 'The first name of the person', @@ -82,12 +73,8 @@ export const personFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'create', - ], + resource: ['person'], + operation: ['create'], }, }, description: 'The last name of the person', @@ -100,12 +87,8 @@ export const personFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'create', - ], + resource: ['person'], + operation: ['create'], }, }, options: [ @@ -117,7 +100,8 @@ export const personFields: INodeProperties[] = [ loadOptionsMethod: 'getOrganizations', }, default: [], - description: 'Organizations that the person is associated with. Choose from the list, or specify IDs using an expression.', + description: + 'Organizations that the person is associated with. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -132,12 +116,8 @@ export const personFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'create', - ], + resource: ['person'], + operation: ['create'], }, }, placeholder: 'info@example.com', @@ -154,12 +134,8 @@ export const personFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'update', - ], + resource: ['person'], + operation: ['update'], }, }, description: 'Unique identifier for the person', @@ -172,12 +148,8 @@ export const personFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'update', - ], + resource: ['person'], + operation: ['update'], }, }, options: [ @@ -203,7 +175,8 @@ export const personFields: INodeProperties[] = [ loadOptionsMethod: 'getOrganizations', }, default: [], - description: 'Organizations that the person is associated with. Choose from the list, or specify IDs using an expression.', + description: + 'Organizations that the person is associated with. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -218,12 +191,8 @@ export const personFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'update', - ], + resource: ['person'], + operation: ['update'], }, }, placeholder: 'info@example.com', @@ -240,12 +209,8 @@ export const personFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'get', - ], + resource: ['person'], + operation: ['get'], }, }, description: 'Unique identifier for the person', @@ -258,12 +223,8 @@ export const personFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'get', - ], + resource: ['person'], + operation: ['get'], }, }, options: [ @@ -285,12 +246,8 @@ export const personFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'getAll', - ], + resource: ['person'], + operation: ['getAll'], }, }, default: false, @@ -302,15 +259,9 @@ export const personFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['person'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -328,12 +279,8 @@ export const personFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'getAll', - ], + resource: ['person'], + operation: ['getAll'], }, }, options: [ @@ -342,7 +289,8 @@ export const personFields: INodeProperties[] = [ name: 'term', type: 'string', default: '', - description: 'A string used to search all the persons in your team’s address book. This could be an email address, a first name or a last name.', + description: + 'A string used to search all the persons in your team’s address book. This could be an email address, a first name or a last name.', }, { displayName: 'With Interaction Dates', @@ -364,12 +312,8 @@ export const personFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'delete', - ], + resource: ['person'], + operation: ['delete'], }, }, description: 'Unique identifier for the person', diff --git a/packages/nodes-base/nodes/Affinity/PersonInterface.ts b/packages/nodes-base/nodes/Affinity/PersonInterface.ts index 3bf495d3fa735..6107de2b03db3 100644 --- a/packages/nodes-base/nodes/Affinity/PersonInterface.ts +++ b/packages/nodes-base/nodes/Affinity/PersonInterface.ts @@ -1,4 +1,3 @@ - export interface IPerson { first_name?: string; last_name?: string; diff --git a/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts b/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts index 6461e22fe1061..c9b6cccc2b957 100644 --- a/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts +++ b/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,42 +8,26 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - contactFields, - contactOperations -} from './ContactDescription'; +import { contactFields, contactOperations } from './ContactDescription'; -import { - companyFields, - companyOperations -} from './CompanyDescription'; +import { companyFields, companyOperations } from './CompanyDescription'; -import { - dealFields, - dealOperations -} from './DealDescription'; +import { dealFields, dealOperations } from './DealDescription'; -import { - IContact, - IContactUpdate, -} from './ContactInterface'; +import { IContact, IContactUpdate } from './ContactInterface'; import { - agileCrmApiRequest, agileCrmApiRequestAllItems, + agileCrmApiRequest, + agileCrmApiRequestAllItems, agileCrmApiRequestUpdate, getFilterRules, simplifyResponse, validateJSON, } from './GenericFunctions'; -import { - IDeal, -} from './DealInterface'; +import { IDeal } from './DealInterface'; -import { - IFilter, - ISearchConditions, -} from './FilterInterface'; +import { IFilter, ISearchConditions } from './FilterInterface'; export class AgileCrm implements INodeType { description: INodeTypeDescription = { @@ -104,11 +86,9 @@ export class AgileCrm implements INodeType { ...dealOperations, ...dealFields, ], - }; async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); const returnData: IDataObject[] = []; let responseData; @@ -116,7 +96,6 @@ export class AgileCrm implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < items.length; i++) { - if (resource === 'contact' || resource === 'company') { const idGetter = resource === 'contact' ? 'contactId' : 'companyId'; @@ -125,18 +104,19 @@ export class AgileCrm implements INodeType { const endpoint = `api/contacts/${contactId}`; responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, {}); - } else if (operation === 'delete') { const contactId = this.getNodeParameter(idGetter, i) as string; const endpoint = `api/contacts/${contactId}`; responseData = await agileCrmApiRequest.call(this, 'DELETE', endpoint, {}); - } else if (operation === 'getAll') { const simple = this.getNodeParameter('simple', 0) as boolean; const returnAll = this.getNodeParameter('returnAll', 0) as boolean; const filterType = this.getNodeParameter('filterType', i) as string; - const sort = this.getNodeParameter('options.sort.sort', i, {}) as { direction: string, field: string }; + const sort = this.getNodeParameter('options.sort.sort', i, {}) as { + direction: string; + field: string; + }; const body: IDataObject = {}; const filterJson: IFilter = {}; @@ -149,21 +129,31 @@ export class AgileCrm implements INodeType { filterJson.contact_type = contactType; if (filterType === 'manual') { - const conditions = this.getNodeParameter('filters.conditions', i, []) as ISearchConditions[]; + const conditions = this.getNodeParameter( + 'filters.conditions', + i, + [], + ) as ISearchConditions[]; const matchType = this.getNodeParameter('matchType', i) as string; let rules; if (conditions.length !== 0) { rules = getFilterRules(conditions, matchType); Object.assign(filterJson, rules); } else { - throw new NodeOperationError(this.getNode(), 'At least one condition must be added.', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'At least one condition must be added.', + { itemIndex: i }, + ); } } else if (filterType === 'json') { const filterJsonRules = this.getNodeParameter('filterJson', i) as string; if (validateJSON(filterJsonRules) !== undefined) { Object.assign(filterJson, JSON.parse(filterJsonRules) as IFilter); } else { - throw new NodeOperationError(this.getNode(), 'Filter (JSON) must be a valid json', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Filter (JSON) must be a valid json', { + itemIndex: i, + }); } } body.filterJson = JSON.stringify(filterJson); @@ -178,16 +168,31 @@ export class AgileCrm implements INodeType { if (returnAll) { body.page_size = 100; - responseData = await agileCrmApiRequestAllItems.call(this, 'POST', `api/filters/filter/dynamic-filter`, body, undefined, undefined, true); + responseData = await agileCrmApiRequestAllItems.call( + this, + 'POST', + `api/filters/filter/dynamic-filter`, + body, + undefined, + undefined, + true, + ); } else { body.page_size = this.getNodeParameter('limit', 0) as number; - responseData = await agileCrmApiRequest.call(this, 'POST', `api/filters/filter/dynamic-filter`, body, undefined, undefined, true); + responseData = await agileCrmApiRequest.call( + this, + 'POST', + `api/filters/filter/dynamic-filter`, + body, + undefined, + undefined, + true, + ); } if (simple) { responseData = simplifyResponse(responseData); } - } else if (operation === 'create') { const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean; const body: IContact = {}; @@ -197,18 +202,17 @@ export class AgileCrm implements INodeType { 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 company, add 'company' as type. default is person @@ -254,7 +258,7 @@ export class AgileCrm implements INodeType { } if (additionalFields.emailOptions) { //@ts-ignore - additionalFields.emailOptions.emailProperties.map(property => { + additionalFields.emailOptions.emailProperties.map((property) => { properties.push({ type: 'SYSTEM', subtype: property.subtype as string, @@ -265,7 +269,7 @@ export class AgileCrm implements INodeType { } if (additionalFields.addressOptions) { //@ts-ignore - additionalFields.addressOptions.addressProperties.map(property => { + additionalFields.addressOptions.addressProperties.map((property) => { properties.push({ type: 'SYSTEM', subtype: property.subtype as string, @@ -277,7 +281,7 @@ export class AgileCrm implements INodeType { if (additionalFields.phoneOptions) { //@ts-ignore - additionalFields.phoneOptions.phoneProperties.map(property => { + additionalFields.phoneOptions.phoneProperties.map((property) => { properties.push({ type: 'SYSTEM', subtype: property.subtype as string, @@ -310,12 +314,11 @@ export class AgileCrm implements INodeType { value: additionalFields.phone as string, } as IDataObject); } - } if (additionalFields.websiteOptions) { //@ts-ignore - additionalFields.websiteOptions.websiteProperties.map(property => { + additionalFields.websiteOptions.websiteProperties.map((property) => { properties.push({ type: 'SYSTEM', subtype: property.subtype as string, @@ -327,7 +330,7 @@ export class AgileCrm implements INodeType { if (additionalFields.customProperties) { //@ts-ignore - additionalFields.customProperties.customProperty.map(property => { + additionalFields.customProperties.customProperty.map((property) => { properties.push({ type: 'CUSTOM', subtype: property.subtype as string, @@ -337,11 +340,9 @@ export class AgileCrm implements INodeType { }); } body.properties = properties; - } const endpoint = 'api/contacts'; responseData = await agileCrmApiRequest.call(this, 'POST', endpoint, body); - } else if (operation === 'update') { const contactId = this.getNodeParameter(idGetter, i) as string; const contactUpdatePayload: IContactUpdate = { id: contactId }; @@ -353,13 +354,14 @@ export class AgileCrm implements INodeType { 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 { @@ -374,7 +376,6 @@ export class AgileCrm implements INodeType { // Contact specific properties if (resource === 'contact') { - if (additionalFields.leadScore) { body.lead_score = additionalFields.leadScore as string; } @@ -409,7 +410,7 @@ export class AgileCrm implements INodeType { } if (additionalFields.emailOptions) { //@ts-ignore - additionalFields.emailOptions.emailProperties.map(property => { + additionalFields.emailOptions.emailProperties.map((property) => { properties.push({ type: 'SYSTEM', subtype: property.subtype as string, @@ -420,7 +421,7 @@ export class AgileCrm implements INodeType { } if (additionalFields.addressOptions) { //@ts-ignore - additionalFields.addressOptions.addressProperties.map(property => { + additionalFields.addressOptions.addressProperties.map((property) => { properties.push({ type: 'SYSTEM', subtype: property.subtype as string, @@ -432,7 +433,7 @@ export class AgileCrm implements INodeType { if (additionalFields.phoneOptions) { //@ts-ignore - additionalFields.phoneOptions.phoneProperties.map(property => { + additionalFields.phoneOptions.phoneProperties.map((property) => { properties.push({ type: 'SYSTEM', subtype: property.subtype as string, @@ -465,12 +466,11 @@ export class AgileCrm implements INodeType { value: additionalFields.phone as string, } as IDataObject); } - } if (additionalFields.websiteOptions) { //@ts-ignore - additionalFields.websiteOptions.websiteProperties.map(property => { + additionalFields.websiteOptions.websiteProperties.map((property) => { properties.push({ type: 'SYSTEM', subtype: property.subtype as string, @@ -481,7 +481,7 @@ export class AgileCrm implements INodeType { } if (additionalFields.customProperties) { //@ts-ignore - additionalFields.customProperties.customProperty.map(property => { + additionalFields.customProperties.customProperty.map((property) => { properties.push({ type: 'CUSTOM', subtype: property.subtype as string, @@ -496,35 +496,33 @@ export class AgileCrm implements INodeType { Object.assign(contactUpdatePayload, body); responseData = await agileCrmApiRequestUpdate.call(this, 'PUT', '', contactUpdatePayload); - } - } else if (resource === 'deal') { - if (operation === 'get') { const dealId = this.getNodeParameter('dealId', i) as string; const endpoint = `api/opportunity/${dealId}`; responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, {}); - } else if (operation === 'delete') { const contactId = this.getNodeParameter('dealId', i) as string; const endpoint = `api/opportunity/${contactId}`; responseData = await agileCrmApiRequest.call(this, 'DELETE', endpoint, {}); - } else if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', 0) as boolean; const endpoint = 'api/opportunity'; if (returnAll) { const limit = 100; - responseData = await agileCrmApiRequestAllItems.call(this, 'GET', endpoint, undefined, { page_size: limit }); + responseData = await agileCrmApiRequestAllItems.call(this, 'GET', endpoint, undefined, { + page_size: limit, + }); } else { const limit = this.getNodeParameter('limit', 0) as number; - responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, undefined, { page_size: limit }); + responseData = await agileCrmApiRequest.call(this, 'GET', endpoint, undefined, { + page_size: limit, + }); } - } else if (operation === 'create') { const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean; @@ -537,10 +535,13 @@ export class AgileCrm implements INodeType { 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; @@ -558,12 +559,10 @@ export class AgileCrm implements INodeType { // @ts-ignore body.customData = additionalFields.customData.customProperty as IDealCustomProperty[]; } - } const endpoint = 'api/opportunity'; responseData = await agileCrmApiRequest.call(this, 'POST', endpoint, body); - } else if (operation === 'update') { const jsonParameters = this.getNodeParameter('jsonParameters', i) as boolean; @@ -573,16 +572,16 @@ export class AgileCrm implements INodeType { 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 valid JSON', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Additional fields must be valid JSON', + { itemIndex: i }, + ); } } - } else { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; body.id = this.getNodeParameter('dealId', i) as number; @@ -607,7 +606,6 @@ export class AgileCrm implements INodeType { // @ts-ignore body.customData = additionalFields.customData.customProperty as IDealCustomProperty[]; } - } const endpoint = 'api/opportunity/partial-update'; @@ -620,10 +618,8 @@ export class AgileCrm implements INodeType { } else { returnData.push(responseData as IDataObject); } - } return [this.helpers.returnJsonArray(returnData)]; } - } diff --git a/packages/nodes-base/nodes/AgileCrm/CompanyDescription.ts b/packages/nodes-base/nodes/AgileCrm/CompanyDescription.ts index f35fec04507b8..1fc276e7ecf55 100644 --- a/packages/nodes-base/nodes/AgileCrm/CompanyDescription.ts +++ b/packages/nodes-base/nodes/AgileCrm/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: [ @@ -62,12 +58,8 @@ export const companyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'get', - ], + resource: ['company'], + operation: ['get'], }, }, default: '', @@ -83,12 +75,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], + resource: ['company'], + operation: ['getAll'], }, }, default: false, @@ -103,15 +91,9 @@ export const companyFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['company'], + operation: ['getAll'], + returnAll: [false], }, }, default: 20, @@ -138,12 +120,8 @@ export const companyFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], + resource: ['company'], + operation: ['getAll'], }, }, default: 'none', @@ -164,15 +142,9 @@ export const companyFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], - filterType: [ - 'manual', - ], + resource: ['company'], + operation: ['getAll'], + filterType: ['manual'], }, }, default: 'anyFilter', @@ -183,12 +155,8 @@ export const companyFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], + resource: ['company'], + operation: ['getAll'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-default-wrong-for-simplify @@ -204,15 +172,9 @@ export const companyFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], - filterType: [ - 'manual', - ], + resource: ['company'], + operation: ['getAll'], + filterType: ['manual'], }, }, default: {}, @@ -277,9 +239,7 @@ export const companyFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - condition_type: [ - 'BETWEEN', - ], + condition_type: ['BETWEEN'], }, }, default: '', @@ -289,20 +249,15 @@ export const companyFields: INodeProperties[] = [ ], }, { - displayName: 'See Agile CRM guide to creating filters', + displayName: + 'See Agile CRM guide to creating filters', name: 'jsonNotice', type: 'notice', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], - filterType: [ - 'json', - ], + resource: ['company'], + operation: ['getAll'], + filterType: ['json'], }, }, default: '', @@ -316,15 +271,9 @@ export const companyFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], - filterType: [ - 'json', - ], + resource: ['company'], + operation: ['getAll'], + filterType: ['json'], }, }, default: '', @@ -337,12 +286,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], + resource: ['company'], + operation: ['getAll'], }, }, options: [ @@ -398,12 +343,8 @@ export const companyFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], + resource: ['company'], + operation: ['create'], }, }, }, @@ -417,18 +358,13 @@ export const companyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['company'], + operation: ['create'], + jsonParameters: [true], }, }, - description: 'Object of values to set as described here', + description: + 'Object of values to set as described here', }, { displayName: 'Additional Fields', @@ -438,15 +374,9 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['company'], + operation: ['create'], + jsonParameters: [false], }, }, options: [ @@ -522,7 +452,8 @@ export const companyFields: INodeProperties[] = [ multipleValueButtonText: 'Add Tag', }, default: [], - description: 'Unique identifiers added to company, for easy management of companys. This is not applicable for companies.', + description: + 'Unique identifiers added to company, for easy management of companys. This is not applicable for companies.', }, { displayName: 'Website', @@ -656,12 +587,8 @@ export const companyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'delete', - ], + resource: ['company'], + operation: ['delete'], }, }, default: '', @@ -678,12 +605,8 @@ export const companyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'update', - ], + resource: ['company'], + operation: ['update'], }, }, default: '', @@ -696,12 +619,8 @@ export const companyFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'update', - ], + resource: ['company'], + operation: ['update'], }, }, }, @@ -715,18 +634,13 @@ export const companyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['company'], + operation: ['update'], + jsonParameters: [true], }, }, - description: 'Object of values to set as described here', + description: + 'Object of values to set as described here', }, { displayName: 'Additional Fields', @@ -736,15 +650,9 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'update', - ], - jsonParameters: [ - false, - ], + resource: ['company'], + operation: ['update'], + jsonParameters: [false], }, }, options: [ @@ -806,7 +714,8 @@ export const companyFields: INodeProperties[] = [ multipleValueButtonText: 'Add Tag', }, default: [], - description: 'Unique identifiers added to company, for easy management of companys. This is not applicable for companies.', + description: + 'Unique identifiers added to company, for easy management of companys. This is not applicable for companies.', }, { displayName: 'Name', @@ -943,5 +852,4 @@ export const companyFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/AgileCrm/ContactDescription.ts b/packages/nodes-base/nodes/AgileCrm/ContactDescription.ts index 502f2cba2eecf..aa33268975123 100644 --- a/packages/nodes-base/nodes/AgileCrm/ContactDescription.ts +++ b/packages/nodes-base/nodes/AgileCrm/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[] = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], + resource: ['contact'], + operation: ['get'], }, }, default: '', @@ -83,12 +75,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, default: false, @@ -103,15 +91,9 @@ export const contactFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['contact'], + operation: ['getAll'], + returnAll: [false], }, }, default: 20, @@ -138,12 +120,8 @@ export const contactFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, default: 'none', @@ -164,15 +142,9 @@ export const contactFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], - filterType: [ - 'manual', - ], + resource: ['contact'], + operation: ['getAll'], + filterType: ['manual'], }, }, default: 'anyFilter', @@ -183,12 +155,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-default-wrong-for-simplify @@ -204,15 +172,9 @@ export const contactFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], - filterType: [ - 'manual', - ], + resource: ['contact'], + operation: ['getAll'], + filterType: ['manual'], }, }, default: {}, @@ -277,9 +239,7 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - condition_type: [ - 'BETWEEN', - ], + condition_type: ['BETWEEN'], }, }, default: '', @@ -289,20 +249,15 @@ export const contactFields: INodeProperties[] = [ ], }, { - displayName: 'See Agile CRM guide to creating filters', + displayName: + 'See Agile CRM guide to creating filters', name: 'jsonNotice', type: 'notice', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], - filterType: [ - 'json', - ], + resource: ['contact'], + operation: ['getAll'], + filterType: ['json'], }, }, default: '', @@ -316,15 +271,9 @@ export const contactFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], - filterType: [ - 'json', - ], + resource: ['contact'], + operation: ['getAll'], + filterType: ['json'], }, }, default: '', @@ -337,12 +286,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, options: [ @@ -399,12 +344,8 @@ export const contactFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, }, @@ -418,19 +359,14 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['contact'], + operation: ['create'], + jsonParameters: [true], }, }, - description: 'Object of values to set as described here', + description: + 'Object of values to set as described here', }, { @@ -441,15 +377,9 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['contact'], + operation: ['create'], + jsonParameters: [false], }, }, options: [ @@ -682,7 +612,8 @@ export const contactFields: INodeProperties[] = [ multipleValueButtonText: 'Add Tag', }, default: [], - description: 'Unique identifiers added to contact, for easy management of contacts. This is not applicable for companies.', + description: + 'Unique identifiers added to contact, for easy management of contacts. This is not applicable for companies.', }, { displayName: 'Title', @@ -823,12 +754,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'delete', - ], + resource: ['contact'], + operation: ['delete'], }, }, default: '', @@ -845,12 +772,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, default: '', @@ -863,12 +786,8 @@ export const contactFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, }, @@ -882,18 +801,13 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['contact'], + operation: ['update'], + jsonParameters: [true], }, }, - description: 'Object of values to set as described here', + description: + 'Object of values to set as described here', }, { displayName: 'Additional Fields', @@ -903,15 +817,9 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], - jsonParameters: [ - false, - ], + resource: ['contact'], + operation: ['update'], + jsonParameters: [false], }, }, options: [ @@ -1144,7 +1052,8 @@ export const contactFields: INodeProperties[] = [ multipleValueButtonText: 'Add Tag', }, default: [], - description: 'Unique identifiers added to contact, for easy management of contacts. This is not applicable for companies.', + description: + 'Unique identifiers added to contact, for easy management of contacts. This is not applicable for companies.', }, { displayName: 'Title', @@ -1274,5 +1183,4 @@ export const contactFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/AgileCrm/ContactInterface.ts b/packages/nodes-base/nodes/AgileCrm/ContactInterface.ts index 3a18ed3e154aa..006c065228409 100644 --- a/packages/nodes-base/nodes/AgileCrm/ContactInterface.ts +++ b/packages/nodes-base/nodes/AgileCrm/ContactInterface.ts @@ -1,6 +1,4 @@ -import { - IDataObject, -} from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export interface IProperty { type: string; diff --git a/packages/nodes-base/nodes/AgileCrm/DealDescription.ts b/packages/nodes-base/nodes/AgileCrm/DealDescription.ts index fda45fcee5981..e48aed426a668 100644 --- a/packages/nodes-base/nodes/AgileCrm/DealDescription.ts +++ b/packages/nodes-base/nodes/AgileCrm/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: [ @@ -46,7 +42,6 @@ export const dealOperations: INodeProperties[] = [ description: 'Update deal properties', action: 'Update a deal', }, - ], default: 'get', }, @@ -63,19 +58,14 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'get', - ], + resource: ['deal'], + operation: ['get'], }, }, default: '', description: 'Unique identifier for a particular deal', }, - /* -------------------------------------------------------------------------- */ /* deal:get all */ /* -------------------------------------------------------------------------- */ @@ -90,15 +80,9 @@ export const dealFields: INodeProperties[] = [ default: 20, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['deal'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -108,12 +92,8 @@ export const dealFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'getAll', - ], + resource: ['deal'], + operation: ['getAll'], }, }, default: false, @@ -129,15 +109,9 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['deal'], + operation: ['create'], + jsonParameters: [false], }, }, default: '', @@ -154,15 +128,9 @@ export const dealFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['deal'], + operation: ['create'], + jsonParameters: [false], }, }, default: 1, @@ -175,15 +143,9 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['deal'], + operation: ['create'], + jsonParameters: [false], }, }, default: '', @@ -196,15 +158,9 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['deal'], + operation: ['create'], + jsonParameters: [false], }, }, default: '', @@ -221,15 +177,9 @@ export const dealFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['deal'], + operation: ['create'], + jsonParameters: [false], }, }, default: 50, @@ -242,12 +192,8 @@ export const dealFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, }, @@ -261,18 +207,13 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['deal'], + operation: ['create'], + jsonParameters: [true], }, }, - description: 'Object of values to set as described here', + description: + 'Object of values to set as described here', }, { displayName: 'Additional Fields', @@ -282,15 +223,9 @@ export const dealFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['deal'], + operation: ['create'], + jsonParameters: [false], }, }, options: [ @@ -350,12 +285,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'delete', - ], + resource: ['deal'], + operation: ['delete'], }, }, default: '', @@ -372,12 +303,8 @@ export const dealFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], + resource: ['deal'], + operation: ['update'], }, }, default: '', @@ -390,12 +317,8 @@ export const dealFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], + resource: ['deal'], + operation: ['update'], }, }, }, @@ -409,19 +332,14 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], - jsonParameters: [ - true, - ], + resource: ['deal'], + operation: ['update'], + jsonParameters: [true], }, }, - description: 'Object of values to set as described here', + description: + 'Object of values to set as described here', }, { displayName: 'Additional Fields', @@ -431,15 +349,9 @@ export const dealFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], - jsonParameters: [ - false, - ], + resource: ['deal'], + operation: ['update'], + jsonParameters: [false], }, }, options: [ diff --git a/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts b/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts index 07464bd9831d2..4273d0b87a990 100644 --- a/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts @@ -7,28 +7,28 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, - NodeApiError, -} from 'n8n-workflow'; - -import { - IContactUpdate, -} from './ContactInterface'; - -import { - IFilterRules, - ISearchConditions, -} from './FilterInterface'; - -export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, - method: string, endpoint: string, body: any = {}, query: IDataObject = {}, uri?: string, sendAsForm?: boolean): Promise { // tslint:disable-line:no-any - +import { IDataObject, NodeApiError } from 'n8n-workflow'; + +import { IContactUpdate } from './ContactInterface'; + +import { IFilterRules, ISearchConditions } from './FilterInterface'; + +export async function agileCrmApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + uri?: string, + sendAsForm?: boolean, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('agileCrmApi'); const options: OptionsWithUri = { method, headers: { - 'Accept': 'application/json', + Accept: 'application/json', }, auth: { username: credentials.email as string, @@ -40,7 +40,7 @@ export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunction }; // To send the request as 'content-type': 'application/x-www-form-urlencoded' add form to options instead of body - if(sendAsForm) { + if (sendAsForm) { options.form = body; } // Only add Body property if method not GET or DELETE to avoid 400 response @@ -56,38 +56,63 @@ export async function agileCrmApiRequest(this: IHookFunctions | IExecuteFunction } } -export async function agileCrmApiRequestAllItems(this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, - method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, sendAsForm?: boolean): Promise { // tslint:disable-line:no-any +export async function agileCrmApiRequestAllItems( + this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + uri?: string, + sendAsForm?: boolean, + // tslint:disable-next-line:no-any +): Promise { // https://github.com/agilecrm/rest-api#11-listing-contacts- const returnData: IDataObject[] = []; let responseData; do { - responseData = await agileCrmApiRequest.call(this, method, resource, body, query, uri, sendAsForm); + responseData = await agileCrmApiRequest.call( + this, + method, + resource, + body, + query, + uri, + sendAsForm, + ); if (responseData.length !== 0) { returnData.push.apply(returnData, responseData); if (sendAsForm) { - body.cursor = responseData[responseData.length-1].cursor; + body.cursor = responseData[responseData.length - 1].cursor; } else { - query.cursor = responseData[responseData.length-1].cursor; + query.cursor = responseData[responseData.length - 1].cursor; } } } while ( - responseData.length !== 0 && - responseData[responseData.length-1].hasOwnProperty('cursor') - ); + responseData.length !== 0 && + responseData[responseData.length - 1].hasOwnProperty('cursor') + ); return returnData; } -export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method = 'PUT', endpoint?: string, body: any = {}, query: IDataObject = {}, uri?: string): Promise { // tslint:disable-line:no-any - +export async function agileCrmApiRequestUpdate( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method = 'PUT', + 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('agileCrmApi'); const baseUri = `https://${credentials.subdomain}.agilecrm.com/dev/`; const options: OptionsWithUri = { method, headers: { - 'Accept': 'application/json', + Accept: 'application/json', }, body: { id: body.id }, auth: { @@ -110,7 +135,8 @@ export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFu lastSuccesfulUpdateReturn = await this.helpers.request!(options); // Iterate trough properties and show them as individial updates instead of only vague "properties" - payload.properties?.map((property: any) => { // tslint:disable-line:no-any + // tslint:disable-next-line:no-any + payload.properties?.map((property: any) => { successfulUpdates.push(`${property.name}`); }); @@ -147,18 +173,21 @@ export async function agileCrmApiRequestUpdate(this: IHookFunctions | IExecuteFu } return lastSuccesfulUpdateReturn; - } catch (error) { if (successfulUpdates.length === 0) { throw new NodeApiError(this.getNode(), error); } else { - throw new NodeApiError(this.getNode(), error, { message: `Not all properties updated. Updated properties: ${successfulUpdates.join(', ')}`, description: error.message, httpCode: error.statusCode }); + throw new NodeApiError(this.getNode(), error, { + message: `Not all properties updated. Updated properties: ${successfulUpdates.join(', ')}`, + description: error.message, + httpCode: error.statusCode, + }); } } - } -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!); @@ -168,7 +197,7 @@ export function validateJSON(json: string | undefined): any { // tslint:disable- return result; } -export function getFilterRules(conditions: ISearchConditions[], matchType: string): IDataObject { // tslint:disable-line:no-any +export function getFilterRules(conditions: ISearchConditions[], matchType: string): IDataObject { const rules = []; for (const key in conditions) { @@ -180,7 +209,7 @@ export function getFilterRules(conditions: ISearchConditions[], matchType: strin RHS: searchConditions.value as string, RHS_NEW: searchConditions.value2 as string, }; - rules.push(rule); + rules.push(rule); } } @@ -188,18 +217,24 @@ export function getFilterRules(conditions: ISearchConditions[], matchType: strin return { or_rules: rules, }; - } - else { + } else { return { rules, }; } } -export function simplifyResponse(records: [{ id: string, properties: [{ name: string, value: string }] } ]) { +export function simplifyResponse( + records: [{ id: string; properties: [{ name: string; value: string }] }], +) { const results = []; for (const record of records) { - results.push(record.properties.reduce((obj, value) => Object.assign(obj, { [`${value.name}`]: value.value }), { id: record.id })); + results.push( + record.properties.reduce( + (obj, value) => Object.assign(obj, { [`${value.name}`]: value.value }), + { id: record.id }, + ), + ); } return results; } diff --git a/packages/nodes-base/nodes/Airtable/Airtable.node.ts b/packages/nodes-base/nodes/Airtable/Airtable.node.ts index c330f247e8d9d..a8a77fa66db8f 100644 --- a/packages/nodes-base/nodes/Airtable/Airtable.node.ts +++ b/packages/nodes-base/nodes/Airtable/Airtable.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, - downloadRecordAttachments, -} from './GenericFunctions'; +import { apiRequest, apiRequestAllItems, downloadRecordAttachments } from './GenericFunctions'; export class Airtable implements INodeType { description: INodeTypeDescription = { @@ -106,9 +100,7 @@ export class Airtable implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'append', - ], + operation: ['append'], }, }, default: true, @@ -124,12 +116,8 @@ export class Airtable implements INodeType { }, displayOptions: { show: { - addAllFields: [ - false, - ], - operation: [ - 'append', - ], + addAllFields: [false], + operation: ['append'], }, }, default: [], @@ -147,9 +135,7 @@ export class Airtable implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], }, }, default: '', @@ -166,9 +152,7 @@ export class Airtable implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'list', - ], + operation: ['list'], }, }, default: true, @@ -180,12 +164,8 @@ export class Airtable implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'list', - ], - returnAll: [ - false, - ], + operation: ['list'], + returnAll: [false], }, }, typeOptions: { @@ -201,13 +181,11 @@ export class Airtable implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'list', - ], + operation: ['list'], }, }, 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', @@ -216,16 +194,13 @@ export class Airtable implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'list', - ], - downloadAttachments: [ - true, - ], + operation: ['list'], + 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 and cannot include spaces after a comma.', + description: + "Name of the fields of type 'attachment' that should be downloaded. Multiple ones can be defined separated by comma. Case sensitive and cannot include spaces after a comma.", }, { displayName: 'Additional Options', @@ -233,9 +208,7 @@ export class Airtable implements INodeType { type: 'collection', displayOptions: { show: { - operation: [ - 'list', - ], + operation: ['list'], }, }, default: {}, @@ -252,15 +225,17 @@ export class Airtable implements INodeType { }, default: [], placeholder: 'Name', - description: 'Only data for fields whose names are in this list will be included in the records', + description: + 'Only data for fields whose names are in this list will be included in the records', }, { displayName: 'Filter By Formula', name: 'filterByFormula', type: 'string', default: '', - placeholder: 'NOT({Name} = \'\')', - description: 'A formula used to filter records. The formula will be evaluated for each record, and if the result is not 0, false, "", NaN, [], or #Error! the record will be included in the response.', + placeholder: "NOT({Name} = '')", + description: + 'A formula used to filter records. The formula will be evaluated for each record, and if the result is not 0, false, "", NaN, [], or #Error! the record will be included in the response.', }, { displayName: 'Sort', @@ -313,7 +288,8 @@ export class Airtable 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.', }, ], }, @@ -327,9 +303,7 @@ export class Airtable implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'read', - ], + operation: ['read'], }, }, default: '', @@ -346,9 +320,7 @@ export class Airtable implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: '', @@ -361,9 +333,7 @@ export class Airtable implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: true, @@ -379,12 +349,8 @@ export class Airtable implements INodeType { }, displayOptions: { show: { - updateAllFields: [ - false, - ], - operation: [ - 'update', - ], + updateAllFields: [false], + operation: ['update'], }, }, default: [], @@ -403,11 +369,7 @@ export class Airtable implements INodeType { placeholder: 'Add Option', displayOptions: { show: { - operation: [ - 'append', - 'delete', - 'update', - ], + operation: ['append', 'delete', 'update'], }, }, default: {}, @@ -429,12 +391,8 @@ export class Airtable implements INodeType { type: 'string', displayOptions: { show: { - '/operation': [ - 'update', - ], - '/updateAllFields': [ - true, - ], + '/operation': ['update'], + '/updateAllFields': [true], }, }, default: '', @@ -446,14 +404,12 @@ export class Airtable implements INodeType { type: 'boolean', displayOptions: { show: { - '/operation': [ - 'append', - 'update', - ], + '/operation': ['append', 'update'], }, }, default: false, - description: 'Whether the Airtable API should attempt mapping of string values for linked records & select options', + description: + 'Whether the Airtable API should attempt mapping of string values for linked records & select options', }, ], }, @@ -496,7 +452,7 @@ export class Airtable implements INodeType { try { addAllFields = this.getNodeParameter('addAllFields', i) as boolean; options = this.getNodeParameter('options', i, {}) as IDataObject; - bulkSize = options.bulkSize as number || bulkSize; + bulkSize = (options.bulkSize as number) || bulkSize; const row: IDataObject = {}; @@ -540,13 +496,12 @@ export class Airtable implements INodeType { throw error; } } - } else if (operation === 'delete') { requestMethod = 'DELETE'; const rows: string[] = []; const options = this.getNodeParameter('options', 0, {}) as IDataObject; - const bulkSize = options.bulkSize as number || 10; + const bulkSize = (options.bulkSize as number) || 10; for (let i = 0; i < items.length; i++) { try { @@ -581,7 +536,6 @@ export class Airtable implements INodeType { throw error; } } - } else if (operation === 'list') { // ---------------------------------- // list @@ -614,8 +568,14 @@ export class Airtable implements INodeType { returnData.push.apply(returnData, responseData.records); if (downloadAttachments === true) { - const downloadFieldNames = (this.getNodeParameter('downloadFieldNames', 0) as string).split(','); - const data = await downloadRecordAttachments.call(this, responseData.records, downloadFieldNames); + const downloadFieldNames = ( + this.getNodeParameter('downloadFieldNames', 0) as string + ).split(','); + const data = await downloadRecordAttachments.call( + this, + responseData.records, + downloadFieldNames, + ); return [data]; } } catch (error) { @@ -625,7 +585,6 @@ export class Airtable implements INodeType { throw error; } } - } else if (operation === 'read') { // ---------------------------------- // read @@ -635,7 +594,6 @@ export class Airtable implements INodeType { let id: string; for (let i = 0; i < items.length; i++) { - id = this.getNodeParameter('id', i) as string; endpoint = `${application}/${table}/${id}`; @@ -658,7 +616,6 @@ export class Airtable implements INodeType { throw error; } } - } else if (operation === 'update') { // ---------------------------------- // update @@ -677,7 +634,7 @@ export class Airtable implements INodeType { try { updateAllFields = this.getNodeParameter('updateAllFields', i) as boolean; options = this.getNodeParameter('options', i, {}) as IDataObject; - bulkSize = options.bulkSize as number || bulkSize; + bulkSize = (options.bulkSize as number) || bulkSize; const row: IDataObject = {}; row.fields = {} as IDataObject; @@ -690,7 +647,10 @@ export class Airtable implements INodeType { delete (row.fields! as any).id; if (options.ignoreFields && options.ignoreFields !== '') { - const ignoreFields = (options.ignoreFields as string).split(',').map(field => field.trim()).filter(field => !!field); + const ignoreFields = (options.ignoreFields as string) + .split(',') + .map((field) => field.trim()) + .filter((field) => !!field); if (ignoreFields.length) { // From: https://stackoverflow.com/questions/17781472/how-to-get-a-subset-of-a-javascript-objects-properties row.fields = Object.entries(items[i].json) @@ -721,7 +681,7 @@ export class Airtable implements INodeType { // according to specific rules like not more than 5 requests // per seconds. - const data = { records: rows, typecast: (options.typecast) ? true : false }; + const data = { records: rows, typecast: options.typecast ? true : false }; responseData = await apiRequest.call(this, requestMethod, endpoint, data, qs); @@ -738,7 +698,6 @@ export class Airtable implements INodeType { throw error; } } - } else { throw new NodeOperationError(this.getNode(), `The operation "${operation}" is not known!`); } diff --git a/packages/nodes-base/nodes/Airtable/AirtableTrigger.node.ts b/packages/nodes-base/nodes/Airtable/AirtableTrigger.node.ts index b423c15a04891..98f6b77a244c9 100644 --- a/packages/nodes-base/nodes/Airtable/AirtableTrigger.node.ts +++ b/packages/nodes-base/nodes/Airtable/AirtableTrigger.node.ts @@ -1,6 +1,4 @@ -import { - IPollFunctions, -} from 'n8n-core'; +import { IPollFunctions } from 'n8n-core'; import { IDataObject, @@ -10,10 +8,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - apiRequestAllItems, - downloadRecordAttachments, -} from './GenericFunctions'; +import { apiRequestAllItems, downloadRecordAttachments } from './GenericFunctions'; import moment from 'moment'; @@ -60,7 +55,8 @@ export class AirtableTrigger implements INodeType { name: 'triggerField', type: 'string', default: '', - description: 'A Created Time or Last Modified Time field that will be used to sort records. If you do not have a Created Time or Last Modified Time field in your schema, please create one, because without this field trigger will not work correctly.', + description: + 'A Created Time or Last Modified Time field that will be used to sort records. If you do not have a Created Time or Last Modified Time field in your schema, please create one, because without this field trigger will not work correctly.', required: true, }, { @@ -68,7 +64,7 @@ export class AirtableTrigger implements INodeType { name: 'downloadAttachments', type: 'boolean', 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', @@ -77,13 +73,12 @@ export class AirtableTrigger implements INodeType { required: true, displayOptions: { show: { - downloadAttachments: [ - true, - ], + 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: 'Additional Fields', @@ -98,21 +93,24 @@ export class AirtableTrigger implements INodeType { type: 'string', default: '', // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id - description: 'Fields to be included in the response. Multiple ones can be set separated by comma. Example: name, id. By default just the trigger field will be included.', + description: + 'Fields to be included in the response. Multiple ones can be set separated by comma. Example: name, id. By default just the trigger field will be included.', }, { displayName: 'Formula', name: 'formula', type: 'string', default: '', - description: 'Formulas may involve functions, numeric operations, logical operations, and text operations that operate on fields. More info here.', + description: + 'Formulas may involve functions, numeric operations, logical operations, and text operations that operate on fields. More info here.', }, { displayName: 'View ID', name: 'viewId', type: 'string', default: '', - description: 'The name or ID of a view in the table. If set, only the records in that view will be returned.', + description: + 'The name or ID of a view in the table. If set, only the records in that view will be returned.', }, ], }, @@ -138,7 +136,7 @@ export class AirtableTrigger implements INodeType { const now = moment().utc().format(); - const startDate = webhookData.lastTimeChecked as string || now; + const startDate = (webhookData.lastTimeChecked as string) || now; const endDate = now; @@ -171,7 +169,9 @@ export class AirtableTrigger implements INodeType { } if (downloadAttachments === true) { - const downloadFieldNames = (this.getNodeParameter('downloadFieldNames', 0) as string).split(','); + const downloadFieldNames = (this.getNodeParameter('downloadFieldNames', 0) as string).split( + ',', + ); const data = await downloadRecordAttachments.call(this, records, downloadFieldNames); return [data]; } diff --git a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts index 05057a6e3faf5..542483ab47b88 100644 --- a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts @@ -1,11 +1,6 @@ -import { - IExecuteFunctions, - IPollFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IPollFunctions } from 'n8n-core'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IBinaryKeyData, @@ -15,7 +10,6 @@ import { NodeApiError, } from 'n8n-workflow'; - interface IAttachment { url: string; filename: string; @@ -24,7 +18,7 @@ interface IAttachment { export interface IRecord { fields: { - [key: string]: string | IAttachment[], + [key: string]: string | IAttachment[]; }; } @@ -37,7 +31,16 @@ export interface IRecord { * @param {object} body * @returns {Promise} */ -export async function apiRequest(this: 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: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, + method: string, + endpoint: string, + body: object, + query?: IDataObject, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('airtableApi'); query = query || {}; @@ -48,8 +51,7 @@ export async function apiRequest(this: IExecuteFunctions | ILoadOptionsFunctions // query.api_key = credentials.apiKey; const options: OptionsWithUri = { - headers: { - }, + headers: {}, method, body, qs: query, @@ -73,7 +75,6 @@ export async function apiRequest(this: IExecuteFunctions | ILoadOptionsFunctions } } - /** * Make an API request to paginated Airtable endpoint * and return all results @@ -86,8 +87,14 @@ export async function apiRequest(this: IExecuteFunctions | ILoadOptionsFunctions * @param {IDataObject} [query] * @returns {Promise} */ -export async function apiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, method: string, endpoint: string, body: IDataObject, query?: IDataObject): Promise { // tslint:disable-line:no-any - +export async function apiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions | IPollFunctions, + method: string, + endpoint: string, + body: IDataObject, + query?: IDataObject, + // tslint:disable-next-line:no-any +): Promise { if (query === undefined) { query = {}; } @@ -102,16 +109,18 @@ export async function apiRequestAllItems(this: IExecuteFunctions | ILoadOptionsF returnData.push.apply(returnData, responseData.records); query.offset = responseData.offset; - } while ( - responseData.offset !== undefined - ); + } while (responseData.offset !== undefined); return { records: returnData, }; } -export async function downloadRecordAttachments(this: IExecuteFunctions | IPollFunctions, records: IRecord[], fieldNames: string[]): Promise { +export async function downloadRecordAttachments( + this: IExecuteFunctions | IPollFunctions, + records: IRecord[], + fieldNames: string[], +): Promise { const elements: INodeExecutionData[] = []; for (const record of records) { const element: INodeExecutionData = { json: {}, binary: {} }; @@ -119,8 +128,15 @@ export async function downloadRecordAttachments(this: IExecuteFunctions | IPollF for (const fieldName of fieldNames) { if (record.fields[fieldName] !== undefined) { for (const [index, attachment] of (record.fields[fieldName] 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.filename, attachment.type); + 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.filename, + attachment.type, + ); } } } diff --git a/packages/nodes-base/nodes/Amqp/Amqp.node.ts b/packages/nodes-base/nodes/Amqp/Amqp.node.ts index d3f3c6f30800b..a780b0b38f895 100644 --- a/packages/nodes-base/nodes/Amqp/Amqp.node.ts +++ b/packages/nodes-base/nodes/Amqp/Amqp.node.ts @@ -1,9 +1,4 @@ -import { - ContainerOptions, - create_container, - Dictionary, - EventContext, -} from 'rhea'; +import { ContainerOptions, create_container, Dictionary, EventContext } from 'rhea'; import { IExecuteFunctions } from 'n8n-core'; import { @@ -28,10 +23,12 @@ export class Amqp implements INodeType { }, inputs: ['main'], outputs: ['main'], - credentials: [{ - name: 'amqp', - required: true, - }], + credentials: [ + { + name: 'amqp', + required: true, + }, + ], properties: [ { displayName: 'Queue / Topic', @@ -47,7 +44,8 @@ export class Amqp implements INodeType { name: 'headerParametersJson', type: 'json', default: '', - description: 'Header parameters as JSON (flat object). Sent as application_properties in amqp-message meta info.', + description: + 'Header parameters as JSON (flat object). Sent as application_properties in amqp-message meta info.', }, { displayName: 'Options', @@ -101,11 +99,13 @@ export class Amqp implements INodeType { const credentials = await this.getCredentials('amqp'); const sink = this.getNodeParameter('sink', 0, '') as string; - const applicationProperties = this.getNodeParameter('headerParametersJson', 0, {}) as string | object; + const applicationProperties = this.getNodeParameter('headerParametersJson', 0, {}) as + | string + | object; const options = this.getNodeParameter('options', 0, {}) as IDataObject; const containerId = options.containerId as string; - const containerReconnect = options.reconnect as boolean || true; - const containerReconnectLimit = options.reconnectLimit as number || 50; + const containerReconnect = (options.reconnect as boolean) || true; + const containerReconnectLimit = (options.reconnectLimit as number) || 50; let headerProperties: Dictionary; // tslint:disable-line:no-any if (typeof applicationProperties === 'string' && applicationProperties !== '') { @@ -177,7 +177,7 @@ export class Amqp implements INodeType { } catch (error) { if (this.continueOnFail()) { return [this.helpers.returnJsonArray({ error: error.message })]; - }else{ + } else { throw error; } } diff --git a/packages/nodes-base/nodes/Amqp/AmqpTrigger.node.ts b/packages/nodes-base/nodes/Amqp/AmqpTrigger.node.ts index 006d72f306617..19460825f8115 100644 --- a/packages/nodes-base/nodes/Amqp/AmqpTrigger.node.ts +++ b/packages/nodes-base/nodes/Amqp/AmqpTrigger.node.ts @@ -1,10 +1,4 @@ -import { - ContainerOptions, - create_container, - EventContext, - Message, - ReceiverOptions, -} from 'rhea'; +import { ContainerOptions, create_container, EventContext, Message, ReceiverOptions } from 'rhea'; import { ITriggerFunctions } from 'n8n-core'; import { @@ -15,7 +9,6 @@ import { NodeOperationError, } from 'n8n-workflow'; - export class AmqpTrigger implements INodeType { description: INodeTypeDescription = { displayName: 'AMQP Trigger', @@ -30,10 +23,12 @@ export class AmqpTrigger implements INodeType { }, inputs: [], outputs: ['main'], - credentials: [{ - name: 'amqp', - required: true, - }], + credentials: [ + { + name: 'amqp', + required: true, + }, + ], properties: [ // Node properties which the user gets displayed and // can change on the node. @@ -80,7 +75,8 @@ export class AmqpTrigger implements INodeType { name: 'jsonConvertByteArrayToString', type: 'boolean', default: false, - description: 'Whether to convert JSON Body content (["body"]["content"]) from Byte Array to string. Needed for Azure Service Bus.', + description: + 'Whether to convert JSON Body content (["body"]["content"]) from Byte Array to string. Needed for Azure Service Bus.', }, { displayName: 'JSON Parse Body', @@ -129,19 +125,17 @@ export class AmqpTrigger implements INodeType { ], }; - async trigger(this: ITriggerFunctions): Promise { - const credentials = await this.getCredentials('amqp'); const sink = this.getNodeParameter('sink', '') as string; const clientname = this.getNodeParameter('clientname', '') as string; const subscription = this.getNodeParameter('subscription', '') as string; const options = this.getNodeParameter('options', {}) as IDataObject; - const pullMessagesNumber = options.pullMessagesNumber as number || 100; + const pullMessagesNumber = (options.pullMessagesNumber as number) || 100; const containerId = options.containerId as string; - const containerReconnect = options.reconnect as boolean || true; - const containerReconnectLimit = options.reconnectLimit as number || 50; + const containerReconnect = (options.reconnect as boolean) || true; + const containerReconnectLimit = (options.reconnectLimit as number) || 50; if (sink === '') { throw new NodeOperationError(this.getNode(), 'Queue or Topic required!'); @@ -163,7 +157,6 @@ export class AmqpTrigger implements INodeType { }); container.on('message', (context: EventContext) => { - // No message in the context if (!context.message) { return; @@ -202,13 +195,12 @@ export class AmqpTrigger implements INodeType { data = data.body; } - self.emit([self.helpers.returnJsonArray([data as any])]); // tslint:disable-line:no-any if (!context.receiver?.has_credit()) { setTimeout(() => { context.receiver?.add_credit(pullMessagesNumber); - }, options.sleepTime as number || 10); + }, (options.sleepTime as number) || 10); } }); @@ -233,14 +225,13 @@ export class AmqpTrigger implements INodeType { name: subscription ? subscription : undefined, source: { address: sink, - durable: (durable ? 2 : undefined), - expiry_policy: (durable ? 'never' : undefined), + durable: durable ? 2 : undefined, + expiry_policy: durable ? 'never' : undefined, }, - credit_window: 0, // prefetch 1 + credit_window: 0, // prefetch 1 }; connection.open_receiver(clientOptions); - // The "closeFunction" function gets called by n8n whenever // the workflow gets deactivated and can so clean up. async function closeFunction() { @@ -257,7 +248,11 @@ export class AmqpTrigger implements INodeType { async function manualTriggerFunction() { await new Promise((resolve, reject) => { const timeoutHandler = setTimeout(() => { - reject(new Error('Aborted, no message received within 30secs. This 30sec timeout is only set for "manually triggered execution". Active Workflows will listen indefinitely.')); + reject( + new Error( + 'Aborted, no message received within 30secs. This 30sec timeout is only set for "manually triggered execution". Active Workflows will listen indefinitely.', + ), + ); }, 30000); container.on('message', (context: EventContext) => { // Check if the only property present in the message is body @@ -279,6 +274,5 @@ export class AmqpTrigger implements INodeType { closeFunction, manualTriggerFunction, }; - } } diff --git a/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts b/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts index 35dc4bf900c77..869dfe81b7de5 100644 --- a/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts +++ b/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -77,10 +75,7 @@ export class ApiTemplateIo implements INodeType { ], displayOptions: { show: { - resource: [ - 'image', - 'pdf', - ], + resource: ['image', 'pdf'], }, }, }, @@ -100,9 +95,7 @@ export class ApiTemplateIo implements INodeType { ], displayOptions: { show: { - resource: [ - 'account', - ], + resource: ['account'], }, }, }, @@ -112,18 +105,15 @@ export class ApiTemplateIo implements INodeType { type: 'options', required: true, default: '', - description: 'ID of the image template to use. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the image template to use. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getImageTemplates', }, displayOptions: { show: { - resource: [ - 'image', - ], - operation: [ - 'create', - ], + resource: ['image'], + operation: ['create'], }, }, }, @@ -133,18 +123,15 @@ export class ApiTemplateIo implements INodeType { type: 'options', required: true, default: '', - description: 'ID of the PDF template to use. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the PDF template to use. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getPdfTemplates', }, displayOptions: { show: { - resource: [ - 'pdf', - ], - operation: [ - 'create', - ], + resource: ['pdf'], + operation: ['create'], }, }, }, @@ -155,13 +142,8 @@ export class ApiTemplateIo implements INodeType { default: false, displayOptions: { show: { - resource: [ - 'pdf', - 'image', - ], - operation: [ - 'create', - ], + resource: ['pdf', 'image'], + operation: ['create'], }, }, }, @@ -172,13 +154,8 @@ export class ApiTemplateIo implements INodeType { default: false, displayOptions: { show: { - resource: [ - 'pdf', - 'image', - ], - operation: [ - 'create', - ], + resource: ['pdf', 'image'], + operation: ['create'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether @@ -193,16 +170,9 @@ export class ApiTemplateIo implements INodeType { description: 'Name of the binary property to which to write to', displayOptions: { show: { - resource: [ - 'pdf', - 'image', - ], - operation: [ - 'create', - ], - download: [ - true, - ], + resource: ['pdf', 'image'], + operation: ['create'], + download: [true], }, }, }, @@ -213,15 +183,9 @@ export class ApiTemplateIo implements INodeType { default: '', displayOptions: { show: { - resource: [ - 'image', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['image'], + operation: ['create'], + jsonParameters: [true], }, }, placeholder: `[ {"name": "text_1", "text": "hello world", "textBackgroundColor": "rgba(246, 243, 243, 0)" } ]`, @@ -233,15 +197,9 @@ export class ApiTemplateIo implements INodeType { default: '', displayOptions: { show: { - resource: [ - 'pdf', - ], - operation: [ - 'create', - ], - jsonParameters: [ - true, - ], + resource: ['pdf'], + operation: ['create'], + jsonParameters: [true], }, }, placeholder: `{ "name": "text_1" }`, @@ -256,15 +214,9 @@ export class ApiTemplateIo implements INodeType { }, displayOptions: { show: { - resource: [ - 'image', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['image'], + operation: ['create'], + jsonParameters: [false], }, }, default: {}, @@ -320,15 +272,9 @@ export class ApiTemplateIo implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'pdf', - ], - operation: [ - 'create', - ], - jsonParameters: [ - false, - ], + resource: ['pdf'], + operation: ['create'], + jsonParameters: [false], }, }, options: [ @@ -361,16 +307,9 @@ export class ApiTemplateIo implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'pdf', - 'image', - ], - 'download': [ - true, - ], + operation: ['create'], + resource: ['pdf', 'image'], + download: [true], }, }, default: {}, @@ -380,7 +319,8 @@ export class ApiTemplateIo implements INodeType { name: 'fileName', type: 'string', default: '', - description: 'The name of the downloaded image/pdf. It has to include the extension. For example: report.pdf', + description: + 'The name of the downloaded image/pdf. It has to include the extension. For example: report.pdf', }, ], }, @@ -410,13 +350,11 @@ export class ApiTemplateIo implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; if (resource === 'account') { - // ********************************************************************* // account // ********************************************************************* if (operation === 'get') { - // ---------------------------------- // account: get // ---------------------------------- @@ -428,16 +366,14 @@ export class ApiTemplateIo implements INodeType { returnData.push(responseData); } catch (error) { if (this.continueOnFail()) { - returnData.push({json:{ error: error.message }}); + returnData.push({ json: { error: error.message } }); continue; } throw error; } } } - } else if (resource === 'image') { - // ********************************************************************* // image // ********************************************************************* @@ -466,12 +402,21 @@ export class ApiTemplateIo implements INodeType { const body = { overrides: [] } as IDataObject; if (jsonParameters === false) { - const overrides = (this.getNodeParameter('overridesUi', i) as IDataObject || {}).overrideValues as IDataObject[] || []; + const overrides = + (((this.getNodeParameter('overridesUi', i) as IDataObject) || {}) + .overrideValues as IDataObject[]) || []; if (overrides.length !== 0) { const data: IDataObject[] = []; for (const override of overrides) { - const properties = (override.propertiesUi as IDataObject || {}).propertyValues as IDataObject[] || []; - data.push(properties.reduce((obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), {})); + const properties = + (((override.propertiesUi as IDataObject) || {}) + .propertyValues as IDataObject[]) || []; + data.push( + properties.reduce( + (obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), + {}, + ), + ); } body.overrides = data; } @@ -480,7 +425,9 @@ export class ApiTemplateIo implements INodeType { if (overrideJson !== '') { const data = validateJSON(overrideJson); if (data === undefined) { - throw new NodeOperationError(this.getNode(), 'A valid JSON must be provided.', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'A valid JSON must be provided.', { + itemIndex: i, + }); } body.overrides = data; } @@ -492,7 +439,10 @@ export class ApiTemplateIo implements INodeType { const binaryProperty = this.getNodeParameter('binaryProperty', i) as string; const data = await downloadImage.call(this, responseData.download_url); const fileName = responseData.download_url.split('/').pop(); - const binaryData = await this.helpers.prepareBinaryData(data, options.fileName || fileName); + const binaryData = await this.helpers.prepareBinaryData( + data, + options.fileName || fileName, + ); responseData = { json: responseData, binary: { @@ -503,7 +453,7 @@ export class ApiTemplateIo implements INodeType { returnData.push(responseData); } catch (error) { if (this.continueOnFail()) { - returnData.push({json:{ error: error.message }}); + returnData.push({ json: { error: error.message } }); continue; } throw error; @@ -514,15 +464,12 @@ export class ApiTemplateIo implements INodeType { return this.prepareOutputData(returnData as unknown as INodeExecutionData[]); } } - } else if (resource === 'pdf') { - // ********************************************************************* // pdf // ********************************************************************* if (operation === 'create') { - // ---------------------------------- // pdf: create // ---------------------------------- @@ -546,16 +493,27 @@ export class ApiTemplateIo implements INodeType { let data; if (jsonParameters === false) { - const properties = (this.getNodeParameter('propertiesUi', i) as IDataObject || {}).propertyValues as IDataObject[] || []; + const properties = + (((this.getNodeParameter('propertiesUi', i) as IDataObject) || {}) + .propertyValues as IDataObject[]) || []; if (properties.length === 0) { - throw new NodeOperationError(this.getNode(), 'The parameter properties cannot be empty', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'The parameter properties cannot be empty', + { itemIndex: i }, + ); } - data = properties.reduce((obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), {}); + data = properties.reduce( + (obj, value) => Object.assign(obj, { [`${value.key}`]: value.value }), + {}, + ); } else { const propertiesJson = this.getNodeParameter('propertiesJson', i) as string; data = validateJSON(propertiesJson); if (data === undefined) { - throw new NodeOperationError(this.getNode(), 'A valid JSON must be provided.', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'A valid JSON must be provided.', { + itemIndex: i, + }); } } @@ -565,7 +523,10 @@ export class ApiTemplateIo implements INodeType { const binaryProperty = this.getNodeParameter('binaryProperty', i) as string; const data = await downloadImage.call(this, responseData.download_url); const fileName = responseData.download_url.split('/').pop(); - const binaryData = await this.helpers.prepareBinaryData(data, options.fileName || fileName); + const binaryData = await this.helpers.prepareBinaryData( + data, + options.fileName || fileName, + ); responseData = { json: responseData, binary: { @@ -576,7 +537,7 @@ export class ApiTemplateIo implements INodeType { returnData.push(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/ApiTemplateIo/GenericFunctions.ts b/packages/nodes-base/nodes/ApiTemplateIo/GenericFunctions.ts index 8e1a273b01458..fe5ac6291389f 100644 --- a/packages/nodes-base/nodes/ApiTemplateIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ApiTemplateIo/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 { NodeApiError } from 'n8n-workflow'; export async function apiTemplateIoApiRequest( @@ -38,7 +33,11 @@ export async function apiTemplateIoApiRequest( } try { - const response = await this.helpers.requestWithAuthentication.call(this, 'apiTemplateIoApi',options); + const response = await this.helpers.requestWithAuthentication.call( + this, + 'apiTemplateIoApi', + options, + ); if (response.status === 'error') { throw new NodeApiError(this.getNode(), response.message); } @@ -48,21 +47,21 @@ export async function apiTemplateIoApiRequest( } } -export async function loadResource( - this: ILoadOptionsFunctions, - resource: 'image' | 'pdf', -) { +export async function loadResource(this: ILoadOptionsFunctions, resource: 'image' | 'pdf') { const target = resource === 'image' ? ['JPEG', 'PNG'] : ['PDF']; const templates = await apiTemplateIoApiRequest.call(this, 'GET', '/list-templates'); - const filtered = templates.filter(({ format }: { format: 'PDF' | 'JPEG' | 'PNG' }) => target.includes(format)); + const filtered = templates.filter(({ format }: { format: 'PDF' | 'JPEG' | 'PNG' }) => + target.includes(format), + ); - return filtered.map(({ format, name, id }: { format: string, name: string, id: string }) => ({ + return filtered.map(({ format, name, id }: { format: string; name: string; id: string }) => ({ name: `${name} (${format})`, value: id, })); } -export function validateJSON(json: string | object | undefined): any { // tslint:disable-line:no-any +// tslint:disable-next-line:no-any +export function validateJSON(json: string | object | undefined): any { let result; if (typeof json === 'object') { return json; @@ -75,7 +74,6 @@ export function validateJSON(json: string | object | undefined): any { // tslint return result; } - export function downloadImage(this: IExecuteFunctions, url: string) { return this.helpers.request({ uri: url, diff --git a/packages/nodes-base/nodes/Asana/Asana.node.ts b/packages/nodes-base/nodes/Asana/Asana.node.ts index b8f9343e0f8a8..a9da13495fdf8 100644 --- a/packages/nodes-base/nodes/Asana/Asana.node.ts +++ b/packages/nodes-base/nodes/Asana/Asana.node.ts @@ -44,9 +44,7 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, testedBy: { @@ -61,9 +59,7 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -136,9 +132,7 @@ export class Asana implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'subtask', - ], + resource: ['subtask'], }, }, options: [ @@ -169,12 +163,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'subtask', - ], + operation: ['create'], + resource: ['subtask'], }, }, description: 'The task to operate on', @@ -187,12 +177,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'subtask', - ], + operation: ['create'], + resource: ['subtask'], }, }, description: 'The name of the subtask to create', @@ -203,12 +189,8 @@ export class Asana implements INodeType { type: 'collection', displayOptions: { show: { - resource: [ - 'subtask', - ], - operation: [ - 'create', - ], + resource: ['subtask'], + operation: ['create'], }, }, default: {}, @@ -222,7 +204,8 @@ export class Asana implements INodeType { loadOptionsMethod: 'getUsers', }, default: '', - description: 'Set Assignee on the subtask. Choose from the list, or specify an ID using an expression.', + description: + 'Set Assignee on the subtask. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Assignee Status', @@ -289,7 +272,8 @@ export class Asana implements INodeType { loadOptionsMethod: 'getWorkspaces', }, default: '', - description: 'The workspace to create the subtask in. Choose from the list, or specify an ID using an expression.', + description: + 'The workspace to create the subtask in. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -304,12 +288,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'subtask', - ], + operation: ['getAll'], + resource: ['subtask'], }, }, description: 'The task to operate on', @@ -320,12 +300,8 @@ export class Asana implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'subtask', - ], + operation: ['getAll'], + resource: ['subtask'], }, }, default: false, @@ -337,15 +313,9 @@ export class Asana implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'subtask', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['subtask'], + returnAll: [false], }, }, typeOptions: { @@ -361,12 +331,8 @@ export class Asana implements INodeType { type: 'collection', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'subtask', - ], + operation: ['getAll'], + resource: ['subtask'], }, }, default: {}, @@ -379,12 +345,9 @@ export class Asana implements INodeType { typeOptions: { loadOptionsMethod: 'getTaskFields', }, - default: [ - 'gid', - 'name', - 'resource_type', - ], - description: 'Defines fields to return. Choose from the list, or specify IDs using an expression.', + default: ['gid', 'name', 'resource_type'], + description: + 'Defines fields to return. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Pretty', @@ -405,9 +368,7 @@ export class Asana implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'task', - ], + resource: ['task'], }, }, options: [ @@ -472,15 +433,12 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'task', - ], + operation: ['create'], + resource: ['task'], }, }, - description: 'The workspace to create the task in. Choose from the list, or specify an ID using an expression.', + description: + 'The workspace to create the task in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Name', @@ -490,12 +448,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'task', - ], + operation: ['create'], + resource: ['task'], }, }, description: 'The name of the task to create', @@ -512,12 +466,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'task', - ], + operation: ['delete'], + resource: ['task'], }, }, description: 'The ID of the task to delete', @@ -534,12 +484,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'task', - ], + operation: ['get'], + resource: ['task'], }, }, description: 'The ID of the task to get the data of', @@ -553,12 +499,8 @@ export class Asana implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], + operation: ['getAll'], + resource: ['task'], }, }, default: false, @@ -570,15 +512,9 @@ export class Asana implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['task'], + returnAll: [false], }, }, typeOptions: { @@ -594,12 +530,8 @@ export class Asana implements INodeType { type: 'collection', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], + operation: ['getAll'], + resource: ['task'], }, }, default: {}, @@ -614,7 +546,8 @@ export class Asana implements INodeType { loadOptionsMethod: 'getUsers', }, default: '', - description: 'The assignee to filter tasks on. Note: If you specify assignee, you must also specify the workspace to filter on. Choose from the list, or specify an ID using an expression.', + description: + 'The assignee to filter tasks on. Note: If you specify assignee, you must also specify the workspace to filter on. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Field Names or IDs', @@ -623,12 +556,9 @@ export class Asana implements INodeType { typeOptions: { loadOptionsMethod: 'getTaskFields', }, - default: [ - 'gid', - 'name', - 'resource_type', - ], - description: 'Defines fields to return. Choose from the list, or specify IDs using an expression.', + default: ['gid', 'name', 'resource_type'], + description: + 'Defines fields to return. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Pretty', @@ -645,7 +575,8 @@ export class Asana implements INodeType { loadOptionsMethod: 'getProjects', }, default: '', - description: 'The project to filter tasks on. Choose from the list, or specify an ID using an expression.', + description: + 'The project to filter tasks on. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Section Name or ID', @@ -655,7 +586,8 @@ export class Asana implements INodeType { loadOptionsMethod: 'getSections', }, default: '', - description: 'The section to filter tasks on. Choose from the list, or specify an ID using an expression.', + description: + 'The section to filter tasks on. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Workspace Name or ID', @@ -665,14 +597,16 @@ export class Asana implements INodeType { loadOptionsMethod: 'getWorkspaces', }, default: '', - description: 'The workspace to filter tasks on. Note: If you specify workspace, you must also specify the assignee to filter on. Choose from the list, or specify an ID using an expression.', + description: + 'The workspace to filter tasks on. Note: If you specify workspace, you must also specify the assignee to filter on. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Completed Since', name: 'completed_since', type: 'dateTime', default: '', - description: 'Only return tasks that are either incomplete or that have been completed since this time', + description: + 'Only return tasks that are either incomplete or that have been completed since this time', }, { displayName: 'Modified Since', @@ -696,12 +630,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'move', - ], - resource: [ - 'task', - ], + operation: ['move'], + resource: ['task'], }, }, description: 'The ID of the task to be moved', @@ -718,24 +648,19 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'move', - ], - resource: [ - 'task', - ], + operation: ['move'], + resource: ['task'], }, }, - description: 'Project to show the sections of. Choose from the list, or specify an ID using an expression.', + description: + 'Project to show the sections of. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Section Name or ID', name: 'section', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getSections', }, options: [], @@ -743,15 +668,12 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'move', - ], - resource: [ - 'task', - ], + operation: ['move'], + resource: ['task'], }, }, - description: 'The Section to move the task to. Choose from the list, or specify an ID using an expression.', + description: + 'The Section to move the task to. Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- @@ -765,12 +687,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'task', - ], + operation: ['update'], + resource: ['task'], }, }, description: 'The ID of the task to update the data of', @@ -791,15 +709,12 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'task', - ], + operation: ['search'], + resource: ['task'], }, }, - description: 'The workspace in which the task is searched. Choose from the list, or specify an ID using an expression.', + description: + 'The workspace in which the task is searched. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Filters', @@ -807,12 +722,8 @@ export class Asana implements INodeType { type: 'collection', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'task', - ], + operation: ['search'], + resource: ['task'], }, }, default: {}, @@ -849,13 +760,8 @@ export class Asana implements INodeType { type: 'collection', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - 'update', - ], + resource: ['task'], + operation: ['create', 'update'], }, }, default: {}, @@ -869,7 +775,8 @@ export class Asana implements INodeType { loadOptionsMethod: 'getUsers', }, default: '', - description: 'Set Assignee on the task. Choose from the list, or specify an ID using an expression.', + description: + 'Set Assignee on the task. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Assignee Status', @@ -917,9 +824,7 @@ export class Asana implements INodeType { default: '', displayOptions: { show: { - '/operation': [ - 'update', - ], + '/operation': ['update'], }, }, description: 'The new name of the task', @@ -950,7 +855,8 @@ export class Asana implements INodeType { loadOptionsMethod: 'getProjects', }, default: [], - description: 'The project to filter tasks on. Choose from the list, or specify IDs using an expression.', + description: + 'The project to filter tasks on. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -966,9 +872,7 @@ export class Asana implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'taskComment', - ], + resource: ['taskComment'], }, }, options: [ @@ -1000,12 +904,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'taskComment', - ], + operation: ['add'], + resource: ['taskComment'], }, }, description: 'The ID of the task to add the comment to', @@ -1016,12 +916,8 @@ export class Asana implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'taskComment', - ], + operation: ['add'], + resource: ['taskComment'], }, }, default: false, @@ -1038,15 +934,9 @@ export class Asana implements INodeType { }, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'taskComment', - ], - isTextHtml: [ - false, - ], + operation: ['add'], + resource: ['taskComment'], + isTextHtml: [false], }, }, description: 'The plain text of the comment to add', @@ -1062,15 +952,9 @@ export class Asana implements INodeType { }, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'taskComment', - ], - isTextHtml: [ - true, - ], + operation: ['add'], + resource: ['taskComment'], + isTextHtml: [true], }, }, description: 'Comment as HTML string. Do not use together with plain text.', @@ -1081,12 +965,8 @@ export class Asana implements INodeType { type: 'collection', displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'taskComment', - ], + operation: ['add'], + resource: ['taskComment'], }, }, default: {}, @@ -1115,12 +995,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'remove', - ], - resource: [ - 'taskComment', - ], + operation: ['remove'], + resource: ['taskComment'], }, }, description: 'The ID of the comment to be removed', @@ -1136,9 +1012,7 @@ export class Asana implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'taskProject', - ], + resource: ['taskProject'], }, }, options: [ @@ -1168,12 +1042,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'taskProject', - ], + operation: ['add'], + resource: ['taskProject'], }, }, description: 'The ID of the task to add the project to', @@ -1189,15 +1059,12 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'taskProject', - ], + operation: ['add'], + resource: ['taskProject'], }, }, - description: 'The project where the task will be added. Choose from the list, or specify an ID using an expression.', + description: + 'The project where the task will be added. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Additional Fields', @@ -1205,12 +1072,8 @@ export class Asana implements INodeType { type: 'collection', displayOptions: { show: { - resource: [ - 'taskProject', - ], - operation: [ - 'add', - ], + resource: ['taskProject'], + operation: ['add'], }, }, default: {}, @@ -1222,21 +1085,24 @@ export class Asana implements INodeType { name: 'insert_after', type: 'string', default: '', - description: 'A task in the project to insert the task after, or null to insert at the beginning of the list', + description: + 'A task in the project to insert the task after, or null to insert at the beginning of the list', }, { displayName: 'Insert Before', name: 'insert_before', type: 'string', default: '', - description: 'A task in the project to insert the task before, or null to insert at the end of the list', + description: + 'A task in the project to insert the task before, or null to insert at the end of the list', }, { displayName: 'Section', name: 'section', type: 'string', default: '', - description: 'A section in the project to insert the task into. The task will be inserted at the bottom of the section.', + description: + 'A section in the project to insert the task into. The task will be inserted at the bottom of the section.', }, ], }, @@ -1252,12 +1118,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'remove', - ], - resource: [ - 'taskProject', - ], + operation: ['remove'], + resource: ['taskProject'], }, }, description: 'The ID of the task to add the project to', @@ -1273,15 +1135,12 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'remove', - ], - resource: [ - 'taskProject', - ], + operation: ['remove'], + resource: ['taskProject'], }, }, - description: 'The project where the task will be removed from. Choose from the list, or specify an ID using an expression.', + description: + 'The project where the task will be removed from. Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- // taskTag @@ -1294,9 +1153,7 @@ export class Asana implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'taskTag', - ], + resource: ['taskTag'], }, }, options: [ @@ -1328,12 +1185,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'taskTag', - ], + operation: ['add'], + resource: ['taskTag'], }, }, description: 'The ID of the task to add the tag to', @@ -1343,24 +1196,19 @@ export class Asana implements INodeType { name: 'tag', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'id', - ], + loadOptionsDependsOn: ['id'], loadOptionsMethod: 'getTags', }, default: '', required: true, displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'taskTag', - ], + operation: ['add'], + resource: ['taskTag'], }, }, - description: 'The tag that should be added. Choose from the list, or specify an ID using an expression.', + description: + 'The tag that should be added. Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- @@ -1375,12 +1223,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'remove', - ], - resource: [ - 'taskTag', - ], + operation: ['remove'], + resource: ['taskTag'], }, }, description: 'The ID of the task to add the tag to', @@ -1390,24 +1234,19 @@ export class Asana implements INodeType { name: 'tag', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'id', - ], + loadOptionsDependsOn: ['id'], loadOptionsMethod: 'getTags', }, default: '', required: true, displayOptions: { show: { - operation: [ - 'remove', - ], - resource: [ - 'taskTag', - ], + operation: ['remove'], + resource: ['taskTag'], }, }, - description: 'The tag that should be added. Choose from the list, or specify an ID using an expression.', + description: + 'The tag that should be added. Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- @@ -1420,9 +1259,7 @@ export class Asana implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -1453,15 +1290,12 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'user', - ], + operation: ['get'], + resource: ['user'], }, }, - description: 'An identifier for the user to get data of. Can be one of an email address,the globally unique identifier for the user, or the keyword me to indicate the current user making the request.', + description: + 'An identifier for the user to get data of. Can be one of an email address,the globally unique identifier for the user, or the keyword me to indicate the current user making the request.', }, // ---------------------------------- @@ -1479,15 +1313,12 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'user', - ], + operation: ['getAll'], + resource: ['user'], }, }, - description: 'The workspace in which to get users. Choose from the list, or specify an ID using an expression.', + description: + 'The workspace in which to get users. Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- @@ -1501,9 +1332,7 @@ export class Asana implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'project', - ], + resource: ['project'], }, }, options: [ @@ -1552,12 +1381,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'project', - ], + operation: ['create'], + resource: ['project'], }, }, description: 'The name of the project to create', @@ -1573,38 +1398,30 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'project', - ], + operation: ['create'], + resource: ['project'], }, }, - description: 'The workspace to create the project in. Choose from the list, or specify an ID using an expression.', + description: + 'The workspace to create the project in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Team Name or ID', name: 'team', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'workspace', - ], + loadOptionsDependsOn: ['workspace'], loadOptionsMethod: 'getTeams', }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'project', - ], + operation: ['create'], + resource: ['project'], }, }, default: '', - description: 'The team this project will be assigned to. Choose from the list, or specify an ID using an expression.', + description: + 'The team this project will be assigned to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Additional Fields', @@ -1612,12 +1429,8 @@ export class Asana implements INodeType { type: 'collection', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'create', - ], + resource: ['project'], + operation: ['create'], }, }, default: {}, @@ -1637,7 +1450,8 @@ export class Asana implements INodeType { name: 'due_on', type: 'dateTime', default: '', - description: 'The day on which this project is due. This takes a date with format YYYY-MM-DD.', + description: + 'The day on which this project is due. This takes a date with format YYYY-MM-DD.', }, { displayName: 'Notes', @@ -1659,12 +1473,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'project', - ], + operation: ['delete'], + resource: ['project'], }, }, }, @@ -1679,12 +1489,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'project', - ], + operation: ['get'], + resource: ['project'], }, }, }, @@ -1704,15 +1510,12 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'project', - ], + operation: ['getAll'], + resource: ['project'], }, }, - description: 'The workspace in which to get users. Choose from the list, or specify an ID using an expression.', + description: + 'The workspace in which to get users. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -1720,12 +1523,8 @@ export class Asana implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'project', - ], + operation: ['getAll'], + resource: ['project'], }, }, default: false, @@ -1737,15 +1536,9 @@ export class Asana implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'project', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['project'], + returnAll: [false], }, }, typeOptions: { @@ -1761,12 +1554,8 @@ export class Asana implements INodeType { type: 'collection', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'getAll', - ], + resource: ['project'], + operation: ['getAll'], }, }, default: {}, @@ -1778,20 +1567,20 @@ export class Asana implements INodeType { name: 'archived', type: 'boolean', default: false, - description: 'Whether to only return projects whose archived field takes on the value of this parameter', + description: + 'Whether to only return projects whose archived field takes on the value of this parameter', }, { displayName: 'Teams Name or ID', name: 'team', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'workspace', - ], + loadOptionsDependsOn: ['workspace'], loadOptionsMethod: 'getTeams', }, default: '', - description: 'The new name of the task. Choose from the list, or specify an ID using an expression.', + description: + 'The new name of the task. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -1810,15 +1599,12 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'project', - ], + operation: ['update'], + resource: ['project'], }, }, - description: 'The workspace in which to get users. Choose from the list, or specify an ID using an expression.', + description: + 'The workspace in which to get users. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Project ID', @@ -1828,12 +1614,8 @@ export class Asana implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'project', - ], + operation: ['update'], + resource: ['project'], }, }, description: 'The ID of the project to update the data of', @@ -1844,12 +1626,8 @@ export class Asana implements INodeType { type: 'collection', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'update', - ], + resource: ['project'], + operation: ['update'], }, }, default: {}, @@ -1869,7 +1647,8 @@ export class Asana implements INodeType { name: 'due_on', type: 'dateTime', default: '', - description: 'The day on which this project is due. This takes a date with format YYYY-MM-DD.', + description: + 'The day on which this project is due. This takes a date with format YYYY-MM-DD.', }, { displayName: 'Name', @@ -1897,13 +1676,12 @@ export class Asana implements INodeType { name: 'team', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'workspace', - ], + loadOptionsDependsOn: ['workspace'], loadOptionsMethod: 'getTeams', }, default: '', - description: 'The team this project will be assigned to. Choose from the list, or specify an ID using an expression.', + description: + 'The team this project will be assigned to. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -1943,8 +1721,12 @@ export class Asana 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; }); @@ -1976,8 +1758,12 @@ export class Asana 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; }); @@ -1995,7 +1781,10 @@ export class Asana implements INodeType { // to retrieve the teams from an organization just work with workspaces that are an organization if (workspace.is_organization === false) { - throw new NodeOperationError(this.getNode(), 'To filter by team, the workspace selected has to be an organization'); + throw new NodeOperationError( + this.getNode(), + 'To filter by team, the workspace selected has to be an organization', + ); } const endpoint = `/organizations/${workspaceId}/teams`; @@ -2017,8 +1806,12 @@ export class Asana 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; }); @@ -2035,7 +1828,9 @@ export class Asana implements INodeType { try { taskData = await asanaApiRequest.call(this, 'GET', `/tasks/${taskId}`, {}); } catch (error) { - throw new NodeApiError(this.getNode(), error, { message: `Could not find task with id "${taskId}" so tags could not be loaded.` }); + throw new NodeApiError(this.getNode(), error, { + message: `Could not find task with id "${taskId}" so tags could not be loaded.`, + }); } const workspace = taskData.data.workspace.gid; @@ -2060,8 +1855,12 @@ export class Asana 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; }); @@ -2094,13 +1893,12 @@ export class Asana implements INodeType { return returnData; }, async getTaskFields(this: ILoadOptionsFunctions): Promise { - const returnData: INodePropertyOptions[] = []; for (const field of getTaskFields()) { const value = snakeCase(field); returnData.push({ name: field, - value: (value === '') ? '*' : value, + value: value === '' ? '*' : value, }); } return returnData; @@ -2167,7 +1965,9 @@ export class Asana implements INodeType { if (qs.opt_fields) { const fields = qs.opt_fields as string[]; if (fields.includes('*')) { - qs.opt_fields = getTaskFields().map((e) => snakeCase(e)).join(','); + qs.opt_fields = getTaskFields() + .map((e) => snakeCase(e)) + .join(','); } else { qs.opt_fields = (qs.opt_fields as string[]).join(','); } @@ -2202,7 +2002,6 @@ export class Asana implements INodeType { responseData = await asanaApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = responseData.data; - } else if (operation === 'delete') { // ---------------------------------- // task:delete @@ -2210,12 +2009,11 @@ export class Asana implements INodeType { requestMethod = 'DELETE'; - endpoint = '/tasks/' + this.getNodeParameter('id', i) as string; + endpoint = ('/tasks/' + this.getNodeParameter('id', i)) as string; responseData = await asanaApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = responseData.data; - } else if (operation === 'get') { // ---------------------------------- // task:get @@ -2223,12 +2021,11 @@ export class Asana implements INodeType { requestMethod = 'GET'; - endpoint = '/tasks/' + this.getNodeParameter('id', i) as string; + endpoint = ('/tasks/' + this.getNodeParameter('id', i)) as string; responseData = await asanaApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = responseData.data; - } else if (operation === 'getAll') { // ---------------------------------- // task:getAll @@ -2245,7 +2042,9 @@ export class Asana implements INodeType { if (qs.opt_fields) { const fields = qs.opt_fields as string[]; if (fields.includes('*')) { - qs.opt_fields = getTaskFields().map((e) => snakeCase(e)).join(','); + qs.opt_fields = getTaskFields() + .map((e) => snakeCase(e)) + .join(','); } else { qs.opt_fields = (qs.opt_fields as string[]).join(','); } @@ -2260,8 +2059,13 @@ export class Asana implements INodeType { } if (returnAll) { - responseData = await asanaApiRequestAllItems.call(this, requestMethod, endpoint, body, qs); - + responseData = await asanaApiRequestAllItems.call( + this, + requestMethod, + endpoint, + body, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as boolean; @@ -2269,7 +2073,6 @@ export class Asana implements INodeType { responseData = responseData.data; } - } else if (operation === 'move') { // ---------------------------------- // task:move @@ -2288,14 +2091,13 @@ export class Asana implements INodeType { responseData = await asanaApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = { success: true }; - } else if (operation === 'update') { // ---------------------------------- // task:update // ---------------------------------- requestMethod = 'PUT'; - endpoint = '/tasks/' + this.getNodeParameter('id', i) as string; + endpoint = ('/tasks/' + this.getNodeParameter('id', i)) as string; const otherProperties = this.getNodeParameter('otherProperties', i) as IDataObject; Object.assign(body, otherProperties); @@ -2303,7 +2105,6 @@ export class Asana implements INodeType { responseData = await asanaApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = responseData.data; - } else if (operation === 'search') { // ---------------------------------- // tasksearch @@ -2314,7 +2115,10 @@ export class Asana implements INodeType { requestMethod = 'GET'; endpoint = `/workspaces/${workspaceId}/tasks/search`; - const searchTaskProperties = this.getNodeParameter('searchTaskProperties', i) as IDataObject; + const searchTaskProperties = this.getNodeParameter( + 'searchTaskProperties', + i, + ) as IDataObject; Object.assign(qs, searchTaskProperties); responseData = await asanaApiRequest.call(this, requestMethod, endpoint, body, qs); @@ -2369,7 +2173,6 @@ export class Asana implements INodeType { } if (resource === 'taskTag') { if (operation === 'add') { - // ---------------------------------- // taskTag:add // ---------------------------------- @@ -2388,7 +2191,6 @@ export class Asana implements INodeType { } if (operation === 'remove') { - // ---------------------------------- // taskTag:remove // ---------------------------------- @@ -2430,7 +2232,6 @@ export class Asana implements INodeType { } if (operation === 'remove') { - // ---------------------------------- // taskProject:remove // ---------------------------------- @@ -2461,7 +2262,6 @@ export class Asana implements INodeType { responseData = await asanaApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = responseData.data; - } else if (operation === 'getAll') { // ---------------------------------- // getAll @@ -2474,7 +2274,6 @@ export class Asana implements INodeType { responseData = await asanaApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = responseData.data; - } } if (resource === 'project') { @@ -2534,7 +2333,6 @@ export class Asana implements INodeType { responseData = await asanaApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = responseData.data; - } if (operation === 'getAll') { @@ -2559,11 +2357,14 @@ export class Asana implements INodeType { } if (returnAll) { - - responseData = await asanaApiRequestAllItems.call(this, requestMethod, endpoint, body, qs); - + responseData = await asanaApiRequestAllItems.call( + this, + requestMethod, + endpoint, + body, + qs, + ); } else { - qs.limit = this.getNodeParameter('limit', i) as boolean; responseData = await asanaApiRequest.call(this, requestMethod, endpoint, body, qs); @@ -2605,7 +2406,6 @@ export class Asana implements INodeType { responseData = await asanaApiRequest.call(this, requestMethod, endpoint, body, qs); responseData = responseData.data; - } } diff --git a/packages/nodes-base/nodes/Asana/AsanaTrigger.node.ts b/packages/nodes-base/nodes/Asana/AsanaTrigger.node.ts index 602847cdc22e2..5775e426d21c5 100644 --- a/packages/nodes-base/nodes/Asana/AsanaTrigger.node.ts +++ b/packages/nodes-base/nodes/Asana/AsanaTrigger.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 { NodeOperationError, } from 'n8n-workflow'; -import { - asanaApiRequest, - getWorkspaces, -} from './GenericFunctions'; +import { asanaApiRequest, getWorkspaces } from './GenericFunctions'; // import { // createHmac, @@ -41,9 +35,7 @@ export class AsanaTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -52,9 +44,7 @@ export class AsanaTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -101,7 +91,8 @@ export class AsanaTrigger implements INodeType { }, options: [], default: '', - description: 'The workspace ID the resource is registered under. This is only required if you want to allow overriding existing webhooks. Choose from the list, or specify an ID using an expression.', + description: + 'The workspace ID the resource is registered under. This is only required if you want to allow overriding existing webhooks. Choose from the list, or specify an ID using an expression.', }, ], }; @@ -153,7 +144,10 @@ export class AsanaTrigger implements INodeType { const webhookUrl = this.getNodeWebhookUrl('default') as string; if (webhookUrl.includes('%20')) { - throw new NodeOperationError(this.getNode(), 'The name of the Asana Trigger Node is not allowed to contain any spaces!'); + throw new NodeOperationError( + this.getNode(), + 'The name of the Asana Trigger Node is not allowed to contain any spaces!', + ); } const resource = this.getNodeParameter('resource') as string; @@ -225,8 +219,11 @@ export class AsanaTrigger implements INodeType { // Is regular webhook call // Check if it contains any events - if (bodyData.events === undefined || !Array.isArray(bodyData.events) || - bodyData.events.length === 0) { + if ( + bodyData.events === undefined || + !Array.isArray(bodyData.events) || + bodyData.events.length === 0 + ) { // Does not contain any event data so nothing to process so no reason to // start the workflow return {}; @@ -245,9 +242,7 @@ export class AsanaTrigger implements INodeType { // } return { - workflowData: [ - this.helpers.returnJsonArray(req.body.events), - ], + workflowData: [this.helpers.returnJsonArray(req.body.events)], }; } } diff --git a/packages/nodes-base/nodes/Asana/GenericFunctions.ts b/packages/nodes-base/nodes/Asana/GenericFunctions.ts index 373e219f705c8..7b7a24c3c5876 100644 --- a/packages/nodes-base/nodes/Asana/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Asana/GenericFunctions.ts @@ -1,8 +1,4 @@ -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject, @@ -11,9 +7,7 @@ import { INodePropertyOptions, } from 'n8n-workflow'; -import { - get, -} from 'lodash'; +import { get } from 'lodash'; /** * Make an API request to Asana @@ -24,7 +18,15 @@ import { * @param {object} body * @returns {Promise} */ -export async function asanaApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: IHttpRequestMethods, endpoint: string, body: object, query?: IDataObject, uri?: string | undefined): Promise { // tslint:disable-line:no-any +export async function asanaApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: IHttpRequestMethods, + endpoint: string, + body: object, + query?: IDataObject, + uri?: string | undefined, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0) as string; const options: IHttpRequestOptions = { @@ -40,8 +42,15 @@ export async function asanaApiRequest(this: IHookFunctions | IExecuteFunctions | return this.helpers.requestWithAuthentication.call(this, credentialType, options); } -export async function asanaApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: IHttpRequestMethods, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function asanaApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions, + method: IHttpRequestMethods, + 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 asanaApiRequestAllItems(this: IExecuteFunctions | ILoadOpt responseData = await asanaApiRequest.call(this, method, endpoint, body, query, uri); uri = get(responseData, 'next_page.uri'); returnData.push.apply(returnData, responseData['data']); - } while ( - responseData['next_page'] !== null - ); + } while (responseData['next_page'] !== null); return returnData; } @@ -78,15 +85,18 @@ export async function getWorkspaces(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; } - export function getColorOptions(): INodePropertyOptions[] { return [ 'dark-blue', @@ -108,7 +118,7 @@ export function getColorOptions(): INodePropertyOptions[] { 'light-warm-gray', 'light-yellow', 'none', - ].map(value => { + ].map((value) => { return { name: value, value, diff --git a/packages/nodes-base/nodes/Automizy/Automizy.node.ts b/packages/nodes-base/nodes/Automizy/Automizy.node.ts index 3caac93d56cc9..22cd8f60090d9 100644 --- a/packages/nodes-base/nodes/Automizy/Automizy.node.ts +++ b/packages/nodes-base/nodes/Automizy/Automizy.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 { - automizyApiRequest, - automizyApiRequestAllItems, -} from './GenericFunctions'; +import { automizyApiRequest, automizyApiRequestAllItems } from './GenericFunctions'; -import { - contactFields, - contactOperations, -} from './ContactDescription'; +import { contactFields, contactOperations } from './ContactDescription'; -import { - listFields, - listOperations, -} from './ListDescription'; +import { listFields, listOperations } from './ListDescription'; export class Automizy implements INodeType { description: INodeTypeDescription = { @@ -78,9 +67,7 @@ export class Automizy implements INodeType { loadOptions: { // Get all the tags to display them to user so that he can // select them easily - async getLists( - this: ILoadOptionsFunctions, - ): Promise { + async getLists(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const lists = await automizyApiRequestAllItems.call( this, @@ -96,9 +83,7 @@ export class Automizy implements INodeType { } return returnData; }, - async getTags( - this: ILoadOptionsFunctions, - ): Promise { + async getTags(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const tags = await automizyApiRequestAllItems.call( this, @@ -114,9 +99,7 @@ export class Automizy implements INodeType { } return returnData; }, - async getCustomFields( - this: ILoadOptionsFunctions, - ): Promise { + async getCustomFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const customFields = await automizyApiRequestAllItems.call( this, @@ -144,9 +127,7 @@ export class Automizy 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 === 'contact') { - if (operation === 'create') { const listId = this.getNodeParameter('listId', i) as string; @@ -161,12 +142,12 @@ export class Automizy implements INodeType { Object.assign(body, additionalFields); if (body.customFieldsUi) { - const customFieldsValues = (body.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFieldsValues = (body.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; body.customFields = {}; for (const customField of customFieldsValues) { - //@ts-ignore body.customFields[customField.key] = customField.value; } @@ -185,11 +166,7 @@ export class Automizy implements INodeType { if (operation === 'delete') { const contactId = this.getNodeParameter('contactId', i) as string; - responseData = await automizyApiRequest.call( - this, - 'DELETE', - `/contacts/${contactId}`, - ); + responseData = await automizyApiRequest.call(this, 'DELETE', `/contacts/${contactId}`); responseData = { success: true }; } @@ -197,11 +174,7 @@ export class Automizy implements INodeType { if (operation === 'get') { const contactId = this.getNodeParameter('contactId', i) as string; - responseData = await automizyApiRequest.call( - this, - 'GET', - `/contacts/${contactId}`, - ); + responseData = await automizyApiRequest.call(this, 'GET', `/contacts/${contactId}`); } if (operation === 'getAll') { @@ -220,7 +193,6 @@ export class Automizy implements INodeType { } if (returnAll) { - responseData = await automizyApiRequestAllItems.call( this, 'contacts', @@ -229,7 +201,6 @@ export class Automizy implements INodeType { {}, qs, ); - } else { qs.limit = this.getNodeParameter('limit', i) as number; @@ -255,12 +226,12 @@ export class Automizy implements INodeType { Object.assign(body, updateFields); if (body.customFieldsUi) { - const customFieldsValues = (body.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFieldsValues = (body.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; body.customFields = {}; for (const customField of customFieldsValues) { - //@ts-ignore body.customFields[customField.key] = customField.value; } @@ -268,17 +239,11 @@ export class Automizy implements INodeType { delete body.customFieldsUi; } - responseData = await automizyApiRequest.call( - this, - 'PATCH', - `/contacts/${email}`, - body, - ); + responseData = await automizyApiRequest.call(this, 'PATCH', `/contacts/${email}`, body); } } if (resource === 'list') { - if (operation === 'create') { const name = this.getNodeParameter('name', i) as string; @@ -286,22 +251,13 @@ export class Automizy implements INodeType { name, }; - responseData = await automizyApiRequest.call( - this, - 'POST', - `/smart-lists`, - body, - ); + responseData = await automizyApiRequest.call(this, 'POST', `/smart-lists`, body); } if (operation === 'delete') { const listId = this.getNodeParameter('listId', i) as string; - responseData = await automizyApiRequest.call( - this, - 'DELETE', - `/smart-lists/${listId}`, - ); + responseData = await automizyApiRequest.call(this, 'DELETE', `/smart-lists/${listId}`); responseData = { success: true }; } @@ -309,11 +265,7 @@ export class Automizy implements INodeType { if (operation === 'get') { const listId = this.getNodeParameter('listId', i) as string; - responseData = await automizyApiRequest.call( - this, - 'GET', - `/smart-lists/${listId}`, - ); + responseData = await automizyApiRequest.call(this, 'GET', `/smart-lists/${listId}`); } if (operation === 'getAll') { @@ -330,7 +282,6 @@ export class Automizy implements INodeType { } if (returnAll) { - responseData = await automizyApiRequestAllItems.call( this, 'smartLists', @@ -339,17 +290,10 @@ export class Automizy implements INodeType { {}, qs, ); - } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await automizyApiRequest.call( - this, - 'GET', - `/smart-lists`, - {}, - qs, - ); + responseData = await automizyApiRequest.call(this, 'GET', `/smart-lists`, {}, qs); responseData = responseData.smartLists; } diff --git a/packages/nodes-base/nodes/Automizy/ContactDescription.ts b/packages/nodes-base/nodes/Automizy/ContactDescription.ts index d8591a96cb596..1f04c4c4f9466 100644 --- a/packages/nodes-base/nodes/Automizy/ContactDescription.ts +++ b/packages/nodes-base/nodes/Automizy/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: [ @@ -52,7 +48,6 @@ export const contactOperations: INodeProperties[] = [ ]; export const contactFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* contact:create */ /* -------------------------------------------------------------------------- */ @@ -64,12 +59,8 @@ export const contactFields: INodeProperties[] = [ placeholder: 'name@email.com', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], + operation: ['create'], + resource: ['contact'], }, }, default: '', @@ -80,18 +71,15 @@ export const contactFields: INodeProperties[] = [ name: 'listId', 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: 'getLists', }, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], + operation: ['create'], + resource: ['contact'], }, }, default: '', @@ -102,12 +90,8 @@ export const contactFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], + operation: ['create'], + resource: ['contact'], }, }, default: {}, @@ -135,7 +119,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: '', }, { @@ -177,7 +162,8 @@ export const contactFields: INodeProperties[] = [ }, ], default: '', - description: 'The status of the contact. You can only send email to contacts with ACTIVE status.', + description: + 'The status of the contact. You can only send email to contacts with ACTIVE status.', }, { displayName: 'Tag Names or IDs', @@ -187,7 +173,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'The tags you want to set to the contact. Choose from the list, or specify IDs using an expression.', + description: + 'The tags you want to set to the contact. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -202,12 +189,8 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'contact', - ], + operation: ['delete'], + resource: ['contact'], }, }, default: '', @@ -224,12 +207,8 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], + operation: ['get'], + resource: ['contact'], }, }, default: '', @@ -244,18 +223,15 @@ export const contactFields: INodeProperties[] = [ name: 'listId', 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: 'getLists', }, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], + operation: ['getAll'], + resource: ['contact'], }, }, default: '', @@ -266,12 +242,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], + operation: ['getAll'], + resource: ['contact'], }, }, default: false, @@ -283,15 +255,9 @@ export const contactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['contact'], + returnAll: [false], }, }, typeOptions: { @@ -308,12 +274,8 @@ export const contactFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], + operation: ['getAll'], + resource: ['contact'], }, }, default: {}, @@ -333,7 +295,8 @@ export const contactFields: INodeProperties[] = [ }, ], default: 'desc', - description: 'Defines the direction in which search results are ordered. Default value is DESC. Note: It has to be using with the Sort By parameter', + description: + 'Defines the direction in which search results are ordered. Default value is DESC. Note: It has to be using with the Sort By parameter', }, { displayName: 'Fields', @@ -346,7 +309,8 @@ export const contactFields: INodeProperties[] = [ displayName: 'Sort By', name: 'sortBy', type: 'string', - default: 'Defines the field in which search results are sort by. Note: It has to be using with the Direcction parameter', + default: + 'Defines the field in which search results are sort by. Note: It has to be using with the Direcction parameter', }, ], }, @@ -362,12 +326,8 @@ export const contactFields: INodeProperties[] = [ placeholder: 'name@email.com', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'contact', - ], + operation: ['update'], + resource: ['contact'], }, }, default: '', @@ -378,12 +338,8 @@ export const contactFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'contact', - ], + operation: ['update'], + resource: ['contact'], }, }, default: {}, @@ -397,7 +353,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'The tags you want to add to the contact. Choose from the list, or specify IDs using an expression.', + description: + 'The tags you want to add to the contact. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Custom Fields', @@ -421,7 +378,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: '', }, { @@ -444,7 +402,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'The tags you want to add to the contact. Choose from the list, or specify IDs using an expression.', + description: + 'The tags you want to add to the contact. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Status', @@ -473,7 +432,8 @@ export const contactFields: INodeProperties[] = [ }, ], default: '', - description: 'The status of the contact. You can only send email to contacts with ACTIVE status.', + description: + 'The status of the contact. You can only send email to contacts with ACTIVE status.', }, { displayName: 'Tag Names or IDs', @@ -483,7 +443,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'The tags you want to set to the contact. Will replace all existing ones. Choose from the list, or specify IDs using an expression.', + description: + 'The tags you want to set to the contact. Will replace all existing ones. Choose from the list, or specify IDs using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/Automizy/GenericFunctions.ts b/packages/nodes-base/nodes/Automizy/GenericFunctions.ts index 2644bbf225da2..767aaa5b5a6f1 100644 --- a/packages/nodes-base/nodes/Automizy/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Automizy/GenericFunctions.ts @@ -1,24 +1,24 @@ -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 automizyApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, option = {}): Promise { // tslint:disable-line:no-any - - const credentials = await this.getCredentials('automizyApi') as IDataObject; +export async function automizyApiRequest( + 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('automizyApi')) as IDataObject; const options: OptionsWithUri = { headers: { - 'Authorization': `Bearer ${credentials.apiToken}`, + Authorization: `Bearer ${credentials.apiToken}`, }, method, body, @@ -44,8 +44,16 @@ export async function automizyApiRequest(this: IExecuteFunctions | IExecuteSingl } } -export async function automizyApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function automizyApiRequestAllItems( + 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,9 +63,7 @@ export async function automizyApiRequestAllItems(this: IExecuteFunctions | ILoad responseData = await automizyApiRequest.call(this, method, endpoint, body, query); query.page++; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData.pageCount !== responseData.page - ); + } while (responseData.pageCount !== responseData.page); return returnData; } diff --git a/packages/nodes-base/nodes/Automizy/ListDescription.ts b/packages/nodes-base/nodes/Automizy/ListDescription.ts index 98451ed06b3c4..be401e3782692 100644 --- a/packages/nodes-base/nodes/Automizy/ListDescription.ts +++ b/packages/nodes-base/nodes/Automizy/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: [ @@ -52,7 +48,6 @@ export const listOperations: INodeProperties[] = [ ]; export const listFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* list:create */ /* -------------------------------------------------------------------------- */ @@ -63,12 +58,8 @@ export const listFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'list', - ], + operation: ['create'], + resource: ['list'], }, }, default: '', @@ -83,17 +74,13 @@ export const listFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'list', - ], + operation: ['delete'], + resource: ['list'], }, }, default: '', }, - /* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ /* list:get */ /* -------------------------------------------------------------------------- */ { @@ -103,12 +90,8 @@ export const listFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'list', - ], + operation: ['get'], + resource: ['list'], }, }, default: '', @@ -122,12 +105,8 @@ export const listFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'list', - ], + operation: ['getAll'], + resource: ['list'], }, }, default: false, @@ -139,15 +118,9 @@ export const listFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'list', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['list'], + returnAll: [false], }, }, typeOptions: { @@ -164,12 +137,8 @@ export const listFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'list', - ], + operation: ['getAll'], + resource: ['list'], }, }, default: {}, @@ -189,7 +158,8 @@ export const listFields: INodeProperties[] = [ }, ], default: 'desc', - description: 'Defines the direction in which search results are ordered. Default value is DESC. Note: It has to be using with the Sort By parameter', + description: + 'Defines the direction in which search results are ordered. Default value is DESC. Note: It has to be using with the Sort By parameter', }, { displayName: 'Fields', @@ -202,7 +172,8 @@ export const listFields: INodeProperties[] = [ displayName: 'Sort By', name: 'sortBy', type: 'string', - default: 'Defines the field in which search results are sort by. Note: It has to be using with the Direcction parameter', + default: + 'Defines the field in which search results are sort by. Note: It has to be using with the Direcction parameter', }, ], }, @@ -216,12 +187,8 @@ export const listFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'list', - ], + operation: ['update'], + resource: ['list'], }, }, default: '', @@ -233,12 +200,8 @@ export const listFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'list', - ], + operation: ['update'], + resource: ['list'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts b/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts index df53118164526..590d13dea6785 100644 --- a/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts +++ b/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,30 +9,15 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - autopilotApiRequest, - autopilotApiRequestAllItems, -} from './GenericFunctions'; +import { autopilotApiRequest, autopilotApiRequestAllItems } from './GenericFunctions'; -import { - contactFields, - contactOperations, -} from './ContactDescription'; +import { contactFields, contactOperations } from './ContactDescription'; -import { - contactJourneyFields, - contactJourneyOperations, -} from './ContactJourneyDescription'; +import { contactJourneyFields, contactJourneyOperations } from './ContactJourneyDescription'; -import { - contactListFields, - contactListOperations, -} from './ContactListDescription'; +import { contactListFields, contactListOperations } from './ContactListDescription'; -import { - listFields, - listOperations, -} from './ListDescription'; +import { listFields, listOperations } from './ListDescription'; export class Autopilot implements INodeType { description: INodeTypeDescription = { @@ -96,15 +79,9 @@ export class Autopilot implements INodeType { methods = { loadOptions: { - async getCustomFields( - this: ILoadOptionsFunctions, - ): Promise { + async getCustomFields(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const customFields = await autopilotApiRequest.call( - this, - 'GET', - '/contacts/custom_fields', - ); + const customFields = await autopilotApiRequest.call(this, 'GET', '/contacts/custom_fields'); for (const customField of customFields) { returnData.push({ name: customField.name, @@ -113,15 +90,9 @@ export class Autopilot implements INodeType { } return returnData; }, - async getLists( - this: ILoadOptionsFunctions, - ): Promise { + async getLists(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { lists } = await autopilotApiRequest.call( - this, - 'GET', - '/lists', - ); + const { lists } = await autopilotApiRequest.call(this, 'GET', '/lists'); for (const list of lists) { returnData.push({ name: list.title, @@ -130,15 +101,9 @@ export class Autopilot implements INodeType { } return returnData; }, - async getTriggers( - this: ILoadOptionsFunctions, - ): Promise { + async getTriggers(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { triggers } = await autopilotApiRequest.call( - this, - 'GET', - '/triggers', - ); + const { triggers } = await autopilotApiRequest.call(this, 'GET', '/triggers'); for (const trigger of triggers) { returnData.push({ name: trigger.journey, @@ -173,7 +138,8 @@ export class Autopilot implements INodeType { Object.assign(body, additionalFields); if (body.customFieldsUi) { - const customFieldsValues = (body.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFieldsValues = (body.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; body.custom = {}; @@ -203,22 +169,15 @@ export class Autopilot implements INodeType { delete body.newEmail; } - responseData = await autopilotApiRequest.call( - this, - 'POST', - `/contact`, - { contact: body }, - ); + responseData = await autopilotApiRequest.call(this, 'POST', `/contact`, { + contact: body, + }); } if (operation === 'delete') { const contactId = this.getNodeParameter('contactId', i) as string; - responseData = await autopilotApiRequest.call( - this, - 'DELETE', - `/contact/${contactId}`, - ); + responseData = await autopilotApiRequest.call(this, 'DELETE', `/contact/${contactId}`); responseData = { success: true }; } @@ -226,11 +185,7 @@ export class Autopilot implements INodeType { if (operation === 'get') { const contactId = this.getNodeParameter('contactId', i) as string; - responseData = await autopilotApiRequest.call( - this, - 'GET', - `/contact/${contactId}`, - ); + responseData = await autopilotApiRequest.call(this, 'GET', `/contact/${contactId}`); } if (operation === 'getAll') { @@ -255,7 +210,6 @@ export class Autopilot implements INodeType { } if (resource === 'contactJourney') { if (operation === 'add') { - const triggerId = this.getNodeParameter('triggerId', i) as string; const contactId = this.getNodeParameter('contactId', i) as string; @@ -271,15 +225,14 @@ export class Autopilot implements INodeType { } if (resource === 'contactList') { if (['add', 'remove', 'exist'].includes(operation)) { - const listId = this.getNodeParameter('listId', i) as string; const contactId = this.getNodeParameter('contactId', i) as string; const method: { [key: string]: string } = { - 'add': 'POST', - 'remove': 'DELETE', - 'exist': 'GET', + add: 'POST', + remove: 'DELETE', + exist: 'GET', }; const endpoint = `/list/${listId}/contact/${contactId}`; @@ -321,19 +274,13 @@ export class Autopilot implements INodeType { } if (resource === 'list') { if (operation === 'create') { - const name = this.getNodeParameter('name', i) as string; const body: IDataObject = { name, }; - responseData = await autopilotApiRequest.call( - this, - 'POST', - `/list`, - body, - ); + responseData = await autopilotApiRequest.call(this, 'POST', `/list`, body); } if (operation === 'getAll') { @@ -342,11 +289,7 @@ export class Autopilot implements INodeType { if (returnAll === false) { qs.limit = this.getNodeParameter('limit', i) as number; } - responseData = await autopilotApiRequest.call( - this, - 'GET', - '/lists', - ); + responseData = await autopilotApiRequest.call(this, 'GET', '/lists'); responseData = responseData.lists; @@ -361,9 +304,7 @@ export class Autopilot implements INodeType { } else if (responseData !== undefined) { returnData.push(responseData as IDataObject); } - } catch (error) { - if (this.continueOnFail()) { returnData.push({ error: error.toString() }); continue; diff --git a/packages/nodes-base/nodes/Autopilot/AutopilotTrigger.node.ts b/packages/nodes-base/nodes/Autopilot/AutopilotTrigger.node.ts index 171f8f09deda0..177c17aa4b888 100644 --- a/packages/nodes-base/nodes/Autopilot/AutopilotTrigger.node.ts +++ b/packages/nodes-base/nodes/Autopilot/AutopilotTrigger.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 { - autopilotApiRequest, -} from './GenericFunctions'; +import { autopilotApiRequest } from './GenericFunctions'; -import { - snakeCase, -} from 'change-case'; +import { snakeCase } from 'change-case'; export class AutopilotTrigger implements INodeType { description: INodeTypeDescription = { @@ -131,9 +119,7 @@ export class AutopilotTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/Autopilot/ContactDescription.ts b/packages/nodes-base/nodes/Autopilot/ContactDescription.ts index 098514f8409d5..9d0ec0dc94929 100644 --- a/packages/nodes-base/nodes/Autopilot/ContactDescription.ts +++ b/packages/nodes-base/nodes/Autopilot/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,7 +43,6 @@ export const contactOperations: INodeProperties[] = [ ]; export const contactFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* contact:upsert */ /* -------------------------------------------------------------------------- */ @@ -58,12 +54,8 @@ export const contactFields: INodeProperties[] = [ placeholder: 'name@email.com', displayOptions: { show: { - operation: [ - 'upsert', - ], - resource: [ - 'contact', - ], + operation: ['upsert'], + resource: ['contact'], }, }, default: '', @@ -75,12 +67,8 @@ export const contactFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'upsert', - ], - resource: [ - 'contact', - ], + operation: ['upsert'], + resource: ['contact'], }, }, default: {}, @@ -114,7 +102,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCustomFields', }, - description: 'User-specified key of user-defined data. Choose from the list, or specify an ID using an expression.', + description: + 'User-specified key of user-defined data. Choose from the list, or specify an ID using an expression.', default: '', }, { @@ -172,7 +161,8 @@ export const contactFields: INodeProperties[] = [ loadOptionsMethod: 'getLists', }, default: '', - description: 'List to which this contact will be added on creation. Choose from the list, or specify an ID using an expression.', + description: + 'List to which this contact will be added on creation. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Mailing Country', @@ -215,7 +205,8 @@ export const contactFields: INodeProperties[] = [ name: 'newEmail', type: 'string', default: '', - description: 'If provided, will change the email address of the contact identified by the Email field', + description: + 'If provided, will change the email address of the contact identified by the Email field', }, { displayName: 'Notify', @@ -223,7 +214,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 Autopilot notifies registered REST hook endpoints for contact_added/contact_updated events when a new contact is added or an existing contact is updated via API. Disable to skip notifications.', + description: + 'By default Autopilot notifies registered REST hook endpoints for contact_added/contact_updated events when a new contact is added or an existing contact is updated via API. Disable to skip notifications.', }, { displayName: 'Number of Employees', @@ -294,12 +286,8 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'contact', - ], + operation: ['delete'], + resource: ['contact'], }, }, default: '', @@ -316,12 +304,8 @@ export const contactFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], + operation: ['get'], + resource: ['contact'], }, }, default: '', @@ -337,12 +321,8 @@ export const contactFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], + operation: ['getAll'], + resource: ['contact'], }, }, default: false, @@ -354,15 +334,9 @@ export const contactFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['contact'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Autopilot/ContactJourneyDescription.ts b/packages/nodes-base/nodes/Autopilot/ContactJourneyDescription.ts index 6055f9952c858..4187a5e0624dd 100644 --- a/packages/nodes-base/nodes/Autopilot/ContactJourneyDescription.ts +++ b/packages/nodes-base/nodes/Autopilot/ContactJourneyDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactJourneyOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const contactJourneyOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contactJourney', - ], + resource: ['contactJourney'], }, }, options: [ @@ -28,7 +24,6 @@ export const contactJourneyOperations: INodeProperties[] = [ ]; export const contactJourneyFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* contactJourney:add */ /* -------------------------------------------------------------------------- */ @@ -42,16 +37,13 @@ export const contactJourneyFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'contactJourney', - ], + operation: ['add'], + resource: ['contactJourney'], }, }, default: '', - description: 'List ID. Choose from the list, or specify an ID using an expression.', + description: + 'List ID. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Contact ID', @@ -60,12 +52,8 @@ export const contactJourneyFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'add', - ], - resource: [ - 'contactJourney', - ], + operation: ['add'], + resource: ['contactJourney'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Autopilot/ContactListDescription.ts b/packages/nodes-base/nodes/Autopilot/ContactListDescription.ts index 9908ac2ca9a87..4611eed9e81f6 100644 --- a/packages/nodes-base/nodes/Autopilot/ContactListDescription.ts +++ b/packages/nodes-base/nodes/Autopilot/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: [ @@ -46,7 +42,6 @@ export const contactListOperations: INodeProperties[] = [ ]; export const contactListFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* contactList:add */ /* -------------------------------------------------------------------------- */ @@ -60,19 +55,13 @@ export const contactListFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - operation: [ - 'add', - 'remove', - 'exist', - 'getAll', - ], - resource: [ - 'contactList', - ], + operation: ['add', 'remove', 'exist', 'getAll'], + resource: ['contactList'], }, }, default: '', - description: 'ID of the list to operate on. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the list to operate on. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Contact ID', @@ -81,14 +70,8 @@ export const contactListFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'add', - 'remove', - 'exist', - ], - resource: [ - 'contactList', - ], + operation: ['add', 'remove', 'exist'], + resource: ['contactList'], }, }, default: '', @@ -104,12 +87,8 @@ export const contactListFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contactList', - ], + operation: ['getAll'], + resource: ['contactList'], }, }, default: false, @@ -121,15 +100,9 @@ export const contactListFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contactList', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['contactList'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts b/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts index c70a139c126f1..872a27176b21c 100644 --- a/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts @@ -1,22 +1,21 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - IHookFunctions, - IWebhookFunctions, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, IHookFunctions, IWebhookFunctions, NodeApiError } from 'n8n-workflow'; -export async function autopilotApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any - - const credentials = await this.getCredentials('autopilotApi') as IDataObject; +export async function autopilotApiRequest( + 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('autopilotApi')) as IDataObject; const apiKey = `${credentials.apiKey}`; @@ -47,8 +46,16 @@ export async function autopilotApiRequest(this: IExecuteFunctions | IWebhookFunc } } -export async function autopilotApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function autopilotApiRequestAllItems( + 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[] = []; const returnAll = this.getNodeParameter('returnAll', 0, false) as boolean; @@ -62,8 +69,6 @@ export async function autopilotApiRequestAllItems(this: IExecuteFunctions | ILoa if (query.limit && returnData.length >= query.limit && returnAll === false) { return returnData; } - } while ( - responseData.bookmark !== undefined - ); + } while (responseData.bookmark !== undefined); return returnData; } diff --git a/packages/nodes-base/nodes/Autopilot/ListDescription.ts b/packages/nodes-base/nodes/Autopilot/ListDescription.ts index 92d1fd8d2aad8..1f33738a1fcf2 100644 --- a/packages/nodes-base/nodes/Autopilot/ListDescription.ts +++ b/packages/nodes-base/nodes/Autopilot/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: [ @@ -34,7 +30,6 @@ export const listOperations: INodeProperties[] = [ ]; export const listFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* list:create */ /* -------------------------------------------------------------------------- */ @@ -45,12 +40,8 @@ export const listFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'list', - ], + operation: ['create'], + resource: ['list'], }, }, default: '', @@ -66,12 +57,8 @@ export const listFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'list', - ], + operation: ['getAll'], + resource: ['list'], }, }, default: false, @@ -83,15 +70,9 @@ export const listFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'list', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['list'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Aws/AwsLambda.node.ts b/packages/nodes-base/nodes/Aws/AwsLambda.node.ts index 32daebb5f3675..f1f544b5f32a9 100644 --- a/packages/nodes-base/nodes/Aws/AwsLambda.node.ts +++ b/packages/nodes-base/nodes/Aws/AwsLambda.node.ts @@ -58,15 +58,14 @@ export class AwsLambda implements INodeType { }, displayOptions: { show: { - operation: [ - 'invoke', - ], + operation: ['invoke'], }, }, options: [], default: '', required: true, - description: 'The function you want to invoke. Choose from the list, or specify an ID using an expression.', + description: + 'The function you want to invoke. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Qualifier', @@ -74,9 +73,7 @@ export class AwsLambda implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'invoke', - ], + operation: ['invoke'], }, }, required: true, @@ -101,9 +98,7 @@ export class AwsLambda implements INodeType { ], displayOptions: { show: { - operation: [ - 'invoke', - ], + operation: ['invoke'], }, }, default: 'RequestResponse', @@ -115,9 +110,7 @@ export class AwsLambda implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'invoke', - ], + operation: ['invoke'], }, }, default: '', @@ -145,7 +138,12 @@ export class AwsLambda implements INodeType { if (data.NextMarker) { let marker: string = data.NextMarker; while (true) { - const dataLoop = await awsApiRequestREST.call(this, 'lambda', 'GET', `/2015-03-31/functions/?MaxItems=50&Marker=${encodeURIComponent(marker)}`); + const dataLoop = await awsApiRequestREST.call( + this, + 'lambda', + 'GET', + `/2015-03-31/functions/?MaxItems=50&Marker=${encodeURIComponent(marker)}`, + ); for (const func of dataLoop.Functions!) { returnData.push({ @@ -167,7 +165,6 @@ export class AwsLambda implements INodeType { }, }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; diff --git a/packages/nodes-base/nodes/Aws/AwsSns.node.ts b/packages/nodes-base/nodes/Aws/AwsSns.node.ts index 073565e38d743..4d6ba5e8045f0 100644 --- a/packages/nodes-base/nodes/Aws/AwsSns.node.ts +++ b/packages/nodes-base/nodes/Aws/AwsSns.node.ts @@ -57,15 +57,14 @@ export class AwsSns implements INodeType { }, displayOptions: { show: { - operation: [ - 'publish', - ], + operation: ['publish'], }, }, options: [], default: '', required: true, - description: 'The topic you want to publish to. Choose from the list, or specify an ID using an expression.', + description: + 'The topic you want to publish to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Subject', @@ -73,9 +72,7 @@ export class AwsSns implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'publish', - ], + operation: ['publish'], }, }, default: '', @@ -88,9 +85,7 @@ export class AwsSns implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'publish', - ], + operation: ['publish'], }, }, required: true, @@ -134,7 +129,6 @@ export class AwsSns implements INodeType { }, }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -142,14 +136,20 @@ export class AwsSns implements INodeType { for (let i = 0; i < items.length; i++) { try { const params = [ - 'TopicArn=' + this.getNodeParameter('topic', i) as string, - 'Subject=' + this.getNodeParameter('subject', i) as string, - 'Message=' + this.getNodeParameter('message', i) as string, + ('TopicArn=' + this.getNodeParameter('topic', i)) as string, + ('Subject=' + this.getNodeParameter('subject', i)) as string, + ('Message=' + this.getNodeParameter('message', i)) as string, ]; - - const responseData = await awsApiRequestSOAP.call(this, 'sns', 'GET', '/?Action=Publish&' + params.join('&')); - returnData.push({MessageId: responseData.PublishResponse.PublishResult.MessageId} as IDataObject); + const responseData = await awsApiRequestSOAP.call( + this, + 'sns', + 'GET', + '/?Action=Publish&' + params.join('&'), + ); + returnData.push({ + MessageId: responseData.PublishResponse.PublishResult.MessageId, + } as IDataObject); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/Aws/AwsSnsTrigger.node.ts b/packages/nodes-base/nodes/Aws/AwsSnsTrigger.node.ts index 87608e27b85bc..7c4d803055ce9 100644 --- a/packages/nodes-base/nodes/Aws/AwsSnsTrigger.node.ts +++ b/packages/nodes-base/nodes/Aws/AwsSnsTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { ILoadOptionsFunctions, @@ -13,13 +10,9 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - awsApiRequestSOAP, -} from './GenericFunctions'; +import { awsApiRequestSOAP } from './GenericFunctions'; -import { - get, -} from 'lodash'; +import { get } from 'lodash'; export class AwsSnsTrigger implements INodeType { description: INodeTypeDescription = { @@ -54,7 +47,8 @@ export class AwsSnsTrigger implements INodeType { displayName: 'Topic Name or ID', name: 'topic', type: 'options', - 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: 'getTopics', @@ -102,12 +96,17 @@ export class AwsSnsTrigger implements INodeType { if (webhookData.webhookId === undefined) { return false; } - const params = [ - `TopicArn=${topic}`, - 'Version=2010-03-31', - ]; - const data = await awsApiRequestSOAP.call(this, 'sns', 'GET', '/?Action=ListSubscriptionsByTopic&' + params.join('&')); - const subscriptions = get(data, 'ListSubscriptionsByTopicResponse.ListSubscriptionsByTopicResult.Subscriptions'); + const params = [`TopicArn=${topic}`, 'Version=2010-03-31']; + const data = await awsApiRequestSOAP.call( + this, + 'sns', + 'GET', + '/?Action=ListSubscriptionsByTopic&' + params.join('&'), + ); + const subscriptions = get( + data, + 'ListSubscriptionsByTopicResponse.ListSubscriptionsByTopicResult.Subscriptions', + ); if (!subscriptions || !subscriptions.member) { return false; } @@ -131,7 +130,10 @@ export class AwsSnsTrigger implements INodeType { const topic = this.getNodeParameter('topic') as string; if (webhookUrl.includes('%20')) { - throw new NodeOperationError(this.getNode(), 'The name of the SNS Trigger Node is not allowed to contain any spaces!'); + throw new NodeOperationError( + this.getNode(), + 'The name of the SNS Trigger Node is not allowed to contain any spaces!', + ); } const params = [ @@ -142,20 +144,27 @@ export class AwsSnsTrigger implements INodeType { 'Version=2010-03-31', ]; - const { SubscribeResponse } = await awsApiRequestSOAP.call(this, 'sns', 'GET', '/?Action=Subscribe&' + params.join('&')); + const { SubscribeResponse } = await awsApiRequestSOAP.call( + this, + 'sns', + 'GET', + '/?Action=Subscribe&' + params.join('&'), + ); webhookData.webhookId = SubscribeResponse.SubscribeResult.SubscriptionArn; return true; }, async delete(this: IHookFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); - const params = [ - `SubscriptionArn=${webhookData.webhookId}`, - 'Version=2010-03-31', - ]; + const params = [`SubscriptionArn=${webhookData.webhookId}`, 'Version=2010-03-31']; try { - await awsApiRequestSOAP.call(this, 'sns', 'GET', '/?Action=Unsubscribe&' + params.join('&')); - } catch(error) { + await awsApiRequestSOAP.call( + this, + 'sns', + 'GET', + '/?Action=Unsubscribe&' + params.join('&'), + ); + } catch (error) { return false; } delete webhookData.webhookId; @@ -169,17 +178,17 @@ export class AwsSnsTrigger implements INodeType { const topic = this.getNodeParameter('topic') as string; // @ts-ignore - const body = JSON.parse((req.rawBody).toString()); + const body = JSON.parse(req.rawBody.toString()); - if (body.Type === 'SubscriptionConfirmation' && - body.TopicArn === topic) { + if (body.Type === 'SubscriptionConfirmation' && body.TopicArn === topic) { const { Token } = body; - const params = [ - `TopicArn=${topic}`, - `Token=${Token}`, - 'Version=2010-03-31', - ]; - await awsApiRequestSOAP.call(this, 'sns', 'GET', '/?Action=ConfirmSubscription&' + params.join('&')); + const params = [`TopicArn=${topic}`, `Token=${Token}`, 'Version=2010-03-31']; + await awsApiRequestSOAP.call( + this, + 'sns', + 'GET', + '/?Action=ConfirmSubscription&' + params.join('&'), + ); return { noWebhookResponse: true, @@ -192,9 +201,7 @@ export class AwsSnsTrigger implements INodeType { //TODO verify message signature return { - workflowData: [ - this.helpers.returnJsonArray(body), - ], + workflowData: [this.helpers.returnJsonArray(body)], }; } } diff --git a/packages/nodes-base/nodes/Aws/Comprehend/AwsComprehend.node.ts b/packages/nodes-base/nodes/Aws/Comprehend/AwsComprehend.node.ts index f8e5d1c721004..97bc35de7f8ac 100644 --- a/packages/nodes-base/nodes/Aws/Comprehend/AwsComprehend.node.ts +++ b/packages/nodes-base/nodes/Aws/Comprehend/AwsComprehend.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 { - awsApiRequestREST, -} from './GenericFunctions'; +import { awsApiRequestREST } from './GenericFunctions'; export class AwsComprehend implements INodeType { description: INodeTypeDescription = { @@ -132,13 +123,8 @@ export class AwsComprehend implements INodeType { default: 'en', displayOptions: { show: { - resource: [ - 'text', - ], - operation: [ - 'detectSentiment', - 'detectEntities', - ], + resource: ['text'], + operation: ['detectSentiment', 'detectEntities'], }, }, description: 'The language code for text', @@ -153,9 +139,7 @@ export class AwsComprehend implements INodeType { default: '', displayOptions: { show: { - resource: [ - 'text', - ], + resource: ['text'], }, }, description: 'The text to send', @@ -166,16 +150,13 @@ export class AwsComprehend implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'text', - ], - operation: [ - 'detectDominantLanguage', - ], + resource: ['text'], + operation: ['detectDominantLanguage'], }, }, 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', }, { displayName: 'Additional Fields', @@ -184,12 +165,8 @@ export class AwsComprehend implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'text', - ], - operation: [ - 'detectEntities', - ], + resource: ['text'], + operation: ['detectEntities'], }, }, default: {}, @@ -202,7 +179,8 @@ export class AwsComprehend implements INodeType { alwaysOpenEditWindow: true, }, default: '', - description: 'The Amazon Resource Name of an endpoint that is associated with a custom entity recognition model', + description: + 'The Amazon Resource Name of an endpoint that is associated with a custom entity recognition model', }, ], }, @@ -227,13 +205,23 @@ export class AwsComprehend implements INodeType { Text: text, }; const action = 'Comprehend_20171127.DetectDominantLanguage'; - responseData = await awsApiRequestREST.call(this, 'comprehend', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }); + responseData = await awsApiRequestREST.call( + this, + 'comprehend', + 'POST', + '', + JSON.stringify(body), + { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }, + ); if (simple === true) { - responseData = responseData.Languages.reduce((accumulator: { [key: string]: number }, currentValue: IDataObject) => { - accumulator[currentValue.LanguageCode as string] = currentValue.Score as number; - return accumulator; - }, {}); + responseData = responseData.Languages.reduce( + (accumulator: { [key: string]: number }, currentValue: IDataObject) => { + accumulator[currentValue.LanguageCode as string] = currentValue.Score as number; + return accumulator; + }, + {}, + ); } } @@ -246,7 +234,14 @@ export class AwsComprehend implements INodeType { Text: text, LanguageCode: languageCode, }; - responseData = await awsApiRequestREST.call(this, 'comprehend', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }); + responseData = await awsApiRequestREST.call( + this, + 'comprehend', + 'POST', + '', + JSON.stringify(body), + { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }, + ); } //https://docs.aws.amazon.com/comprehend/latest/dg/API_DetectEntities.html @@ -265,7 +260,14 @@ export class AwsComprehend implements INodeType { body.EndpointArn = additionalFields.endpointArn; } - responseData = await awsApiRequestREST.call(this, 'comprehend', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }); + responseData = await awsApiRequestREST.call( + this, + 'comprehend', + 'POST', + '', + JSON.stringify(body), + { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }, + ); responseData = responseData.Entities; } } diff --git a/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts index 7c326694709b8..0bae9e9cd0dc9 100644 --- a/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts @@ -1,19 +1,10 @@ -import { - URL, -} from 'url'; +import { URL } from 'url'; -import { - Request, - sign, -} from 'aws4'; +import { Request, sign } from 'aws4'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - parseString, -} from 'xml2js'; +import { parseString } from 'xml2js'; import { IExecuteFunctions, @@ -22,11 +13,12 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - ICredentialDataDecryptedObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { ICredentialDataDecryptedObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -function getEndpointForService(service: string, credentials: ICredentialDataDecryptedObject): string { +function getEndpointForService( + service: string, + credentials: ICredentialDataDecryptedObject, +): string { let endpoint; if (service === 'lambda' && credentials.lambdaEndpoint) { endpoint = credentials.lambdaEndpoint; @@ -38,7 +30,15 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr return (endpoint as string).replace('{region}', credentials.region as string); } -export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise { // tslint:disable-line:no-any +export async function awsApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + service: string, + method: string, + path: string, + body?: string, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('aws'); // Concatenate path and instantiate URL object so it parses correctly query strings @@ -49,7 +49,9 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I 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); @@ -68,7 +70,15 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I } } -export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise { // tslint:disable-line:no-any +export async function awsApiRequestREST( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + service: string, + method: string, + path: string, + body?: string, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const response = await awsApiRequest.call(this, service, method, path, body, headers); try { return JSON.parse(response); @@ -77,7 +87,15 @@ export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions } } -export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise { // tslint:disable-line:no-any +export async function awsApiRequestSOAP( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + service: string, + method: string, + path: string, + body?: string, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const response = await awsApiRequest.call(this, service, method, path, body, headers); try { return await new Promise((resolve, reject) => { diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts b/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts index 88a9ac8f2f404..65ccd619c6471 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.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, @@ -12,15 +10,9 @@ import { NodeParameterValue, } from 'n8n-workflow'; -import { - awsApiRequest, - awsApiRequestAllItems, -} from './GenericFunctions'; +import { awsApiRequest, awsApiRequestAllItems } from './GenericFunctions'; -import { - itemFields, - itemOperations, -} from './ItemDescription'; +import { itemFields, itemOperations } from './ItemDescription'; import { FieldsUiValues, @@ -102,22 +94,30 @@ export class AwsDynamoDB implements INodeType { const returnData: IDataObject[] = []; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'item') { - if (operation === 'upsert') { - // ---------------------------------- // upsert // ---------------------------------- // https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html - const eavUi = this.getNodeParameter('additionalFields.eavUi.eavValues', i, []) as IAttributeValueUi[]; - const conditionExpession = this.getNodeParameter('conditionExpression', i, '') as string; - const eanUi = this.getNodeParameter('additionalFields.eanUi.eanValues', i, []) as IAttributeNameUi[]; + const eavUi = this.getNodeParameter( + 'additionalFields.eavUi.eavValues', + i, + [], + ) as IAttributeValueUi[]; + const conditionExpession = this.getNodeParameter( + 'conditionExpression', + i, + '', + ) as string; + const eanUi = this.getNodeParameter( + 'additionalFields.eanUi.eanValues', + i, + [], + ) as IAttributeNameUi[]; const body: IRequestBody = { TableName: this.getNodeParameter('tableName', i) as string, @@ -139,14 +139,15 @@ export class AwsDynamoDB implements INodeType { body.ConditionExpression = conditionExpession; } - const dataToSend = this.getNodeParameter('dataToSend', 0) as 'defineBelow' | 'autoMapInputData'; + const dataToSend = this.getNodeParameter('dataToSend', 0) as + | 'defineBelow' + | 'autoMapInputData'; const item: { [key: string]: string } = {}; if (dataToSend === 'autoMapInputData') { - 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()); for (const key of incomingKeys) { if (inputsToIgnore.includes(key)) continue; @@ -154,13 +155,10 @@ export class AwsDynamoDB implements INodeType { } body.Item = adjustPutItem(item as PutItemUi); - } else { - const fields = this.getNodeParameter('fieldsUi.fieldValues', i, []) as FieldsUiValues; - fields.forEach(({ fieldId, fieldValue }) => item[fieldId] = fieldValue); + fields.forEach(({ fieldId, fieldValue }) => (item[fieldId] = fieldValue)); body.Item = adjustPutItem(item as PutItemUi); - } const headers = { @@ -170,9 +168,7 @@ export class AwsDynamoDB implements INodeType { responseData = await awsApiRequest.call(this, 'dynamodb', 'POST', '/', body, headers); responseData = item; - } else if (operation === 'delete') { - // ---------------------------------- // delete // ---------------------------------- @@ -186,12 +182,22 @@ export class AwsDynamoDB implements INodeType { ReturnValues: this.getNodeParameter('returnValues', 0) as string, }; - const eavUi = this.getNodeParameter('additionalFields.eavUi.eavValues', i, []) as IAttributeValueUi[]; - const eanUi = this.getNodeParameter('additionalFields.eanUi.eanValues', i, []) as IAttributeNameUi[]; + const eavUi = this.getNodeParameter( + 'additionalFields.eavUi.eavValues', + i, + [], + ) as IAttributeValueUi[]; + const eanUi = this.getNodeParameter( + 'additionalFields.eanUi.eanValues', + i, + [], + ) as IAttributeNameUi[]; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const simple = this.getNodeParameter('simple', 0, false) as boolean; - const items = this.getNodeParameter('keysUi.keyValues', i, []) as [{ key: string, type: string, value: string }]; + const items = this.getNodeParameter('keysUi.keyValues', i, []) as [ + { key: string; type: string; value: string }, + ]; for (const item of items) { let value = item.value as NodeParameterValue; @@ -229,9 +235,7 @@ export class AwsDynamoDB implements INodeType { } else if (simple === true) { responseData = decodeItem(responseData.Attributes); } - } else if (operation === 'get') { - // ---------------------------------- // get // ---------------------------------- @@ -242,7 +246,11 @@ export class AwsDynamoDB implements INodeType { const simple = this.getNodeParameter('simple', 0, false) as boolean; const select = this.getNodeParameter('select', 0) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - const eanUi = this.getNodeParameter('additionalFields.eanUi.eanValues', i, []) as IAttributeNameUi[]; + const eanUi = this.getNodeParameter( + 'additionalFields.eanUi.eanValues', + i, + [], + ) as IAttributeNameUi[]; // tslint:disable-next-line: no-any const body: { [key: string]: any } = { @@ -289,9 +297,7 @@ export class AwsDynamoDB implements INodeType { if (simple && responseData) { responseData = decodeItem(responseData); } - } else if (operation === 'getAll') { - // ---------------------------------- // getAll // ---------------------------------- @@ -303,7 +309,11 @@ export class AwsDynamoDB implements INodeType { const select = this.getNodeParameter('select', 0) as string; const returnAll = this.getNodeParameter('returnAll', 0) as boolean; const scan = this.getNodeParameter('scan', 0) as boolean; - const eanUi = this.getNodeParameter('options.eanUi.eanValues', i, []) as IAttributeNameUi[]; + const eanUi = this.getNodeParameter( + 'options.eanUi.eanValues', + i, + [], + ) as IAttributeNameUi[]; const body: IRequestBody = { TableName: this.getNodeParameter('tableName', i) as string, @@ -315,14 +325,16 @@ export class AwsDynamoDB implements INodeType { body['FilterExpression'] = filterExpression; } } else { - body['KeyConditionExpression'] = this.getNodeParameter('keyConditionExpression', i) as string; + body['KeyConditionExpression'] = this.getNodeParameter( + 'keyConditionExpression', + i, + ) as string; } - const { - indexName, - projectionExpression, - filterExpression, - } = this.getNodeParameter('options', i) as { + const { indexName, projectionExpression, filterExpression } = this.getNodeParameter( + 'options', + i, + ) as { indexName: string; projectionExpression: string; filterExpression: string; @@ -358,11 +370,18 @@ export class AwsDynamoDB implements INodeType { const headers = { 'Content-Type': 'application/json', - 'X-Amz-Target': (scan) ? 'DynamoDB_20120810.Scan' : 'DynamoDB_20120810.Query', + 'X-Amz-Target': scan ? 'DynamoDB_20120810.Scan' : 'DynamoDB_20120810.Query', }; if (returnAll === true && select !== 'COUNT') { - responseData = await awsApiRequestAllItems.call(this, 'dynamodb', 'POST', '/', body, headers); + responseData = await awsApiRequestAllItems.call( + this, + 'dynamodb', + 'POST', + '/', + body, + headers, + ); } else { body.Limit = this.getNodeParameter('limit', 0, 1) as number; responseData = await awsApiRequest.call(this, 'dynamodb', 'POST', '/', body, headers); @@ -373,14 +392,12 @@ export class AwsDynamoDB implements INodeType { if (simple === true) { responseData = responseData.map(simplify); } - } 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/Aws/DynamoDB/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts index c55fcfc6a1630..e3657c9505775 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts @@ -1,10 +1,6 @@ -import { - URL, -} from 'url'; +import { URL } from 'url'; -import { - sign, -} from 'aws4'; +import { sign } from 'aws4'; import { IExecuteFunctions, @@ -13,17 +9,14 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - ICredentialDataDecryptedObject, - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { ICredentialDataDecryptedObject, IDataObject, INodeExecutionData } from 'n8n-workflow'; -import { - IRequestBody, -} from './types'; +import { IRequestBody } from './types'; -function getEndpointForService(service: string, credentials: ICredentialDataDecryptedObject): string { +function getEndpointForService( + service: string, + credentials: ICredentialDataDecryptedObject, +): string { let endpoint; if (service === 'lambda' && credentials.lambdaEndpoint) { endpoint = credentials.lambdaEndpoint; @@ -35,7 +28,15 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr return (endpoint as string).replace('{region}', credentials.region as string); } -export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: object | IRequestBody, headers?: object): Promise { // tslint:disable-line:no-any +export async function awsApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + service: string, + method: string, + path: string, + body?: object | IRequestBody, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('aws'); // Concatenate path and instantiate URL object so it parses correctly query strings @@ -43,18 +44,23 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I const securityHeaders = { accessKeyId: `${credentials.accessKeyId}`.trim(), secretAccessKey: `${credentials.secretAccessKey}`.trim(), - sessionToken: credentials.temporaryCredentials ? `${credentials.sessionToken}`.trim() : undefined, + sessionToken: credentials.temporaryCredentials + ? `${credentials.sessionToken}`.trim() + : undefined, }; - const options = sign({ - // @ts-ignore - uri: endpoint, - service, - region: credentials.region as string, - method, - path: '/', - headers: { ...headers }, - body: JSON.stringify(body), - }, securityHeaders); + const options = sign( + { + // @ts-ignore + uri: endpoint, + service, + region: credentials.region as string, + method, + path: '/', + headers: { ...headers }, + body: JSON.stringify(body), + }, + securityHeaders, + ); try { return JSON.parse(await this.helpers.request!(options)); @@ -66,7 +72,11 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I if (error.statusCode === 403) { if (errorMessage === 'The security token included in the request is invalid.') { throw new Error('The AWS credentials are not valid!'); - } else if (errorMessage.startsWith('The request signature we calculated does not match the signature you provided')) { + } else if ( + errorMessage.startsWith( + 'The request signature we calculated does not match the signature you provided', + ) + ) { throw new Error('The AWS credentials are not valid!'); } } @@ -75,9 +85,15 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I } } - -export async function awsApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: IRequestBody, headers?: object): Promise { // tslint:disable-line:no-any - +export async function awsApiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + service: string, + method: string, + path: string, + body?: IRequestBody, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -88,9 +104,7 @@ export async function awsApiRequestAllItems(this: IHookFunctions | IExecuteFunct body!.ExclusiveStartKey = responseData.LastEvaluatedKey; } returnData.push(...responseData.Items); - } while ( - responseData.LastEvaluatedKey !== undefined - ); + } while (responseData.LastEvaluatedKey !== undefined); return returnData; } diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/ItemDescription.ts b/packages/nodes-base/nodes/Aws/DynamoDB/ItemDescription.ts index b18eb16f6d719..e9305372d0ad5 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/ItemDescription.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/ItemDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const itemOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const itemOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'item', - ], + resource: ['item'], }, }, options: [ @@ -52,14 +48,13 @@ export const itemFields: INodeProperties[] = [ { displayName: 'Table Name or ID', name: 'tableName', - description: 'Table to operate on. Choose from the list, or specify an ID using an expression.', + description: + 'Table to operate on. Choose from the list, or specify an ID using an expression.', type: 'options', required: true, displayOptions: { show: { - resource: [ - 'item', - ], + resource: ['item'], }, }, default: [], @@ -89,9 +84,7 @@ export const itemFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'upsert', - ], + operation: ['upsert'], }, }, default: 'defineBelow', @@ -103,16 +96,13 @@ export const itemFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'upsert', - ], - dataToSend: [ - 'autoMapInputData', - ], + operation: ['upsert'], + 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...', }, { @@ -126,12 +116,8 @@ export const itemFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'upsert', - ], - dataToSend: [ - 'defineBelow', - ], + operation: ['upsert'], + dataToSend: ['defineBelow'], }, }, default: {}, @@ -164,19 +150,16 @@ export const itemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'upsert', - ], + resource: ['item'], + operation: ['upsert'], }, }, options: [ { displayName: 'Expression Attribute Values', name: 'eavUi', - description: 'Substitution tokens for attribute names in an expression. Only needed when the parameter "condition expression" is set.', + description: + 'Substitution tokens for attribute names in an expression. Only needed when the parameter "condition expression" is set.', placeholder: 'Add Attribute Value', type: 'fixedCollection', default: {}, @@ -227,7 +210,8 @@ export const itemFields: INodeProperties[] = [ name: 'conditionExpression', type: 'string', default: '', - description: 'A condition that must be satisfied in order for a conditional upsert to succeed. View details.', + description: + 'A condition that must be satisfied in order for a conditional upsert to succeed. View details.', }, { displayName: 'Expression Attribute Names', @@ -258,7 +242,8 @@ export const itemFields: INodeProperties[] = [ ], }, ], - description: 'One or more substitution tokens for attribute names in an expression. View details.', + description: + 'One or more substitution tokens for attribute names in an expression. View details.', }, ], }, @@ -272,12 +257,8 @@ export const itemFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'delete', - ], + resource: ['item'], + operation: ['delete'], }, }, options: [ @@ -293,7 +274,8 @@ export const itemFields: INodeProperties[] = [ }, ], default: 'NONE', - description: 'Use ReturnValues if you want to get the item attributes as they appeared before they were deleted', + description: + 'Use ReturnValues if you want to get the item attributes as they appeared before they were deleted', }, { displayName: 'Keys', @@ -306,12 +288,8 @@ export const itemFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'delete', - ], + resource: ['item'], + operation: ['delete'], }, }, options: [ @@ -354,7 +332,8 @@ export const itemFields: INodeProperties[] = [ ], }, ], - description: 'Item\'s primary key. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key.', + description: + "Item's primary key. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key.", }, { displayName: 'Simplify', @@ -362,15 +341,9 @@ export const itemFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'delete', - ], - returnValues: [ - 'ALL_OLD', - ], + resource: ['item'], + operation: ['delete'], + returnValues: ['ALL_OLD'], }, }, default: true, @@ -384,12 +357,8 @@ export const itemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'delete', - ], + resource: ['item'], + operation: ['delete'], }, }, options: [ @@ -398,7 +367,8 @@ export const itemFields: INodeProperties[] = [ name: 'conditionExpression', type: 'string', default: '', - description: 'A condition that must be satisfied in order for a conditional delete to succeed', + description: + 'A condition that must be satisfied in order for a conditional delete to succeed', }, { displayName: 'Expression Attribute Names', @@ -429,12 +399,14 @@ export const itemFields: INodeProperties[] = [ ], }, ], - description: 'One or more substitution tokens for attribute names in an expression. Check Info.', + description: + 'One or more substitution tokens for attribute names in an expression. Check Info.', }, { displayName: 'Expression Attribute Values', name: 'expressionAttributeUi', - description: 'Substitution tokens for attribute names in an expression. Only needed when the parameter "condition expression" is set.', + description: + 'Substitution tokens for attribute names in an expression. Only needed when the parameter "condition expression" is set.', placeholder: 'Add Attribute Value', type: 'fixedCollection', default: {}, @@ -492,12 +464,8 @@ export const itemFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'get', - ], + resource: ['item'], + operation: ['get'], }, }, options: [ @@ -523,16 +491,9 @@ export const itemFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'get', - ], - select: [ - 'ALL_PROJECTED_ATTRIBUTES', - 'ALL_ATTRIBUTES', - ], + resource: ['item'], + operation: ['get'], + select: ['ALL_PROJECTED_ATTRIBUTES', 'ALL_ATTRIBUTES'], }, }, default: true, @@ -549,12 +510,8 @@ export const itemFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'get', - ], + resource: ['item'], + operation: ['get'], }, }, options: [ @@ -597,7 +554,8 @@ export const itemFields: INodeProperties[] = [ ], }, ], - description: 'Item\'s primary key. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key.', + description: + "Item's primary key. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key.", }, { displayName: 'Additional Fields', @@ -607,12 +565,8 @@ export const itemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'get', - ], + resource: ['item'], + operation: ['get'], }, }, options: [ @@ -653,7 +607,8 @@ export const itemFields: INodeProperties[] = [ ], }, ], - description: 'One or more substitution tokens for attribute names in an expression. View details.', + description: + 'One or more substitution tokens for attribute names in an expression. View details.', }, { displayName: 'Read Type', @@ -670,7 +625,8 @@ export const itemFields: INodeProperties[] = [ }, ], default: 'eventuallyConsistentRead', - description: 'Type of read to perform on the table. View details.', + description: + 'Type of read to perform on the table. View details.', }, ], }, @@ -684,16 +640,13 @@ export const itemFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'getAll', - ], + resource: ['item'], + operation: ['getAll'], }, }, default: false, - description: 'Whether to do an scan or query. Check differences.', + description: + 'Whether to do an scan or query. Check differences.', }, { displayName: 'Filter Expression', @@ -701,18 +654,18 @@ export const itemFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - scan: [ - true, - ], + scan: [true], }, }, default: '', - description: 'A filter expression determines which items within the Scan results should be returned to you. All of the other results are discarded. Empty value will return all Scan results.', + description: + 'A filter expression determines which items within the Scan results should be returned to you. All of the other results are discarded. Empty value will return all Scan results.', }, { displayName: 'Key Condition Expression', name: 'keyConditionExpression', - description: 'Condition to determine the items to be retrieved. The condition must perform an equality test on a single partition key value, in this format: partitionKeyName = :partitionkeyval', + description: + 'Condition to determine the items to be retrieved. The condition must perform an equality test on a single partition key value, in this format: partitionKeyName = :partitionkeyval', // eslint-disable-next-line n8n-nodes-base/node-param-placeholder-miscased-id placeholder: 'id = :id', default: '', @@ -720,15 +673,9 @@ export const itemFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'getAll', - ], - scan: [ - false, - ], + resource: ['item'], + operation: ['getAll'], + scan: [false], }, }, }, @@ -746,12 +693,8 @@ export const itemFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'getAll', - ], + resource: ['item'], + operation: ['getAll'], }, }, options: [ @@ -797,12 +740,8 @@ export const itemFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'getAll', - ], + resource: ['item'], + operation: ['getAll'], }, }, default: false, @@ -814,12 +753,8 @@ export const itemFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -835,12 +770,8 @@ export const itemFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'getAll', - ], + resource: ['item'], + operation: ['getAll'], }, }, options: [ @@ -870,17 +801,9 @@ export const itemFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'getAll', - ], - select: [ - 'ALL_PROJECTED_ATTRIBUTES', - 'ALL_ATTRIBUTES', - 'SPECIFIC_ATTRIBUTES', - ], + resource: ['item'], + operation: ['getAll'], + select: ['ALL_PROJECTED_ATTRIBUTES', 'ALL_ATTRIBUTES', 'SPECIFIC_ATTRIBUTES'], }, }, default: true, @@ -894,19 +817,16 @@ export const itemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'item', - ], - operation: [ - 'getAll', - ], + resource: ['item'], + operation: ['getAll'], }, }, options: [ { displayName: 'Index Name', name: 'indexName', - description: 'Name of the index to query. It can be any secondary local or global index on the table.', + description: + 'Name of the index to query. It can be any secondary local or global index on the table.', type: 'string', default: '', }, @@ -915,7 +835,8 @@ export const itemFields: INodeProperties[] = [ name: 'projectionExpression', type: 'string', default: '', - description: 'Text that identifies one or more attributes to retrieve from the table. These attributes can include scalars, sets, or elements of a JSON document. The attributes in the expression must be separated by commas.', + description: + 'Text that identifies one or more attributes to retrieve from the table. These attributes can include scalars, sets, or elements of a JSON document. The attributes in the expression must be separated by commas.', }, { displayName: 'Filter Expression', @@ -923,13 +844,12 @@ export const itemFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - '/scan': [ - false, - ], + '/scan': [false], }, }, default: '', - description: 'Text that contains conditions that DynamoDB applies after the Query operation, but before the data is returned. Items that do not satisfy the FilterExpression criteria are not returned.', + description: + 'Text that contains conditions that DynamoDB applies after the Query operation, but before the data is returned. Items that do not satisfy the FilterExpression criteria are not returned.', }, { displayName: 'Expression Attribute Names', @@ -960,7 +880,8 @@ export const itemFields: INodeProperties[] = [ ], }, ], - description: 'One or more substitution tokens for attribute names in an expression. Check Info.', + description: + 'One or more substitution tokens for attribute names in an expression. Check Info.', }, ], }, diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/types.d.ts b/packages/nodes-base/nodes/Aws/DynamoDB/types.d.ts index 99eada32c73f6..c03eb89ab59a1 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/types.d.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/types.d.ts @@ -32,27 +32,36 @@ export interface IAttributeNameUi { } type AttributeValueType = - | 'B' // binary - | 'BOOL' // boolean - | 'BS' // binary set - | 'L' // list - | 'M' // map - | 'N' // number + | 'B' // binary + | 'BOOL' // boolean + | 'BS' // binary set + | 'L' // list + | 'M' // map + | 'N' // number | 'NULL' - | 'NS' // number set - | 'S' // string - | 'SS'; // string set + | 'NS' // number set + | 'S' // string + | 'SS'; // string set export type PartitionKey = { details: { name: string; type: string; value: string; - }, + }; }; export enum EAttributeValueType { - S = 'S', SS = 'SS', M = 'M', L = 'L', NS = 'NS', N = 'N', BOOL = 'BOOL', B = 'B', BS = 'BS', NULL = 'NULL', + S = 'S', + SS = 'SS', + M = 'M', + L = 'L', + NS = 'NS', + N = 'N', + BOOL = 'BOOL', + B = 'B', + BS = 'BS', + NULL = 'NULL', } export interface IExpressionAttributeValue { @@ -74,6 +83,6 @@ export type PutItemUi = { export type AdjustedPutItem = { [attribute: string]: { - [type: string]: string - } + [type: string]: string; + }; }; diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/utils.ts b/packages/nodes-base/nodes/Aws/DynamoDB/utils.ts index a3651b48329bd..35399172b1efb 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/utils.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/utils.ts @@ -1,7 +1,4 @@ -import { - IDataObject, - INodeExecutionData, -} from 'n8n-workflow'; +import { IDataObject, INodeExecutionData } from 'n8n-workflow'; import { AdjustedPutItem, @@ -14,9 +11,10 @@ import { PutItemUi, } from './types'; -const addColon = (attribute: string) => attribute = attribute.charAt(0) === ':' ? attribute : `:${attribute}`; +const addColon = (attribute: string) => + (attribute = attribute.charAt(0) === ':' ? attribute : `:${attribute}`); -const addPound = (key: string) => key = key.charAt(0) === '#' ? key : `#${key}`; +const addPound = (key: string) => (key = key.charAt(0) === '#' ? key : `#${key}`); export function adjustExpressionAttributeValues(eavUi: IAttributeValueUi[]) { const eav: IAttributeValue = {}; @@ -100,7 +98,7 @@ export function validateJSON(input: any): object { export function copyInputItem(item: INodeExecutionData, properties: string[]): IDataObject { // Prepare the data to insert and copy it to be returned let newItem: IDataObject; - newItem = {}; + newItem = {}; for (const property of properties) { if (item.json[property] === undefined) { newItem[property] = null; diff --git a/packages/nodes-base/nodes/Aws/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/GenericFunctions.ts index f1d1d13508c3b..358b2d3a88fc9 100644 --- a/packages/nodes-base/nodes/Aws/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/GenericFunctions.ts @@ -10,11 +10,12 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - ICredentialDataDecryptedObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { ICredentialDataDecryptedObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -function getEndpointForService(service: string, credentials: ICredentialDataDecryptedObject): string { +function getEndpointForService( + service: string, + credentials: ICredentialDataDecryptedObject, +): string { let endpoint; if (service === 'lambda' && credentials.lambdaEndpoint) { endpoint = credentials.lambdaEndpoint; @@ -28,7 +29,15 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr return (endpoint as string).replace('{region}', credentials.region as string); } -export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise { // tslint:disable-line:no-any +export async function awsApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + service: string, + method: string, + path: string, + body?: string, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('aws'); // Concatenate path and instantiate URL object so it parses correctly query strings @@ -39,7 +48,9 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I 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); @@ -58,7 +69,15 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I } } -export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise { // tslint:disable-line:no-any +export async function awsApiRequestREST( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + service: string, + method: string, + path: string, + body?: string, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const response = await awsApiRequest.call(this, service, method, path, body, headers); try { return JSON.parse(response); @@ -67,7 +86,15 @@ export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions } } -export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise { // tslint:disable-line:no-any +export async function awsApiRequestSOAP( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + service: string, + method: string, + path: string, + body?: string, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const response = await awsApiRequest.call(this, service, method, path, body, headers); try { return await new Promise((resolve, reject) => { diff --git a/packages/nodes-base/nodes/Aws/Rekognition/AwsRekognition.node.ts b/packages/nodes-base/nodes/Aws/Rekognition/AwsRekognition.node.ts index 96f9b05e3e189..b29b48c76306a 100644 --- a/packages/nodes-base/nodes/Aws/Rekognition/AwsRekognition.node.ts +++ b/packages/nodes-base/nodes/Aws/Rekognition/AwsRekognition.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryKeyData, @@ -12,10 +10,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - awsApiRequestREST, - keysTPascalCase, -} from './GenericFunctions'; +import { awsApiRequestREST, keysTPascalCase } from './GenericFunctions'; export class AwsRekognition implements INodeType { description: INodeTypeDescription = { @@ -70,12 +65,8 @@ export class AwsRekognition implements INodeType { type: 'options', displayOptions: { show: { - operation: [ - 'analyze', - ], - resource: [ - 'image', - ], + operation: ['analyze'], + resource: ['image'], }, }, options: [ @@ -110,12 +101,8 @@ export class AwsRekognition implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'analyze', - ], - resource: [ - 'image', - ], + operation: ['analyze'], + resource: ['image'], }, }, description: 'Whether the image to analize should be taken from binary field', @@ -124,15 +111,9 @@ export class AwsRekognition implements INodeType { displayName: 'Binary Property', displayOptions: { show: { - operation: [ - 'analyze', - ], - resource: [ - 'image', - ], - binaryData: [ - true, - ], + operation: ['analyze'], + resource: ['image'], + binaryData: [true], }, }, name: 'binaryPropertyName', @@ -146,15 +127,9 @@ export class AwsRekognition implements INodeType { name: 'bucket', displayOptions: { show: { - operation: [ - 'analyze', - ], - resource: [ - 'image', - ], - binaryData: [ - false, - ], + operation: ['analyze'], + resource: ['image'], + binaryData: [false], }, }, type: 'string', @@ -167,15 +142,9 @@ export class AwsRekognition implements INodeType { name: 'name', displayOptions: { show: { - operation: [ - 'analyze', - ], - resource: [ - 'image', - ], - binaryData: [ - false, - ], + operation: ['analyze'], + resource: ['image'], + binaryData: [false], }, }, type: 'string', @@ -190,12 +159,8 @@ export class AwsRekognition implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'analyze', - ], - resource: [ - 'image', - ], + operation: ['analyze'], + resource: ['image'], }, }, default: {}, @@ -208,9 +173,7 @@ export class AwsRekognition implements INodeType { placeholder: 'Add Region of Interest', displayOptions: { show: { - '/type': [ - 'detectText', - ], + '/type': ['detectText'], }, }, typeOptions: { @@ -225,21 +188,24 @@ export class AwsRekognition implements INodeType { displayName: 'Height', name: 'height', type: 'number', - description: 'Height of the bounding box as a ratio of the overall image height', + description: + 'Height of the bounding box as a ratio of the overall image height', default: 0, }, { displayName: 'Left', name: 'left', type: 'number', - description: 'Left coordinate of the bounding box as a ratio of overall image width', + description: + 'Left coordinate of the bounding box as a ratio of overall image width', default: 0, }, { displayName: 'Top', name: 'top', type: 'number', - description: 'Top coordinate of the bounding box as a ratio of overall image height', + description: + 'Top coordinate of the bounding box as a ratio of overall image height', default: 0, }, { @@ -258,9 +224,7 @@ export class AwsRekognition implements INodeType { name: 'version', displayOptions: { show: { - '/binaryData': [ - false, - ], + '/binaryData': [false], }, }, type: 'string', @@ -275,9 +239,7 @@ export class AwsRekognition implements INodeType { placeholder: 'Add Word Filter', displayOptions: { show: { - '/type': [ - 'detectText', - ], + '/type': ['detectText'], }, }, typeOptions: { @@ -288,21 +250,24 @@ export class AwsRekognition implements INodeType { displayName: 'Min Bounding Box Height', name: 'MinBoundingBoxHeight', type: 'number', - description: 'Sets the minimum height of the word bounding box. Words with bounding box heights lesser than this value will be excluded from the result. Value is relative to the video frame height.', + description: + 'Sets the minimum height of the word bounding box. Words with bounding box heights lesser than this value will be excluded from the result. Value is relative to the video frame height.', default: 0, }, { displayName: 'Min Bounding Box Width', name: 'MinBoundingBoxWidth', type: 'number', - description: 'Sets the minimum width of the word bounding box. Words with bounding boxes widths lesser than this value will be excluded from the result. Value is relative to the video frame width.', + description: + 'Sets the minimum width of the word bounding box. Words with bounding boxes widths lesser than this value will be excluded from the result. Value is relative to the video frame width.', default: 0, }, { displayName: 'Min Confidence', name: 'MinConfidence', type: 'number', - description: 'Sets the confidence of word detection. Words with detection confidence below this will be excluded from the result. Values should be between 50 and 100 as Text in Video will not return any result below 50.', + description: + 'Sets the confidence of word detection. Words with detection confidence below this will be excluded from the result. Values should be between 50 and 100 as Text in Video will not return any result below 50.', default: 0, }, ], @@ -313,17 +278,15 @@ export class AwsRekognition implements INodeType { type: 'number', displayOptions: { show: { - '/type': [ - 'detectModerationLabels', - 'detectLabels', - ], + '/type': ['detectModerationLabels', 'detectLabels'], }, }, default: 0, typeOptions: { minValue: 0, }, - description: 'Maximum number of labels you want the service to return in the response. The service returns the specified number of highest confidence labels.', + description: + 'Maximum number of labels you want the service to return in the response. The service returns the specified number of highest confidence labels.', }, { displayName: 'Min Confidence', @@ -331,10 +294,7 @@ export class AwsRekognition implements INodeType { type: 'number', displayOptions: { show: { - '/type': [ - 'detectModerationLabels', - 'detectLabels', - ], + '/type': ['detectModerationLabels', 'detectLabels'], }, }, default: 0, @@ -342,7 +302,8 @@ export class AwsRekognition implements INodeType { minValue: 0, maxValue: 100, }, - description: 'Specifies the minimum confidence level for the labels to return. Amazon Rekognition doesn\'t return any labels with a confidence level lower than this specified value.', + description: + "Specifies the minimum confidence level for the labels to return. Amazon Rekognition doesn't return any labels with a confidence level lower than this specified value.", }, { displayName: 'Attributes', @@ -350,9 +311,7 @@ export class AwsRekognition implements INodeType { type: 'multiOptions', displayOptions: { show: { - '/type': [ - 'detectFaces', - ], + '/type': ['detectFaces'], }, }, options: [ @@ -438,7 +397,9 @@ export class AwsRekognition implements INodeType { body.Filters = {}; - const box = (additionalFields.regionsOfInterestUi as IDataObject || {}).regionsOfInterestValues as IDataObject[] || []; + const box = + (((additionalFields.regionsOfInterestUi as IDataObject) || {}) + .regionsOfInterestValues as IDataObject[]) || []; if (box.length !== 0) { //@ts-ignore @@ -447,7 +408,7 @@ export class AwsRekognition implements INodeType { }); } - const wordFilter = additionalFields.wordFilterUi as IDataObject || {}; + const wordFilter = (additionalFields.wordFilterUi as IDataObject) || {}; if (Object.keys(wordFilter).length !== 0) { //@ts-ignore body.Filters.WordFilter = keysTPascalCase(wordFilter); @@ -456,15 +417,20 @@ export class AwsRekognition implements INodeType { const binaryData = this.getNodeParameter('binaryData', 0) as boolean; if (binaryData) { - 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 binaryPropertyData = (items[i].binary as IBinaryKeyData)[binaryPropertyName]; @@ -474,9 +440,7 @@ export class AwsRekognition implements INodeType { Bytes: binaryPropertyData.data, }, }); - } else { - const bucket = this.getNodeParameter('bucket', i) as string; const name = this.getNodeParameter('name', i) as string; @@ -496,8 +460,15 @@ export class AwsRekognition implements INodeType { } } - responseData = await awsApiRequestREST.call(this, 'rekognition', 'POST', '', JSON.stringify(body), {}, { 'X-Amz-Target': action, 'Content-Type': 'application/x-amz-json-1.1' }); - + responseData = await awsApiRequestREST.call( + this, + 'rekognition', + 'POST', + '', + JSON.stringify(body), + {}, + { 'X-Amz-Target': action, 'Content-Type': 'application/x-amz-json-1.1' }, + ); } } } diff --git a/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts index 3a8b98c3607e9..112c8c6234d5f 100644 --- a/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts @@ -1,23 +1,12 @@ -import { - URL, -} from 'url'; +import { URL } from 'url'; -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, @@ -26,27 +15,39 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, - NodeApiError, - NodeOperationError, - } from 'n8n-workflow'; - -import { - pascalCase, -} from 'change-case'; - -export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string | Buffer | IDataObject, query: IDataObject = {}, headers?: object, option: IDataObject = {}, region?: string): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; + +import { pascalCase } from 'change-case'; + +export async function awsApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + service: string, + method: string, + path: string, + body?: string | Buffer | IDataObject, + query: IDataObject = {}, + headers?: object, + option: IDataObject = {}, + region?: string, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('aws'); - const endpoint = new URL(((credentials.rekognitionEndpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path); + const endpoint = new URL( + (((credentials.rekognitionEndpoint as string) || '').replace( + '{region}', + credentials.region as string, + ) || `https://${service}.${credentials.region}.amazonaws.com`) + path, + ); // Sign AWS API request with the user credentials - const signOpts = {headers: headers || {}, host: endpoint.host, method, path, body} as Request; + const signOpts = { headers: headers || {}, host: endpoint.host, method, path, body } as Request; 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); @@ -68,8 +69,29 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I } } -export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, method: string, path: string, body?: string, query: IDataObject = {}, headers?: object, options: IDataObject = {}, region?: string): Promise { // tslint:disable-line:no-any - const response = await awsApiRequest.call(this, service, method, path, body, query, headers, options, region); +export async function awsApiRequestREST( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + service: 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 awsApiRequest.call( + this, + service, + method, + path, + body, + query, + headers, + options, + region, + ); try { return JSON.parse(response); } catch (error) { @@ -77,8 +99,29 @@ export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions } } -export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string | Buffer | IDataObject, query: IDataObject = {}, headers?: object, option: IDataObject = {}, region?: string): Promise { // tslint:disable-line:no-any - const response = await awsApiRequest.call(this, service, method, path, body, query, headers, option, region); +export async function awsApiRequestSOAP( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + service: string, + method: string, + path: string, + body?: string | Buffer | IDataObject, + query: IDataObject = {}, + headers?: object, + option: IDataObject = {}, + region?: string, + // tslint:disable-next-line:no-any +): Promise { + const response = await awsApiRequest.call( + this, + service, + method, + path, + body, + query, + headers, + option, + region, + ); try { return await new Promise((resolve, reject) => { parseString(response, { explicitArray: false }, (err, data) => { @@ -93,18 +136,42 @@ export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions } } -export async function awsApiRequestSOAPAllItems(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 awsApiRequestSOAPAllItems( + 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 awsApiRequestSOAP.call(this, service, method, path, body, query, headers, option, region); + responseData = await awsApiRequestSOAP.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))) { @@ -125,7 +192,9 @@ export async function awsApiRequestSOAPAllItems(this: IHookFunctions | IExecuteF } function queryToString(params: IDataObject) { - return Object.keys(params).map(key => key + '=' + params[key]).join('&'); + return Object.keys(params) + .map((key) => key + '=' + params[key]) + .join('&'); } export function keysTPascalCase(object: IDataObject) { diff --git a/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts b/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts index 8a35569a016d2..ae7f3fc3adb23 100644 --- a/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts +++ b/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts @@ -1,20 +1,10 @@ +import { paramCase, snakeCase } from 'change-case'; -import { - paramCase, - snakeCase, -} from 'change-case'; +import { createHash } from 'crypto'; -import { - createHash, -} from 'crypto'; +import { Builder } from 'xml2js'; -import { - Builder, -} from 'xml2js'; - -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryKeyData, @@ -26,20 +16,11 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - bucketFields, - bucketOperations, -} from './BucketDescription'; +import { bucketFields, bucketOperations } from './BucketDescription'; -import { - folderFields, - folderOperations, -} from './FolderDescription'; +import { folderFields, folderOperations } from './FolderDescription'; -import { - fileFields, - fileOperations, -} from './FileDescription'; +import { fileFields, fileOperations } from './FileDescription'; import { awsApiRequestREST, @@ -121,7 +102,8 @@ export class AwsS3 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'] = ''; @@ -146,7 +128,7 @@ export class AwsS3 implements INodeType { const body: IDataObject = { CreateBucketConfiguration: { - '$': { + $: { xmlns: 'http://s3.amazonaws.com/doc/2006-03-01/', }, }, @@ -159,7 +141,15 @@ export class AwsS3 implements INodeType { const builder = new Builder(); data = builder.buildObject(body); } - responseData = await awsApiRequestSOAP.call(this, `${name}.s3`, 'PUT', '', data, qs, headers); + responseData = await awsApiRequestSOAP.call( + this, + `${name}.s3`, + 'PUT', + '', + data, + qs, + headers, + ); returnData.push({ success: true }); } @@ -168,7 +158,15 @@ export class AwsS3 implements INodeType { if (operation === 'delete') { const name = this.getNodeParameter('name', i) as string; - responseData = await awsApiRequestSOAP.call(this, `${name}.s3`, 'DELETE', '', '', {}, headers); + responseData = await awsApiRequestSOAP.call( + this, + `${name}.s3`, + 'DELETE', + '', + '', + {}, + headers, + ); returnData.push({ success: true }); } @@ -176,10 +174,24 @@ export class AwsS3 implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', 0) as boolean; if (returnAll) { - responseData = await awsApiRequestSOAPAllItems.call(this, 'ListAllMyBucketsResult.Buckets.Bucket', 's3', 'GET', ''); + responseData = await awsApiRequestSOAPAllItems.call( + this, + 'ListAllMyBucketsResult.Buckets.Bucket', + 's3', + 'GET', + '', + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; - responseData = await awsApiRequestSOAPAllItems.call(this, 'ListAllMyBucketsResult.Buckets.Bucket', 's3', 'GET', '', '', qs); + responseData = await awsApiRequestSOAPAllItems.call( + this, + 'ListAllMyBucketsResult.Buckets.Bucket', + 's3', + 'GET', + '', + '', + qs, + ); responseData = responseData.slice(0, qs.limit); } returnData.push.apply(returnData, responseData); @@ -217,16 +229,38 @@ export class AwsS3 implements INodeType { qs['list-type'] = 2; - - responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' }); + responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._ as string; if (returnAll) { - responseData = await awsApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', `${bucketName}.s3`, 'GET', '', '', qs, {}, {}, region); + responseData = await awsApiRequestSOAPAllItems.call( + this, + 'ListBucketResult.Contents', + `${bucketName}.s3`, + 'GET', + '', + '', + qs, + {}, + {}, + region, + ); } else { qs['max-keys'] = this.getNodeParameter('limit', 0) as number; - responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', qs, {}, {}, region); + responseData = await awsApiRequestSOAP.call( + this, + `${bucketName}.s3`, + 'GET', + '', + '', + qs, + {}, + {}, + region, + ); responseData = responseData.ListBucketResult.Contents; } if (Array.isArray(responseData)) { @@ -251,13 +285,27 @@ export class AwsS3 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 awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' }); + responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._; - responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'PUT', path, '', qs, headers, {}, region); + responseData = await awsApiRequestSOAP.call( + this, + `${bucketName}.s3`, + 'PUT', + path, + '', + qs, + headers, + {}, + region, + ); returnData.push({ success: true }); } //https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html @@ -265,24 +313,45 @@ export class AwsS3 implements INodeType { const bucketName = this.getNodeParameter('bucketName', i) as string; const folderKey = this.getNodeParameter('folderKey', i) as string; - responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' }); + responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._; - responseData = await awsApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', `${bucketName}.s3`, 'GET', '/', '', { 'list-type': 2, prefix: folderKey }, {}, {}, region); + responseData = await awsApiRequestSOAPAllItems.call( + this, + 'ListBucketResult.Contents', + `${bucketName}.s3`, + 'GET', + '/', + '', + { 'list-type': 2, prefix: folderKey }, + {}, + {}, + region, + ); // folder empty then just delete it if (responseData.length === 0) { - - responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'DELETE', `/${folderKey}`, '', qs, {}, {}, region); - - responseData = { deleted: [ { 'Key': folderKey } ] }; - + responseData = await awsApiRequestSOAP.call( + this, + `${bucketName}.s3`, + 'DELETE', + `/${folderKey}`, + '', + qs, + {}, + {}, + region, + ); + + responseData = { deleted: [{ Key: folderKey }] }; } else { - // delete everything inside the folder + // delete everything inside the folder const body: IDataObject = { Delete: { - '$': { + $: { xmlns: 'http://s3.amazonaws.com/doc/2006-03-01/', }, Object: [], @@ -303,7 +372,17 @@ export class AwsS3 implements INodeType { headers['Content-Type'] = 'application/xml'; - responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'POST', '/', data, { delete: '' } , headers, {}, region); + responseData = await awsApiRequestSOAP.call( + this, + `${bucketName}.s3`, + 'POST', + '/', + data, + { delete: '' }, + headers, + {}, + region, + ); responseData = { deleted: responseData.DeleteResult.Deleted }; } @@ -325,18 +404,45 @@ export class AwsS3 implements INodeType { qs['list-type'] = 2; - responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' }); + responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._; if (returnAll) { - responseData = await awsApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', `${bucketName}.s3`, 'GET', '', '', qs, {}, {}, region); + responseData = await awsApiRequestSOAPAllItems.call( + this, + 'ListBucketResult.Contents', + `${bucketName}.s3`, + 'GET', + '', + '', + qs, + {}, + {}, + region, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; - responseData = await awsApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', `${bucketName}.s3`, 'GET', '', '', qs, {}, {}, region); + responseData = await awsApiRequestSOAPAllItems.call( + this, + 'ListBucketResult.Contents', + `${bucketName}.s3`, + '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); } @@ -357,7 +463,9 @@ export class AwsS3 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); @@ -375,37 +483,52 @@ export class AwsS3 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('/'); @@ -414,17 +537,27 @@ export class AwsS3 implements INodeType { const destination = `/${destinationParts.slice(2, destinationParts.length).join('/')}`; - responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' }); + responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._; - responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'PUT', destination, '', qs, headers, {}, region); + responseData = await awsApiRequestSOAP.call( + this, + `${bucketName}.s3`, + '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; @@ -432,14 +565,29 @@ export class AwsS3 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 awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' }); + let region = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { + location: '', + }); region = region.LocationConstraint._; - const response = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', `/${fileKey}`, '', qs, {}, { encoding: null, resolveWithFullResponse: true }, region); + const response = await awsApiRequestREST.call( + this, + `${bucketName}.s3`, + 'GET', + `/${fileKey}`, + '', + qs, + {}, + { encoding: null, resolveWithFullResponse: true }, + region, + ); let mimeType: string | undefined; if (response.headers['content-type']) { @@ -460,11 +608,18 @@ export class AwsS3 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') { @@ -478,11 +633,23 @@ export class AwsS3 implements INodeType { qs.versionId = options.versionId as string; } - responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' }); + responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._; - responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'DELETE', `/${fileKey}`, '', qs, {}, {}, region); + responseData = await awsApiRequestSOAP.call( + this, + `${bucketName}.s3`, + 'DELETE', + `/${fileKey}`, + '', + qs, + {}, + {}, + region, + ); returnData.push({ success: true }); } @@ -504,19 +671,45 @@ export class AwsS3 implements INodeType { qs['list-type'] = 2; - responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' }); + responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._; if (returnAll) { - responseData = await awsApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', `${bucketName}.s3`, 'GET', '', '', qs, {}, {}, region); + responseData = await awsApiRequestSOAPAllItems.call( + this, + 'ListBucketResult.Contents', + `${bucketName}.s3`, + 'GET', + '', + '', + qs, + {}, + {}, + region, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; - responseData = await awsApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', `${bucketName}.s3`, 'GET', '', '', qs, {}, {}, region); + responseData = await awsApiRequestSOAPAllItems.call( + this, + 'ListBucketResult.Contents', + `${bucketName}.s3`, + '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); } @@ -529,7 +722,8 @@ export class AwsS3 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; @@ -540,7 +734,9 @@ export class AwsS3 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); @@ -558,39 +754,54 @@ export class AwsS3 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 awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' }); + responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { + location: '', + }); const region = responseData.LocationConstraint._; @@ -598,15 +809,24 @@ export class AwsS3 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]; - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + i, + binaryPropertyName, + ); body = binaryDataBuffer; @@ -614,10 +834,18 @@ export class AwsS3 implements INodeType { headers['Content-MD5'] = createHash('md5').update(body).digest('base64'); - responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'PUT', `${path}${fileName || binaryData.fileName}`, body, qs, headers, {}, region); - + responseData = await awsApiRequestSOAP.call( + this, + `${bucketName}.s3`, + 'PUT', + `${path}${fileName || binaryData.fileName}`, + body, + qs, + headers, + {}, + region, + ); } else { - const fileContent = this.getNodeParameter('fileContent', i) as string; body = Buffer.from(fileContent, 'utf8'); @@ -626,7 +854,17 @@ export class AwsS3 implements INodeType { headers['Content-MD5'] = createHash('md5').update(fileContent).digest('base64'); - responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'PUT', `${path}${fileName}`, body, qs, headers, {}, region); + responseData = await awsApiRequestSOAP.call( + this, + `${bucketName}.s3`, + 'PUT', + `${path}${fileName}`, + body, + qs, + headers, + {}, + region, + ); } returnData.push({ success: true }); } diff --git a/packages/nodes-base/nodes/Aws/S3/BucketDescription.ts b/packages/nodes-base/nodes/Aws/S3/BucketDescription.ts index 0cf93752ebd8a..a5bfd0aae1c29 100644 --- a/packages/nodes-base/nodes/Aws/S3/BucketDescription.ts +++ b/packages/nodes-base/nodes/Aws/S3/BucketDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const bucketOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const bucketOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'bucket', - ], + resource: ['bucket'], }, }, options: [ @@ -46,10 +42,9 @@ export const bucketOperations: INodeProperties[] = [ ]; export const bucketFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* bucket:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* bucket:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Name', name: 'name', @@ -58,12 +53,8 @@ export const bucketFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'bucket', - ], - operation: [ - 'create', - ], + resource: ['bucket'], + operation: ['create'], }, }, description: 'A succinct description of the nature, symptoms, cause, or effect of the bucket', @@ -75,12 +66,8 @@ export const bucketFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'bucket', - ], - operation: [ - 'create', - ], + resource: ['bucket'], + operation: ['create'], }, }, default: {}, @@ -122,7 +109,8 @@ export const bucketFields: INodeProperties[] = [ name: 'grantFullControl', type: 'boolean', default: false, - description: 'Whether to allow grantee the read, write, read ACP, and write ACP permissions on the bucket', + description: + 'Whether to allow grantee the read, write, read ACP, and write ACP permissions on the bucket', }, { displayName: 'Grant Read', @@ -143,7 +131,8 @@ export const bucketFields: INodeProperties[] = [ name: 'grantWrite', type: 'boolean', default: false, - description: 'Whether to allow grantee to create, overwrite, and delete any object in the bucket', + description: + 'Whether to allow grantee to create, overwrite, and delete any object in the bucket', }, { displayName: 'Grant Write ACP', @@ -157,14 +146,15 @@ export const bucketFields: INodeProperties[] = [ name: 'region', type: 'string', default: '', - description: 'Region you want to create the bucket in, by default the buckets are created on the region defined on the credentials', + description: + 'Region you want to create the bucket in, by default the buckets are created on the region defined on the credentials', }, ], }, -/* -------------------------------------------------------------------------- */ -/* bucket:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* bucket:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Name', name: 'name', @@ -173,32 +163,24 @@ export const bucketFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'bucket', - ], - operation: [ - 'delete', - ], + resource: ['bucket'], + operation: ['delete'], }, }, description: 'Name of the AWS S3 bucket to delete', }, -/* -------------------------------------------------------------------------- */ -/* bucket:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* bucket:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'bucket', - ], + operation: ['getAll'], + resource: ['bucket'], }, }, default: false, @@ -210,15 +192,9 @@ export const bucketFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'bucket', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['bucket'], + returnAll: [false], }, }, typeOptions: { @@ -228,9 +204,9 @@ export const bucketFields: INodeProperties[] = [ default: 100, description: 'Max number of results to return', }, -/* -------------------------------------------------------------------------- */ -/* bucket:search */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* bucket:search */ + /* -------------------------------------------------------------------------- */ { displayName: 'Bucket Name', name: 'bucketName', @@ -239,12 +215,8 @@ export const bucketFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'bucket', - ], - operation: [ - 'search', - ], + resource: ['bucket'], + operation: ['search'], }, }, }, @@ -254,12 +226,8 @@ export const bucketFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'bucket', - ], + operation: ['search'], + resource: ['bucket'], }, }, default: false, @@ -271,15 +239,9 @@ export const bucketFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'bucket', - ], - returnAll: [ - false, - ], + operation: ['search'], + resource: ['bucket'], + returnAll: [false], }, }, typeOptions: { @@ -296,12 +258,8 @@ export const bucketFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'bucket', - ], - operation: [ - 'search', - ], + resource: ['bucket'], + operation: ['search'], }, }, default: {}, @@ -332,7 +290,8 @@ export const bucketFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'The owner field is not present in listV2 by default, if you want to return owner field with each key in the result then set the fetch owner field to true', + description: + 'The owner field is not present in listV2 by default, if you want to return owner field with each key in the result then set the fetch owner field to true', }, { displayName: 'Prefix', @@ -346,14 +305,16 @@ export const bucketFields: INodeProperties[] = [ name: 'requesterPays', type: 'boolean', default: false, - description: 'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.', + description: + 'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.', }, { displayName: 'Start After', name: 'startAfter', type: 'string', default: '', - description: 'StartAfter is where you want Amazon S3 to start listing from. Amazon S3 starts listing after this specified key.', + description: + 'StartAfter is where you want Amazon S3 to start listing from. Amazon S3 starts listing after this specified key.', }, ], }, diff --git a/packages/nodes-base/nodes/Aws/S3/FileDescription.ts b/packages/nodes-base/nodes/Aws/S3/FileDescription.ts index 386575dda73cf..f6bd10dabfed0 100644 --- a/packages/nodes-base/nodes/Aws/S3/FileDescription.ts +++ b/packages/nodes-base/nodes/Aws/S3/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: [ @@ -52,10 +48,9 @@ export const fileOperations: INodeProperties[] = [ ]; export const fileFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* file:copy */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* file:copy */ + /* -------------------------------------------------------------------------- */ { displayName: 'Source Path', name: 'sourcePath', @@ -65,15 +60,12 @@ export const fileFields: INodeProperties[] = [ placeholder: '/bucket/my-image.jpg', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'copy', - ], + resource: ['file'], + operation: ['copy'], }, }, - description: 'The name of the source bucket and key name of the source object, separated by a slash (/)', + description: + 'The name of the source bucket and key name of the source object, separated by a slash (/)', }, { displayName: 'Destination Path', @@ -84,15 +76,12 @@ export const fileFields: INodeProperties[] = [ placeholder: '/bucket/my-second-image.jpg', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'copy', - ], + resource: ['file'], + operation: ['copy'], }, }, - description: 'The name of the destination bucket and key name of the destination object, separated by a slash (/)', + description: + 'The name of the destination bucket and key name of the destination object, separated by a slash (/)', }, { displayName: 'Additional Fields', @@ -101,12 +90,8 @@ export const fileFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'copy', - ], + resource: ['file'], + operation: ['copy'], }, }, default: {}, @@ -153,7 +138,8 @@ export const fileFields: INodeProperties[] = [ name: 'grantFullControl', type: 'boolean', default: false, - description: 'Whether to give the grantee READ, READ_ACP, and WRITE_ACP permissions on the object', + description: + 'Whether to give the grantee READ, READ_ACP, and WRITE_ACP permissions on the object', }, { displayName: 'Grant Read', @@ -205,7 +191,7 @@ export const fileFields: INodeProperties[] = [ name: 'lockRetainUntilDate', type: 'dateTime', default: '', - description: 'The date and time when you want this object\'s Object Lock to expire', + description: "The date and time when you want this object's Object Lock to expire", }, { displayName: 'Metadata Directive', @@ -222,14 +208,16 @@ export const fileFields: INodeProperties[] = [ }, ], default: '', - description: 'Specifies whether the metadata is copied from the source object or replaced with metadata provided in the request', + description: + 'Specifies whether the metadata is copied from the source object or replaced with metadata provided in the request', }, { displayName: 'Requester Pays', name: 'requesterPays', type: 'boolean', default: false, - description: 'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.', + description: + 'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.', }, { displayName: 'Server Side Encryption', @@ -246,7 +234,8 @@ export const fileFields: INodeProperties[] = [ }, ], default: '', - description: 'The server-side encryption algorithm used when storing this object in Amazon S3', + description: + 'The server-side encryption algorithm used when storing this object in Amazon S3', }, { displayName: 'Server Side Encryption Context', @@ -267,14 +256,16 @@ export const fileFields: INodeProperties[] = [ name: 'serversideEncryptionCustomerAlgorithm', type: 'string', default: '', - description: 'Specifies the algorithm to use to when encrypting the object (for example, AES256)', + description: + 'Specifies the algorithm to use to when encrypting the object (for example, AES256)', }, { displayName: 'Server Side Encryption Customer Key', name: 'serversideEncryptionCustomerKey', type: 'string', default: '', - description: 'Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data', + description: + 'Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data', }, { displayName: 'Server Side Encryption Customer Key MD5', @@ -331,13 +322,14 @@ export const fileFields: INodeProperties[] = [ }, ], default: '', - description: 'Specifies whether the metadata is copied from the source object or replaced with metadata provided in the request', + description: + 'Specifies whether the metadata is copied from the source object or replaced with metadata provided in the request', }, ], }, -/* -------------------------------------------------------------------------- */ -/* file:upload */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* file:upload */ + /* -------------------------------------------------------------------------- */ { displayName: 'Bucket Name', name: 'bucketName', @@ -346,12 +338,8 @@ export const fileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'upload', - ], + resource: ['file'], + operation: ['upload'], }, }, }, @@ -364,15 +352,9 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'upload', - ], - binaryData: [ - false, - ], + resource: ['file'], + operation: ['upload'], + binaryData: [false], }, }, }, @@ -383,15 +365,9 @@ export const fileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'upload', - ], - binaryData: [ - true, - ], + resource: ['file'], + operation: ['upload'], + binaryData: [true], }, }, description: 'If not set the binary data filename will be used', @@ -403,12 +379,8 @@ export const fileFields: INodeProperties[] = [ default: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, description: 'Whether the data to upload should be taken from binary field', @@ -420,15 +392,9 @@ export const fileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], - binaryData: [ - false, - ], + operation: ['upload'], + resource: ['file'], + binaryData: [false], }, }, placeholder: '', @@ -442,17 +408,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', @@ -464,12 +423,8 @@ export const fileFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'upload', - ], + resource: ['file'], + operation: ['upload'], }, }, default: {}, @@ -516,7 +471,8 @@ export const fileFields: INodeProperties[] = [ name: 'grantFullControl', type: 'boolean', default: false, - description: 'Whether to give the grantee READ, READ_ACP, and WRITE_ACP permissions on the object', + description: + 'Whether to give the grantee READ, READ_ACP, and WRITE_ACP permissions on the object', }, { displayName: 'Grant Read', @@ -568,7 +524,7 @@ export const fileFields: INodeProperties[] = [ name: 'lockRetainUntilDate', type: 'dateTime', default: '', - description: 'The date and time when you want this object\'s Object Lock to expire', + description: "The date and time when you want this object's Object Lock to expire", }, { displayName: 'Parent Folder Key', @@ -582,7 +538,8 @@ export const fileFields: INodeProperties[] = [ name: 'requesterPays', type: 'boolean', default: false, - description: 'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.', + description: + 'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.', }, { displayName: 'Server Side Encryption', @@ -599,7 +556,8 @@ export const fileFields: INodeProperties[] = [ }, ], default: '', - description: 'The server-side encryption algorithm used when storing this object in Amazon S3', + description: + 'The server-side encryption algorithm used when storing this object in Amazon S3', }, { displayName: 'Server Side Encryption Context', @@ -620,14 +578,16 @@ export const fileFields: INodeProperties[] = [ name: 'serversideEncryptionCustomerAlgorithm', type: 'string', default: '', - description: 'Specifies the algorithm to use to when encrypting the object (for example, AES256)', + description: + 'Specifies the algorithm to use to when encrypting the object (for example, AES256)', }, { displayName: 'Server Side Encryption Customer Key', name: 'serversideEncryptionCustomerKey', type: 'string', default: '', - description: 'Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data', + description: + 'Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data', }, { displayName: 'Server Side Encryption Customer Key MD5', @@ -682,12 +642,8 @@ export const fileFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'upload', - ], + resource: ['file'], + operation: ['upload'], }, }, options: [ @@ -712,9 +668,9 @@ export const fileFields: INodeProperties[] = [ ], description: 'Optional extra headers to add to the message (most headers are allowed)', }, -/* -------------------------------------------------------------------------- */ -/* file:download */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* file:download */ + /* -------------------------------------------------------------------------- */ { displayName: 'Bucket Name', name: 'bucketName', @@ -723,12 +679,8 @@ export const fileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'download', - ], + resource: ['file'], + operation: ['download'], }, }, }, @@ -740,12 +692,8 @@ export const fileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'download', - ], + resource: ['file'], + operation: ['download'], }, }, }, @@ -757,19 +705,15 @@ 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:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* file:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Bucket Name', name: 'bucketName', @@ -778,12 +722,8 @@ export const fileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'delete', - ], + resource: ['file'], + operation: ['delete'], }, }, }, @@ -795,12 +735,8 @@ export const fileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'delete', - ], + resource: ['file'], + operation: ['delete'], }, }, }, @@ -812,12 +748,8 @@ export const fileFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'delete', - ], + resource: ['file'], + operation: ['delete'], }, }, options: [ @@ -829,9 +761,9 @@ export const fileFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* file:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* file:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Bucket Name', name: 'bucketName', @@ -840,12 +772,8 @@ export const fileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'getAll', - ], + resource: ['file'], + operation: ['getAll'], }, }, }, @@ -855,12 +783,8 @@ export const fileFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'file', - ], + operation: ['getAll'], + resource: ['file'], }, }, default: false, @@ -872,15 +796,9 @@ export const fileFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'file', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['file'], + returnAll: [false], }, }, typeOptions: { @@ -898,12 +816,8 @@ export const fileFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'file', - ], - operation: [ - 'getAll', - ], + resource: ['file'], + operation: ['getAll'], }, }, options: [ @@ -913,7 +827,8 @@ export const fileFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'The owner field is not present in listV2 by default, if you want to return owner field with each key in the result then set the fetch owner field to true', + description: + 'The owner field is not present in listV2 by default, if you want to return owner field with each key in the result then set the fetch owner field to true', }, { displayName: 'Folder Key', diff --git a/packages/nodes-base/nodes/Aws/S3/FolderDescription.ts b/packages/nodes-base/nodes/Aws/S3/FolderDescription.ts index 2a0c003e1dc66..c089d646a2980 100644 --- a/packages/nodes-base/nodes/Aws/S3/FolderDescription.ts +++ b/packages/nodes-base/nodes/Aws/S3/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: [ @@ -40,10 +36,9 @@ export const folderOperations: INodeProperties[] = [ ]; export const folderFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* folder:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* folder:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Bucket Name', name: 'bucketName', @@ -52,12 +47,8 @@ export const folderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'create', - ], + resource: ['folder'], + operation: ['create'], }, }, }, @@ -69,12 +60,8 @@ export const folderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'create', - ], + resource: ['folder'], + operation: ['create'], }, }, }, @@ -85,12 +72,8 @@ export const folderFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'create', - ], + resource: ['folder'], + operation: ['create'], }, }, default: {}, @@ -107,7 +90,8 @@ export const folderFields: INodeProperties[] = [ name: 'requesterPays', type: 'boolean', default: false, - description: 'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.', + description: + 'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.', }, { displayName: 'Storage Class', @@ -148,9 +132,9 @@ export const folderFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* folder:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* folder:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Bucket Name', name: 'bucketName', @@ -159,12 +143,8 @@ export const folderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'delete', - ], + resource: ['folder'], + operation: ['delete'], }, }, }, @@ -176,18 +156,14 @@ export const folderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'delete', - ], + resource: ['folder'], + operation: ['delete'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* folder:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* folder:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Bucket Name', name: 'bucketName', @@ -196,12 +172,8 @@ export const folderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'getAll', - ], + resource: ['folder'], + operation: ['getAll'], }, }, }, @@ -211,12 +183,8 @@ export const folderFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'folder', - ], + operation: ['getAll'], + resource: ['folder'], }, }, default: false, @@ -228,15 +196,9 @@ export const folderFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'folder', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['folder'], + returnAll: [false], }, }, typeOptions: { @@ -254,12 +216,8 @@ export const folderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'getAll', - ], + resource: ['folder'], + operation: ['getAll'], }, }, options: [ @@ -269,7 +227,8 @@ export const folderFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'The owner field is not present in listV2 by default, if you want to return owner field with each key in the result then set the fetch owner field to true', + description: + 'The owner field is not present in listV2 by default, if you want to return owner field with each key in the result then set the fetch owner field to true', }, { displayName: 'Folder Key', diff --git a/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts index d2d7d4d19cca6..42c6537596ec6 100644 --- a/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts @@ -1,23 +1,12 @@ -import { - URL, -} from 'url'; +import { URL } from 'url'; -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, @@ -26,21 +15,41 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, JsonObject, NodeApiError, NodeOperationError, - } from 'n8n-workflow'; - -export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string | Buffer, query: IDataObject = {}, headers?: object, option: IDataObject = {}, region?: string): Promise { // tslint:disable-line:no-any +import { IDataObject, JsonObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; + +export async function awsApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + service: string, + method: string, + path: string, + body?: string | Buffer, + query: IDataObject = {}, + headers?: object, + option: IDataObject = {}, + region?: string, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('aws'); - const endpoint = new URL(((credentials.s3Endpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path); + const endpoint = new URL( + (((credentials.s3Endpoint as string) || '').replace('{region}', credentials.region as string) || + `https://${service}.${credentials.region}.amazonaws.com`) + path, + ); // Sign AWS API request with the user credentials - const signOpts = {headers: headers || {}, host: endpoint.host, method, path: `${endpoint.pathname}?${queryToString(query).replace(/\+/g, '%2B')}`, body} as Request; + const signOpts = { + headers: headers || {}, + host: endpoint.host, + method, + path: `${endpoint.pathname}?${queryToString(query).replace(/\+/g, '%2B')}`, + body, + } as Request; 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); @@ -59,12 +68,33 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I 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); } } -export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, method: string, path: string, body?: string, query: IDataObject = {}, headers?: object, options: IDataObject = {}, region?: string): Promise { // tslint:disable-line:no-any - const response = await awsApiRequest.call(this, service, method, path, body, query, headers, options, region); +export async function awsApiRequestREST( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + service: 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 awsApiRequest.call( + this, + service, + method, + path, + body, + query, + headers, + options, + region, + ); try { return JSON.parse(response); } catch (error) { @@ -72,8 +102,29 @@ export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions } } -export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: 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 awsApiRequest.call(this, service, method, path, body, query, headers, option, region); +export async function awsApiRequestSOAP( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + service: 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 awsApiRequest.call( + this, + service, + method, + path, + body, + query, + headers, + option, + region, + ); try { return await new Promise((resolve, reject) => { parseString(response, { explicitArray: false }, (err, data) => { @@ -88,18 +139,42 @@ export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions } } -export async function awsApiRequestSOAPAllItems(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 awsApiRequestSOAPAllItems( + 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 awsApiRequestSOAP.call(this, service, method, path, body, query, headers, option, region); + responseData = await awsApiRequestSOAP.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))) { @@ -120,5 +195,7 @@ export async function awsApiRequestSOAPAllItems(this: IHookFunctions | IExecuteF } 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/Aws/SES/AwsSes.node.ts b/packages/nodes-base/nodes/Aws/SES/AwsSes.node.ts index 72e13db4f6fa4..0b2ede1b3b24a 100644 --- a/packages/nodes-base/nodes/Aws/SES/AwsSes.node.ts +++ b/packages/nodes-base/nodes/Aws/SES/AwsSes.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,10 +10,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - awsApiRequestSOAP, - awsApiRequestSOAPAllItems, -} from './GenericFunctions'; +import { awsApiRequestSOAP, awsApiRequestSOAPAllItems } from './GenericFunctions'; function setParameter(params: string[], base: string, values: string[]) { for (let i = 0; i < values.length; i++) { @@ -72,9 +67,7 @@ export class AwsSes implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'customVerificationEmail', - ], + resource: ['customVerificationEmail'], }, }, options: [ @@ -99,7 +92,8 @@ export class AwsSes implements INodeType { { name: 'Get All', value: 'getAll', - description: 'Get all the existing custom verification email templates for your account', + description: + 'Get all the existing custom verification email templates for your account', action: 'Get all custom verifications', }, { @@ -124,12 +118,8 @@ export class AwsSes implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'customVerificationEmail', - ], - operation: [ - 'create', - ], + resource: ['customVerificationEmail'], + operation: ['create'], }, }, required: true, @@ -142,12 +132,8 @@ export class AwsSes implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'customVerificationEmail', - ], - operation: [ - 'create', - ], + resource: ['customVerificationEmail'], + operation: ['create'], }, }, default: '', @@ -162,15 +148,12 @@ export class AwsSes implements INodeType { }, displayOptions: { show: { - resource: [ - 'customVerificationEmail', - ], - operation: [ - 'create', - ], + resource: ['customVerificationEmail'], + operation: ['create'], }, }, - description: 'The content of the custom verification email. The total size of the email must be less than 10 MB. The message body may contain HTML', + description: + 'The content of the custom verification email. The total size of the email must be less than 10 MB. The message body may contain HTML', default: '', }, { @@ -179,12 +162,8 @@ export class AwsSes implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'customVerificationEmail', - ], - operation: [ - 'create', - ], + resource: ['customVerificationEmail'], + operation: ['create'], }, }, default: '', @@ -197,16 +176,13 @@ export class AwsSes implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'customVerificationEmail', - ], - operation: [ - 'create', - ], + resource: ['customVerificationEmail'], + operation: ['create'], }, }, required: true, - description: 'The URL that the recipient of the verification email is sent to if his or her address is successfully verified', + description: + 'The URL that the recipient of the verification email is sent to if his or her address is successfully verified', default: '', }, { @@ -215,16 +191,13 @@ export class AwsSes implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'customVerificationEmail', - ], - operation: [ - 'create', - ], + resource: ['customVerificationEmail'], + operation: ['create'], }, }, required: true, - description: 'The URL that the recipient of the verification email is sent to if his or her address is not successfully verified', + description: + 'The URL that the recipient of the verification email is sent to if his or her address is not successfully verified', default: '', }, @@ -235,12 +208,8 @@ export class AwsSes implements INodeType { placeholder: 'name@email.com', displayOptions: { show: { - resource: [ - 'customVerificationEmail', - ], - operation: [ - 'send', - ], + resource: ['customVerificationEmail'], + operation: ['send'], }, }, default: '', @@ -253,17 +222,14 @@ export class AwsSes implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'customVerificationEmail', - ], - operation: [ - 'send', - ], + resource: ['customVerificationEmail'], + operation: ['send'], }, }, default: '', required: true, - description: 'The name of the custom verification email template to use when sending the verification email', + description: + 'The name of the custom verification email template to use when sending the verification email', }, { displayName: 'Additional Fields', @@ -273,12 +239,8 @@ export class AwsSes implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'customVerificationEmail', - ], - operation: [ - 'send', - ], + resource: ['customVerificationEmail'], + operation: ['send'], }, }, options: [ @@ -298,14 +260,8 @@ export class AwsSes implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'customVerificationEmail', - ], - operation: [ - 'update', - 'delete', - 'get', - ], + resource: ['customVerificationEmail'], + operation: ['update', 'delete', 'get'], }, }, default: '', @@ -319,12 +275,8 @@ export class AwsSes implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'customVerificationEmail', - ], - operation: [ - 'update', - ], + resource: ['customVerificationEmail'], + operation: ['update'], }, }, options: [ @@ -332,7 +284,8 @@ export class AwsSes implements INodeType { displayName: 'Failure Redirection URL', name: 'failureRedirectionURL', type: 'string', - description: 'The URL that the recipient of the verification email is sent to if his or her address is not successfully verified', + description: + 'The URL that the recipient of the verification email is sent to if his or her address is not successfully verified', default: '', }, { @@ -346,7 +299,8 @@ export class AwsSes implements INodeType { displayName: 'Success Redirection URL', name: 'successRedirectionURL', type: 'string', - description: 'The URL that the recipient of the verification email is sent to if his or her address is successfully verified', + description: + 'The URL that the recipient of the verification email is sent to if his or her address is successfully verified', default: '', }, { @@ -356,7 +310,8 @@ export class AwsSes implements INodeType { typeOptions: { alwaysOpenEditWindow: true, }, - description: 'The content of the custom verification email. The total size of the email must be less than 10 MB. The message body may contain HTML', + description: + 'The content of the custom verification email. The total size of the email must be less than 10 MB. The message body may contain HTML', default: '', }, { @@ -374,12 +329,8 @@ export class AwsSes implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'customVerificationEmail', - ], - operation: [ - 'getAll', - ], + resource: ['customVerificationEmail'], + operation: ['getAll'], }, }, default: false, @@ -396,15 +347,9 @@ export class AwsSes implements INodeType { default: 20, displayOptions: { show: { - resource: [ - 'customVerificationEmail', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['customVerificationEmail'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -415,9 +360,7 @@ export class AwsSes implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'email', - ], + resource: ['email'], }, }, options: [ @@ -440,12 +383,8 @@ export class AwsSes implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'send', - ], + resource: ['email'], + operation: ['send'], }, }, default: false, @@ -457,12 +396,8 @@ export class AwsSes implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'send', - ], + resource: ['email'], + operation: ['send'], }, }, default: '', @@ -477,12 +412,8 @@ export class AwsSes implements INodeType { }, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'send', - ], + resource: ['email'], + operation: ['send'], }, }, default: '', @@ -495,12 +426,8 @@ export class AwsSes implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'send', - ], + resource: ['email'], + operation: ['send'], }, }, required: true, @@ -519,12 +446,8 @@ export class AwsSes implements INodeType { }, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'send', - ], + resource: ['email'], + operation: ['send'], }, }, placeholder: 'info@example.com', @@ -539,16 +462,13 @@ export class AwsSes implements INodeType { }, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'sendTemplate', - ], + resource: ['email'], + operation: ['sendTemplate'], }, }, default: '', - description: 'The ARN of the template to use when sending this email. Choose from the list, or specify an ID using an expression.', + description: + 'The ARN of the template to use when sending this email. Choose from the list, or specify an ID using an expression.', }, { displayName: 'From Email', @@ -556,12 +476,8 @@ export class AwsSes implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'sendTemplate', - ], + resource: ['email'], + operation: ['sendTemplate'], }, }, required: true, @@ -580,12 +496,8 @@ export class AwsSes implements INodeType { }, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'sendTemplate', - ], + resource: ['email'], + operation: ['sendTemplate'], }, }, placeholder: 'info@example.com', @@ -601,12 +513,8 @@ export class AwsSes implements INodeType { }, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'sendTemplate', - ], + resource: ['email'], + operation: ['sendTemplate'], }, }, default: {}, @@ -639,13 +547,8 @@ export class AwsSes implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'email', - ], - operation: [ - 'send', - 'sendTemplate', - ], + resource: ['email'], + operation: ['send', 'sendTemplate'], }, }, options: [ @@ -694,7 +597,8 @@ export class AwsSes implements INodeType { displayName: 'Return Path', name: 'returnPath', type: 'string', - description: 'Email address that bounces and complaints will be forwarded to when feedback forwarding is enabled', + description: + 'Email address that bounces and complaints will be forwarded to when feedback forwarding is enabled', default: '', }, { @@ -720,9 +624,7 @@ export class AwsSes implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'template', - ], + resource: ['template'], }, }, options: [ @@ -765,15 +667,8 @@ export class AwsSes implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'template', - ], - operation: [ - 'update', - 'create', - 'get', - 'delete', - ], + resource: ['template'], + operation: ['update', 'create', 'get', 'delete'], }, }, required: true, @@ -786,12 +681,8 @@ export class AwsSes implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'template', - ], - operation: [ - 'create', - ], + resource: ['template'], + operation: ['create'], }, }, description: 'The subject line of the email', @@ -803,12 +694,8 @@ export class AwsSes implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'template', - ], - operation: [ - 'create', - ], + resource: ['template'], + operation: ['create'], }, }, description: 'The HTML body of the email', @@ -822,12 +709,8 @@ export class AwsSes implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'template', - ], - operation: [ - 'create', - ], + resource: ['template'], + operation: ['create'], }, }, options: [ @@ -835,7 +718,8 @@ export class AwsSes implements INodeType { displayName: 'Text Part', name: 'textPart', type: 'string', - description: 'The email body that will be visible to recipients whose email clients do not display HTML', + description: + 'The email body that will be visible to recipients whose email clients do not display HTML', default: '', }, ], @@ -848,12 +732,8 @@ export class AwsSes implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'template', - ], - operation: [ - 'update', - ], + resource: ['template'], + operation: ['update'], }, }, options: [ @@ -861,7 +741,8 @@ export class AwsSes implements INodeType { displayName: 'Text Part', name: 'textPart', type: 'string', - description: 'The email body that will be visible to recipients whose email clients do not display HTML', + description: + 'The email body that will be visible to recipients whose email clients do not display HTML', default: '', }, { @@ -886,12 +767,8 @@ export class AwsSes implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'template', - ], - operation: [ - 'getAll', - ], + resource: ['template'], + operation: ['getAll'], }, }, default: false, @@ -908,15 +785,9 @@ export class AwsSes implements INodeType { default: 20, displayOptions: { show: { - resource: [ - 'template', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['template'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -930,7 +801,13 @@ export class AwsSes implements INodeType { async getTemplates(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const templates = await awsApiRequestSOAPAllItems.call(this, 'ListTemplatesResponse.ListTemplatesResult.TemplatesMetadata.member', 'email', 'POST', '/?Action=ListTemplates'); + const templates = await awsApiRequestSOAPAllItems.call( + this, + 'ListTemplatesResponse.ListTemplatesResult.TemplatesMetadata.member', + 'email', + 'POST', + '/?Action=ListTemplates', + ); for (const template of templates) { const templateName = template.Name; @@ -957,14 +834,18 @@ export class AwsSes implements INodeType { for (let i = 0; i < items.length; i++) { try { if (resource === 'customVerificationEmail') { - if (operation === 'create') { - - const failureRedirectionURL = this.getNodeParameter('failureRedirectionURL', i) as string; + const failureRedirectionURL = this.getNodeParameter( + 'failureRedirectionURL', + i, + ) as string; const email = this.getNodeParameter('fromEmailAddress', i) as string; - const successRedirectionURL = this.getNodeParameter('successRedirectionURL', i) as string; + const successRedirectionURL = this.getNodeParameter( + 'successRedirectionURL', + i, + ) as string; const templateContent = this.getNodeParameter('templateContent', i) as string; @@ -982,13 +863,18 @@ export class AwsSes implements INodeType { `TemplateSubject=${templateSubject}`, ]; - responseData = await awsApiRequestSOAP.call(this, 'email', 'POST', '', params.join('&')); + responseData = await awsApiRequestSOAP.call( + this, + 'email', + 'POST', + '', + params.join('&'), + ); responseData = responseData.CreateCustomVerificationEmailTemplateResponse; } if (operation === 'delete') { - const templateName = this.getNodeParameter('templateName', i) as string; const params = [ @@ -996,42 +882,61 @@ export class AwsSes implements INodeType { `TemplateName=${templateName}`, ]; - responseData = await awsApiRequestSOAP.call(this, 'email', 'POST', '', params.join('&')); + responseData = await awsApiRequestSOAP.call( + this, + 'email', + 'POST', + '', + params.join('&'), + ); responseData = responseData.DeleteCustomVerificationEmailTemplateResponse; } if (operation === 'get') { - const templateName = this.getNodeParameter('templateName', i) as string; - const params = [ - `TemplateName=${templateName}`, - ]; + const params = [`TemplateName=${templateName}`]; - responseData = await awsApiRequestSOAP.call(this, 'email', 'POST', '/?Action=GetCustomVerificationEmailTemplate&' + params.join('&')); + responseData = await awsApiRequestSOAP.call( + this, + 'email', + 'POST', + '/?Action=GetCustomVerificationEmailTemplate&' + params.join('&'), + ); responseData = responseData.GetCustomVerificationEmailTemplateResponse; } if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll === true) { - responseData = await awsApiRequestSOAPAllItems.call(this, 'ListCustomVerificationEmailTemplatesResponse.ListCustomVerificationEmailTemplatesResult.CustomVerificationEmailTemplates.member', 'email', 'POST', '/?Action=ListCustomVerificationEmailTemplates'); - + responseData = await awsApiRequestSOAPAllItems.call( + this, + 'ListCustomVerificationEmailTemplatesResponse.ListCustomVerificationEmailTemplatesResult.CustomVerificationEmailTemplates.member', + 'email', + 'POST', + '/?Action=ListCustomVerificationEmailTemplates', + ); } else { const limit = this.getNodeParameter('limit', i) as number; - responseData = await awsApiRequestSOAP.call(this, 'email', 'GET', `/?Action=ListCustomVerificationEmailTemplates&MaxResults=${limit}`); - - responseData = responseData.ListCustomVerificationEmailTemplatesResponse.ListCustomVerificationEmailTemplatesResult.CustomVerificationEmailTemplates.member; + responseData = await awsApiRequestSOAP.call( + this, + 'email', + 'GET', + `/?Action=ListCustomVerificationEmailTemplates&MaxResults=${limit}`, + ); + + responseData = + responseData.ListCustomVerificationEmailTemplatesResponse + .ListCustomVerificationEmailTemplatesResult.CustomVerificationEmailTemplates + .member; } } if (operation === 'send') { - const email = this.getNodeParameter('email', i) as string[]; const templateName = this.getNodeParameter('templateName', i) as string; @@ -1048,13 +953,18 @@ export class AwsSes implements INodeType { params.push(`ConfigurationSetName=${additionalFields.configurationSetName}`); } - responseData = await awsApiRequestSOAP.call(this, 'email', 'POST', '', params.join('&')); + responseData = await awsApiRequestSOAP.call( + this, + 'email', + 'POST', + '', + params.join('&'), + ); responseData = responseData.SendCustomVerificationEmailResponse; } if (operation === 'update') { - const templateName = this.getNodeParameter('templateName', i) as string; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; @@ -1084,16 +994,20 @@ export class AwsSes implements INodeType { params.push(`TemplateSubject=${updateFields.templateSubject}`); } - responseData = await awsApiRequestSOAP.call(this, 'email', 'POST', '', params.join('&')); + responseData = await awsApiRequestSOAP.call( + this, + 'email', + 'POST', + '', + params.join('&'), + ); responseData = responseData.UpdateCustomVerificationEmailTemplateResponse; } } if (resource === 'email') { - if (operation === 'send') { - const toAddresses = this.getNodeParameter('toAddresses', i) as string[]; const message = this.getNodeParameter('body', i) as string; @@ -1106,10 +1020,7 @@ export class AwsSes implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - const params = [ - `Message.Subject.Data=${subject}`, - `Source=${fromEmail}`, - ]; + const params = [`Message.Subject.Data=${subject}`, `Source=${fromEmail}`]; if (isBodyHtml) { params.push(`Message.Body.Html.Data=${encodeURIComponent(message)}`); @@ -1121,7 +1032,11 @@ export class AwsSes implements INodeType { if (toAddresses.length) { setParameter(params, 'Destination.ToAddresses.member', toAddresses); } else { - throw new NodeOperationError(this.getNode(), 'At least one "To Address" has to be added!', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'At least one "To Address" has to be added!', + { itemIndex: i }, + ); } if (additionalFields.configurationSetName) { @@ -1141,21 +1056,37 @@ export class AwsSes implements INodeType { } if (additionalFields.replyToAddresses) { - setParameter(params, 'ReplyToAddresses.member', additionalFields.replyToAddresses as string[]); + setParameter( + params, + 'ReplyToAddresses.member', + additionalFields.replyToAddresses as string[], + ); } if (additionalFields.bccAddresses) { - setParameter(params, 'Destination.BccAddresses.member', additionalFields.bccAddresses as string[]); + setParameter( + params, + 'Destination.BccAddresses.member', + additionalFields.bccAddresses as string[], + ); } if (additionalFields.ccAddresses) { - setParameter(params, 'Destination.CcAddresses.member', additionalFields.ccAddresses as string[]); + setParameter( + params, + 'Destination.CcAddresses.member', + additionalFields.ccAddresses as string[], + ); } - responseData = await awsApiRequestSOAP.call(this, 'email', 'POST', '/?Action=SendEmail&' + params.join('&')); + responseData = await awsApiRequestSOAP.call( + this, + 'email', + 'POST', + '/?Action=SendEmail&' + params.join('&'), + ); } if (operation === 'sendTemplate') { - const toAddresses = this.getNodeParameter('toAddresses', i) as string[]; const template = this.getNodeParameter('templateName', i) as string; @@ -1166,15 +1097,16 @@ export class AwsSes implements INodeType { const templateDataUi = this.getNodeParameter('templateDataUi', i) as IDataObject; - const params = [ - `Template=${template}`, - `Source=${fromEmail}`, - ]; + const params = [`Template=${template}`, `Source=${fromEmail}`]; if (toAddresses.length) { setParameter(params, 'Destination.ToAddresses.member', toAddresses); } else { - throw new NodeOperationError(this.getNode(), 'At least one "To Address" has to be added!', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'At least one "To Address" has to be added!', + { itemIndex: i }, + ); } if (additionalFields.configurationSetName) { @@ -1194,19 +1126,32 @@ export class AwsSes implements INodeType { } if (additionalFields.replyToAddresses) { - setParameter(params, 'ReplyToAddresses.member', additionalFields.replyToAddresses as string[]); + setParameter( + params, + 'ReplyToAddresses.member', + additionalFields.replyToAddresses as string[], + ); } if (additionalFields.bccAddresses) { - setParameter(params, 'Destination.BccAddresses.member', additionalFields.bccAddresses as string[]); + setParameter( + params, + 'Destination.BccAddresses.member', + additionalFields.bccAddresses as string[], + ); } if (additionalFields.ccAddresses) { - setParameter(params, 'Destination.CcAddresses.member', additionalFields.ccAddresses as string[]); + setParameter( + params, + 'Destination.CcAddresses.member', + additionalFields.ccAddresses as string[], + ); } if (templateDataUi) { - const templateDataValues = (templateDataUi as IDataObject).templateDataValues as IDataObject[]; + const templateDataValues = (templateDataUi as IDataObject) + .templateDataValues as IDataObject[]; const templateData: IDataObject = {}; if (templateDataValues !== undefined) { for (const templateDataValue of templateDataValues) { @@ -1217,16 +1162,19 @@ export class AwsSes implements INodeType { } } - responseData = await awsApiRequestSOAP.call(this, 'email', 'POST', '/?Action=SendTemplatedEmail&' + params.join('&')); + responseData = await awsApiRequestSOAP.call( + this, + 'email', + 'POST', + '/?Action=SendTemplatedEmail&' + params.join('&'), + ); responseData = responseData.SendTemplatedEmailResponse; } } if (resource === 'template') { - if (operation === 'create') { - const templateName = this.getNodeParameter('templateName', i) as string; const subjectPart = this.getNodeParameter('subjectPart', i) as string; @@ -1245,62 +1193,78 @@ export class AwsSes implements INodeType { params.push(`Template.TextPart=${additionalFields.textPart}`); } - responseData = await awsApiRequestSOAP.call(this, 'email', 'POST', '/?Action=CreateTemplate&' + params.join('&')); + responseData = await awsApiRequestSOAP.call( + this, + 'email', + 'POST', + '/?Action=CreateTemplate&' + params.join('&'), + ); responseData = responseData.CreateTemplateResponse; } if (operation === 'delete') { - const templateName = this.getNodeParameter('templateName', i) as string; - const params = [ - `TemplateName=${templateName}`, - ]; + const params = [`TemplateName=${templateName}`]; - responseData = await awsApiRequestSOAP.call(this, 'email', 'POST', '/?Action=DeleteTemplate&' + params.join('&')); + responseData = await awsApiRequestSOAP.call( + this, + 'email', + 'POST', + '/?Action=DeleteTemplate&' + params.join('&'), + ); responseData = responseData.DeleteTemplateResponse; } if (operation === 'get') { - const templateName = this.getNodeParameter('templateName', i) as string; - const params = [ - `TemplateName=${templateName}`, - ]; + const params = [`TemplateName=${templateName}`]; - responseData = await awsApiRequestSOAP.call(this, 'email', 'POST', '/?Action=GetTemplate&' + params.join('&')); + responseData = await awsApiRequestSOAP.call( + this, + 'email', + 'POST', + '/?Action=GetTemplate&' + params.join('&'), + ); responseData = responseData.GetTemplateResponse; } if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll === true) { - responseData = await awsApiRequestSOAPAllItems.call(this, 'ListTemplatesResponse.ListTemplatesResult.TemplatesMetadata.member', 'email', 'POST', '/?Action=ListTemplates'); - + responseData = await awsApiRequestSOAPAllItems.call( + this, + 'ListTemplatesResponse.ListTemplatesResult.TemplatesMetadata.member', + 'email', + 'POST', + '/?Action=ListTemplates', + ); } else { const limit = this.getNodeParameter('limit', i) as number; - responseData = await awsApiRequestSOAP.call(this, 'email', 'GET', `/?Action=ListTemplates&MaxItems=${limit}`); + responseData = await awsApiRequestSOAP.call( + this, + 'email', + 'GET', + `/?Action=ListTemplates&MaxItems=${limit}`, + ); - responseData = responseData.ListTemplatesResponse.ListTemplatesResult.TemplatesMetadata.member; + responseData = + responseData.ListTemplatesResponse.ListTemplatesResult.TemplatesMetadata.member; } } if (operation === 'update') { - const templateName = this.getNodeParameter('templateName', i) as string; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - const params = [ - `Template.TemplateName=${templateName}`, - ]; + const params = [`Template.TemplateName=${templateName}`]; if (updateFields.textPart) { params.push(`Template.TextPart=${updateFields.textPart}`); @@ -1314,7 +1278,12 @@ export class AwsSes implements INodeType { params.push(`Template.HtmlPart=${updateFields.htmlPart}`); } - responseData = await awsApiRequestSOAP.call(this, 'email', 'POST', '/?Action=UpdateTemplate&' + params.join('&')); + responseData = await awsApiRequestSOAP.call( + this, + 'email', + 'POST', + '/?Action=UpdateTemplate&' + params.join('&'), + ); responseData = responseData.UpdateTemplateResponse; } diff --git a/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts index 09adde5ead19e..1e4ae868d81da 100644 --- a/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts @@ -1,19 +1,10 @@ -import { - URL, -} from 'url'; +import { URL } from 'url'; -import { - Request, - sign, -} from 'aws4'; +import { Request, sign } from 'aws4'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - parseString, -} from 'xml2js'; +import { parseString } from 'xml2js'; import { IExecuteFunctions, @@ -22,18 +13,27 @@ import { IWebhookFunctions, } 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 awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise { // tslint:disable-line:no-any +export async function awsApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + service: string, + method: string, + path: string, + body?: string, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('aws'); - const endpoint = new URL(((credentials.sesEndpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path); + const endpoint = new URL( + (((credentials.sesEndpoint as string) || '').replace( + '{region}', + credentials.region as string, + ) || `https://${service}.${credentials.region}.amazonaws.com`) + path, + ); // Sign AWS API request with the user credentials @@ -41,7 +41,9 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I 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); @@ -60,7 +62,15 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I } } -export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise { // tslint:disable-line:no-any +export async function awsApiRequestREST( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + service: string, + method: string, + path: string, + body?: string, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const response = await awsApiRequest.call(this, service, method, path, body, headers); try { return JSON.parse(response); @@ -69,7 +79,15 @@ export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions } } -export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise { // tslint:disable-line:no-any +export async function awsApiRequestSOAP( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + service: string, + method: string, + path: string, + body?: string, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const response = await awsApiRequest.call(this, service, method, path, body, headers); try { return await new Promise((resolve, reject) => { @@ -85,9 +103,19 @@ export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions } } - -export async function awsApiRequestSOAPAllItems(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 awsApiRequestSOAPAllItems( + 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; @@ -98,7 +126,10 @@ export async function awsApiRequestSOAPAllItems(this: IHookFunctions | IExecuteF responseData = await awsApiRequestSOAP.call(this, service, method, path, body, query); if (get(responseData, `${propertyNameArray[0]}.${propertyNameArray[1]}.NextToken`)) { - query['NextToken'] = get(responseData, `${propertyNameArray[0]}.${propertyNameArray[1]}.NextToken`); + query['NextToken'] = get( + responseData, + `${propertyNameArray[0]}.${propertyNameArray[1]}.NextToken`, + ); } if (get(responseData, propertyName)) { if (Array.isArray(get(responseData, propertyName))) { diff --git a/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts b/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts index e071af2404308..546d36d298e7b 100644 --- a/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts +++ b/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -14,17 +12,11 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - URL, -} from 'url'; +import { URL } from 'url'; -import { - awsApiRequestSOAP, -} from '../GenericFunctions'; +import { awsApiRequestSOAP } from '../GenericFunctions'; -import { - pascalCase, -} from 'change-case'; +import { pascalCase } from 'change-case'; export class AwsSqs implements INodeType { description: INodeTypeDescription = { @@ -71,15 +63,14 @@ export class AwsSqs implements INodeType { }, displayOptions: { show: { - operation: [ - 'sendMessage', - ], + operation: ['sendMessage'], }, }, options: [], default: '', required: true, - description: 'Queue to send a message to. Choose from the list, or specify an ID using an expression.', + description: + 'Queue to send a message to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Queue Type', @@ -112,12 +103,8 @@ export class AwsSqs implements INodeType { type: 'string', displayOptions: { show: { - operation: [ - 'sendMessage', - ], - sendInputData: [ - false, - ], + operation: ['sendMessage'], + sendInputData: [false], }, }, required: true, @@ -132,12 +119,11 @@ export class AwsSqs implements INodeType { name: 'messageGroupId', type: 'string', default: '', - description: 'Tag that specifies that a message belongs to a specific message group. Applies only to FIFO (first-in-first-out) queues.', + description: + 'Tag that specifies that a message belongs to a specific message group. Applies only to FIFO (first-in-first-out) queues.', displayOptions: { show: { - queueType: [ - 'fifo', - ], + queueType: ['fifo'], }, }, required: true, @@ -148,9 +134,7 @@ export class AwsSqs implements INodeType { type: 'collection', displayOptions: { show: { - operation: [ - 'sendMessage', - ], + operation: ['sendMessage'], }, }, default: {}, @@ -162,9 +146,7 @@ export class AwsSqs implements INodeType { type: 'number', displayOptions: { show: { - '/queueType': [ - 'standard', - ], + '/queueType': ['standard'], }, }, description: 'How long, in seconds, to delay a message for', @@ -201,7 +183,8 @@ export class AwsSqs implements INodeType { name: 'dataPropertyName', type: 'string', default: 'data', - description: 'Name of the binary property which contains the data for the message attribute', + description: + 'Name of the binary property which contains the data for the message attribute', }, ], }, @@ -252,12 +235,11 @@ export class AwsSqs implements INodeType { name: 'messageDeduplicationId', type: 'string', default: '', - description: 'Token used for deduplication of sent messages. Applies only to FIFO (first-in-first-out) queues.', + description: + 'Token used for deduplication of sent messages. Applies only to FIFO (first-in-first-out) queues.', displayOptions: { show: { - '/queueType': [ - 'fifo', - ], + '/queueType': ['fifo'], }, }, }, @@ -270,10 +252,7 @@ export class AwsSqs implements INodeType { loadOptions: { // Get all the available queues to display them to user so that it can be selected easily async getQueues(this: ILoadOptionsFunctions): Promise { - const params = [ - 'Version=2012-11-05', - `Action=ListQueues`, - ]; + const params = ['Version=2012-11-05', `Action=ListQueues`]; let data; try { @@ -307,7 +286,6 @@ export class AwsSqs implements INodeType { }, }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -319,15 +297,14 @@ export class AwsSqs implements INodeType { const queueUrl = this.getNodeParameter('queue', i) as string; const queuePath = new URL(queueUrl).pathname; - const params = [ - 'Version=2012-11-05', - `Action=${pascalCase(operation)}`, - ]; + const params = ['Version=2012-11-05', `Action=${pascalCase(operation)}`]; const options = this.getNodeParameter('options', i, {}) as IDataObject; const sendInputData = this.getNodeParameter('sendInputData', i) as boolean; - const message = sendInputData ? JSON.stringify(items[i].json) : this.getNodeParameter('message', i) as string; + const message = sendInputData + ? JSON.stringify(items[i].json) + : (this.getNodeParameter('message', i) as string); params.push(`MessageBody=${message}`); if (options.delaySeconds) { @@ -336,7 +313,11 @@ export class AwsSqs implements INodeType { const queueType = this.getNodeParameter('queueType', i, {}) as string; if (queueType === 'fifo') { - const messageDeduplicationId = this.getNodeParameter('options.messageDeduplicationId', i, '') as string; + const messageDeduplicationId = this.getNodeParameter( + 'options.messageDeduplicationId', + i, + '', + ) as string; if (messageDeduplicationId) { params.push(`MessageDeduplicationId=${messageDeduplicationId}`); } @@ -349,7 +330,9 @@ export class AwsSqs implements INodeType { let attributeCount = 0; // Add string values - (this.getNodeParameter('options.messageAttributes.string', i, []) as INodeParameters[]).forEach((attribute) => { + ( + this.getNodeParameter('options.messageAttributes.string', i, []) as INodeParameters[] + ).forEach((attribute) => { attributeCount++; params.push(`MessageAttribute.${attributeCount}.Name=${attribute.name}`); params.push(`MessageAttribute.${attributeCount}.Value.StringValue=${attribute.value}`); @@ -357,17 +340,27 @@ export class AwsSqs implements INodeType { }); // Add binary values - (this.getNodeParameter('options.messageAttributes.binary', i, []) as INodeParameters[]).forEach((attribute) => { + ( + this.getNodeParameter('options.messageAttributes.binary', i, []) as INodeParameters[] + ).forEach((attribute) => { attributeCount++; const dataPropertyName = attribute.dataPropertyName as string; const item = items[i]; if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data set. So message attribute cannot be added!', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'No binary data set. So message attribute cannot be added!', + { itemIndex: i }, + ); } if (item.binary[dataPropertyName] === undefined) { - throw new NodeOperationError(this.getNode(), `The binary property "${dataPropertyName}" does not exist. So message attribute cannot be added!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The binary property "${dataPropertyName}" does not exist. So message attribute cannot be added!`, + { itemIndex: i }, + ); } const binaryData = item.binary[dataPropertyName].data; @@ -378,7 +371,9 @@ export class AwsSqs implements INodeType { }); // Add number values - (this.getNodeParameter('options.messageAttributes.number', i, []) as INodeParameters[]).forEach((attribute) => { + ( + this.getNodeParameter('options.messageAttributes.number', i, []) as INodeParameters[] + ).forEach((attribute) => { attributeCount++; params.push(`MessageAttribute.${attributeCount}.Name=${attribute.name}`); params.push(`MessageAttribute.${attributeCount}.Value.StringValue=${attribute.value}`); @@ -387,7 +382,12 @@ export class AwsSqs implements INodeType { let responseData; try { - responseData = await awsApiRequestSOAP.call(this, 'sqs', 'GET', `${queuePath}?${params.join('&')}`); + responseData = await awsApiRequestSOAP.call( + this, + 'sqs', + 'GET', + `${queuePath}?${params.join('&')}`, + ); } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Aws/Textract/AwsTextract.node.ts b/packages/nodes-base/nodes/Aws/Textract/AwsTextract.node.ts index cd094e881df3f..7ae96adc35502 100644 --- a/packages/nodes-base/nodes/Aws/Textract/AwsTextract.node.ts +++ b/packages/nodes-base/nodes/Aws/Textract/AwsTextract.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryKeyData, @@ -64,13 +62,12 @@ export class AwsTextract implements INodeType { default: 'data', displayOptions: { show: { - operation: [ - 'analyzeExpense', - ], + operation: ['analyzeExpense'], }, }, required: true, - description: 'The name of the input field containing the binary file data to be uploaded. Supported file types: PNG, JPEG.', + description: + 'The name of the input field containing the binary file data to be uploaded. Supported file types: PNG, JPEG.', }, { displayName: 'Simplify', @@ -78,22 +75,28 @@ export class AwsTextract implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'analyzeExpense', - ], + operation: ['analyzeExpense'], }, }, 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', }, ], }; methods = { credentialTest: { - async awsTextractApiCredentialTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { + async awsTextractApiCredentialTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { try { - await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject, 'sts'); + await validateCredentials.call( + this, + credential.data as ICredentialDataDecryptedObject, + 'sts', + ); } catch (error) { return { status: 'Error', @@ -122,11 +125,17 @@ export class AwsTextract implements INodeType { const simple = this.getNodeParameter('simple', 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, + }); } if ((items[i].binary as IBinaryKeyData)[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 binaryPropertyData = (items[i].binary as IBinaryKeyData)[binaryProperty]; @@ -138,7 +147,14 @@ export class AwsTextract implements INodeType { }; const action = 'Textract.AnalyzeExpense'; - responseData = await awsApiRequestREST.call(this, 'textract', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }) as IExpenseDocument; + responseData = (await awsApiRequestREST.call( + this, + 'textract', + 'POST', + '', + JSON.stringify(body), + { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }, + )) as IExpenseDocument; if (simple) { responseData = simplify(responseData); } diff --git a/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts index a78f1436de095..4175593e0e43f 100644 --- a/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts @@ -1,19 +1,10 @@ -import { - URL, -} from 'url'; +import { URL } from 'url'; -import { - Request, - sign, -} from 'aws4'; +import { Request, sign } from 'aws4'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - parseString, -} from 'xml2js'; +import { parseString } from 'xml2js'; import { IExecuteFunctions, @@ -29,7 +20,10 @@ import { NodeOperationError, } from 'n8n-workflow'; -function getEndpointForService(service: string, credentials: ICredentialDataDecryptedObject): string { +function getEndpointForService( + service: string, + credentials: ICredentialDataDecryptedObject, +): string { let endpoint; if (service === 'lambda' && credentials.lambdaEndpoint) { endpoint = credentials.lambdaEndpoint; @@ -41,7 +35,15 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr return (endpoint as string).replace('{region}', credentials.region as string); } -export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise { // tslint:disable-line:no-any +export async function awsApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + service: string, + method: string, + path: string, + body?: string, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('aws'); // Concatenate path and instantiate URL object so it parses correctly query strings @@ -52,7 +54,9 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I 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); @@ -73,7 +77,8 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I const user = JSON.parse(errorMessage).Message.split(' ')[1]; throw new NodeApiError(this.getNode(), error, { message: 'Unauthorized — please check your AWS policy configuration', - description: `Make sure an identity-based policy allows user ${user} to perform textract:AnalyzeExpense` }); + description: `Make sure an identity-based policy allows user ${user} to perform textract:AnalyzeExpense`, + }); } } @@ -81,7 +86,15 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I } } -export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise { // tslint:disable-line:no-any +export async function awsApiRequestREST( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + service: string, + method: string, + path: string, + body?: string, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const response = await awsApiRequest.call(this, service, method, path, body, headers); try { return JSON.parse(response); @@ -90,7 +103,15 @@ export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions } } -export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise { // tslint:disable-line:no-any +export async function awsApiRequestSOAP( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + service: string, + method: string, + path: string, + body?: string, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const response = await awsApiRequest.call(this, service, method, path, body, headers); try { return await new Promise((resolve, reject) => { @@ -121,25 +142,40 @@ export interface IExpenseDocument { { SummaryFields: [ { - LabelDetection: { Text: string }, - ValueDetection: { Text: string }, - Type: { Text: string } - }] - }]; + LabelDetection: { Text: string }; + ValueDetection: { Text: string }; + Type: { Text: string }; + }, + ]; + }, + ]; } -export async function validateCredentials(this: ICredentialTestFunctions, decryptedCredentials: ICredentialDataDecryptedObject, service: string): Promise { // tslint:disable-line:no-any +export async function validateCredentials( + this: ICredentialTestFunctions, + decryptedCredentials: ICredentialDataDecryptedObject, + service: string, + // tslint:disable-next-line:no-any +): Promise { const credentials = decryptedCredentials; // Concatenate path and instantiate URL object so it parses correctly query strings - const endpoint = new URL(getEndpointForService(service, credentials) + `?Action=GetCallerIdentity&Version=2011-06-15`); + const endpoint = new URL( + getEndpointForService(service, credentials) + `?Action=GetCallerIdentity&Version=2011-06-15`, + ); // Sign AWS API request with the user credentials - const signOpts = { host: endpoint.host, method: 'POST', path: '?Action=GetCallerIdentity&Version=2011-06-15' } as Request; + const signOpts = { + host: endpoint.host, + method: 'POST', + path: '?Action=GetCallerIdentity&Version=2011-06-15', + } as Request; 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); diff --git a/packages/nodes-base/nodes/Aws/Transcribe/AwsTranscribe.node.ts b/packages/nodes-base/nodes/Aws/Transcribe/AwsTranscribe.node.ts index 984b258c19c79..90cf571a2f60a 100644 --- a/packages/nodes-base/nodes/Aws/Transcribe/AwsTranscribe.node.ts +++ b/packages/nodes-base/nodes/Aws/Transcribe/AwsTranscribe.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 { - awsApiRequestREST, - awsApiRequestRESTAllItems, -} from './GenericFunctions'; +import { awsApiRequestREST, awsApiRequestRESTAllItems } from './GenericFunctions'; export class AwsTranscribe implements INodeType { description: INodeTypeDescription = { @@ -88,14 +78,8 @@ export class AwsTranscribe implements INodeType { default: '', displayOptions: { show: { - resource: [ - 'transcriptionJob', - ], - operation: [ - 'create', - 'get', - 'delete', - ], + resource: ['transcriptionJob'], + operation: ['create', 'get', 'delete'], }, }, description: 'The name of the job', @@ -107,12 +91,8 @@ export class AwsTranscribe implements INodeType { default: '', displayOptions: { show: { - resource: [ - 'transcriptionJob', - ], - operation: [ - 'create', - ], + resource: ['transcriptionJob'], + operation: ['create'], }, }, description: 'The S3 object location of the input media file', @@ -123,16 +103,13 @@ export class AwsTranscribe implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'transcriptionJob', - ], - operation: [ - 'create', - ], + resource: ['transcriptionJob'], + operation: ['create'], }, }, default: false, - description: 'Whether to set this field to true to enable automatic language identification', + description: + 'Whether to set this field to true to enable automatic language identification', }, { displayName: 'Language', @@ -170,15 +147,9 @@ export class AwsTranscribe implements INodeType { ], displayOptions: { show: { - resource: [ - 'transcriptionJob', - ], - operation: [ - 'create', - ], - detectLanguage: [ - false, - ], + resource: ['transcriptionJob'], + operation: ['create'], + detectLanguage: [false], }, }, default: 'en-US', @@ -194,9 +165,7 @@ export class AwsTranscribe implements INodeType { placeholder: 'Add Option', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], }, }, default: {}, @@ -207,7 +176,8 @@ export class AwsTranscribe implements INodeType { type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'Instructs Amazon Transcribe to process each audiochannel separately and then merge the transcription output of each channel into a single transcription. You can\'t set both Max Speaker Labels and Channel Identification in the same request. If you set both, your request returns a BadRequestException.', + description: + "Instructs Amazon Transcribe to process each audiochannel separately and then merge the transcription output of each channel into a single transcription. You can't set both Max Speaker Labels and Channel Identification in the same request. If you set both, your request returns a BadRequestException.", }, { displayName: 'Max Alternatives', @@ -229,7 +199,8 @@ export class AwsTranscribe implements INodeType { minValue: 2, maxValue: 10, }, - description: 'The maximum number of speakers to identify in the input audio. If there are more speakers in the audio than this number, multiple speakers are identified as a single speaker.', + description: + 'The maximum number of speakers to identify in the input audio. If there are more speakers in the audio than this number, multiple speakers are identified as a single speaker.', }, { displayName: 'Vocabulary Name', @@ -243,7 +214,8 @@ export class AwsTranscribe implements INodeType { name: 'vocabularyFilterName', type: 'string', default: '', - description: 'The name of the vocabulary filter to use when transcribing the audio. The filter that you specify must have the same language code as the transcription job.', + description: + 'The name of the vocabulary filter to use when transcribing the audio. The filter that you specify must have the same language code as the transcription job.', }, { displayName: 'Vocabulary Filter Method', @@ -262,10 +234,10 @@ export class AwsTranscribe implements INodeType { name: 'Tag', value: 'tag', }, - ], default: 'remove', - description: '

Set to mask to remove filtered text from the transcript and replace it with three asterisks ("***") as placeholder text.

Set to remove to remove filtered text from the transcript without using placeholder text. Set to tag to mark the word in the transcription output that matches the vocabulary filter. When you set the filter method to tag, the words matching your vocabulary filter are not masked or removed.

', + description: + '

Set to mask to remove filtered text from the transcript and replace it with three asterisks ("***") as placeholder text.

Set to remove to remove filtered text from the transcript without using placeholder text. Set to tag to mark the word in the transcription output that matches the vocabulary filter. When you set the filter method to tag, the words matching your vocabulary filter are not masked or removed.

', }, ], }, @@ -276,16 +248,13 @@ export class AwsTranscribe implements INodeType { default: true, displayOptions: { show: { - resource: [ - 'transcriptionJob', - ], - operation: [ - 'get', - ], + resource: ['transcriptionJob'], + operation: ['get'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default, the response only contains metadata about the transcript. Enable this option to retrieve the transcript instead.', + description: + 'By default, the response only contains metadata about the transcript. Enable this option to retrieve the transcript instead.', }, { displayName: 'Simplify', @@ -293,19 +262,14 @@ export class AwsTranscribe implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'transcriptionJob', - ], - operation: [ - 'get', - ], - returnTranscript: [ - true, - ], + resource: ['transcriptionJob'], + operation: ['get'], + returnTranscript: [true], }, }, 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', }, { displayName: 'Return All', @@ -313,12 +277,8 @@ export class AwsTranscribe implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'transcriptionJob', - ], - operation: [ - 'getAll', - ], + resource: ['transcriptionJob'], + operation: ['getAll'], }, }, default: false, @@ -334,15 +294,9 @@ export class AwsTranscribe implements INodeType { }, displayOptions: { show: { - resource: [ - 'transcriptionJob', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['transcriptionJob'], + operation: ['getAll'], + returnAll: [false], }, }, description: 'Max number of results to return', @@ -355,12 +309,8 @@ export class AwsTranscribe implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'transcriptionJob', - ], - operation: [ - 'getAll', - ], + resource: ['transcriptionJob'], + operation: ['getAll'], }, }, options: [ @@ -433,7 +383,9 @@ export class AwsTranscribe implements INodeType { } if (options.channelIdentification) { - Object.assign(body.Settings, { ChannelIdentification: options.channelIdentification }); + Object.assign(body.Settings, { + ChannelIdentification: options.channelIdentification, + }); } if (options.maxAlternatives) { @@ -469,7 +421,14 @@ export class AwsTranscribe implements INodeType { } const action = 'Transcribe.StartTranscriptionJob'; - responseData = await awsApiRequestREST.call(this, 'transcribe', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }); + responseData = await awsApiRequestREST.call( + this, + 'transcribe', + 'POST', + '', + JSON.stringify(body), + { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }, + ); responseData = responseData.TranscriptionJob; } //https://docs.aws.amazon.com/transcribe/latest/dg/API_DeleteTranscriptionJob.html @@ -481,7 +440,14 @@ export class AwsTranscribe implements INodeType { }; const action = 'Transcribe.DeleteTranscriptionJob'; - responseData = await awsApiRequestREST.call(this, 'transcribe', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }); + responseData = await awsApiRequestREST.call( + this, + 'transcribe', + 'POST', + '', + JSON.stringify(body), + { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }, + ); responseData = { success: true }; } //https://docs.aws.amazon.com/transcribe/latest/dg/API_GetTranscriptionJob.html @@ -494,14 +460,29 @@ export class AwsTranscribe implements INodeType { }; const action = 'Transcribe.GetTranscriptionJob'; - responseData = await awsApiRequestREST.call(this, 'transcribe', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }); + responseData = await awsApiRequestREST.call( + this, + 'transcribe', + 'POST', + '', + JSON.stringify(body), + { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }, + ); responseData = responseData.TranscriptionJob; if (resolve === true && responseData.TranscriptionJobStatus === 'COMPLETED') { - responseData = await this.helpers.request({ method: 'GET', uri: responseData.Transcript.TranscriptFileUri, json: true }); + responseData = await this.helpers.request({ + method: 'GET', + uri: responseData.Transcript.TranscriptFileUri, + json: true, + }); const simple = this.getNodeParameter('simple', 0) as boolean; if (simple === true) { - responseData = { transcript: responseData.results.transcripts.map((data: IDataObject) => data.transcript).join(' ') }; + responseData = { + transcript: responseData.results.transcripts + .map((data: IDataObject) => data.transcript) + .join(' '), + }; } } } @@ -521,12 +502,26 @@ export class AwsTranscribe implements INodeType { } if (returnAll === true) { - responseData = await awsApiRequestRESTAllItems.call(this, 'TranscriptionJobSummaries', 'transcribe', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }); - + responseData = await awsApiRequestRESTAllItems.call( + this, + 'TranscriptionJobSummaries', + 'transcribe', + 'POST', + '', + JSON.stringify(body), + { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }, + ); } else { const limit = this.getNodeParameter('limit', i) as number; body['MaxResults'] = limit; - responseData = await awsApiRequestREST.call(this, 'transcribe', 'POST', '', JSON.stringify(body), { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }); + responseData = await awsApiRequestREST.call( + this, + 'transcribe', + 'POST', + '', + JSON.stringify(body), + { 'x-amz-target': action, 'Content-Type': 'application/x-amz-json-1.1' }, + ); responseData = responseData.TranscriptionJobSummaries; } } @@ -537,7 +532,6 @@ export class AwsTranscribe 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/Aws/Transcribe/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts index 7de8078242efd..2d756b90bbd74 100644 --- a/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts @@ -1,15 +1,8 @@ -import { - URL, -} from 'url'; +import { URL } from 'url'; -import { - Request, - sign, -} from 'aws4'; +import { Request, sign } from 'aws4'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -25,11 +18,12 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - get, -} from 'lodash'; +import { get } from 'lodash'; -function getEndpointForService(service: string, credentials: ICredentialDataDecryptedObject): string { +function getEndpointForService( + service: string, + credentials: ICredentialDataDecryptedObject, +): string { let endpoint; if (service === 'lambda' && credentials.lambdaEndpoint) { endpoint = credentials.lambdaEndpoint; @@ -41,7 +35,15 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr return (endpoint as string).replace('{region}', credentials.region as string); } -export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise { // tslint:disable-line:no-any +export async function awsApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + service: string, + method: string, + path: string, + body?: string, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('aws'); // Concatenate path and instantiate URL object so it parses correctly query strings @@ -52,7 +54,9 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I 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); @@ -71,7 +75,15 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I } } -export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, method: string, path: string, body?: string, headers?: object): Promise { // tslint:disable-line:no-any +export async function awsApiRequestREST( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + service: string, + method: string, + path: string, + body?: string, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const response = await awsApiRequest.call(this, service, method, path, body, headers); try { return JSON.parse(response); @@ -80,8 +92,19 @@ export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions } } -export async function awsApiRequestRESTAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, 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 awsApiRequestRESTAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + 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; @@ -92,7 +115,10 @@ export async function awsApiRequestRESTAllItems(this: IHookFunctions | IExecuteF responseData = await awsApiRequestREST.call(this, service, method, path, body, query); if (get(responseData, `${propertyNameArray[0]}.${propertyNameArray[1]}.NextToken`)) { - query['NextToken'] = get(responseData, `${propertyNameArray[0]}.${propertyNameArray[1]}.NextToken`); + query['NextToken'] = get( + responseData, + `${propertyNameArray[0]}.${propertyNameArray[1]}.NextToken`, + ); } if (get(responseData, propertyName)) { if (Array.isArray(get(responseData, propertyName))) { diff --git a/packages/nodes-base/nodes/BambooHr/BambooHr.node.ts b/packages/nodes-base/nodes/BambooHr/BambooHr.node.ts index 6c06a5f6ab900..3c074ffc9c512 100644 --- a/packages/nodes-base/nodes/BambooHr/BambooHr.node.ts +++ b/packages/nodes-base/nodes/BambooHr/BambooHr.node.ts @@ -1,12 +1,6 @@ -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 { router } from './v1/actions/router'; import { versionDescription } from './v1/actions/versionDescription'; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/Interfaces.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/Interfaces.ts index 1e18e6596612f..eaa4e27d4f583 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/Interfaces.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/Interfaces.ts @@ -1,8 +1,4 @@ -import { - AllEntities, - Entity, - PropertiesOf, -} from 'n8n-workflow'; +import { AllEntities, Entity, PropertiesOf } from 'n8n-workflow'; type BambooHrMap = { employee: 'create' | 'get' | 'getAll' | 'update'; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/description.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/description.ts index e49949b79c056..1201871e52d72 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/description.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/description.ts @@ -8,16 +8,13 @@ export const companyReportGetDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'companyReport', - ], + operation: ['get'], + resource: ['companyReport'], }, }, default: '', - description: 'ID of the report. You can get the report number by hovering over the report name on the reports page and grabbing the ID.', + description: + 'ID of the report. You can get the report number by hovering over the report name on the reports page and grabbing the ID.', }, { displayName: 'Format', @@ -48,12 +45,8 @@ export const companyReportGetDescription: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'companyReport', - ], + operation: ['get'], + resource: ['companyReport'], }, }, default: 'JSON', @@ -68,17 +61,11 @@ export const companyReportGetDescription: INodeProperties[] = [ description: 'The name of the output field to put the binary file data in', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'companyReport', - ], + operation: ['get'], + resource: ['companyReport'], }, hide: { - format: [ - 'JSON', - ], + format: ['JSON'], }, }, }, @@ -90,12 +77,8 @@ export const companyReportGetDescription: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'companyReport', - ], + operation: ['get'], + resource: ['companyReport'], }, }, options: [ diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/execute.ts index 0a75b812f281e..49bc4e0f4bfc9 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/execute.ts @@ -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 get(this: IExecuteFunctions, index: number) { const body: IDataObject = {}; @@ -25,16 +18,26 @@ export async function get(this: IExecuteFunctions, index: number) { const endpoint = `reports/${reportId}/?format=${format}&fd=${fd}`; if (format === 'JSON') { - const responseData = await apiRequest.call(this, requestMethod, endpoint, body, {}, { resolveWithFullResponse: true }); + const responseData = await apiRequest.call( + this, + requestMethod, + endpoint, + body, + {}, + { resolveWithFullResponse: true }, + ); return this.helpers.returnJsonArray(responseData.body); } const output: string = this.getNodeParameter('output', index) as string; - const response = await apiRequest.call(this, requestMethod, endpoint, body, {} as IDataObject, - { encoding: null, json: false, resolveWithFullResponse: true }); + const response = await apiRequest.call(this, requestMethod, endpoint, body, {} as IDataObject, { + encoding: null, + json: false, + resolveWithFullResponse: true, + }); let mimeType = response.headers['content-type'] as string | undefined; - mimeType = mimeType ? mimeType.split(';').find(value => value.includes('/')) : undefined; + mimeType = mimeType ? mimeType.split(';').find((value) => value.includes('/')) : undefined; const contentDisposition = response.headers['content-disposition']; const fileNameRegex = /(?<=filename=").*\b/; const match = fileNameRegex.exec(contentDisposition); @@ -58,7 +61,11 @@ export async function get(this: IExecuteFunctions, index: number) { } newItem.binary = { - [output]: await this.helpers.prepareBinaryData(response.body as unknown as Buffer, fileName, mimeType), + [output]: await this.helpers.prepareBinaryData( + response.body as unknown as Buffer, + fileName, + mimeType, + ), }; return this.prepareOutputData(newItem as unknown as INodeExecutionData[]); diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/index.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/index.ts index c15f450dd1e96..bd99a16bdd72a 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/index.ts @@ -1,7 +1,4 @@ import { get as execute } from './execute'; import { companyReportGetDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/index.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/index.ts index 8b9e7d8dad36e..7e5a991a512aa 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/index.ts @@ -1,12 +1,8 @@ import * as get from './get'; -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -export { - get, -}; +export { get }; export const descriptions: INodeProperties[] = [ { @@ -16,9 +12,7 @@ export const descriptions: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'companyReport', - ], + resource: ['companyReport'], }, }, options: [ diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/create/description.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/create/description.ts index 36eafa765ec12..fa2490e20f7ec 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/create/description.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/create/description.ts @@ -1,10 +1,6 @@ -import { - EmployeeProperties, -} from '../../Interfaces'; +import { EmployeeProperties } from '../../Interfaces'; -import { - createEmployeeSharedDescription, -} from './shareDescription'; +import { createEmployeeSharedDescription } from './shareDescription'; export const employeeCreateDescription: EmployeeProperties = [ { @@ -14,16 +10,13 @@ export const employeeCreateDescription: EmployeeProperties = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'employee', - ], + operation: ['create'], + resource: ['employee'], }, }, default: false, - description: 'Whether the employee to create was added to a pay schedule synced with Trax Payroll', + description: + 'Whether the employee to create was added to a pay schedule synced with Trax Payroll', }, { displayName: 'First Name', @@ -32,12 +25,8 @@ export const employeeCreateDescription: EmployeeProperties = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'employee', - ], + operation: ['create'], + resource: ['employee'], }, }, default: '', @@ -49,12 +38,8 @@ export const employeeCreateDescription: EmployeeProperties = [ required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'employee', - ], + operation: ['create'], + resource: ['employee'], }, }, default: '', @@ -68,12 +53,8 @@ export const employeeCreateDescription: EmployeeProperties = [ default: {}, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'employee', - ], + operation: ['create'], + resource: ['employee'], }, }, options: [ @@ -92,4 +73,4 @@ export const employeeCreateDescription: EmployeeProperties = [ }, ], }, -]; \ No newline at end of file +]; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/create/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/create/execute.ts index fb990bcd32f7a..3656f3d9b872f 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/create/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/create/execute.ts @@ -1,23 +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'; import moment from 'moment'; -import { - capitalCase -} from 'change-case'; +import { capitalCase } from 'change-case'; -export async function create(this: IExecuteFunctions, index: number): Promise { +export async function create( + this: IExecuteFunctions, + index: number, +): Promise { const body: IDataObject = {}; const requestMethod = 'POST'; const endpoint = 'employees'; @@ -30,8 +24,12 @@ export async function create(this: IExecuteFunctions, index: number): Promise { let elements: INodeProperties[] = [ @@ -66,7 +64,8 @@ export const createEmployeeSharedDescription = (sync = false): INodeProperties[] displayName: 'Department Name or ID', name: 'department', type: 'options', - 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: 'getDepartments', }, @@ -76,7 +75,8 @@ export const createEmployeeSharedDescription = (sync = false): INodeProperties[] displayName: 'Division Name or ID', name: 'division', type: 'options', - 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: 'getDivisions', }, @@ -130,7 +130,8 @@ export const createEmployeeSharedDescription = (sync = false): INodeProperties[] displayName: 'Location Name or ID', name: 'location', type: 'options', - 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: 'getEmployeeLocations', }, @@ -293,19 +294,13 @@ export const createEmployeeSharedDescription = (sync = false): INodeProperties[] ]; if (sync === true) { - elements = elements.map(element => { + elements = elements.map((element) => { return Object.assign(element, { displayOptions: { show: { - resource: [ - 'employee', - ], - operation: [ - 'create', - ], - synced: [ - true, - ], + resource: ['employee'], + operation: ['create'], + synced: [true], }, }, required: true, @@ -313,13 +308,11 @@ export const createEmployeeSharedDescription = (sync = false): INodeProperties[] }); return elements; } else { - elements = elements.map(element => { + elements = elements.map((element) => { return Object.assign(element, { displayOptions: { show: { - '/synced': [ - false, - ], + '/synced': [false], }, }, }); diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/description.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/description.ts index d3d3ceb37e549..505b39e3930c6 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/description.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/description.ts @@ -1,6 +1,4 @@ -import { - EmployeeProperties, -} from '../../Interfaces'; +import { EmployeeProperties } from '../../Interfaces'; export const employeeGetDescription: EmployeeProperties = [ { @@ -10,12 +8,8 @@ export const employeeGetDescription: EmployeeProperties = [ required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'employee', - ], + operation: ['get'], + resource: ['employee'], }, }, default: '', @@ -28,12 +22,8 @@ export const employeeGetDescription: EmployeeProperties = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'employee', - ], + operation: ['get'], + resource: ['employee'], }, }, options: [ @@ -44,10 +34,9 @@ export const employeeGetDescription: EmployeeProperties = [ typeOptions: { loadOptionsMethod: 'getEmployeeFields', }, - default: [ - 'all', - ], - description: 'Set of fields to get from employee data. Choose from the list, or specify IDs using an expression.', + default: ['all'], + description: + 'Set of fields to get from employee data. Choose from the list, or specify IDs using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/execute.ts index 7ce3cff6f3402..8170020508eb5 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/execute.ts @@ -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 get(this: IExecuteFunctions, index: number): Promise { const body: IDataObject = {}; @@ -22,7 +15,12 @@ export async function get(this: IExecuteFunctions, index: number): Promise field.id); } diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/index.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/index.ts index f5b38ee652c03..981c65126e799 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/index.ts @@ -1,7 +1,4 @@ import { get as execute } from './execute'; import { employeeGetDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/description.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/description.ts index 51369d85e2227..075ad5ce8f149 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/description.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/description.ts @@ -8,12 +8,8 @@ export const employeeGetAllDescription: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'employee', - ], - operation: [ - 'getAll', - ], + resource: ['employee'], + operation: ['getAll'], }, }, description: 'Whether to return all results or only up to a given limit', @@ -29,15 +25,9 @@ export const employeeGetAllDescription: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'employee', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['employee'], + operation: ['getAll'], + returnAll: [false], }, }, description: 'Max number of results to return', diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/execute.ts index 0158273f538b7..b3537fd36e8da 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/execute.ts @@ -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 getAll(this: IExecuteFunctions, index: number): Promise { +export async function getAll( + this: IExecuteFunctions, + index: number, +): Promise { const body: IDataObject = {}; const requestMethod = 'GET'; const endpoint = 'employees/directory'; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/index.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/index.ts index c500a19ccba67..9ae4d1d2b1a9b 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/getAll/index.ts @@ -1,7 +1,4 @@ import { getAll as execute } from './execute'; import { employeeGetAllDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/index.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/index.ts index 8010cc75cf39e..acae299826519 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/index.ts @@ -3,16 +3,9 @@ import * as get from './get'; import * as getAll from './getAll'; import * as update from './update'; -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -export { - create, - get, - getAll, - update -}; +export { create, get, getAll, update }; export const descriptions: INodeProperties[] = [ { @@ -22,9 +15,7 @@ export const descriptions: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'employee', - ], + resource: ['employee'], }, }, options: [ diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/description.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/description.ts index a87e62941e6c6..176ffdf7d6583 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/description.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/description.ts @@ -1,6 +1,4 @@ -import { - EmployeeProperties, -} from '../../Interfaces'; +import { EmployeeProperties } from '../../Interfaces'; import { updateEmployeeSharedDescription } from './sharedDescription'; export const employeeUpdateDescription: EmployeeProperties = [ @@ -11,12 +9,8 @@ export const employeeUpdateDescription: EmployeeProperties = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'employee', - ], + operation: ['update'], + resource: ['employee'], }, }, default: '', @@ -28,16 +22,13 @@ export const employeeUpdateDescription: EmployeeProperties = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'employee', - ], + operation: ['update'], + resource: ['employee'], }, }, default: false, - description: 'Whether the employee to create was added to a pay schedule synced with Trax Payroll', + description: + 'Whether the employee to create was added to a pay schedule synced with Trax Payroll', }, ...updateEmployeeSharedDescription(true), { @@ -48,12 +39,8 @@ export const employeeUpdateDescription: EmployeeProperties = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'employee', - ], + operation: ['update'], + resource: ['employee'], }, }, options: [ diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/execute.ts index 0676c147e8b0b..ab1ca39cb547d 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/update/execute.ts @@ -1,24 +1,17 @@ -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'; import moment from 'moment'; -import { - capitalCase, -} from 'change-case'; +import { capitalCase } from 'change-case'; -export async function update(this: IExecuteFunctions, index: number): Promise { +export async function update( + this: IExecuteFunctions, + index: number, +): Promise { let body: IDataObject = {}; const requestMethod = 'POST'; @@ -35,8 +28,12 @@ export async function update(this: IExecuteFunctions, index: number): Promise { let elements: INodeProperties[] = [ @@ -66,7 +64,8 @@ export const updateEmployeeSharedDescription = (sync = false): INodeProperties[] displayName: 'Department Name or ID', name: 'department', type: 'options', - 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: 'getDepartments', }, @@ -76,7 +75,8 @@ export const updateEmployeeSharedDescription = (sync = false): INodeProperties[] displayName: 'Division Name or ID', name: 'division', type: 'options', - 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: 'getDivisions', }, @@ -94,9 +94,7 @@ export const updateEmployeeSharedDescription = (sync = false): INodeProperties[] type: 'string', displayOptions: { show: { - 'synced': [ - false, - ], + synced: [false], }, }, default: '', @@ -107,9 +105,7 @@ export const updateEmployeeSharedDescription = (sync = false): INodeProperties[] type: 'string', displayOptions: { show: { - 'synced': [ - false, - ], + synced: [false], }, }, default: '', @@ -156,7 +152,8 @@ export const updateEmployeeSharedDescription = (sync = false): INodeProperties[] displayName: 'Location Name or ID', name: 'location', type: 'options', - 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: 'getEmployeeLocations', }, @@ -319,19 +316,13 @@ export const updateEmployeeSharedDescription = (sync = false): INodeProperties[] ]; if (sync === true) { - elements = elements.map(element => { + elements = elements.map((element) => { return Object.assign(element, { displayOptions: { show: { - resource: [ - 'employee', - ], - operation: [ - 'update', - ], - synced: [ - true, - ], + resource: ['employee'], + operation: ['update'], + synced: [true], }, }, required: true, @@ -339,13 +330,11 @@ export const updateEmployeeSharedDescription = (sync = false): INodeProperties[] }); return elements; } else { - elements = elements.map(element => { + elements = elements.map((element) => { return Object.assign(element, { displayOptions: { show: { - '/synced': [ - false, - ], + '/synced': [false], }, }, }); diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/del/description.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/del/description.ts index d898a312442bc..c12094c46c111 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/del/description.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/del/description.ts @@ -1,6 +1,4 @@ -import { - EmployeeDocumentProperties, -} from '../../Interfaces'; +import { EmployeeDocumentProperties } from '../../Interfaces'; export const employeeDocumentDelDescription: EmployeeDocumentProperties = [ { @@ -10,12 +8,8 @@ export const employeeDocumentDelDescription: EmployeeDocumentProperties = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'employeeDocument', - ], + operation: ['delete'], + resource: ['employeeDocument'], }, }, default: '', @@ -28,12 +22,8 @@ export const employeeDocumentDelDescription: EmployeeDocumentProperties = [ required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'employeeDocument', - ], + operation: ['delete'], + resource: ['employeeDocument'], }, }, default: '', diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/del/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/del/execute.ts index 1d2ebe01b3f25..4f5615fc7b015 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/del/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/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 body: IDataObject = {}; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/del/index.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/del/index.ts index 4b40bf333a062..05d70b3f50845 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/del/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/del/index.ts @@ -1,7 +1,4 @@ import { del as execute } from './execute'; import { employeeDocumentDelDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/description.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/description.ts index 6560de5c2af71..e48fdc3f8d4fb 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/description.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/description.ts @@ -1,6 +1,4 @@ -import { - EmployeeDocumentProperties, -} from '../../Interfaces'; +import { EmployeeDocumentProperties } from '../../Interfaces'; export const employeeDocumentDownloadDescription: EmployeeDocumentProperties = [ { @@ -10,12 +8,8 @@ export const employeeDocumentDownloadDescription: EmployeeDocumentProperties = [ required: true, displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'employeeDocument', - ], + operation: ['download'], + resource: ['employeeDocument'], }, }, default: '', @@ -28,12 +22,8 @@ export const employeeDocumentDownloadDescription: EmployeeDocumentProperties = [ required: true, displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'employeeDocument', - ], + operation: ['download'], + resource: ['employeeDocument'], }, }, default: '', @@ -48,12 +38,8 @@ export const employeeDocumentDownloadDescription: EmployeeDocumentProperties = [ description: 'The name of the output field to put the binary file data in', displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'employeeDocument', - ], + operation: ['download'], + resource: ['employeeDocument'], }, }, }, diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/execute.ts index 4c9870ea4ef43..816a1f1dd94da 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/execute.ts @@ -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 download(this: IExecuteFunctions, index: number) { const body: IDataObject = {}; @@ -25,10 +18,13 @@ export async function download(this: IExecuteFunctions, index: number) { const endpoint = `employees/${id}/files/${fileId}/`; //response - const response = await apiRequest.call(this, requestMethod, endpoint, body, {} as IDataObject, - { encoding: null, json: false, resolveWithFullResponse: true }); + const response = await apiRequest.call(this, requestMethod, endpoint, body, {} as IDataObject, { + encoding: null, + json: false, + resolveWithFullResponse: true, + }); let mimeType = response.headers['content-type'] as string | undefined; - mimeType = mimeType ? mimeType.split(';').find(value => value.includes('/')) : undefined; + mimeType = mimeType ? mimeType.split(';').find((value) => value.includes('/')) : undefined; const contentDisposition = response.headers['content-disposition']; const fileNameRegex = /(?<=filename=").*\b/; const match = fileNameRegex.exec(contentDisposition); @@ -52,7 +48,11 @@ export async function download(this: IExecuteFunctions, index: number) { } newItem.binary = { - [output]: await this.helpers.prepareBinaryData(response.body as unknown as Buffer, fileName, mimeType), + [output]: await this.helpers.prepareBinaryData( + response.body as unknown as Buffer, + fileName, + mimeType, + ), }; return this.prepareOutputData(newItem as unknown as INodeExecutionData[]); diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/index.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/index.ts index 956798721cd3e..67f73a986dfc7 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/index.ts @@ -1,7 +1,4 @@ import { download as execute } from './execute'; import { employeeDocumentDownloadDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/description.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/description.ts index aabd0d527f737..e2258048484c1 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/description.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/description.ts @@ -1,6 +1,4 @@ -import { - EmployeeDocumentProperties, -} from '../../Interfaces'; +import { EmployeeDocumentProperties } from '../../Interfaces'; export const employeeDocumentGetAllDescription: EmployeeDocumentProperties = [ { @@ -10,12 +8,8 @@ export const employeeDocumentGetAllDescription: EmployeeDocumentProperties = [ required: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'employeeDocument', - ], + operation: ['getAll'], + resource: ['employeeDocument'], }, }, default: '', @@ -27,12 +21,8 @@ export const employeeDocumentGetAllDescription: EmployeeDocumentProperties = [ default: false, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'employeeDocument', - ], + operation: ['getAll'], + resource: ['employeeDocument'], }, }, description: 'Whether to return all results or only up to a given limit', @@ -49,15 +39,9 @@ export const employeeDocumentGetAllDescription: EmployeeDocumentProperties = [ }, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'employeeDocument', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['employeeDocument'], + returnAll: [false], }, }, }, @@ -68,12 +52,8 @@ export const employeeDocumentGetAllDescription: EmployeeDocumentProperties = [ default: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'employeeDocument', - ], + operation: ['getAll'], + resource: ['employeeDocument'], }, }, description: 'Whether to return a simplified version of the response instead of the raw data', diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/execute.ts index 2a11cad42c5c7..dbede13557545 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/execute.ts @@ -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 getAll(this: IExecuteFunctions, index: number): Promise { +export async function getAll( + this: IExecuteFunctions, + index: number, +): Promise { const body: IDataObject = {}; const requestMethod = 'GET'; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/index.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/index.ts index 60a7d085c521e..eb6a95a73ec97 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/index.ts @@ -1,7 +1,4 @@ import { getAll as execute } from './execute'; import { employeeDocumentGetAllDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/index.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/index.ts index 95d3d79ad94c8..29e79989d65a1 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/index.ts @@ -4,17 +4,9 @@ import * as getAll from './getAll'; import * as update from './update'; import * as upload from './upload'; -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -export { - del, - download, - getAll, - update, - upload, -}; +export { del, download, getAll, update, upload }; export const descriptions: INodeProperties[] = [ { @@ -24,9 +16,7 @@ export const descriptions: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'employeeDocument', - ], + resource: ['employeeDocument'], }, }, options: [ diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/update/description.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/update/description.ts index ba16465e8d983..a4380e9e7d286 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/update/description.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/update/description.ts @@ -1,6 +1,4 @@ -import { - EmployeeDocumentProperties, -} from '../../Interfaces'; +import { EmployeeDocumentProperties } from '../../Interfaces'; export const employeeDocumentUpdateDescription: EmployeeDocumentProperties = [ { @@ -10,12 +8,8 @@ export const employeeDocumentUpdateDescription: EmployeeDocumentProperties = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'employeeDocument', - ], + operation: ['update'], + resource: ['employeeDocument'], }, }, default: '', @@ -27,12 +21,8 @@ export const employeeDocumentUpdateDescription: EmployeeDocumentProperties = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'employeeDocument', - ], + operation: ['update'], + resource: ['employeeDocument'], }, }, default: '', @@ -45,12 +35,8 @@ export const employeeDocumentUpdateDescription: EmployeeDocumentProperties = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'employeeDocument', - ], + operation: ['update'], + resource: ['employeeDocument'], }, }, options: [ @@ -60,12 +46,11 @@ export const employeeDocumentUpdateDescription: EmployeeDocumentProperties = [ type: 'options', typeOptions: { loadOptionsMethod: 'getEmployeeDocumentCategories', - loadOptionsDependsOn: [ - 'employeeId', - ], + loadOptionsDependsOn: ['employeeId'], }, default: '', - description: 'ID of the new category of the file. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the new category of the file. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Name', diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/update/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/update/execute.ts index 04acce14853f6..8ea89c1fd0a03 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/update/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/update/execute.ts @@ -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 update(this: IExecuteFunctions, index: number): Promise { +export async function update( + this: IExecuteFunctions, + index: number, +): Promise { let body: IDataObject = {}; const requestMethod = 'POST'; @@ -24,7 +20,7 @@ export async function update(this: IExecuteFunctions, index: number): Promise { const body: IDataObject = {}; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/file/del/index.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/file/del/index.ts index 90105b3d1c8f9..0bef7541b8931 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/file/del/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/file/del/index.ts @@ -1,7 +1,4 @@ import { del as execute } from './execute'; import { fileDelDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/description.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/description.ts index 55b45d6d79222..d600fb61b0846 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/description.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/description.ts @@ -1,6 +1,4 @@ -import { - FileProperties, -} from '../../Interfaces'; +import { FileProperties } from '../../Interfaces'; export const fileDownloadDescription: FileProperties = [ { @@ -10,12 +8,8 @@ export const fileDownloadDescription: FileProperties = [ required: true, displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'file', - ], + operation: ['download'], + resource: ['file'], }, }, default: '', @@ -30,12 +24,8 @@ export const fileDownloadDescription: FileProperties = [ description: 'The name of the output field to put the binary file data in', displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'file', - ], + operation: ['download'], + resource: ['file'], }, }, }, diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/execute.ts index 358be14eca94d..b3b5bf4cf8a2b 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/execute.ts @@ -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 download(this: IExecuteFunctions, index: number) { const body: IDataObject = {}; @@ -24,11 +17,14 @@ export async function download(this: IExecuteFunctions, index: number) { const endpoint = `files/${fileId}/`; //response - const response = await apiRequest.call(this, requestMethod, endpoint, body, {} as IDataObject, - { encoding: null, json: false, resolveWithFullResponse: true }); + const response = await apiRequest.call(this, requestMethod, endpoint, body, {} as IDataObject, { + encoding: null, + json: false, + resolveWithFullResponse: true, + }); let mimeType = response.headers['content-type'] as string | undefined; - mimeType = mimeType ? mimeType.split(';').find(value => value.includes('/')) : undefined; + mimeType = mimeType ? mimeType.split(';').find((value) => value.includes('/')) : undefined; const contentDisposition = response.headers['content-disposition']; const fileNameRegex = /(?<=filename=").*\b/; const match = fileNameRegex.exec(contentDisposition); @@ -52,7 +48,11 @@ export async function download(this: IExecuteFunctions, index: number) { } newItem.binary = { - [output]: await this.helpers.prepareBinaryData(response.body as unknown as Buffer, fileName, mimeType), + [output]: await this.helpers.prepareBinaryData( + response.body as unknown as Buffer, + fileName, + mimeType, + ), }; return this.prepareOutputData(newItem as unknown as INodeExecutionData[]); diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/index.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/index.ts index 0f3b6da933937..8d736b9e28da4 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/index.ts @@ -1,7 +1,4 @@ import { download as execute } from './execute'; import { fileDownloadDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/description.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/description.ts index 646ed3c03570c..f965f854d0318 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/description.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/description.ts @@ -1,6 +1,4 @@ -import { - FileProperties, -} from '../../Interfaces'; +import { FileProperties } from '../../Interfaces'; export const fileGetAllDescription: FileProperties = [ { @@ -11,12 +9,8 @@ export const fileGetAllDescription: FileProperties = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'file', - ], + operation: ['getAll'], + resource: ['file'], }, }, }, @@ -32,15 +26,9 @@ export const fileGetAllDescription: FileProperties = [ }, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'file', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['file'], + returnAll: [false], }, }, }, @@ -51,12 +39,8 @@ export const fileGetAllDescription: FileProperties = [ default: true, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'file', - ], + operation: ['getAll'], + resource: ['file'], }, }, description: 'Whether to return a simplified version of the response instead of the raw data', diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/execute.ts index b78dc8ee837ff..6fd312a50dd7d 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/execute.ts @@ -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 getAll(this: IExecuteFunctions, index: number): Promise { +export async function getAll( + this: IExecuteFunctions, + index: number, +): Promise { const body: IDataObject = {}; const requestMethod = 'GET'; const endpoint = 'files/view'; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/index.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/index.ts index 3b1b2ee79527c..ddb484a98c4b1 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/index.ts @@ -1,7 +1,4 @@ import { getAll as execute } from './execute'; import { fileGetAllDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/file/index.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/file/index.ts index 464e5ae05bb2b..02d05ec6c224a 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/file/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/file/index.ts @@ -4,17 +4,9 @@ import * as getAll from './getAll'; import * as update from './update'; import * as upload from './upload'; -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -export { - del, - download, - getAll, - update, - upload, -}; +export { del, download, getAll, update, upload }; export const descriptions: INodeProperties[] = [ { @@ -24,9 +16,7 @@ export const descriptions: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'file', - ], + resource: ['file'], }, }, options: [ diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/file/update/description.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/file/update/description.ts index 7c0b110c1a633..f1e722eb4e1e9 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/file/update/description.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/file/update/description.ts @@ -1,6 +1,4 @@ -import { - FileProperties, -} from '../../Interfaces'; +import { FileProperties } from '../../Interfaces'; export const fileUpdateDescription: FileProperties = [ { @@ -10,12 +8,8 @@ export const fileUpdateDescription: FileProperties = [ required: true, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'file', - ], + operation: ['update'], + resource: ['file'], }, }, default: '', @@ -29,12 +23,8 @@ export const fileUpdateDescription: FileProperties = [ default: {}, displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'file', - ], + operation: ['update'], + resource: ['file'], }, }, options: [ @@ -46,7 +36,8 @@ export const fileUpdateDescription: FileProperties = [ loadOptionsMethod: 'getCompanyFileCategories', }, default: '', - description: 'Move the file to a different category. Choose from the list, or specify an ID using an expression.', + description: + 'Move the file to a different category. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Name', diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/file/update/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/file/update/execute.ts index aed7b0f3f05f9..1618aac3328b0 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/file/update/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/file/update/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 update(this: IExecuteFunctions, index: number): Promise { +export async function update( + this: IExecuteFunctions, + index: number, +): Promise { const body: IDataObject = {}; const requestMethod = 'POST'; @@ -22,7 +18,11 @@ export async function update(this: IExecuteFunctions, index: number): Promiseexpression', + description: + 'Choose from the list, or specify an ID using an expression', typeOptions: { loadOptionsMethod: 'getCompanyFileCategories', }, required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, default: '', @@ -47,12 +41,8 @@ export const fileUploadDescription: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/file/upload/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/file/upload/execute.ts index c9c711d671c46..fda421d1bc07f 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/file/upload/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/file/upload/execute.ts @@ -1,17 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IBinaryData, - IBinaryKeyData, - IDataObject, - NodeOperationError, -} from 'n8n-workflow'; +import { IBinaryData, IBinaryKeyData, IDataObject, NodeOperationError } from 'n8n-workflow'; -import { - apiRequest, -} from '../../../transport'; +import { apiRequest } from '../../../transport'; export async function upload(this: IExecuteFunctions, index: number) { let body: IDataObject = {}; @@ -23,13 +14,19 @@ export async function upload(this: IExecuteFunctions, index: number) { const share = this.getNodeParameter('options.share', index, true) as boolean; if (items[index].binary === undefined) { - throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: index }); + throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { + itemIndex: index, + }); } const propertyNameUpload = this.getNodeParameter('binaryPropertyName', index) as string; if (items[index]!.binary![propertyNameUpload] === undefined) { - throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`, { itemIndex: index }); + throw new NodeOperationError( + this.getNode(), + `No binary data property "${propertyNameUpload}" does not exists on item!`, + { itemIndex: index }, + ); } const item = items[index].binary as IBinaryKeyData; @@ -54,7 +51,7 @@ export async function upload(this: IExecuteFunctions, index: number) { resolveWithFullResponse: true, }; - Object.assign(body.formData, (share) ? { share: 'yes' } : { share: 'no' }); + Object.assign(body.formData, share ? { share: 'yes' } : { share: 'no' }); //endpoint const endpoint = `files`; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/file/upload/index.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/file/upload/index.ts index 23cd4577f3186..20787c370b06b 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/file/upload/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/file/upload/index.ts @@ -1,7 +1,4 @@ import { upload as execute } from './execute'; import { fileUploadDescription as description } from './description'; -export { - description, - execute, -}; +export { description, execute }; diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/router.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/router.ts index b053254582147..e8e97623a18c6 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/router.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/router.ts @@ -1,10 +1,6 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - INodeExecutionData, -} from 'n8n-workflow'; +import { INodeExecutionData } from 'n8n-workflow'; import * as employee from './employee'; import * as employeeDocument from './employeeDocument'; @@ -33,16 +29,16 @@ export async function router(this: IExecuteFunctions): Promise { +export async function bambooHrApiCredentialTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, +): Promise { try { await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject); } catch (error) { @@ -22,15 +25,16 @@ export async function bambooHrApiCredentialTest(this: ICredentialTestFunctions, } as INodeCredentialTestResult; } -async function validateCredentials(this: ICredentialTestFunctions, decryptedCredentials: ICredentialDataDecryptedObject): Promise { // tslint:disable-line:no-any +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/BambooHr/v1/methods/loadOptions.ts b/packages/nodes-base/nodes/BambooHr/v1/methods/loadOptions.ts index 37f57ad54c580..8d29d8ea8d14e 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/methods/loadOptions.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/methods/loadOptions.ts @@ -1,15 +1,11 @@ -import { - IDataObject, - ILoadOptionsFunctions, - INodePropertyOptions, -} from 'n8n-workflow'; +import { IDataObject, ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow'; -import { - apiRequest, -} from '../transport'; +import { apiRequest } from '../transport'; // Get all the available channels -export async function getTimeOffTypeID(this: ILoadOptionsFunctions): Promise { +export async function getTimeOffTypeID( + this: ILoadOptionsFunctions, +): Promise { const returnData: INodePropertyOptions[] = []; const body: IDataObject = {}; const requestMethod = 'GET'; @@ -27,7 +23,9 @@ export async function getTimeOffTypeID(this: ILoadOptionsFunctions): Promise { +export async function getCompanyFileCategories( + this: ILoadOptionsFunctions, +): Promise { const returnData: INodePropertyOptions[] = []; const body: IDataObject = {}; const requestMethod = 'GET'; @@ -42,18 +40,20 @@ export async function getCompanyFileCategories(this: ILoadOptionsFunctions): Pro value: category.id, }); } - + returnData.sort(sort); return returnData; } -export async function getEmployeeDocumentCategories(this: ILoadOptionsFunctions): Promise { +export async function getEmployeeDocumentCategories( + this: ILoadOptionsFunctions, +): Promise { const returnData: INodePropertyOptions[] = []; const body: IDataObject = {}; const requestMethod = 'GET'; const id = this.getCurrentNodeParameter('employeeId') as string; - + const endPoint = `employees/${id}/files/view/`; const response = await apiRequest.call(this, requestMethod, endPoint, body); @@ -71,16 +71,20 @@ export async function getEmployeeDocumentCategories(this: ILoadOptionsFunctions) return returnData; } -export async function getEmployeeLocations(this: ILoadOptionsFunctions): Promise { +export async function getEmployeeLocations( + this: ILoadOptionsFunctions, +): Promise { const returnData: INodePropertyOptions[] = []; const body: IDataObject = {}; const requestMethod = 'GET'; const endPoint = 'meta/lists/'; - //do not request all data? - const fields = await apiRequest.call(this, requestMethod, endPoint, body, {}) as [{ fieldId: number, options: [{ id: number, name: string }] }]; + //do not request all data? + const fields = (await apiRequest.call(this, requestMethod, endPoint, body, {})) as [ + { fieldId: number; options: [{ id: number; name: string }] }, + ]; - const options = fields.filter(field => field.fieldId === 18)[0].options; + const options = fields.filter((field) => field.fieldId === 18)[0].options; for (const option of options) { returnData.push({ @@ -100,10 +104,12 @@ export async function getDepartments(this: ILoadOptionsFunctions): Promise field.fieldId === 4)[0].options; + const options = fields.filter((field) => field.fieldId === 4)[0].options; for (const option of options) { returnData.push({ @@ -123,10 +129,12 @@ export async function getDivisions(this: ILoadOptionsFunctions): Promise field.fieldId === 1355)[0].options; + const options = fields.filter((field) => field.fieldId === 1355)[0].options; for (const option of options) { returnData.push({ @@ -140,7 +148,9 @@ export async function getDivisions(this: ILoadOptionsFunctions): Promise { +export async function getEmployeeFields( + this: ILoadOptionsFunctions, +): Promise { const returnData: INodePropertyOptions[] = []; const body: IDataObject = {}; const requestMethod = 'GET'; @@ -167,10 +177,11 @@ export async function getEmployeeFields(this: ILoadOptionsFunctions): Promise { - 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/BambooHr/v1/transport/index.ts b/packages/nodes-base/nodes/BambooHr/v1/transport/index.ts index 66a0a7859bb61..6421abf74dad6 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/transport/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/transport/index.ts @@ -1,18 +1,8 @@ -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 { - OptionsWithUrl, -} from 'request'; +import { OptionsWithUrl } from 'request'; /** * Make an API request to Mattermost diff --git a/packages/nodes-base/nodes/Bannerbear/Bannerbear.node.ts b/packages/nodes-base/nodes/Bannerbear/Bannerbear.node.ts index 01d0638306eae..c0f3dd7d062da 100644 --- a/packages/nodes-base/nodes/Bannerbear/Bannerbear.node.ts +++ b/packages/nodes-base/nodes/Bannerbear/Bannerbear.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 { - bannerbearApiRequest, - keysToSnakeCase, -} from './GenericFunctions'; +import { bannerbearApiRequest, keysToSnakeCase } from './GenericFunctions'; -import { - imageFields, - imageOperations, -} from './ImageDescription'; +import { imageFields, imageOperations } from './ImageDescription'; -import { - templateFields, - templateOperations, -} from './TemplateDescription'; +import { templateFields, templateOperations } from './TemplateDescription'; export class Bannerbear implements INodeType { description: INodeTypeDescription = { @@ -97,7 +86,11 @@ export class Bannerbear implements INodeType { async getModificationNames(this: ILoadOptionsFunctions): Promise { const templateId = this.getCurrentNodeParameter('templateId'); const returnData: INodePropertyOptions[] = []; - const { available_modifications } = await bannerbearApiRequest.call(this, 'GET', `/templates/${templateId}`); + const { available_modifications } = await bannerbearApiRequest.call( + this, + 'GET', + `/templates/${templateId}`, + ); for (const modification of available_modifications) { const modificationName = modification.name; const modificationId = modification.name; @@ -125,7 +118,8 @@ export class Bannerbear implements INodeType { if (operation === 'create') { const templateId = this.getNodeParameter('templateId', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - const modifications = (this.getNodeParameter('modificationsUi', i) as IDataObject).modificationsValues as IDataObject; + const modifications = (this.getNodeParameter('modificationsUi', i) as IDataObject) + .modificationsValues as IDataObject; const body: IDataObject = { template: templateId, }; diff --git a/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts b/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts index dc5373cb35f73..cc288e770625b 100644 --- a/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bannerbear/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 bannerbearApiRequest(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 bannerbearApiRequest( + 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 credentials = await this.getCredentials('bannerbearApi'); const options: OptionsWithUri = { @@ -48,7 +50,7 @@ export async function bannerbearApiRequest(this: IExecuteFunctions | IWebhookFun } } -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/Bannerbear/ImageDescription.ts b/packages/nodes-base/nodes/Bannerbear/ImageDescription.ts index 7628c40d0844d..3fdd1788f9752 100644 --- a/packages/nodes-base/nodes/Bannerbear/ImageDescription.ts +++ b/packages/nodes-base/nodes/Bannerbear/ImageDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const imageOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const imageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'image', - ], + resource: ['image'], }, }, options: [ @@ -34,10 +30,9 @@ export const imageOperations: INodeProperties[] = [ ]; export const imageFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* image:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* image:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Template Name or ID', name: 'templateId', @@ -49,15 +44,12 @@ export const imageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'image', - ], - operation: [ - 'create', - ], + resource: ['image'], + operation: ['create'], }, }, - description: 'The template ID you want to use. Choose from the list, or specify an ID using an expression.', + description: + 'The template ID you want to use. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Additional Fields', @@ -66,12 +58,8 @@ export const imageFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'image', - ], - operation: [ - 'create', - ], + resource: ['image'], + operation: ['create'], }, }, default: {}, @@ -88,7 +76,8 @@ export const imageFields: INodeProperties[] = [ name: 'waitForImage', type: 'boolean', default: false, - description: 'Whether to wait for the image to be proccesed before returning. If after three tries the images is not ready, an error will be thrown. Number of tries can be increased by setting "Wait Max Tries".', + description: + 'Whether to wait for the image to be proccesed before returning. If after three tries the images is not ready, an error will be thrown. Number of tries can be increased by setting "Wait Max Tries".', }, { displayName: 'Wait Max Tries', @@ -100,9 +89,7 @@ export const imageFields: INodeProperties[] = [ }, displayOptions: { show: { - waitForImage: [ - true, - ], + waitForImage: [true], }, }, default: 3, @@ -127,12 +114,8 @@ export const imageFields: INodeProperties[] = [ placeholder: 'Add Modification', displayOptions: { show: { - resource: [ - 'image', - ], - operation: [ - 'create', - ], + resource: ['image'], + operation: ['create'], }, }, default: {}, @@ -147,12 +130,11 @@ export const imageFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getModificationNames', - loadOptionsDependsOn: [ - 'templateId', - ], + loadOptionsDependsOn: ['templateId'], }, default: '', - description: 'The name of the item you want to change. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the item you want to change. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Text', @@ -186,9 +168,9 @@ export const imageFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* image:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* image:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Image ID', name: 'imageId', @@ -197,12 +179,8 @@ export const imageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'image', - ], - operation: [ - 'get', - ], + resource: ['image'], + operation: ['get'], }, }, description: 'Unique identifier for the image', diff --git a/packages/nodes-base/nodes/Bannerbear/TemplateDescription.ts b/packages/nodes-base/nodes/Bannerbear/TemplateDescription.ts index 723ec8a853b26..a8c04bb73f4e5 100644 --- a/packages/nodes-base/nodes/Bannerbear/TemplateDescription.ts +++ b/packages/nodes-base/nodes/Bannerbear/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: [ @@ -34,10 +30,9 @@ export const templateOperations: INodeProperties[] = [ ]; export const templateFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* template:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* template:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Template ID', name: 'templateId', @@ -46,12 +41,8 @@ export const templateFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'template', - ], - operation: [ - 'get', - ], + resource: ['template'], + operation: ['get'], }, }, description: 'Unique identifier for the template', diff --git a/packages/nodes-base/nodes/Baserow/Baserow.node.ts b/packages/nodes-base/nodes/Baserow/Baserow.node.ts index bc4202d367261..50bafa0b8c437 100644 --- a/packages/nodes-base/nodes/Baserow/Baserow.node.ts +++ b/packages/nodes-base/nodes/Baserow/Baserow.node.ts @@ -6,9 +6,7 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { baserowApiRequest, @@ -18,9 +16,7 @@ import { toOptions, } from './GenericFunctions'; -import { - operationFields -} from './OperationDescription'; +import { operationFields } from './OperationDescription'; import { BaserowCredentials, @@ -72,9 +68,7 @@ export class Baserow implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'row', - ], + resource: ['row'], }, }, options: [ @@ -118,28 +112,49 @@ export class Baserow implements INodeType { methods = { loadOptions: { async getDatabaseIds(this: ILoadOptionsFunctions) { - const credentials = await this.getCredentials('baserowApi') as BaserowCredentials; + const credentials = (await this.getCredentials('baserowApi')) as BaserowCredentials; const jwtToken = await getJwtToken.call(this, credentials); const endpoint = '/api/applications/'; - const databases = await baserowApiRequest.call(this, 'GET', endpoint, {}, {}, jwtToken) as LoadedResource[]; + const databases = (await baserowApiRequest.call( + this, + 'GET', + endpoint, + {}, + {}, + jwtToken, + )) as LoadedResource[]; return toOptions(databases); }, async getTableIds(this: ILoadOptionsFunctions) { - const credentials = await this.getCredentials('baserowApi') as BaserowCredentials; + const credentials = (await this.getCredentials('baserowApi')) as BaserowCredentials; const jwtToken = await getJwtToken.call(this, credentials); const databaseId = this.getNodeParameter('databaseId', 0) as string; const endpoint = `/api/database/tables/database/${databaseId}/`; - const tables = await baserowApiRequest.call(this, 'GET', endpoint, {}, {}, jwtToken) as LoadedResource[]; + const tables = (await baserowApiRequest.call( + this, + 'GET', + endpoint, + {}, + {}, + jwtToken, + )) as LoadedResource[]; return toOptions(tables); }, async getTableFields(this: ILoadOptionsFunctions) { - const credentials = await this.getCredentials('baserowApi') as BaserowCredentials; + const credentials = (await this.getCredentials('baserowApi')) as BaserowCredentials; const jwtToken = await getJwtToken.call(this, credentials); const tableId = this.getNodeParameter('tableId', 0) as string; const endpoint = `/api/database/fields/table/${tableId}/`; - const fields = await baserowApiRequest.call(this, 'GET', endpoint, {}, {}, jwtToken) as LoadedResource[]; + const fields = (await baserowApiRequest.call( + this, + 'GET', + endpoint, + {}, + {}, + jwtToken, + )) as LoadedResource[]; return toOptions(fields); }, }, @@ -152,24 +167,24 @@ export class Baserow implements INodeType { const operation = this.getNodeParameter('operation', 0) as Operation; const tableId = this.getNodeParameter('tableId', 0) as string; - const credentials = await this.getCredentials('baserowApi') as BaserowCredentials; + const credentials = (await this.getCredentials('baserowApi')) as BaserowCredentials; const jwtToken = await getJwtToken.call(this, credentials); const fields = await mapper.getTableFields.call(this, tableId, jwtToken); mapper.createMappings(fields); for (let i = 0; i < items.length; i++) { - try { - if (operation === 'getAll') { - // ---------------------------------- // getAll // ---------------------------------- // https://api.baserow.io/api/redoc/#operation/list_database_table_rows - const { order, filters, filterType, search } = this.getNodeParameter('additionalOptions', 0) as GetAllAdditionalOptions; + const { order, filters, filterType, search } = this.getNodeParameter( + 'additionalOptions', + 0, + ) as GetAllAdditionalOptions; const qs: IDataObject = {}; @@ -194,14 +209,19 @@ export class Baserow implements INodeType { } const endpoint = `/api/database/rows/table/${tableId}/`; - const rows = await baserowApiRequestAllItems.call(this, 'GET', endpoint, {}, qs, jwtToken) as Row[]; + const rows = (await baserowApiRequestAllItems.call( + this, + 'GET', + endpoint, + {}, + qs, + jwtToken, + )) as Row[]; - rows.forEach(row => mapper.idsToNames(row)); + rows.forEach((row) => mapper.idsToNames(row)); returnData.push(...rows); - } else if (operation === 'get') { - // ---------------------------------- // get // ---------------------------------- @@ -215,9 +235,7 @@ export class Baserow implements INodeType { mapper.idsToNames(row); returnData.push(row); - } else if (operation === 'create') { - // ---------------------------------- // create // ---------------------------------- @@ -226,12 +244,14 @@ export class Baserow implements INodeType { const body: 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; @@ -246,14 +266,19 @@ export class Baserow implements INodeType { } const endpoint = `/api/database/rows/table/${tableId}/`; - const createdRow = await baserowApiRequest.call(this, 'POST', endpoint, body, {}, jwtToken); + const createdRow = await baserowApiRequest.call( + this, + 'POST', + endpoint, + body, + {}, + jwtToken, + ); mapper.idsToNames(createdRow); returnData.push(createdRow); - } else if (operation === 'update') { - // ---------------------------------- // update // ---------------------------------- @@ -264,13 +289,14 @@ export class Baserow implements INodeType { const body: 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 inputsToIgnore = rawInputsToIgnore.split(',').map(c => c.trim()); + const inputsToIgnore = rawInputsToIgnore.split(',').map((c) => c.trim()); for (const key of incomingKeys) { if (inputsToIgnore.includes(key)) continue; @@ -285,14 +311,19 @@ export class Baserow implements INodeType { } const endpoint = `/api/database/rows/table/${tableId}/${rowId}/`; - const updatedRow = await baserowApiRequest.call(this, 'PATCH', endpoint, body, {}, jwtToken); + const updatedRow = await baserowApiRequest.call( + this, + 'PATCH', + endpoint, + body, + {}, + jwtToken, + ); mapper.idsToNames(updatedRow); returnData.push(updatedRow); - } else if (operation === 'delete') { - // ---------------------------------- // delete // ---------------------------------- @@ -306,7 +337,6 @@ export class Baserow implements INodeType { returnData.push({ success: true }); } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/Baserow/GenericFunctions.ts b/packages/nodes-base/nodes/Baserow/GenericFunctions.ts index 119474ddd61b5..5fda24275c623 100644 --- a/packages/nodes-base/nodes/Baserow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Baserow/GenericFunctions.ts @@ -1,23 +1,10 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; - -import { - OptionsWithUri, -} from 'request'; - -import { - IDataObject, - ILoadOptionsFunctions, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; - -import { - Accumulator, - BaserowCredentials, - LoadedResource, -} from './types'; +import { IExecuteFunctions } from 'n8n-core'; + +import { OptionsWithUri } from 'request'; + +import { IDataObject, ILoadOptionsFunctions, NodeApiError, NodeOperationError } from 'n8n-workflow'; + +import { Accumulator, BaserowCredentials, LoadedResource } from './types'; /** * Make a request to Baserow API. @@ -30,7 +17,7 @@ export async function baserowApiRequest( qs: IDataObject = {}, jwtToken: string, ) { - const credentials = await this.getCredentials('baserowApi') as BaserowCredentials; + const credentials = (await this.getCredentials('baserowApi')) as BaserowCredentials; const options: OptionsWithUri = { headers: { @@ -110,7 +97,7 @@ export async function getJwtToken( }; try { - const { token } = await this.helpers.request!(options) as { token: string }; + const { token } = (await this.helpers.request!(options)) as { token: string }; return token; } catch (error) { throw new NodeApiError(this.getNode(), error); @@ -123,7 +110,14 @@ export async function getFieldNamesAndIds( jwtToken: string, ) { const endpoint = `/api/database/fields/table/${tableId}/`; - const response = await baserowApiRequest.call(this, 'GET', endpoint, {}, {}, jwtToken) as LoadedResource[]; + const response = (await baserowApiRequest.call( + this, + 'GET', + endpoint, + {}, + {}, + jwtToken, + )) as LoadedResource[]; return { names: response.map((field) => field.name), @@ -183,7 +177,7 @@ export class TableFieldMapper { }); } - namesToIds(obj: Record) { + namesToIds(obj: Record) { Object.entries(obj).forEach(([key, value]) => { if (this.nameToIdMapping[key] !== undefined) { delete obj[key]; diff --git a/packages/nodes-base/nodes/Baserow/OperationDescription.ts b/packages/nodes-base/nodes/Baserow/OperationDescription.ts index c0f96d62aca82..b0a4e2afff2a9 100644 --- a/packages/nodes-base/nodes/Baserow/OperationDescription.ts +++ b/packages/nodes-base/nodes/Baserow/OperationDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const operationFields: INodeProperties[] = [ // ---------------------------------- @@ -12,7 +10,8 @@ export const operationFields: INodeProperties[] = [ type: 'options', default: '', required: true, - description: 'Database to operate on. Choose from the list, or specify an ID using an expression.', + description: + 'Database to operate on. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getDatabaseIds', }, @@ -23,11 +22,10 @@ export const operationFields: INodeProperties[] = [ type: 'options', default: '', required: true, - description: 'Table to operate on. Choose from the list, or specify an ID using an expression.', + description: + 'Table to operate on. Choose from the list, or specify an ID using an expression.', typeOptions: { - loadOptionsDependsOn: [ - 'databaseId', - ], + loadOptionsDependsOn: ['databaseId'], loadOptionsMethod: 'getTableIds', }, }, @@ -41,9 +39,7 @@ export const operationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], + operation: ['get'], }, }, default: '', @@ -60,9 +56,7 @@ export const operationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, default: '', @@ -91,10 +85,7 @@ export const operationFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'create', - 'update', - ], + operation: ['create', 'update'], }, }, default: 'defineBelow', @@ -106,17 +97,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...', }, { @@ -130,13 +117,8 @@ export const operationFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - 'update', - ], - dataToSend: [ - 'defineBelow', - ], + operation: ['create', 'update'], + dataToSend: ['defineBelow'], }, }, default: {}, @@ -149,11 +131,10 @@ export const operationFields: 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: 'getTableFields', }, default: '', @@ -178,9 +159,7 @@ export const operationFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], }, }, default: '', @@ -199,9 +178,7 @@ export const operationFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, }, @@ -217,12 +194,8 @@ export const operationFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -234,9 +207,7 @@ export const operationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], + operation: ['getAll'], }, }, options: [ @@ -260,11 +231,10 @@ export const operationFields: INodeProperties[] = [ name: 'field', type: 'options', default: '', - description: 'Field to compare. Choose from the list, or specify an ID using an expression.', + description: + 'Field to compare. Choose from the list, or specify an ID using an expression.', typeOptions: { - loadOptionsDependsOn: [ - 'tableId', - ], + loadOptionsDependsOn: ['tableId'], loadOptionsMethod: 'getTableFields', }, }, @@ -287,17 +257,17 @@ export const operationFields: INodeProperties[] = [ { name: 'Date After Date', value: 'date_after', - description: 'Field after this date. Format: \'YYYY-MM-DD\'.', + description: "Field after this date. Format: 'YYYY-MM-DD'.", }, { name: 'Date Before Date', value: 'date_before', - description: 'Field before this date. Format: \'YYYY-MM-DD\'.', + description: "Field before this date. Format: 'YYYY-MM-DD'.", }, { name: 'Date Equal', value: 'date_equal', - description: 'Field is date. Format: \'YYYY-MM-DD\'.', + description: "Field is date. Format: 'YYYY-MM-DD'.", }, { name: 'Date Equals Month', @@ -317,7 +287,7 @@ export const operationFields: INodeProperties[] = [ { name: 'Date Not Equal', value: 'date_not_equal', - description: 'Field is not date. Format: \'YYYY-MM-DD\'.', + description: "Field is not date. Format: 'YYYY-MM-DD'.", }, { name: 'Equal', @@ -410,7 +380,8 @@ export const operationFields: INodeProperties[] = [ }, ], default: 'AND', - description: 'This works only if two or more filters are provided. Defaults to AND', + description: + 'This works only if two or more filters are provided. Defaults to AND', }, { displayName: 'Search Term', @@ -439,11 +410,10 @@ export const operationFields: INodeProperties[] = [ name: 'field', type: 'options', default: '', - description: 'Field name to sort by. Choose from the list, or specify an ID using an expression.', + description: + 'Field name to sort by. Choose from the list, or specify an ID using an expression.', typeOptions: { - loadOptionsDependsOn: [ - 'tableId', - ], + loadOptionsDependsOn: ['tableId'], loadOptionsMethod: 'getTableFields', }, }, diff --git a/packages/nodes-base/nodes/Baserow/types.d.ts b/packages/nodes-base/nodes/Baserow/types.d.ts index 7999d82b0d934..bb340d3231e8e 100644 --- a/packages/nodes-base/nodes/Baserow/types.d.ts +++ b/packages/nodes-base/nodes/Baserow/types.d.ts @@ -2,14 +2,14 @@ export type BaserowCredentials = { username: string; password: string; host: string; -} +}; export type GetAllAdditionalOptions = { order?: { fields: Array<{ field: string; direction: string; - }> + }>; }; filters?: { fields: Array<{ @@ -18,20 +18,20 @@ export type GetAllAdditionalOptions = { value: string; }>; }; - filterType: string, - search: string, + filterType: string; + search: string; }; export type LoadedResource = { id: number; name: string; -} +}; export type Accumulator = { [key: string]: string; -} +}; -export type Row = Record +export type Row = Record; export type FieldsUiValues = Array<{ fieldId: string; diff --git a/packages/nodes-base/nodes/Beeminder/Beeminder.node.functions.ts b/packages/nodes-base/nodes/Beeminder/Beeminder.node.functions.ts index 3984b4cf4acc6..8a8b61f8ec8c8 100644 --- a/packages/nodes-base/nodes/Beeminder/Beeminder.node.functions.ts +++ b/packages/nodes-base/nodes/Beeminder/Beeminder.node.functions.ts @@ -1,21 +1,13 @@ -import { - IExecuteFunctions, - ILoadOptionsFunctions -} from 'n8n-core'; - -import { - IDataObject, - IHookFunctions, - IWebhookFunctions, - NodeOperationError, -} from 'n8n-workflow'; - -import { - beeminderApiRequest, - beeminderApiRequestAllItems, -} from './GenericFunctions'; - -export async function createDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) { +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; + +import { IDataObject, IHookFunctions, IWebhookFunctions, NodeOperationError } from 'n8n-workflow'; + +import { beeminderApiRequest, beeminderApiRequestAllItems } from './GenericFunctions'; + +export async function createDatapoint( + this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, + data: IDataObject, +) { const credentials = await this.getCredentials('beeminderApi'); const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints.json`; @@ -23,7 +15,10 @@ export async function createDatapoint(this: IExecuteFunctions | IWebhookFunction return await beeminderApiRequest.call(this, 'POST', endpoint, data); } -export async function getAllDatapoints(this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) { +export async function getAllDatapoints( + this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, + data: IDataObject, +) { const credentials = await this.getCredentials('beeminderApi'); const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints.json`; @@ -35,7 +30,10 @@ export async function getAllDatapoints(this: IExecuteFunctions | IHookFunctions return await beeminderApiRequestAllItems.call(this, 'GET', endpoint, {}, data); } -export async function updateDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) { +export async function updateDatapoint( + this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, + data: IDataObject, +) { const credentials = await this.getCredentials('beeminderApi'); const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints/${data.datapointId}.json`; @@ -43,11 +41,13 @@ export async function updateDatapoint(this: IExecuteFunctions | IWebhookFunction return await beeminderApiRequest.call(this, 'PUT', endpoint, data); } -export async function deleteDatapoint(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, data: IDataObject) { +export async function deleteDatapoint( + this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, + data: IDataObject, +) { const credentials = await this.getCredentials('beeminderApi'); const endpoint = `/users/${credentials.user}/goals/${data.goalName}/datapoints/${data.datapointId}.json`; return await beeminderApiRequest.call(this, 'DELETE', endpoint); } - diff --git a/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts b/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts index 0ba75b9d09289..4b76745800604 100644 --- a/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts +++ b/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -17,12 +15,10 @@ import { createDatapoint, deleteDatapoint, getAllDatapoints, - updateDatapoint + updateDatapoint, } from './Beeminder.node.functions'; -import { - beeminderApiRequest, -} from './GenericFunctions'; +import { beeminderApiRequest } from './GenericFunctions'; import moment from 'moment-timezone'; @@ -105,13 +101,12 @@ export class Beeminder implements INodeType { }, displayOptions: { show: { - resource: [ - 'datapoint', - ], + resource: ['datapoint'], }, }, default: '', - description: 'The name of the goal. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the goal. Choose from the list, or specify an ID using an expression.', required: true, }, { @@ -120,12 +115,8 @@ export class Beeminder implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'datapoint', - ], + operation: ['getAll'], + resource: ['datapoint'], }, }, default: false, @@ -137,15 +128,9 @@ export class Beeminder implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'datapoint', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['datapoint'], + returnAll: [false], }, }, typeOptions: { @@ -164,12 +149,8 @@ export class Beeminder implements INodeType { description: 'Datapoint value to send', displayOptions: { show: { - resource: [ - 'datapoint', - ], - operation: [ - 'create', - ], + resource: ['datapoint'], + operation: ['create'], }, }, required: true, @@ -181,10 +162,7 @@ export class Beeminder implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'update', - 'delete', - ], + operation: ['update', 'delete'], }, }, required: true, @@ -197,12 +175,8 @@ export class Beeminder implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'datapoint', - ], - operation: [ - 'create', - ], + resource: ['datapoint'], + operation: ['create'], }, }, options: [ @@ -218,7 +192,8 @@ export class Beeminder implements INodeType { type: 'dateTime', default: '', placeholder: '', - description: 'Defaults to "now" if none is passed in, or the existing timestamp if the datapoint is being updated rather than created', + description: + 'Defaults to "now" if none is passed in, or the existing timestamp if the datapoint is being updated rather than created', }, { displayName: 'Request ID', @@ -238,12 +213,8 @@ export class Beeminder implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'datapoint', - ], - operation: [ - 'getAll', - ], + resource: ['datapoint'], + operation: ['getAll'], }, }, options: [ @@ -265,12 +236,8 @@ export class Beeminder implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'datapoint', - ], - operation: [ - 'update', - ], + resource: ['datapoint'], + operation: ['update'], }, }, options: [ @@ -294,7 +261,8 @@ export class Beeminder implements INodeType { type: 'dateTime', default: '', placeholder: '', - description: 'Defaults to "now" if none is passed in, or the existing timestamp if the datapoint is being updated rather than created', + description: + 'Defaults to "now" if none is passed in, or the existing timestamp if the datapoint is being updated rather than created', }, ], }, @@ -306,7 +274,6 @@ export class Beeminder implements INodeType { // Get all the available groups to display them to user so that he can // select them easily async getGoals(this: ILoadOptionsFunctions): Promise { - const credentials = await this.getCredentials('beeminderApi'); const endpoint = `/users/${credentials.user}/goals.json`; @@ -325,7 +292,6 @@ export class Beeminder implements INodeType { }; async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); const returnData: IDataObject[] = []; const length = items.length; @@ -335,7 +301,6 @@ export class Beeminder implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; let results; - for (let i = 0; i < length; i++) { try { if (resource === 'datapoint') { @@ -353,8 +318,7 @@ export class Beeminder implements INodeType { data.timestamp = moment.tz(data.timestamp, timezone).unix(); } results = await createDatapoint.call(this, data); - } - else if (operation === 'getAll') { + } else if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; const options = this.getNodeParameter('options', i) as INodeParameters; const data: IDataObject = { @@ -367,8 +331,7 @@ export class Beeminder implements INodeType { } results = await getAllDatapoints.call(this, data); - } - else if (operation === 'update') { + } else if (operation === 'update') { const datapointId = this.getNodeParameter('datapointId', i) as string; const options = this.getNodeParameter('updateFields', i) as INodeParameters; const data: IDataObject = { @@ -380,8 +343,7 @@ export class Beeminder implements INodeType { data.timestamp = moment.tz(data.timestamp, timezone).unix(); } results = await updateDatapoint.call(this, data); - } - else if (operation === 'delete') { + } else if (operation === 'delete') { const datapointId = this.getNodeParameter('datapointId', i) as string; const data: IDataObject = { goalName, @@ -407,4 +369,3 @@ export class Beeminder implements INodeType { return [this.helpers.returnJsonArray(returnData)]; } } - diff --git a/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts b/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts index cc8162fbd6d51..9ea2b43e6abd1 100644 --- a/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts @@ -1,24 +1,21 @@ -import { - OptionsWithUri, -} from 'request'; - -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; - -import { - IDataObject, - IHookFunctions, - IWebhookFunctions, - NodeApiError, -} from 'n8n-workflow'; +import { OptionsWithUri } from 'request'; -const BEEMINDER_URI = 'https://www.beeminder.com/api/v1'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; + +import { IDataObject, IHookFunctions, IWebhookFunctions, NodeApiError } from 'n8n-workflow'; -export async function beeminderApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any +const BEEMINDER_URI = 'https://www.beeminder.com/api/v1'; - const credentials = await this.getCredentials('beeminderApi') as IDataObject; +export async function beeminderApiRequest( + this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { + const credentials = (await this.getCredentials('beeminderApi')) as IDataObject; Object.assign(body, { auth_token: credentials.authToken }); @@ -45,8 +42,15 @@ export async function beeminderApiRequest(this: IExecuteFunctions | IWebhookFunc } } -export async function beeminderApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function beeminderApiRequestAllItems( + 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; @@ -55,9 +59,7 @@ export async function beeminderApiRequestAllItems(this: IExecuteFunctions | ILoa responseData = await beeminderApiRequest.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/Bitbucket/BitbucketTrigger.node.ts b/packages/nodes-base/nodes/Bitbucket/BitbucketTrigger.node.ts index efbfe5f4bbfb6..a8741631016f5 100644 --- a/packages/nodes-base/nodes/Bitbucket/BitbucketTrigger.node.ts +++ b/packages/nodes-base/nodes/Bitbucket/BitbucketTrigger.node.ts @@ -1,9 +1,6 @@ import { OptionsWithUri } from 'request'; -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -17,10 +14,7 @@ import { IWebhookResponseData, } from 'n8n-workflow'; -import { - bitbucketApiRequest, - bitbucketApiRequestAllItems, -} from './GenericFunctions'; +import { bitbucketApiRequest, bitbucketApiRequestAllItems } from './GenericFunctions'; export class BitbucketTrigger implements INodeType { description: INodeTypeDescription = { @@ -75,10 +69,7 @@ export class BitbucketTrigger implements INodeType { type: 'options', displayOptions: { show: { - resource: [ - 'workspace', - 'repository', - ], + resource: ['workspace', 'repository'], }, }, typeOptions: { @@ -86,7 +77,8 @@ export class BitbucketTrigger implements INodeType { }, required: true, default: '', - description: 'The repository of which to listen to the events. Choose from the list, or specify an ID using an expression.', + description: + 'The repository of which to listen to the events. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Event Names or IDs', @@ -94,9 +86,7 @@ export class BitbucketTrigger implements INodeType { type: 'multiOptions', displayOptions: { show: { - resource: [ - 'workspace', - ], + resource: ['workspace'], }, }, typeOptions: { @@ -105,7 +95,8 @@ export class BitbucketTrigger implements INodeType { options: [], required: true, default: [], - description: 'The events to listen to. Choose from the list, or specify IDs using an expression.', + description: + 'The events to listen to. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Repository Name or ID', @@ -113,20 +104,17 @@ export class BitbucketTrigger implements INodeType { type: 'options', displayOptions: { show: { - resource: [ - 'repository', - ], + resource: ['repository'], }, }, typeOptions: { loadOptionsMethod: 'getRepositories', - loadOptionsDependsOn: [ - 'workspace', - ], + loadOptionsDependsOn: ['workspace'], }, required: true, default: '', - description: 'The repository of which to listen to the events. Choose from the list, or specify an ID using an expression.', + description: + 'The repository of which to listen to the events. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Event Names or IDs', @@ -134,9 +122,7 @@ export class BitbucketTrigger implements INodeType { type: 'multiOptions', displayOptions: { show: { - resource: [ - 'repository', - ], + resource: ['repository'], }, }, typeOptions: { @@ -145,15 +131,18 @@ export class BitbucketTrigger implements INodeType { options: [], required: true, default: [], - description: 'The events to listen to. Choose from the list, or specify IDs using an expression.', + description: + 'The events to listen to. Choose from the list, or specify IDs using an expression.', }, ], - }; methods = { credentialTest: { - async bitbucketApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { + async bitbucketApiTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { const credentials = credential.data; const options: OptionsWithUri = { @@ -190,7 +179,12 @@ export class BitbucketTrigger implements INodeType { loadOptions: { async getWorkspaceEvents(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const events = await bitbucketApiRequestAllItems.call(this, 'values', 'GET', '/hook_events/workspace'); + const events = await bitbucketApiRequestAllItems.call( + this, + 'values', + 'GET', + '/hook_events/workspace', + ); for (const event of events) { returnData.push({ name: event.event, @@ -202,7 +196,12 @@ export class BitbucketTrigger implements INodeType { }, async getRepositoriesEvents(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const events = await bitbucketApiRequestAllItems.call(this, 'values', 'GET', '/hook_events/repository'); + const events = await bitbucketApiRequestAllItems.call( + this, + 'values', + 'GET', + '/hook_events/repository', + ); for (const event of events) { returnData.push({ name: event.event, @@ -215,7 +214,12 @@ export class BitbucketTrigger implements INodeType { async getRepositories(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const workspace = this.getCurrentNodeParameter('workspace') as string; - const repositories = await bitbucketApiRequestAllItems.call(this, 'values', 'GET', `/repositories/${workspace}`); + const repositories = await bitbucketApiRequestAllItems.call( + this, + 'values', + 'GET', + `/repositories/${workspace}`, + ); for (const repository of repositories) { returnData.push({ name: repository.slug, @@ -227,7 +231,12 @@ export class BitbucketTrigger implements INodeType { }, async getWorkspaces(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const workspaces = await bitbucketApiRequestAllItems.call(this, 'values', 'GET', `/workspaces`); + const workspaces = await bitbucketApiRequestAllItems.call( + this, + 'values', + 'GET', + `/workspaces`, + ); for (const workspace of workspaces) { returnData.push({ name: workspace.name, @@ -320,9 +329,7 @@ export class BitbucketTrigger implements INodeType { return {}; } return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts b/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts index af6d52d9b1eee..16d24b68e1689 100644 --- a/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts @@ -5,9 +5,19 @@ import { IHookFunctions, ILoadOptionsFunctions, } from 'n8n-core'; -import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function bitbucketApiRequest(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 bitbucketApiRequest( + 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('bitbucketApi'); let options: OptionsWithUri = { method, @@ -17,7 +27,7 @@ export async function bitbucketApiRequest(this: IHookFunctions | IExecuteFunctio }, qs, body, - uri: uri ||`https://api.bitbucket.org/2.0${resource}`, + uri: uri || `https://api.bitbucket.org/2.0${resource}`, json: true, }; options = Object.assign({}, options, option); @@ -36,8 +46,16 @@ export async function bitbucketApiRequest(this: IHookFunctions | IExecuteFunctio * Make an API request to paginated flow endpoint * and return all results */ -export async function bitbucketApiRequestAllItems(this: IHookFunctions | IExecuteFunctions| ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function bitbucketApiRequestAllItems( + 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; @@ -48,9 +66,7 @@ export async function bitbucketApiRequestAllItems(this: IHookFunctions | IExecut responseData = await bitbucketApiRequest.call(this, method, resource, body, query, uri); uri = responseData.next; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData.next !== undefined - ); + } while (responseData.next !== undefined); return returnData; } diff --git a/packages/nodes-base/nodes/Bitly/Bitly.node.ts b/packages/nodes-base/nodes/Bitly/Bitly.node.ts index 61d1cfb9a86f3..5334954f56b14 100644 --- a/packages/nodes-base/nodes/Bitly/Bitly.node.ts +++ b/packages/nodes-base/nodes/Bitly/Bitly.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 { - linkFields, - linkOperations -} from './LinkDescription'; +import { linkFields, linkOperations } from './LinkDescription'; -import { - bitlyApiRequest, - bitlyApiRequestAllItems, -} from './GenericFunctions'; +import { bitlyApiRequest, bitlyApiRequestAllItems } from './GenericFunctions'; export class Bitly implements INodeType { description: INodeTypeDescription = { @@ -41,9 +33,7 @@ export class Bitly implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -52,9 +42,7 @@ export class Bitly implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -116,7 +104,12 @@ export class Bitly implements INodeType { async getTags(this: ILoadOptionsFunctions): Promise { const groupId = this.getCurrentNodeParameter('group') as string; const returnData: INodePropertyOptions[] = []; - const tags = await bitlyApiRequestAllItems.call(this, 'tags', 'GET', `groups/${groupId}/tags`); + const tags = await bitlyApiRequestAllItems.call( + this, + 'tags', + 'GET', + `groups/${groupId}/tags`, + ); for (const tag of tags) { const tagName = tag; const tagId = tag; @@ -159,7 +152,8 @@ export class Bitly implements INodeType { if (additionalFields.tags) { body.tags = additionalFields.tags as string[]; } - const deeplinks = (this.getNodeParameter('deeplink', i) as IDataObject).deeplinkUi as IDataObject[]; + const deeplinks = (this.getNodeParameter('deeplink', i) as IDataObject) + .deeplinkUi as IDataObject[]; if (deeplinks) { for (const deeplink of deeplinks) { //@ts-ignore @@ -192,7 +186,8 @@ export class Bitly implements INodeType { if (updateFields.tags) { body.tags = updateFields.tags as string[]; } - const deeplinks = (this.getNodeParameter('deeplink', i) as IDataObject).deeplinkUi as IDataObject[]; + const deeplinks = (this.getNodeParameter('deeplink', i) as IDataObject) + .deeplinkUi as IDataObject[]; if (deeplinks) { for (const deeplink of deeplinks) { //@ts-ignore diff --git a/packages/nodes-base/nodes/Bitly/GenericFunctions.ts b/packages/nodes-base/nodes/Bitly/GenericFunctions.ts index ec7fd9242ffb2..a6f6df142b596 100644 --- a/packages/nodes-base/nodes/Bitly/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitly/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, - } from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,18 +7,26 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, - } from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function bitlyApiRequest(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 bitlyApiRequest( + 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) as string; let options: OptionsWithUri = { headers: {}, method, qs, body, - uri: uri ||`https://api-ssl.bitly.com/v4${resource}`, + uri: uri || `https://api-ssl.bitly.com/v4${resource}`, json: true, }; options = Object.assign({}, options, option); @@ -28,17 +34,18 @@ export async function bitlyApiRequest(this: IHookFunctions | IExecuteFunctions | delete options.body; } - try{ + try { if (authenticationMethod === 'accessToken') { const credentials = await this.getCredentials('bitlyApi'); - options.headers = { Authorization: `Bearer ${credentials.accessToken}`}; + options.headers = { Authorization: `Bearer ${credentials.accessToken}` }; return await this.helpers.request!(options); } else { - - return await this.helpers.requestOAuth2!.call(this, 'bitlyOAuth2Api', options, { tokenType: 'Bearer' }); + return await this.helpers.requestOAuth2!.call(this, 'bitlyOAuth2Api', options, { + tokenType: 'Bearer', + }); } - } catch(error) { + } catch (error) { throw new NodeApiError(this.getNode(), error); } } @@ -47,8 +54,16 @@ export async function bitlyApiRequest(this: IHookFunctions | IExecuteFunctions | * Make an API request to paginated flow endpoint * and return all results */ -export async function bitlyApiRequestAllItems(this: IHookFunctions | IExecuteFunctions| ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function bitlyApiRequestAllItems( + 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; @@ -61,9 +76,6 @@ export async function bitlyApiRequestAllItems(this: IHookFunctions | IExecuteFun if (responseData.pagination && responseData.pagination.next) { uri = responseData.pagination.next; } - } while ( - responseData.pagination !== undefined && - responseData.pagination.next !== undefined - ); + } while (responseData.pagination !== undefined && responseData.pagination.next !== undefined); return returnData; } diff --git a/packages/nodes-base/nodes/Bitly/LinkDescription.ts b/packages/nodes-base/nodes/Bitly/LinkDescription.ts index 7e55b0c51c5ac..60ff959d9e17c 100644 --- a/packages/nodes-base/nodes/Bitly/LinkDescription.ts +++ b/packages/nodes-base/nodes/Bitly/LinkDescription.ts @@ -8,9 +8,7 @@ export const linkOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'link', - ], + resource: ['link'], }, }, options: [ @@ -38,22 +36,17 @@ export const linkOperations: INodeProperties[] = [ ]; export const linkFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* link:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* link:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Long URL', name: 'longUrl', type: 'string', displayOptions: { show: { - resource: [ - 'link', - ], - operation: [ - 'create', - ], + resource: ['link'], + operation: ['create'], }, }, default: '', @@ -68,12 +61,8 @@ export const linkFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'link', - ], - operation: [ - 'create', - ], + resource: ['link'], + operation: ['create'], }, }, options: [ @@ -87,7 +76,8 @@ export const linkFields: INodeProperties[] = [ displayName: 'Group Name or ID', name: 'group', type: 'options', - 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', @@ -97,13 +87,12 @@ export const linkFields: 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', default: [], typeOptions: { loadOptionsMethod: 'getTags', - loadOptionsDependsOn: [ - 'group', - ], + loadOptionsDependsOn: ['group'], }, }, { @@ -124,12 +113,8 @@ export const linkFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'link', - ], - operation: [ - 'create', - ], + resource: ['link'], + operation: ['create'], }, }, default: {}, @@ -166,9 +151,9 @@ export const linkFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* link:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* link:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'Bitlink', name: 'id', @@ -178,12 +163,8 @@ export const linkFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'link', - ], - operation: [ - 'update', - ], + resource: ['link'], + operation: ['update'], }, }, }, @@ -195,12 +176,8 @@ export const linkFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'link', - ], - operation: [ - 'update', - ], + resource: ['link'], + operation: ['update'], }, }, options: [ @@ -214,7 +191,8 @@ export const linkFields: INodeProperties[] = [ displayName: 'Group Name or ID', name: 'group', type: 'options', - 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', @@ -230,13 +208,12 @@ export const linkFields: 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', default: [], typeOptions: { loadOptionsMethod: 'getTags', - loadOptionsDependsOn: [ - 'group', - ], + loadOptionsDependsOn: ['group'], }, }, { @@ -257,12 +234,8 @@ export const linkFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'link', - ], - operation: [ - 'update', - ], + resource: ['link'], + operation: ['update'], }, }, default: {}, @@ -299,9 +272,9 @@ export const linkFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* link:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* link:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Bitlink', name: 'id', @@ -311,12 +284,8 @@ export const linkFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'link', - ], - operation: [ - 'get', - ], + resource: ['link'], + operation: ['get'], }, }, }, diff --git a/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts b/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts index 0ddec67dadf09..e98f60f5a1c50 100644 --- a/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts +++ b/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -24,10 +22,7 @@ import { CollectionUpdateFields, } from './descriptions/CollectionDescription'; -import { - eventFields, - eventOperations, -} from './descriptions/EventDescription'; +import { eventFields, eventOperations } from './descriptions/EventDescription'; import { GroupCreationAdditionalFields, @@ -43,10 +38,7 @@ import { MemberUpdateFields, } from './descriptions/MemberDescription'; -import { - isEmpty, - partialRight, -} from 'lodash'; +import { isEmpty, partialRight } from 'lodash'; export class Bitwarden implements INodeType { description: INodeTypeDescription = { @@ -131,15 +123,12 @@ export class Bitwarden implements INodeType { const handleGetAll = partialRight(tokenlessHandleGetAll, token); for (let i = 0; i < items.length; i++) { - if (resource === 'collection') { - // ********************************************************************* // collection // ********************************************************************* if (operation === 'delete') { - // ---------------------------------- // collection: delete // ---------------------------------- @@ -148,9 +137,7 @@ export class Bitwarden implements INodeType { const endpoint = `/public/collections/${id}`; responseData = await bitwardenApiRequest.call(this, 'DELETE', endpoint, {}, {}); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------- // collection: get // ---------------------------------- @@ -158,18 +145,14 @@ export class Bitwarden implements INodeType { const id = this.getNodeParameter('collectionId', i); const endpoint = `/public/collections/${id}`; responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {}); - } else if (operation === 'getAll') { - // ---------------------------------- // collection: getAll // ---------------------------------- const endpoint = '/public/collections'; responseData = await handleGetAll.call(this, i, 'GET', endpoint, {}, {}); - } else if (operation === 'update') { - // ---------------------------------- // collection: update // ---------------------------------- @@ -177,7 +160,11 @@ export class Bitwarden implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as CollectionUpdateFields; 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 { groups, externalId } = updateFields; @@ -198,17 +185,13 @@ export class Bitwarden implements INodeType { const id = this.getNodeParameter('collectionId', i); const endpoint = `/public/collections/${id}`; responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body); - } - } else if (resource === 'event') { - // ********************************************************************* // event // ********************************************************************* if (operation === 'getAll') { - // ---------------------------------- // event: getAll // ---------------------------------- @@ -217,17 +200,13 @@ export class Bitwarden implements INodeType { const qs = isEmpty(filters) ? {} : filters; const endpoint = '/public/events'; responseData = await handleGetAll.call(this, i, 'GET', endpoint, qs, {}); - } - } else if (resource === 'group') { - // ********************************************************************* // group // ********************************************************************* if (operation === 'create') { - // ---------------------------------- // group: create // ---------------------------------- @@ -237,10 +216,10 @@ export class Bitwarden implements INodeType { AccessAll: this.getNodeParameter('accessAll', i), } as IDataObject; - const { - collections, - externalId, - } = this.getNodeParameter('additionalFields', i) as GroupCreationAdditionalFields; + const { collections, externalId } = this.getNodeParameter( + 'additionalFields', + i, + ) as GroupCreationAdditionalFields; if (collections) { body.collections = collections.map((collectionId) => ({ @@ -255,9 +234,7 @@ export class Bitwarden implements INodeType { const endpoint = '/public/groups'; responseData = await bitwardenApiRequest.call(this, 'POST', endpoint, {}, body); - } else if (operation === 'delete') { - // ---------------------------------- // group: delete // ---------------------------------- @@ -266,9 +243,7 @@ export class Bitwarden implements INodeType { const endpoint = `/public/groups/${id}`; responseData = await bitwardenApiRequest.call(this, 'DELETE', endpoint, {}, {}); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------- // group: get // ---------------------------------- @@ -276,18 +251,14 @@ export class Bitwarden implements INodeType { const id = this.getNodeParameter('groupId', i); const endpoint = `/public/groups/${id}`; responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {}); - } else if (operation === 'getAll') { - // ---------------------------------- // group: getAll // ---------------------------------- const endpoint = '/public/groups'; responseData = await handleGetAll.call(this, i, 'GET', endpoint, {}, {}); - } else if (operation === 'getMembers') { - // ---------------------------------- // group: getMembers // ---------------------------------- @@ -296,9 +267,7 @@ export class Bitwarden implements INodeType { const endpoint = `/public/groups/${id}/member-ids`; responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData.map((memberId: string) => ({ memberId })); - } else if (operation === 'update') { - // ---------------------------------- // group: update // ---------------------------------- @@ -308,7 +277,11 @@ export class Bitwarden implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as GroupUpdateFields; 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 }, + ); } // set defaults for `name` and `accessAll`, required by Bitwarden but optional in n8n @@ -316,7 +289,13 @@ export class Bitwarden implements INodeType { let { name, accessAll } = updateFields; if (name === undefined) { - responseData = await bitwardenApiRequest.call(this, 'GET', `/public/groups/${groupId}`, {}, {}) as { name: string }; + responseData = (await bitwardenApiRequest.call( + this, + 'GET', + `/public/groups/${groupId}`, + {}, + {}, + )) as { name: string }; name = responseData.name; } @@ -344,9 +323,7 @@ export class Bitwarden implements INodeType { const endpoint = `/public/groups/${groupId}`; responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body); - } else if (operation === 'updateMembers') { - // ---------------------------------- // group: updateMembers // ---------------------------------- @@ -362,15 +339,12 @@ export class Bitwarden implements INodeType { responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body); responseData = { success: true }; } - } else if (resource === 'member') { - // ********************************************************************* // member // ********************************************************************* if (operation === 'create') { - // ---------------------------------- // member: create // ---------------------------------- @@ -381,10 +355,10 @@ export class Bitwarden implements INodeType { AccessAll: this.getNodeParameter('accessAll', i), } as IDataObject; - const { - collections, - externalId, - } = this.getNodeParameter('additionalFields', i) as MemberCreationAdditionalFields; + const { collections, externalId } = this.getNodeParameter( + 'additionalFields', + i, + ) as MemberCreationAdditionalFields; if (collections) { body.collections = collections.map((collectionId) => ({ @@ -399,9 +373,7 @@ export class Bitwarden implements INodeType { const endpoint = '/public/members/'; responseData = await bitwardenApiRequest.call(this, 'POST', endpoint, {}, body); - } else if (operation === 'delete') { - // ---------------------------------- // member: delete // ---------------------------------- @@ -410,9 +382,7 @@ export class Bitwarden implements INodeType { const endpoint = `/public/members/${id}`; responseData = await bitwardenApiRequest.call(this, 'DELETE', endpoint, {}, {}); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------- // member: get // ---------------------------------- @@ -420,18 +390,14 @@ export class Bitwarden implements INodeType { const id = this.getNodeParameter('memberId', i); const endpoint = `/public/members/${id}`; responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {}); - } else if (operation === 'getAll') { - // ---------------------------------- // member: getAll // ---------------------------------- const endpoint = '/public/members'; responseData = await handleGetAll.call(this, i, 'GET', endpoint, {}, {}); - } else if (operation === 'getGroups') { - // ---------------------------------- // member: getGroups // ---------------------------------- @@ -440,9 +406,7 @@ export class Bitwarden implements INodeType { const endpoint = `/public/members/${id}/group-ids`; responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData.map((groupId: string) => ({ groupId })); - } else if (operation === 'update') { - // ---------------------------------- // member: update // ---------------------------------- @@ -452,7 +416,11 @@ export class Bitwarden implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as MemberUpdateFields; 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 { accessAll, collections, externalId, type } = updateFields; @@ -479,9 +447,7 @@ export class Bitwarden implements INodeType { const id = this.getNodeParameter('memberId', i); const endpoint = `/public/members/${id}`; responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body); - } else if (operation === 'updateGroups') { - // ---------------------------------- // member: updateGroups // ---------------------------------- diff --git a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts index dd9891c72127d..97241605d141a 100644 --- a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -9,9 +7,7 @@ import { NodeApiError, } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; /** * Make an authenticated API request to Bitwarden. @@ -23,8 +19,8 @@ export async function bitwardenApiRequest( qs: IDataObject, body: IDataObject, token: string, -): Promise { // tslint:disable-line:no-any - + // tslint:disable-next-line:no-any +): Promise { const baseUrl = await getBaseUrl.call(this); const options: OptionsWithUri = { headers: { @@ -59,8 +55,8 @@ export async function bitwardenApiRequest( */ export async function getAccessToken( this: IExecuteFunctions | ILoadOptionsFunctions, -): Promise { // tslint:disable-line:no-any - + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('bitwardenApi'); const options: OptionsWithUri = { @@ -115,13 +111,12 @@ export async function handleGetAll( /** * Return the access token URL based on the user's environment. */ - async function getTokenUrl(this: IExecuteFunctions | ILoadOptionsFunctions) { +async function getTokenUrl(this: IExecuteFunctions | ILoadOptionsFunctions) { const { environment, domain } = await this.getCredentials('bitwardenApi'); return environment === 'cloudHosted' ? 'https://identity.bitwarden.com/connect/token' : `${domain}/identity/connect/token`; - } /** @@ -130,26 +125,20 @@ export async function handleGetAll( async function getBaseUrl(this: IExecuteFunctions | ILoadOptionsFunctions) { const { environment, domain } = await this.getCredentials('bitwardenApi'); - return environment === 'cloudHosted' - ? 'https://api.bitwarden.com' - : `${domain}/api`; - + return environment === 'cloudHosted' ? 'https://api.bitwarden.com' : `${domain}/api`; } /** * Load a resource so that it can be selected by name from a dropdown. */ -export async function loadResource( - this: ILoadOptionsFunctions, - resource: string, -) { +export async function loadResource(this: ILoadOptionsFunctions, resource: string) { const returnData: INodePropertyOptions[] = []; const token = await getAccessToken.call(this); const endpoint = `/public/${resource}`; const { data } = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {}, token); - data.forEach(({ id, name, externalId }: { id: string, name: string, externalId?: string }) => { + data.forEach(({ id, name, externalId }: { id: string; name: string; externalId?: string }) => { returnData.push({ name: externalId || name || id, value: id, diff --git a/packages/nodes-base/nodes/Bitwarden/descriptions/CollectionDescription.ts b/packages/nodes-base/nodes/Bitwarden/descriptions/CollectionDescription.ts index d887b6c1243f6..45907d487f7fd 100644 --- a/packages/nodes-base/nodes/Bitwarden/descriptions/CollectionDescription.ts +++ b/packages/nodes-base/nodes/Bitwarden/descriptions/CollectionDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const collectionOperations: INodeProperties[] = [ { @@ -33,9 +31,7 @@ export const collectionOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'collection', - ], + resource: ['collection'], }, }, }, @@ -55,14 +51,8 @@ export const collectionFields: INodeProperties[] = [ placeholder: '5e59c8c7-e05a-4d17-8e85-acc301343926', displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'delete', - 'get', - 'update', - ], + resource: ['collection'], + operation: ['delete', 'get', 'update'], }, }, }, @@ -78,12 +68,8 @@ export const collectionFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'getAll', - ], + resource: ['collection'], + operation: ['getAll'], }, }, }, @@ -98,15 +84,9 @@ export const collectionFields: INodeProperties[] = [ description: 'Max number of results to return', displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['collection'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -126,7 +106,8 @@ export const collectionFields: INodeProperties[] = [ displayName: 'Group Names or IDs', name: 'groups', type: 'multiOptions', - description: 'The group to assign this collection to. Choose from the list, or specify IDs using an expression.', + description: + 'The group to assign this collection to. Choose from the list, or specify IDs using an expression.', default: [], typeOptions: { loadOptionsMethod: 'getGroups', @@ -142,12 +123,8 @@ export const collectionFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'update', - ], + resource: ['collection'], + operation: ['update'], }, }, }, diff --git a/packages/nodes-base/nodes/Bitwarden/descriptions/EventDescription.ts b/packages/nodes-base/nodes/Bitwarden/descriptions/EventDescription.ts index 6d9ea6c57e3eb..32155722303dc 100644 --- a/packages/nodes-base/nodes/Bitwarden/descriptions/EventDescription.ts +++ b/packages/nodes-base/nodes/Bitwarden/descriptions/EventDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const eventOperations: INodeProperties[] = [ { @@ -18,15 +16,12 @@ export const eventOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'event', - ], + resource: ['event'], }, }, }, ]; - export const eventFields: INodeProperties[] = [ // ---------------------------------- // event: getAll @@ -39,12 +34,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'], }, }, }, @@ -59,15 +50,9 @@ export const eventFields: INodeProperties[] = [ description: 'Max number of results to return', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['event'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -111,12 +96,8 @@ export const eventFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'getAll', - ], + resource: ['event'], + operation: ['getAll'], }, }, }, diff --git a/packages/nodes-base/nodes/Bitwarden/descriptions/GroupDescription.ts b/packages/nodes-base/nodes/Bitwarden/descriptions/GroupDescription.ts index bfa9eaab7fb1d..fef3e30228059 100644 --- a/packages/nodes-base/nodes/Bitwarden/descriptions/GroupDescription.ts +++ b/packages/nodes-base/nodes/Bitwarden/descriptions/GroupDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const groupOperations: INodeProperties[] = [ { @@ -48,9 +46,7 @@ export const groupOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'group', - ], + resource: ['group'], }, }, }, @@ -70,16 +66,8 @@ export const groupFields: INodeProperties[] = [ placeholder: '5e59c8c7-e05a-4d17-8e85-acc301343926', displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'delete', - 'get', - 'getMembers', - 'update', - 'updateMembers', - ], + resource: ['group'], + operation: ['delete', 'get', 'getMembers', 'update', 'updateMembers'], }, }, }, @@ -95,12 +83,8 @@ export const groupFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'getAll', - ], + resource: ['group'], + operation: ['getAll'], }, }, }, @@ -115,15 +99,9 @@ export const groupFields: INodeProperties[] = [ description: 'Max number of results to return', displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['group'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -140,12 +118,8 @@ export const groupFields: INodeProperties[] = [ description: 'The name of the group to create', displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'create', - ], + resource: ['group'], + operation: ['create'], }, }, }, @@ -154,15 +128,12 @@ export const groupFields: INodeProperties[] = [ name: 'accessAll', type: 'boolean', default: false, - description: 'Whether to allow this group to access all collections within the organization, instead of only its associated collections. If set to true, this option overrides any collection assignments.', + description: + 'Whether to allow this group to access all collections within the organization, instead of only its associated collections. If set to true, this option overrides any collection assignments.', displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'create', - ], + resource: ['group'], + operation: ['create'], }, }, }, @@ -177,7 +148,8 @@ export const groupFields: INodeProperties[] = [ displayName: 'Collection Names or IDs', name: 'collections', type: 'multiOptions', - description: 'The collections to assign to this group. Choose from the list, or specify IDs using an expression.', + description: + 'The collections to assign to this group. Choose from the list, or specify IDs using an expression.', default: [], typeOptions: { loadOptionsMethod: 'getCollections', @@ -193,12 +165,8 @@ export const groupFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'create', - ], + resource: ['group'], + operation: ['create'], }, }, }, @@ -218,13 +186,15 @@ export const groupFields: INodeProperties[] = [ name: 'accessAll', type: 'boolean', default: false, - description: 'Whether to allow this group to access all collections within the organization, instead of only its associated collections. If set to true, this option overrides any collection assignments.', + description: + 'Whether to allow this group to access all collections within the organization, instead of only its associated collections. If set to true, this option overrides any collection assignments.', }, { displayName: 'Collection Names or IDs', name: 'collections', type: 'multiOptions', - description: 'The collections to assign to this group. Choose from the list, or specify IDs using an expression.', + description: + 'The collections to assign to this group. Choose from the list, or specify IDs using an expression.', default: [], typeOptions: { loadOptionsMethod: 'getCollections', @@ -247,12 +217,8 @@ export const groupFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'update', - ], + resource: ['group'], + operation: ['update'], }, }, }, @@ -268,12 +234,8 @@ export const groupFields: INodeProperties[] = [ description: 'Comma-separated list of IDs of members to set in a group', displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'updateMembers', - ], + resource: ['group'], + operation: ['updateMembers'], }, }, }, diff --git a/packages/nodes-base/nodes/Bitwarden/descriptions/MemberDescription.ts b/packages/nodes-base/nodes/Bitwarden/descriptions/MemberDescription.ts index 5d67637cef21e..6787199ac2287 100644 --- a/packages/nodes-base/nodes/Bitwarden/descriptions/MemberDescription.ts +++ b/packages/nodes-base/nodes/Bitwarden/descriptions/MemberDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const memberOperations: INodeProperties[] = [ { @@ -48,9 +46,7 @@ export const memberOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'member', - ], + resource: ['member'], }, }, }, @@ -70,16 +66,8 @@ export const memberFields: INodeProperties[] = [ placeholder: '5e59c8c7-e05a-4d17-8e85-acc301343926', displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'delete', - 'get', - 'getGroups', - 'update', - 'updateGroups', - ], + resource: ['member'], + operation: ['delete', 'get', 'getGroups', 'update', 'updateGroups'], }, }, }, @@ -109,12 +97,8 @@ export const memberFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'create', - ], + resource: ['member'], + operation: ['create'], }, }, }, @@ -129,12 +113,8 @@ export const memberFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'getAll', - ], + resource: ['member'], + operation: ['getAll'], }, }, }, @@ -149,15 +129,9 @@ export const memberFields: INodeProperties[] = [ description: 'Max number of results to return', displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['member'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -173,12 +147,8 @@ export const memberFields: INodeProperties[] = [ description: 'The email of the member to update', displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'create', - ], + resource: ['member'], + operation: ['create'], }, }, }, @@ -189,12 +159,8 @@ export const memberFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'create', - ], + resource: ['member'], + operation: ['create'], }, }, }, @@ -209,7 +175,8 @@ export const memberFields: INodeProperties[] = [ displayName: 'Collection Names or IDs', name: 'collections', type: 'multiOptions', - description: 'The collections to assign to this member. Choose from the list, or specify IDs using an expression.', + description: + 'The collections to assign to this member. Choose from the list, or specify IDs using an expression.', default: [], typeOptions: { loadOptionsMethod: 'getCollections', @@ -225,12 +192,8 @@ export const memberFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'create', - ], + resource: ['member'], + operation: ['create'], }, }, }, @@ -272,7 +235,8 @@ export const memberFields: INodeProperties[] = [ displayName: 'Collection Names or IDs', name: 'collections', type: 'multiOptions', - description: 'The collections to assign to this member. Choose from the list, or specify IDs using an expression.', + description: + 'The collections to assign to this member. Choose from the list, or specify IDs using an expression.', default: [], typeOptions: { loadOptionsMethod: 'getCollections', @@ -294,12 +258,8 @@ export const memberFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'update', - ], + resource: ['member'], + operation: ['update'], }, }, }, @@ -314,12 +274,8 @@ export const memberFields: INodeProperties[] = [ description: 'Comma-separated list of IDs of groups to set for a member', displayOptions: { show: { - resource: [ - 'member', - ], - operation: [ - 'updateGroups', - ], + resource: ['member'], + operation: ['updateGroups'], }, }, }, diff --git a/packages/nodes-base/nodes/Box/Box.node.ts b/packages/nodes-base/nodes/Box/Box.node.ts index abf9c91cabc59..1184412b78737 100644 --- a/packages/nodes-base/nodes/Box/Box.node.ts +++ b/packages/nodes-base/nodes/Box/Box.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryKeyData, @@ -11,26 +9,15 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - boxApiRequest, - boxApiRequestAllItems, -} from './GenericFunctions'; +import { boxApiRequest, boxApiRequestAllItems } from './GenericFunctions'; -import { - fileFields, - fileOperations, -} from './FileDescription'; +import { fileFields, fileOperations } from './FileDescription'; -import { - folderFields, - folderOperations, -} from './FolderDescription'; +import { folderFields, folderOperations } from './FolderDescription'; import moment from 'moment-timezone'; -import { - noCase, -} from 'change-case'; +import { noCase } from 'change-case'; export class Box implements INodeType { description: INodeTypeDescription = { @@ -110,7 +97,13 @@ export class Box implements INodeType { if (additionalFields.version) { body.version = additionalFields.version as string; } - responseData = await boxApiRequest.call(this, 'POST', `/files/${fileId}/copy`, body, qs); + responseData = await boxApiRequest.call( + this, + 'POST', + `/files/${fileId}/copy`, + body, + qs, + ); returnData.push(responseData as IDataObject); } @@ -124,14 +117,25 @@ export class Box implements INodeType { // https://developer.box.com/reference/get-files-id-content 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 boxApiRequest.call(this, 'GET', `/files/${fileId}`); const fileName = responseData.name; let mimeType: string | undefined; - responseData = await boxApiRequest.call(this, 'GET', `/files/${fileId}/content`, {}, {}, undefined, { encoding: null, resolveWithFullResponse: true }); + responseData = await boxApiRequest.call( + this, + 'GET', + `/files/${fileId}/content`, + {}, + {}, + undefined, + { encoding: null, resolveWithFullResponse: true }, + ); const newItem: INodeExecutionData = { json: items[i].json, @@ -153,7 +157,11 @@ export class Box 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://developer.box.com/reference/get-files-id if (operation === 'get') { @@ -180,23 +188,36 @@ export class Box implements INodeType { } if (additionalFields.createdRangeUi) { - const createdRangeValues = (additionalFields.createdRangeUi as IDataObject).createdRangeValuesUi as IDataObject; + const createdRangeValues = (additionalFields.createdRangeUi as IDataObject) + .createdRangeValuesUi as IDataObject; if (createdRangeValues) { - qs.created_at_range = `${moment.tz(createdRangeValues.from, timezone).format()},${moment.tz(createdRangeValues.to, timezone).format()}`; + qs.created_at_range = `${moment + .tz(createdRangeValues.from, timezone) + .format()},${moment.tz(createdRangeValues.to, timezone).format()}`; } delete qs.createdRangeUi; } if (additionalFields.updatedRangeUi) { - const updateRangeValues = (additionalFields.updatedRangeUi as IDataObject).updatedRangeValuesUi as IDataObject; + const updateRangeValues = (additionalFields.updatedRangeUi as IDataObject) + .updatedRangeValuesUi as IDataObject; if (updateRangeValues) { - qs.updated_at_range = `${moment.tz(updateRangeValues.from, timezone).format()},${moment.tz(updateRangeValues.to, timezone).format()}`; + qs.updated_at_range = `${moment + .tz(updateRangeValues.from, timezone) + .format()},${moment.tz(updateRangeValues.to, timezone).format()}`; } delete qs.updatedRangeUi; } if (returnAll) { - responseData = await boxApiRequestAllItems.call(this, 'entries', 'GET', `/search`, {}, qs); + responseData = await boxApiRequestAllItems.call( + this, + 'entries', + 'GET', + `/search`, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await boxApiRequest.call(this, 'GET', `/search`, {}, qs); @@ -211,13 +232,13 @@ export class Box implements INodeType { const accessibleBy = this.getNodeParameter('accessibleBy', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; // tslint:disable-next-line: no-any - const body: { accessible_by: IDataObject, [key: string]: any } = { + const body: { accessible_by: IDataObject; [key: string]: any } = { accessible_by: {}, item: { id: fileId, type: 'file', }, - role: (role === 'coOwner') ? 'co-owner' : noCase(role), + role: role === 'coOwner' ? 'co-owner' : noCase(role), ...options, }; @@ -268,15 +289,24 @@ export class Box 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 binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + i, + binaryPropertyName, + ); const body: IDataObject = {}; @@ -292,15 +322,24 @@ export class Box implements INodeType { }, }; - responseData = await boxApiRequest.call(this, 'POST', '', {}, {}, 'https://upload.box.com/api/2.0/files/content', { formData: body }); + responseData = await boxApiRequest.call( + this, + 'POST', + '', + {}, + {}, + 'https://upload.box.com/api/2.0/files/content', + { formData: body }, + ); returnData.push.apply(returnData, responseData.entries as IDataObject[]); - } else { const content = 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, + }); } attributes['name'] = fileName; @@ -316,7 +355,15 @@ export class Box implements INodeType { contentType: 'text/plain', }, }; - responseData = await boxApiRequest.call(this, 'POST', '', {}, {}, 'https://upload.box.com/api/2.0/files/content', { formData: body }); + responseData = await boxApiRequest.call( + this, + 'POST', + '', + {}, + {}, + 'https://upload.box.com/api/2.0/files/content', + { formData: body }, + ); returnData.push.apply(returnData, responseData.entries as IDataObject[]); } @@ -383,23 +430,36 @@ export class Box implements INodeType { } if (additionalFields.createdRangeUi) { - const createdRangeValues = (additionalFields.createdRangeUi as IDataObject).createdRangeValuesUi as IDataObject; + const createdRangeValues = (additionalFields.createdRangeUi as IDataObject) + .createdRangeValuesUi as IDataObject; if (createdRangeValues) { - qs.created_at_range = `${moment.tz(createdRangeValues.from, timezone).format()},${moment.tz(createdRangeValues.to, timezone).format()}`; + qs.created_at_range = `${moment + .tz(createdRangeValues.from, timezone) + .format()},${moment.tz(createdRangeValues.to, timezone).format()}`; } delete qs.createdRangeUi; } if (additionalFields.updatedRangeUi) { - const updateRangeValues = (additionalFields.updatedRangeUi as IDataObject).updatedRangeValuesUi as IDataObject; + const updateRangeValues = (additionalFields.updatedRangeUi as IDataObject) + .updatedRangeValuesUi as IDataObject; if (updateRangeValues) { - qs.updated_at_range = `${moment.tz(updateRangeValues.from, timezone).format()},${moment.tz(updateRangeValues.to, timezone).format()}`; + qs.updated_at_range = `${moment + .tz(updateRangeValues.from, timezone) + .format()},${moment.tz(updateRangeValues.to, timezone).format()}`; } delete qs.updatedRangeUi; } if (returnAll) { - responseData = await boxApiRequestAllItems.call(this, 'entries', 'GET', `/search`, {}, qs); + responseData = await boxApiRequestAllItems.call( + this, + 'entries', + 'GET', + `/search`, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await boxApiRequest.call(this, 'GET', `/search`, {}, qs); @@ -414,13 +474,13 @@ export class Box implements INodeType { const accessibleBy = this.getNodeParameter('accessibleBy', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; // tslint:disable-next-line: no-any - const body: { accessible_by: IDataObject, [key: string]: any } = { + const body: { accessible_by: IDataObject; [key: string]: any } = { accessible_by: {}, item: { id: folderId, type: 'folder', }, - role: (role === 'coOwner') ? 'co-owner' : noCase(role), + role: role === 'coOwner' ? 'co-owner' : noCase(role), ...options, }; diff --git a/packages/nodes-base/nodes/Box/BoxTrigger.node.ts b/packages/nodes-base/nodes/Box/BoxTrigger.node.ts index 15a2da802d17f..5179f05339132 100644 --- a/packages/nodes-base/nodes/Box/BoxTrigger.node.ts +++ b/packages/nodes-base/nodes/Box/BoxTrigger.node.ts @@ -1,18 +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 { - boxApiRequest, - boxApiRequestAllItems, -} from './GenericFunctions'; +import { boxApiRequest, boxApiRequestAllItems } from './GenericFunctions'; export class BoxTrigger implements INodeType { description: INodeTypeDescription = { @@ -191,12 +181,14 @@ export class BoxTrigger implements INodeType { { name: 'Metadata Instance Deleted', value: 'METADATA_INSTANCE.DELETED', - description: 'An existing metadata template instance associated with a file or folder is deleted', + description: + 'An existing metadata template instance associated with a file or folder is deleted', }, { name: 'Metadata Instance Updated', value: 'METADATA_INSTANCE.UPDATED', - description: 'An attribute (value) is updated/deleted for an existing metadata template instance associated with a file or folder', + description: + 'An attribute (value) is updated/deleted for an existing metadata template instance associated with a file or folder', }, { name: 'Sharedlink Created', @@ -275,9 +267,11 @@ export class BoxTrigger implements INodeType { const webhooks = await boxApiRequestAllItems.call(this, 'entries', 'GET', endpoint, {}); for (const webhook of webhooks) { - if (webhook.address === webhookUrl && + if ( + webhook.address === webhookUrl && webhook.target.id === targetId && - webhook.target.type === targetType) { + webhook.target.type === targetType + ) { for (const event of events) { if (!webhook.triggers.includes(event)) { return false; @@ -321,7 +315,6 @@ export class BoxTrigger implements INodeType { async delete(this: IHookFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); if (webhookData.webhookId !== undefined) { - const endpoint = `/webhooks/${webhookData.webhookId}`; try { @@ -343,9 +336,7 @@ export class BoxTrigger implements INodeType { const bodyData = this.getBodyData(); return { - workflowData: [ - this.helpers.returnJsonArray(bodyData), - ], + workflowData: [this.helpers.returnJsonArray(bodyData)], }; } } diff --git a/packages/nodes-base/nodes/Box/FileDescription.ts b/packages/nodes-base/nodes/Box/FileDescription.ts index bdcaed55c6cb7..092828965455e 100644 --- a/packages/nodes-base/nodes/Box/FileDescription.ts +++ b/packages/nodes-base/nodes/Box/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: [ @@ -64,7 +60,6 @@ export const fileOperations: INodeProperties[] = [ ]; export const fileFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* file:copy */ /* -------------------------------------------------------------------------- */ @@ -75,12 +70,8 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'copy', - ], - resource: [ - 'file', - ], + operation: ['copy'], + resource: ['file'], }, }, default: '', @@ -92,15 +83,12 @@ export const fileFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'copy', - ], - resource: [ - 'file', - ], + operation: ['copy'], + resource: ['file'], }, }, - description: 'The ID of folder to copy the file to. If not defined will be copied to the root folder.', + description: + 'The ID of folder to copy the file to. If not defined will be copied to the root folder.', }, { displayName: 'Additional Fields', @@ -109,12 +97,8 @@ export const fileFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'copy', - ], - resource: [ - 'file', - ], + operation: ['copy'], + resource: ['file'], }, }, default: {}, @@ -124,7 +108,8 @@ export const fileFields: INodeProperties[] = [ name: 'fields', type: 'string', default: '', - description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', + description: + 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', }, { displayName: 'Name', @@ -152,12 +137,8 @@ export const fileFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'file', - ], + operation: ['delete'], + resource: ['file'], }, }, default: '', @@ -173,12 +154,8 @@ export const fileFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'file', - ], + operation: ['download'], + resource: ['file'], }, }, default: '', @@ -191,12 +168,8 @@ 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', @@ -211,12 +184,8 @@ export const fileFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'file', - ], + operation: ['get'], + resource: ['file'], }, }, default: '', @@ -229,12 +198,8 @@ export const fileFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'file', - ], + operation: ['get'], + resource: ['file'], }, }, default: {}, @@ -244,7 +209,8 @@ export const fileFields: INodeProperties[] = [ name: 'fields', type: 'string', default: '', - description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', + description: + 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', }, ], }, @@ -258,16 +224,13 @@ export const fileFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'file', - ], + operation: ['search'], + resource: ['file'], }, }, default: '', - description: 'The string to search for. This query is matched against item names, descriptions, text content of files, and various other fields of the different item types.', + description: + 'The string to search for. This query is matched against item names, descriptions, text content of files, and various other fields of the different item types.', }, { displayName: 'Return All', @@ -275,12 +238,8 @@ export const fileFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'file', - ], + operation: ['search'], + resource: ['file'], }, }, default: false, @@ -292,15 +251,9 @@ export const fileFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'file', - ], - returnAll: [ - false, - ], + operation: ['search'], + resource: ['file'], + returnAll: [false], }, }, typeOptions: { @@ -317,12 +270,8 @@ export const fileFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'file', - ], + operation: ['search'], + resource: ['file'], }, }, default: {}, @@ -332,7 +281,8 @@ export const fileFields: INodeProperties[] = [ name: 'contet_types', type: 'string', default: '', - description: 'Limits search results to items with the given content types. Content types are defined as a comma-separated lists of Box recognized content types.', + description: + 'Limits search results to items with the given content types. Content types are defined as a comma-separated lists of Box recognized content types.', }, { displayName: 'Created At Range', @@ -379,14 +329,16 @@ export const fileFields: INodeProperties[] = [ }, ], default: '', - 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: 'Fields', name: 'fields', type: 'string', default: '', - description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', + description: + 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', }, { displayName: 'File Extensions', @@ -401,7 +353,8 @@ export const fileFields: INodeProperties[] = [ name: 'ancestor_folder_ids', type: 'string', default: '', - description: 'Limits search results to items within the given list of folders. Folders are defined as a comma-separated lists of folder IDs.', + description: + 'Limits search results to items within the given list of folders. Folders are defined as a comma-separated lists of folder IDs.', }, { displayName: 'Scope', @@ -426,7 +379,8 @@ export const fileFields: INodeProperties[] = [ type: 'string', default: '', placeholder: '1000000,5000000', - description: 'Limits search results to items within a given file size range. File size ranges are defined as comma-separated byte sizes.', + description: + 'Limits search results to items within a given file size range. File size ranges are defined as comma-separated byte sizes.', }, { displayName: 'Sort', @@ -443,7 +397,8 @@ export const fileFields: INodeProperties[] = [ }, ], default: 'relevance', - description: 'Returns the results ordered in descending order by date at which the item was last modified', + description: + 'Returns the results ordered in descending order by date at which the item was last modified', }, { displayName: 'Trash Content', @@ -497,7 +452,8 @@ export const fileFields: INodeProperties[] = [ name: 'owner_user_ids', type: 'string', default: '', - description: 'Limits search results to items owned by the given list of owners. Owners are defined as a comma-separated list of user IDs.', + description: + 'Limits search results to items owned by the given list of owners. Owners are defined as a comma-separated list of user IDs.', }, ], }, @@ -511,12 +467,8 @@ export const fileFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'file', - ], + operation: ['share'], + resource: ['file'], }, }, default: '', @@ -538,12 +490,8 @@ export const fileFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'file', - ], + operation: ['share'], + resource: ['file'], }, }, default: '', @@ -555,15 +503,9 @@ export const fileFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'file', - ], - accessibleBy: [ - 'user', - ], + operation: ['share'], + resource: ['file'], + accessibleBy: ['user'], }, }, default: true, @@ -576,22 +518,14 @@ export const fileFields: INodeProperties[] = [ placeholder: 'name@email.com', displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'file', - ], - useEmail: [ - true, - ], - accessibleBy: [ - 'user', - ], + operation: ['share'], + resource: ['file'], + useEmail: [true], + accessibleBy: ['user'], }, }, default: '', - description: 'The user\'s email address to share the file with', + description: "The user's email address to share the file with", }, { displayName: 'User ID', @@ -599,22 +533,14 @@ export const fileFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'file', - ], - useEmail: [ - false, - ], - accessibleBy: [ - 'user', - ], + operation: ['share'], + resource: ['file'], + useEmail: [false], + accessibleBy: ['user'], }, }, default: '', - description: 'The user\'s ID to share the file with', + description: "The user's ID to share the file with", }, { displayName: 'Group ID', @@ -622,19 +548,13 @@ export const fileFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'file', - ], - accessibleBy: [ - 'group', - ], + operation: ['share'], + resource: ['file'], + accessibleBy: ['group'], }, }, default: '', - description: 'The group\'s ID to share the file with', + description: "The group's ID to share the file with", }, { displayName: 'Role', @@ -679,12 +599,8 @@ export const fileFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'file', - ], + operation: ['share'], + resource: ['file'], }, }, default: 'editor', @@ -697,12 +613,8 @@ export const fileFields: INodeProperties[] = [ placeholder: 'Add Option', displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'file', - ], + operation: ['share'], + resource: ['file'], }, }, default: {}, @@ -712,21 +624,24 @@ export const fileFields: INodeProperties[] = [ name: 'can_view_path', type: 'boolean', default: false, - description: 'Whether the invited users can see the entire parent path to the associated folder. The user will not gain privileges in any parent folder and therefore cannot see content the user is not collaborated on.', + description: + 'Whether the invited users can see the entire parent path to the associated folder. The user will not gain privileges in any parent folder and therefore cannot see content the user is not collaborated on.', }, { displayName: 'Expires At', name: 'expires_at', type: 'dateTime', default: '', - description: 'Set the expiration date for the collaboration. At this date, the collaboration will be automatically removed from the item.', + description: + 'Set the expiration date for the collaboration. At this date, the collaboration will be automatically removed from the item.', }, { displayName: 'Fields', name: 'fields', type: 'string', default: '', - description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', + description: + 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', }, { displayName: 'Notify', @@ -748,12 +663,8 @@ export const fileFields: INodeProperties[] = [ placeholder: 'photo.png', displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, default: '', @@ -767,12 +678,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', @@ -785,17 +692,10 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - binaryData: [ - false, - ], - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + binaryData: [false], + operation: ['upload'], + resource: ['file'], }, - }, description: 'The text content of the file', }, @@ -807,17 +707,10 @@ export const fileFields: INodeProperties[] = [ required: true, displayOptions: { show: { - binaryData: [ - true, - ], - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + binaryData: [true], + operation: ['upload'], + resource: ['file'], }, - }, description: 'Name of the binary property which contains the data for the file', }, @@ -827,15 +720,12 @@ export const fileFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, default: '', - description: 'ID of the parent folder that will contain the file. If not it will be uploaded to the root folder.', + description: + 'ID of the parent folder that will contain the file. If not it will be uploaded to the root folder.', }, ]; diff --git a/packages/nodes-base/nodes/Box/FolderDescription.ts b/packages/nodes-base/nodes/Box/FolderDescription.ts index 33d7bb722b18c..08b60c0a19ef1 100644 --- a/packages/nodes-base/nodes/Box/FolderDescription.ts +++ b/packages/nodes-base/nodes/Box/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,7 +54,6 @@ export const folderOperations: INodeProperties[] = [ ]; export const folderFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* folder:create */ /* -------------------------------------------------------------------------- */ @@ -69,16 +64,12 @@ export const folderFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'folder', - ], + operation: ['create'], + resource: ['folder'], }, }, default: '', - description: 'Folder\'s name', + description: "Folder's name", }, { displayName: 'Parent ID', @@ -86,16 +77,13 @@ export const folderFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'folder', - ], + operation: ['create'], + resource: ['folder'], }, }, default: '', - description: 'ID of the folder you want to create the new folder in. if not defined it will be created on the root folder.', + description: + 'ID of the folder you want to create the new folder in. if not defined it will be created on the root folder.', }, { displayName: 'Options', @@ -103,12 +91,8 @@ export const folderFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'folder', - ], + operation: ['create'], + resource: ['folder'], }, }, default: {}, @@ -122,7 +106,8 @@ export const folderFields: INodeProperties[] = [ { name: 'Collaborators', value: 'collaborators', - description: 'Only emails from registered email addresses for collaborators will be accepted', + description: + 'Only emails from registered email addresses for collaborators will be accepted', }, { name: 'Open', @@ -138,7 +123,8 @@ export const folderFields: INodeProperties[] = [ name: 'fields', type: 'string', default: '', - description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', + description: + 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', }, ], }, @@ -152,12 +138,8 @@ export const folderFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'folder', - ], + operation: ['get'], + resource: ['folder'], }, }, default: '', @@ -172,12 +154,8 @@ export const folderFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'folder', - ], + operation: ['delete'], + resource: ['folder'], }, }, default: '', @@ -188,16 +166,13 @@ export const folderFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'folder', - ], + operation: ['delete'], + resource: ['folder'], }, }, default: false, - description: 'Whether to delete a folder that is not empty by recursively deleting the folder and all of its content', + description: + 'Whether to delete a folder that is not empty by recursively deleting the folder and all of its content', }, /* -------------------------------------------------------------------------- */ @@ -209,16 +184,13 @@ export const folderFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'folder', - ], + operation: ['search'], + resource: ['folder'], }, }, default: '', - description: 'The string to search for. This query is matched against item names, descriptions, text content of files, and various other fields of the different item types.', + description: + 'The string to search for. This query is matched against item names, descriptions, text content of files, and various other fields of the different item types.', }, { displayName: 'Return All', @@ -226,12 +198,8 @@ export const folderFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'folder', - ], + operation: ['search'], + resource: ['folder'], }, }, default: false, @@ -243,15 +211,9 @@ export const folderFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'folder', - ], - returnAll: [ - false, - ], + operation: ['search'], + resource: ['folder'], + returnAll: [false], }, }, typeOptions: { @@ -268,12 +230,8 @@ export const folderFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'search', - ], - resource: [ - 'folder', - ], + operation: ['search'], + resource: ['folder'], }, }, default: {}, @@ -283,7 +241,8 @@ export const folderFields: INodeProperties[] = [ name: 'contet_types', type: 'string', default: '', - description: 'Limits search results to items with the given content types. Content types are defined as a comma-separated lists of Box recognized content types.', + description: + 'Limits search results to items with the given content types. Content types are defined as a comma-separated lists of Box recognized content types.', }, { displayName: 'Created At Range', @@ -330,14 +289,16 @@ export const folderFields: INodeProperties[] = [ }, ], default: '', - 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: 'Fields', name: 'fields', type: 'string', default: '', - description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', + description: + 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', }, { displayName: 'File Extensions', @@ -352,7 +313,8 @@ export const folderFields: INodeProperties[] = [ name: 'ancestor_folder_ids', type: 'string', default: '', - description: 'Limits search results to items within the given list of folders. Folders are defined as a comma-separated lists of folder IDs.', + description: + 'Limits search results to items within the given list of folders. Folders are defined as a comma-separated lists of folder IDs.', }, { displayName: 'Scope', @@ -377,7 +339,8 @@ export const folderFields: INodeProperties[] = [ type: 'string', default: '', placeholder: '1000000,5000000', - description: 'Limits search results to items within a given file size range. File size ranges are defined as comma-separated byte sizes.', + description: + 'Limits search results to items within a given file size range. File size ranges are defined as comma-separated byte sizes.', }, { displayName: 'Sort', @@ -394,7 +357,8 @@ export const folderFields: INodeProperties[] = [ }, ], default: 'relevance', - description: 'Returns the results ordered in descending order by date at which the item was last modified', + description: + 'Returns the results ordered in descending order by date at which the item was last modified', }, { displayName: 'Trash Content', @@ -448,7 +412,8 @@ export const folderFields: INodeProperties[] = [ name: 'owner_user_ids', type: 'string', default: '', - description: 'Limits search results to items owned by the given list of owners. Owners are defined as a comma-separated list of user IDs.', + description: + 'Limits search results to items owned by the given list of owners. Owners are defined as a comma-separated list of user IDs.', }, ], }, @@ -462,12 +427,8 @@ export const folderFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'folder', - ], + operation: ['share'], + resource: ['folder'], }, }, default: '', @@ -489,12 +450,8 @@ export const folderFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'folder', - ], + operation: ['share'], + resource: ['folder'], }, }, default: 'user', @@ -506,15 +463,9 @@ export const folderFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'folder', - ], - accessibleBy: [ - 'user', - ], + operation: ['share'], + resource: ['folder'], + accessibleBy: ['user'], }, }, default: true, @@ -527,22 +478,14 @@ export const folderFields: INodeProperties[] = [ placeholder: 'name@email.com', displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'folder', - ], - accessibleBy: [ - 'user', - ], - useEmail: [ - true, - ], + operation: ['share'], + resource: ['folder'], + accessibleBy: ['user'], + useEmail: [true], }, }, default: '', - description: 'The user\'s email address to share the folder with', + description: "The user's email address to share the folder with", }, { displayName: 'User ID', @@ -550,22 +493,14 @@ export const folderFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'folder', - ], - accessibleBy: [ - 'user', - ], - useEmail: [ - false, - ], + operation: ['share'], + resource: ['folder'], + accessibleBy: ['user'], + useEmail: [false], }, }, default: '', - description: 'The user\'s ID to share the folder with', + description: "The user's ID to share the folder with", }, { displayName: 'Group ID', @@ -573,19 +508,13 @@ export const folderFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'folder', - ], - accessibleBy: [ - 'group', - ], + operation: ['share'], + resource: ['folder'], + accessibleBy: ['group'], }, }, default: '', - description: 'The group\'s ID to share the folder with', + description: "The group's ID to share the folder with", }, { displayName: 'Role', @@ -630,12 +559,8 @@ export const folderFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'folder', - ], + operation: ['share'], + resource: ['folder'], }, }, default: 'editor', @@ -648,12 +573,8 @@ export const folderFields: INodeProperties[] = [ placeholder: 'Add Option', displayOptions: { show: { - operation: [ - 'share', - ], - resource: [ - 'folder', - ], + operation: ['share'], + resource: ['folder'], }, }, default: {}, @@ -663,21 +584,24 @@ export const folderFields: INodeProperties[] = [ name: 'can_view_path', type: 'boolean', default: false, - description: 'Whether the invited users can see the entire parent path to the associated folder. The user will not gain privileges in any parent folder and therefore cannot see content the user is not collaborated on.', + description: + 'Whether the invited users can see the entire parent path to the associated folder. The user will not gain privileges in any parent folder and therefore cannot see content the user is not collaborated on.', }, { displayName: 'Expires At', name: 'expires_at', type: 'dateTime', default: '', - description: 'Set the expiration date for the collaboration. At this date, the collaboration will be automatically removed from the item.', + description: + 'Set the expiration date for the collaboration. At this date, the collaboration will be automatically removed from the item.', }, { displayName: 'Fields', name: 'fields', type: 'string', default: '', - description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', + description: + 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', }, { displayName: 'Notify', @@ -699,12 +623,8 @@ export const folderFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'folder', - ], + operation: ['update'], + resource: ['folder'], }, }, default: '', @@ -715,12 +635,8 @@ export const folderFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'folder', - ], + operation: ['update'], + resource: ['folder'], }, }, default: {}, @@ -731,14 +647,16 @@ export const folderFields: INodeProperties[] = [ name: 'can_non_owners_invite', type: 'boolean', default: false, - description: 'Whether users who are not the owner of the folder can invite new collaborators to the folder', + description: + 'Whether users who are not the owner of the folder can invite new collaborators to the folder', }, { displayName: 'Can Non-Owners View Colaborators', name: 'can_non_owners_view_collaborators', type: 'boolean', default: false, - description: 'Whether to restrict collaborators who are not the owner of this folder from viewing other collaborations on this folder', + description: + 'Whether to restrict collaborators who are not the owner of this folder from viewing other collaborations on this folder', }, { displayName: 'Description', @@ -752,14 +670,16 @@ export const folderFields: INodeProperties[] = [ name: 'fields', type: 'string', default: '', - description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', + description: + 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.', }, { displayName: 'Is Collaboration Restricted To Enterprise', name: 'is_collaboration_restricted_to_enterprise', type: 'boolean', default: false, - description: 'Whether new invites to this folder are restricted to users within the enterprise. This does not affect existing collaborations.', + description: + 'Whether new invites to this folder are restricted to users within the enterprise. This does not affect existing collaborations.', }, { displayName: 'Name', @@ -773,7 +693,8 @@ export const folderFields: INodeProperties[] = [ name: 'parentId', type: 'string', default: '', - description: 'The parent folder for this folder. Use this to move the folder or to restore it out of the trash.', + description: + 'The parent folder for this folder. Use this to move the folder or to restore it out of the trash.', }, { displayName: 'Shared Link', @@ -815,13 +736,12 @@ export const folderFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - access: [ - 'open', - ], + access: ['open'], }, }, default: '', - description: 'The password required to access the shared link. Set the password to null to remove it.', + description: + 'The password required to access the shared link. Set the password to null to remove it.', }, { displayName: 'Permissions', @@ -849,7 +769,8 @@ export const folderFields: INodeProperties[] = [ name: 'vanity_name', type: 'string', default: '', - description: 'Defines a custom vanity name to use in the shared link URL, for example https://app.box.com/v/my-shared-link', + description: + 'Defines a custom vanity name to use in the shared link URL, for example https://app.box.com/v/my-shared-link', }, ], }, @@ -858,7 +779,8 @@ export const folderFields: INodeProperties[] = [ name: 'tags', type: 'string', default: '', - description: 'The tags for this item. These tags are shown in the Box web app and mobile apps next to an item.', + description: + 'The tags for this item. These tags are shown in the Box web app and mobile apps next to an item.', }, ], }, diff --git a/packages/nodes-base/nodes/Box/GenericFunctions.ts b/packages/nodes-base/nodes/Box/GenericFunctions.ts index 1483b7f43d592..da3b2429cf2ad 100644 --- a/packages/nodes-base/nodes/Box/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Box/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,14 +7,19 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, - IOAuth2Options, - NodeApiError, -} from 'n8n-workflow'; - -export async function boxApiRequest(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, IOAuth2Options, NodeApiError } from 'n8n-workflow'; +export async function boxApiRequest( + 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', @@ -40,14 +43,21 @@ export async function boxApiRequest(this: IExecuteFunctions | IExecuteSingleFunc //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'boxOAuth2Api', options, oAuth2Options); - } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function boxApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function boxApiRequestAllItems( + 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; @@ -57,9 +67,7 @@ export async function boxApiRequestAllItems(this: IExecuteFunctions | ILoadOptio responseData = await boxApiRequest.call(this, method, endpoint, body, query); query.offset = responseData['offset'] + query.limit; 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/Brandfetch/Brandfetch.node.ts b/packages/nodes-base/nodes/Brandfetch/Brandfetch.node.ts index bd572dfaae470..e3f66a8e159b1 100644 --- a/packages/nodes-base/nodes/Brandfetch/Brandfetch.node.ts +++ b/packages/nodes-base/nodes/Brandfetch/Brandfetch.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 { - brandfetchApiRequest, -} from './GenericFunctions'; +import { brandfetchApiRequest } from './GenericFunctions'; export class Brandfetch implements INodeType { description: INodeTypeDescription = { @@ -41,36 +32,35 @@ export class Brandfetch implements INodeType { type: 'options', noDataExpression: true, options: [ - { name: 'Color', value: 'color', - description: 'Return a company\'s colors', - action: 'Return a company\'s colors', + description: "Return a company's colors", + action: "Return a company's colors", }, { name: 'Company', value: 'company', - description: 'Return a company\'s data', - action: 'Return a company\'s data', + description: "Return a company's data", + action: "Return a company's data", }, { name: 'Font', value: 'font', - description: 'Return a company\'s fonts', - action: 'Return a company\'s fonts', + description: "Return a company's fonts", + action: "Return a company's fonts", }, { name: 'Industry', value: 'industry', - description: 'Return a company\'s industry', - action: 'Return a company\'s industry', + description: "Return a company's industry", + action: "Return a company's industry", }, { name: 'Logo', value: 'logo', - description: 'Return a company\'s logo & icon', - action: 'Return a company\'s logo & icon', + description: "Return a company's logo & icon", + action: "Return a company's logo & icon", }, ], default: 'logo', @@ -95,9 +85,7 @@ export class Brandfetch implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'logo', - ], + operation: ['logo'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether @@ -109,12 +97,8 @@ export class Brandfetch implements INodeType { type: 'multiOptions', displayOptions: { show: { - operation: [ - 'logo', - ], - download: [ - true, - ], + operation: ['logo'], + download: [true], }, }, options: [ @@ -127,10 +111,7 @@ export class Brandfetch implements INodeType { value: 'logo', }, ], - default: [ - 'logo', - 'icon', - ], + default: ['logo', 'icon'], required: true, }, { @@ -139,12 +120,8 @@ export class Brandfetch implements INodeType { type: 'multiOptions', displayOptions: { show: { - operation: [ - 'logo', - ], - download: [ - true, - ], + operation: ['logo'], + download: [true], }, }, options: [ @@ -157,9 +134,7 @@ export class Brandfetch implements INodeType { value: 'svg', }, ], - default: [ - 'png', - ], + default: ['png'], description: 'The image format in which the logo should be returned as', required: true, }, @@ -185,7 +160,6 @@ export class Brandfetch implements INodeType { const response = await brandfetchApiRequest.call(this, 'POST', `/logo`, body); if (download === true) { - const imageTypes = this.getNodeParameter('imageTypes', i) as string[]; const imageFormats = this.getNodeParameter('imageFormats', i) as string[]; @@ -206,13 +180,21 @@ export class Brandfetch implements INodeType { for (const imageType of imageTypes) { for (const imageFormat of imageFormats) { - - const url = response.response[imageType][(imageFormat === 'png') ? 'image' : imageFormat] as string; + const url = response.response[imageType][ + imageFormat === 'png' ? 'image' : imageFormat + ] as string; if (url !== null) { - const data = await brandfetchApiRequest.call(this, 'GET', '', {}, {}, url, { json: false, encoding: null }); + const data = await brandfetchApiRequest.call(this, 'GET', '', {}, {}, url, { + json: false, + encoding: null, + }); - newItem.binary![`${imageType}_${imageFormat}`] = await this.helpers.prepareBinaryData(data, `${imageType}_${domain}.${imageFormat}`); + newItem.binary![`${imageType}_${imageFormat}`] = + await this.helpers.prepareBinaryData( + data, + `${imageType}_${domain}.${imageFormat}`, + ); items[i] = newItem; } diff --git a/packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts b/packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts index 3423c79cb5747..13384fedc357c 100644 --- a/packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Brandfetch/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'; - -export async function brandfetchApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; + +export async function brandfetchApiRequest( + 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('brandfetchApi'); let options: OptionsWithUri = { @@ -47,7 +53,6 @@ export async function brandfetchApiRequest(this: IHookFunctions | IExecuteFuncti } return response; - } catch (error) { throw new NodeApiError(this.getNode(), error); } diff --git a/packages/nodes-base/nodes/Bubble/Bubble.node.ts b/packages/nodes-base/nodes/Bubble/Bubble.node.ts index 2077e504aa7ab..536535453ab91 100644 --- a/packages/nodes-base/nodes/Bubble/Bubble.node.ts +++ b/packages/nodes-base/nodes/Bubble/Bubble.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -10,16 +8,9 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - bubbleApiRequest, - bubbleApiRequestAllItems, - validateJSON, -} from './GenericFunctions'; +import { bubbleApiRequest, bubbleApiRequestAllItems, validateJSON } from './GenericFunctions'; -import { - objectFields, - objectOperations, -} from './ObjectDescription'; +import { objectFields, objectOperations } from './ObjectDescription'; export class Bubble implements INodeType { description: INodeTypeDescription = { @@ -71,9 +62,7 @@ export class Bubble implements INodeType { const returnData: IDataObject[] = []; for (let i = 0; i < items.length; i++) { - if (resource === 'object') { - // ********************************************************************* // object // ********************************************************************* @@ -81,7 +70,6 @@ export class Bubble implements INodeType { // https://bubble.io/reference#API if (operation === 'create') { - // ---------------------------------- // object: create // ---------------------------------- @@ -90,19 +78,15 @@ export class Bubble implements INodeType { const typeName = typeNameInput.replace(/\s/g, '').toLowerCase(); const { property } = this.getNodeParameter('properties', i) as { - property: [ - { key: string; value: string; }, - ], + property: [{ key: string; value: string }]; }; const body = {} as IDataObject; - property.forEach(data => body[data.key] = data.value); + property.forEach((data) => (body[data.key] = data.value)); responseData = await bubbleApiRequest.call(this, 'POST', `/obj/${typeName}`, body, {}); - } else if (operation === 'delete') { - // ---------------------------------- // object: delete // ---------------------------------- @@ -114,9 +98,7 @@ export class Bubble implements INodeType { const endpoint = `/obj/${typeName}/${objectId}`; responseData = await bubbleApiRequest.call(this, 'DELETE', endpoint, {}, {}); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------- // object: get // ---------------------------------- @@ -128,9 +110,7 @@ export class Bubble implements INodeType { const endpoint = `/obj/${typeName}/${objectId}`; responseData = await bubbleApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData.response; - } else if (operation === 'getAll') { - // ---------------------------------- // object: getAll // ---------------------------------- @@ -153,7 +133,9 @@ export class Bubble implements INodeType { const filter = options.filtersJson as string; const data = validateJSON(filter); if (data === undefined) { - throw new NodeOperationError(this.getNode(), 'Filters must be a valid JSON', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Filters must be a valid JSON', { + itemIndex: i, + }); } qs.constraints = JSON.stringify(data); } @@ -170,9 +152,7 @@ export class Bubble implements INodeType { responseData = await bubbleApiRequest.call(this, 'GET', endpoint, {}, qs); responseData = responseData.response.results; } - } else if (operation === 'update') { - // ---------------------------------- // object: update // ---------------------------------- @@ -182,14 +162,12 @@ export class Bubble implements INodeType { const objectId = this.getNodeParameter('objectId', i) as string; const endpoint = `/obj/${typeName}/${objectId}`; const { property } = this.getNodeParameter('properties', i) as { - property: [ - { key: string; value: string; }, - ], + property: [{ key: string; value: string }]; }; const body = {} as IDataObject; - property.forEach(data => body[data.key] = data.value); + property.forEach((data) => (body[data.key] = data.value)); responseData = await bubbleApiRequest.call(this, 'PATCH', endpoint, body, {}); responseData = { sucess: true }; } @@ -201,6 +179,5 @@ export class Bubble implements INodeType { } return [this.helpers.returnJsonArray(returnData)]; - } } diff --git a/packages/nodes-base/nodes/Bubble/GenericFunctions.ts b/packages/nodes-base/nodes/Bubble/GenericFunctions.ts index de785babf511f..53b9747895314 100644 --- a/packages/nodes-base/nodes/Bubble/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bubble/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 Bubble. @@ -23,13 +14,14 @@ export async function bubbleApiRequest( body: IDataObject, qs: IDataObject, ) { - - const { apiToken, appName, domain, environment, hosting } = await this.getCredentials('bubbleApi') as { - apiToken: string, - appName: string, - domain: string, - environment: 'development' | 'live', - hosting: 'bubbleHosted' | 'selfHosted', + const { apiToken, appName, domain, environment, hosting } = (await this.getCredentials( + 'bubbleApi', + )) as { + apiToken: string; + appName: string; + domain: string; + environment: 'development' | 'live'; + hosting: 'bubbleHosted' | 'selfHosted'; }; const rootUrl = hosting === 'bubbleHosted' ? `https://${appName}.bubbleapps.io` : domain; @@ -38,7 +30,7 @@ export async function bubbleApiRequest( const options: OptionsWithUri = { headers: { 'user-agent': 'n8n', - 'Authorization': `Bearer ${apiToken}`, + Authorization: `Bearer ${apiToken}`, }, method, uri: `${rootUrl}${urlSegment}${endpoint}`, @@ -80,14 +72,13 @@ export async function bubbleApiRequestAllItems( responseData = await bubbleApiRequest.call(this, method, endpoint, body, qs); qs.cursor = responseData.cursor; returnData.push.apply(returnData, responseData['response']['results']); - } while ( - responseData.response.remaining !== 0 - ); + } while (responseData.response.remaining !== 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/Bubble/ObjectDescription.ts b/packages/nodes-base/nodes/Bubble/ObjectDescription.ts index 58aa7d195f929..bf6002d3d9563 100644 --- a/packages/nodes-base/nodes/Bubble/ObjectDescription.ts +++ b/packages/nodes-base/nodes/Bubble/ObjectDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const objectOperations: INodeProperties[] = [ { @@ -38,9 +36,7 @@ export const objectOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'object', - ], + resource: ['object'], }, }, }, @@ -59,12 +55,8 @@ export const objectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'object', - ], - operation: [ - 'create', - ], + resource: ['object'], + operation: ['create'], }, }, }, @@ -79,12 +71,8 @@ export const objectFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'object', - ], - operation: [ - 'create', - ], + resource: ['object'], + operation: ['create'], }, }, options: [ @@ -123,13 +111,8 @@ export const objectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'object', - ], - operation: [ - 'get', - 'delete', - ], + resource: ['object'], + operation: ['get', 'delete'], }, }, }, @@ -142,13 +125,8 @@ export const objectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'object', - ], - operation: [ - 'get', - 'delete', - ], + resource: ['object'], + operation: ['get', 'delete'], }, }, }, @@ -165,12 +143,8 @@ export const objectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'object', - ], - operation: [ - 'update', - ], + resource: ['object'], + operation: ['update'], }, }, }, @@ -183,12 +157,8 @@ export const objectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'object', - ], - operation: [ - 'update', - ], + resource: ['object'], + operation: ['update'], }, }, }, @@ -203,12 +173,8 @@ export const objectFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'object', - ], - operation: [ - 'update', - ], + resource: ['object'], + operation: ['update'], }, }, options: [ @@ -247,12 +213,8 @@ export const objectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'object', - ], - operation: [ - 'getAll', - ], + resource: ['object'], + operation: ['getAll'], }, }, }, @@ -262,12 +224,8 @@ export const objectFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'object', - ], - operation: [ - 'getAll', - ], + resource: ['object'], + operation: ['getAll'], }, }, default: false, @@ -279,15 +237,9 @@ export const objectFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'object', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['object'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -304,12 +256,8 @@ export const objectFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'object', - ], - operation: [ - 'getAll', - ], + resource: ['object'], + operation: ['getAll'], }, }, }, @@ -319,12 +267,8 @@ export const objectFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'object', - ], + operation: ['getAll'], + resource: ['object'], }, }, default: {}, @@ -340,9 +284,7 @@ export const objectFields: INodeProperties[] = [ }, displayOptions: { show: { - '/jsonParameters': [ - false, - ], + '/jsonParameters': [false], }, }, default: {}, @@ -377,52 +319,62 @@ export const objectFields: INodeProperties[] = [ { name: 'Is Empty', value: 'is_empty', - description: 'Use to test whether a thing\'s given field is empty, for all field types', + description: + "Use to test whether a thing's given field is empty, for all field types", }, { name: 'Is Not Empty', value: 'is_not_empty', - description: 'Use to test whether a thing\'s given field is not empty, for all field types', + description: + "Use to test whether a thing's given field is not empty, for all field types", }, { name: 'Text Contains', value: 'text contains', - description: 'Use to test if a text field contains a string, for text fields only', + description: + 'Use to test if a text field contains a string, for text fields only', }, { name: 'Not Text Contains', value: 'not text contains', - description: 'Use to test if a text field does not contain a string, for text fields only', + description: + 'Use to test if a text field does not contain a string, for text fields only', }, { name: 'Greater Than', value: 'greater than', - description: 'Use to compare a thing\'s field value relative to a string or number, for text, number, and date fields', + description: + "Use to compare a thing's field value relative to a string or number, for text, number, and date fields", }, { name: 'Less Than', value: 'less than', - description: 'Use to compare a thing\'s field value relative to a string or number, for text, number, and date fields', + description: + "Use to compare a thing's field value relative to a string or number, for text, number, and date fields", }, { name: 'In', value: 'in', - description: 'Use to test whether a thing\'s field is in a list, for all field types', + description: + "Use to test whether a thing's field is in a list, for all field types", }, { name: 'Not In', value: 'not in', - description: 'Use to test whether a thing\'s field is not in a list, for all field types', + description: + "Use to test whether a thing's field is not in a list, for all field types", }, { name: 'Contains', value: 'contains', - description: 'Use to test whether a list field contains an entry, for list fields only', + description: + 'Use to test whether a list field contains an entry, for list fields only', }, { name: 'Not Contains', value: 'not contains', - description: 'Use to test whether a list field does not contains an entry, for list fields only', + description: + 'Use to test whether a list field does not contains an entry, for list fields only', }, { name: 'Empty', @@ -432,12 +384,14 @@ export const objectFields: INodeProperties[] = [ { name: 'Not Empty', value: 'not empty', - description: 'Use to test whether a list field is not empty, for list fields only', + description: + 'Use to test whether a list field is not empty, for list fields only', }, { name: 'Geographic Search', value: 'geographic_search', - description: 'Use to test if the current thing is within a radius from a central address. To use this, the value sent with the constraint must have an address and a range. See link.', + description: + 'Use to test if the current thing is within a radius from a central address. To use this, the value sent with the constraint must have an address and a range. See link.', }, ], default: '', @@ -448,12 +402,7 @@ export const objectFields: INodeProperties[] = [ type: 'string', displayOptions: { hide: { - constraint_type: [ - 'is_empty', - 'is_not_empty', - 'empty', - 'not empty', - ], + constraint_type: ['is_empty', 'is_not_empty', 'empty', 'not empty'], }, }, default: '', @@ -470,13 +419,12 @@ export const objectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - '/jsonParameters': [ - true, - ], + '/jsonParameters': [true], }, }, placeholder: `[ { "key": "name", "constraint_type": "text contains", "value": "cafe" } , { "key": "address", "constraint_type": "geographic_search", "value": { "range":10, "origin_address":"New York" } } ]`, - description: 'Refine the list that is returned by the Data API with search constraints, exactly as you define a search in Bubble. See link.', + description: + 'Refine the list that is returned by the Data API with search constraints, exactly as you define a search in Bubble. See link.', }, { displayName: 'Sort', @@ -497,7 +445,8 @@ export const objectFields: INodeProperties[] = [ name: 'sort_field', type: 'string', default: '', - description: 'Specify the field to use for sorting. Either use a fielddefined for the current typeor use _random_sorting to get the entries in a random order.', + description: + 'Specify the field to use for sorting. Either use a fielddefined for the current typeor use _random_sorting to get the entries in a random order.', }, { displayName: 'Descending', @@ -510,7 +459,8 @@ export const objectFields: INodeProperties[] = [ name: 'geo_reference', type: 'string', default: '', - description: 'When the field\'s type is geographic address, you need to add another parameter geo_reference and provide an address as a string', + description: + "When the field's type is geographic address, you need to add another parameter geo_reference and provide an address as a string", }, ], }, diff --git a/packages/nodes-base/nodes/Cal/CalTrigger.node.ts b/packages/nodes-base/nodes/Cal/CalTrigger.node.ts index 6ac5bad77271e..16c0a5884768f 100644 --- a/packages/nodes-base/nodes/Cal/CalTrigger.node.ts +++ b/packages/nodes-base/nodes/Cal/CalTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { ILoadOptionsFunctions, @@ -11,103 +8,101 @@ import { IWebhookResponseData, } from 'n8n-workflow'; -import { - calApiRequest, - sortOptionParameters, -} from './GenericFunctions'; +import { calApiRequest, sortOptionParameters } from './GenericFunctions'; export class CalTrigger implements INodeType { description: INodeTypeDescription = { - displayName: 'Cal Trigger', - name: 'calTrigger', - icon: 'file:cal.svg', - group: ['trigger'], - version: 1, - subtitle: '=Events: {{$parameter["events"].join(", ")}}', - description: 'Handle Cal events via webhooks', - defaults: { - name: 'Cal Trigger', - color: '#888', + displayName: 'Cal Trigger', + name: 'calTrigger', + icon: 'file:cal.svg', + group: ['trigger'], + version: 1, + subtitle: '=Events: {{$parameter["events"].join(", ")}}', + description: 'Handle Cal events via webhooks', + defaults: { + name: 'Cal Trigger', + color: '#888', + }, + inputs: [], + outputs: ['main'], + credentials: [ + { + name: 'calApi', + required: true, }, - inputs: [], - outputs: ['main'], - credentials: [ - { - name: 'calApi', - required: true, - }, - ], - webhooks: [ + ], + webhooks: [ + { + name: 'default', + httpMethod: 'POST', + responseMode: 'onReceived', + path: 'webhook', + }, + ], + properties: [ + { + displayName: 'Events', + name: 'events', + type: 'multiOptions', + options: [ { - name: 'default', - httpMethod: 'POST', - responseMode: 'onReceived', - path: 'webhook', + name: 'Booking Cancelled', + value: 'BOOKING_CANCELLED', + description: 'Receive notifications when a Cal event is canceled', }, - ], - properties: [ - { - displayName: 'Events', - name: 'events', - type: 'multiOptions', - options: [ - { - name: 'Booking Cancelled', - value: 'BOOKING_CANCELLED', - description: 'Receive notifications when a Cal event is canceled', - }, - { - name: 'Booking Created', - value: 'BOOKING_CREATED', - description: 'Receive notifications when a new Cal event is created', - }, - { - name: 'Booking Rescheduled', - value: 'BOOKING_RESCHEDULED', - description: 'Receive notifications when a Cal event is rescheduled', - }, - ], - default: [], - required: true, - }, - { - displayName: 'Options', - name: 'options', - type: 'collection', - placeholder: 'Add Field', - default: {}, - options: [ - { - displayName: 'App ID', - name: 'appId', - type: 'string', - description: 'The ID of the App to monitor', - default: '', - }, - { - displayName: 'EventType Name or ID', - name: 'eventTypeId', - type: 'options', - typeOptions: { - loadOptionsMethod: 'getEventTypes', - }, - description: 'The EventType to monitor. Choose from the list, or specify an ID using an expression.', - default: '', + { + name: 'Booking Created', + value: 'BOOKING_CREATED', + description: 'Receive notifications when a new Cal event is created', + }, + { + name: 'Booking Rescheduled', + value: 'BOOKING_RESCHEDULED', + description: 'Receive notifications when a Cal event is rescheduled', + }, + ], + default: [], + required: true, + }, + { + displayName: 'Options', + name: 'options', + type: 'collection', + placeholder: 'Add Field', + default: {}, + options: [ + { + displayName: 'App ID', + name: 'appId', + type: 'string', + description: 'The ID of the App to monitor', + default: '', + }, + { + displayName: 'EventType Name or ID', + name: 'eventTypeId', + type: 'options', + typeOptions: { + loadOptionsMethod: 'getEventTypes', }, - { - displayName: 'Payload Template', - name: 'payloadTemplate', - type: 'string', - description: 'Template to customize the webhook payload', - default: '', - typeOptions: { - alwaysOpenEditWindow: true, - rows: 4, - }, + description: + 'The EventType to monitor. Choose from the list, or specify an ID using an expression.', + default: '', + }, + { + displayName: 'Payload Template', + name: 'payloadTemplate', + type: 'string', + description: 'Template to customize the webhook payload', + default: '', + typeOptions: { + alwaysOpenEditWindow: true, + rows: 4, }, - ], - }, - ], + }, + ], + }, + ], }; methods = { @@ -165,7 +160,7 @@ export class CalTrigger implements INodeType { subscriberUrl, eventTriggers, active, - ...options as object, + ...(options as object), }; const responseData = await calApiRequest.call(this, 'POST', '/hooks', body); @@ -181,7 +176,6 @@ export class CalTrigger implements INodeType { async delete(this: IHookFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); if (webhookData.webhookId !== undefined) { - const endpoint = `/hooks/${webhookData.webhookId}`; try { @@ -202,13 +196,13 @@ export class CalTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [ - this.helpers.returnJsonArray({ - triggerEvent: req.body.triggerEvent, - createdAt: req.body.createdAt, - ...req.body.payload, - }), - ], + workflowData: [ + this.helpers.returnJsonArray({ + triggerEvent: req.body.triggerEvent, + createdAt: req.body.createdAt, + ...req.body.payload, + }), + ], }; } } diff --git a/packages/nodes-base/nodes/Cal/GenericFunctions.ts b/packages/nodes-base/nodes/Cal/GenericFunctions.ts index 2396f948ef36f..fd5dbceb4daad 100644 --- a/packages/nodes-base/nodes/Cal/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cal/GenericFunctions.ts @@ -1,7 +1,4 @@ -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject, @@ -13,8 +10,16 @@ import { NodeApiError, } from 'n8n-workflow'; -export async function calApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: IHttpRequestMethods, resource: string, body: any = {}, query: IDataObject = {}, option: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function calApiRequest( + this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, + method: IHttpRequestMethods, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('calApi'); let options: IHttpRequestOptions = { @@ -36,12 +41,18 @@ export async function calApiRequest(this: IExecuteFunctions | IWebhookFunctions } } -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/Calendly/CalendlyTrigger.node.ts b/packages/nodes-base/nodes/Calendly/CalendlyTrigger.node.ts index 8feec84819d8e..90138546f347f 100644 --- a/packages/nodes-base/nodes/Calendly/CalendlyTrigger.node.ts +++ b/packages/nodes-base/nodes/Calendly/CalendlyTrigger.node.ts @@ -1,19 +1,8 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; - -import { - IDataObject, - INodeType, - INodeTypeDescription, - IWebhookResponseData, -} from 'n8n-workflow'; - -import { - calendlyApiRequest, - getAuthenticationType, -} from './GenericFunctions'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; + +import { IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; + +import { calendlyApiRequest, getAuthenticationType } from './GenericFunctions'; export class CalendlyTrigger implements INodeType { description: INodeTypeDescription = { @@ -59,7 +48,8 @@ export class CalendlyTrigger implements INodeType { { name: 'User', value: 'user', - description: 'Triggers the webhook for subscribed events that belong to the current user', + description: + 'Triggers the webhook for subscribed events that belong to the current user', }, ], }, @@ -83,7 +73,6 @@ export class CalendlyTrigger implements INodeType { required: true, }, ], - }; // @ts-ignore (because of request) @@ -93,7 +82,7 @@ export class CalendlyTrigger implements INodeType { const webhookUrl = this.getNodeWebhookUrl('default'); const webhookData = this.getWorkflowStaticData('node'); const events = this.getNodeParameter('events') as string; - const { apiKey } = await this.getCredentials('calendlyApi') as { apiKey: string }; + const { apiKey } = (await this.getCredentials('calendlyApi')) as { apiKey: string }; const authenticationType = getAuthenticationType(apiKey); @@ -156,7 +145,7 @@ export class CalendlyTrigger implements INodeType { const webhookData = this.getWorkflowStaticData('node'); const webhookUrl = this.getNodeWebhookUrl('default'); const events = this.getNodeParameter('events') as string; - const { apiKey } = await this.getCredentials('calendlyApi') as { apiKey: string }; + const { apiKey } = (await this.getCredentials('calendlyApi')) as { apiKey: string }; const authenticationType = getAuthenticationType(apiKey); @@ -190,7 +179,7 @@ export class CalendlyTrigger implements INodeType { scope, }; - if ( scope === 'user') { + if (scope === 'user') { body.user = resource.uri; } @@ -208,13 +197,12 @@ export class CalendlyTrigger implements INodeType { }, async delete(this: IHookFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); - const { apiKey } = await this.getCredentials('calendlyApi') as { apiKey: string }; + const { apiKey } = (await this.getCredentials('calendlyApi')) as { apiKey: string }; const authenticationType = getAuthenticationType(apiKey); // remove condition once API Keys are deprecated if (authenticationType === 'apiKey') { if (webhookData.webhookId !== undefined) { - const endpoint = `/hooks/${webhookData.webhookId}`; try { @@ -232,7 +220,14 @@ export class CalendlyTrigger implements INodeType { if (authenticationType === 'accessToken') { if (webhookData.webhookURI !== undefined) { try { - await calendlyApiRequest.call(this, 'DELETE', '', {}, {}, webhookData.webhookURI as string); + await calendlyApiRequest.call( + this, + 'DELETE', + '', + {}, + {}, + webhookData.webhookURI as string, + ); } catch (error) { return false; } @@ -249,9 +244,7 @@ export class CalendlyTrigger 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/Calendly/GenericFunctions.ts b/packages/nodes-base/nodes/Calendly/GenericFunctions.ts index a801c3aa3e1f3..46fd1fc63dee6 100644 --- a/packages/nodes-base/nodes/Calendly/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Calendly/GenericFunctions.ts @@ -1,9 +1,6 @@ import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -14,9 +11,18 @@ import { NodeApiError, } from 'n8n-workflow'; -export async function calendlyApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any - - const { apiKey } = await this.getCredentials('calendlyApi') as { apiKey: string }; +export async function calendlyApiRequest( + 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 { apiKey } = (await this.getCredentials('calendlyApi')) as { apiKey: string }; const authenticationType = getAuthenticationType(apiKey); @@ -60,11 +66,15 @@ export function getAuthenticationType(data: string): 'accessToken' | 'apiKey' { return data.includes('.') ? 'accessToken' : 'apiKey'; } -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 { apiKey } = credentials as { - apiKey: string, + apiKey: string; }; const authenticationType = getAuthenticationType(apiKey); @@ -76,9 +86,15 @@ export async function validateCredentials(this: ICredentialTestFunctions, decryp }; if (authenticationType === 'accessToken') { - Object.assign(options, { headers: { 'Authorization': `Bearer ${apiKey}` }, uri: 'https://api.calendly.com/users/me' }); + Object.assign(options, { + headers: { Authorization: `Bearer ${apiKey}` }, + uri: 'https://api.calendly.com/users/me', + }); } else { - Object.assign(options, { headers: { 'X-TOKEN': apiKey }, uri: 'https://calendly.com/api/v1/users/me' }); + Object.assign(options, { + headers: { 'X-TOKEN': apiKey }, + uri: 'https://calendly.com/api/v1/users/me', + }); } return this.helpers.request!(options); } diff --git a/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts b/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts index 5eaf3908cf7ee..75528ea58d6f7 100644 --- a/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts +++ b/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts @@ -9,7 +9,6 @@ import { NodeParameterValue, } from 'n8n-workflow'; - interface CustomProperty { name: string; value: string; @@ -23,7 +22,6 @@ interface FilterValues { [key: string]: FilterValue[]; } - export class Chargebee implements INodeType { description: INodeTypeDescription = { displayName: 'Chargebee', @@ -68,8 +66,6 @@ export class Chargebee implements INodeType { default: 'invoice', }, - - // ---------------------------------- // customer // ---------------------------------- @@ -80,9 +76,7 @@ export class Chargebee implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'customer', - ], + resource: ['customer'], }, }, options: [ @@ -105,12 +99,8 @@ export class Chargebee implements INodeType { type: 'collection', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'customer', - ], + operation: ['create'], + resource: ['customer'], }, }, default: {}, @@ -193,12 +183,9 @@ export class Chargebee implements INodeType { }, ], }, - ], }, - - // ---------------------------------- // invoice // ---------------------------------- @@ -210,9 +197,7 @@ export class Chargebee implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'invoice', - ], + resource: ['invoice'], }, }, options: [ @@ -245,12 +230,8 @@ export class Chargebee implements INodeType { default: 10, displayOptions: { show: { - operation: [ - 'list', - ], - resource: [ - 'invoice', - ], + operation: ['list'], + resource: ['invoice'], }, }, description: 'Max. amount of results to return(< 100).', @@ -267,12 +248,8 @@ export class Chargebee implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'list', - ], - resource: [ - 'invoice', - ], + operation: ['list'], + resource: ['invoice'], }, }, options: [ @@ -302,7 +279,6 @@ export class Chargebee implements INodeType { name: 'Before', value: 'before', }, - ], default: 'after', description: 'Operation to decide where the the data should be mapped to', @@ -381,18 +357,12 @@ export class Chargebee implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'pdfUrl', - ], - resource: [ - 'invoice', - ], + operation: ['pdfUrl'], + resource: ['invoice'], }, }, }, - - // ---------------------------------- // subscription // ---------------------------------- @@ -403,9 +373,7 @@ export class Chargebee implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'subscription', - ], + resource: ['subscription'], }, }, options: [ @@ -437,12 +405,8 @@ export class Chargebee implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'cancel', - ], - resource: [ - 'subscription', - ], + operation: ['cancel'], + resource: ['subscription'], }, }, }, @@ -453,15 +417,12 @@ export class Chargebee implements INodeType { default: false, displayOptions: { show: { - operation: [ - 'cancel', - ], - resource: [ - 'subscription', - ], + operation: ['cancel'], + resource: ['subscription'], }, }, - description: 'Whether it will not cancel it directly in will instead schedule the cancelation for the end of the term', + description: + 'Whether it will not cancel it directly in will instead schedule the cancelation for the end of the term', }, // ---------------------------------- @@ -476,21 +437,14 @@ export class Chargebee implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'delete', - ], - resource: [ - 'subscription', - ], + operation: ['delete'], + resource: ['subscription'], }, }, }, - ], }; - - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -526,8 +480,12 @@ export class Chargebee implements INodeType { const properties = this.getNodeParameter('properties', i, {}) as IDataObject; for (const key of Object.keys(properties)) { - if (key === 'customProperties' && (properties.customProperties as IDataObject).property !== undefined) { - for (const customProperty of (properties.customProperties as IDataObject)!.property! as CustomProperty[]) { + if ( + key === 'customProperties' && + (properties.customProperties as IDataObject).property !== undefined + ) { + for (const customProperty of (properties.customProperties as IDataObject)! + .property! as CustomProperty[]) { qs[customProperty.name] = customProperty.value; } } else { @@ -537,9 +495,12 @@ export class Chargebee implements INodeType { endpoint = `customers`; } 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 === 'invoice') { if (operation === 'list') { // ---------------------------------- @@ -552,7 +513,11 @@ export class Chargebee implements INodeType { qs.limit = this.getNodeParameter('maxResults', i, {}); - const setFilters: FilterValues = this.getNodeParameter('filters', i, {}) as unknown as FilterValues; + const setFilters: FilterValues = this.getNodeParameter( + 'filters', + i, + {}, + ) as unknown as FilterValues; let filter: FilterValue; let value: NodeParameterValue; @@ -575,9 +540,12 @@ export class Chargebee implements INodeType { const invoiceId = this.getNodeParameter('invoiceId', i) as string; endpoint = `invoices/${invoiceId.trim()}/pdf`; } 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 === 'subscription') { if (operation === 'cancel') { // ---------------------------------- @@ -601,10 +569,16 @@ export class Chargebee implements INodeType { endpoint = `subscriptions/${subscriptionId.trim()}/delete`; } 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 options = { diff --git a/packages/nodes-base/nodes/Chargebee/ChargebeeTrigger.node.ts b/packages/nodes-base/nodes/Chargebee/ChargebeeTrigger.node.ts index c8f882f700415..09e7772e9d1e0 100644 --- a/packages/nodes-base/nodes/Chargebee/ChargebeeTrigger.node.ts +++ b/packages/nodes-base/nodes/Chargebee/ChargebeeTrigger.node.ts @@ -1,14 +1,6 @@ -import { - IWebhookFunctions, -} from 'n8n-core'; - -import { - IDataObject, - INodeType, - INodeTypeDescription, - IWebhookResponseData, -} from 'n8n-workflow'; +import { IWebhookFunctions } from 'n8n-core'; +import { IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; export class ChargebeeTrigger implements INodeType { description: INodeTypeDescription = { @@ -63,7 +55,8 @@ export class ChargebeeTrigger implements INodeType { { name: 'Card Expiring', value: 'card_expiring', - description: 'Triggered when the customer\'s credit card is expiring soon.Triggered 30 days before the expiry date', + description: + "Triggered when the customer's credit card is expiring soon.Triggered 30 days before the expiry date", }, { name: 'Card Updated', @@ -88,7 +81,8 @@ export class ChargebeeTrigger implements INodeType { { name: 'Invoice Created', value: 'invoice_created', - description: 'Event triggered (in the case of metered billing) when a \'Pending\' invoice is created that has usage related charges or line items to be added, before being closed. This is triggered only when the “Notify for Pending Invoices” option is enabled.', + description: + "Event triggered (in the case of metered billing) when a 'Pending' invoice is created that has usage related charges or line items to be added, before being closed. This is triggered only when the “Notify for Pending Invoices” option is enabled.", }, { name: 'Invoice Deleted', @@ -98,17 +92,19 @@ export class ChargebeeTrigger implements INodeType { { name: 'Invoice Generated', value: 'invoice_generated', - description: 'Event triggered when a new invoice is generated. In case of metered billing, this event is triggered when a \'Pending\' invoice is closed.', + description: + "Event triggered when a new invoice is generated. In case of metered billing, this event is triggered when a 'Pending' invoice is closed.", }, { name: 'Invoice Updated', value: 'invoice_updated', - description: 'Triggered when the invoice’s shipping/billing address is updated, if the invoice is voided, or when the amount due is modified due to payments applied/removed', + description: + 'Triggered when the invoice’s shipping/billing address is updated, if the invoice is voided, or when the amount due is modified due to payments applied/removed', }, { name: 'Payment Failed', value: 'payment_failed', - description: 'Triggered when attempt to charge customer\'s credit card fails', + description: "Triggered when attempt to charge customer's credit card fails", }, { name: 'Payment Initiated', @@ -133,17 +129,20 @@ export class ChargebeeTrigger implements INodeType { { name: 'Subscription Activated', value: 'subscription_activated', - description: 'Triggered after the subscription has been moved from \'Trial\' to \'Active\' state', + description: + "Triggered after the subscription has been moved from 'Trial' to 'Active' state", }, { name: 'Subscription Cancellation Scheduled', value: 'subscription_cancellation_scheduled', - description: 'Triggered when subscription is scheduled to cancel at end of current term', + description: + 'Triggered when subscription is scheduled to cancel at end of current term', }, { name: 'Subscription Cancelled', value: 'subscription_cancelled', - description: 'Triggered when the subscription is cancelled. If it is cancelled due to non payment or because the card details are not present, the subscription will have the possible reason as \'cancel_reason\'.', + description: + "Triggered when the subscription is cancelled. If it is cancelled due to non payment or because the card details are not present, the subscription will have the possible reason as 'cancel_reason'.", }, { name: 'Subscription Cancelling', @@ -153,7 +152,7 @@ export class ChargebeeTrigger implements INodeType { { name: 'Subscription Changed', value: 'subscription_changed', - description: 'Triggered when the subscription\'s recurring items are changed', + description: "Triggered when the subscription's recurring items are changed", }, { name: 'Subscription Created', @@ -168,12 +167,13 @@ export class ChargebeeTrigger implements INodeType { { name: 'Subscription Reactivated', value: 'subscription_reactivated', - description: 'Triggered when the subscription is moved from cancelled state to \'Active\' or \'Trial\' state', + description: + "Triggered when the subscription is moved from cancelled state to 'Active' or 'Trial' state", }, { name: 'Subscription Renewal Reminder', value: 'subscription_renewal_reminder', - description: 'Triggered 3 days before each subscription\'s renewal', + description: "Triggered 3 days before each subscription's renewal", }, { name: 'Subscription Renewed', @@ -193,12 +193,12 @@ export class ChargebeeTrigger implements INodeType { { name: 'Subscription Started', value: 'subscription_started', - description: 'Triggered when a \'future\' subscription gets started', + description: "Triggered when a 'future' subscription gets started", }, { name: 'Subscription Trial Ending', value: 'subscription_trial_ending', - description: 'Triggered 6 days prior to the trial period\'s end date', + description: "Triggered 6 days prior to the trial period's end date", }, { name: 'Transaction Created', @@ -213,12 +213,12 @@ export class ChargebeeTrigger implements INodeType { { name: 'Transaction Updated', value: 'transaction_updated', - description: 'Triggered when a transaction is updated. E.g. (1) When a transaction is removed, (2) or when an excess payment is applied on an invoice, (3) or when amount_capturable gets updated.', + description: + 'Triggered when a transaction is updated. E.g. (1) When a transaction is removed, (2) or when an excess payment is applied on an invoice, (3) or when amount_capturable gets updated.', }, ], }, ], - }; async webhook(this: IWebhookFunctions): Promise { @@ -229,16 +229,14 @@ export class ChargebeeTrigger implements INodeType { const eventType = bodyData.event_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/CircleCi/CircleCi.node.ts b/packages/nodes-base/nodes/CircleCi/CircleCi.node.ts index d99696b035490..8e326cccff37e 100644 --- a/packages/nodes-base/nodes/CircleCi/CircleCi.node.ts +++ b/packages/nodes-base/nodes/CircleCi/CircleCi.node.ts @@ -1,23 +1,10 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; - -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; - -import { - pipelineFields, - pipelineOperations, -} from './PipelineDescription'; - -import { - circleciApiRequest, - circleciApiRequestAllItems, -} from './GenericFunctions'; +import { IExecuteFunctions } from 'n8n-core'; + +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; + +import { pipelineFields, pipelineOperations } from './PipelineDescription'; + +import { circleciApiRequest, circleciApiRequestAllItems } from './GenericFunctions'; export class CircleCi implements INodeType { description: INodeTypeDescription = { @@ -97,8 +84,14 @@ export class CircleCi implements INodeType { const endpoint = `/project/${vcs}/${slug}/pipeline`; if (returnAll === true) { - responseData = await circleciApiRequestAllItems.call(this, 'items', 'GET', endpoint, {}, qs); - + responseData = await circleciApiRequestAllItems.call( + this, + 'items', + 'GET', + endpoint, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await circleciApiRequest.call(this, 'GET', endpoint, {}, qs); diff --git a/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts b/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts index 88afcefed508c..ee9eb11a81e26 100644 --- a/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,21 +7,29 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function circleciApiRequest(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 circleciApiRequest( + 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('circleCiApi'); let options: OptionsWithUri = { headers: { 'Circle-Token': credentials.apiKey, - 'Accept': 'application/json', + Accept: 'application/json', }, method, qs, body, - uri: uri ||`https://circleci.com/api/v2${resource}`, + uri: uri || `https://circleci.com/api/v2${resource}`, json: true, }; options = Object.assign({}, options, option); @@ -41,8 +47,16 @@ export async function circleciApiRequest(this: IHookFunctions | IExecuteFunction * Make an API request to paginated CircleCI endpoint * and return all results */ -export async function circleciApiRequestAllItems(this: IHookFunctions | IExecuteFunctions| ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function circleciApiRequestAllItems( + 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; @@ -51,9 +65,6 @@ export async function circleciApiRequestAllItems(this: IHookFunctions | IExecute responseData = await circleciApiRequest.call(this, method, resource, body, query); returnData.push.apply(returnData, responseData[propertyName]); query['page-token'] = responseData.next_page_token; - } while ( - responseData.next_page_token !== undefined && - responseData.next_page_token !== null - ); + } while (responseData.next_page_token !== undefined && responseData.next_page_token !== null); return returnData; } diff --git a/packages/nodes-base/nodes/CircleCi/PipelineDescription.ts b/packages/nodes-base/nodes/CircleCi/PipelineDescription.ts index 592f07776688e..243a546d5212d 100644 --- a/packages/nodes-base/nodes/CircleCi/PipelineDescription.ts +++ b/packages/nodes-base/nodes/CircleCi/PipelineDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const pipelineOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const pipelineOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'pipeline', - ], + resource: ['pipeline'], }, }, options: [ @@ -40,10 +36,9 @@ export const pipelineOperations: INodeProperties[] = [ ]; export const pipelineFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* pipeline:shared */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* pipeline:shared */ + /* -------------------------------------------------------------------------- */ { displayName: 'Provider', name: 'vcs', @@ -60,14 +55,8 @@ export const pipelineFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'get', - 'getAll', - 'trigger', - ], - resource: [ - 'pipeline', - ], + operation: ['get', 'getAll', 'trigger'], + resource: ['pipeline'], }, }, default: '', @@ -79,14 +68,8 @@ export const pipelineFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - operation: [ - 'get', - 'getAll', - 'trigger', - ], - resource: [ - 'pipeline', - ], + operation: ['get', 'getAll', 'trigger'], + resource: ['pipeline'], }, }, default: '', @@ -94,9 +77,9 @@ export const pipelineFields: INodeProperties[] = [ description: 'Project slug in the form org-name/repo-name', }, -/* -------------------------------------------------------------------------- */ -/* pipeline:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* pipeline:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Pipeline Number', name: 'pipelineNumber', @@ -106,33 +89,25 @@ export const pipelineFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'pipeline', - ], + operation: ['get'], + resource: ['pipeline'], }, }, default: 1, description: 'The number of the pipeline', }, -/* -------------------------------------------------------------------------- */ -/* pipeline:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* pipeline:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Return All', name: 'returnAll', type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'pipeline', - ], + operation: ['getAll'], + resource: ['pipeline'], }, }, default: false, @@ -144,15 +119,9 @@ export const pipelineFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'pipeline', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['pipeline'], + returnAll: [false], }, }, typeOptions: { @@ -170,12 +139,8 @@ export const pipelineFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'pipeline', - ], - operation: [ - 'getAll', - ], + resource: ['pipeline'], + operation: ['getAll'], }, }, options: [ @@ -189,9 +154,9 @@ export const pipelineFields: INodeProperties[] = [ ], }, -/* -------------------------------------------------------------------------- */ -/* pipeline:trigger */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* pipeline:trigger */ + /* -------------------------------------------------------------------------- */ { displayName: 'Additional Fields', name: 'additionalFields', @@ -200,12 +165,8 @@ export const pipelineFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'pipeline', - ], - operation: [ - 'trigger', - ], + resource: ['pipeline'], + operation: ['trigger'], }, }, options: [ @@ -214,14 +175,16 @@ export const pipelineFields: INodeProperties[] = [ name: 'branch', type: 'string', default: '', - description: 'The branch where the pipeline ran. The HEAD commit on this branch was used for the pipeline. Note that branch and tag are mutually exclusive.', + description: + 'The branch where the pipeline ran. The HEAD commit on this branch was used for the pipeline. Note that branch and tag are mutually exclusive.', }, { displayName: 'Tag', name: 'tag', type: 'string', default: '', - description: 'The tag used by the pipeline. The commit that this tag points to was used for the pipeline. Note that branch and tag are mutually exclusive', + description: + 'The tag used by the pipeline. The commit that this tag points to was used for the pipeline. Note that branch and tag are mutually exclusive', }, ], }, diff --git a/packages/nodes-base/nodes/Cisco/Webex/CiscoWebex.node.ts b/packages/nodes-base/nodes/Cisco/Webex/CiscoWebex.node.ts index 13a68af67e19a..7b85bec62d93f 100644 --- a/packages/nodes-base/nodes/Cisco/Webex/CiscoWebex.node.ts +++ b/packages/nodes-base/nodes/Cisco/Webex/CiscoWebex.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryData, @@ -13,11 +11,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - getAttachemnts, - webexApiRequest, - webexApiRequestAllItems, -} from './GenericFunctions'; +import { getAttachemnts, webexApiRequest, webexApiRequestAllItems } from './GenericFunctions'; import { meetingFields, @@ -97,7 +91,12 @@ export class CiscoWebex implements INodeType { }, async getSites(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const sites = await webexApiRequestAllItems.call(this, 'sites', 'GET', '/meetingPreferences/sites'); + const sites = await webexApiRequestAllItems.call( + this, + 'sites', + 'GET', + '/meetingPreferences/sites', + ); for (const site of sites) { returnData.push({ name: site.siteUrl, @@ -118,25 +117,25 @@ export class CiscoWebex implements INodeType { let responseData; - for (let i = 0; i < items.length; i++) { - try { if (resource === 'message') { - // ********************************************************************** // message // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // message: create // ---------------------------------------- // https://developer.webex.com/docs/api/v1/messages/create-a-message const destination = this.getNodeParameter('destination', i); - const file = this.getNodeParameter('additionalFields.fileUi.fileValue', i, {}) as IDataObject; + const file = this.getNodeParameter( + 'additionalFields.fileUi.fileValue', + i, + {}, + ) as IDataObject; const markdown = this.getNodeParameter('additionalFields.markdown', i, '') as boolean; const body = {} as IDataObject; if (destination === 'room') { @@ -158,22 +157,31 @@ export class CiscoWebex implements INodeType { body['text'] = this.getNodeParameter('text', i); - body.attachments = getAttachemnts(this.getNodeParameter('additionalFields.attachmentsUi.attachmentValues', i, []) as IDataObject[]); + body.attachments = getAttachemnts( + this.getNodeParameter( + 'additionalFields.attachmentsUi.attachmentValues', + i, + [], + ) as IDataObject[], + ); if (Object.keys(file).length) { - const isBinaryData = file.fileLocation === 'binaryData' ? true : false; if (isBinaryData) { - 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 = file.binaryPropertyName as string; const binaryData = items[i].binary![binaryPropertyName] as IBinaryData; - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + i, + binaryPropertyName, + ); const formData = { files: { @@ -192,14 +200,19 @@ export class CiscoWebex implements INodeType { } if (file.fileLocation === 'binaryData') { - responseData = await webexApiRequest.call(this, 'POST', '/messages', {}, {}, undefined, { formData: body }); + responseData = await webexApiRequest.call( + this, + 'POST', + '/messages', + {}, + {}, + undefined, + { formData: body }, + ); } else { responseData = await webexApiRequest.call(this, 'POST', '/messages', body); } - - } else if (operation === 'delete') { - // ---------------------------------------- // message: delete // ---------------------------------------- @@ -210,9 +223,7 @@ export class CiscoWebex implements INodeType { const endpoint = `/messages/${messageId}`; responseData = await webexApiRequest.call(this, 'DELETE', endpoint); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // message: get // ---------------------------------------- @@ -222,10 +233,7 @@ export class CiscoWebex implements INodeType { const endpoint = `/messages/${messageId}`; responseData = await webexApiRequest.call(this, 'GET', endpoint); - - } else if (operation === 'getAll') { - // ---------------------------------------- // message: getAll // ---------------------------------------- @@ -237,22 +245,25 @@ export class CiscoWebex implements INodeType { const filters = this.getNodeParameter('filters', i) as IDataObject; const returnAll = this.getNodeParameter('returnAll', i) as boolean; - if (Object.keys(filters).length) { Object.assign(qs, filters); } if (returnAll === true) { - responseData = await webexApiRequestAllItems.call(this, 'items', 'GET', '/messages', {}, qs); + responseData = await webexApiRequestAllItems.call( + this, + 'items', + 'GET', + '/messages', + {}, + qs, + ); } else { qs.max = this.getNodeParameter('limit', i) as number; responseData = await webexApiRequest.call(this, 'GET', '/messages', {}, qs); responseData = responseData.items; } - - } else if (operation === 'update') { - // ---------------------------------------- // message: update // ---------------------------------------- @@ -284,7 +295,11 @@ export class CiscoWebex implements INodeType { const title = this.getNodeParameter('title', i) as string; const start = this.getNodeParameter('start', i) as string; const end = this.getNodeParameter('end', i) as string; - const invitees = this.getNodeParameter('additionalFields.inviteesUi.inviteeValues', i, []) as IDataObject[]; + const invitees = this.getNodeParameter( + 'additionalFields.inviteesUi.inviteeValues', + i, + [], + ) as IDataObject[]; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body: IDataObject = { @@ -295,8 +310,10 @@ export class CiscoWebex implements INodeType { }; if (body.requireRegistrationInfo) { - body['registration'] = (body.requireRegistrationInfo as string[]) - .reduce((obj, value) => Object.assign(obj, { [`${value}`]: true }), {}); + body['registration'] = (body.requireRegistrationInfo as string[]).reduce( + (obj, value) => Object.assign(obj, { [`${value}`]: true }), + {}, + ); delete body.requireRegistrationInfo; } @@ -306,7 +323,6 @@ export class CiscoWebex implements INodeType { } responseData = await webexApiRequest.call(this, 'POST', '/meetings', body); - } if (operation === 'delete') { @@ -317,7 +333,13 @@ export class CiscoWebex implements INodeType { ...options, }; - responseData = await webexApiRequest.call(this, 'DELETE', `/meetings/${meetingId}`, {}, qs); + responseData = await webexApiRequest.call( + this, + 'DELETE', + `/meetings/${meetingId}`, + {}, + qs, + ); responseData = { success: true }; } @@ -336,7 +358,15 @@ export class CiscoWebex implements INodeType { }; } - responseData = await webexApiRequest.call(this, 'GET', `/meetings/${meetingId}`, {}, qs, undefined, { headers }); + responseData = await webexApiRequest.call( + this, + 'GET', + `/meetings/${meetingId}`, + {}, + qs, + undefined, + { headers }, + ); } if (operation === 'getAll') { @@ -348,15 +378,26 @@ export class CiscoWebex implements INodeType { }; if (qs.from) { - qs.from = moment(qs.from as string).utc(true).format(); + qs.from = moment(qs.from as string) + .utc(true) + .format(); } if (qs.to) { - qs.to = moment(qs.to as string).utc(true).format(); + qs.to = moment(qs.to as string) + .utc(true) + .format(); } if (returnAll === true) { - responseData = await webexApiRequestAllItems.call(this, 'items', 'GET', '/meetings', {}, qs); + responseData = await webexApiRequestAllItems.call( + this, + 'items', + 'GET', + '/meetings', + {}, + qs, + ); returnData.push(...responseData); } else { qs.max = this.getNodeParameter('limit', i) as number; @@ -367,23 +408,28 @@ export class CiscoWebex implements INodeType { if (operation === 'update') { const meetingId = this.getNodeParameter('meetingId', i) as string; - const invitees = this.getNodeParameter('updateFields.inviteesUi.inviteeValues', i, []) as IDataObject[]; + const invitees = this.getNodeParameter( + 'updateFields.inviteesUi.inviteeValues', + i, + [], + ) as IDataObject[]; const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; - const { - title, - password, - start, - end, - } = await webexApiRequest.call(this, 'GET', `/meetings/${meetingId}`); + const { title, password, start, end } = await webexApiRequest.call( + this, + 'GET', + `/meetings/${meetingId}`, + ); const body: IDataObject = { ...updateFields, }; if (body.requireRegistrationInfo) { - body['registration'] = (body.requireRegistrationInfo as string[]) - .reduce((obj, value) => Object.assign(obj, { [`${value}`]: true }), {}); + body['registration'] = (body.requireRegistrationInfo as string[]).reduce( + (obj, value) => Object.assign(obj, { [`${value}`]: true }), + {}, + ); delete body.requireRegistrationInfo; } @@ -412,7 +458,6 @@ export class CiscoWebex implements INodeType { } responseData = await webexApiRequest.call(this, 'PUT', `/meetings/${meetingId}`, body); - } } @@ -421,9 +466,7 @@ export class CiscoWebex implements INodeType { } else if (responseData !== undefined) { returnData.push(responseData as IDataObject); } - } catch (error) { - if (this.continueOnFail()) { returnData.push({ error: error.toString() }); continue; @@ -431,7 +474,6 @@ export class CiscoWebex implements INodeType { throw error; } - } // if (resource === 'meetingTranscript') { diff --git a/packages/nodes-base/nodes/Cisco/Webex/CiscoWebexTrigger.node.ts b/packages/nodes-base/nodes/Cisco/Webex/CiscoWebexTrigger.node.ts index 2f2422c431f75..f1e6a015c93b5 100644 --- a/packages/nodes-base/nodes/Cisco/Webex/CiscoWebexTrigger.node.ts +++ b/packages/nodes-base/nodes/Cisco/Webex/CiscoWebexTrigger.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 { webexApiRequestAllItems, } from './GenericFunctions'; -import { - createHmac, -} from 'crypto'; +import { createHmac } from 'crypto'; export class CiscoWebexTrigger implements INodeType { description: INodeTypeDescription = { @@ -102,14 +97,13 @@ export class CiscoWebexTrigger implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'attachmentAction', - ], + resource: ['attachmentAction'], }, }, default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default the response only contain a reference to the data the user inputed. If this option gets activated, it will resolve the data automatically.', + description: + 'By default the response only contain a reference to the data the user inputed. If this option gets activated, it will resolve the data automatically.', }, { displayName: 'Filters', @@ -124,13 +118,8 @@ export class CiscoWebexTrigger implements INodeType { type: 'boolean', displayOptions: { show: { - '/resource': [ - 'message', - ], - '/event': [ - 'created', - 'deleted', - ], + '/resource': ['message'], + '/event': ['created', 'deleted'], }, }, default: false, @@ -142,13 +131,8 @@ export class CiscoWebexTrigger implements INodeType { type: 'boolean', displayOptions: { show: { - '/resource': [ - 'room', - ], - '/event': [ - 'created', - 'updated', - ], + '/resource': ['room'], + '/event': ['created', 'updated'], }, }, default: false, @@ -160,14 +144,8 @@ export class CiscoWebexTrigger implements INodeType { type: 'boolean', displayOptions: { show: { - '/resource': [ - 'membership', - ], - '/event': [ - 'created', - 'updated', - 'deleted', - ], + '/resource': ['membership'], + '/event': ['created', 'updated', 'deleted'], }, }, default: false, @@ -179,17 +157,13 @@ export class CiscoWebexTrigger implements INodeType { type: 'string', displayOptions: { show: { - '/resource': [ - 'message', - ], - '/event': [ - 'created', - 'deleted', - ], + '/resource': ['message'], + '/event': ['created', 'deleted'], }, }, default: '', - description: 'Limit to messages which contain these mentioned people, by person ID; accepts me as a shorthand for your own person ID; separate multiple values with commas', + description: + 'Limit to messages which contain these mentioned people, by person ID; accepts me as a shorthand for your own person ID; separate multiple values with commas', }, { displayName: 'Message ID', @@ -197,12 +171,8 @@ export class CiscoWebexTrigger implements INodeType { type: 'string', displayOptions: { show: { - '/resource': [ - 'attachmentAction', - ], - '/event': [ - 'created', - ], + '/resource': ['attachmentAction'], + '/event': ['created'], }, }, default: '', @@ -213,9 +183,7 @@ export class CiscoWebexTrigger implements INodeType { name: 'ownedBy', displayOptions: { show: { - '/resource': [ - 'meeting', - ], + '/resource': ['meeting'], }, }, type: 'string', @@ -227,14 +195,8 @@ export class CiscoWebexTrigger implements INodeType { type: 'string', displayOptions: { show: { - '/resource': [ - 'membership', - ], - '/event': [ - 'created', - 'updated', - 'deleted', - ], + '/resource': ['membership'], + '/event': ['created', 'updated', 'deleted'], }, }, default: '', @@ -246,13 +208,8 @@ export class CiscoWebexTrigger implements INodeType { type: 'string', displayOptions: { show: { - '/resource': [ - 'message', - ], - '/event': [ - 'created', - 'deleted', - ], + '/resource': ['message'], + '/event': ['created', 'deleted'], }, }, default: '', @@ -264,12 +221,8 @@ export class CiscoWebexTrigger implements INodeType { type: 'string', displayOptions: { show: { - '/resource': [ - 'attachmentAction', - ], - '/event': [ - 'created', - ], + '/resource': ['attachmentAction'], + '/event': ['created'], }, }, default: '', @@ -281,14 +234,8 @@ export class CiscoWebexTrigger implements INodeType { type: 'string', displayOptions: { show: { - '/resource': [ - 'membership', - ], - '/event': [ - 'created', - 'updated', - 'deleted', - ], + '/resource': ['membership'], + '/event': ['created', 'updated', 'deleted'], }, }, default: '', @@ -300,13 +247,8 @@ export class CiscoWebexTrigger implements INodeType { type: 'string', displayOptions: { show: { - '/resource': [ - 'message', - ], - '/event': [ - 'created', - 'deleted', - ], + '/resource': ['message'], + '/event': ['created', 'deleted'], }, }, default: '', @@ -319,12 +261,8 @@ export class CiscoWebexTrigger implements INodeType { type: 'string', displayOptions: { show: { - '/resource': [ - 'attachmentAction', - ], - '/event': [ - 'created', - ], + '/resource': ['attachmentAction'], + '/event': ['created'], }, }, default: '', @@ -336,14 +274,8 @@ export class CiscoWebexTrigger implements INodeType { type: 'string', displayOptions: { show: { - '/resource': [ - 'membership', - ], - '/event': [ - 'created', - 'updated', - 'deleted', - ], + '/resource': ['membership'], + '/event': ['created', 'updated', 'deleted'], }, }, default: '', @@ -355,13 +287,8 @@ export class CiscoWebexTrigger implements INodeType { type: 'string', displayOptions: { show: { - '/resource': [ - 'message', - ], - '/event': [ - 'created', - 'updated', - ], + '/resource': ['message'], + '/event': ['created', 'updated'], }, }, default: '', @@ -383,13 +310,8 @@ export class CiscoWebexTrigger implements INodeType { ], displayOptions: { show: { - '/resource': [ - 'message', - ], - '/event': [ - 'created', - 'deleted', - ], + '/resource': ['message'], + '/event': ['created', 'deleted'], }, }, default: '', @@ -411,13 +333,8 @@ export class CiscoWebexTrigger implements INodeType { ], displayOptions: { show: { - '/resource': [ - 'room', - ], - '/event': [ - 'created', - 'updated', - ], + '/resource': ['room'], + '/event': ['created', 'updated'], }, }, default: '', @@ -587,10 +504,12 @@ export class CiscoWebexTrigger implements INodeType { // one that is supposed to get created. const data = await webexApiRequestAllItems.call(this, 'items', 'GET', '/webhooks'); for (const webhook of data) { - if (webhook.url === webhookUrl - && webhook.resource === mapResource(resource) - && webhook.event === event - && webhook.status === 'active') { + if ( + webhook.url === webhookUrl && + webhook.resource === mapResource(resource) && + webhook.event === event && + webhook.status === 'active' + ) { webhookData.webhookId = webhook.id as string; return true; } @@ -643,7 +562,6 @@ export class CiscoWebexTrigger implements INodeType { async delete(this: IHookFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); if (webhookData.webhookId !== undefined) { - const endpoint = `/webhooks/${webhookData.webhookId}`; try { await webexApiRequest.call(this, 'DELETE', endpoint); @@ -668,20 +586,23 @@ export class CiscoWebexTrigger implements INodeType { const resolveData = this.getNodeParameter('resolveData', false) as boolean; //@ts-ignore - const computedSignature = createHmac('sha1', webhookData.secret).update(req.rawBody).digest('hex'); + const computedSignature = createHmac('sha1', webhookData.secret) + //@ts-ignore + .update(req.rawBody) + .digest('hex'); if (headers['x-spark-signature'] !== computedSignature) { return {}; } if (resolveData) { - const { data: { id } } = bodyData as { data: { id: string } }; + const { + data: { id }, + } = bodyData as { data: { id: string } }; bodyData = await webexApiRequest.call(this, 'GET', `/attachment/actions/${id}`); } return { - workflowData: [ - this.helpers.returnJsonArray(bodyData), - ], + workflowData: [this.helpers.returnJsonArray(bodyData)], }; } } diff --git a/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts b/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts index 3ccef56ba18c8..561dac937f92c 100644 --- a/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts @@ -1,12 +1,6 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -16,15 +10,21 @@ import { NodeApiError, } from 'n8n-workflow'; -import { - upperFirst, -} from 'lodash'; +import { upperFirst } from 'lodash'; -import { - createHash, -} from 'crypto'; +import { createHash } from 'crypto'; -export async function webexApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function webexApiRequest( + this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | 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 { let options: OptionsWithUri = { method, body, @@ -43,21 +43,35 @@ export async function webexApiRequest(this: IExecuteFunctions | ILoadOptionsFunc delete options.qs; } //@ts-ignore - return await this.helpers.requestOAuth2.call(this, 'ciscoWebexOAuth2Api', options, { tokenType: 'Bearer' }); + return await this.helpers.requestOAuth2.call(this, 'ciscoWebexOAuth2Api', options, { + tokenType: 'Bearer', + }); } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function webexApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, options: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function webexApiRequestAllItems( + this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, + propertyName: string, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + query: IDataObject = {}, + options: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; let uri: string | undefined; query.max = 100; do { - responseData = await webexApiRequest.call(this, method, endpoint, body, query, uri, { resolveWithFullResponse: true, ...options }); + responseData = await webexApiRequest.call(this, method, endpoint, body, query, uri, { + resolveWithFullResponse: true, + ...options, + }); if (responseData.headers.link) { uri = responseData.headers['link'].split(';')[0].replace('<', '').replace('>', ''); } @@ -71,13 +85,13 @@ export async function webexApiRequestAllItems(this: IExecuteFunctions | ILoadOpt export function getEvents() { const resourceEvents: { [key: string]: string[] } = { - 'attachmentAction': ['created', 'deleted', 'updated', '*'], - 'membership': ['created', 'deleted', 'updated', '*'], - 'message': ['created', 'deleted', 'updated', '*'], - 'room': ['created', 'deleted', 'updated', '*'], - 'meeting': ['created', 'deleted', 'updated', 'started', 'ended', '*'], - 'recording': ['created', 'deleted', 'updated', '*'], - 'telephonyCall': ['created', 'deleted', 'updated'], + attachmentAction: ['created', 'deleted', 'updated', '*'], + membership: ['created', 'deleted', 'updated', '*'], + message: ['created', 'deleted', 'updated', '*'], + room: ['created', 'deleted', 'updated', '*'], + meeting: ['created', 'deleted', 'updated', 'started', 'ended', '*'], + recording: ['created', 'deleted', 'updated', '*'], + telephonyCall: ['created', 'deleted', 'updated'], '*': ['created', 'updated', 'deleted', '*'], }; @@ -90,12 +104,13 @@ export function getEvents() { type: 'options', displayOptions: { show: { - resource: [ - (resource === '*') ? 'all' : resource, - ], + resource: [resource === '*' ? 'all' : resource], }, }, - options: resourceEvents[resource].map((event) => ({ value: (event === '*' ? 'all' : event), name: upperFirst(event) })), + options: resourceEvents[resource].map((event) => ({ + value: event === '*' ? 'all' : event, + name: upperFirst(event), + })), default: '', required: true, }); @@ -104,16 +119,18 @@ export function getEvents() { } export function mapResource(event: string) { - return ({ - 'attachmentAction': 'attachmentActions', - 'membership': 'memberships', - 'message': 'messages', - 'room': 'rooms', - 'meeting': 'meetings', - 'recording': 'recordings', - 'telephonyCall': 'telephony_calls', - 'all': 'all', - } as { [key: string]: string })[event]; + return ( + { + attachmentAction: 'attachmentActions', + membership: 'memberships', + message: 'messages', + room: 'rooms', + meeting: 'meetings', + recording: 'recordings', + telephonyCall: 'telephony_calls', + all: 'all', + } as { [key: string]: string } + )[event]; } export function getAttachemnts(attachements: IDataObject[]) { @@ -121,18 +138,23 @@ export function getAttachemnts(attachements: IDataObject[]) { for (const attachment of attachements) { const body: IDataObject[] = []; const actions: IDataObject[] = []; - for (const element of (attachment?.elementsUi as IDataObject).elementValues as IDataObject[] || []) { + for (const element of ((attachment?.elementsUi as IDataObject) + .elementValues as IDataObject[]) || []) { // tslint:disable-next-line: no-any - const { type, ...rest } = element as { type: string, [key: string]: any }; + const { type, ...rest } = element as { type: string; [key: string]: any }; if (type.startsWith('input')) { - body.push({ type: `Input.${upperFirst(type.replace('input', ''))}`, ...removeEmptyProperties(rest) }); + body.push({ + type: `Input.${upperFirst(type.replace('input', ''))}`, + ...removeEmptyProperties(rest), + }); } else { body.push({ type: upperFirst(type), ...removeEmptyProperties(rest) }); } } - for (const action of (attachment?.actionsUi as IDataObject).actionValues as IDataObject[] || []) { + for (const action of ((attachment?.actionsUi as IDataObject).actionValues as IDataObject[]) || + []) { // tslint:disable-next-line: no-any - const { type, ...rest } = action as { type: string, [key: string]: any }; + const { type, ...rest } = action as { type: string; [key: string]: any }; actions.push({ type: `Action.${upperFirst(type)}`, ...removeEmptyProperties(rest) }); } _attachments.push({ @@ -164,7 +186,8 @@ export function getActionInheritedProperties(): INodeProperties[] { name: 'iconUrl', type: 'string', default: '', - description: 'Optional icon to be shown on the action in conjunction with the title. Supports data URI in version 1.2+.', + description: + 'Optional icon to be shown on the action in conjunction with the title. Supports data URI in version 1.2+.', }, { displayName: 'Style', @@ -185,7 +208,8 @@ export function getActionInheritedProperties(): INodeProperties[] { }, ], default: 'default', - description: 'Controls the style of an Action, which influences how the action is displayed, spoken, etc', + description: + 'Controls the style of an Action, which influences how the action is displayed, spoken, etc', }, ]; } @@ -199,13 +223,12 @@ export function getTextBlockProperties(): INodeProperties[] { default: '', displayOptions: { show: { - type: [ - 'textBlock', - ], + type: ['textBlock'], }, }, required: true, - description: 'Text to display. A subset of markdown is supported (https://aka.ms/ACTextFeatures).', + description: + 'Text to display. A subset of markdown is supported (https://aka.ms/ACTextFeatures).', }, { displayName: 'Color', @@ -213,9 +236,7 @@ export function getTextBlockProperties(): INodeProperties[] { type: 'options', displayOptions: { show: { - type: [ - 'textBlock', - ], + type: ['textBlock'], }, }, options: [ @@ -257,9 +278,7 @@ export function getTextBlockProperties(): INodeProperties[] { type: 'options', displayOptions: { show: { - type: [ - 'textBlock', - ], + type: ['textBlock'], }, }, options: [ @@ -281,9 +300,7 @@ export function getTextBlockProperties(): INodeProperties[] { type: 'options', displayOptions: { show: { - type: [ - 'textBlock', - ], + type: ['textBlock'], }, }, options: [ @@ -309,9 +326,7 @@ export function getTextBlockProperties(): INodeProperties[] { type: 'boolean', displayOptions: { show: { - type: [ - 'textBlock', - ], + type: ['textBlock'], }, }, default: false, @@ -323,9 +338,7 @@ export function getTextBlockProperties(): INodeProperties[] { type: 'number', displayOptions: { show: { - type: [ - 'textBlock', - ], + type: ['textBlock'], }, }, default: 1, @@ -337,9 +350,7 @@ export function getTextBlockProperties(): INodeProperties[] { type: 'options', displayOptions: { show: { - type: [ - 'textBlock', - ], + type: ['textBlock'], }, }, options: [ @@ -373,9 +384,7 @@ export function getTextBlockProperties(): INodeProperties[] { type: 'options', displayOptions: { show: { - type: [ - 'textBlock', - ], + type: ['textBlock'], }, }, options: [ @@ -401,9 +410,7 @@ export function getTextBlockProperties(): INodeProperties[] { type: 'boolean', displayOptions: { show: { - type: [ - 'textBlock', - ], + type: ['textBlock'], }, }, default: true, @@ -415,9 +422,7 @@ export function getTextBlockProperties(): INodeProperties[] { type: 'options', displayOptions: { show: { - type: [ - 'textBlock', - ], + type: ['textBlock'], }, }, options: [ @@ -440,9 +445,7 @@ export function getTextBlockProperties(): INodeProperties[] { default: false, displayOptions: { show: { - type: [ - 'textBlock', - ], + type: ['textBlock'], }, }, description: 'Whether to draw a separating line at the top of the element', @@ -453,9 +456,7 @@ export function getTextBlockProperties(): INodeProperties[] { type: 'options', displayOptions: { show: { - type: [ - 'textBlock', - ], + type: ['textBlock'], }, }, options: [ @@ -497,9 +498,7 @@ export function getTextBlockProperties(): INodeProperties[] { type: 'string', displayOptions: { show: { - type: [ - 'textBlock', - ], + type: ['textBlock'], }, }, default: '', @@ -511,9 +510,7 @@ export function getTextBlockProperties(): INodeProperties[] { type: 'boolean', displayOptions: { show: { - type: [ - 'textBlock', - ], + type: ['textBlock'], }, }, default: true, @@ -531,13 +528,12 @@ export function getInputTextProperties(): INodeProperties[] { required: true, displayOptions: { show: { - type: [ - 'inputText', - ], + type: ['inputText'], }, }, default: '', - description: 'Unique identifier for the value. Used to identify collected input when the Submit action is performed.', + description: + 'Unique identifier for the value. Used to identify collected input when the Submit action is performed.', }, { displayName: 'Is Multiline', @@ -545,9 +541,7 @@ export function getInputTextProperties(): INodeProperties[] { type: 'boolean', displayOptions: { show: { - type: [ - 'inputText', - ], + type: ['inputText'], }, }, default: false, @@ -559,9 +553,7 @@ export function getInputTextProperties(): INodeProperties[] { type: 'number', displayOptions: { show: { - type: [ - 'inputText', - ], + type: ['inputText'], }, }, default: 1, @@ -573,9 +565,7 @@ export function getInputTextProperties(): INodeProperties[] { type: 'string', displayOptions: { show: { - type: [ - 'inputText', - ], + type: ['inputText'], }, }, default: '', @@ -587,9 +577,7 @@ export function getInputTextProperties(): INodeProperties[] { type: 'string', displayOptions: { show: { - type: [ - 'inputText', - ], + type: ['inputText'], }, }, default: '', @@ -601,9 +589,7 @@ export function getInputTextProperties(): INodeProperties[] { type: 'options', displayOptions: { show: { - type: [ - 'inputText', - ], + type: ['inputText'], }, }, options: [ @@ -633,9 +619,7 @@ export function getInputTextProperties(): INodeProperties[] { type: 'string', displayOptions: { show: { - type: [ - 'inputText', - ], + type: ['inputText'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Cisco/Webex/descriptions/MeetingDescription.ts b/packages/nodes-base/nodes/Cisco/Webex/descriptions/MeetingDescription.ts index ad1b44741868b..61cdef4928831 100644 --- a/packages/nodes-base/nodes/Cisco/Webex/descriptions/MeetingDescription.ts +++ b/packages/nodes-base/nodes/Cisco/Webex/descriptions/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: [ @@ -58,12 +54,8 @@ export const meetingFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'meeting', - ], - operation: [ - 'create', - ], + resource: ['meeting'], + operation: ['create'], }, }, description: 'Meeting title. The title can be a maximum of 128 characters long.', @@ -76,15 +68,12 @@ export const meetingFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'meeting', - ], - operation: [ - 'create', - ], + resource: ['meeting'], + operation: ['create'], }, }, - description: 'Date and time for the start of the meeting. Acceptable format.', + description: + 'Date and time for the start of the meeting. Acceptable format.', }, { displayName: 'End', @@ -94,15 +83,12 @@ export const meetingFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'meeting', - ], - operation: [ - 'create', - ], + resource: ['meeting'], + operation: ['create'], }, }, - description: 'Date and time for the end of the meeting. Acceptable format.', + description: + 'Date and time for the end of the meeting. Acceptable format.', }, { displayName: 'Additional Fields', @@ -110,12 +96,8 @@ export const meetingFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - resource: [ - 'meeting', - ], - operation: [ - 'create', - ], + resource: ['meeting'], + operation: ['create'], }, }, default: {}, @@ -133,21 +115,24 @@ export const meetingFields: INodeProperties[] = [ name: 'allowAnyUserToBeCoHost', type: 'boolean', default: false, - description: 'Whether or not to allow any attendee with a host account on the target site to become a co-host when joining the meeting', + description: + 'Whether or not to allow any attendee with a host account on the target site to become a co-host when joining the meeting', }, { displayName: 'Allow Authenticated Devices', name: 'allowAuthenticatedDevices', type: 'boolean', default: false, - description: 'Whether or not to allow authenticated video devices in the meeting\'s organization to start or join the meeting without a prompt', + description: + "Whether or not to allow authenticated video devices in the meeting's organization to start or join the meeting without a prompt", }, { displayName: 'Allow First User To Be Co-Host', name: 'allowFirstUserToBeCoHost', type: 'boolean', default: false, - description: 'Whether or not to allow the first attendee of the meeting with a host account on the target site to become a co-host', + description: + 'Whether or not to allow the first attendee of the meeting with a host account on the target site to become a co-host', }, { displayName: 'Auto Accept Request', @@ -161,7 +146,8 @@ export const meetingFields: INodeProperties[] = [ name: 'enableConnectAudioBeforeHost', type: 'boolean', default: false, - description: 'Whether or not to allow any attendee to connect audio in the meeting before the host joins the meeting', + description: + 'Whether or not to allow any attendee to connect audio in the meeting before the host joins the meeting', }, { displayName: 'Enabled Auto Record Meeting', @@ -175,7 +161,8 @@ export const meetingFields: INodeProperties[] = [ name: 'enabledJoinBeforeHost', type: 'boolean', default: false, - description: 'Whether or not to allow any attendee to join the meeting before the host joins the meeting', + description: + 'Whether or not to allow any attendee to join the meeting before the host joins the meeting', }, { displayName: 'Exclude Password', @@ -189,14 +176,15 @@ export const meetingFields: INodeProperties[] = [ name: 'hostEmail', type: 'string', default: '', - description: 'Email address for the meeting host. Can only be set if you\'re an admin.', + description: "Email address for the meeting host. Can only be set if you're an admin.", }, { displayName: 'Integration Tags', name: 'integrationTags', type: 'string', default: '', - description: 'External keys created by an integration application in its own domain. They could be Zendesk ticket IDs, Jira IDs, Salesforce Opportunity IDs, etc.', + description: + 'External keys created by an integration application in its own domain. They could be Zendesk ticket IDs, Jira IDs, Salesforce Opportunity IDs, etc.', }, { displayName: 'Invitees', @@ -262,7 +250,8 @@ export const meetingFields: INodeProperties[] = [ }, ], default: 0, - description: 'The number of minutes an attendee can join the meeting before the meeting start time and the host joins', + description: + 'The number of minutes an attendee can join the meeting before the meeting start time and the host joins', }, { displayName: 'Public Meeting', @@ -276,7 +265,8 @@ export const meetingFields: INodeProperties[] = [ name: 'recurrence', type: 'string', default: '', - description: 'Rule for how the meeting should recur. Acceptable format.', + description: + 'Rule for how the meeting should recur. Acceptable format.', }, { displayName: 'Required Registration Info', @@ -345,7 +335,8 @@ export const meetingFields: INodeProperties[] = [ name: 'reminderTime', type: 'number', default: 1, - description: 'The number of minutes before the meeting begins, for sending an email reminder to the host', + description: + 'The number of minutes before the meeting begins, for sending an email reminder to the host', }, { displayName: 'Send Email', @@ -363,7 +354,8 @@ export const meetingFields: INodeProperties[] = [ loadOptionsMethod: 'getSites', }, default: '', - description: 'URL of the Webex site which the meeting is created on. If not specified, the meeting is created on user\'s preferred site. Choose from the list, or specify an ID using an expression.', + description: + 'URL of the Webex site which the meeting is created on. If not specified, the meeting is created on user\'s preferred site. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -379,12 +371,8 @@ export const meetingFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'meeting', - ], - operation: [ - 'delete', - ], + resource: ['meeting'], + operation: ['delete'], }, }, description: 'ID of the meeting', @@ -397,12 +385,8 @@ export const meetingFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'meeting', - ], - operation: [ - 'delete', - ], + resource: ['meeting'], + operation: ['delete'], }, }, options: [ @@ -411,7 +395,8 @@ export const meetingFields: INodeProperties[] = [ name: 'hostEmail', type: 'string', default: '', - description: 'Email address for the meeting host. This parameter is only used if the user or application calling the API has the admin-level scopes.', + description: + 'Email address for the meeting host. This parameter is only used if the user or application calling the API has the admin-level scopes.', }, { displayName: 'Send Email', @@ -434,12 +419,8 @@ export const meetingFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'meeting', - ], - operation: [ - 'get', - ], + resource: ['meeting'], + operation: ['get'], }, }, description: 'ID of the meeting', @@ -452,12 +433,8 @@ export const meetingFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'meeting', - ], - operation: [ - 'get', - ], + resource: ['meeting'], + operation: ['get'], }, }, options: [ @@ -466,21 +443,24 @@ export const meetingFields: INodeProperties[] = [ name: 'hostEmail', type: 'string', default: '', - description: 'Email address for the meeting host. This parameter is only used if the user or application calling the API has the admin-level scopes.', + description: + 'Email address for the meeting host. This parameter is only used if the user or application calling the API has the admin-level scopes.', }, { displayName: 'Password', name: 'password', type: 'string', default: '', - description: 'Meeting password. It\'s required when the meeting is protected by a password and the current user is not privileged to view it if they are not a host, co-host or invitee of the meeting.', + description: + "Meeting password. It's required when the meeting is protected by a password and the current user is not privileged to view it if they are not a host, co-host or invitee of the meeting.", }, { displayName: 'Send Email', name: 'sendEmail', type: 'boolean', default: true, - description: 'Whether or not to send emails to host and invitees. It is an optional field and default value is true.', + description: + 'Whether or not to send emails to host and invitees. It is an optional field and default value is true.', }, ], }, @@ -496,12 +476,8 @@ export const meetingFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'meeting', - ], - operation: [ - 'getAll', - ], + resource: ['meeting'], + operation: ['getAll'], }, }, }, @@ -516,15 +492,9 @@ export const meetingFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'meeting', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['meeting'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -536,12 +506,8 @@ export const meetingFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'meeting', - ], - operation: [ - 'getAll', - ], + resource: ['meeting'], + operation: ['getAll'], }, }, options: [ @@ -550,7 +516,8 @@ export const meetingFields: INodeProperties[] = [ name: 'from', type: 'dateTime', default: '', - description: 'Start date and time (inclusive) for the meeting. Acceptable format.', + description: + 'Start date and time (inclusive) for the meeting. Acceptable format.', }, { displayName: 'Host Email', @@ -564,7 +531,8 @@ export const meetingFields: INodeProperties[] = [ name: 'integrationTag', type: 'string', default: '', - description: 'External tag created by another application, e.g. Zendesk ticket ID or Jira ID', + description: + 'External tag created by another application, e.g. Zendesk ticket ID or Jira ID', }, { displayName: 'Limit to Current Meetings', @@ -588,7 +556,8 @@ export const meetingFields: INodeProperties[] = [ { name: 'Meeting Series', value: 'meetingSeries', - description: 'Master of a scheduled series of meetings which consists of one or more scheduled meeting based on a recurrence rule', + description: + 'Master of a scheduled series of meetings which consists of one or more scheduled meeting based on a recurrence rule', }, { name: 'Scheduled Meeting', @@ -619,7 +588,8 @@ export const meetingFields: INodeProperties[] = [ loadOptionsMethod: 'getSites', }, default: '', - description: 'URL of the Webex site which the API lists meetings from. Choose from the list, or specify an ID using an expression.', + description: + 'URL of the Webex site which the API lists meetings from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'State', @@ -667,7 +637,8 @@ export const meetingFields: INodeProperties[] = [ name: 'to', type: 'dateTime', default: '', - description: 'End date and time (inclusive) for the meeting. Acceptable format.', + description: + 'End date and time (inclusive) for the meeting. Acceptable format.', }, { displayName: 'Weblink', @@ -690,12 +661,8 @@ export const meetingFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'meeting', - ], - operation: [ - 'update', - ], + resource: ['meeting'], + operation: ['update'], }, }, description: 'ID of the meeting', @@ -706,12 +673,8 @@ export const meetingFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - resource: [ - 'meeting', - ], - operation: [ - 'update', - ], + resource: ['meeting'], + operation: ['update'], }, }, default: {}, @@ -722,35 +685,39 @@ export const meetingFields: INodeProperties[] = [ name: 'agenda', type: 'string', default: '', - description: 'The meeting\'s agenda. Cannot be longer that 1300 characters.', + description: "The meeting's agenda. Cannot be longer that 1300 characters.", }, { displayName: 'Allow Any User To Be Co-Host', name: 'allowAnyUserToBeCoHost', type: 'boolean', default: false, - description: 'Whether or not to allow any attendee with a host account on the target site to become a co-host when joining the meeting', + description: + 'Whether or not to allow any attendee with a host account on the target site to become a co-host when joining the meeting', }, { displayName: 'Allow Authenticated Devices', name: 'allowAuthenticatedDevices', type: 'boolean', default: false, - description: 'Whether or not to allow authenticated video devices in the meeting\'s organization to start or join the meeting without a prompt', + description: + "Whether or not to allow authenticated video devices in the meeting's organization to start or join the meeting without a prompt", }, { displayName: 'Allow First User To Be Co-Host', name: 'allowFirstUserToBeCoHost', type: 'boolean', default: false, - description: 'Whether or not to allow the first attendee of the meeting with a host account on the target site to become a co-host', + description: + 'Whether or not to allow the first attendee of the meeting with a host account on the target site to become a co-host', }, { displayName: 'Enable Connect Audio Before Host', name: 'enableConnectAudioBeforeHost', type: 'boolean', default: false, - description: 'Whether or not to allow any attendee to connect audio in the meeting before the host joins the meeting', + description: + 'Whether or not to allow any attendee to connect audio in the meeting before the host joins the meeting', }, { displayName: 'Enabled Auto Record Meeting', @@ -764,14 +731,16 @@ export const meetingFields: INodeProperties[] = [ name: 'enabledJoinBeforeHost', type: 'boolean', default: false, - description: 'Whether or not to allow any attendee to join the meeting before the host joins the meeting', + description: + 'Whether or not to allow any attendee to join the meeting before the host joins the meeting', }, { displayName: 'End', name: 'end', type: 'dateTime', default: '', - description: 'Date and time for the end of the meeting. Acceptable format.', + description: + 'Date and time for the end of the meeting. Acceptable format.', }, { displayName: 'Exclude Password', @@ -785,7 +754,8 @@ export const meetingFields: INodeProperties[] = [ name: 'hostEmail', type: 'string', default: '', - description: 'Email address for the meeting host. This attribute should only be set if the user or application calling the API has the admin-level scopes.', + description: + 'Email address for the meeting host. This attribute should only be set if the user or application calling the API has the admin-level scopes.', }, { displayName: 'Invitees', @@ -851,14 +821,16 @@ export const meetingFields: INodeProperties[] = [ }, ], default: 0, - description: 'The number of minutes an attendee can join the meeting before the meeting start time and the host joins', + description: + 'The number of minutes an attendee can join the meeting before the meeting start time and the host joins', }, { displayName: 'Password', name: 'password', type: 'string', default: '', - description: 'Meeting password. Must conform to the site\'s password complexity settings. If not specified, a random password conforming to the site\'s password rules will be generated automatically', + description: + "Meeting password. Must conform to the site's password complexity settings. If not specified, a random password conforming to the site's password rules will be generated automatically", }, { displayName: 'Public Meeting', @@ -872,7 +844,8 @@ export const meetingFields: INodeProperties[] = [ name: 'recurrence', type: 'string', default: '', - description: 'Meeting series recurrence rule (conforming with RFC 2445), applying only to meeting series', + description: + 'Meeting series recurrence rule (conforming with RFC 2445), applying only to meeting series', }, { displayName: 'Required Registration Info', @@ -941,14 +914,16 @@ export const meetingFields: INodeProperties[] = [ name: 'reminderTime', type: 'number', default: 1, - description: 'The number of minutes before the meeting begins, for sending an email reminder to the host', + description: + 'The number of minutes before the meeting begins, for sending an email reminder to the host', }, { displayName: 'Send Email', name: 'sendEmail', type: 'boolean', default: false, - description: 'Whether or not to send emails to host and invitees. It is an optional field and default value is true.', + description: + 'Whether or not to send emails to host and invitees. It is an optional field and default value is true.', }, { // eslint-disable-next-line n8n-nodes-base/node-param-display-name-wrong-for-dynamic-options @@ -959,14 +934,16 @@ export const meetingFields: INodeProperties[] = [ loadOptionsMethod: 'getSites', }, default: '', - description: 'URL of the Webex site which the meeting is created on. If not specified, the meeting is created on user\'s preferred site. Choose from the list, or specify an ID using an expression.', + description: + 'URL of the Webex site which the meeting is created on. If not specified, the meeting is created on user\'s preferred site. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Start', name: 'start', type: 'dateTime', default: '', - description: 'Date and time for the start of the meeting. Acceptable format.', + description: + 'Date and time for the start of the meeting. Acceptable format.', }, { displayName: 'Title', diff --git a/packages/nodes-base/nodes/Cisco/Webex/descriptions/MeetingTranscript.ts b/packages/nodes-base/nodes/Cisco/Webex/descriptions/MeetingTranscript.ts index 068b8d8571df6..a85436a74bf20 100644 --- a/packages/nodes-base/nodes/Cisco/Webex/descriptions/MeetingTranscript.ts +++ b/packages/nodes-base/nodes/Cisco/Webex/descriptions/MeetingTranscript.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const meetingTranscriptOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const meetingTranscriptOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'meetingTranscript', - ], + resource: ['meetingTranscript'], }, }, options: [ @@ -43,12 +39,8 @@ export const meetingTranscriptFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'meetingTranscript', - ], - operation: [ - 'download', - ], + resource: ['meetingTranscript'], + operation: ['download'], }, }, description: 'Unique identifier for the meeting transcript', @@ -61,12 +53,8 @@ export const meetingTranscriptFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'meetingTranscript', - ], - operation: [ - 'download', - ], + resource: ['meetingTranscript'], + operation: ['download'], }, }, description: 'Unique identifier for the meeting instance which the transcripts belong to', @@ -77,12 +65,8 @@ export const meetingTranscriptFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - resource: [ - 'meetingTranscript', - ], - operation: [ - 'download', - ], + resource: ['meetingTranscript'], + operation: ['download'], }, }, default: {}, @@ -121,12 +105,8 @@ export const meetingTranscriptFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'meetingTranscript', - ], - operation: [ - 'getAll', - ], + resource: ['meetingTranscript'], + operation: ['getAll'], }, }, description: 'Unique identifier for the meeting instance which the transcripts belong to', @@ -139,12 +119,8 @@ export const meetingTranscriptFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'meetingTranscript', - ], - operation: [ - 'getAll', - ], + resource: ['meetingTranscript'], + operation: ['getAll'], }, }, }, @@ -159,15 +135,9 @@ export const meetingTranscriptFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'meetingTranscript', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['meetingTranscript'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -179,12 +149,8 @@ export const meetingTranscriptFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'meetingTranscript', - ], - operation: [ - 'getAll', - ], + resource: ['meetingTranscript'], + operation: ['getAll'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Cisco/Webex/descriptions/MessageDescription.ts b/packages/nodes-base/nodes/Cisco/Webex/descriptions/MessageDescription.ts index 8a430c12bf93e..fbad869585f9b 100644 --- a/packages/nodes-base/nodes/Cisco/Webex/descriptions/MessageDescription.ts +++ b/packages/nodes-base/nodes/Cisco/Webex/descriptions/MessageDescription.ts @@ -1,9 +1,9 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import { - getActionInheritedProperties, getInputTextProperties, getTextBlockProperties, + getActionInheritedProperties, + getInputTextProperties, + getTextBlockProperties, } from '../GenericFunctions'; export const messageOperations: INodeProperties[] = [ @@ -14,9 +14,7 @@ export const messageOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'message', - ], + resource: ['message'], }, }, options: [ @@ -72,12 +70,8 @@ export const messageFields: INodeProperties[] = [ default: 'room', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], + resource: ['message'], + operation: ['create'], }, }, }, @@ -85,7 +79,8 @@ export const messageFields: 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: 'getRooms', }, @@ -93,15 +88,9 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], - destination: [ - 'room', - ], + resource: ['message'], + operation: ['create'], + destination: ['room'], }, }, }, @@ -123,15 +112,9 @@ export const messageFields: INodeProperties[] = [ default: 'email', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], - destination: [ - 'person', - ], + resource: ['message'], + operation: ['create'], + destination: ['person'], }, }, }, @@ -143,15 +126,9 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], - specifyPersonBy: [ - 'id', - ], + resource: ['message'], + operation: ['create'], + specifyPersonBy: ['id'], }, }, }, @@ -163,15 +140,9 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], - specifyPersonBy: [ - 'email', - ], + resource: ['message'], + operation: ['create'], + specifyPersonBy: ['email'], }, }, }, @@ -183,12 +154,8 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], + resource: ['message'], + operation: ['create'], }, }, description: 'The message, in plain text', @@ -199,12 +166,8 @@ export const messageFields: INodeProperties[] = [ type: 'collection', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'create', - ], + resource: ['message'], + operation: ['create'], }, }, default: {}, @@ -301,9 +264,7 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - type: [ - 'openUrl', - ], + type: ['openUrl'], }, }, description: 'The URL to open', @@ -314,14 +275,12 @@ export const messageFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - type: [ - 'submit', - 'execute', - ], + type: ['submit', 'execute'], }, }, default: '', - description: 'Any extra data to pass along. These are essentially ‘hidden’ properties.', + description: + 'Any extra data to pass along. These are essentially ‘hidden’ properties.', }, { displayName: 'Verb', @@ -329,9 +288,7 @@ export const messageFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - type: [ - 'execute', - ], + type: ['execute'], }, }, default: '', @@ -384,9 +341,7 @@ export const messageFields: INodeProperties[] = [ required: true, displayOptions: { show: { - fileLocation: [ - 'binaryData', - ], + fileLocation: ['binaryData'], }, }, description: 'The field in the node input containing the binary file data', @@ -398,9 +353,7 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - fileLocation: [ - 'url', - ], + fileLocation: ['url'], }, }, description: 'The public URL of the file', @@ -414,7 +367,8 @@ export const messageFields: INodeProperties[] = [ name: 'markdown', type: 'string', default: '', - description: 'The message in markdown format. When used the text parameter is used to provide alternate text for UI clients that do not support rich text.', + description: + 'The message in markdown format. When used the text parameter is used to provide alternate text for UI clients that do not support rich text.', }, ], }, @@ -431,12 +385,8 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'delete', - ], + resource: ['message'], + operation: ['delete'], }, }, }, @@ -453,12 +403,8 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'get', - ], + resource: ['message'], + operation: ['get'], }, }, }, @@ -469,7 +415,8 @@ export const messageFields: INodeProperties[] = [ { displayName: 'Room Name or ID', name: 'roomId', - description: 'List messages in a room, by ID. Choose from the list, or specify an ID using an expression.', + description: + 'List messages in a room, by ID. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { loadOptionsMethod: 'getRooms', @@ -478,12 +425,8 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'getAll', - ], + resource: ['message'], + operation: ['getAll'], }, }, }, @@ -495,12 +438,8 @@ export const messageFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'getAll', - ], + resource: ['message'], + operation: ['getAll'], }, }, }, @@ -515,15 +454,9 @@ export const messageFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['message'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -535,12 +468,8 @@ export const messageFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'getAll', - ], + resource: ['message'], + operation: ['getAll'], }, }, options: [ @@ -570,7 +499,8 @@ export const messageFields: INodeProperties[] = [ name: 'mentionedPeople', type: 'string', default: '', - description: 'List only messages with certain person mentioned. Enter their ID. You can use \'me\' as a shorthand for yourself', + description: + "List only messages with certain person mentioned. Enter their ID. You can use 'me' as a shorthand for yourself", }, ], }, @@ -587,12 +517,8 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], + resource: ['message'], + operation: ['update'], }, }, }, @@ -605,12 +531,8 @@ export const messageFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], + resource: ['message'], + operation: ['update'], }, }, }, @@ -622,15 +544,9 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], - markdown: [ - false, - ], + resource: ['message'], + operation: ['update'], + markdown: [false], }, }, description: 'The message, in plain text', @@ -644,15 +560,9 @@ export const messageFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'message', - ], - operation: [ - 'update', - ], - markdown: [ - true, - ], + resource: ['message'], + operation: ['update'], + markdown: [true], }, }, }, diff --git a/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts b/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts index 53c255baf00f0..e0a20a1a4dc89 100644 --- a/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts +++ b/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts @@ -1,27 +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 { - clearbitApiRequest, -} from './GenericFunctions'; +import { clearbitApiRequest } from './GenericFunctions'; -import { - companyFields, - companyOperations, -} from './CompanyDescription'; +import { companyFields, companyOperations } from './CompanyDescription'; -import { - personFields, - personOperations, -} from './PersonDescription'; +import { personFields, personOperations } from './PersonDescription'; export class Clearbit implements INodeType { description: INodeTypeDescription = { @@ -58,7 +43,8 @@ export class Clearbit implements INodeType { { name: 'Person', value: 'person', - description: 'The Person API lets you retrieve social information associated with an email address, such as a person’s name, location and Twitter handle', + description: + 'The Person API lets you retrieve social information associated with an email address, such as a person’s name, location and Twitter handle', }, ], default: 'company', @@ -112,7 +98,14 @@ export class Clearbit implements INodeType { if (additionalFields.facebook) { qs.facebook = additionalFields.facebook as string; } - responseData = await clearbitApiRequest.call(this, 'GET', `${resource}-stream`, '/v2/people/find', {}, qs); + responseData = await clearbitApiRequest.call( + this, + 'GET', + `${resource}-stream`, + '/v2/people/find', + {}, + qs, + ); } } if (resource === 'company') { @@ -132,12 +125,26 @@ export class Clearbit implements INodeType { if (additionalFields.facebook) { qs.facebook = additionalFields.facebook as string; } - responseData = await clearbitApiRequest.call(this, 'GET', `${resource}-stream`, '/v2/companies/find', {}, qs); + responseData = await clearbitApiRequest.call( + this, + 'GET', + `${resource}-stream`, + '/v2/companies/find', + {}, + qs, + ); } if (operation === 'autocomplete') { const name = this.getNodeParameter('name', i) as string; qs.query = name; - responseData = await clearbitApiRequest.call(this, 'GET', 'autocomplete', '/v1/companies/suggest', {}, qs); + responseData = await clearbitApiRequest.call( + this, + 'GET', + 'autocomplete', + '/v1/companies/suggest', + {}, + qs, + ); } } if (Array.isArray(responseData)) { diff --git a/packages/nodes-base/nodes/Clearbit/CompanyDescription.ts b/packages/nodes-base/nodes/Clearbit/CompanyDescription.ts index 40ca6c0f05035..dd826cd80e2dd 100644 --- a/packages/nodes-base/nodes/Clearbit/CompanyDescription.ts +++ b/packages/nodes-base/nodes/Clearbit/CompanyDescription.ts @@ -8,9 +8,7 @@ export const companyOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'company', - ], + resource: ['company'], }, }, options: [ @@ -32,7 +30,6 @@ export const companyOperations: INodeProperties[] = [ ]; export const companyFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* company:enrich */ /* -------------------------------------------------------------------------- */ @@ -44,12 +41,8 @@ export const companyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'enrich', - ], + resource: ['company'], + operation: ['enrich'], }, }, description: 'The domain to look up', @@ -62,12 +55,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'enrich', - ], + resource: ['company'], + operation: ['enrich'], }, }, options: [ @@ -113,12 +102,8 @@ export const companyFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'autocomplete', - ], + resource: ['company'], + operation: ['autocomplete'], }, }, description: 'Name is the partial name of the company', diff --git a/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts b/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts index 8ae14ff171aa3..90e24f85569c4 100644 --- a/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,9 +7,20 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function clearbitApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, api: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function clearbitApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + api: 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('clearbitApi'); let options: OptionsWithUri = { headers: { Authorization: `Bearer ${credentials.apiKey}` }, diff --git a/packages/nodes-base/nodes/Clearbit/PersonDescription.ts b/packages/nodes-base/nodes/Clearbit/PersonDescription.ts index 0aa0754cd09ec..f6346fa56b46f 100644 --- a/packages/nodes-base/nodes/Clearbit/PersonDescription.ts +++ b/packages/nodes-base/nodes/Clearbit/PersonDescription.ts @@ -8,9 +8,7 @@ export const personOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'person', - ], + resource: ['person'], }, }, options: [ @@ -26,7 +24,6 @@ export const personOperations: INodeProperties[] = [ ]; export const personFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* person:enrich */ /* -------------------------------------------------------------------------- */ @@ -39,12 +36,8 @@ export const personFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'enrich', - ], + resource: ['person'], + operation: ['enrich'], }, }, description: 'The email address to look up', @@ -57,12 +50,8 @@ export const personFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'enrich', - ], + resource: ['person'], + operation: ['enrich'], }, }, options: [ @@ -92,7 +81,8 @@ export const personFields: INodeProperties[] = [ name: 'familyName', type: 'string', default: '', - description: 'Last name of person. If you have this, passing this is strongly recommended to improve match rates.', + description: + 'Last name of person. If you have this, passing this is strongly recommended to improve match rates.', }, { displayName: 'Given Name', @@ -106,7 +96,8 @@ export const personFields: INodeProperties[] = [ name: 'ipAddress', type: 'string', default: '', - description: 'IP address of the person. If you have this, passing this is strongly recommended to improve match rates.', + description: + 'IP address of the person. If you have this, passing this is strongly recommended to improve match rates.', }, { displayName: 'Location', diff --git a/packages/nodes-base/nodes/ClickUp/ChecklistDescription.ts b/packages/nodes-base/nodes/ClickUp/ChecklistDescription.ts index 8f8036ac4617c..f88710e86f719 100644 --- a/packages/nodes-base/nodes/ClickUp/ChecklistDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/ChecklistDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const checklistOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const checklistOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'checklist', - ], + resource: ['checklist'], }, }, options: [ @@ -40,7 +36,6 @@ export const checklistOperations: INodeProperties[] = [ ]; export const checklistFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* checklist:create */ /* -------------------------------------------------------------------------- */ @@ -51,12 +46,8 @@ export const checklistFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'checklist', - ], - operation: [ - 'create', - ], + resource: ['checklist'], + operation: ['create'], }, }, required: true, @@ -68,12 +59,8 @@ export const checklistFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'checklist', - ], - operation: [ - 'create', - ], + resource: ['checklist'], + operation: ['create'], }, }, required: true, @@ -88,12 +75,8 @@ export const checklistFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'checklist', - ], - operation: [ - 'delete', - ], + resource: ['checklist'], + operation: ['delete'], }, }, required: true, @@ -108,12 +91,8 @@ export const checklistFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'checklist', - ], - operation: [ - 'update', - ], + resource: ['checklist'], + operation: ['update'], }, }, required: true, @@ -126,12 +105,8 @@ export const checklistFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'checklist', - ], - operation: [ - 'update', - ], + resource: ['checklist'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/ClickUp/ChecklistItemDescription.ts b/packages/nodes-base/nodes/ClickUp/ChecklistItemDescription.ts index 605a1462e9747..19191aaa5ad68 100644 --- a/packages/nodes-base/nodes/ClickUp/ChecklistItemDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/ChecklistItemDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const checklistItemOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const checklistItemOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'checklistItem', - ], + resource: ['checklistItem'], }, }, options: [ @@ -40,7 +36,6 @@ export const checklistItemOperations: INodeProperties[] = [ ]; export const checklistItemFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* checklistItem:create */ /* -------------------------------------------------------------------------- */ @@ -51,12 +46,8 @@ export const checklistItemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'checklistItem', - ], - operation: [ - 'create', - ], + resource: ['checklistItem'], + operation: ['create'], }, }, required: true, @@ -68,12 +59,8 @@ export const checklistItemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'checklistItem', - ], - operation: [ - 'create', - ], + resource: ['checklistItem'], + operation: ['create'], }, }, required: true, @@ -86,12 +73,8 @@ export const checklistItemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'checklistItem', - ], - operation: [ - 'create', - ], + resource: ['checklistItem'], + operation: ['create'], }, }, options: [ @@ -114,12 +97,8 @@ export const checklistItemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'checklistItem', - ], - operation: [ - 'delete', - ], + resource: ['checklistItem'], + operation: ['delete'], }, }, required: true, @@ -131,12 +110,8 @@ export const checklistItemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'checklistItem', - ], - operation: [ - 'delete', - ], + resource: ['checklistItem'], + operation: ['delete'], }, }, required: true, @@ -152,12 +127,8 @@ export const checklistItemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'checklistItem', - ], - operation: [ - 'update', - ], + resource: ['checklistItem'], + operation: ['update'], }, }, required: true, @@ -169,12 +140,8 @@ export const checklistItemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'checklistItem', - ], - operation: [ - 'update', - ], + resource: ['checklistItem'], + operation: ['update'], }, }, required: true, @@ -187,12 +154,8 @@ export const checklistItemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'checklistItem', - ], - operation: [ - 'update', - ], + resource: ['checklistItem'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/ClickUp/ClickUp.node.ts b/packages/nodes-base/nodes/ClickUp/ClickUp.node.ts index 29cbbe84b4a53..04de66d2649f1 100644 --- a/packages/nodes-base/nodes/ClickUp/ClickUp.node.ts +++ b/packages/nodes-base/nodes/ClickUp/ClickUp.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,94 +10,44 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - clickupApiRequest, - clickupApiRequestAllItems, - validateJSON, -} from './GenericFunctions'; +import { clickupApiRequest, clickupApiRequestAllItems, validateJSON } from './GenericFunctions'; -import { - checklistFields, - checklistOperations, -} from './ChecklistDescription'; +import { checklistFields, checklistOperations } from './ChecklistDescription'; -import { - checklistItemFields, - checklistItemOperations, -} from './ChecklistItemDescription'; +import { checklistItemFields, checklistItemOperations } from './ChecklistItemDescription'; -import { - commentFields, - commentOperations, -} from './CommentDescription'; +import { commentFields, commentOperations } from './CommentDescription'; -import { - folderFields, - folderOperations, -} from './FolderDescription'; +import { folderFields, folderOperations } from './FolderDescription'; -import { - goalFields, - goalOperations, -} from './GoalDescription'; +import { goalFields, goalOperations } from './GoalDescription'; -import { - goalKeyResultFields, - goalKeyResultOperations, -} from './GoalKeyResultDescription'; +import { goalKeyResultFields, goalKeyResultOperations } from './GoalKeyResultDescription'; // import { // guestFields, // guestOperations, // } from './guestDescription'; -import { - taskFields, - taskOperations, -} from './TaskDescription'; +import { taskFields, taskOperations } from './TaskDescription'; -import { - taskListFields, - taskListOperations, -} from './TaskListDescription'; +import { taskListFields, taskListOperations } from './TaskListDescription'; -import { - taskTagFields, - taskTagOperations, -} from './TaskTagDescription'; +import { taskTagFields, taskTagOperations } from './TaskTagDescription'; -import { - spaceTagFields, - spaceTagOperations, -} from './SpaceTagDescription'; +import { spaceTagFields, spaceTagOperations } from './SpaceTagDescription'; -import { - taskDependencyFields, - taskDependencyOperations, -} from './TaskDependencyDescription'; +import { taskDependencyFields, taskDependencyOperations } from './TaskDependencyDescription'; -import { - timeEntryFields, - timeEntryOperations, -} from './TimeEntryDescription'; +import { timeEntryFields, timeEntryOperations } from './TimeEntryDescription'; -import { - timeEntryTagFields, - timeEntryTagOperations, -} from './TimeEntryTagDescription'; +import { timeEntryTagFields, timeEntryTagOperations } from './TimeEntryTagDescription'; -import { - listFields, - listOperations, -} from './ListDescription'; +import { listFields, listOperations } from './ListDescription'; -import { - ITask, -} from './TaskInterface'; +import { ITask } from './TaskInterface'; -import { - IList, -} from './ListInterface'; +import { IList } from './ListInterface'; import moment from 'moment-timezone'; @@ -123,9 +71,7 @@ export class ClickUp implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -134,9 +80,7 @@ export class ClickUp implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -366,8 +310,7 @@ export class ClickUp implements INodeType { let url: string; if (listId) { url = `/list/${listId}/member`; - } - else if (taskId) { + } else if (taskId) { url = `/task/${taskId}/member`; } else { return returnData; @@ -405,7 +348,11 @@ export class ClickUp implements INodeType { async getTimeEntryTags(this: ILoadOptionsFunctions): Promise { const teamId = this.getCurrentNodeParameter('team') as string; const returnData: INodePropertyOptions[] = []; - const { data: tags } = await clickupApiRequest.call(this, 'GET', `/team/${teamId}/time_entries/tags`); + const { data: tags } = await clickupApiRequest.call( + this, + 'GET', + `/team/${teamId}/time_entries/tags`, + ); for (const tag of tags) { const tagName = tag.name; const tagId = JSON.stringify(tag); @@ -456,7 +403,11 @@ export class ClickUp implements INodeType { const listId = this.getCurrentNodeParameter('list') as string; const archived = this.getCurrentNodeParameter('archived') as string; const returnData: INodePropertyOptions[] = []; - const { tasks } = await clickupApiRequest.call(this, 'GET', `/list/${listId}/task?archived=${archived}`); + const { tasks } = await clickupApiRequest.call( + this, + 'GET', + `/list/${listId}/task?archived=${archived}`, + ); for (const task of tasks) { const taskName = task.name; const taskId = task.id; @@ -489,12 +440,21 @@ export class ClickUp implements INodeType { const body: IDataObject = { name, }; - responseData = await clickupApiRequest.call(this, 'POST', `/task/${taskId}/checklist`, body); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/task/${taskId}/checklist`, + body, + ); responseData = responseData.checklist; } if (operation === 'delete') { const checklistId = this.getNodeParameter('checklist', i) as string; - responseData = await clickupApiRequest.call(this, 'DELETE', `/checklist/${checklistId}`); + responseData = await clickupApiRequest.call( + this, + 'DELETE', + `/checklist/${checklistId}`, + ); responseData = { success: true }; } if (operation === 'update') { @@ -507,7 +467,12 @@ export class ClickUp implements INodeType { if (updateFields.position) { body.position = updateFields.position as number; } - responseData = await clickupApiRequest.call(this, 'PUT', `/checklist/${checklistId}`, body); + responseData = await clickupApiRequest.call( + this, + 'PUT', + `/checklist/${checklistId}`, + body, + ); responseData = responseData.checklist; } } @@ -522,13 +487,22 @@ export class ClickUp implements INodeType { if (additionalFields.assignee) { body.assignee = parseInt(additionalFields.assignee as string, 10); } - responseData = await clickupApiRequest.call(this, 'POST', `/checklist/${checklistId}/checklist_item`, body); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/checklist/${checklistId}/checklist_item`, + body, + ); responseData = responseData.checklist; } if (operation === 'delete') { const checklistId = this.getNodeParameter('checklist', i) as string; const checklistItemId = this.getNodeParameter('checklistItem', i) as string; - responseData = await clickupApiRequest.call(this, 'DELETE', `/checklist/${checklistId}/checklist_item/${checklistItemId}`); + responseData = await clickupApiRequest.call( + this, + 'DELETE', + `/checklist/${checklistId}/checklist_item/${checklistItemId}`, + ); responseData = { success: true }; } if (operation === 'update') { @@ -548,7 +522,12 @@ export class ClickUp implements INodeType { if (updateFields.resolved) { body.resolved = updateFields.resolved as boolean; } - responseData = await clickupApiRequest.call(this, 'PUT', `/checklist/${checklistId}/checklist_item/${checklistItemId}`, body); + responseData = await clickupApiRequest.call( + this, + 'PUT', + `/checklist/${checklistId}/checklist_item/${checklistItemId}`, + body, + ); responseData = responseData.checklist; } } @@ -567,7 +546,12 @@ export class ClickUp implements INodeType { if (additionalFields.notifyAll) { body.notify_all = additionalFields.notifyAll as boolean; } - responseData = await clickupApiRequest.call(this, 'POST', `/${resource}/${id}/comment`, body); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/${resource}/${id}/comment`, + body, + ); } if (operation === 'delete') { const commentId = this.getNodeParameter('comment', i) as string; @@ -578,7 +562,13 @@ export class ClickUp implements INodeType { const resource = this.getNodeParameter('commentsOn', i) as string; const id = this.getNodeParameter('id', i) as string; qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await clickupApiRequest.call(this, 'GET', `/${resource}/${id}/comment`, {}, qs); + responseData = await clickupApiRequest.call( + this, + 'GET', + `/${resource}/${id}/comment`, + {}, + qs, + ); responseData = responseData.comments; responseData = responseData.splice(0, qs.limit); } @@ -606,7 +596,12 @@ export class ClickUp implements INodeType { const body: IDataObject = { name, }; - responseData = await clickupApiRequest.call(this, 'POST', `/space/${spaceId}/folder`, body); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/space/${spaceId}/folder`, + body, + ); } if (operation === 'delete') { const folderId = this.getNodeParameter('folder', i) as string; @@ -624,7 +619,13 @@ export class ClickUp implements INodeType { qs.archived = filters.archived as boolean; } qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await clickupApiRequest.call(this, 'GET', `/space/${spaceId}/folder`, {}, qs); + responseData = await clickupApiRequest.call( + this, + 'GET', + `/space/${spaceId}/folder`, + {}, + qs, + ); responseData = responseData.folders; responseData = responseData.splice(0, qs.limit); } @@ -659,7 +660,9 @@ export class ClickUp implements INodeType { body.color = additionalFields.color as string; } if (additionalFields.owners) { - body.owners = ((additionalFields.owners as string).split(',') as string[]).map((e: string) => parseInt(e, 10)); + body.owners = ((additionalFields.owners as string).split(',') as string[]).map( + (e: string) => parseInt(e, 10), + ); } responseData = await clickupApiRequest.call(this, 'POST', `/team/${teamId}/goal`, body); responseData = responseData.goal; @@ -677,10 +680,15 @@ export class ClickUp implements INodeType { if (operation === 'getAll') { const teamId = this.getNodeParameter('team', i) as string; qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await clickupApiRequest.call(this, 'GET', `/team/${teamId}/goal`, {}, qs); + responseData = await clickupApiRequest.call( + this, + 'GET', + `/team/${teamId}/goal`, + {}, + qs, + ); responseData = responseData.goals; responseData = responseData.splice(0, qs.limit); - } if (operation === 'update') { const goalId = this.getNodeParameter('goal', i) as string; @@ -699,10 +707,14 @@ export class ClickUp implements INodeType { body.color = updateFields.color as string; } if (updateFields.addOwners) { - body.add_owners = ((updateFields.addOwners as string).split(',') as string[]).map((e: string) => parseInt(e, 10)) as number[]; + body.add_owners = ((updateFields.addOwners as string).split(',') as string[]).map( + (e: string) => parseInt(e, 10), + ) as number[]; } if (updateFields.removeOwners) { - body.rem_owners = ((updateFields.removeOwners as string).split(',') as string[]).map((e: string) => parseInt(e, 10)) as number[]; + body.rem_owners = ((updateFields.removeOwners as string).split(',') as string[]).map( + (e: string) => parseInt(e, 10), + ) as number[]; } responseData = await clickupApiRequest.call(this, 'PUT', `/goal/${goalId}`, body); responseData = responseData.goal; @@ -720,14 +732,26 @@ export class ClickUp implements INodeType { }; if (type === 'number' || type === 'currency') { if (!additionalFields.unit) { - throw new NodeOperationError(this.getNode(), 'Unit field must be set', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Unit field must be set', { + itemIndex: i, + }); } } - if (type === 'number' || type === 'percentaje' - || type === 'automatic' || type === 'currency') { - if (additionalFields.stepsStart === undefined - || !additionalFields.stepsEnd === undefined) { - throw new NodeOperationError(this.getNode(), 'Steps start and steps end fields must be set', { itemIndex: i }); + if ( + type === 'number' || + type === 'percentaje' || + type === 'automatic' || + type === 'currency' + ) { + if ( + additionalFields.stepsStart === undefined || + !additionalFields.stepsEnd === undefined + ) { + throw new NodeOperationError( + this.getNode(), + 'Steps start and steps end fields must be set', + { itemIndex: i }, + ); } } if (additionalFields.unit) { @@ -746,14 +770,25 @@ export class ClickUp implements INodeType { body.list_ids = (additionalFields.listIds as string).split(','); } if (additionalFields.owners) { - body.owners = ((additionalFields.owners as string).split(',') as string[]).map((e: string) => parseInt(e, 10)); - } - responseData = await clickupApiRequest.call(this, 'POST', `/goal/${goalId}/key_result`, body); + body.owners = ((additionalFields.owners as string).split(',') as string[]).map( + (e: string) => parseInt(e, 10), + ); + } + responseData = await clickupApiRequest.call( + this, + 'POST', + `/goal/${goalId}/key_result`, + body, + ); responseData = responseData.key_result; } if (operation === 'delete') { const keyResultId = this.getNodeParameter('keyResult', i) as string; - responseData = await clickupApiRequest.call(this, 'DELETE', `/key_result/${keyResultId}`); + responseData = await clickupApiRequest.call( + this, + 'DELETE', + `/key_result/${keyResultId}`, + ); responseData = { success: true }; } if (operation === 'update') { @@ -778,7 +813,12 @@ export class ClickUp implements INodeType { if (updateFields.unit) { body.unit = updateFields.unit as string; } - responseData = await clickupApiRequest.call(this, 'PUT', `/key_result/${keyResultId}`, body); + responseData = await clickupApiRequest.call( + this, + 'PUT', + `/key_result/${keyResultId}`, + body, + ); responseData = responseData.key_result; } } @@ -799,19 +839,32 @@ export class ClickUp implements INodeType { if (additionalFields.canSeeTimeEstimated) { body.can_see_time_estimated = additionalFields.canSeeTimeEstimated as boolean; } - responseData = await clickupApiRequest.call(this, 'POST', `/team/${teamId}/guest`, body); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/team/${teamId}/guest`, + body, + ); responseData = responseData.team; } if (operation === 'delete') { const teamId = this.getNodeParameter('team', i) as string; const guestId = this.getNodeParameter('guest', i) as string; - responseData = await clickupApiRequest.call(this, 'DELETE', `/team/${teamId}/guest/${guestId}`); + responseData = await clickupApiRequest.call( + this, + 'DELETE', + `/team/${teamId}/guest/${guestId}`, + ); responseData = { success: true }; } if (operation === 'get') { const teamId = this.getNodeParameter('team', i) as string; const guestId = this.getNodeParameter('guest', i) as string; - responseData = await clickupApiRequest.call(this, 'GET', `/team/${teamId}/guest/${guestId}`); + responseData = await clickupApiRequest.call( + this, + 'GET', + `/team/${teamId}/guest/${guestId}`, + ); responseData = responseData.team; } if (operation === 'update') { @@ -831,7 +884,12 @@ export class ClickUp implements INodeType { if (updateFields.canSeeTimeEstimated) { body.can_see_time_estimated = updateFields.canSeeTimeEstimated as boolean; } - responseData = await clickupApiRequest.call(this, 'PUT', `/team/${teamId}/guest/${guestId}`, body); + responseData = await clickupApiRequest.call( + this, + 'PUT', + `/team/${teamId}/guest/${guestId}`, + body, + ); responseData = responseData.team; } } @@ -846,7 +904,9 @@ export class ClickUp implements INodeType { if (additionalFields.customFieldsJson) { const customFields = validateJSON(additionalFields.customFieldsJson as string); if (customFields === undefined) { - throw new NodeOperationError(this.getNode(), 'Custom Fields: Invalid JSON', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Custom Fields: Invalid JSON', { + itemIndex: i, + }); } body.custom_fields = customFields; } @@ -933,11 +993,15 @@ export class ClickUp implements INodeType { } if (updateFields.addAssignees) { //@ts-ignore - body.assignees.add = ((updateFields.addAssignees as string).split(',') as string[]).map((e: string) => parseInt(e, 10)); + body.assignees.add = ( + (updateFields.addAssignees as string).split(',') as string[] + ).map((e: string) => parseInt(e, 10)); } if (updateFields.removeAssignees) { //@ts-ignore - body.assignees.rem = ((updateFields.removeAssignees as string).split(',') as string[]).map((e: string) => parseInt(e, 10)); + body.assignees.rem = ( + (updateFields.removeAssignees as string).split(',') as string[] + ).map((e: string) => parseInt(e, 10)); } if (updateFields.status) { body.status = updateFields.status as string; @@ -995,13 +1059,15 @@ export class ClickUp implements INodeType { qs.date_updated_lt = new Date(filters.dateUpdatedLt as string).getTime(); } if (filters.customFieldsUi) { - const customFieldsValues = (filters.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFieldsValues = (filters.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; if (customFieldsValues) { const customFields: IDataObject[] = []; for (const customFieldValue of customFieldsValues) { customFields.push({ field_id: customFieldValue.fieldId, - operator: (customFieldValue.operator === 'equal') ? '=' : customFieldValue.operator, + operator: + customFieldValue.operator === 'equal' ? '=' : customFieldValue.operator, value: customFieldValue.value as string, }); } @@ -1012,10 +1078,24 @@ export class ClickUp implements INodeType { const listId = this.getNodeParameter('list', i) as string; if (returnAll === true) { - responseData = await clickupApiRequestAllItems.call(this, 'tasks', 'GET', `/list/${listId}/task`, {}, qs); + responseData = await clickupApiRequestAllItems.call( + this, + 'tasks', + 'GET', + `/list/${listId}/task`, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await clickupApiRequestAllItems.call(this, 'tasks', 'GET', `/list/${listId}/task`, {}, qs); + responseData = await clickupApiRequestAllItems.call( + this, + 'tasks', + 'GET', + `/list/${listId}/task`, + {}, + qs, + ); responseData = responseData.splice(0, qs.limit); } } @@ -1023,11 +1103,23 @@ export class ClickUp implements INodeType { const taskId = this.getNodeParameter('id', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll === true) { - responseData = await clickupApiRequest.call(this, 'GET', `/task/${taskId}/member`, {}, qs); + responseData = await clickupApiRequest.call( + this, + 'GET', + `/task/${taskId}/member`, + {}, + qs, + ); responseData = responseData.members; } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await clickupApiRequest.call(this, 'GET', `/task/${taskId}/member`, {}, qs); + responseData = await clickupApiRequest.call( + this, + 'GET', + `/task/${taskId}/member`, + {}, + qs, + ); responseData = responseData.members; responseData = responseData.splice(0, qs.limit); } @@ -1043,7 +1135,9 @@ export class ClickUp implements INodeType { if (jsonParse === true) { body.value = validateJSON(body.value); if (body.value === undefined) { - throw new NodeOperationError(this.getNode(), 'Value is invalid JSON!', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Value is invalid JSON!', { + itemIndex: i, + }); } } else { //@ts-ignore @@ -1051,7 +1145,12 @@ export class ClickUp implements INodeType { body.value = parseInt(body.value, 10); } } - responseData = await clickupApiRequest.call(this, 'POST', `/task/${taskId}/field/${fieldId}`, body); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/task/${taskId}/field/${fieldId}`, + body, + ); } if (operation === 'delete') { const taskId = this.getNodeParameter('id', i) as string; @@ -1066,7 +1165,13 @@ export class ClickUp implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const qs: IDataObject = {}; Object.assign(qs, additionalFields); - responseData = await clickupApiRequest.call(this, 'POST', `/task/${taskId}/tag/${name}`, {}, qs); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/task/${taskId}/tag/${name}`, + {}, + qs, + ); responseData = { success: true }; } if (operation === 'remove') { @@ -1075,7 +1180,13 @@ export class ClickUp implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const qs: IDataObject = {}; Object.assign(qs, additionalFields); - responseData = await clickupApiRequest.call(this, 'DELETE', `/task/${taskId}/tag/${name}`, {}, qs); + responseData = await clickupApiRequest.call( + this, + 'DELETE', + `/task/${taskId}/tag/${name}`, + {}, + qs, + ); responseData = { success: true }; } } @@ -1083,13 +1194,21 @@ export class ClickUp implements INodeType { if (operation === 'add') { const taskId = this.getNodeParameter('taskId', i) as string; const listId = this.getNodeParameter('listId', i) as string; - responseData = await clickupApiRequest.call(this, 'POST', `/list/${listId}/task/${taskId}`); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/list/${listId}/task/${taskId}`, + ); responseData = { success: true }; } if (operation === 'remove') { const taskId = this.getNodeParameter('taskId', i) as string; const listId = this.getNodeParameter('listId', i) as string; - responseData = await clickupApiRequest.call(this, 'DELETE', `/list/${listId}/task/${taskId}`); + responseData = await clickupApiRequest.call( + this, + 'DELETE', + `/list/${listId}/task/${taskId}`, + ); responseData = { success: true }; } } @@ -1101,7 +1220,12 @@ export class ClickUp implements INodeType { body.depends_on = dependsOnTaskId; - responseData = await clickupApiRequest.call(this, 'POST', `/task/${taskId}/dependency`, body); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/task/${taskId}/dependency`, + body, + ); responseData = { success: true }; } if (operation === 'delete') { @@ -1110,7 +1234,13 @@ export class ClickUp implements INodeType { qs.depends_on = dependsOnTaskId; - responseData = await clickupApiRequest.call(this, 'DELETE', `/task/${taskId}/dependency`, {}, qs); + responseData = await clickupApiRequest.call( + this, + 'DELETE', + `/task/${taskId}/dependency`, + {}, + qs, + ); responseData = { success: true }; } } @@ -1128,7 +1258,7 @@ export class ClickUp implements INodeType { } if (body.duration) { - body.duration = body.duration as number * 60000; + body.duration = (body.duration as number) * 60000; } if (body.task) { @@ -1136,7 +1266,12 @@ export class ClickUp implements INodeType { body.custom_task_ids = true; } - responseData = await clickupApiRequest.call(this, 'PUT', `/team/${teamId}/time_entries/${timeEntryId}`, body); + responseData = await clickupApiRequest.call( + this, + 'PUT', + `/team/${teamId}/time_entries/${timeEntryId}`, + body, + ); responseData = responseData.data; } if (operation === 'getAll') { @@ -1152,7 +1287,13 @@ export class ClickUp implements INodeType { if (filters.end_date) { qs.end_date = moment.tz(qs.end_date, timezone).valueOf(); } - responseData = await clickupApiRequest.call(this, 'GET', `/team/${teamId}/time_entries`, {}, qs); + responseData = await clickupApiRequest.call( + this, + 'GET', + `/team/${teamId}/time_entries`, + {}, + qs, + ); responseData = responseData.data; @@ -1160,7 +1301,6 @@ export class ClickUp implements INodeType { const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.splice(0, limit); } - } if (operation === 'get') { const teamId = this.getNodeParameter('team', i) as string; @@ -1191,10 +1331,15 @@ export class ClickUp implements INodeType { Object.assign(body, additionalFields); if (body.tags) { - body.tags = (body.tags as string[]).map((tag) => (JSON.parse(tag))); + body.tags = (body.tags as string[]).map((tag) => JSON.parse(tag)); } - responseData = await clickupApiRequest.call(this, 'POST', `/team/${teamId}/time_entries`, body); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/team/${teamId}/time_entries`, + body, + ); responseData = responseData.data; } if (operation === 'start') { @@ -1204,23 +1349,38 @@ export class ClickUp implements INodeType { body.tid = taskId; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; Object.assign(body, additionalFields); - responseData = await clickupApiRequest.call(this, 'POST', `/team/${teamId}/time_entries/start`, body); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/team/${teamId}/time_entries/start`, + body, + ); responseData = responseData.data; } if (operation === 'stop') { const teamId = this.getNodeParameter('team', i) as string; - responseData = await clickupApiRequest.call(this, 'POST', `/team/${teamId}/time_entries/stop`); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/team/${teamId}/time_entries/stop`, + ); if (responseData.data) { responseData = responseData.data; } else { - throw new NodeOperationError(this.getNode(), 'There seems to be nothing to stop.', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'There seems to be nothing to stop.', { + itemIndex: i, + }); } } if (operation === 'delete') { const teamId = this.getNodeParameter('team', i) as string; const timeEntryId = this.getNodeParameter('timeEntry', i) as string; - responseData = await clickupApiRequest.call(this, 'DELETE', `/team/${teamId}/time_entries/${timeEntryId}`); + responseData = await clickupApiRequest.call( + this, + 'DELETE', + `/team/${teamId}/time_entries/${timeEntryId}`, + ); responseData = responseData.data; } } @@ -1234,17 +1394,28 @@ export class ClickUp implements INodeType { if (tagsUi) { const tags = (tagsUi as IDataObject).tagsValues as IDataObject[]; if (tags === undefined) { - throw new NodeOperationError(this.getNode(), 'At least one tag must be set', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'At least one tag must be set', { + itemIndex: i, + }); } body.tags = tags; } - responseData = await clickupApiRequest.call(this, 'POST', `/team/${teamId}/time_entries/tags`, body); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/team/${teamId}/time_entries/tags`, + body, + ); responseData = { success: true }; } if (operation === 'getAll') { const teamId = this.getNodeParameter('team', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; - responseData = await clickupApiRequest.call(this, 'GET', `/team/${teamId}/time_entries/tags`); + responseData = await clickupApiRequest.call( + this, + 'GET', + `/team/${teamId}/time_entries/tags`, + ); responseData = responseData.data; @@ -1252,7 +1423,6 @@ export class ClickUp implements INodeType { const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.splice(0, limit); } - } if (operation === 'remove') { const teamId = this.getNodeParameter('team', i) as string; @@ -1260,11 +1430,15 @@ export class ClickUp implements INodeType { const tagNames = this.getNodeParameter('tagNames', i) as string[]; const body: IDataObject = {}; body.time_entry_ids = timeEntryIds.split(','); - body.tags = tagNames.map((tag) => (JSON.parse(tag).name)); - responseData = await clickupApiRequest.call(this, 'DELETE', `/team/${teamId}/time_entries/tags`, body); + body.tags = tagNames.map((tag) => JSON.parse(tag).name); + responseData = await clickupApiRequest.call( + this, + 'DELETE', + `/team/${teamId}/time_entries/tags`, + body, + ); responseData = { success: true }; } - } if (resource === 'spaceTag') { if (operation === 'create') { @@ -1279,13 +1453,22 @@ export class ClickUp implements INodeType { tag_fg: foregroundColor, }, }; - responseData = await clickupApiRequest.call(this, 'POST', `/space/${spaceId}/tag`, body); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/space/${spaceId}/tag`, + body, + ); responseData = { success: true }; } if (operation === 'delete') { const spaceId = this.getNodeParameter('space', i) as string; const name = this.getNodeParameter('name', i) as string; - responseData = await clickupApiRequest.call(this, 'DELETE', `/space/${spaceId}/tag/${name}`); + responseData = await clickupApiRequest.call( + this, + 'DELETE', + `/space/${spaceId}/tag/${name}`, + ); responseData = { success: true }; } if (operation === 'getAll') { @@ -1343,21 +1526,43 @@ export class ClickUp implements INodeType { body.status = additionalFields.status as string; } if (folderless) { - responseData = await clickupApiRequest.call(this, 'POST', `/space/${spaceId}/list`, body); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/space/${spaceId}/list`, + body, + ); } else { const folderId = this.getNodeParameter('folder', i) as string; - responseData = await clickupApiRequest.call(this, 'POST', `/folder/${folderId}/list`, body); + responseData = await clickupApiRequest.call( + this, + 'POST', + `/folder/${folderId}/list`, + body, + ); } } if (operation === 'member') { const listId = this.getNodeParameter('id', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; if (returnAll === true) { - responseData = await clickupApiRequest.call(this, 'GET', `/list/${listId}/member`, {}, qs); + responseData = await clickupApiRequest.call( + this, + 'GET', + `/list/${listId}/member`, + {}, + qs, + ); responseData = responseData.members; } else { qs.limit = this.getNodeParameter('limit', i) as number; - responseData = await clickupApiRequest.call(this, 'GET', `/list/${listId}/member`, {}, qs); + responseData = await clickupApiRequest.call( + this, + 'GET', + `/list/${listId}/member`, + {}, + qs, + ); responseData = responseData.members; responseData = responseData.splice(0, qs.limit); } diff --git a/packages/nodes-base/nodes/ClickUp/ClickUpTrigger.node.ts b/packages/nodes-base/nodes/ClickUp/ClickUpTrigger.node.ts index 263678169b855..c08e82eb3b7be 100644 --- a/packages/nodes-base/nodes/ClickUp/ClickUpTrigger.node.ts +++ b/packages/nodes-base/nodes/ClickUp/ClickUpTrigger.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 { - clickupApiRequest, -} from './GenericFunctions'; +import { clickupApiRequest } from './GenericFunctions'; -import { - createHmac, -} from 'crypto'; +import { createHmac } from 'crypto'; export class ClickUpTrigger implements INodeType { description: INodeTypeDescription = { @@ -39,9 +32,7 @@ export class ClickUpTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -50,9 +41,7 @@ export class ClickUpTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -86,7 +75,8 @@ export class ClickUpTrigger implements INodeType { displayName: 'Team Name or ID', name: 'team', type: 'options', - 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', }, @@ -339,15 +329,15 @@ export class ClickUpTrigger implements INodeType { const webhookData = this.getWorkflowStaticData('node'); const headerData = this.getHeaderData() as IDataObject; const req = this.getRequestObject(); - const computedSignature = createHmac('sha256', webhookData.secret as string).update(JSON.stringify(req.body)).digest('hex'); + const computedSignature = createHmac('sha256', webhookData.secret as string) + .update(JSON.stringify(req.body)) + .digest('hex'); if (headerData['x-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/ClickUp/CommentDescription.ts b/packages/nodes-base/nodes/ClickUp/CommentDescription.ts index 5459e17542201..6ace3d85d577d 100644 --- a/packages/nodes-base/nodes/ClickUp/CommentDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/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: [ @@ -46,7 +42,6 @@ export const commentOperations: INodeProperties[] = [ ]; export const commentFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* comment:create */ /* -------------------------------------------------------------------------- */ @@ -71,12 +66,8 @@ export const commentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'comment', - ], - operation: [ - 'create', - ], + resource: ['comment'], + operation: ['create'], }, }, }, @@ -87,12 +78,8 @@ export const commentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'comment', - ], - operation: [ - 'create', - ], + resource: ['comment'], + operation: ['create'], }, }, required: true, @@ -104,12 +91,8 @@ export const commentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'comment', - ], - operation: [ - 'create', - ], + resource: ['comment'], + operation: ['create'], }, }, }, @@ -121,12 +104,8 @@ export const commentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'comment', - ], - operation: [ - 'create', - ], + resource: ['comment'], + operation: ['create'], }, }, options: [ @@ -141,7 +120,8 @@ export const commentFields: INodeProperties[] = [ name: 'notifyAll', type: 'boolean', default: false, - description: 'Whether creation notifications will be sent to everyone including the creator of the comment', + description: + 'Whether creation notifications will be sent to everyone including the creator of the comment', }, ], }, @@ -156,12 +136,8 @@ export const commentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'comment', - ], - operation: [ - 'delete', - ], + resource: ['comment'], + operation: ['delete'], }, }, required: true, @@ -191,12 +167,8 @@ export const commentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'comment', - ], - operation: [ - 'getAll', - ], + resource: ['comment'], + operation: ['getAll'], }, }, }, @@ -207,12 +179,8 @@ export const commentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'comment', - ], - operation: [ - 'getAll', - ], + resource: ['comment'], + operation: ['getAll'], }, }, required: true, @@ -223,12 +191,8 @@ export const commentFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'comment', - ], - operation: [ - 'getAll', - ], + resource: ['comment'], + operation: ['getAll'], }, }, typeOptions: { @@ -249,12 +213,8 @@ export const commentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'comment', - ], - operation: [ - 'update', - ], + resource: ['comment'], + operation: ['update'], }, }, required: true, @@ -267,12 +227,8 @@ export const commentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'comment', - ], - operation: [ - 'update', - ], + resource: ['comment'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/ClickUp/FolderDescription.ts b/packages/nodes-base/nodes/ClickUp/FolderDescription.ts index 1ba2deebe5735..bf502d176490f 100644 --- a/packages/nodes-base/nodes/ClickUp/FolderDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/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: [ @@ -52,7 +48,6 @@ export const folderOperations: INodeProperties[] = [ ]; export const folderFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* folder:create */ /* -------------------------------------------------------------------------- */ @@ -60,16 +55,13 @@ export const folderFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'create', - ], + resource: ['folder'], + operation: ['create'], }, }, typeOptions: { @@ -81,23 +73,18 @@ export const folderFields: INodeProperties[] = [ displayName: 'Space Name or ID', name: 'space', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'create', - ], + resource: ['folder'], + operation: ['create'], }, }, typeOptions: { loadOptionsMethod: 'getSpaces', - loadOptionsDependsOn: [ - 'team', - ], + loadOptionsDependsOn: ['team'], }, required: true, }, @@ -108,12 +95,8 @@ export const folderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'create', - ], + resource: ['folder'], + operation: ['create'], }, }, required: true, @@ -126,16 +109,13 @@ export const folderFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'delete', - ], + resource: ['folder'], + operation: ['delete'], }, }, typeOptions: { @@ -147,23 +127,18 @@ export const folderFields: INodeProperties[] = [ displayName: 'Space Name or ID', name: 'space', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'delete', - ], + resource: ['folder'], + operation: ['delete'], }, }, typeOptions: { loadOptionsMethod: 'getSpaces', - loadOptionsDependsOn: [ - 'team', - ], + loadOptionsDependsOn: ['team'], }, required: true, }, @@ -171,23 +146,18 @@ export const folderFields: INodeProperties[] = [ displayName: 'Folder Name or ID', name: 'folder', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'delete', - ], + resource: ['folder'], + operation: ['delete'], }, }, typeOptions: { loadOptionsMethod: 'getFolders', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -199,16 +169,13 @@ export const folderFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'get', - ], + resource: ['folder'], + operation: ['get'], }, }, typeOptions: { @@ -220,23 +187,18 @@ export const folderFields: INodeProperties[] = [ displayName: 'Space Name or ID', name: 'space', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'get', - ], + resource: ['folder'], + operation: ['get'], }, }, typeOptions: { loadOptionsMethod: 'getSpaces', - loadOptionsDependsOn: [ - 'team', - ], + loadOptionsDependsOn: ['team'], }, required: true, }, @@ -244,23 +206,18 @@ export const folderFields: INodeProperties[] = [ displayName: 'Folder Name or ID', name: 'folder', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'get', - ], + resource: ['folder'], + operation: ['get'], }, }, typeOptions: { loadOptionsMethod: 'getFolders', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -272,16 +229,13 @@ export const folderFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'getAll', - ], + resource: ['folder'], + operation: ['getAll'], }, }, typeOptions: { @@ -293,23 +247,18 @@ export const folderFields: INodeProperties[] = [ displayName: 'Space Name or ID', name: 'space', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'getAll', - ], + resource: ['folder'], + operation: ['getAll'], }, }, typeOptions: { loadOptionsMethod: 'getSpaces', - loadOptionsDependsOn: [ - 'team', - ], + loadOptionsDependsOn: ['team'], }, required: true, }, @@ -319,12 +268,8 @@ export const folderFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'getAll', - ], + resource: ['folder'], + operation: ['getAll'], }, }, typeOptions: { @@ -342,12 +287,8 @@ export const folderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'getAll', - ], + resource: ['folder'], + operation: ['getAll'], }, }, options: [ @@ -367,16 +308,13 @@ export const folderFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'update', - ], + resource: ['folder'], + operation: ['update'], }, }, typeOptions: { @@ -388,23 +326,18 @@ export const folderFields: INodeProperties[] = [ displayName: 'Space Name or ID', name: 'space', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'update', - ], + resource: ['folder'], + operation: ['update'], }, }, typeOptions: { loadOptionsMethod: 'getSpaces', - loadOptionsDependsOn: [ - 'team', - ], + loadOptionsDependsOn: ['team'], }, required: true, }, @@ -412,23 +345,18 @@ export const folderFields: INodeProperties[] = [ displayName: 'Folder Name or ID', name: 'folder', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'update', - ], + resource: ['folder'], + operation: ['update'], }, }, typeOptions: { loadOptionsMethod: 'getFolders', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -440,12 +368,8 @@ export const folderFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'update', - ], + resource: ['folder'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts b/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts index 15aa2c77c41d4..e974426932591 100644 --- a/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -10,14 +8,24 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, - IOAuth2Options, - NodeApiError, -} from 'n8n-workflow'; - +import { IDataObject, IOAuth2Options, NodeApiError } from 'n8n-workflow'; -export async function clickupApiRequest(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 clickupApiRequest( + 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 options: OptionsWithUri = { headers: { 'Content-Type': 'application/json', @@ -34,22 +42,34 @@ export async function clickupApiRequest(this: IHookFunctions | IExecuteFunctions if (authenticationMethod === 'accessToken') { return await this.helpers.requestWithAuthentication.call(this, 'clickUpApi', options); - } else { const oAuth2Options: IOAuth2Options = { keepBearer: false, tokenType: 'Bearer', }; // @ts-ignore - return await this.helpers.requestOAuth2!.call(this, 'clickUpOAuth2Api', options, oAuth2Options); + return await this.helpers.requestOAuth2!.call( + this, + 'clickUpOAuth2Api', + options, + oAuth2Options, + ); } - } catch(error) { + } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function clickupApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function clickupApiRequestAllItems( + 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,14 +82,12 @@ export async function clickupApiRequestAllItems(this: IHookFunctions | IExecuteF if (query.limit && query.limit <= returnData.length) { return returnData; } - } 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!); diff --git a/packages/nodes-base/nodes/ClickUp/GoalDescription.ts b/packages/nodes-base/nodes/ClickUp/GoalDescription.ts index f69a23056d648..f9249325294c0 100644 --- a/packages/nodes-base/nodes/ClickUp/GoalDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/GoalDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const goalOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const goalOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'goal', - ], + resource: ['goal'], }, }, options: [ @@ -52,7 +48,6 @@ export const goalOperations: INodeProperties[] = [ ]; export const goalFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* goal:create */ /* -------------------------------------------------------------------------- */ @@ -60,16 +55,13 @@ export const goalFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'goal', - ], - operation: [ - 'create', - ], + resource: ['goal'], + operation: ['create'], }, }, typeOptions: { @@ -84,12 +76,8 @@ export const goalFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'goal', - ], - operation: [ - 'create', - ], + resource: ['goal'], + operation: ['create'], }, }, required: true, @@ -102,12 +90,8 @@ export const goalFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'goal', - ], - operation: [ - 'create', - ], + resource: ['goal'], + operation: ['create'], }, }, options: [ @@ -157,12 +141,8 @@ export const goalFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'goal', - ], - operation: [ - 'delete', - ], + resource: ['goal'], + operation: ['delete'], }, }, required: true, @@ -178,12 +158,8 @@ export const goalFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'goal', - ], - operation: [ - 'get', - ], + resource: ['goal'], + operation: ['get'], }, }, required: true, @@ -196,16 +172,13 @@ export const goalFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'goal', - ], - operation: [ - 'getAll', - ], + resource: ['goal'], + operation: ['getAll'], }, }, typeOptions: { @@ -219,12 +192,8 @@ export const goalFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'goal', - ], - operation: [ - 'getAll', - ], + resource: ['goal'], + operation: ['getAll'], }, }, typeOptions: { @@ -245,12 +214,8 @@ export const goalFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'goal', - ], - operation: [ - 'update', - ], + resource: ['goal'], + operation: ['update'], }, }, required: true, @@ -263,12 +228,8 @@ export const goalFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'goal', - ], - operation: [ - 'update', - ], + resource: ['goal'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/ClickUp/GoalKeyResultDescription.ts b/packages/nodes-base/nodes/ClickUp/GoalKeyResultDescription.ts index f4de1b42dd577..668cf9f660567 100644 --- a/packages/nodes-base/nodes/ClickUp/GoalKeyResultDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/GoalKeyResultDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const goalKeyResultOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const goalKeyResultOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'goalKeyResult', - ], + resource: ['goalKeyResult'], }, }, options: [ @@ -40,7 +36,6 @@ export const goalKeyResultOperations: INodeProperties[] = [ ]; export const goalKeyResultFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* goalKeyResult:create */ /* -------------------------------------------------------------------------- */ @@ -51,12 +46,8 @@ export const goalKeyResultFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'goalKeyResult', - ], - operation: [ - 'create', - ], + resource: ['goalKeyResult'], + operation: ['create'], }, }, required: true, @@ -68,12 +59,8 @@ export const goalKeyResultFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'goalKeyResult', - ], - operation: [ - 'create', - ], + resource: ['goalKeyResult'], + operation: ['create'], }, }, required: true, @@ -107,12 +94,8 @@ export const goalKeyResultFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'goalKeyResult', - ], - operation: [ - 'create', - ], + resource: ['goalKeyResult'], + operation: ['create'], }, }, required: true, @@ -125,12 +108,8 @@ export const goalKeyResultFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'goalKeyResult', - ], - operation: [ - 'create', - ], + resource: ['goalKeyResult'], + operation: ['create'], }, }, options: [ @@ -177,7 +156,8 @@ export const goalKeyResultFields: INodeProperties[] = [ name: 'unit', type: 'string', default: '', - description: 'Only matters for type Number and Currency. For Currency the unit must be a valid currency code.', + description: + 'Only matters for type Number and Currency. For Currency the unit must be a valid currency code.', }, ], }, @@ -192,12 +172,8 @@ export const goalKeyResultFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'goalKeyResult', - ], - operation: [ - 'delete', - ], + resource: ['goalKeyResult'], + operation: ['delete'], }, }, required: true, @@ -213,12 +189,8 @@ export const goalKeyResultFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'goalKeyResult', - ], - operation: [ - 'update', - ], + resource: ['goalKeyResult'], + operation: ['update'], }, }, required: true, @@ -231,12 +203,8 @@ export const goalKeyResultFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'goalKeyResult', - ], - operation: [ - 'update', - ], + resource: ['goalKeyResult'], + operation: ['update'], }, }, options: [ @@ -287,7 +255,8 @@ export const goalKeyResultFields: INodeProperties[] = [ name: 'unit', type: 'string', default: '', - description: 'Only matters for type Number and Currency. For Currency the unit must be a valid currency code.', + description: + 'Only matters for type Number and Currency. For Currency the unit must be a valid currency code.', }, ], }, diff --git a/packages/nodes-base/nodes/ClickUp/GuestDescription.ts b/packages/nodes-base/nodes/ClickUp/GuestDescription.ts index 25e8c1230ac87..8d7620ee8c113 100644 --- a/packages/nodes-base/nodes/ClickUp/GuestDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/GuestDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const guestOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const guestOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'guest', - ], + resource: ['guest'], }, }, options: [ @@ -46,7 +42,6 @@ export const guestOperations: INodeProperties[] = [ ]; export const guestFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* guest:create */ /* -------------------------------------------------------------------------- */ @@ -54,16 +49,13 @@ export const guestFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'guest', - ], - operation: [ - 'create', - ], + resource: ['guest'], + operation: ['create'], }, }, typeOptions: { @@ -79,12 +71,8 @@ export const guestFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'guest', - ], - operation: [ - 'create', - ], + resource: ['guest'], + operation: ['create'], }, }, }, @@ -96,12 +84,8 @@ export const guestFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'guest', - ], - operation: [ - 'create', - ], + resource: ['guest'], + operation: ['create'], }, }, options: [ @@ -133,16 +117,13 @@ export const guestFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'guest', - ], - operation: [ - 'delete', - ], + resource: ['guest'], + operation: ['delete'], }, }, typeOptions: { @@ -157,12 +138,8 @@ export const guestFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'guest', - ], - operation: [ - 'delete', - ], + resource: ['guest'], + operation: ['delete'], }, }, required: true, @@ -175,16 +152,13 @@ export const guestFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'guest', - ], - operation: [ - 'get', - ], + resource: ['guest'], + operation: ['get'], }, }, typeOptions: { @@ -199,12 +173,8 @@ export const guestFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'guest', - ], - operation: [ - 'get', - ], + resource: ['guest'], + operation: ['get'], }, }, required: true, @@ -217,16 +187,13 @@ export const guestFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'guest', - ], - operation: [ - 'update', - ], + resource: ['guest'], + operation: ['update'], }, }, typeOptions: { @@ -241,12 +208,8 @@ export const guestFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'guest', - ], - operation: [ - 'update', - ], + resource: ['guest'], + operation: ['update'], }, }, required: true, @@ -259,12 +222,8 @@ export const guestFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'guest', - ], - operation: [ - 'update', - ], + resource: ['guest'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/ClickUp/ListDescription.ts b/packages/nodes-base/nodes/ClickUp/ListDescription.ts index 3540a9f824905..5e4c4096152c0 100644 --- a/packages/nodes-base/nodes/ClickUp/ListDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/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: [ @@ -25,7 +21,7 @@ export const listOperations: INodeProperties[] = [ { name: 'Custom Fields', value: 'customFields', - description: 'Retrieve list\'s custom fields', + description: "Retrieve list's custom fields", action: 'Get custom fields from a list', }, { @@ -64,7 +60,6 @@ export const listOperations: INodeProperties[] = [ ]; export const listFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* list:create */ /* -------------------------------------------------------------------------- */ @@ -72,16 +67,13 @@ export const listFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'create', - ], + resource: ['list'], + operation: ['create'], }, }, typeOptions: { @@ -93,23 +85,18 @@ export const listFields: INodeProperties[] = [ displayName: 'Space Name or ID', name: 'space', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'create', - ], + resource: ['list'], + operation: ['create'], }, }, typeOptions: { loadOptionsMethod: 'getSpaces', - loadOptionsDependsOn: [ - 'team', - ], + loadOptionsDependsOn: ['team'], }, required: true, }, @@ -120,12 +107,8 @@ export const listFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'create', - ], + resource: ['list'], + operation: ['create'], }, }, required: true, @@ -134,26 +117,19 @@ export const listFields: INodeProperties[] = [ displayName: 'Folder Name or ID', name: 'folder', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'create', - ], - folderless: [ - false, - ], + resource: ['list'], + operation: ['create'], + folderless: [false], }, }, typeOptions: { loadOptionsMethod: 'getFolders', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -164,12 +140,8 @@ export const listFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'create', - ], + resource: ['list'], + operation: ['create'], }, }, required: true, @@ -182,12 +154,8 @@ export const listFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'create', - ], + resource: ['list'], + operation: ['create'], }, }, options: [ @@ -233,12 +201,11 @@ export const listFields: INodeProperties[] = [ displayName: 'Status Name or ID', name: 'status', type: 'options', - 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: 'getStatuses', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, default: '', }, @@ -256,12 +223,8 @@ export const listFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'member', - ], + resource: ['list'], + operation: ['member'], }, }, description: 'Task ID', @@ -272,12 +235,8 @@ export const listFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'member', - ], + resource: ['list'], + operation: ['member'], }, }, default: true, @@ -289,15 +248,9 @@ export const listFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'member', - ], - returnAll: [ - false, - ], + resource: ['list'], + operation: ['member'], + returnAll: [false], }, }, typeOptions: { @@ -314,16 +267,13 @@ export const listFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'customFields', - ], + resource: ['list'], + operation: ['customFields'], }, }, typeOptions: { @@ -335,23 +285,18 @@ export const listFields: INodeProperties[] = [ displayName: 'Space Name or ID', name: 'space', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'customFields', - ], + resource: ['list'], + operation: ['customFields'], }, }, typeOptions: { loadOptionsMethod: 'getSpaces', - loadOptionsDependsOn: [ - 'teamId', - ], + loadOptionsDependsOn: ['teamId'], }, required: true, }, @@ -362,12 +307,8 @@ export const listFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'customFields', - ], + resource: ['list'], + operation: ['customFields'], }, }, required: true, @@ -376,26 +317,19 @@ export const listFields: INodeProperties[] = [ displayName: 'Folder Name or ID', name: 'folder', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'customFields', - ], - folderless: [ - false, - ], + resource: ['list'], + operation: ['customFields'], + folderless: [false], }, }, typeOptions: { loadOptionsMethod: 'getFolders', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -403,26 +337,19 @@ export const listFields: INodeProperties[] = [ displayName: 'List Name or ID', name: 'list', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'customFields', - ], - folderless: [ - true, - ], + resource: ['list'], + operation: ['customFields'], + folderless: [true], }, }, typeOptions: { loadOptionsMethod: 'getFolderlessLists', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -430,26 +357,19 @@ export const listFields: INodeProperties[] = [ displayName: 'List Name or ID', name: 'list', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'customFields', - ], - folderless: [ - false, - ], + resource: ['list'], + operation: ['customFields'], + folderless: [false], }, }, typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'folder', - ], + loadOptionsDependsOn: ['folder'], }, required: true, }, @@ -461,16 +381,13 @@ export const listFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'delete', - ], + resource: ['list'], + operation: ['delete'], }, }, typeOptions: { @@ -482,23 +399,18 @@ export const listFields: INodeProperties[] = [ displayName: 'Space Name or ID', name: 'space', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'delete', - ], + resource: ['list'], + operation: ['delete'], }, }, typeOptions: { loadOptionsMethod: 'getSpaces', - loadOptionsDependsOn: [ - 'team', - ], + loadOptionsDependsOn: ['team'], }, required: true, }, @@ -509,12 +421,8 @@ export const listFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'delete', - ], + resource: ['list'], + operation: ['delete'], }, }, required: true, @@ -523,26 +431,19 @@ export const listFields: INodeProperties[] = [ displayName: 'Folder Name or ID', name: 'folder', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'delete', - ], - folderless: [ - false, - ], + resource: ['list'], + operation: ['delete'], + folderless: [false], }, }, typeOptions: { loadOptionsMethod: 'getFolders', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -553,12 +454,8 @@ export const listFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'delete', - ], + resource: ['list'], + operation: ['delete'], }, }, required: true, @@ -571,16 +468,13 @@ export const listFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'get', - ], + resource: ['list'], + operation: ['get'], }, }, typeOptions: { @@ -592,23 +486,18 @@ export const listFields: INodeProperties[] = [ displayName: 'Space Name or ID', name: 'space', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'get', - ], + resource: ['list'], + operation: ['get'], }, }, typeOptions: { loadOptionsMethod: 'getSpaces', - loadOptionsDependsOn: [ - 'team', - ], + loadOptionsDependsOn: ['team'], }, required: true, }, @@ -619,12 +508,8 @@ export const listFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'get', - ], + resource: ['list'], + operation: ['get'], }, }, required: true, @@ -633,26 +518,19 @@ export const listFields: INodeProperties[] = [ displayName: 'Folder Name or ID', name: 'folder', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'get', - ], - folderless: [ - false, - ], + resource: ['list'], + operation: ['get'], + folderless: [false], }, }, typeOptions: { loadOptionsMethod: 'getFolders', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -663,12 +541,8 @@ export const listFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'get', - ], + resource: ['list'], + operation: ['get'], }, }, required: true, @@ -681,16 +555,13 @@ export const listFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], + resource: ['list'], + operation: ['getAll'], }, }, typeOptions: { @@ -702,23 +573,18 @@ export const listFields: INodeProperties[] = [ displayName: 'Space Name or ID', name: 'space', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], + resource: ['list'], + operation: ['getAll'], }, }, typeOptions: { loadOptionsMethod: 'getSpaces', - loadOptionsDependsOn: [ - 'team', - ], + loadOptionsDependsOn: ['team'], }, required: true, }, @@ -729,12 +595,8 @@ export const listFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], + resource: ['list'], + operation: ['getAll'], }, }, required: true, @@ -743,26 +605,19 @@ export const listFields: INodeProperties[] = [ displayName: 'Folder Name or ID', name: 'folder', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], - folderless: [ - false, - ], + resource: ['list'], + operation: ['getAll'], + folderless: [false], }, }, typeOptions: { loadOptionsMethod: 'getFolders', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -772,12 +627,8 @@ export const listFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], + resource: ['list'], + operation: ['getAll'], }, }, typeOptions: { @@ -795,12 +646,8 @@ export const listFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'getAll', - ], + resource: ['list'], + operation: ['getAll'], }, }, options: [ @@ -820,16 +667,13 @@ export const listFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'update', - ], + resource: ['list'], + operation: ['update'], }, }, typeOptions: { @@ -841,23 +685,18 @@ export const listFields: INodeProperties[] = [ displayName: 'Space Name or ID', name: 'space', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'update', - ], + resource: ['list'], + operation: ['update'], }, }, typeOptions: { loadOptionsMethod: 'getSpaces', - loadOptionsDependsOn: [ - 'team', - ], + loadOptionsDependsOn: ['team'], }, required: true, }, @@ -868,12 +707,8 @@ export const listFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'update', - ], + resource: ['list'], + operation: ['update'], }, }, required: true, @@ -882,26 +717,19 @@ export const listFields: INodeProperties[] = [ displayName: 'Folder Name or ID', name: 'folder', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'update', - ], - folderless: [ - false, - ], + resource: ['list'], + operation: ['update'], + folderless: [false], }, }, typeOptions: { loadOptionsMethod: 'getFolders', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -912,12 +740,8 @@ export const listFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'update', - ], + resource: ['list'], + operation: ['update'], }, }, required: true, @@ -930,12 +754,8 @@ export const listFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'list', - ], - operation: [ - 'update', - ], + resource: ['list'], + operation: ['update'], }, }, options: [ @@ -943,12 +763,11 @@ export const listFields: 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: 'getAssignees', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, default: '', diff --git a/packages/nodes-base/nodes/ClickUp/ListInterface.ts b/packages/nodes-base/nodes/ClickUp/ListInterface.ts index d8a6db8157a60..09230bc46487a 100644 --- a/packages/nodes-base/nodes/ClickUp/ListInterface.ts +++ b/packages/nodes-base/nodes/ClickUp/ListInterface.ts @@ -1,4 +1,3 @@ - export interface IList { name?: string; content?: string; diff --git a/packages/nodes-base/nodes/ClickUp/SpaceTagDescription.ts b/packages/nodes-base/nodes/ClickUp/SpaceTagDescription.ts index e9efa0afd6a85..2200551cf2b5c 100644 --- a/packages/nodes-base/nodes/ClickUp/SpaceTagDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/SpaceTagDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const spaceTagOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const spaceTagOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'spaceTag', - ], + resource: ['spaceTag'], }, }, options: [ @@ -56,15 +52,8 @@ export const spaceTagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'spaceTag', - ], - operation: [ - 'create', - 'delete', - 'getAll', - 'update', - ], + resource: ['spaceTag'], + operation: ['create', 'delete', 'getAll', 'update'], }, }, required: true, @@ -76,12 +65,8 @@ export const spaceTagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'spaceTag', - ], - operation: [ - 'create', - ], + resource: ['spaceTag'], + operation: ['create'], }, }, required: true, @@ -90,23 +75,17 @@ export const spaceTagFields: INodeProperties[] = [ 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: { - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], loadOptionsMethod: 'getTags', }, default: '', displayOptions: { show: { - resource: [ - 'spaceTag', - ], - operation: [ - 'delete', - 'update', - ], + resource: ['spaceTag'], + operation: ['delete', 'update'], }, }, required: true, @@ -119,12 +98,8 @@ export const spaceTagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'spaceTag', - ], - operation: [ - 'update', - ], + resource: ['spaceTag'], + operation: ['update'], }, }, required: true, @@ -136,13 +111,8 @@ export const spaceTagFields: INodeProperties[] = [ default: '#000000', displayOptions: { show: { - resource: [ - 'spaceTag', - ], - operation: [ - 'create', - 'update', - ], + resource: ['spaceTag'], + operation: ['create', 'update'], }, }, required: true, @@ -154,13 +124,8 @@ export const spaceTagFields: INodeProperties[] = [ default: '#000000', displayOptions: { show: { - resource: [ - 'spaceTag', - ], - operation: [ - 'create', - 'update', - ], + resource: ['spaceTag'], + operation: ['create', 'update'], }, }, required: true, @@ -171,12 +136,8 @@ export const spaceTagFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'spaceTag', - ], - operation: [ - 'getAll', - ], + resource: ['spaceTag'], + operation: ['getAll'], }, }, default: true, @@ -188,15 +149,9 @@ export const spaceTagFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'spaceTag', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['spaceTag'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/ClickUp/TaskDependencyDescription.ts b/packages/nodes-base/nodes/ClickUp/TaskDependencyDescription.ts index 5455f1f3c90cd..f3f332638ad6a 100644 --- a/packages/nodes-base/nodes/ClickUp/TaskDependencyDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/TaskDependencyDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const taskDependencyOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const taskDependencyOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'taskDependency', - ], + resource: ['taskDependency'], }, }, options: [ @@ -34,7 +30,6 @@ export const taskDependencyOperations: INodeProperties[] = [ ]; export const taskDependencyFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* taskDependency:create */ /* -------------------------------------------------------------------------- */ @@ -45,12 +40,8 @@ export const taskDependencyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'taskDependency', - ], - operation: [ - 'create', - ], + resource: ['taskDependency'], + operation: ['create'], }, }, required: true, @@ -62,12 +53,8 @@ export const taskDependencyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'taskDependency', - ], - operation: [ - 'create', - ], + resource: ['taskDependency'], + operation: ['create'], }, }, required: true, @@ -83,12 +70,8 @@ export const taskDependencyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'taskDependency', - ], - operation: [ - 'delete', - ], + resource: ['taskDependency'], + operation: ['delete'], }, }, required: true, @@ -100,12 +83,8 @@ export const taskDependencyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'taskDependency', - ], - operation: [ - 'delete', - ], + resource: ['taskDependency'], + operation: ['delete'], }, }, required: true, diff --git a/packages/nodes-base/nodes/ClickUp/TaskDescription.ts b/packages/nodes-base/nodes/ClickUp/TaskDescription.ts index 3a636723adcf2..f1b9496524192 100644 --- a/packages/nodes-base/nodes/ClickUp/TaskDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/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,7 +60,6 @@ export const taskOperations: INodeProperties[] = [ ]; export const taskFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* task:create */ /* -------------------------------------------------------------------------- */ @@ -72,16 +67,13 @@ export const taskFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, typeOptions: { @@ -93,23 +85,18 @@ export const taskFields: INodeProperties[] = [ displayName: 'Space Name or ID', name: 'space', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, typeOptions: { loadOptionsMethod: 'getSpaces', - loadOptionsDependsOn: [ - 'team', - ], + loadOptionsDependsOn: ['team'], }, required: true, }, @@ -120,12 +107,8 @@ export const taskFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, required: true, @@ -134,26 +117,19 @@ export const taskFields: INodeProperties[] = [ displayName: 'Folder Name or ID', name: 'folder', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], - folderless: [ - false, - ], + resource: ['task'], + operation: ['create'], + folderless: [false], }, }, typeOptions: { loadOptionsMethod: 'getFolders', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -161,26 +137,19 @@ export const taskFields: INodeProperties[] = [ displayName: 'List Name or ID', name: 'list', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], - folderless: [ - true, - ], + resource: ['task'], + operation: ['create'], + folderless: [true], }, }, typeOptions: { loadOptionsMethod: 'getFolderlessLists', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -188,26 +157,19 @@ export const taskFields: INodeProperties[] = [ displayName: 'List Name or ID', name: 'list', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], - folderless: [ - false, - ], + resource: ['task'], + operation: ['create'], + folderless: [false], }, }, typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'folder', - ], + loadOptionsDependsOn: ['folder'], }, required: true, }, @@ -218,12 +180,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, required: true, @@ -237,12 +195,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, options: [ @@ -250,12 +204,11 @@ export const taskFields: INodeProperties[] = [ displayName: 'Assignee Names or IDs', name: 'assignees', 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: 'getAssignees', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, default: [], }, @@ -268,7 +221,8 @@ export const taskFields: INodeProperties[] = [ }, default: '', // eslint-disable-next-line n8n-nodes-base/node-param-description-miscased-id - description: 'Custom fields to set as JSON in the format: [ {"id": "", "value": ""} ]', + description: + 'Custom fields to set as JSON in the format: [ {"id": "", "value": ""} ]', }, { displayName: 'Content', @@ -336,12 +290,11 @@ export const taskFields: INodeProperties[] = [ displayName: 'Status Name or ID', name: 'status', type: 'options', - 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: 'getStatuses', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, default: '', }, @@ -351,12 +304,11 @@ export const taskFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getTags', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, default: [], - description: 'The array of tags applied to this task. Choose from the list, or specify IDs using an expression.', + description: + 'The array of tags applied to this task. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Time Estimate', @@ -379,12 +331,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, }, @@ -396,12 +344,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, options: [ @@ -501,7 +445,6 @@ export const taskFields: INodeProperties[] = [ default: 1, }, ], - }, /* -------------------------------------------------------------------------- */ @@ -515,12 +458,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'get', - ], + resource: ['task'], + operation: ['get'], }, }, }, @@ -532,16 +471,13 @@ export const taskFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, typeOptions: { @@ -553,23 +489,18 @@ export const taskFields: INodeProperties[] = [ displayName: 'Space Name or ID', name: 'space', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, typeOptions: { loadOptionsMethod: 'getSpaces', - loadOptionsDependsOn: [ - 'team', - ], + loadOptionsDependsOn: ['team'], }, required: true, }, @@ -580,12 +511,8 @@ export const taskFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, required: true, @@ -594,26 +521,19 @@ export const taskFields: INodeProperties[] = [ displayName: 'Folder Name or ID', name: 'folder', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], - folderless: [ - false, - ], + resource: ['task'], + operation: ['getAll'], + folderless: [false], }, }, typeOptions: { loadOptionsMethod: 'getFolders', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -621,26 +541,19 @@ export const taskFields: INodeProperties[] = [ displayName: 'List Name or ID', name: 'list', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], - folderless: [ - true, - ], + resource: ['task'], + operation: ['getAll'], + folderless: [true], }, }, typeOptions: { loadOptionsMethod: 'getFolderlessLists', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -648,26 +561,19 @@ export const taskFields: INodeProperties[] = [ displayName: 'List Name or ID', name: 'list', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], - folderless: [ - false, - ], + resource: ['task'], + operation: ['getAll'], + folderless: [false], }, }, typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'folder', - ], + loadOptionsDependsOn: ['folder'], }, required: true, }, @@ -677,12 +583,8 @@ export const taskFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, default: true, @@ -694,15 +596,9 @@ export const taskFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['task'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -720,12 +616,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, options: [ @@ -739,12 +631,11 @@ export const taskFields: INodeProperties[] = [ displayName: 'Assignee Names or IDs', name: 'assignees', 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: 'getAssignees', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, default: [], @@ -772,7 +663,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: 'Operator', @@ -821,10 +713,7 @@ export const taskFields: INodeProperties[] = [ type: 'string', displayOptions: { hide: { - operator: [ - 'IS NULL', - 'IS NOT NULL', - ], + operator: ['IS NULL', 'IS NOT NULL'], }, }, default: '', @@ -882,7 +771,8 @@ export const taskFields: INodeProperties[] = [ type: 'boolean', default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'The response does by default not include closed tasks. Set this to true and dont send a status filter to include closed tasks.', + description: + 'The response does by default not include closed tasks. Set this to true and dont send a status filter to include closed tasks.', }, { displayName: 'Order By', @@ -912,12 +802,11 @@ export const taskFields: INodeProperties[] = [ displayName: 'Status Names or IDs', name: 'statuses', 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: 'getStatuses', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, default: [], }, @@ -934,12 +823,11 @@ export const taskFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getTags', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, default: [], - description: 'The array of tags applied to this task. Choose from the list, or specify IDs using an expression.', + description: + 'The array of tags applied to this task. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -955,12 +843,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'delete', - ], + resource: ['task'], + operation: ['delete'], }, }, }, @@ -976,12 +860,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'member', - ], + resource: ['task'], + operation: ['member'], }, }, }, @@ -991,12 +871,8 @@ export const taskFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'member', - ], + resource: ['task'], + operation: ['member'], }, }, default: true, @@ -1008,15 +884,9 @@ export const taskFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'member', - ], - returnAll: [ - false, - ], + resource: ['task'], + operation: ['member'], + returnAll: [false], }, }, typeOptions: { @@ -1038,12 +908,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'setCustomField', - ], + resource: ['task'], + operation: ['setCustomField'], }, }, description: 'The ID of the task to add custom field to', @@ -1056,12 +922,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'setCustomField', - ], + resource: ['task'], + operation: ['setCustomField'], }, }, description: 'The ID of the field to add custom field to', @@ -1072,17 +934,14 @@ export const taskFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'setCustomField', - ], + resource: ['task'], + operation: ['setCustomField'], }, }, default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'The value is JSON and will be parsed as such. Is needed if for example needed for labels which expects the value to be an array.', + description: + 'The value is JSON and will be parsed as such. Is needed if for example needed for labels which expects the value to be an array.', }, { displayName: 'Value', @@ -1092,12 +951,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'setCustomField', - ], + resource: ['task'], + operation: ['setCustomField'], }, }, description: 'The value to set on custom field', diff --git a/packages/nodes-base/nodes/ClickUp/TaskInterface.ts b/packages/nodes-base/nodes/ClickUp/TaskInterface.ts index a24f9b2851670..9465271a7246f 100644 --- a/packages/nodes-base/nodes/ClickUp/TaskInterface.ts +++ b/packages/nodes-base/nodes/ClickUp/TaskInterface.ts @@ -1,6 +1,4 @@ -import { - IDataObject - } from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export interface ITask { name?: string; diff --git a/packages/nodes-base/nodes/ClickUp/TaskListDescription.ts b/packages/nodes-base/nodes/ClickUp/TaskListDescription.ts index ed9b0466848c3..4202ba75dd0bb 100644 --- a/packages/nodes-base/nodes/ClickUp/TaskListDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/TaskListDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const taskListOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const taskListOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'taskList', - ], + resource: ['taskList'], }, }, options: [ @@ -44,13 +40,8 @@ export const taskListFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'taskList', - ], - operation: [ - 'remove', - 'add', - ], + resource: ['taskList'], + operation: ['remove', 'add'], }, }, required: true, @@ -62,13 +53,8 @@ export const taskListFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'taskList', - ], - operation: [ - 'remove', - 'add', - ], + resource: ['taskList'], + operation: ['remove', 'add'], }, }, required: true, diff --git a/packages/nodes-base/nodes/ClickUp/TaskTagDescription.ts b/packages/nodes-base/nodes/ClickUp/TaskTagDescription.ts index 2020f191bf231..d0e89e363211b 100644 --- a/packages/nodes-base/nodes/ClickUp/TaskTagDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/TaskTagDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const taskTagOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const taskTagOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'taskTag', - ], + resource: ['taskTag'], }, }, options: [ @@ -44,13 +40,8 @@ export const taskTagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'taskTag', - ], - operation: [ - 'remove', - 'add', - ], + resource: ['taskTag'], + operation: ['remove', 'add'], }, }, required: true, @@ -62,13 +53,8 @@ export const taskTagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'taskTag', - ], - operation: [ - 'remove', - 'add', - ], + resource: ['taskTag'], + operation: ['remove', 'add'], }, }, required: true, @@ -81,13 +67,8 @@ export const taskTagFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'taskTag', - ], - operation: [ - 'remove', - 'add', - ], + resource: ['taskTag'], + operation: ['remove', 'add'], }, }, options: [ @@ -96,7 +77,7 @@ export const taskTagFields: INodeProperties[] = [ name: 'custom_task_ids', type: 'boolean', default: false, - description: 'Whether to reference a task by it\'s custom task ID', + description: "Whether to reference a task by it's custom task ID", }, { displayName: 'Team Name or ID', @@ -106,7 +87,8 @@ export const taskTagFields: INodeProperties[] = [ loadOptionsMethod: 'getTeams', }, default: '', - description: 'Only used when the parameter is set to custom_task_ids=true. Choose from the list, or specify an ID using an expression.', + description: + 'Only used when the parameter is set to custom_task_ids=true. Choose from the list, or specify an ID using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/ClickUp/TimeEntryDescription.ts b/packages/nodes-base/nodes/ClickUp/TimeEntryDescription.ts index 835da63950599..97a04a644b6a7 100644 --- a/packages/nodes-base/nodes/ClickUp/TimeEntryDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/TimeEntryDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const timeEntryOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const timeEntryOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'timeEntry', - ], + resource: ['timeEntry'], }, }, options: [ @@ -64,7 +60,6 @@ export const timeEntryOperations: INodeProperties[] = [ ]; export const timeEntryFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* timeEntry:getAll */ /* -------------------------------------------------------------------------- */ @@ -72,16 +67,13 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'getAll', - ], + resource: ['timeEntry'], + operation: ['getAll'], }, }, typeOptions: { @@ -95,12 +87,8 @@ export const timeEntryFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'getAll', - ], + resource: ['timeEntry'], + operation: ['getAll'], }, }, default: false, @@ -112,15 +100,9 @@ export const timeEntryFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['timeEntry'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -138,12 +120,8 @@ export const timeEntryFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'getAll', - ], + resource: ['timeEntry'], + operation: ['getAll'], }, }, options: [ @@ -169,16 +147,13 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'get', - ], + resource: ['timeEntry'], + operation: ['get'], }, }, typeOptions: { @@ -192,12 +167,8 @@ export const timeEntryFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'get', - ], + resource: ['timeEntry'], + operation: ['get'], }, }, default: false, @@ -210,15 +181,9 @@ export const timeEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'get', - ], - running: [ - false, - ], + resource: ['timeEntry'], + operation: ['get'], + running: [false], }, }, required: true, @@ -231,16 +196,13 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'create', - ], + resource: ['timeEntry'], + operation: ['create'], }, }, typeOptions: { @@ -252,23 +214,18 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'Space Name or ID', name: 'space', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'create', - ], + resource: ['timeEntry'], + operation: ['create'], }, }, typeOptions: { loadOptionsMethod: 'getSpaces', - loadOptionsDependsOn: [ - 'team', - ], + loadOptionsDependsOn: ['team'], }, required: true, }, @@ -279,12 +236,8 @@ export const timeEntryFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'create', - ], + resource: ['timeEntry'], + operation: ['create'], }, }, required: true, @@ -293,26 +246,19 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'Folder Name or ID', name: 'folder', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'create', - ], - folderless: [ - false, - ], + resource: ['timeEntry'], + operation: ['create'], + folderless: [false], }, }, typeOptions: { loadOptionsMethod: 'getFolders', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -320,26 +266,19 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'List Name or ID', name: 'list', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'create', - ], - folderless: [ - true, - ], + resource: ['timeEntry'], + operation: ['create'], + folderless: [true], }, }, typeOptions: { loadOptionsMethod: 'getFolderlessLists', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -347,26 +286,19 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'List Name or ID', name: 'list', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'create', - ], - folderless: [ - false, - ], + resource: ['timeEntry'], + operation: ['create'], + folderless: [false], }, }, typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'folder', - ], + loadOptionsDependsOn: ['folder'], }, required: true, }, @@ -376,12 +308,8 @@ export const timeEntryFields: INodeProperties[] = [ type: 'dateTime', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'create', - ], + resource: ['timeEntry'], + operation: ['create'], }, }, required: true, @@ -393,12 +321,8 @@ export const timeEntryFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'create', - ], + resource: ['timeEntry'], + operation: ['create'], }, }, default: 0, @@ -409,22 +333,17 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'Task 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', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'create', - ], + resource: ['timeEntry'], + operation: ['create'], }, }, typeOptions: { loadOptionsMethod: 'getTasks', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, default: '', }, @@ -436,12 +355,8 @@ export const timeEntryFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'create', - ], + resource: ['timeEntry'], + operation: ['create'], }, }, options: [ @@ -449,12 +364,11 @@ export const timeEntryFields: 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: 'getAssignees', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, default: [], }, @@ -475,11 +389,10 @@ export const timeEntryFields: 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: [ - 'team', - ], + loadOptionsDependsOn: ['team'], loadOptionsMethod: 'getTimeEntryTags', }, default: [], @@ -494,16 +407,13 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'start', - ], + resource: ['timeEntry'], + operation: ['start'], }, }, typeOptions: { @@ -518,12 +428,8 @@ export const timeEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'start', - ], + resource: ['timeEntry'], + operation: ['start'], }, }, required: true, @@ -536,12 +442,8 @@ export const timeEntryFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'start', - ], + resource: ['timeEntry'], + operation: ['start'], }, }, options: [ @@ -568,16 +470,13 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'stop', - ], + resource: ['timeEntry'], + operation: ['stop'], }, }, typeOptions: { @@ -593,16 +492,13 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'delete', - ], + resource: ['timeEntry'], + operation: ['delete'], }, }, typeOptions: { @@ -617,12 +513,8 @@ export const timeEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'delete', - ], + resource: ['timeEntry'], + operation: ['delete'], }, }, required: true, @@ -635,16 +527,13 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'update', - ], + resource: ['timeEntry'], + operation: ['update'], }, }, typeOptions: { @@ -656,23 +545,18 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'Space Name or ID', name: 'space', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'update', - ], + resource: ['timeEntry'], + operation: ['update'], }, }, typeOptions: { loadOptionsMethod: 'getSpaces', - loadOptionsDependsOn: [ - 'team', - ], + loadOptionsDependsOn: ['team'], }, required: true, }, @@ -683,12 +567,8 @@ export const timeEntryFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'update', - ], + resource: ['timeEntry'], + operation: ['update'], }, }, required: true, @@ -697,26 +577,19 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'Folder Name or ID', name: 'folder', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'update', - ], - folderless: [ - false, - ], + resource: ['timeEntry'], + operation: ['update'], + folderless: [false], }, }, typeOptions: { loadOptionsMethod: 'getFolders', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -724,26 +597,19 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'List Name or ID', name: 'list', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'update', - ], - folderless: [ - true, - ], + resource: ['timeEntry'], + operation: ['update'], + folderless: [true], }, }, typeOptions: { loadOptionsMethod: 'getFolderlessLists', - loadOptionsDependsOn: [ - 'space', - ], + loadOptionsDependsOn: ['space'], }, required: true, }, @@ -751,26 +617,19 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'List Name or ID', name: 'list', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'update', - ], - folderless: [ - false, - ], + resource: ['timeEntry'], + operation: ['update'], + folderless: [false], }, }, typeOptions: { loadOptionsMethod: 'getLists', - loadOptionsDependsOn: [ - 'folder', - ], + loadOptionsDependsOn: ['folder'], }, required: true, }, @@ -781,12 +640,8 @@ export const timeEntryFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'update', - ], + resource: ['timeEntry'], + operation: ['update'], }, }, required: true, @@ -798,12 +653,8 @@ export const timeEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'update', - ], + resource: ['timeEntry'], + operation: ['update'], }, }, required: true, @@ -816,12 +667,8 @@ export const timeEntryFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'update', - ], + resource: ['timeEntry'], + operation: ['update'], }, }, options: [ @@ -829,12 +676,11 @@ export const timeEntryFields: 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: 'getAssignees', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, default: [], }, @@ -868,11 +714,10 @@ export const timeEntryFields: 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: [ - 'spaceId', - ], + loadOptionsDependsOn: ['spaceId'], loadOptionsMethod: 'getTags', }, default: [], @@ -881,13 +726,11 @@ export const timeEntryFields: INodeProperties[] = [ displayName: 'Task 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', - loadOptionsDependsOn: [ - 'archived', - 'list', - ], + loadOptionsDependsOn: ['archived', 'list'], }, default: '', }, diff --git a/packages/nodes-base/nodes/ClickUp/TimeEntryTagDescription.ts b/packages/nodes-base/nodes/ClickUp/TimeEntryTagDescription.ts index 33f1b7e71773e..9c81401d6412c 100644 --- a/packages/nodes-base/nodes/ClickUp/TimeEntryTagDescription.ts +++ b/packages/nodes-base/nodes/ClickUp/TimeEntryTagDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const timeEntryTagOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const timeEntryTagOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'timeEntryTag', - ], + resource: ['timeEntryTag'], }, }, options: [ @@ -40,7 +36,6 @@ export const timeEntryTagOperations: INodeProperties[] = [ ]; export const timeEntryTagFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* timeEntryTag:getAll */ /* -------------------------------------------------------------------------- */ @@ -48,16 +43,13 @@ export const timeEntryTagFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntryTag', - ], - operation: [ - 'getAll', - ], + resource: ['timeEntryTag'], + operation: ['getAll'], }, }, typeOptions: { @@ -71,12 +63,8 @@ export const timeEntryTagFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'timeEntryTag', - ], - operation: [ - 'getAll', - ], + resource: ['timeEntryTag'], + operation: ['getAll'], }, }, default: false, @@ -88,15 +76,9 @@ export const timeEntryTagFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'timeEntryTag', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['timeEntryTag'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -114,16 +96,13 @@ export const timeEntryTagFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntryTag', - ], - operation: [ - 'add', - ], + resource: ['timeEntryTag'], + operation: ['add'], }, }, typeOptions: { @@ -138,12 +117,8 @@ export const timeEntryTagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'timeEntryTag', - ], - operation: [ - 'add', - ], + resource: ['timeEntryTag'], + operation: ['add'], }, }, required: true, @@ -159,12 +134,8 @@ export const timeEntryTagFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'timeEntryTag', - ], - operation: [ - 'add', - ], + resource: ['timeEntryTag'], + operation: ['add'], }, }, options: [ @@ -202,16 +173,13 @@ export const timeEntryTagFields: INodeProperties[] = [ displayName: 'Team Name or ID', name: 'team', type: 'options', - 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: '', displayOptions: { show: { - resource: [ - 'timeEntryTag', - ], - operation: [ - 'remove', - ], + resource: ['timeEntryTag'], + operation: ['remove'], }, }, typeOptions: { @@ -226,12 +194,8 @@ export const timeEntryTagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'timeEntryTag', - ], - operation: [ - 'remove', - ], + resource: ['timeEntryTag'], + operation: ['remove'], }, }, required: true, @@ -240,22 +204,17 @@ export const timeEntryTagFields: INodeProperties[] = [ displayName: 'Tag Names or IDs', name: 'tagNames', 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: 'getTimeEntryTags', - loadOptionsDependsOn: [ - 'teamId', - ], + loadOptionsDependsOn: ['teamId'], }, default: [], displayOptions: { show: { - resource: [ - 'timeEntryTag', - ], - operation: [ - 'remove', - ], + resource: ['timeEntryTag'], + operation: ['remove'], }, }, required: true, diff --git a/packages/nodes-base/nodes/Clockify/ClientDescription.ts b/packages/nodes-base/nodes/Clockify/ClientDescription.ts index c7c38eadf3e73..0453471e52c97 100644 --- a/packages/nodes-base/nodes/Clockify/ClientDescription.ts +++ b/packages/nodes-base/nodes/Clockify/ClientDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const clientOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const clientOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'client', - ], + resource: ['client'], }, }, options: [ @@ -52,7 +48,6 @@ export const clientOperations: INodeProperties[] = [ ]; export const clientFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* client:create */ /* -------------------------------------------------------------------------- */ @@ -65,12 +60,8 @@ export const clientFields: INodeProperties[] = [ description: 'Name of client being created', displayOptions: { show: { - resource: [ - 'client', - ], - operation: [ - 'create', - ], + resource: ['client'], + operation: ['create'], }, }, }, @@ -84,12 +75,8 @@ export const clientFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'client', - ], - operation: [ - 'delete', - ], + resource: ['client'], + operation: ['delete'], }, }, }, @@ -103,12 +90,8 @@ export const clientFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'client', - ], - operation: [ - 'get', - ], + resource: ['client'], + operation: ['get'], }, }, }, @@ -121,12 +104,8 @@ export const clientFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'client', - ], + operation: ['getAll'], + resource: ['client'], }, }, default: false, @@ -138,15 +117,9 @@ export const clientFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'client', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['client'], + returnAll: [false], }, }, typeOptions: { @@ -163,12 +136,8 @@ export const clientFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'client', - ], - operation: [ - 'getAll', - ], + resource: ['client'], + operation: ['getAll'], }, }, default: {}, @@ -215,12 +184,8 @@ export const clientFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'client', - ], - operation: [ - 'update', - ], + resource: ['client'], + operation: ['update'], }, }, }, @@ -232,12 +197,8 @@ export const clientFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'client', - ], - operation: [ - 'update', - ], + resource: ['client'], + operation: ['update'], }, }, }, @@ -248,12 +209,8 @@ export const clientFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'client', - ], + operation: ['update'], + resource: ['client'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/Clockify/Clockify.node.ts b/packages/nodes-base/nodes/Clockify/Clockify.node.ts index 22007a25884d0..17aa05ae177d2 100644 --- a/packages/nodes-base/nodes/Clockify/Clockify.node.ts +++ b/packages/nodes-base/nodes/Clockify/Clockify.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,58 +9,27 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - clockifyApiRequest, - clockifyApiRequestAllItems, -} from './GenericFunctions'; +import { clockifyApiRequest, clockifyApiRequestAllItems } from './GenericFunctions'; -import { - IClientDto, - IWorkspaceDto, -} from './WorkpaceInterfaces'; +import { IClientDto, IWorkspaceDto } from './WorkpaceInterfaces'; -import { - IUserDto, -} from './UserDtos'; +import { IUserDto } from './UserDtos'; -import { - IProjectDto, -} from './ProjectInterfaces'; +import { IProjectDto } from './ProjectInterfaces'; -import { - clientFields, - clientOperations, -} from './ClientDescription'; +import { clientFields, clientOperations } from './ClientDescription'; -import { - projectFields, - projectOperations, -} from './ProjectDescription'; +import { projectFields, projectOperations } from './ProjectDescription'; -import { - tagFields, - tagOperations, -} from './TagDescription'; +import { tagFields, tagOperations } from './TagDescription'; -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'; -import { - workspaceFields, - workspaceOperations, -} from './WorkspaceDescription'; +import { workspaceFields, workspaceOperations } from './WorkspaceDescription'; import moment from 'moment-timezone'; @@ -136,7 +103,8 @@ export class Clockify implements INodeType { 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: 'listWorkspaces', }, @@ -144,9 +112,7 @@ export class Clockify implements INodeType { default: [], displayOptions: { hide: { - resource: [ - 'workspace', - ], + resource: ['workspace'], }, }, }, @@ -163,14 +129,17 @@ export class Clockify implements INodeType { loadOptions: { async listWorkspaces(this: ILoadOptionsFunctions): Promise { const rtv: INodePropertyOptions[] = []; - const workspaces: IWorkspaceDto[] = await clockifyApiRequest.call(this, 'GET', 'workspaces'); + const workspaces: IWorkspaceDto[] = await clockifyApiRequest.call( + this, + 'GET', + 'workspaces', + ); if (undefined !== workspaces) { - workspaces.forEach(value => { - rtv.push( - { - name: value.name, - value: value.id, - }); + workspaces.forEach((value) => { + rtv.push({ + name: value.name, + value: value.id, + }); }); } return rtv; @@ -182,12 +151,11 @@ export class Clockify implements INodeType { const resource = `workspaces/${workspaceId}/users`; const users: IUserDto[] = await clockifyApiRequest.call(this, 'GET', resource); if (undefined !== users) { - users.forEach(value => { - rtv.push( - { - name: value.name, - value: value.id, - }); + users.forEach((value) => { + rtv.push({ + name: value.name, + value: value.id, + }); }); } } @@ -200,12 +168,11 @@ export class Clockify implements INodeType { const resource = `workspaces/${workspaceId}/clients`; const clients: IClientDto[] = await clockifyApiRequest.call(this, 'GET', resource); if (undefined !== clients) { - clients.forEach(value => { - rtv.push( - { - name: value.name, - value: value.id, - }); + clients.forEach((value) => { + rtv.push({ + name: value.name, + value: value.id, + }); }); } } @@ -218,12 +185,11 @@ export class Clockify implements INodeType { const resource = `workspaces/${workspaceId}/projects`; const users: IProjectDto[] = await clockifyApiRequest.call(this, 'GET', resource); if (undefined !== users) { - users.forEach(value => { - rtv.push( - { - name: value.name, - value: value.id, - }); + users.forEach((value) => { + rtv.push({ + name: value.name, + value: value.id, + }); }); } } @@ -236,29 +202,29 @@ export class Clockify implements INodeType { const resource = `workspaces/${workspaceId}/tags`; const users: IProjectDto[] = await clockifyApiRequest.call(this, 'GET', resource); if (undefined !== users) { - users.forEach(value => { - rtv.push( - { - name: value.name, - value: value.id, - }); + users.forEach((value) => { + rtv.push({ + name: value.name, + value: value.id, + }); }); } } return rtv; }, - async loadCustomFieldsForWorkspace(this: ILoadOptionsFunctions): Promise { + async loadCustomFieldsForWorkspace( + this: ILoadOptionsFunctions, + ): Promise { const rtv: INodePropertyOptions[] = []; const workspaceId = this.getCurrentNodeParameter('workspaceId'); if (undefined !== workspaceId) { const resource = `workspaces/${workspaceId}/custom-fields`; const customFields = await clockifyApiRequest.call(this, 'GET', resource); for (const customField of customFields) { - rtv.push( - { - name: customField.name, - value: customField.id, - }); + rtv.push({ + name: customField.name, + value: customField.id, + }); } } return rtv; @@ -267,7 +233,6 @@ export class Clockify implements INodeType { }; async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); const returnData: IDataObject[] = []; @@ -285,10 +250,7 @@ export class Clockify implements INodeType { for (let i = 0; i < length; i++) { try { if (resource === 'client') { - - if (operation === 'create') { - const workspaceId = this.getNodeParameter('workspaceId', i) as string; const name = this.getNodeParameter('name', i) as string; @@ -307,12 +269,11 @@ export class Clockify implements INodeType { } if (operation === 'delete') { - const workspaceId = this.getNodeParameter('workspaceId', i) as string; const clientId = this.getNodeParameter('clientId', i) as string; - responseData = await clockifyApiRequest.call( + responseData = await clockifyApiRequest.call( this, 'DELETE', `/workspaces/${workspaceId}/clients/${clientId}`, @@ -322,16 +283,12 @@ export class Clockify implements INodeType { } if (operation === 'update') { - const workspaceId = this.getNodeParameter('workspaceId', i) as string; const clientId = this.getNodeParameter('clientId', i) as string; const name = this.getNodeParameter('name', i) as string; - const updateFields = this.getNodeParameter( - 'updateFields', - i, - ) as IDataObject; + const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const body: IDataObject = { name, @@ -349,7 +306,6 @@ export class Clockify implements INodeType { } if (operation === 'get') { - const workspaceId = this.getNodeParameter('workspaceId', i) as string; const clientId = this.getNodeParameter('clientId', i) as string; @@ -364,7 +320,6 @@ export class Clockify implements INodeType { } if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; const workspaceId = this.getNodeParameter('workspaceId', i) as string; @@ -381,9 +336,7 @@ export class Clockify implements INodeType { {}, qs, ); - } else { - qs.limit = this.getNodeParameter('limit', i) as number; responseData = await clockifyApiRequestAllItems.call( @@ -400,9 +353,7 @@ export class Clockify implements INodeType { } if (resource === 'project') { - if (operation === 'create') { - const workspaceId = this.getNodeParameter('workspaceId', i) as string; const name = this.getNodeParameter('name', i) as string; @@ -416,7 +367,6 @@ export class Clockify implements INodeType { Object.assign(body, additionalFields); if (body.estimateUi) { - body.estimate = (body.estimateUi as IDataObject).estimateValues; delete body.estimateUi; @@ -432,7 +382,6 @@ export class Clockify implements INodeType { } if (operation === 'delete') { - const workspaceId = this.getNodeParameter('workspaceId', i) as string; const projectId = this.getNodeParameter('projectId', i) as string; @@ -444,11 +393,9 @@ export class Clockify implements INodeType { {}, qs, ); - } if (operation === 'get') { - const workspaceId = this.getNodeParameter('workspaceId', i) as string; const projectId = this.getNodeParameter('projectId', i) as string; @@ -463,7 +410,6 @@ export class Clockify implements INodeType { } if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; const workspaceId = this.getNodeParameter('workspaceId', i) as string; @@ -480,9 +426,7 @@ export class Clockify implements INodeType { {}, qs, ); - } else { - qs.limit = this.getNodeParameter('limit', i) as number; responseData = await clockifyApiRequestAllItems.call( @@ -498,7 +442,6 @@ export class Clockify implements INodeType { } if (operation === 'update') { - const workspaceId = this.getNodeParameter('workspaceId', i) as string; const projectId = this.getNodeParameter('projectId', i) as string; @@ -510,7 +453,6 @@ export class Clockify implements INodeType { Object.assign(body, updateFields); if (body.estimateUi) { - body.estimate = (body.estimateUi as IDataObject).estimateValues; delete body.estimateUi; @@ -527,9 +469,7 @@ export class Clockify implements INodeType { } if (resource === 'tag') { - if (operation === 'create') { - const workspaceId = this.getNodeParameter('workspaceId', i) as string; const name = this.getNodeParameter('name', i) as string; @@ -548,7 +488,6 @@ export class Clockify implements INodeType { } if (operation === 'delete') { - const workspaceId = this.getNodeParameter('workspaceId', i) as string; const tagId = this.getNodeParameter('tagId', i) as string; @@ -565,7 +504,6 @@ export class Clockify implements INodeType { } if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; const workspaceId = this.getNodeParameter('workspaceId', i) as string; @@ -582,9 +520,7 @@ export class Clockify implements INodeType { {}, qs, ); - } else { - qs.limit = this.getNodeParameter('limit', i) as number; responseData = await clockifyApiRequestAllItems.call( @@ -600,7 +536,6 @@ export class Clockify implements INodeType { } if (operation === 'update') { - const workspaceId = this.getNodeParameter('workspaceId', i) as string; const tagId = this.getNodeParameter('tagId', i) as string; @@ -623,19 +558,13 @@ export class Clockify implements INodeType { if (resource === 'task') { if (operation === 'create') { - const workspaceId = this.getNodeParameter( - 'workspaceId', - i, - ) as string; + const workspaceId = this.getNodeParameter('workspaceId', i) as string; const projectId = this.getNodeParameter('projectId', i) as string; const name = this.getNodeParameter('name', i) as string; - const additionalFields = this.getNodeParameter( - 'additionalFields', - i, - ) as IDataObject; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; const body: IDataObject = { name, @@ -658,10 +587,7 @@ export class Clockify implements INodeType { } if (operation === 'delete') { - const workspaceId = this.getNodeParameter( - 'workspaceId', - i, - ) as string; + const workspaceId = this.getNodeParameter('workspaceId', i) as string; const projectId = this.getNodeParameter('projectId', i) as string; @@ -677,10 +603,7 @@ export class Clockify implements INodeType { } if (operation === 'get') { - const workspaceId = this.getNodeParameter( - 'workspaceId', - i, - ) as string; + const workspaceId = this.getNodeParameter('workspaceId', i) as string; const projectId = this.getNodeParameter('projectId', i) as string; @@ -698,17 +621,11 @@ export class Clockify implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; - const workspaceId = this.getNodeParameter( - 'workspaceId', - i, - ) as string; + const workspaceId = this.getNodeParameter('workspaceId', i) as string; const projectId = this.getNodeParameter('projectId', i) as string; - const filters = this.getNodeParameter( - 'filters', - i, - ) as IDataObject; + const filters = this.getNodeParameter('filters', i) as IDataObject; Object.assign(qs, filters); @@ -734,19 +651,13 @@ export class Clockify implements INodeType { } if (operation === 'update') { - const workspaceId = this.getNodeParameter( - 'workspaceId', - i, - ) as string; + const workspaceId = this.getNodeParameter('workspaceId', i) as string; const projectId = this.getNodeParameter('projectId', 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; const body: IDataObject = {}; @@ -768,9 +679,7 @@ export class Clockify implements INodeType { } if (resource === 'timeEntry') { - if (operation === 'create') { - const timezone = this.getTimezone(); const workspaceId = this.getNodeParameter('workspaceId', i) as string; @@ -790,8 +699,8 @@ export class Clockify implements INodeType { } if (body.customFieldsUi) { - - const customFields = (body.customFieldsUi as IDataObject).customFieldsValues as IDataObject[]; + const customFields = (body.customFieldsUi as IDataObject) + .customFieldsValues as IDataObject[]; body.customFields = customFields; } @@ -806,7 +715,6 @@ export class Clockify implements INodeType { } if (operation === 'delete') { - const workspaceId = this.getNodeParameter('workspaceId', i) as string; const timeEntryId = this.getNodeParameter('timeEntryId', i) as string; @@ -823,7 +731,6 @@ export class Clockify implements INodeType { } if (operation === 'get') { - const workspaceId = this.getNodeParameter('workspaceId', i) as string; const timeEntryId = this.getNodeParameter('timeEntryId', i) as string; @@ -838,7 +745,6 @@ export class Clockify implements INodeType { } if (operation === 'update') { - const timezone = this.getTimezone(); const workspaceId = this.getNodeParameter('workspaceId', i) as string; @@ -861,7 +767,9 @@ export class Clockify implements INodeType { // even if you do not want to update the start time, it always has to be set // to make it more simple to the user, if he did not set a start time look for the current start time // and set it - const { timeInterval: { start } } = await clockifyApiRequest.call( + const { + timeInterval: { start }, + } = await clockifyApiRequest.call( this, 'GET', `/workspaces/${workspaceId}/time-entries/${timeEntryId}`, @@ -883,9 +791,7 @@ export class Clockify implements INodeType { } if (resource === 'user') { - if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; const workspaceId = this.getNodeParameter('workspaceId', i) as string; @@ -902,9 +808,7 @@ export class Clockify implements INodeType { {}, qs, ); - } else { - qs.limit = this.getNodeParameter('limit', i) as number; responseData = await clockifyApiRequestAllItems.call( @@ -923,13 +827,7 @@ export class Clockify implements INodeType { if (resource === 'workspace') { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; - responseData = await clockifyApiRequest.call( - this, - 'GET', - '/workspaces', - {}, - qs, - ); + responseData = await clockifyApiRequest.call(this, 'GET', '/workspaces', {}, qs); if (!returnAll) { qs.limit = this.getNodeParameter('limit', i) as number; responseData = responseData.splice(0, qs.limit); @@ -938,9 +836,7 @@ export class Clockify 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/Clockify/ClockifyTrigger.node.ts b/packages/nodes-base/nodes/Clockify/ClockifyTrigger.node.ts index ff620605060d9..382bd4386418a 100644 --- a/packages/nodes-base/nodes/Clockify/ClockifyTrigger.node.ts +++ b/packages/nodes-base/nodes/Clockify/ClockifyTrigger.node.ts @@ -10,15 +10,12 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - clockifyApiRequest, -} from './GenericFunctions'; +import { clockifyApiRequest } from './GenericFunctions'; import { EntryTypeEnum } from './EntryTypeEnum'; import { IUserDto } from './UserDtos'; import { IWorkspaceDto } from './WorkpaceInterfaces'; - export class ClockifyTrigger implements INodeType { description: INodeTypeDescription = { displayName: 'Clockify Trigger', @@ -44,7 +41,8 @@ export class ClockifyTrigger implements INodeType { 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: 'listWorkspaces', }, @@ -72,14 +70,17 @@ export class ClockifyTrigger implements INodeType { loadOptions: { async listWorkspaces(this: ILoadOptionsFunctions): Promise { const rtv: INodePropertyOptions[] = []; - const workspaces: IWorkspaceDto[] = await clockifyApiRequest.call(this, 'GET', 'workspaces'); + const workspaces: IWorkspaceDto[] = await clockifyApiRequest.call( + this, + 'GET', + 'workspaces', + ); if (undefined !== workspaces) { - workspaces.forEach(value => { - rtv.push( - { - name: value.name, - value: value.id, - }); + workspaces.forEach((value) => { + rtv.push({ + name: value.name, + value: value.id, + }); }); } return rtv; diff --git a/packages/nodes-base/nodes/Clockify/GenericFunctions.ts b/packages/nodes-base/nodes/Clockify/GenericFunctions.ts index dc478ecaf1c5f..7bb9059f907d4 100644 --- a/packages/nodes-base/nodes/Clockify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Clockify/GenericFunctions.ts @@ -1,18 +1,20 @@ -import { - OptionsWithUri, -} from 'request'; - -import { - IExecuteFunctions, - ILoadOptionsFunctions, - IPollFunctions, -} from 'n8n-core'; - -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; - -export async function clockifyApiRequest(this: ILoadOptionsFunctions | IPollFunctions | IExecuteFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { OptionsWithUri } from 'request'; + +import { IExecuteFunctions, ILoadOptionsFunctions, IPollFunctions } from 'n8n-core'; + +import { IDataObject, NodeApiError } from 'n8n-workflow'; + +export async function clockifyApiRequest( + this: ILoadOptionsFunctions | IPollFunctions | IExecuteFunctions, + 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 BASE_URL = 'https://api.clockify.me/api/v1'; const options: OptionsWithUri = { @@ -34,8 +36,15 @@ export async function clockifyApiRequest(this: ILoadOptionsFunctions | IPollFunc } } -export async function clockifyApiRequestAllItems(this: IExecuteFunctions | IPollFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function clockifyApiRequestAllItems( + this: IExecuteFunctions | IPollFunctions | 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; @@ -49,16 +58,12 @@ export async function clockifyApiRequestAllItems(this: IExecuteFunctions | IPoll returnData.push.apply(returnData, responseData); - if (query.limit && (returnData.length >= query.limit)) { - + if (query.limit && returnData.length >= query.limit) { return returnData; } query.page++; - - } while ( - responseData.length !== 0 - ); + } while (responseData.length !== 0); return returnData; } diff --git a/packages/nodes-base/nodes/Clockify/ProjectDescription.ts b/packages/nodes-base/nodes/Clockify/ProjectDescription.ts index 67c0fbda25722..0ed7ef4953a3d 100644 --- a/packages/nodes-base/nodes/Clockify/ProjectDescription.ts +++ b/packages/nodes-base/nodes/Clockify/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: [ @@ -52,7 +48,6 @@ export const projectOperations: INodeProperties[] = [ ]; export const projectFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* project:create */ /* -------------------------------------------------------------------------- */ @@ -65,12 +60,8 @@ export const projectFields: INodeProperties[] = [ description: 'Name of project being created', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'create', - ], + resource: ['project'], + operation: ['create'], }, }, }, @@ -81,12 +72,8 @@ export const projectFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'project', - ], + operation: ['create'], + resource: ['project'], }, }, default: {}, @@ -107,11 +94,10 @@ export const projectFields: 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', typeOptions: { - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], loadOptionsMethod: 'loadClientsForWorkspace', }, default: '', @@ -182,12 +168,8 @@ export const projectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'delete', - ], + resource: ['project'], + operation: ['delete'], }, }, }, @@ -202,12 +184,8 @@ export const projectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'get', - ], + resource: ['project'], + operation: ['get'], }, }, }, @@ -220,12 +198,8 @@ export const projectFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'project', - ], + operation: ['getAll'], + resource: ['project'], }, }, default: false, @@ -237,15 +211,9 @@ export const projectFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'project', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['project'], + returnAll: [false], }, }, typeOptions: { @@ -262,12 +230,8 @@ export const projectFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'project', - ], + operation: ['getAll'], + resource: ['project'], }, }, default: {}, @@ -288,11 +252,10 @@ export const projectFields: INodeProperties[] = [ displayName: 'Client Names or IDs', name: 'clients', 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: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], loadOptionsMethod: 'loadClientsForWorkspace', }, default: [], @@ -381,11 +344,10 @@ export const projectFields: INodeProperties[] = [ displayName: 'User Name or ID', name: 'users', type: 'options', - 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: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], loadOptionsMethod: 'loadUsersForWorkspace', }, default: '', @@ -421,12 +383,8 @@ export const projectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'update', - ], + resource: ['project'], + operation: ['update'], }, }, }, @@ -437,12 +395,8 @@ export const projectFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'project', - ], + operation: ['update'], + resource: ['project'], }, }, default: {}, @@ -463,11 +417,10 @@ export const projectFields: 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', typeOptions: { - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], loadOptionsMethod: 'loadClientsForWorkspace', }, default: '', @@ -533,5 +486,4 @@ export const projectFields: INodeProperties[] = [ }, ], }, - ]; diff --git a/packages/nodes-base/nodes/Clockify/ProjectInterfaces.ts b/packages/nodes-base/nodes/Clockify/ProjectInterfaces.ts index 4b07c0662c44c..3f601efa9473b 100644 --- a/packages/nodes-base/nodes/Clockify/ProjectInterfaces.ts +++ b/packages/nodes-base/nodes/Clockify/ProjectInterfaces.ts @@ -1,7 +1,4 @@ -import { - IHourlyRateDto, - IMembershipDto, -} from './CommonDtos'; +import { IHourlyRateDto, IMembershipDto } from './CommonDtos'; enum EstimateEnum { AUTO = 'AUTO', diff --git a/packages/nodes-base/nodes/Clockify/TagDescription.ts b/packages/nodes-base/nodes/Clockify/TagDescription.ts index 16611e871d08f..6eed9e976fa54 100644 --- a/packages/nodes-base/nodes/Clockify/TagDescription.ts +++ b/packages/nodes-base/nodes/Clockify/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: [ @@ -46,7 +42,6 @@ export const tagOperations: INodeProperties[] = [ ]; export const tagFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* tag:create */ /* -------------------------------------------------------------------------- */ @@ -59,12 +54,8 @@ export const tagFields: INodeProperties[] = [ description: 'Name of tag being created', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'create', - ], + resource: ['tag'], + operation: ['create'], }, }, }, @@ -79,12 +70,8 @@ export const tagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'delete', - ], + resource: ['tag'], + operation: ['delete'], }, }, }, @@ -97,12 +84,8 @@ export const tagFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'tag', - ], + operation: ['getAll'], + resource: ['tag'], }, }, default: false, @@ -114,15 +97,9 @@ export const tagFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'tag', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['tag'], + returnAll: [false], }, }, typeOptions: { @@ -139,12 +116,8 @@ export const tagFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'tag', - ], + operation: ['getAll'], + resource: ['tag'], }, }, default: {}, @@ -203,12 +176,8 @@ export const tagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'update', - ], + resource: ['tag'], + operation: ['update'], }, }, }, @@ -219,12 +188,8 @@ export const tagFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'tag', - ], + operation: ['update'], + resource: ['tag'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/Clockify/TaskDescription.ts b/packages/nodes-base/nodes/Clockify/TaskDescription.ts index 2354bc279fde1..c9e9ff9710a5b 100644 --- a/packages/nodes-base/nodes/Clockify/TaskDescription.ts +++ b/packages/nodes-base/nodes/Clockify/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: [ @@ -56,18 +52,15 @@ export const taskFields: INodeProperties[] = [ 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: { - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], loadOptionsMethod: 'loadProjectsForWorkspace', }, displayOptions: { show: { - resource: [ - 'task', - ], + resource: ['task'], }, }, required: true, @@ -85,12 +78,8 @@ export const taskFields: INodeProperties[] = [ description: 'Name of task to create', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, }, @@ -101,12 +90,8 @@ export const taskFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'task', - ], + operation: ['create'], + resource: ['task'], }, }, default: {}, @@ -116,7 +101,8 @@ export const taskFields: INodeProperties[] = [ displayName: 'Assignee Names or IDs', name: 'assigneeIds', 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: 'loadUsersForWorkspace', @@ -144,12 +130,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'delete', - ], + resource: ['task'], + operation: ['delete'], }, }, description: 'ID of task to delete', @@ -166,12 +148,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'get', - ], + resource: ['task'], + operation: ['get'], }, }, description: 'ID of task to get', @@ -186,12 +164,8 @@ export const taskFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], + operation: ['getAll'], + resource: ['task'], }, }, default: false, @@ -203,15 +177,9 @@ export const taskFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['task'], + returnAll: [false], }, }, typeOptions: { @@ -228,12 +196,8 @@ export const taskFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'task', - ], + operation: ['getAll'], + resource: ['task'], }, }, default: {}, @@ -293,12 +257,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, description: 'ID of task to update', @@ -310,12 +270,8 @@ export const taskFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'task', - ], + operation: ['update'], + resource: ['task'], }, }, default: {}, @@ -325,7 +281,8 @@ export const taskFields: INodeProperties[] = [ displayName: 'Assignee Names or IDs', name: 'assigneeIds', 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: 'loadUsersForWorkspace', diff --git a/packages/nodes-base/nodes/Clockify/TimeEntryDescription.ts b/packages/nodes-base/nodes/Clockify/TimeEntryDescription.ts index bdff1204410b6..d38c41794af5e 100644 --- a/packages/nodes-base/nodes/Clockify/TimeEntryDescription.ts +++ b/packages/nodes-base/nodes/Clockify/TimeEntryDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const timeEntryOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const timeEntryOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'timeEntry', - ], + resource: ['timeEntry'], }, }, options: [ @@ -46,7 +42,6 @@ export const timeEntryOperations: INodeProperties[] = [ ]; export const timeEntryFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* timeEntry:create */ /* -------------------------------------------------------------------------- */ @@ -58,12 +53,8 @@ export const timeEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'create', - ], + resource: ['timeEntry'], + operation: ['create'], }, }, }, @@ -74,12 +65,8 @@ export const timeEntryFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'timeEntry', - ], + operation: ['create'], + resource: ['timeEntry'], }, }, default: {}, @@ -110,13 +97,12 @@ export const timeEntryFields: INodeProperties[] = [ name: 'customFieldId', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], loadOptionsMethod: 'loadCustomFieldsForWorkspace', }, 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', @@ -148,11 +134,10 @@ export const timeEntryFields: INodeProperties[] = [ 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: { - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], loadOptionsMethod: 'loadProjectsForWorkspace', }, default: '', @@ -162,11 +147,10 @@ export const timeEntryFields: 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: { - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], loadOptionsMethod: 'loadTagsForWorkspace', }, default: [], @@ -191,12 +175,8 @@ export const timeEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'delete', - ], + resource: ['timeEntry'], + operation: ['delete'], }, }, }, @@ -211,12 +191,8 @@ export const timeEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'get', - ], + resource: ['timeEntry'], + operation: ['get'], }, }, }, @@ -227,12 +203,8 @@ export const timeEntryFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'timeEntry', - ], + operation: ['get'], + resource: ['timeEntry'], }, }, default: {}, @@ -242,14 +214,16 @@ export const timeEntryFields: INodeProperties[] = [ name: 'consider-duration-format', type: 'boolean', default: false, - description: 'Whether to return the time entry\'s duration rounded to minutes or seconds based on duration format (hh:mm or hh:mm:ss) from workspace settings', + description: + "Whether to return the time entry's duration rounded to minutes or seconds based on duration format (hh:mm or hh:mm:ss) from workspace settings", }, { displayName: 'Hydrated', name: 'hydrated', type: 'boolean', default: false, - description: 'Whether to return the time entry\'s project, task and tags in full and not just their IDs', + description: + "Whether to return the time entry's project, task and tags in full and not just their IDs", }, ], }, @@ -264,12 +238,8 @@ export const timeEntryFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'timeEntry', - ], - operation: [ - 'update', - ], + resource: ['timeEntry'], + operation: ['update'], }, }, }, @@ -280,12 +250,8 @@ export const timeEntryFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'update', - ], - resource: [ - 'timeEntry', - ], + operation: ['update'], + resource: ['timeEntry'], }, }, default: {}, @@ -316,13 +282,12 @@ export const timeEntryFields: INodeProperties[] = [ name: 'customFieldId', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], loadOptionsMethod: 'loadCustomFieldsForWorkspace', }, 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', @@ -354,11 +319,10 @@ export const timeEntryFields: INodeProperties[] = [ 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: { - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], loadOptionsMethod: 'loadProjectsForWorkspace', }, default: '', @@ -374,11 +338,10 @@ export const timeEntryFields: 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: { - loadOptionsDependsOn: [ - 'workspaceId', - ], + loadOptionsDependsOn: ['workspaceId'], loadOptionsMethod: 'loadTagsForWorkspace', }, default: [], diff --git a/packages/nodes-base/nodes/Clockify/UserDescription.ts b/packages/nodes-base/nodes/Clockify/UserDescription.ts index a98f2800a1752..e858648c81c99 100644 --- a/packages/nodes-base/nodes/Clockify/UserDescription.ts +++ b/packages/nodes-base/nodes/Clockify/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,7 +24,6 @@ export const userOperations: INodeProperties[] = [ ]; export const userFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* user:getAll */ /* -------------------------------------------------------------------------- */ @@ -38,12 +33,8 @@ export const userFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'user', - ], + operation: ['getAll'], + resource: ['user'], }, }, default: false, @@ -55,15 +46,9 @@ export const userFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'user', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['user'], + returnAll: [false], }, }, typeOptions: { @@ -80,12 +65,8 @@ export const userFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, default: {}, @@ -96,14 +77,16 @@ export const userFields: INodeProperties[] = [ type: 'string', placeholder: 'name@email.com', default: '', - description: 'If provided, you\'ll get a filtered list of users that contain the provided string in their email address', + description: + "If provided, you'll get a filtered list of users that contain the provided string in their email address", }, { displayName: 'Name', name: 'name', type: 'string', default: '', - description: 'If provided, you\'ll get a filtered list of users that contain the provided string in their name', + description: + "If provided, you'll get a filtered list of users that contain the provided string in their name", }, { displayName: 'Status', @@ -128,7 +111,8 @@ export const userFields: INodeProperties[] = [ }, ], default: '', - description: 'If provided, you\'ll get a filtered list of users with the corresponding status', + description: + "If provided, you'll get a filtered list of users with the corresponding status", }, { displayName: 'Sort Column', diff --git a/packages/nodes-base/nodes/Clockify/UserDtos.ts b/packages/nodes-base/nodes/Clockify/UserDtos.ts index 1a8453866d757..10153db21c54a 100644 --- a/packages/nodes-base/nodes/Clockify/UserDtos.ts +++ b/packages/nodes-base/nodes/Clockify/UserDtos.ts @@ -1,11 +1,12 @@ import { IMembershipDto } from './CommonDtos'; enum UserStatusEnum { - ACTIVE, PENDING_EMAIL_VERIFICATION, DELETED, + ACTIVE, + PENDING_EMAIL_VERIFICATION, + DELETED, } -interface IUserSettingsDto { -} +interface IUserSettingsDto {} export interface IUserDto { activeWorkspace: string; diff --git a/packages/nodes-base/nodes/Clockify/WorkspaceDescription.ts b/packages/nodes-base/nodes/Clockify/WorkspaceDescription.ts index c38f769ada000..c97f355b53d6b 100644 --- a/packages/nodes-base/nodes/Clockify/WorkspaceDescription.ts +++ b/packages/nodes-base/nodes/Clockify/WorkspaceDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const workspaceOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const workspaceOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'workspace', - ], + resource: ['workspace'], }, }, options: [ @@ -34,12 +30,8 @@ export const workspaceFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'workspace', - ], + operation: ['getAll'], + resource: ['workspace'], }, }, default: false, @@ -51,15 +43,9 @@ export const workspaceFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'workspace', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['workspace'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Cockpit/Cockpit.node.ts b/packages/nodes-base/nodes/Cockpit/Cockpit.node.ts index de46cf21e4115..89b7975599c20 100644 --- a/packages/nodes-base/nodes/Cockpit/Cockpit.node.ts +++ b/packages/nodes-base/nodes/Cockpit/Cockpit.node.ts @@ -7,29 +7,17 @@ import { INodeType, INodeTypeDescription, } from 'n8n-workflow'; -import { - collectionFields, - collectionOperations, -} from './CollectionDescription'; +import { collectionFields, collectionOperations } from './CollectionDescription'; import { createCollectionEntry, getAllCollectionEntries, getAllCollectionNames, } from './CollectionFunctions'; -import { - formFields, - formOperations -} from './FormDescription'; +import { formFields, formOperations } from './FormDescription'; import { submitForm } from './FormFunctions'; import { createDataFromParameters } from './GenericFunctions'; -import { - singletonFields, - singletonOperations, -} from './SingletonDescription'; -import { - getAllSingletonNames, - getSingleton, -} from './SingletonFunctions'; +import { singletonFields, singletonOperations } from './SingletonDescription'; +import { getAllSingletonNames, getSingleton } from './SingletonFunctions'; export class Cockpit implements INodeType { description: INodeTypeDescription = { @@ -89,7 +77,7 @@ export class Cockpit implements INodeType { async getCollections(this: ILoadOptionsFunctions): Promise { const collections = await getAllCollectionNames.call(this); - return collections.map(itemName => { + return collections.map((itemName) => { return { name: itemName, value: itemName, @@ -100,7 +88,7 @@ export class Cockpit implements INodeType { async getSingletons(this: ILoadOptionsFunctions): Promise { const singletons = await getAllSingletonNames.call(this); - return singletons.map(itemName => { + return singletons.map((itemName) => { return { name: itemName, value: itemName, diff --git a/packages/nodes-base/nodes/Cockpit/CollectionDescription.ts b/packages/nodes-base/nodes/Cockpit/CollectionDescription.ts index cc7f5b1324f83..4e85791b538a3 100644 --- a/packages/nodes-base/nodes/Cockpit/CollectionDescription.ts +++ b/packages/nodes-base/nodes/Cockpit/CollectionDescription.ts @@ -8,9 +8,7 @@ export const collectionOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'collection', - ], + resource: ['collection'], }, }, options: [ @@ -49,13 +47,12 @@ export const collectionFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'collection', - ], + resource: ['collection'], }, }, required: true, - description: 'Name of the collection to operate on. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the collection to operate on. Choose from the list, or specify an ID using an expression.', }, // Collection:entry:getAll @@ -65,12 +62,8 @@ export const collectionFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'collection', - ], + operation: ['getAll'], + resource: ['collection'], }, }, default: false, @@ -82,15 +75,9 @@ export const collectionFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'collection', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['collection'], + returnAll: [false], }, }, typeOptions: { @@ -108,12 +95,8 @@ export const collectionFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'getAll', - ], + resource: ['collection'], + operation: ['getAll'], }, }, options: [ @@ -137,7 +120,8 @@ export const collectionFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, placeholder: '{"name": "Jim"}', - description: 'Filter query in Mongolite format', + description: + 'Filter query in Mongolite format', }, { displayName: 'Language', @@ -173,7 +157,8 @@ export const collectionFields: INodeProperties[] = [ type: 'json', default: '', placeholder: '{"price": -1}', - description: 'Sort query in Mongolite format', + description: + 'Sort query in Mongolite format', }, ], }, @@ -187,12 +172,8 @@ export const collectionFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'update', - ], + resource: ['collection'], + operation: ['update'], }, }, }, @@ -206,13 +187,8 @@ export const collectionFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'collection', - ], - operation: [ - 'create', - 'update', - ], + resource: ['collection'], + operation: ['create', 'update'], }, }, description: 'Whether new entry fields should be set via the value-key pair UI or JSON', @@ -227,16 +203,9 @@ export const collectionFields: INodeProperties[] = [ }, displayOptions: { show: { - jsonDataFields: [ - true, - ], - resource: [ - 'collection', - ], - operation: [ - 'create', - 'update', - ], + jsonDataFields: [true], + resource: ['collection'], + operation: ['create', 'update'], }, }, description: 'Entry data to send as JSON', @@ -251,16 +220,9 @@ export const collectionFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - jsonDataFields: [ - false, - ], - resource: [ - 'collection', - ], - operation: [ - 'create', - 'update', - ], + jsonDataFields: [false], + resource: ['collection'], + operation: ['create', 'update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Cockpit/CollectionFunctions.ts b/packages/nodes-base/nodes/Cockpit/CollectionFunctions.ts index 27e51094fe086..51c0d5d199d49 100644 --- a/packages/nodes-base/nodes/Cockpit/CollectionFunctions.ts +++ b/packages/nodes-base/nodes/Cockpit/CollectionFunctions.ts @@ -1,13 +1,15 @@ -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject } from 'n8n-workflow'; import { ICollection } from './CollectionInterface'; import { cockpitApiRequest } from './GenericFunctions'; -export async function createCollectionEntry(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, resourceName: string, data: IDataObject, id?: string): Promise { // tslint:disable-line:no-any +export async function createCollectionEntry( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + resourceName: string, + data: IDataObject, + id?: string, + // tslint:disable-next-line:no-any +): Promise { const body: ICollection = { data, }; @@ -22,12 +24,16 @@ export async function createCollectionEntry(this: IExecuteFunctions | IExecuteSi return cockpitApiRequest.call(this, 'post', `/collections/save/${resourceName}`, body); } - -export async function getAllCollectionEntries(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, resourceName: string, options: IDataObject): Promise { // tslint:disable-line:no-any +export async function getAllCollectionEntries( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + resourceName: string, + options: IDataObject, + // tslint:disable-next-line:no-any +): Promise { const body: ICollection = {}; if (options.fields) { - const fields = (options.fields as string).split(',').map(field => field.trim() ); + const fields = (options.fields as string).split(',').map((field) => field.trim()); const bodyFields = { _id: false, @@ -71,7 +77,8 @@ export async function getAllCollectionEntries(this: IExecuteFunctions | IExecute return cockpitApiRequest.call(this, 'post', `/collections/get/${resourceName}`, body); } - -export async function getAllCollectionNames(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions): Promise { +export async function getAllCollectionNames( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, +): Promise { return cockpitApiRequest.call(this, 'GET', `/collections/listCollections`, {}); } diff --git a/packages/nodes-base/nodes/Cockpit/FormDescription.ts b/packages/nodes-base/nodes/Cockpit/FormDescription.ts index 4b2c24aec83e9..335ca6f323100 100644 --- a/packages/nodes-base/nodes/Cockpit/FormDescription.ts +++ b/packages/nodes-base/nodes/Cockpit/FormDescription.ts @@ -8,9 +8,7 @@ export const formOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'form', - ], + resource: ['form'], }, }, options: [ @@ -20,7 +18,6 @@ export const formOperations: INodeProperties[] = [ description: 'Store data from a form submission', action: 'Submit a form', }, - ], default: 'submit', }, @@ -33,9 +30,7 @@ export const formFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'form', - ], + resource: ['form'], }, }, default: '', @@ -51,12 +46,8 @@ export const formFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'form', - ], - operation: [ - 'submit', - ], + resource: ['form'], + operation: ['submit'], }, }, description: 'Whether form fields should be set via the value-key pair UI or JSON', @@ -71,15 +62,9 @@ export const formFields: INodeProperties[] = [ }, displayOptions: { show: { - jsonDataFields: [ - true, - ], - resource: [ - 'form', - ], - operation: [ - 'submit', - ], + jsonDataFields: [true], + resource: ['form'], + operation: ['submit'], }, }, description: 'Form data to send as JSON', @@ -94,15 +79,9 @@ export const formFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - jsonDataFields: [ - false, - ], - resource: [ - 'form', - ], - operation: [ - 'submit', - ], + jsonDataFields: [false], + resource: ['form'], + operation: ['submit'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Cockpit/FormFunctions.ts b/packages/nodes-base/nodes/Cockpit/FormFunctions.ts index f2a3e5eec6bd7..da4465fb59878 100644 --- a/packages/nodes-base/nodes/Cockpit/FormFunctions.ts +++ b/packages/nodes-base/nodes/Cockpit/FormFunctions.ts @@ -1,13 +1,13 @@ -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject } from 'n8n-workflow'; import { IForm } from './FormInterface'; import { cockpitApiRequest } from './GenericFunctions'; -export async function submitForm(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, resourceName: string, form: IDataObject) { +export async function submitForm( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + resourceName: string, + form: IDataObject, +) { const body: IForm = { form, }; diff --git a/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts b/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts index e491a11448ff1..2de2cffe3f1a7 100644 --- a/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts @@ -1,12 +1,17 @@ -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'; import { OptionsWithUri } from 'request'; -export async function cockpitApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function cockpitApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + resource: string, + // tslint:disable-next-line:no-any + body: any = {}, + uri?: string, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('cockpitApi'); let options: OptionsWithUri = { headers: { @@ -35,7 +40,10 @@ export async function cockpitApiRequest(this: IExecuteFunctions | IExecuteSingle } } -export function createDataFromParameters(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, itemIndex: number): IDataObject { +export function createDataFromParameters( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + itemIndex: number, +): IDataObject { const dataFieldsAreJson = this.getNodeParameter('jsonDataFields', itemIndex) as boolean; if (dataFieldsAreJson) { diff --git a/packages/nodes-base/nodes/Cockpit/SingletonDescription.ts b/packages/nodes-base/nodes/Cockpit/SingletonDescription.ts index 7c1f7ea1e108c..8fb877b64edb7 100644 --- a/packages/nodes-base/nodes/Cockpit/SingletonDescription.ts +++ b/packages/nodes-base/nodes/Cockpit/SingletonDescription.ts @@ -8,9 +8,7 @@ export const singletonOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'singleton', - ], + resource: ['singleton'], }, }, options: [ @@ -36,12 +34,11 @@ export const singletonFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'singleton', - ], + resource: ['singleton'], }, }, required: true, - description: 'Name of the singleton to operate on. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the singleton to operate on. Choose from the list, or specify an ID using an expression.', }, ]; diff --git a/packages/nodes-base/nodes/Cockpit/SingletonFunctions.ts b/packages/nodes-base/nodes/Cockpit/SingletonFunctions.ts index dab17f21f3b10..89be4925b1e7e 100644 --- a/packages/nodes-base/nodes/Cockpit/SingletonFunctions.ts +++ b/packages/nodes-base/nodes/Cockpit/SingletonFunctions.ts @@ -1,14 +1,16 @@ -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { cockpitApiRequest } from './GenericFunctions'; -export async function getSingleton(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, resourceName: string): Promise { // tslint:disable-line:no-any +export async function getSingleton( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + resourceName: string, + // tslint:disable-next-line:no-any +): Promise { return cockpitApiRequest.call(this, 'get', `/singletons/get/${resourceName}`); } -export async function getAllSingletonNames(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions): Promise { +export async function getAllSingletonNames( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, +): Promise { return cockpitApiRequest.call(this, 'GET', `/singletons/listSingletons`, {}); } diff --git a/packages/nodes-base/nodes/Coda/Coda.node.ts b/packages/nodes-base/nodes/Coda/Coda.node.ts index 6edb066431eeb..750973fedd6fb 100644 --- a/packages/nodes-base/nodes/Coda/Coda.node.ts +++ b/packages/nodes-base/nodes/Coda/Coda.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, ILoadOptionsFunctions, @@ -11,26 +9,11 @@ import { NodeApiError, NodeOperationError, } from 'n8n-workflow'; -import { - codaApiRequest, - codaApiRequestAllItems, -} from './GenericFunctions'; -import { - tableFields, - tableOperations, -} from './TableDescription'; -import { - formulaFields, - formulaOperations, -} from './FormulaDescription'; -import { - controlFields, - controlOperations, -} from './ControlDescription'; -import { - viewFields, - viewOperations, -} from './ViewDescription'; +import { codaApiRequest, codaApiRequestAllItems } from './GenericFunctions'; +import { tableFields, tableOperations } from './TableDescription'; +import { formulaFields, formulaOperations } from './FormulaDescription'; +import { controlFields, controlOperations } from './ControlDescription'; +import { viewFields, viewOperations } from './ViewDescription'; export class Coda implements INodeType { description: INodeTypeDescription = { @@ -62,7 +45,8 @@ export class Coda implements INodeType { { name: 'Control', value: 'control', - description: 'Controls provide a user-friendly way to input a value that can affect other parts of the doc', + description: + 'Controls provide a user-friendly way to input a value that can affect other parts of the doc', }, { name: 'Formula', @@ -100,7 +84,7 @@ export class Coda implements INodeType { async getDocs(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const qs = {}; - const docs = await codaApiRequestAllItems.call(this,'items', 'GET', `/docs`, {}, qs); + const docs = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs`, {}, qs); for (const doc of docs) { const docName = doc.name; const docId = doc.id; @@ -118,7 +102,13 @@ export class Coda implements INodeType { const docId = this.getCurrentNodeParameter('docId'); - const tables = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/tables`, {}); + const tables = await codaApiRequestAllItems.call( + this, + 'items', + 'GET', + `/docs/${docId}/tables`, + {}, + ); for (const table of tables) { const tableName = table.name; const tableId = table.id; @@ -137,7 +127,13 @@ export class Coda implements INodeType { const docId = this.getCurrentNodeParameter('docId'); const tableId = this.getCurrentNodeParameter('tableId'); - const columns = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/tables/${tableId}/columns`, {}); + const columns = await codaApiRequestAllItems.call( + this, + 'items', + 'GET', + `/docs/${docId}/tables/${tableId}/columns`, + {}, + ); for (const column of columns) { const columnName = column.name; const columnId = column.id; @@ -153,7 +149,13 @@ export class Coda implements INodeType { async getViews(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const docId = this.getCurrentNodeParameter('docId'); - const views = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/tables?tableTypes=view`, {}); + const views = await codaApiRequestAllItems.call( + this, + 'items', + 'GET', + `/docs/${docId}/tables?tableTypes=view`, + {}, + ); for (const view of views) { const viewName = view.name; const viewId = view.id; @@ -169,7 +171,13 @@ export class Coda implements INodeType { async getFormulas(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const docId = this.getCurrentNodeParameter('docId'); - const formulas = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/formulas`, {}); + const formulas = await codaApiRequestAllItems.call( + this, + 'items', + 'GET', + `/docs/${docId}/formulas`, + {}, + ); for (const formula of formulas) { const formulaName = formula.name; const formulaId = formula.id; @@ -186,7 +194,13 @@ export class Coda implements INodeType { const returnData: INodePropertyOptions[] = []; const docId = this.getCurrentNodeParameter('docId'); const viewId = this.getCurrentNodeParameter('viewId'); - const viewRows = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/tables/${viewId}/rows`, {}); + const viewRows = await codaApiRequestAllItems.call( + this, + 'items', + 'GET', + `/docs/${docId}/tables/${viewId}/rows`, + {}, + ); for (const viewRow of viewRows) { const viewRowName = viewRow.name; const viewRowId = viewRow.id; @@ -205,7 +219,13 @@ export class Coda implements INodeType { const docId = this.getCurrentNodeParameter('docId'); const viewId = this.getCurrentNodeParameter('viewId'); - const viewColumns = await codaApiRequestAllItems.call(this, 'items', 'GET', `/docs/${docId}/tables/${viewId}/columns`, {}); + const viewColumns = await codaApiRequestAllItems.call( + this, + 'items', + 'GET', + `/docs/${docId}/tables/${viewId}/columns`, + {}, + ); for (const viewColumn of viewColumns) { const viewColumnName = viewColumn.name; const viewColumnId = viewColumn.id; @@ -265,13 +285,21 @@ export class Coda implements INodeType { if (options.keyColumns) { // @ts-ignore - (sendData[endpoint]! as IDataObject).keyColumns! = options.keyColumns.split(',') as string[]; + (sendData[endpoint]! as IDataObject).keyColumns! = options.keyColumns.split( + ',', + ) as string[]; } } // Now that all data got collected make all the requests for (const endpoint of Object.keys(sendData)) { - await codaApiRequest.call(this, 'POST', endpoint, sendData[endpoint], (sendData[endpoint]! as IDataObject).qs! as IDataObject); + await codaApiRequest.call( + this, + 'POST', + endpoint, + sendData[endpoint], + (sendData[endpoint]! as IDataObject).qs! as IDataObject, + ); } } catch (error) { if (this.continueOnFail()) { @@ -347,7 +375,14 @@ export class Coda implements INodeType { } try { if (returnAll === true) { - responseData = await codaApiRequestAllItems.call(this, 'items', 'GET', endpoint, {}, qs); + responseData = await codaApiRequestAllItems.call( + this, + 'items', + 'GET', + endpoint, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; responseData = await codaApiRequest.call(this, 'GET', endpoint, {}, qs); @@ -392,7 +427,7 @@ export class Coda implements INodeType { // Now that all data got collected make all the requests for (const endpoint of Object.keys(sendData)) { - await codaApiRequest.call(this, 'DELETE', endpoint, { rowIds: sendData[endpoint]}, qs); + await codaApiRequest.call(this, 'DELETE', endpoint, { rowIds: sendData[endpoint] }, qs); } } catch (error) { if (this.continueOnFail()) { @@ -459,7 +494,7 @@ export class Coda implements INodeType { responseData = await codaApiRequest.call(this, 'GET', endpoint, {}, qs); responseData = responseData.items; } - returnData.push.apply(returnData,responseData); + returnData.push.apply(returnData, responseData); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -505,7 +540,7 @@ export class Coda implements INodeType { responseData = await codaApiRequest.call(this, 'GET', endpoint, {}, qs); responseData = responseData.items; } - returnData.push.apply(returnData,responseData); + returnData.push.apply(returnData, responseData); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -551,7 +586,7 @@ export class Coda implements INodeType { responseData = await codaApiRequest.call(this, 'GET', endpoint, {}, qs); responseData = responseData.items; } - returnData.push.apply(returnData,responseData); + returnData.push.apply(returnData, responseData); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -589,7 +624,7 @@ export class Coda implements INodeType { responseData = await codaApiRequest.call(this, 'GET', endpoint, {}, qs); responseData = responseData.items; } - returnData.push.apply(returnData,responseData); + returnData.push.apply(returnData, responseData); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -622,7 +657,14 @@ export class Coda implements INodeType { } try { if (returnAll === true) { - responseData = await codaApiRequestAllItems.call(this, 'items', 'GET', endpoint, {}, qs); + responseData = await codaApiRequestAllItems.call( + this, + 'items', + 'GET', + endpoint, + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', 0) as number; responseData = await codaApiRequest.call(this, 'GET', endpoint, {}, qs); @@ -656,7 +698,7 @@ export class Coda implements INodeType { const rowId = this.getNodeParameter('rowId', i) as string; const endpoint = `/docs/${docId}/tables/${viewId}/rows/${rowId}`; responseData = await codaApiRequest.call(this, 'DELETE', endpoint); - returnData.push.apply(returnData,responseData); + returnData.push.apply(returnData, responseData); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -677,7 +719,7 @@ export class Coda implements INodeType { const columnId = this.getNodeParameter('columnId', i) as string; const endpoint = `/docs/${docId}/tables/${viewId}/rows/${rowId}/buttons/${columnId}`; responseData = await codaApiRequest.call(this, 'POST', endpoint); - returnData.push.apply(returnData,responseData); + returnData.push.apply(returnData, responseData); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -702,7 +744,7 @@ export class Coda implements INodeType { responseData = await codaApiRequest.call(this, 'GET', endpoint, {}, qs); responseData = responseData.items; } - returnData.push.apply(returnData,responseData); + returnData.push.apply(returnData, responseData); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/Coda/ControlDescription.ts b/packages/nodes-base/nodes/Coda/ControlDescription.ts index 84079225ce13f..b395394f76c4b 100644 --- a/packages/nodes-base/nodes/Coda/ControlDescription.ts +++ b/packages/nodes-base/nodes/Coda/ControlDescription.ts @@ -8,9 +8,7 @@ export const controlOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'control', - ], + resource: ['control'], }, }, options: [ @@ -32,10 +30,9 @@ export const controlOperations: INodeProperties[] = [ ]; export const controlFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* control:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* control:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -47,15 +44,12 @@ export const controlFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'control', - ], - operation: [ - 'get', - ], + resource: ['control'], + operation: ['get'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Control ID', @@ -65,19 +59,15 @@ export const controlFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'control', - ], - operation: [ - 'get', - ], + resource: ['control'], + operation: ['get'], }, }, description: 'The control to get the row from', }, -/* -------------------------------------------------------------------------- */ -/* control:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* control:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -89,15 +79,12 @@ export const controlFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'control', - ], - operation: [ - 'getAll', - ], + resource: ['control'], + operation: ['getAll'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -105,12 +92,8 @@ export const controlFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'control', - ], - operation: [ - 'getAll', - ], + resource: ['control'], + operation: ['getAll'], }, }, default: false, @@ -122,15 +105,9 @@ export const controlFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'control', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['control'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Coda/FormulaDescription.ts b/packages/nodes-base/nodes/Coda/FormulaDescription.ts index 0ac601591b5be..114808793bbc8 100644 --- a/packages/nodes-base/nodes/Coda/FormulaDescription.ts +++ b/packages/nodes-base/nodes/Coda/FormulaDescription.ts @@ -8,9 +8,7 @@ export const formulaOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'formula', - ], + resource: ['formula'], }, }, options: [ @@ -32,10 +30,9 @@ export const formulaOperations: INodeProperties[] = [ ]; export const formulaFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* formula:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* formula:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -47,15 +44,12 @@ export const formulaFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'formula', - ], - operation: [ - 'get', - ], + resource: ['formula'], + operation: ['get'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Formula ID', @@ -65,19 +59,15 @@ export const formulaFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'formula', - ], - operation: [ - 'get', - ], + resource: ['formula'], + operation: ['get'], }, }, description: 'The formula to get the row from', }, -/* -------------------------------------------------------------------------- */ -/* formula:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* formula:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -89,15 +79,12 @@ export const formulaFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'formula', - ], - operation: [ - 'getAll', - ], + resource: ['formula'], + operation: ['getAll'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -105,12 +92,8 @@ export const formulaFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'formula', - ], - operation: [ - 'getAll', - ], + resource: ['formula'], + operation: ['getAll'], }, }, default: false, @@ -122,15 +105,9 @@ export const formulaFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'formula', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['formula'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Coda/GenericFunctions.ts b/packages/nodes-base/nodes/Coda/GenericFunctions.ts index d22a58116c5ba..f3c9e536e1966 100644 --- a/packages/nodes-base/nodes/Coda/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Coda/GenericFunctions.ts @@ -1,20 +1,26 @@ import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; -import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow'; - -export async function codaApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; + +export async function codaApiRequest( + 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('codaApi'); let options: OptionsWithUri = { - headers: { 'Authorization': `Bearer ${credentials.accessToken}`}, + headers: { Authorization: `Bearer ${credentials.accessToken}` }, method, qs, body, - uri: uri ||`https://coda.io/apis/v1${resource}`, + uri: uri || `https://coda.io/apis/v1${resource}`, json: true, }; options = Object.assign({}, options, option); @@ -33,8 +39,16 @@ export async function codaApiRequest(this: IExecuteFunctions | IExecuteSingleFun * Make an API request to paginated coda endpoint * and return all results */ -export async function codaApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function codaApiRequestAllItems( + this: 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; @@ -48,10 +62,7 @@ export async function codaApiRequestAllItems(this: IExecuteFunctions | ILoadOpti uri = responseData.nextPageLink; // @ts-ignore returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData.nextPageLink !== undefined && - responseData.nextPageLink !== '' - ); + } while (responseData.nextPageLink !== undefined && responseData.nextPageLink !== ''); return returnData; } diff --git a/packages/nodes-base/nodes/Coda/TableDescription.ts b/packages/nodes-base/nodes/Coda/TableDescription.ts index 6af2581a36552..7dec81a14d626 100644 --- a/packages/nodes-base/nodes/Coda/TableDescription.ts +++ b/packages/nodes-base/nodes/Coda/TableDescription.ts @@ -8,9 +8,7 @@ export const tableOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'table', - ], + resource: ['table'], }, }, options: [ @@ -61,10 +59,9 @@ export const tableOperations: INodeProperties[] = [ ]; export const tableFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* table:createRow */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* table:createRow */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -76,39 +73,31 @@ export const tableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'createRow', - ], + resource: ['table'], + operation: ['createRow'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Table Name or ID', name: 'tableId', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'docId', - ], + loadOptionsDependsOn: ['docId'], loadOptionsMethod: 'getTables', }, required: true, default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'createRow', - ], + resource: ['table'], + operation: ['createRow'], }, }, - description: 'The table to create the row in. Choose from the list, or specify an ID using an expression.', + description: + 'The table to create the row in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Options', @@ -118,12 +107,8 @@ export const tableFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'createRow', - ], + resource: ['table'], + operation: ['createRow'], }, }, options: [ @@ -139,13 +124,14 @@ export const tableFields: INodeProperties[] = [ name: 'keyColumns', type: 'string', default: '', - description: 'Optional column IDs, URLs, or names (fragile and discouraged), specifying columns to be used as upsert keys. If more than one separate by a comma (,).', + description: + 'Optional column IDs, URLs, or names (fragile and discouraged), specifying columns to be used as upsert keys. If more than one separate by a comma (,).', }, ], }, -/* -------------------------------------------------------------------------- */ -/* table:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* table:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -157,39 +143,31 @@ export const tableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getRow', - ], + resource: ['table'], + operation: ['getRow'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Table Name or ID', name: 'tableId', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'docId', - ], + loadOptionsDependsOn: ['docId'], loadOptionsMethod: 'getTables', }, required: true, default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getRow', - ], + resource: ['table'], + operation: ['getRow'], }, }, - description: 'The table to get the row from. Choose from the list, or specify an ID using an expression.', + description: + 'The table to get the row from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Row ID', @@ -199,15 +177,12 @@ export const tableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getRow', - ], + resource: ['table'], + operation: ['getRow'], }, }, - description: 'ID or name of the row. Names are discouraged because they\'re easily prone to being changed by users. If you\'re using a name, be sure to URI-encode it. If there are multiple rows with the same value in the identifying column, an arbitrary one will be selected', + description: + "ID or name of the row. Names are discouraged because they're easily prone to being changed by users. If you're using a name, be sure to URI-encode it. If there are multiple rows with the same value in the identifying column, an arbitrary one will be selected", }, { displayName: 'Options', @@ -217,12 +192,8 @@ export const tableFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getRow', - ], + resource: ['table'], + operation: ['getRow'], }, }, options: [ @@ -238,7 +209,8 @@ export const tableFields: INodeProperties[] = [ name: 'useColumnNames', type: 'boolean', default: false, - description: 'Whether to use column names instead of column IDs in the returned output. This is generally discouraged as it is fragile. If columns are renamed, code using original names may throw errors.', + description: + 'Whether to use column names instead of column IDs in the returned output. This is generally discouraged as it is fragile. If columns are renamed, code using original names may throw errors.', }, { displayName: 'ValueFormat', @@ -263,9 +235,9 @@ export const tableFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* table:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* table:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -277,39 +249,31 @@ export const tableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getAllRows', - ], + resource: ['table'], + operation: ['getAllRows'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Table Name or ID', name: 'tableId', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'docId', - ], + loadOptionsDependsOn: ['docId'], loadOptionsMethod: 'getTables', }, required: true, default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getAllRows', - ], + resource: ['table'], + operation: ['getAllRows'], }, }, - description: 'The table to get the rows from. Choose from the list, or specify an ID using an expression.', + description: + 'The table to get the rows from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -317,12 +281,8 @@ export const tableFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getAllRows', - ], + resource: ['table'], + operation: ['getAllRows'], }, }, default: false, @@ -334,15 +294,9 @@ export const tableFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getAllRows', - ], - returnAll: [ - false, - ], + resource: ['table'], + operation: ['getAllRows'], + returnAll: [false], }, }, typeOptions: { @@ -360,12 +314,8 @@ export const tableFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getAllRows', - ], + resource: ['table'], + operation: ['getAllRows'], }, }, options: [ @@ -377,7 +327,8 @@ export const tableFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'Query used to filter returned rows, specified as <column_id_or_name>:<value>. If you\'d like to use a column name instead of an ID, you must quote it (e.g., "My Column":123). Also note that value is a JSON value; if you\'d like to use a string, you must surround it in quotes (e.g., "groceries").', + description: + 'Query used to filter returned rows, specified as <column_id_or_name>:<value>. If you\'d like to use a column name instead of an ID, you must quote it (e.g., "My Column":123). Also note that value is a JSON value; if you\'d like to use a string, you must surround it in quotes (e.g., "groceries").', }, { displayName: 'RAW Data', @@ -401,14 +352,16 @@ export const tableFields: INodeProperties[] = [ value: 'natural', }, ], - description: 'Specifies the sort order of the rows returned. If left unspecified, rows are returned by creation time ascending.', + description: + 'Specifies the sort order of the rows returned. If left unspecified, rows are returned by creation time ascending.', }, { displayName: 'Use Column Names', name: 'useColumnNames', type: 'boolean', default: false, - description: 'Whether to use column names instead of column IDs in the returned output. This is generally discouraged as it is fragile. If columns are renamed, code using original names may throw errors.', + description: + 'Whether to use column names instead of column IDs in the returned output. This is generally discouraged as it is fragile. If columns are renamed, code using original names may throw errors.', }, { displayName: 'ValueFormat', @@ -440,9 +393,9 @@ export const tableFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* row:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* row:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -454,39 +407,31 @@ export const tableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'deleteRow', - ], + resource: ['table'], + operation: ['deleteRow'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Table Name or ID', name: 'tableId', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'docId', - ], + loadOptionsDependsOn: ['docId'], loadOptionsMethod: 'getTables', }, required: true, default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'deleteRow', - ], + resource: ['table'], + operation: ['deleteRow'], }, }, - description: 'The table to delete the row in. Choose from the list, or specify an ID using an expression.', + description: + 'The table to delete the row in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Row ID', @@ -496,19 +441,15 @@ export const tableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'deleteRow', - ], + resource: ['table'], + operation: ['deleteRow'], }, }, description: 'Row IDs to delete', }, -/* -------------------------------------------------------------------------- */ -/* table:pushButton */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* table:pushButton */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -520,39 +461,31 @@ export const tableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'pushButton', - ], + resource: ['table'], + operation: ['pushButton'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Table Name or ID', name: 'tableId', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'docId', - ], + loadOptionsDependsOn: ['docId'], loadOptionsMethod: 'getTables', }, required: true, default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'pushButton', - ], + resource: ['table'], + operation: ['pushButton'], }, }, - description: 'The table to get the row from. Choose from the list, or specify an ID using an expression.', + description: + 'The table to get the row from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Row ID', @@ -562,44 +495,35 @@ export const tableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'pushButton', - ], + resource: ['table'], + operation: ['pushButton'], }, }, - description: 'ID or name of the row. Names are discouraged because they\'re easily prone to being changed by users. If you\'re using a name, be sure to URI-encode it. If there are multiple rows with the same value in the identifying column, an arbitrary one will be selected', + description: + "ID or name of the row. Names are discouraged because they're easily prone to being changed by users. If you're using a name, be sure to URI-encode it. If there are multiple rows with the same value in the identifying column, an arbitrary one will be selected", }, { displayName: 'Column Name or ID', name: 'columnId', type: 'options', - 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: 'getColumns', - loadOptionsDependsOn: [ - 'docId', - 'tableId', - ], + loadOptionsDependsOn: ['docId', 'tableId'], }, default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'pushButton', - ], + resource: ['table'], + operation: ['pushButton'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* table:getColumn */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* table:getColumn */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -611,39 +535,31 @@ export const tableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getColumn', - ], + resource: ['table'], + operation: ['getColumn'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Table Name or ID', name: 'tableId', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'docId', - ], + loadOptionsDependsOn: ['docId'], loadOptionsMethod: 'getTables', }, required: true, default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getColumn', - ], + resource: ['table'], + operation: ['getColumn'], }, }, - description: 'The table to get the row from. Choose from the list, or specify an ID using an expression.', + description: + 'The table to get the row from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Column ID', @@ -653,19 +569,15 @@ export const tableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getColumn', - ], + resource: ['table'], + operation: ['getColumn'], }, }, description: 'The table to get the row from', }, -/* -------------------------------------------------------------------------- */ -/* table:getAllColumns */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* table:getAllColumns */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -677,39 +589,31 @@ export const tableFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getAllColumns', - ], + resource: ['table'], + operation: ['getAllColumns'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Table Name or ID', name: 'tableId', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'docId', - ], + loadOptionsDependsOn: ['docId'], loadOptionsMethod: 'getTables', }, required: true, default: '', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getAllColumns', - ], + resource: ['table'], + operation: ['getAllColumns'], }, }, - description: 'The table to get the row from. Choose from the list, or specify an ID using an expression.', + description: + 'The table to get the row from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -717,12 +621,8 @@ export const tableFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getAllColumns', - ], + resource: ['table'], + operation: ['getAllColumns'], }, }, default: false, @@ -734,15 +634,9 @@ export const tableFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'table', - ], - operation: [ - 'getAllColumns', - ], - returnAll: [ - false, - ], + resource: ['table'], + operation: ['getAllColumns'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Coda/ViewDescription.ts b/packages/nodes-base/nodes/Coda/ViewDescription.ts index 7d6931a2717e9..3ef939aae07f1 100644 --- a/packages/nodes-base/nodes/Coda/ViewDescription.ts +++ b/packages/nodes-base/nodes/Coda/ViewDescription.ts @@ -8,9 +8,7 @@ export const viewOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'view', - ], + resource: ['view'], }, }, options: [ @@ -61,10 +59,9 @@ export const viewOperations: INodeProperties[] = [ ]; export const viewFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* view:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* view:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -76,15 +73,12 @@ export const viewFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'get', - ], + resource: ['view'], + operation: ['get'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'View ID', @@ -94,19 +88,15 @@ export const viewFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'get', - ], + resource: ['view'], + operation: ['get'], }, }, description: 'The view to get the row from', }, -/* -------------------------------------------------------------------------- */ -/* view:getAll */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* view:getAll */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -118,15 +108,12 @@ export const viewFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'getAll', - ], + resource: ['view'], + operation: ['getAll'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -134,12 +121,8 @@ export const viewFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'getAll', - ], + resource: ['view'], + operation: ['getAll'], }, }, default: false, @@ -151,15 +134,9 @@ export const viewFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['view'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -169,9 +146,9 @@ export const viewFields: INodeProperties[] = [ default: 50, description: 'Max number of results to return', }, -/* -------------------------------------------------------------------------- */ -/* view:getAllViewRows */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* view:getAllViewRows */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -183,39 +160,31 @@ export const viewFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'getAllViewRows', - ], + resource: ['view'], + operation: ['getAllViewRows'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'View Name or ID', name: 'viewId', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'docId', - ], + loadOptionsDependsOn: ['docId'], loadOptionsMethod: 'getViews', }, required: true, default: '', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'getAllViewRows', - ], + resource: ['view'], + operation: ['getAllViewRows'], }, }, - description: 'The table to get the rows from. Choose from the list, or specify an ID using an expression.', + description: + 'The table to get the rows from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -223,12 +192,8 @@ export const viewFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'getAllViewRows', - ], + resource: ['view'], + operation: ['getAllViewRows'], }, }, default: false, @@ -240,15 +205,9 @@ export const viewFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'getAllViewRows', - ], - returnAll: [ - false, - ], + resource: ['view'], + operation: ['getAllViewRows'], + returnAll: [false], }, }, typeOptions: { @@ -266,12 +225,8 @@ export const viewFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'getAllViewRows', - ], + resource: ['view'], + operation: ['getAllViewRows'], }, }, options: [ @@ -283,14 +238,16 @@ export const viewFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'Query used to filter returned rows, specified as <column_id_or_name>:<value>. If you\'d like to use a column name instead of an ID, you must quote it (e.g., "My Column":123). Also note that value is a JSON value; if you\'d like to use a string, you must surround it in quotes (e.g., "groceries").', + description: + 'Query used to filter returned rows, specified as <column_id_or_name>:<value>. If you\'d like to use a column name instead of an ID, you must quote it (e.g., "My Column":123). Also note that value is a JSON value; if you\'d like to use a string, you must surround it in quotes (e.g., "groceries").', }, { displayName: 'Use Column Names', name: 'useColumnNames', type: 'boolean', default: false, - description: 'Whether to use column names instead of column IDs in the returned output. This is generally discouraged as it is fragile. If columns are renamed, code using original names may throw errors.', + description: + 'Whether to use column names instead of column IDs in the returned output. This is generally discouraged as it is fragile. If columns are renamed, code using original names may throw errors.', }, { displayName: 'ValueFormat', @@ -335,13 +292,14 @@ export const viewFields: INodeProperties[] = [ value: 'natural', }, ], - description: 'Specifies the sort order of the rows returned. If left unspecified, rows are returned by creation time ascending.', + description: + 'Specifies the sort order of the rows returned. If left unspecified, rows are returned by creation time ascending.', }, ], }, -/* -------------------------------------------------------------------------- */ -/* view:getAllViewColumns */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* view:getAllViewColumns */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -353,39 +311,31 @@ export const viewFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'getAllViewColumns', - ], + resource: ['view'], + operation: ['getAllViewColumns'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'View Name or ID', name: 'viewId', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'docId', - ], + loadOptionsDependsOn: ['docId'], loadOptionsMethod: 'getViews', }, required: true, default: '', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'getAllViewColumns', - ], + resource: ['view'], + operation: ['getAllViewColumns'], }, }, - description: 'The table to get the rows from. Choose from the list, or specify an ID using an expression.', + description: + 'The table to get the rows from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Return All', @@ -393,12 +343,8 @@ export const viewFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'getAllViewColumns', - ], + resource: ['view'], + operation: ['getAllViewColumns'], }, }, default: false, @@ -410,15 +356,9 @@ export const viewFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'getAllViewColumns', - ], - returnAll: [ - false, - ], + resource: ['view'], + operation: ['getAllViewColumns'], + returnAll: [false], }, }, typeOptions: { @@ -428,9 +368,9 @@ export const viewFields: INodeProperties[] = [ default: 50, description: 'Max number of results to return', }, -/* -------------------------------------------------------------------------- */ -/* view:deleteViewRow */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* view:deleteViewRow */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -442,15 +382,12 @@ export const viewFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'deleteViewRow', - ], + resource: ['view'], + operation: ['deleteViewRow'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'View Name or ID', @@ -460,21 +397,16 @@ export const viewFields: INodeProperties[] = [ default: '', typeOptions: { loadOptionsMethod: 'getViews', - loadOptionsDependsOn: [ - 'docId', - ], + loadOptionsDependsOn: ['docId'], }, displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'deleteViewRow', - ], + resource: ['view'], + operation: ['deleteViewRow'], }, }, - description: 'The view to get the row from. Choose from the list, or specify an ID using an expression.', + description: + 'The view to get the row from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Row Name or ID', @@ -484,25 +416,20 @@ export const viewFields: INodeProperties[] = [ default: '', typeOptions: { loadOptionsMethod: 'getViewRows', - loadOptionsDependsOn: [ - 'viewId', - ], + loadOptionsDependsOn: ['viewId'], }, displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'deleteViewRow', - ], + resource: ['view'], + operation: ['deleteViewRow'], }, }, - description: 'The view to get the row from. Choose from the list, or specify an ID using an expression.', + description: + 'The view to get the row from. Choose from the list, or specify an ID using an expression.', }, -/* -------------------------------------------------------------------------- */ -/* view:pushViewButton */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* view:pushViewButton */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -514,15 +441,12 @@ export const viewFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'pushViewButton', - ], + resource: ['view'], + operation: ['pushViewButton'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'View Name or ID', @@ -532,21 +456,16 @@ export const viewFields: INodeProperties[] = [ default: '', typeOptions: { loadOptionsMethod: 'getViews', - loadOptionsDependsOn: [ - 'docId', - ], + loadOptionsDependsOn: ['docId'], }, displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'pushViewButton', - ], + resource: ['view'], + operation: ['pushViewButton'], }, }, - description: 'The view to get the row from. Choose from the list, or specify an ID using an expression.', + description: + 'The view to get the row from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Row Name or ID', @@ -556,50 +475,39 @@ export const viewFields: INodeProperties[] = [ default: '', typeOptions: { loadOptionsMethod: 'getViewRows', - loadOptionsDependsOn: [ - 'viewId', - ], + loadOptionsDependsOn: ['viewId'], }, displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'pushViewButton', - ], + resource: ['view'], + operation: ['pushViewButton'], }, }, - description: 'The view to get the row from. Choose from the list, or specify an ID using an expression.', + description: + 'The view to get the row from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Column Name or ID', name: 'columnId', type: 'options', - 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: 'getViewColumns', - loadOptionsDependsOn: [ - 'docId', - 'viewId', - ], + loadOptionsDependsOn: ['docId', 'viewId'], }, default: '', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'pushViewButton', - ], + resource: ['view'], + operation: ['pushViewButton'], }, }, }, -/* -------------------------------------------------------------------------- */ -/* view:updateViewRow */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* view:updateViewRow */ + /* -------------------------------------------------------------------------- */ { displayName: 'Doc Name or ID', name: 'docId', @@ -611,15 +519,12 @@ export const viewFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'updateViewRow', - ], + resource: ['view'], + operation: ['updateViewRow'], }, }, - description: 'ID of the doc. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the doc. Choose from the list, or specify an ID using an expression.', }, { displayName: 'View Name or ID', @@ -629,21 +534,16 @@ export const viewFields: INodeProperties[] = [ default: '', typeOptions: { loadOptionsMethod: 'getViews', - loadOptionsDependsOn: [ - 'docId', - ], + loadOptionsDependsOn: ['docId'], }, displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'updateViewRow', - ], + resource: ['view'], + operation: ['updateViewRow'], }, }, - description: 'The view to get the row from. Choose from the list, or specify an ID using an expression.', + description: + 'The view to get the row from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Row Name or ID', @@ -653,21 +553,16 @@ export const viewFields: INodeProperties[] = [ default: '', typeOptions: { loadOptionsMethod: 'getViewRows', - loadOptionsDependsOn: [ - 'viewId', - ], + loadOptionsDependsOn: ['viewId'], }, displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'updateViewRow', - ], + resource: ['view'], + operation: ['updateViewRow'], }, }, - description: 'The view to get the row from. Choose from the list, or specify an ID using an expression.', + description: + 'The view to get the row from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Key Name', @@ -677,12 +572,8 @@ export const viewFields: INodeProperties[] = [ default: 'columns', displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'updateViewRow', - ], + resource: ['view'], + operation: ['updateViewRow'], }, }, description: 'The view to get the row from', @@ -695,12 +586,8 @@ export const viewFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'view', - ], - operation: [ - 'updateViewRow', - ], + resource: ['view'], + operation: ['updateViewRow'], }, }, options: [ diff --git a/packages/nodes-base/nodes/CoinGecko/CoinDescription.ts b/packages/nodes-base/nodes/CoinGecko/CoinDescription.ts index a78d78c6dec6f..6a7b73e844730 100644 --- a/packages/nodes-base/nodes/CoinGecko/CoinDescription.ts +++ b/packages/nodes-base/nodes/CoinGecko/CoinDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const coinOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const coinOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'coin', - ], + resource: ['coin'], }, }, options: [ @@ -43,19 +39,22 @@ export const coinOperations: INodeProperties[] = [ { name: 'Market', value: 'market', - description: 'Get prices and market related data for all trading pairs that match the selected currency', + description: + 'Get prices and market related data for all trading pairs that match the selected currency', action: 'Get market prices for a coin', }, { name: 'Market Chart', value: 'marketChart', - description: 'Get historical market data include price, market cap, and 24h volume (granularity auto)', + description: + 'Get historical market data include price, market cap, and 24h volume (granularity auto)', action: 'Get market chart for a coin', }, { name: 'Price', value: 'price', - description: 'Get the current price of any cryptocurrencies in any other supported currencies that you need', + description: + 'Get the current price of any cryptocurrencies in any other supported currencies that you need', action: 'Get the price for a coin', }, { @@ -87,14 +86,8 @@ export const coinFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'get', - 'marketChart', - 'price', - ], - resource: [ - 'coin', - ], + operation: ['get', 'marketChart', 'price'], + resource: ['coin'], }, }, default: 'coinId', @@ -105,18 +98,15 @@ export const coinFields: INodeProperties[] = [ name: 'coinId', 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: 'getCoins', }, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'coin', - ], + operation: ['get'], + resource: ['coin'], }, }, default: '', @@ -132,17 +122,13 @@ export const coinFields: INodeProperties[] = [ }, displayOptions: { show: { - - operation: [ - 'candlestick', - ], - resource: [ - 'coin', - ], + operation: ['candlestick'], + resource: ['coin'], }, }, default: '', - description: 'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify an ID using an expression.', + description: + 'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Base Currency Name or ID', @@ -154,36 +140,28 @@ export const coinFields: INodeProperties[] = [ }, displayOptions: { show: { - - operation: [ - 'market', - ], - resource: [ - 'coin', - ], + operation: ['market'], + resource: ['coin'], }, }, default: '', - description: 'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify an ID using an expression.', + description: + 'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Coin Name or ID', name: 'coinId', 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: 'getCoins', }, displayOptions: { show: { - operation: [ - 'ticker', - 'history', - ], - resource: [ - 'coin', - ], + operation: ['ticker', 'history'], + resource: ['coin'], }, }, default: '', @@ -199,20 +177,15 @@ export const coinFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'price', - ], - resource: [ - 'coin', - ], - searchBy: [ - 'coinId', - ], + operation: ['price'], + resource: ['coin'], + searchBy: ['coinId'], }, }, default: [], placeholder: 'bitcoin', - description: 'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify IDs using an expression.', + description: + 'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Platform ID', @@ -220,17 +193,9 @@ export const coinFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'get', - 'marketChart', - 'price', - ], - resource: [ - 'coin', - ], - searchBy: [ - 'contractAddress', - ], + operation: ['get', 'marketChart', 'price'], + resource: ['coin'], + searchBy: ['contractAddress'], }, }, type: 'options', @@ -251,19 +216,12 @@ export const coinFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'get', - 'marketChart', - ], - resource: [ - 'coin', - ], - searchBy: [ - 'contractAddress', - ], + operation: ['get', 'marketChart'], + resource: ['coin'], + searchBy: ['contractAddress'], }, }, - description: 'Token\'s contract address', + description: "Token's contract address", }, { displayName: 'Contract Addresses', @@ -273,15 +231,9 @@ export const coinFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'price', - ], - resource: [ - 'coin', - ], - searchBy: [ - 'contractAddress', - ], + operation: ['price'], + resource: ['coin'], + searchBy: ['contractAddress'], }, }, description: 'The contract address of tokens, comma-separated', @@ -296,24 +248,17 @@ export const coinFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'marketChart', - ], - resource: [ - 'coin', - ], - searchBy: [ - 'coinId', - ], + operation: ['marketChart'], + resource: ['coin'], + searchBy: ['coinId'], }, hide: { - searchBy: [ - 'contractAddress', - ], + searchBy: ['contractAddress'], }, }, default: '', - description: 'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify an ID using an expression.', + description: + 'The first currency in the pair. For BTC:ETH this is BTC. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Quote Currency Name or ID', @@ -325,17 +270,13 @@ export const coinFields: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'candlestick', - 'marketChart', - ], - resource: [ - 'coin', - ], + operation: ['candlestick', 'marketChart'], + resource: ['coin'], }, }, default: '', - description: 'The second currency in the pair. For BTC:ETH this is ETH. Choose from the list, or specify an ID using an expression.', + description: + 'The second currency in the pair. For BTC:ETH this is ETH. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Quote Currency Names or IDs', @@ -347,16 +288,13 @@ export const coinFields: INodeProperties[] = [ required: true, displayOptions: { show: { - operation: [ - 'price', - ], - resource: [ - 'coin', - ], + operation: ['price'], + resource: ['coin'], }, }, default: [], - description: 'The second currency in the pair. For BTC:ETH this is ETH. Choose from the list, or specify IDs using an expression.', + description: + 'The second currency in the pair. For BTC:ETH this is ETH. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Range (Days)', @@ -400,13 +338,8 @@ export const coinFields: INodeProperties[] = [ ], displayOptions: { show: { - operation: [ - 'marketChart', - 'candlestick', - ], - resource: [ - 'coin', - ], + operation: ['marketChart', 'candlestick'], + resource: ['coin'], }, }, default: '', @@ -419,12 +352,8 @@ export const coinFields: INodeProperties[] = [ type: 'dateTime', displayOptions: { show: { - operation: [ - 'history', - ], - resource: [ - 'coin', - ], + operation: ['history'], + resource: ['coin'], }, }, default: '', @@ -436,14 +365,8 @@ export const coinFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - 'market', - 'ticker', - ], - resource: [ - 'coin', - ], + operation: ['getAll', 'market', 'ticker'], + resource: ['coin'], }, }, default: false, @@ -455,17 +378,9 @@ export const coinFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - 'market', - 'ticker', - ], - resource: [ - 'coin', - ], - returnAll: [ - false, - ], + operation: ['getAll', 'market', 'ticker'], + resource: ['coin'], + returnAll: [false], }, }, typeOptions: { @@ -483,12 +398,8 @@ export const coinFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'coin', - ], - operation: [ - 'market', - ], + resource: ['coin'], + operation: ['market'], }, }, options: [ @@ -609,12 +520,8 @@ export const coinFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'coin', - ], - operation: [ - 'price', - ], + resource: ['coin'], + operation: ['price'], }, }, options: [ @@ -652,12 +559,8 @@ export const coinFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'coin', - ], - operation: [ - 'ticker', - ], + resource: ['coin'], + operation: ['ticker'], }, }, options: [ @@ -669,7 +572,8 @@ export const coinFields: INodeProperties[] = [ loadOptionsMethod: 'getExchanges', }, default: [], - description: 'Filter results by exchange IDs. Choose from the list, or specify IDs using an expression.', + description: + 'Filter results by exchange IDs. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Include Exchange Logo', @@ -708,12 +612,8 @@ export const coinFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'coin', - ], - operation: [ - 'history', - ], + resource: ['coin'], + operation: ['history'], }, }, options: [ @@ -734,12 +634,8 @@ export const coinFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'coin', - ], + operation: ['get'], + resource: ['coin'], }, }, options: [ diff --git a/packages/nodes-base/nodes/CoinGecko/CoinGecko.node.ts b/packages/nodes-base/nodes/CoinGecko/CoinGecko.node.ts index 27e3235e7c7d4..2789ef3997e7f 100644 --- a/packages/nodes-base/nodes/CoinGecko/CoinGecko.node.ts +++ b/packages/nodes-base/nodes/CoinGecko/CoinGecko.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 { - coinFields, - coinOperations, -} from './CoinDescription'; +import { coinFields, coinOperations } from './CoinDescription'; -import { - eventFields, - eventOperations, -} from './EventDescription'; +import { eventFields, eventOperations } from './EventDescription'; -import { - coinGeckoApiRequest, - coinGeckoRequestAllItems, -} from './GenericFunctions'; +import { coinGeckoApiRequest, coinGeckoRequestAllItems } from './GenericFunctions'; import moment from 'moment-timezone'; @@ -88,11 +77,7 @@ export class CoinGecko implements INodeType { async getCoins(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const coins = await coinGeckoApiRequest.call( - this, - 'GET', - '/coins/list', - ); + const coins = await coinGeckoApiRequest.call(this, 'GET', '/coins/list'); for (const coin of coins) { returnData.push({ name: coin.symbol.toUpperCase(), @@ -100,8 +85,12 @@ export class CoinGecko 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; @@ -109,11 +98,7 @@ export class CoinGecko implements INodeType { async getExchanges(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const exchanges = await coinGeckoApiRequest.call( - this, - 'GET', - '/exchanges/list', - ); + const exchanges = await coinGeckoApiRequest.call(this, 'GET', '/exchanges/list'); for (const exchange of exchanges) { returnData.push({ name: exchange.name, @@ -125,11 +110,7 @@ export class CoinGecko implements INodeType { async getEventCountryCodes(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const countryCodes = await coinGeckoApiRequest.call( - this, - 'GET', - '/events/countries', - ); + const countryCodes = await coinGeckoApiRequest.call(this, 'GET', '/events/countries'); for (const code of countryCodes.data) { if (!code.code) { continue; @@ -144,11 +125,7 @@ export class CoinGecko implements INodeType { async getEventTypes(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const eventTypes = await coinGeckoApiRequest.call( - this, - 'GET', - '/events/types', - ); + const eventTypes = await coinGeckoApiRequest.call(this, 'GET', '/events/types'); for (const type of eventTypes.data) { returnData.push({ name: type, @@ -174,7 +151,6 @@ export class CoinGecko implements INodeType { //https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id_ //https://www.coingecko.com/api/documentations/v3#/contract/get_coins__id__contract__contract_address_ if (operation === 'get') { - const options = this.getNodeParameter('options', i) as IDataObject; qs.community_data = false; @@ -215,18 +191,11 @@ export class CoinGecko implements INodeType { } //https://www.coingecko.com/api/documentations/v3#/coins/get_coins_list if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; let limit; - responseData = await coinGeckoApiRequest.call( - this, - 'GET', - '/coins/list', - {}, - qs, - ); + responseData = await coinGeckoApiRequest.call(this, 'GET', '/coins/list', {}, qs); if (returnAll === false) { limit = this.getNodeParameter('limit', i) as number; @@ -236,7 +205,6 @@ export class CoinGecko implements INodeType { //https://www.coingecko.com/api/documentations/v3#/coins/get_coins_list if (operation === 'market') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; const baseCurrency = this.getNodeParameter('baseCurrency', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; @@ -263,20 +231,13 @@ export class CoinGecko implements INodeType { qs.per_page = limit; - responseData = await coinGeckoApiRequest.call( - this, - 'GET', - `/coins/markets`, - {}, - qs, - ); + responseData = await coinGeckoApiRequest.call(this, 'GET', `/coins/markets`, {}, qs); } } //https://www.coingecko.com/api/documentations/v3#/simple/get_simple_price //https://www.coingecko.com/api/documentations/v3#/simple/get_simple_token_price__id_ if (operation === 'price') { - const searchBy = this.getNodeParameter('searchBy', i) as string; const quoteCurrencies = this.getNodeParameter('quoteCurrencies', i) as string[]; const options = this.getNodeParameter('options', i) as IDataObject; @@ -290,13 +251,7 @@ export class CoinGecko implements INodeType { qs.ids = baseCurrencies.join(','); - responseData = await coinGeckoApiRequest.call( - this, - 'GET', - '/simple/price', - {}, - qs, - ); + responseData = await coinGeckoApiRequest.call(this, 'GET', '/simple/price', {}, qs); } if (searchBy === 'contractAddress') { @@ -317,7 +272,6 @@ export class CoinGecko implements INodeType { //https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__tickers if (operation === 'ticker') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; const coinId = this.getNodeParameter('coinId', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; @@ -329,7 +283,6 @@ export class CoinGecko implements INodeType { } if (returnAll) { - responseData = await coinGeckoRequestAllItems.call( this, 'tickers', @@ -356,7 +309,6 @@ export class CoinGecko implements INodeType { //https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__history if (operation === 'history') { - const coinId = this.getNodeParameter('coinId', i) as string; const date = this.getNodeParameter('date', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; @@ -377,7 +329,6 @@ export class CoinGecko implements INodeType { //https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__market_chart //https://www.coingecko.com/api/documentations/v3#/contract/get_coins__id__contract__contract_address__market_chart_ if (operation === 'marketChart') { - let respData; const searchBy = this.getNodeParameter('searchBy', i) as string; @@ -417,13 +368,17 @@ export class CoinGecko implements INodeType { const [time, price] = respData.prices[idx]; const marketCaps = respData.market_caps[idx][1]; const totalVolume = respData.total_volumes[idx][1]; - responseData.push({ time: moment(time).toISOString(), price, marketCaps, totalVolume } as IDataObject); + responseData.push({ + time: moment(time).toISOString(), + price, + marketCaps, + totalVolume, + } as IDataObject); } } //https://www.coingecko.com/api/documentations/v3#/coins/get_coins__id__ohlc if (operation === 'candlestick') { - const baseCurrency = this.getNodeParameter('baseCurrency', i) as string; const quoteCurrency = this.getNodeParameter('quoteCurrency', i) as string; const days = this.getNodeParameter('days', i) as string; @@ -441,7 +396,13 @@ export class CoinGecko implements INodeType { for (let idx = 0; idx < responseData.length; idx++) { const [time, open, high, low, close] = responseData[idx]; - responseData[idx] = { time: moment(time).toISOString(), open, high, low, close } as IDataObject; + responseData[idx] = { + time: moment(time).toISOString(), + open, + high, + low, + close, + } as IDataObject; } } } @@ -449,7 +410,6 @@ export class CoinGecko implements INodeType { if (resource === 'event') { //https://www.coingecko.com/api/documentations/v3#/events/get_events if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; const options = this.getNodeParameter('options', i) as IDataObject; @@ -469,13 +429,7 @@ export class CoinGecko implements INodeType { qs.per_page = limit; - responseData = await coinGeckoApiRequest.call( - this, - 'GET', - '/events', - {}, - qs, - ); + responseData = await coinGeckoApiRequest.call(this, 'GET', '/events', {}, qs); responseData = responseData.data; } } @@ -484,28 +438,19 @@ export class CoinGecko implements INodeType { if (resource === 'simple') { //https://www.coingecko.com/api/documentations/v3#/simple/get_simple_price if (operation === 'price') { - const ids = this.getNodeParameter('ids', i) as string; const currencies = this.getNodeParameter('currencies', i) as string[]; const options = this.getNodeParameter('options', i) as IDataObject; - qs.ids = ids, - qs.vs_currencies = currencies.join(','); + (qs.ids = ids), (qs.vs_currencies = currencies.join(',')); Object.assign(qs, options); - responseData = await coinGeckoApiRequest.call( - this, - 'GET', - '/simple/price', - {}, - qs, - ); + responseData = await coinGeckoApiRequest.call(this, 'GET', '/simple/price', {}, qs); } //https://www.coingecko.com/api/documentations/v3#/simple/get_simple_token_price__id_ if (operation === 'tokenPrice') { - const id = this.getNodeParameter('id', i) as string; const contractAddresses = this.getNodeParameter('contractAddresses', i) as string; const currencies = this.getNodeParameter('currencies', i) as string[]; diff --git a/packages/nodes-base/nodes/CoinGecko/EventDescription.ts b/packages/nodes-base/nodes/CoinGecko/EventDescription.ts index 2bb62eca535c0..122cdae22c366 100644 --- a/packages/nodes-base/nodes/CoinGecko/EventDescription.ts +++ b/packages/nodes-base/nodes/CoinGecko/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,12 +30,8 @@ export const eventFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'event', - ], + operation: ['getAll'], + resource: ['event'], }, }, default: false, @@ -51,15 +43,9 @@ export const eventFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'event', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['event'], + returnAll: [false], }, }, typeOptions: { @@ -77,12 +63,8 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'event', - ], + operation: ['getAll'], + resource: ['event'], }, }, options: [ @@ -95,7 +77,8 @@ export const eventFields: INodeProperties[] = [ loadOptionsMethod: 'getEventCountryCodes', }, default: '', - description: 'Country code of event. Choose from the list, or specify an ID using an expression.', + description: + 'Country code of event. Choose from the list, or specify an ID using an expression.', }, { displayName: 'From Date', @@ -119,7 +102,8 @@ export const eventFields: INodeProperties[] = [ loadOptionsMethod: 'getEventTypes', }, default: '', - description: 'Type of event. Choose from the list, or specify an ID using an expression.', + description: + 'Type of event. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Upcoming Events Only', diff --git a/packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts b/packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts index 73c35b56eb8a8..d34c41d0da87d 100644 --- a/packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts +++ b/packages/nodes-base/nodes/CoinGecko/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 coinGeckoApiRequest(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 coinGeckoApiRequest( + 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, @@ -35,14 +36,21 @@ export async function coinGeckoApiRequest(this: IExecuteFunctions | IExecuteSing //@ts-ignore return await this.helpers.request.call(this, options); - } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function coinGeckoRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function coinGeckoRequestAllItems( + 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; @@ -58,9 +66,7 @@ export async function coinGeckoRequestAllItems(this: IExecuteFunctions | ILoadOp respData = responseData[propertyName]; } returnData.push.apply(returnData, respData); - } while ( - respData.length !== 0 - ); + } while (respData.length !== 0); return returnData; } diff --git a/packages/nodes-base/nodes/Compression/Compression.node.ts b/packages/nodes-base/nodes/Compression/Compression.node.ts index af14c7147a3f5..f863a7017215e 100644 --- a/packages/nodes-base/nodes/Compression/Compression.node.ts +++ b/packages/nodes-base/nodes/Compression/Compression.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IBinaryKeyData, @@ -89,15 +87,12 @@ export class Compression implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'compress', - 'decompress', - ], + operation: ['compress', 'decompress'], }, - }, placeholder: '', - description: 'Name of the binary property which contains the data for the file(s) to be compress/decompress. Multiple can be used separated by a comma (,).', + description: + 'Name of the binary property which contains the data for the file(s) to be compress/decompress. Multiple can be used separated by a comma (,).', }, { displayName: 'Output Format', @@ -116,9 +111,7 @@ export class Compression implements INodeType { ], displayOptions: { show: { - operation: [ - 'compress', - ], + operation: ['compress'], }, }, description: 'Format of the output file', @@ -132,14 +125,9 @@ export class Compression implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'compress', - ], - outputFormat: [ - 'zip', - ], + operation: ['compress'], + outputFormat: ['zip'], }, - }, description: 'Name of the file to be compressed', }, @@ -150,16 +138,13 @@ export class Compression implements INodeType { default: 'data', displayOptions: { show: { - outputFormat: [ - 'zip', - ], - operation: [ - 'compress', - ], + outputFormat: ['zip'], + operation: ['compress'], }, }, placeholder: '', - description: 'Name of the binary property to which to write the data of the compressed files', + description: + 'Name of the binary property to which to write the data of the compressed files', }, { displayName: 'Output Prefix', @@ -169,12 +154,8 @@ export class Compression implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'compress', - ], - outputFormat: [ - 'gzip', - ], + operation: ['compress'], + outputFormat: ['gzip'], }, }, description: 'Prefix use for all gzip compresed files', @@ -187,9 +168,7 @@ export class Compression implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'decompress', - ], + operation: ['decompress'], }, }, description: 'Prefix use for all decompressed files', @@ -205,9 +184,10 @@ export class Compression implements INodeType { for (let i = 0; i < length; i++) { try { - if (operation === 'decompress') { - const binaryPropertyNames = (this.getNodeParameter('binaryPropertyName', 0) as string).split(',').map(key => key.trim()); + const binaryPropertyNames = (this.getNodeParameter('binaryPropertyName', 0) as string) + .split(',') + .map((key) => key.trim()); const outputPrefix = this.getNodeParameter('outputPrefix', 0) as string; @@ -217,11 +197,17 @@ export class Compression implements INodeType { for (const [index, binaryPropertyName] of binaryPropertyNames.entries()) { 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]; @@ -236,7 +222,10 @@ export class Compression implements INodeType { continue; } - const data = await this.helpers.prepareBinaryData(Buffer.from(files[key].buffer), key); + const data = await this.helpers.prepareBinaryData( + Buffer.from(files[key].buffer), + key, + ); binaryObject[`${outputPrefix}${zipIndex++}`] = data; } @@ -247,7 +236,10 @@ export class Compression implements INodeType { const propertyName = `${outputPrefix}${index}`; - binaryObject[propertyName] = await this.helpers.prepareBinaryData(Buffer.from(file.buffer), fileName); + binaryObject[propertyName] = await this.helpers.prepareBinaryData( + Buffer.from(file.buffer), + fileName, + ); const fileExtension = mime.extension(binaryObject[propertyName].mimeType) as string; binaryObject[propertyName].fileName = `${fileName}.${fileExtension}`; binaryObject[propertyName].fileExtension = fileExtension; @@ -264,7 +256,9 @@ export class Compression implements INodeType { } if (operation === 'compress') { - const binaryPropertyNames = (this.getNodeParameter('binaryPropertyName', 0) as string).split(',').map(key => key.trim()); + const binaryPropertyNames = (this.getNodeParameter('binaryPropertyName', 0) as string) + .split(',') + .map((key) => key.trim()); const outputFormat = this.getNodeParameter('outputFormat', 0) as string; @@ -273,13 +267,18 @@ export class Compression implements INodeType { const binaryObject: IBinaryKeyData = {}; for (const [index, binaryPropertyName] of binaryPropertyNames.entries()) { - 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]; @@ -287,19 +286,22 @@ export class Compression implements INodeType { if (outputFormat === 'zip') { zipData[binaryData.fileName as string] = [ - binaryDataBuffer, { + binaryDataBuffer, + { level: ALREADY_COMPRESSED.includes(binaryData.fileExtension as string) ? 0 : 6, }, ]; - } else if (outputFormat === 'gzip') { const outputPrefix = this.getNodeParameter('outputPrefix', 0) as string; - const data = await gzip(binaryDataBuffer) as Uint8Array; + const data = (await gzip(binaryDataBuffer)) as Uint8Array; const fileName = binaryData.fileName?.split('.')[0]; - binaryObject[`${outputPrefix}${index}`] = await this.helpers.prepareBinaryData(Buffer.from(data), `${fileName}.gzip`); + binaryObject[`${outputPrefix}${index}`] = await this.helpers.prepareBinaryData( + Buffer.from(data), + `${fileName}.gzip`, + ); } } @@ -333,7 +335,6 @@ export class Compression implements INodeType { }); } } - } catch (error) { if (this.continueOnFail()) { returnData.push({ diff --git a/packages/nodes-base/nodes/Contentful/AssetDescription.ts b/packages/nodes-base/nodes/Contentful/AssetDescription.ts index 503892917f8a7..69e08954ba1b9 100644 --- a/packages/nodes-base/nodes/Contentful/AssetDescription.ts +++ b/packages/nodes-base/nodes/Contentful/AssetDescription.ts @@ -1,7 +1,4 @@ -import { - INodeProperties, - INodePropertyOptions, -} from 'n8n-workflow'; +import { INodeProperties, INodePropertyOptions } from 'n8n-workflow'; export const resource = { name: 'Asset', @@ -16,9 +13,7 @@ export const operations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - resource.value, - ], + resource: [resource.value], }, }, options: [ @@ -42,17 +37,13 @@ export const fields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - resource.value, - ], - operation: [ - 'get', - 'getAll', - ], + resource: [resource.value], + operation: ['get', 'getAll'], }, }, default: 'master', - description: 'The ID for the Contentful environment (e.g. master, staging, etc.). Depending on your plan, you might not have environments. In that case use "master".', + description: + 'The ID for the Contentful environment (e.g. master, staging, etc.). Depending on your plan, you might not have environments. In that case use "master".', }, { displayName: 'Return All', @@ -60,12 +51,8 @@ export const fields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - resource.value, - ], + operation: ['getAll'], + resource: [resource.value], }, }, default: false, @@ -77,15 +64,9 @@ export const fields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - resource.value, - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: [resource.value], + returnAll: [false], }, }, typeOptions: { @@ -103,12 +84,8 @@ export const fields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - resource.value, - ], - operation: [ - 'get', - ], + resource: [resource.value], + operation: ['get'], }, }, }, @@ -120,12 +97,8 @@ export const fields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - resource.value, - ], - operation: [ - 'getAll', - ], + resource: [resource.value], + operation: ['getAll'], }, }, options: [ @@ -135,7 +108,8 @@ export const fields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'fields.title=n8n', - description: 'Search for all data that matches the condition: {attribute}={value}. Attribute can use dot notation.', + description: + 'Search for all data that matches the condition: {attribute}={value}. Attribute can use dot notation.', }, { displayName: 'Exclude', @@ -143,7 +117,8 @@ export const fields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'fields.tags[nin]=accessories,flowers', - description: 'Search for all data that matches the condition: {attribute}[nin]={value}. Attribute can use dot notation.', + description: + 'Search for all data that matches the condition: {attribute}[nin]={value}. Attribute can use dot notation.', }, { displayName: 'Exist', @@ -151,7 +126,8 @@ export const fields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'fields.tags[exists]=true', - description: 'Search for all data that matches the condition: {attribute}[exists]={value}. Attribute can use dot notation.', + description: + 'Search for all data that matches the condition: {attribute}[exists]={value}. Attribute can use dot notation.', }, { displayName: 'Fields', @@ -159,7 +135,8 @@ export const fields: INodeProperties[] = [ type: 'string', placeholder: 'fields.title', default: '', - description: 'The select operator allows you to choose what fields to return from an entity. You can choose multiple values by combining comma-separated operators.', + description: + 'The select operator allows you to choose what fields to return from an entity. You can choose multiple values by combining comma-separated operators.', }, { displayName: 'Include', @@ -167,7 +144,8 @@ export const fields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'fields.tags[in]=accessories,flowers', - description: 'Search for all data that matches the condition: {attribute}[in]={value}. Attribute can use dot notation.', + description: + 'Search for all data that matches the condition: {attribute}[in]={value}. Attribute can use dot notation.', }, { displayName: 'Not Equal', @@ -175,7 +153,8 @@ export const fields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'fields.title[ne]=n8n', - description: 'Search for all data that matches the condition: {attribute}[ne]={value}. Attribute can use dot notation.', + description: + 'Search for all data that matches the condition: {attribute}[ne]={value}. Attribute can use dot notation.', }, { displayName: 'Order', @@ -183,14 +162,16 @@ export const fields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'sys.createdAt', - description: 'You can order items in the response by specifying the order search parameter. You can use sys properties (such as sys.createdAt) or field values (such as fields.myCustomDateField) for ordering.', + description: + 'You can order items in the response by specifying the order search parameter. You can use sys properties (such as sys.createdAt) or field values (such as fields.myCustomDateField) for ordering.', }, { displayName: 'Query', name: 'query', type: 'string', default: '', - description: 'Full-text search is case insensitive and might return more results than expected. A query will only take values with more than 1 character.', + description: + 'Full-text search is case insensitive and might return more results than expected. A query will only take values with more than 1 character.', }, { displayName: 'RAW Data', diff --git a/packages/nodes-base/nodes/Contentful/ContentTypeDescription.ts b/packages/nodes-base/nodes/Contentful/ContentTypeDescription.ts index 3d90aa1959ece..29ac419d5009c 100644 --- a/packages/nodes-base/nodes/Contentful/ContentTypeDescription.ts +++ b/packages/nodes-base/nodes/Contentful/ContentTypeDescription.ts @@ -1,7 +1,4 @@ -import { - INodeProperties, - INodePropertyOptions, -} from 'n8n-workflow'; +import { INodeProperties, INodePropertyOptions } from 'n8n-workflow'; export const resource = { name: 'Content Type', @@ -16,9 +13,7 @@ export const operations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - resource.value, - ], + resource: [resource.value], }, }, options: [ @@ -38,16 +33,13 @@ export const fields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - resource.value, - ], - operation: [ - 'get', - ], + resource: [resource.value], + operation: ['get'], }, }, default: 'master', - description: 'The ID for the Contentful environment (e.g. master, staging, etc.). Depending on your plan, you might not have environments. In that case use "master".', + description: + 'The ID for the Contentful environment (e.g. master, staging, etc.). Depending on your plan, you might not have environments. In that case use "master".', }, { displayName: 'Content Type ID', @@ -57,12 +49,8 @@ export const fields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - resource.value, - ], - operation: [ - 'get', - ], + resource: [resource.value], + operation: ['get'], }, }, }, @@ -74,12 +62,8 @@ export const fields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - resource.value, - ], - operation: [ - 'get', - ], + resource: [resource.value], + operation: ['get'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Contentful/Contentful.node.ts b/packages/nodes-base/nodes/Contentful/Contentful.node.ts index f051b7331ba17..aa9e423492a97 100644 --- a/packages/nodes-base/nodes/Contentful/Contentful.node.ts +++ b/packages/nodes-base/nodes/Contentful/Contentful.node.ts @@ -1,18 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; - -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; - -import { - contenfulApiRequestAllItems, - contentfulApiRequest, -} from './GenericFunctions'; +import { IExecuteFunctions } from 'n8n-core'; + +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; + +import { contenfulApiRequestAllItems, contentfulApiRequest } from './GenericFunctions'; import * as SpaceDescription from './SpaceDescription'; import * as ContentTypeDescription from './ContentTypeDescription'; @@ -104,15 +94,17 @@ export class Contentful implements INodeType { try { if (resource === 'space') { if (operation === 'get') { - const credentials = await this.getCredentials('contentfulApi'); - responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}`); + responseData = await contentfulApiRequest.call( + this, + 'GET', + `/spaces/${credentials?.spaceId}`, + ); } } if (resource === 'contentType') { if (operation === 'get') { - const credentials = await this.getCredentials('contentfulApi'); const env = this.getNodeParameter('environmentId', 0) as string; @@ -121,7 +113,11 @@ export class Contentful implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/content_types/${id}`); + responseData = await contentfulApiRequest.call( + this, + 'GET', + `/spaces/${credentials?.spaceId}/environments/${env}/content_types/${id}`, + ); if (!additionalFields.rawData) { responseData = responseData.fields; @@ -129,9 +125,7 @@ export class Contentful implements INodeType { } } if (resource === 'entry') { - if (operation === 'get') { - const credentials = await this.getCredentials('contentfulApi'); const env = this.getNodeParameter('environmentId', 0) as string; @@ -140,12 +134,17 @@ export class Contentful implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/entries/${id}`, {}, qs); + responseData = await contentfulApiRequest.call( + this, + 'GET', + `/spaces/${credentials?.spaceId}/environments/${env}/entries/${id}`, + {}, + qs, + ); if (!additionalFields.rawData) { responseData = responseData.fields; } - } else if (operation === 'getAll') { const credentials = await this.getCredentials('contentfulApi'); @@ -184,12 +183,19 @@ export class Contentful implements INodeType { } if (returnAll) { - responseData = await contenfulApiRequestAllItems.call(this, 'items', 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/entries`, {}, qs); + responseData = await contenfulApiRequestAllItems.call( + this, + 'items', + 'GET', + `/spaces/${credentials?.spaceId}/environments/${env}/entries`, + {}, + qs, + ); if (!rawData) { - const assets : IDataObject[] = []; + const assets: IDataObject[] = []; // tslint:disable-next-line: no-any - responseData.map((asset : any) => { + responseData.map((asset: any) => { assets.push(asset.fields); }); responseData = assets; @@ -197,13 +203,19 @@ export class Contentful implements INodeType { } else { const limit = this.getNodeParameter('limit', 0) as number; qs.limit = limit; - responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/entries`, {}, qs); + responseData = await contentfulApiRequest.call( + this, + 'GET', + `/spaces/${credentials?.spaceId}/environments/${env}/entries`, + {}, + qs, + ); responseData = responseData.items; if (!rawData) { - const assets : IDataObject[] = []; + const assets: IDataObject[] = []; // tslint:disable-next-line: no-any - responseData.map((asset : any) => { + responseData.map((asset: any) => { assets.push(asset.fields); }); responseData = assets; @@ -213,7 +225,6 @@ export class Contentful implements INodeType { } if (resource === 'asset') { if (operation === 'get') { - const credentials = await this.getCredentials('contentfulApi'); const env = this.getNodeParameter('environmentId', 0) as string; @@ -222,14 +233,18 @@ export class Contentful implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; - responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/assets/${id}`, {}, qs); + responseData = await contentfulApiRequest.call( + this, + 'GET', + `/spaces/${credentials?.spaceId}/environments/${env}/assets/${id}`, + {}, + qs, + ); if (!additionalFields.rawData) { responseData = responseData.fields; } - } else if (operation === 'getAll') { - const credentials = await this.getCredentials('contentfulApi'); const returnAll = this.getNodeParameter('returnAll', 0) as boolean; @@ -267,12 +282,19 @@ export class Contentful implements INodeType { } if (returnAll) { - responseData = await contenfulApiRequestAllItems.call(this, 'items', 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/assets`, {}, qs); + responseData = await contenfulApiRequestAllItems.call( + this, + 'items', + 'GET', + `/spaces/${credentials?.spaceId}/environments/${env}/assets`, + {}, + qs, + ); if (!rawData) { - const assets : IDataObject[] = []; + const assets: IDataObject[] = []; // tslint:disable-next-line: no-any - responseData.map((asset : any) => { + responseData.map((asset: any) => { assets.push(asset.fields); }); responseData = assets; @@ -280,13 +302,19 @@ export class Contentful implements INodeType { } else { const limit = this.getNodeParameter('limit', i) as number; qs.limit = limit; - responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/assets`, {}, qs); + responseData = await contentfulApiRequest.call( + this, + 'GET', + `/spaces/${credentials?.spaceId}/environments/${env}/assets`, + {}, + qs, + ); responseData = responseData.items; if (!rawData) { - const assets : IDataObject[] = []; + const assets: IDataObject[] = []; // tslint:disable-next-line: no-any - responseData.map((asset : any) => { + responseData.map((asset: any) => { assets.push(asset.fields); }); responseData = assets; @@ -295,9 +323,7 @@ export class Contentful implements INodeType { } } if (resource === 'locale') { - if (operation === 'getAll') { - const credentials = await this.getCredentials('contentfulApi'); const returnAll = this.getNodeParameter('returnAll', 0) as boolean; @@ -305,14 +331,25 @@ export class Contentful implements INodeType { const env = this.getNodeParameter('environmentId', i) as string; if (returnAll) { - responseData = await contenfulApiRequestAllItems.call(this, 'items', 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/locales`, {}, qs); - + responseData = await contenfulApiRequestAllItems.call( + this, + 'items', + 'GET', + `/spaces/${credentials?.spaceId}/environments/${env}/locales`, + {}, + qs, + ); } else { const limit = this.getNodeParameter('limit', 0) as number; qs.limit = limit; - responseData = await contentfulApiRequest.call(this, 'GET', `/spaces/${credentials?.spaceId}/environments/${env}/locales`, {}, qs); + responseData = await contentfulApiRequest.call( + this, + 'GET', + `/spaces/${credentials?.spaceId}/environments/${env}/locales`, + {}, + qs, + ); responseData = responseData.items; - } } } diff --git a/packages/nodes-base/nodes/Contentful/EntryDescription.ts b/packages/nodes-base/nodes/Contentful/EntryDescription.ts index 0e480b43d5e84..eca827dc8af14 100644 --- a/packages/nodes-base/nodes/Contentful/EntryDescription.ts +++ b/packages/nodes-base/nodes/Contentful/EntryDescription.ts @@ -1,7 +1,4 @@ -import { - INodeProperties, - INodePropertyOptions, -} from 'n8n-workflow'; +import { INodeProperties, INodePropertyOptions } from 'n8n-workflow'; export const resource = { name: 'Entry', @@ -16,9 +13,7 @@ export const operations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - resource.value, - ], + resource: [resource.value], }, }, options: [ @@ -42,17 +37,13 @@ export const fields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - resource.value, - ], - operation: [ - 'get', - 'getAll', - ], + resource: [resource.value], + operation: ['get', 'getAll'], }, }, default: 'master', - description: 'The ID for the Contentful environment (e.g. master, staging, etc.). Depending on your plan, you might not have environments. In that case use "master".', + description: + 'The ID for the Contentful environment (e.g. master, staging, etc.). Depending on your plan, you might not have environments. In that case use "master".', }, { displayName: 'Return All', @@ -60,12 +51,8 @@ export const fields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - resource.value, - ], + operation: ['getAll'], + resource: [resource.value], }, }, default: false, @@ -77,15 +64,9 @@ export const fields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - resource.value, - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: [resource.value], + returnAll: [false], }, }, typeOptions: { @@ -103,12 +84,8 @@ export const fields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - resource.value, - ], - operation: [ - 'getAll', - ], + resource: [resource.value], + operation: ['getAll'], }, }, options: [ @@ -125,7 +102,8 @@ export const fields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'fields.title=n8n', - description: 'Search for all data that matches the condition: {attribute}={value}. Attribute can use dot notation.', + description: + 'Search for all data that matches the condition: {attribute}={value}. Attribute can use dot notation.', }, { displayName: 'Exclude', @@ -133,7 +111,8 @@ export const fields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'fields.tags[nin]=accessories,flowers', - description: 'Search for all data that matches the condition: {attribute}[nin]={value}. Attribute can use dot notation.', + description: + 'Search for all data that matches the condition: {attribute}[nin]={value}. Attribute can use dot notation.', }, { displayName: 'Exist', @@ -141,7 +120,8 @@ export const fields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'fields.tags[exists]=true', - description: 'Search for all data that matches the condition: {attribute}[exists]={value}. Attribute can use dot notation.', + description: + 'Search for all data that matches the condition: {attribute}[exists]={value}. Attribute can use dot notation.', }, { displayName: 'Fields', @@ -149,7 +129,8 @@ export const fields: INodeProperties[] = [ type: 'string', placeholder: 'fields.title', default: '', - description: 'The select operator allows you to choose what fields to return from an entity. You can choose multiple values by combining comma-separated operators.', + description: + 'The select operator allows you to choose what fields to return from an entity. You can choose multiple values by combining comma-separated operators.', }, { displayName: 'Include', @@ -157,7 +138,8 @@ export const fields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'fields.tags[in]=accessories,flowers', - description: 'Search for all data that matches the condition: {attribute}[in]={value}. Attribute can use dot notation.', + description: + 'Search for all data that matches the condition: {attribute}[in]={value}. Attribute can use dot notation.', }, { displayName: 'Not Equal', @@ -165,7 +147,8 @@ export const fields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'fields.title[ne]=n8n', - description: 'Search for all data that matches the condition: {attribute}[ne]={value}. Attribute can use dot notation.', + description: + 'Search for all data that matches the condition: {attribute}[ne]={value}. Attribute can use dot notation.', }, { displayName: 'Order', @@ -173,14 +156,16 @@ export const fields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'sys.createdAt', - description: 'You can order items in the response by specifying the order search parameter. You can use sys properties (such as sys.createdAt) or field values (such as fields.myCustomDateField) for ordering.', + description: + 'You can order items in the response by specifying the order search parameter. You can use sys properties (such as sys.createdAt) or field values (such as fields.myCustomDateField) for ordering.', }, { displayName: 'Query', name: 'query', type: 'string', default: '', - description: 'Full-text search is case insensitive and might return more results than expected. A query will only take values with more than 1 character.', + description: + 'Full-text search is case insensitive and might return more results than expected. A query will only take values with more than 1 character.', }, { displayName: 'RAW Data', @@ -199,12 +184,8 @@ export const fields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - resource.value, - ], - operation: [ - 'get', - ], + resource: [resource.value], + operation: ['get'], }, }, }, diff --git a/packages/nodes-base/nodes/Contentful/GenericFunctions.ts b/packages/nodes-base/nodes/Contentful/GenericFunctions.ts index 571b566cb2b60..c3f90a6f2e154 100644 --- a/packages/nodes-base/nodes/Contentful/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Contentful/GenericFunctions.ts @@ -1,19 +1,20 @@ -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; - -export async function contentfulApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; +export async function contentfulApiRequest( + 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('contentfulApi'); const source = this.getNodeParameter('source', 0) as string; const isPreview = source === 'previewApi'; @@ -22,7 +23,7 @@ export async function contentfulApiRequest(this: IExecuteFunctions | IExecuteSin method, qs, body, - uri: uri ||`https://${isPreview ? 'preview' : 'cdn'}.contentful.com${resource}`, + uri: uri || `https://${isPreview ? 'preview' : 'cdn'}.contentful.com${resource}`, json: true, }; @@ -37,11 +38,18 @@ export async function contentfulApiRequest(this: IExecuteFunctions | IExecuteSin } catch (error) { throw new NodeApiError(this.getNode(), error); } - } -export async function contenfulApiRequestAllItems(this: ILoadOptionsFunctions | IExecuteFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function contenfulApiRequestAllItems( + this: 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; @@ -53,9 +61,7 @@ export async function contenfulApiRequestAllItems(this: ILoadOptionsFunctions | responseData = await contentfulApiRequest.call(this, method, resource, body, query); query.skip = (query.skip + 1) * query.limit; returnData.push.apply(returnData, responseData[propertyName]); - } while ( - returnData.length < responseData.total - ); + } while (returnData.length < responseData.total); return returnData; } diff --git a/packages/nodes-base/nodes/Contentful/LocaleDescription.ts b/packages/nodes-base/nodes/Contentful/LocaleDescription.ts index 516c6217b2743..e57c2936e269b 100644 --- a/packages/nodes-base/nodes/Contentful/LocaleDescription.ts +++ b/packages/nodes-base/nodes/Contentful/LocaleDescription.ts @@ -1,7 +1,4 @@ -import { - INodeProperties, - INodePropertyOptions -} from 'n8n-workflow'; +import { INodeProperties, INodePropertyOptions } from 'n8n-workflow'; export const resource = { name: 'Locale', @@ -16,9 +13,7 @@ export const operations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - resource.value, - ], + resource: [resource.value], }, }, options: [ @@ -38,17 +33,13 @@ export const fields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - resource.value, - ], - operation: [ - 'get', - 'getAll', - ], + resource: [resource.value], + operation: ['get', 'getAll'], }, }, default: 'master', - description: 'The ID for the Contentful environment (e.g. master, staging, etc.). Depending on your plan, you might not have environments. In that case use "master".', + description: + 'The ID for the Contentful environment (e.g. master, staging, etc.). Depending on your plan, you might not have environments. In that case use "master".', }, { displayName: 'Return All', @@ -56,12 +47,8 @@ export const fields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - resource.value, - ], + operation: ['getAll'], + resource: [resource.value], }, }, default: false, @@ -73,15 +60,9 @@ export const fields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - resource.value, - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: [resource.value], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/Contentful/SpaceDescription.ts b/packages/nodes-base/nodes/Contentful/SpaceDescription.ts index 338a97ec34144..e158c09e34b2a 100644 --- a/packages/nodes-base/nodes/Contentful/SpaceDescription.ts +++ b/packages/nodes-base/nodes/Contentful/SpaceDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const resource = { name: 'Space', @@ -15,9 +13,7 @@ export const operations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - resource.value, - ], + resource: [resource.value], }, }, options: [ diff --git a/packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts b/packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts index febdd4fe95cb2..c54c49bd5cfc0 100644 --- a/packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts +++ b/packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts @@ -1,7 +1,4 @@ -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { IDataObject, @@ -11,34 +8,17 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - convertKitApiRequest, -} from './GenericFunctions'; +import { convertKitApiRequest } from './GenericFunctions'; -import { - customFieldFields, - customFieldOperations, -} from './CustomFieldDescription'; +import { customFieldFields, customFieldOperations } from './CustomFieldDescription'; -import { - formFields, - formOperations, -} from './FormDescription'; +import { formFields, formOperations } from './FormDescription'; -import { - sequenceFields, - sequenceOperations, -} from './SequenceDescription'; +import { sequenceFields, sequenceOperations } from './SequenceDescription'; -import { - tagFields, - tagOperations, -} from './TagDescription'; +import { tagFields, tagOperations } from './TagDescription'; -import { - tagSubscriberFields, - tagSubscriberOperations, -} from './TagSubscriberDescription'; +import { tagSubscriberFields, tagSubscriberOperations } from './TagSubscriberDescription'; export class ConvertKit implements INodeType { description: INodeTypeDescription = { @@ -183,30 +163,30 @@ export class ConvertKit implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'customField') { if (operation === 'create') { - const label = this.getNodeParameter('label', i) as string; - responseData = await convertKitApiRequest.call(this, 'POST', '/custom_fields', { label }, qs); + responseData = await convertKitApiRequest.call( + this, + 'POST', + '/custom_fields', + { label }, + qs, + ); } if (operation === 'delete') { - const id = this.getNodeParameter('id', i) as string; responseData = await convertKitApiRequest.call(this, 'DELETE', `/custom_fields/${id}`); } if (operation === 'get') { - const id = this.getNodeParameter('id', i) as string; responseData = await convertKitApiRequest.call(this, 'GET', `/custom_fields/${id}`); } if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; responseData = await convertKitApiRequest.call(this, 'GET', `/custom_fields`); @@ -214,19 +194,19 @@ export class ConvertKit implements INodeType { responseData = responseData.custom_fields; if (!returnAll) { - const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); } } if (operation === 'update') { - const id = this.getNodeParameter('id', i) as string; const label = this.getNodeParameter('label', i) as string; - responseData = await convertKitApiRequest.call(this, 'PUT', `/custom_fields/${id}`, { label }); + responseData = await convertKitApiRequest.call(this, 'PUT', `/custom_fields/${id}`, { + label, + }); responseData = { success: true }; } @@ -234,7 +214,6 @@ export class ConvertKit implements INodeType { if (resource === 'form') { if (operation === 'addSubscriber') { - const email = this.getNodeParameter('email', i) as string; const formId = this.getNodeParameter('id', i) as string; @@ -254,7 +233,8 @@ export class ConvertKit implements INodeType { } if (additionalFields.fieldsUi) { - const fieldValues = (additionalFields.fieldsUi as IDataObject).fieldsValues as IDataObject[]; + const fieldValues = (additionalFields.fieldsUi as IDataObject) + .fieldsValues as IDataObject[]; if (fieldValues) { body.fields = {}; for (const fieldValue of fieldValues) { @@ -264,12 +244,16 @@ export class ConvertKit implements INodeType { } } - const { subscription } = await convertKitApiRequest.call(this, 'POST', `/forms/${formId}/subscribe`, body); + const { subscription } = await convertKitApiRequest.call( + this, + 'POST', + `/forms/${formId}/subscribe`, + body, + ); responseData = subscription; } if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; responseData = await convertKitApiRequest.call(this, 'GET', `/forms`); @@ -277,14 +261,12 @@ export class ConvertKit implements INodeType { responseData = responseData.forms; if (!returnAll) { - const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); } } if (operation === 'getSubscriptions') { - const formId = this.getNodeParameter('id', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; @@ -295,12 +277,17 @@ export class ConvertKit implements INodeType { qs.subscriber_state = additionalFields.subscriberState as string; } - responseData = await convertKitApiRequest.call(this, 'GET', `/forms/${formId}/subscriptions`, {}, qs); + responseData = await convertKitApiRequest.call( + this, + 'GET', + `/forms/${formId}/subscriptions`, + {}, + qs, + ); responseData = responseData.subscriptions; if (!returnAll) { - const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); @@ -310,7 +297,6 @@ export class ConvertKit implements INodeType { if (resource === 'sequence') { if (operation === 'addSubscriber') { - const email = this.getNodeParameter('email', i) as string; const sequenceId = this.getNodeParameter('id', i) as string; @@ -330,7 +316,8 @@ export class ConvertKit implements INodeType { } if (additionalFields.fieldsUi) { - const fieldValues = (additionalFields.fieldsUi as IDataObject).fieldsValues as IDataObject[]; + const fieldValues = (additionalFields.fieldsUi as IDataObject) + .fieldsValues as IDataObject[]; if (fieldValues) { body.fields = {}; for (const fieldValue of fieldValues) { @@ -340,12 +327,16 @@ export class ConvertKit implements INodeType { } } - const { subscription } = await convertKitApiRequest.call(this, 'POST', `/sequences/${sequenceId}/subscribe`, body); + const { subscription } = await convertKitApiRequest.call( + this, + 'POST', + `/sequences/${sequenceId}/subscribe`, + body, + ); responseData = subscription; } if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; responseData = await convertKitApiRequest.call(this, 'GET', `/sequences`); @@ -353,14 +344,12 @@ export class ConvertKit implements INodeType { responseData = responseData.courses; if (!returnAll) { - const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); } } if (operation === 'getSubscriptions') { - const sequenceId = this.getNodeParameter('id', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; @@ -371,12 +360,17 @@ export class ConvertKit implements INodeType { qs.subscriber_state = additionalFields.subscriberState as string; } - responseData = await convertKitApiRequest.call(this, 'GET', `/sequences/${sequenceId}/subscriptions`, {}, qs); + responseData = await convertKitApiRequest.call( + this, + 'GET', + `/sequences/${sequenceId}/subscriptions`, + {}, + qs, + ); responseData = responseData.subscriptions; if (!returnAll) { - const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); @@ -386,8 +380,9 @@ export class ConvertKit implements INodeType { if (resource === 'tag') { if (operation === 'create') { - - const names = ((this.getNodeParameter('name', i) as string).split(',') as string[]).map((e) => ({ name: e })); + const names = ((this.getNodeParameter('name', i) as string).split(',') as string[]).map( + (e) => ({ name: e }), + ); const body: IDataObject = { tag: names, @@ -397,7 +392,6 @@ export class ConvertKit implements INodeType { } if (operation === 'getAll') { - const returnAll = this.getNodeParameter('returnAll', i) as boolean; responseData = await convertKitApiRequest.call(this, 'GET', `/tags`); @@ -405,7 +399,6 @@ export class ConvertKit implements INodeType { responseData = responseData.tags; if (!returnAll) { - const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); @@ -414,9 +407,7 @@ export class ConvertKit implements INodeType { } if (resource === 'tagSubscriber') { - if (operation === 'add') { - const tagId = this.getNodeParameter('tagId', i) as string; const email = this.getNodeParameter('email', i) as string; @@ -432,7 +423,8 @@ export class ConvertKit implements INodeType { } if (additionalFields.fieldsUi) { - const fieldValues = (additionalFields.fieldsUi as IDataObject).fieldsValues as IDataObject[]; + const fieldValues = (additionalFields.fieldsUi as IDataObject) + .fieldsValues as IDataObject[]; if (fieldValues) { body.fields = {}; for (const fieldValue of fieldValues) { @@ -442,23 +434,30 @@ export class ConvertKit implements INodeType { } } - const { subscription } = await convertKitApiRequest.call(this, 'POST', `/tags/${tagId}/subscribe`, body); + const { subscription } = await convertKitApiRequest.call( + this, + 'POST', + `/tags/${tagId}/subscribe`, + body, + ); responseData = subscription; } if (operation === 'getAll') { - const tagId = this.getNodeParameter('tagId', i) as string; const returnAll = this.getNodeParameter('returnAll', i) as boolean; - responseData = await convertKitApiRequest.call(this, 'GET', `/tags/${tagId}/subscriptions`); + responseData = await convertKitApiRequest.call( + this, + 'GET', + `/tags/${tagId}/subscriptions`, + ); responseData = responseData.subscriptions; if (!returnAll) { - const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); @@ -466,12 +465,16 @@ export class ConvertKit implements INodeType { } if (operation === 'delete') { - const tagId = this.getNodeParameter('tagId', i) as string; const email = this.getNodeParameter('email', i) as string; - responseData = await convertKitApiRequest.call(this, 'POST', `/tags/${tagId}>/unsubscribe`, { email }); + responseData = await convertKitApiRequest.call( + this, + 'POST', + `/tags/${tagId}>/unsubscribe`, + { email }, + ); } } @@ -480,7 +483,6 @@ export class ConvertKit 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/ConvertKit/ConvertKitTrigger.node.ts b/packages/nodes-base/nodes/ConvertKit/ConvertKitTrigger.node.ts index 3b1aaf548f2c1..8f27cb6bebd7f 100644 --- a/packages/nodes-base/nodes/ConvertKit/ConvertKitTrigger.node.ts +++ b/packages/nodes-base/nodes/ConvertKit/ConvertKitTrigger.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 { - convertKitApiRequest, -} from './GenericFunctions'; +import { convertKitApiRequest } from './GenericFunctions'; -import { - snakeCase, -} from 'change-case'; +import { snakeCase } from 'change-case'; export class ConvertKitTrigger implements INodeType { description: INodeTypeDescription = { @@ -103,7 +96,8 @@ export class ConvertKitTrigger implements INodeType { displayName: 'Form Name or ID', name: 'formId', type: 'options', - 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: 'getForms', }, @@ -111,9 +105,7 @@ export class ConvertKitTrigger implements INodeType { default: '', displayOptions: { show: { - event: [ - 'formSubscribe', - ], + event: ['formSubscribe'], }, }, }, @@ -121,7 +113,8 @@ export class ConvertKitTrigger implements INodeType { displayName: 'Sequence Name or ID', name: 'courseId', type: 'options', - 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: 'getSequences', }, @@ -129,10 +122,7 @@ export class ConvertKitTrigger implements INodeType { default: '', displayOptions: { show: { - event: [ - 'courseSubscribe', - 'courseComplete', - ], + event: ['courseSubscribe', 'courseComplete'], }, }, }, @@ -145,9 +135,7 @@ export class ConvertKitTrigger implements INodeType { description: 'The URL of the initiating link', displayOptions: { show: { - event: [ - 'linkClick', - ], + event: ['linkClick'], }, }, }, @@ -159,9 +147,7 @@ export class ConvertKitTrigger implements INodeType { default: '', displayOptions: { show: { - event: [ - 'productPurchase', - ], + event: ['productPurchase'], }, }, }, @@ -169,7 +155,8 @@ export class ConvertKitTrigger implements INodeType { displayName: 'Tag Name or ID', name: 'tagId', type: 'options', - 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: 'getTags', }, @@ -177,10 +164,7 @@ export class ConvertKitTrigger implements INodeType { default: '', displayOptions: { show: { - event: [ - 'tagAdd', - 'tagRemove', - ], + event: ['tagAdd', 'tagRemove'], }, }, }, @@ -192,13 +176,11 @@ export class ConvertKitTrigger implements INodeType { // Get all the tags to display them to user so that he can // select them easily async getTags(this: ILoadOptionsFunctions): Promise { - const returnData: INodePropertyOptions[] = []; const { tags } = await convertKitApiRequest.call(this, 'GET', '/tags'); for (const tag of tags) { - const tagName = tag.name; const tagId = tag.id; @@ -214,13 +196,11 @@ export class ConvertKitTrigger implements INodeType { // Get all the forms to display them to user so that he can // select them easily async getForms(this: ILoadOptionsFunctions): Promise { - const returnData: INodePropertyOptions[] = []; const { forms } = await convertKitApiRequest.call(this, 'GET', '/forms'); for (const form of forms) { - const formName = form.name; const formId = form.id; @@ -237,13 +217,11 @@ export class ConvertKitTrigger implements INodeType { // Get all the sequences to display them to user so that he can // select them easily async getSequences(this: ILoadOptionsFunctions): Promise { - const returnData: INodePropertyOptions[] = []; const { courses } = await convertKitApiRequest.call(this, 'GET', '/sequences'); for (const course of courses) { - const courseName = course.name; const courseId = course.id; @@ -263,7 +241,6 @@ export class ConvertKitTrigger implements INodeType { webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { - const webhookData = this.getWorkflowStaticData('node'); // THe API does not have an endpoint to list all webhooks @@ -276,7 +253,6 @@ export class ConvertKitTrigger implements INodeType { }, async create(this: IHookFunctions): Promise { - const webhookUrl = this.getNodeWebhookUrl('default'); let event = this.getNodeParameter('event', 0) as string; @@ -335,11 +311,9 @@ export class ConvertKitTrigger implements INodeType { }, async delete(this: IHookFunctions): Promise { - const webhookData = this.getWorkflowStaticData('node'); if (webhookData.webhookId !== undefined) { - const endpoint = `/automations/hooks/${webhookData.webhookId}`; try { @@ -361,9 +335,7 @@ export class ConvertKitTrigger implements INodeType { returnData.push(this.getBodyData()); return { - workflowData: [ - this.helpers.returnJsonArray(returnData), - ], + workflowData: [this.helpers.returnJsonArray(returnData)], }; } } diff --git a/packages/nodes-base/nodes/ConvertKit/CustomFieldDescription.ts b/packages/nodes-base/nodes/ConvertKit/CustomFieldDescription.ts index c90b46bcfcbc8..c8fe02859de67 100644 --- a/packages/nodes-base/nodes/ConvertKit/CustomFieldDescription.ts +++ b/packages/nodes-base/nodes/ConvertKit/CustomFieldDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const customFieldOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const customFieldOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'customField', - ], + resource: ['customField'], }, }, options: [ @@ -53,13 +49,8 @@ export const customFieldFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'customField', - ], - operation: [ - 'update', - 'delete', - ], + resource: ['customField'], + operation: ['update', 'delete'], }, }, default: '', @@ -72,13 +63,8 @@ export const customFieldFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'customField', - ], - operation: [ - 'update', - 'create', - ], + resource: ['customField'], + operation: ['update', 'create'], }, }, default: '', @@ -90,12 +76,8 @@ export const customFieldFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'customField', - ], + operation: ['getAll'], + resource: ['customField'], }, }, default: false, @@ -107,15 +89,9 @@ export const customFieldFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'customField', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['customField'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/ConvertKit/FormDescription.ts b/packages/nodes-base/nodes/ConvertKit/FormDescription.ts index ba6eebb443a21..7fc93e7c4e275 100644 --- a/packages/nodes-base/nodes/ConvertKit/FormDescription.ts +++ b/packages/nodes-base/nodes/ConvertKit/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: [ @@ -45,20 +41,16 @@ export const formFields: INodeProperties[] = [ displayName: 'Form 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', typeOptions: { loadOptionsMethod: 'getForms', }, required: true, displayOptions: { show: { - resource: [ - 'form', - ], - operation: [ - 'addSubscriber', - 'getSubscriptions', - ], + resource: ['form'], + operation: ['addSubscriber', 'getSubscriptions'], }, }, default: '', @@ -71,16 +63,12 @@ export const formFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'form', - ], - operation: [ - 'addSubscriber', - ], + resource: ['form'], + operation: ['addSubscriber'], }, }, default: '', - description: 'The subscriber\'s email address', + description: "The subscriber's email address", }, { displayName: 'Additional Fields', @@ -90,12 +78,8 @@ export const formFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'form', - ], - operation: [ - 'addSubscriber', - ], + resource: ['form'], + operation: ['addSubscriber'], }, }, options: [ @@ -103,7 +87,8 @@ export const formFields: INodeProperties[] = [ displayName: 'Custom Fields', name: 'fieldsUi', placeholder: 'Add Custom Field', - description: 'Object of key/value pairs for custom fields (the custom field must exist before you can use it here)', + description: + 'Object of key/value pairs for custom fields (the custom field must exist before you can use it here)', type: 'fixedCollection', typeOptions: { multipleValues: true, @@ -120,7 +105,7 @@ export const formFields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'last_name', - description: 'The field\'s key', + description: "The field's key", }, { displayName: 'Field Value', @@ -139,7 +124,7 @@ export const formFields: INodeProperties[] = [ name: 'firstName', type: 'string', default: '', - description: 'The subscriber\'s first name', + description: "The subscriber's first name", }, ], }, @@ -149,13 +134,8 @@ export const formFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - 'getSubscriptions', - ], - resource: [ - 'form', - ], + operation: ['getAll', 'getSubscriptions'], + resource: ['form'], }, }, default: false, @@ -167,16 +147,9 @@ export const formFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - 'getSubscriptions', - ], - resource: [ - 'form', - ], - returnAll: [ - false, - ], + operation: ['getAll', 'getSubscriptions'], + resource: ['form'], + returnAll: [false], }, }, typeOptions: { @@ -194,12 +167,8 @@ export const formFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'form', - ], - operation: [ - 'getSubscriptions', - ], + resource: ['form'], + operation: ['getSubscriptions'], }, }, options: [ diff --git a/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts b/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts index 2eeda1b13d9f0..e121a3eab8110 100644 --- a/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts @@ -1,23 +1,20 @@ -import { - OptionsWithUri -} from 'request'; - -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; - -import { - IDataObject, - IHookFunctions, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; - -export async function convertKitApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, - method: string, endpoint: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any - +import { OptionsWithUri } from 'request'; + +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; + +import { IDataObject, IHookFunctions, NodeApiError, NodeOperationError } from 'n8n-workflow'; + +export async function convertKitApiRequest( + this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, + 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 credentials = await this.getCredentials('convertKitApi'); let options: OptionsWithUri = { diff --git a/packages/nodes-base/nodes/ConvertKit/SequenceDescription.ts b/packages/nodes-base/nodes/ConvertKit/SequenceDescription.ts index bf58ced846319..4ce1ce92b1a3a 100644 --- a/packages/nodes-base/nodes/ConvertKit/SequenceDescription.ts +++ b/packages/nodes-base/nodes/ConvertKit/SequenceDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const sequenceOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const sequenceOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'sequence', - ], + resource: ['sequence'], }, }, options: [ @@ -45,20 +41,16 @@ export const sequenceFields: INodeProperties[] = [ displayName: 'Sequence 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', typeOptions: { loadOptionsMethod: 'getSequences', }, required: true, displayOptions: { show: { - resource: [ - 'sequence', - ], - operation: [ - 'addSubscriber', - 'getSubscriptions', - ], + resource: ['sequence'], + operation: ['addSubscriber', 'getSubscriptions'], }, }, default: '', @@ -71,16 +63,12 @@ export const sequenceFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'sequence', - ], - operation: [ - 'addSubscriber', - ], + resource: ['sequence'], + operation: ['addSubscriber'], }, }, default: '', - description: 'The subscriber\'s email address', + description: "The subscriber's email address", }, { displayName: 'Return All', @@ -88,13 +76,8 @@ export const sequenceFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - 'getSubscriptions', - ], - resource: [ - 'sequence', - ], + operation: ['getAll', 'getSubscriptions'], + resource: ['sequence'], }, }, default: false, @@ -106,16 +89,9 @@ export const sequenceFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - 'getSubscriptions', - ], - resource: [ - 'sequence', - ], - returnAll: [ - false, - ], + operation: ['getAll', 'getSubscriptions'], + resource: ['sequence'], + returnAll: [false], }, }, typeOptions: { @@ -133,12 +109,8 @@ export const sequenceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'sequence', - ], - operation: [ - 'addSubscriber', - ], + resource: ['sequence'], + operation: ['addSubscriber'], }, }, options: [ @@ -146,7 +118,8 @@ export const sequenceFields: INodeProperties[] = [ displayName: 'Custom Fields', name: 'fieldsUi', placeholder: 'Add Custom Field', - description: 'Object of key/value pairs for custom fields (the custom field must exist before you can use it here)', + description: + 'Object of key/value pairs for custom fields (the custom field must exist before you can use it here)', type: 'fixedCollection', typeOptions: { multipleValues: true, @@ -163,7 +136,7 @@ export const sequenceFields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'last_name', - description: 'The field\'s key', + description: "The field's key", }, { displayName: 'Field Value', @@ -182,7 +155,7 @@ export const sequenceFields: INodeProperties[] = [ name: 'firstName', type: 'string', default: '', - description: 'The subscriber\'s first name', + description: "The subscriber's first name", }, { displayName: 'Tag Names or IDs', @@ -192,7 +165,8 @@ export const sequenceFields: INodeProperties[] = [ loadOptionsMethod: 'getTags', }, default: [], - description: 'Tags. Choose from the list, or specify IDs using an expression.', + description: + 'Tags. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -204,12 +178,8 @@ export const sequenceFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'sequence', - ], - operation: [ - 'getSubscriptions', - ], + resource: ['sequence'], + operation: ['getSubscriptions'], }, }, options: [ diff --git a/packages/nodes-base/nodes/ConvertKit/TagDescription.ts b/packages/nodes-base/nodes/ConvertKit/TagDescription.ts index d8a55ff8de10e..e1de30f825b0f 100644 --- a/packages/nodes-base/nodes/ConvertKit/TagDescription.ts +++ b/packages/nodes-base/nodes/ConvertKit/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: [ @@ -41,12 +37,8 @@ export const tagFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'tag', - ], - operation: [ - 'create', - ], + resource: ['tag'], + operation: ['create'], }, }, default: '', @@ -58,12 +50,8 @@ export const tagFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'tag', - ], + operation: ['getAll'], + resource: ['tag'], }, }, default: false, @@ -75,15 +63,9 @@ export const tagFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'tag', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['tag'], + returnAll: [false], }, }, typeOptions: { diff --git a/packages/nodes-base/nodes/ConvertKit/TagSubscriberDescription.ts b/packages/nodes-base/nodes/ConvertKit/TagSubscriberDescription.ts index d90a96c502c63..ae4c611085419 100644 --- a/packages/nodes-base/nodes/ConvertKit/TagSubscriberDescription.ts +++ b/packages/nodes-base/nodes/ConvertKit/TagSubscriberDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const tagSubscriberOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const tagSubscriberOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'tagSubscriber', - ], + resource: ['tagSubscriber'], }, }, options: [ @@ -44,21 +40,16 @@ export const tagSubscriberFields: INodeProperties[] = [ displayName: 'Tag Name or ID', name: 'tagId', type: 'options', - 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: 'getTags', }, required: true, displayOptions: { show: { - resource: [ - 'tagSubscriber', - ], - operation: [ - 'add', - 'getAll', - 'delete', - ], + resource: ['tagSubscriber'], + operation: ['add', 'getAll', 'delete'], }, }, default: '', @@ -71,13 +62,8 @@ export const tagSubscriberFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'tagSubscriber', - ], - operation: [ - 'add', - 'delete', - ], + resource: ['tagSubscriber'], + operation: ['add', 'delete'], }, }, default: '', @@ -91,12 +77,8 @@ export const tagSubscriberFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'tagSubscriber', - ], - operation: [ - 'add', - ], + resource: ['tagSubscriber'], + operation: ['add'], }, }, options: [ @@ -104,7 +86,8 @@ export const tagSubscriberFields: INodeProperties[] = [ displayName: 'Custom Fields', name: 'fields', placeholder: 'Add Custom Field', - description: 'Object of key/value pairs for custom fields (the custom field must exist before you can use it here)', + description: + 'Object of key/value pairs for custom fields (the custom field must exist before you can use it here)', type: 'fixedCollection', typeOptions: { multipleValues: true, @@ -121,7 +104,7 @@ export const tagSubscriberFields: INodeProperties[] = [ type: 'string', default: '', placeholder: 'last_name', - description: 'The field\'s key', + description: "The field's key", }, { displayName: 'Field Value', @@ -150,12 +133,8 @@ export const tagSubscriberFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'tagSubscriber', - ], + operation: ['getAll'], + resource: ['tagSubscriber'], }, }, default: false, @@ -167,15 +146,9 @@ export const tagSubscriberFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'tagSubscriber', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['tagSubscriber'], + returnAll: [false], }, }, typeOptions: { @@ -193,12 +166,8 @@ export const tagSubscriberFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'tagSubscriber', - ], - operation: [ - 'getAll', - ], + resource: ['tagSubscriber'], + operation: ['getAll'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Copper/Copper.node.ts b/packages/nodes-base/nodes/Copper/Copper.node.ts index 24e51562f1bb4..ce49ef100b6b1 100644 --- a/packages/nodes-base/nodes/Copper/Copper.node.ts +++ b/packages/nodes-base/nodes/Copper/Copper.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 { adjustCompanyFields, @@ -128,17 +121,13 @@ export class Copper implements INodeType { let responseData; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'company') { - // ********************************************************************** // company // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // company: create // ---------------------------------------- @@ -156,9 +145,7 @@ export class Copper implements INodeType { } responseData = await copperApiRequest.call(this, 'POST', '/companies', body); - } else if (operation === 'delete') { - // ---------------------------------------- // company: delete // ---------------------------------------- @@ -168,9 +155,7 @@ export class Copper implements INodeType { const companyId = this.getNodeParameter('companyId', i); responseData = await copperApiRequest.call(this, 'DELETE', `/companies/${companyId}`); - } else if (operation === 'get') { - // ---------------------------------------- // company: get // ---------------------------------------- @@ -180,9 +165,7 @@ export class Copper implements INodeType { const companyId = this.getNodeParameter('companyId', i); responseData = await copperApiRequest.call(this, 'GET', `/companies/${companyId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // company: getAll // ---------------------------------------- @@ -197,9 +180,7 @@ export class Copper implements INodeType { } responseData = await handleListing.call(this, 'POST', '/companies/search', body); - } else if (operation === 'update') { - // ---------------------------------------- // company: update // ---------------------------------------- @@ -215,34 +196,31 @@ export class Copper implements INodeType { Object.assign(body, adjustCompanyFields(updateFields)); } - responseData = await copperApiRequest.call(this, 'PUT', `/companies/${companyId}`, body); - + responseData = await copperApiRequest.call( + this, + 'PUT', + `/companies/${companyId}`, + body, + ); } - } else if (resource === 'customerSource') { - // ********************************************************************** // customerSource // ********************************************************************** if (operation === 'getAll') { - // ---------------------------------------- // customerSource: getAll // ---------------------------------------- responseData = await handleListing.call(this, 'GET', '/customer_sources'); - } - } else if (resource === 'lead') { - // ********************************************************************** // lead // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // lead: create // ---------------------------------------- @@ -260,9 +238,7 @@ export class Copper implements INodeType { } responseData = await copperApiRequest.call(this, 'POST', '/leads', body); - } else if (operation === 'delete') { - // ---------------------------------------- // lead: delete // ---------------------------------------- @@ -272,9 +248,7 @@ export class Copper implements INodeType { const leadId = this.getNodeParameter('leadId', i); responseData = await copperApiRequest.call(this, 'DELETE', `/leads/${leadId}`); - } else if (operation === 'get') { - // ---------------------------------------- // lead: get // ---------------------------------------- @@ -284,9 +258,7 @@ export class Copper implements INodeType { const leadId = this.getNodeParameter('leadId', i); responseData = await copperApiRequest.call(this, 'GET', `/leads/${leadId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // lead: getAll // ---------------------------------------- @@ -299,9 +271,7 @@ export class Copper implements INodeType { } responseData = await handleListing.call(this, 'POST', '/leads/search', body); - } else if (operation === 'update') { - // ---------------------------------------- // lead: update // ---------------------------------------- @@ -318,17 +288,13 @@ export class Copper implements INodeType { } responseData = await copperApiRequest.call(this, 'PUT', `/leads/${leadId}`, body); - } - } else if (resource === 'opportunity') { - // ********************************************************************** // opportunity // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // opportunity: create // ---------------------------------------- @@ -342,9 +308,7 @@ export class Copper implements INodeType { }; responseData = await copperApiRequest.call(this, 'POST', '/opportunities', body); - } else if (operation === 'delete') { - // ---------------------------------------- // opportunity: delete // ---------------------------------------- @@ -353,10 +317,12 @@ export class Copper implements INodeType { const opportunityId = this.getNodeParameter('opportunityId', i); - responseData = await copperApiRequest.call(this, 'DELETE', `/opportunities/${opportunityId}`); - + responseData = await copperApiRequest.call( + this, + 'DELETE', + `/opportunities/${opportunityId}`, + ); } else if (operation === 'get') { - // ---------------------------------------- // opportunity: get // ---------------------------------------- @@ -365,10 +331,12 @@ export class Copper implements INodeType { const opportunityId = this.getNodeParameter('opportunityId', i); - responseData = await copperApiRequest.call(this, 'GET', `/opportunities/${opportunityId}`); - + responseData = await copperApiRequest.call( + this, + 'GET', + `/opportunities/${opportunityId}`, + ); } else if (operation === 'getAll') { - // ---------------------------------------- // opportunity: getAll // ---------------------------------------- @@ -383,9 +351,7 @@ export class Copper implements INodeType { } responseData = await handleListing.call(this, 'POST', '/opportunities/search', body); - } else if (operation === 'update') { - // ---------------------------------------- // opportunity: update // ---------------------------------------- @@ -401,18 +367,19 @@ export class Copper implements INodeType { Object.assign(body, updateFields); } - responseData = await copperApiRequest.call(this, 'PUT', `/opportunities/${opportunityId}`, body); - + responseData = await copperApiRequest.call( + this, + 'PUT', + `/opportunities/${opportunityId}`, + body, + ); } - } else if (resource === 'person') { - // ********************************************************************** // person // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // person: create // ---------------------------------------- @@ -430,9 +397,7 @@ export class Copper implements INodeType { } responseData = await copperApiRequest.call(this, 'POST', '/people', body); - } else if (operation === 'delete') { - // ---------------------------------------- // person: delete // ---------------------------------------- @@ -442,9 +407,7 @@ export class Copper implements INodeType { const personId = this.getNodeParameter('personId', i); responseData = await copperApiRequest.call(this, 'DELETE', `/people/${personId}`); - } else if (operation === 'get') { - // ---------------------------------------- // person: get // ---------------------------------------- @@ -454,9 +417,7 @@ export class Copper implements INodeType { const personId = this.getNodeParameter('personId', i); responseData = await copperApiRequest.call(this, 'GET', `/people/${personId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // person: getAll // ---------------------------------------- @@ -469,9 +430,7 @@ export class Copper implements INodeType { } responseData = await handleListing.call(this, 'POST', '/people/search', body); - } else if (operation === 'update') { - // ---------------------------------------- // person: update // ---------------------------------------- @@ -488,17 +447,13 @@ export class Copper implements INodeType { } responseData = await copperApiRequest.call(this, 'PUT', `/people/${personId}`, body); - } - } else if (resource === 'project') { - // ********************************************************************** // project // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // project: create // ---------------------------------------- @@ -516,9 +471,7 @@ export class Copper implements INodeType { } responseData = await copperApiRequest.call(this, 'POST', '/projects', body); - } else if (operation === 'delete') { - // ---------------------------------------- // project: delete // ---------------------------------------- @@ -528,9 +481,7 @@ export class Copper implements INodeType { const projectId = this.getNodeParameter('projectId', i); responseData = await copperApiRequest.call(this, 'DELETE', `/projects/${projectId}`); - } else if (operation === 'get') { - // ---------------------------------------- // project: get // ---------------------------------------- @@ -540,9 +491,7 @@ export class Copper implements INodeType { const projectId = this.getNodeParameter('projectId', i); responseData = await copperApiRequest.call(this, 'GET', `/projects/${projectId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // project: getAll // ---------------------------------------- @@ -557,9 +506,7 @@ export class Copper implements INodeType { } responseData = await handleListing.call(this, 'POST', '/projects/search', body); - } else if (operation === 'update') { - // ---------------------------------------- // project: update // ---------------------------------------- @@ -576,17 +523,13 @@ export class Copper implements INodeType { } responseData = await copperApiRequest.call(this, 'PUT', `/projects/${projectId}`, body); - } - } else if (resource === 'task') { - // ********************************************************************** // task // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // task: create // ---------------------------------------- @@ -604,9 +547,7 @@ export class Copper implements INodeType { } responseData = await copperApiRequest.call(this, 'POST', '/tasks', body); - } else if (operation === 'delete') { - // ---------------------------------------- // task: delete // ---------------------------------------- @@ -616,9 +557,7 @@ export class Copper implements INodeType { const taskId = this.getNodeParameter('taskId', i); responseData = await copperApiRequest.call(this, 'DELETE', `/tasks/${taskId}`); - } else if (operation === 'get') { - // ---------------------------------------- // task: get // ---------------------------------------- @@ -628,9 +567,7 @@ export class Copper implements INodeType { const taskId = this.getNodeParameter('taskId', i); responseData = await copperApiRequest.call(this, 'GET', `/tasks/${taskId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // task: getAll // ---------------------------------------- @@ -645,9 +582,7 @@ export class Copper implements INodeType { } responseData = await handleListing.call(this, 'POST', '/tasks/search', body); - } else if (operation === 'update') { - // ---------------------------------------- // task: update // ---------------------------------------- @@ -665,24 +600,19 @@ export class Copper implements INodeType { responseData = await copperApiRequest.call(this, 'PUT', `/tasks/${taskId}`, body); } - } else if (resource === 'user') { - // ********************************************************************** // user // ********************************************************************** if (operation === 'getAll') { - // ---------------------------------------- // user: getAll // ---------------------------------------- responseData = await handleListing.call(this, 'POST', '/users/search'); - } } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.toString() }); @@ -695,7 +625,6 @@ export class Copper implements INodeType { Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Copper/CopperTrigger.node.ts b/packages/nodes-base/nodes/Copper/CopperTrigger.node.ts index 20cc8cabc7a15..f1127fed7ce28 100644 --- a/packages/nodes-base/nodes/Copper/CopperTrigger.node.ts +++ b/packages/nodes-base/nodes/Copper/CopperTrigger.node.ts @@ -1,19 +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 { - copperApiRequest, - getAutomaticSecret, -} from './GenericFunctions'; +import { copperApiRequest, getAutomaticSecret } from './GenericFunctions'; export class CopperTrigger implements INodeType { description: INodeTypeDescription = { @@ -166,9 +155,7 @@ export class CopperTrigger implements INodeType { } return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/Copper/GenericFunctions.ts b/packages/nodes-base/nodes/Copper/GenericFunctions.ts index 85d2a028ad282..4094e87b800c4 100644 --- a/packages/nodes-base/nodes/Copper/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Copper/GenericFunctions.ts @@ -1,10 +1,6 @@ -import { - createHash, -} from 'crypto'; +import { createHash } from 'crypto'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -14,16 +10,9 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - ICredentialDataDecryptedObject, - IDataObject, - NodeApiError, -} from 'n8n-workflow'; +import { ICredentialDataDecryptedObject, IDataObject, NodeApiError } from 'n8n-workflow'; -import { - flow, - omit, -} from 'lodash'; +import { flow, omit } from 'lodash'; import { AddressFixedCollection, @@ -36,7 +25,12 @@ import { * Make an authenticated API request to Copper. */ export async function copperApiRequest( - this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, + this: + | IHookFunctions + | IExecuteFunctions + | IExecuteSingleFunctions + | ILoadOptionsFunctions + | IWebhookFunctions, method: string, resource: string, body: IDataObject = {}, @@ -44,7 +38,7 @@ export async function copperApiRequest( uri = '', option: IDataObject = {}, ) { - const credentials = await this.getCredentials('copperApi') as { apiKey: string, email: string }; + const credentials = (await this.getCredentials('copperApi')) as { apiKey: string; email: string }; let options: OptionsWithUri = { headers: { @@ -77,7 +71,6 @@ export async function copperApiRequest( } } - /** * Creates a secret from the credentials * diff --git a/packages/nodes-base/nodes/Copper/descriptions/CompanyDescription.ts b/packages/nodes-base/nodes/Copper/descriptions/CompanyDescription.ts index 1b9c9a58e16b4..11aad32ef386f 100644 --- a/packages/nodes-base/nodes/Copper/descriptions/CompanyDescription.ts +++ b/packages/nodes-base/nodes/Copper/descriptions/CompanyDescription.ts @@ -1,15 +1,8 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - isoCountryCodes, -} from '../utils/isoCountryCodes'; +import { isoCountryCodes } from '../utils/isoCountryCodes'; -import { - addressFixedCollection, - phoneNumbersFixedCollection, -} from '../utils/sharedFields'; +import { addressFixedCollection, phoneNumbersFixedCollection } from '../utils/sharedFields'; export const companyOperations: INodeProperties[] = [ { @@ -19,9 +12,7 @@ export const companyOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'company', - ], + resource: ['company'], }, }, options: [ @@ -68,12 +59,8 @@ export const companyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], + resource: ['company'], + operation: ['create'], }, }, }, @@ -85,12 +72,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'create', - ], + resource: ['company'], + operation: ['create'], }, }, options: [ @@ -124,12 +107,8 @@ export const companyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'delete', - ], + resource: ['company'], + operation: ['delete'], }, }, }, @@ -146,12 +125,8 @@ export const companyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'get', - ], + resource: ['company'], + operation: ['get'], }, }, }, @@ -167,12 +142,8 @@ export const companyFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], + resource: ['company'], + operation: ['getAll'], }, }, }, @@ -188,15 +159,9 @@ export const companyFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['company'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -208,12 +173,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'getAll', - ], + resource: ['company'], + operation: ['getAll'], }, }, options: [ @@ -247,12 +208,8 @@ export const companyFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'update', - ], + resource: ['company'], + operation: ['update'], }, }, }, @@ -264,12 +221,8 @@ export const companyFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'company', - ], - operation: [ - 'update', - ], + resource: ['company'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Copper/descriptions/CustomerSourceDescription.ts b/packages/nodes-base/nodes/Copper/descriptions/CustomerSourceDescription.ts index 90ebb14bd6d9e..b3b2f7d41e457 100644 --- a/packages/nodes-base/nodes/Copper/descriptions/CustomerSourceDescription.ts +++ b/packages/nodes-base/nodes/Copper/descriptions/CustomerSourceDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const customerSourceOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const customerSourceOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'customerSource', - ], + resource: ['customerSource'], }, }, options: [ @@ -38,12 +34,8 @@ export const customerSourceFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'customerSource', - ], - operation: [ - 'getAll', - ], + resource: ['customerSource'], + operation: ['getAll'], }, }, }, @@ -59,15 +51,9 @@ export const customerSourceFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'customerSource', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['customerSource'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Copper/descriptions/LeadDescription.ts b/packages/nodes-base/nodes/Copper/descriptions/LeadDescription.ts index 311e41f0f8ea3..6ade2139c66b2 100644 --- a/packages/nodes-base/nodes/Copper/descriptions/LeadDescription.ts +++ b/packages/nodes-base/nodes/Copper/descriptions/LeadDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import { addressFixedCollection, @@ -16,9 +14,7 @@ export const leadOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'lead', - ], + resource: ['lead'], }, }, options: [ @@ -65,12 +61,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - ], + resource: ['lead'], + operation: ['create'], }, }, }, @@ -82,19 +74,11 @@ export const leadFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'create', - ], + resource: ['lead'], + operation: ['create'], }, }, - options: [ - addressFixedCollection, - emailFixedCollection, - phoneNumbersFixedCollection, - ], + options: [addressFixedCollection, emailFixedCollection, phoneNumbersFixedCollection], }, // ---------------------------------------- @@ -109,12 +93,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'delete', - ], + resource: ['lead'], + operation: ['delete'], }, }, }, @@ -131,12 +111,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'get', - ], + resource: ['lead'], + operation: ['get'], }, }, }, @@ -152,12 +128,8 @@ export const leadFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'getAll', - ], + resource: ['lead'], + operation: ['getAll'], }, }, }, @@ -173,15 +145,9 @@ export const leadFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['lead'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -193,12 +159,8 @@ export const leadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'getAll', - ], + resource: ['lead'], + operation: ['getAll'], }, }, options: [ @@ -231,12 +193,8 @@ export const leadFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'update', - ], + resource: ['lead'], + operation: ['update'], }, }, }, @@ -248,12 +206,8 @@ export const leadFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'lead', - ], - operation: [ - 'update', - ], + resource: ['lead'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Copper/descriptions/OpportunityDescription.ts b/packages/nodes-base/nodes/Copper/descriptions/OpportunityDescription.ts index 91f116de2e10a..e0a896b8639f4 100644 --- a/packages/nodes-base/nodes/Copper/descriptions/OpportunityDescription.ts +++ b/packages/nodes-base/nodes/Copper/descriptions/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: [ @@ -59,12 +55,8 @@ export const opportunityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'create', - ], + resource: ['opportunity'], + operation: ['create'], }, }, }, @@ -76,12 +68,8 @@ export const opportunityFields: INodeProperties[] = [ description: 'ID of the customer source that generated this opportunity', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'create', - ], + resource: ['opportunity'], + operation: ['create'], }, }, }, @@ -93,12 +81,8 @@ export const opportunityFields: INodeProperties[] = [ description: 'ID of the primary company associated with this opportunity', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'create', - ], + resource: ['opportunity'], + operation: ['create'], }, }, }, @@ -115,12 +99,8 @@ export const opportunityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'delete', - ], + resource: ['opportunity'], + operation: ['delete'], }, }, }, @@ -137,12 +117,8 @@ export const opportunityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'get', - ], + resource: ['opportunity'], + operation: ['get'], }, }, }, @@ -158,12 +134,8 @@ export const opportunityFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'getAll', - ], + resource: ['opportunity'], + operation: ['getAll'], }, }, }, @@ -179,15 +151,9 @@ export const opportunityFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['opportunity'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -199,12 +165,8 @@ export const opportunityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'getAll', - ], + resource: ['opportunity'], + operation: ['getAll'], }, }, options: [ @@ -237,12 +199,8 @@ export const opportunityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'update', - ], + resource: ['opportunity'], + operation: ['update'], }, }, }, @@ -254,12 +212,8 @@ export const opportunityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'opportunity', - ], - operation: [ - 'update', - ], + resource: ['opportunity'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Copper/descriptions/PersonDescription.ts b/packages/nodes-base/nodes/Copper/descriptions/PersonDescription.ts index 21f00dbb122fc..c74193f196753 100644 --- a/packages/nodes-base/nodes/Copper/descriptions/PersonDescription.ts +++ b/packages/nodes-base/nodes/Copper/descriptions/PersonDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import { addressFixedCollection, @@ -16,9 +14,7 @@ export const personOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'person', - ], + resource: ['person'], }, }, options: [ @@ -65,12 +61,8 @@ export const personFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'create', - ], + resource: ['person'], + operation: ['create'], }, }, }, @@ -82,12 +74,8 @@ export const personFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'create', - ], + resource: ['person'], + operation: ['create'], }, }, options: [ @@ -122,12 +110,8 @@ export const personFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'delete', - ], + resource: ['person'], + operation: ['delete'], }, }, }, @@ -144,12 +128,8 @@ export const personFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'get', - ], + resource: ['person'], + operation: ['get'], }, }, }, @@ -165,12 +145,8 @@ export const personFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'getAll', - ], + resource: ['person'], + operation: ['getAll'], }, }, }, @@ -186,15 +162,9 @@ export const personFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['person'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -206,12 +176,8 @@ export const personFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'getAll', - ], + resource: ['person'], + operation: ['getAll'], }, }, options: [ @@ -237,12 +203,8 @@ export const personFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'update', - ], + resource: ['person'], + operation: ['update'], }, }, }, @@ -254,12 +216,8 @@ export const personFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'person', - ], - operation: [ - 'update', - ], + resource: ['person'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Copper/descriptions/ProjectDescription.ts b/packages/nodes-base/nodes/Copper/descriptions/ProjectDescription.ts index a62b4856a342c..5de802d215c76 100644 --- a/packages/nodes-base/nodes/Copper/descriptions/ProjectDescription.ts +++ b/packages/nodes-base/nodes/Copper/descriptions/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: [ @@ -59,12 +55,8 @@ export const projectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'create', - ], + resource: ['project'], + operation: ['create'], }, }, }, @@ -76,12 +68,8 @@ export const projectFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'create', - ], + resource: ['project'], + operation: ['create'], }, }, options: [ @@ -130,12 +118,8 @@ export const projectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'delete', - ], + resource: ['project'], + operation: ['delete'], }, }, }, @@ -152,12 +136,8 @@ export const projectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'get', - ], + resource: ['project'], + operation: ['get'], }, }, }, @@ -173,12 +153,8 @@ export const projectFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'getAll', - ], + resource: ['project'], + operation: ['getAll'], }, }, }, @@ -194,15 +170,9 @@ export const projectFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['project'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -214,12 +184,8 @@ export const projectFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'getAll', - ], + resource: ['project'], + operation: ['getAll'], }, }, options: [ @@ -245,12 +211,8 @@ export const projectFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'update', - ], + resource: ['project'], + operation: ['update'], }, }, }, @@ -262,12 +224,8 @@ export const projectFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'project', - ], - operation: [ - 'update', - ], + resource: ['project'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Copper/descriptions/TaskDescription.ts b/packages/nodes-base/nodes/Copper/descriptions/TaskDescription.ts index efb40ee608da8..ac9fb30d923d7 100644 --- a/packages/nodes-base/nodes/Copper/descriptions/TaskDescription.ts +++ b/packages/nodes-base/nodes/Copper/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,12 +54,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, }, @@ -75,12 +67,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, options: [ @@ -145,12 +133,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'delete', - ], + resource: ['task'], + operation: ['delete'], }, }, }, @@ -167,12 +151,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'get', - ], + resource: ['task'], + operation: ['get'], }, }, }, @@ -188,12 +168,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'], }, }, }, @@ -209,15 +185,9 @@ export const taskFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['task'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -229,12 +199,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, options: [ @@ -267,12 +233,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, }, @@ -284,12 +246,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Copper/descriptions/UserDescription.ts b/packages/nodes-base/nodes/Copper/descriptions/UserDescription.ts index 0c31575539b98..d09d7072588a1 100644 --- a/packages/nodes-base/nodes/Copper/descriptions/UserDescription.ts +++ b/packages/nodes-base/nodes/Copper/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: [ @@ -38,12 +34,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'], }, }, }, @@ -59,15 +51,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/Copper/utils/isoCountryCodes.ts b/packages/nodes-base/nodes/Copper/utils/isoCountryCodes.ts index dd5bce6f4c74f..9ee28fbf569e2 100644 --- a/packages/nodes-base/nodes/Copper/utils/isoCountryCodes.ts +++ b/packages/nodes-base/nodes/Copper/utils/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/Copper/utils/sharedFields.ts b/packages/nodes-base/nodes/Copper/utils/sharedFields.ts index 8221d1b61404f..43e8570125b4c 100644 --- a/packages/nodes-base/nodes/Copper/utils/sharedFields.ts +++ b/packages/nodes-base/nodes/Copper/utils/sharedFields.ts @@ -1,6 +1,4 @@ -import { - INodeProperties -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; // for companies, leads, persons export const addressFixedCollection: INodeProperties = { diff --git a/packages/nodes-base/nodes/Copper/utils/types.d.ts b/packages/nodes-base/nodes/Copper/utils/types.d.ts index 0c71e916cd3c2..62d935298e49e 100644 --- a/packages/nodes-base/nodes/Copper/utils/types.d.ts +++ b/packages/nodes-base/nodes/Copper/utils/types.d.ts @@ -1,23 +1,23 @@ export type EmailFixedCollection = { email?: { - emailFields: Array<{ email: string, category: string }> - } + emailFields: Array<{ email: string; category: string }>; + }; }; export type EmailsFixedCollection = { emails?: { - emailFields: Array<{ email: string, category: string }> - } + emailFields: Array<{ email: string; category: string }>; + }; }; export type PhoneNumbersFixedCollection = { phone_numbers?: { - phoneFields: object, - } + phoneFields: object; + }; }; export type AddressFixedCollection = { address?: { - addressFields: object - } -} + addressFields: object; + }; +}; diff --git a/packages/nodes-base/nodes/Cortex/AnalyzerDescriptions.ts b/packages/nodes-base/nodes/Cortex/AnalyzerDescriptions.ts index 3da45f38d4cfe..b2f78771ef621 100644 --- a/packages/nodes-base/nodes/Cortex/AnalyzerDescriptions.ts +++ b/packages/nodes-base/nodes/Cortex/AnalyzerDescriptions.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - TLP, -} from './AnalyzerInterface'; +import { TLP } from './AnalyzerInterface'; export const analyzersOperations: INodeProperties[] = [ { @@ -16,9 +12,7 @@ export const analyzersOperations: INodeProperties[] = [ description: 'Choose an operation', displayOptions: { show: { - resource: [ - 'analyzer', - ], + resource: ['analyzer'], }, }, default: 'execute', @@ -44,15 +38,12 @@ export const analyzerFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'analyzer', - ], - operation: [ - 'execute', - ], + resource: ['analyzer'], + operation: ['execute'], }, }, - description: 'Choose the analyzer. Choose from the list, or specify an ID using an expression.', + description: + 'Choose the analyzer. Choose from the list, or specify an ID using an expression.', default: '', }, { @@ -62,27 +53,20 @@ export const analyzerFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'analyzer', - ], - operation: [ - 'execute', - ], + resource: ['analyzer'], + operation: ['execute'], }, hide: { - analyzer: [ - '', - ], + analyzer: [''], }, }, typeOptions: { loadOptionsMethod: 'loadObservableOptions', - loadOptionsDependsOn: [ - 'analyzer', - ], + loadOptionsDependsOn: ['analyzer'], }, default: '', - description: 'Choose the observable type. Choose from the list, or specify an ID using an expression.', + description: + 'Choose the observable type. Choose from the list, or specify an ID using an expression.', }, // Observable type != file @@ -93,20 +77,12 @@ export const analyzerFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'analyzer', - ], - operation: [ - 'execute', - ], + resource: ['analyzer'], + operation: ['execute'], }, hide: { - observableType: [ - 'file', - ], - analyzer: [ - '', - ], + observableType: ['file'], + analyzer: [''], }, }, default: '', @@ -120,15 +96,9 @@ export const analyzerFields: INodeProperties[] = [ required: true, displayOptions: { show: { - observableType: [ - 'file', - ], - resource: [ - 'analyzer', - ], - operation: [ - 'execute', - ], + observableType: ['file'], + resource: ['analyzer'], + operation: ['execute'], }, }, description: 'Name of the binary property to which to write the data of the read file', @@ -139,20 +109,12 @@ export const analyzerFields: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'analyzer', - ], - operation: [ - 'execute', - ], + resource: ['analyzer'], + operation: ['execute'], }, hide: { - observableType: [ - '', - ], - analyzer: [ - '', - ], + observableType: [''], + analyzer: [''], }, }, options: [ @@ -167,7 +129,8 @@ export const analyzerFields: INodeProperties[] = [ { name: 'Amber', value: TLP.amber, - }, { + }, + { name: 'Red', value: TLP.red, }, @@ -183,12 +146,8 @@ export const analyzerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'analyzer', - ], - operation: [ - 'execute', - ], + resource: ['analyzer'], + operation: ['execute'], }, }, options: [ @@ -204,7 +163,8 @@ export const analyzerFields: INodeProperties[] = [ name: 'timeout', type: 'number', default: 3, - description: 'Timeout to wait for the report in case it is not available at the time the query was made', + description: + 'Timeout to wait for the report in case it is not available at the time the query was made', }, ], }, diff --git a/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts b/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts index 842f84f4f2eb0..da523b4b1540f 100644 --- a/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts +++ b/packages/nodes-base/nodes/Cortex/AnalyzerInterface.ts @@ -1,6 +1,4 @@ -import { - IDataObject, -} from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export enum JobStatus { WAITING = 'Waiting', diff --git a/packages/nodes-base/nodes/Cortex/Cortex.node.ts b/packages/nodes-base/nodes/Cortex/Cortex.node.ts index 442b643cc8672..300949e6489c2 100644 --- a/packages/nodes-base/nodes/Cortex/Cortex.node.ts +++ b/packages/nodes-base/nodes/Cortex/Cortex.node.ts @@ -1,18 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - cortexApiRequest, - getEntityLabel, - prepareParameters, - splitTags, -} from './GenericFunctions'; +import { cortexApiRequest, getEntityLabel, prepareParameters, splitTags } from './GenericFunctions'; -import { - analyzerFields, - analyzersOperations, -} from './AnalyzerDescriptions'; +import { analyzerFields, analyzersOperations } from './AnalyzerDescriptions'; import { IBinaryData, @@ -25,27 +15,15 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - responderFields, - respondersOperations, -} from './ResponderDescription'; +import { responderFields, respondersOperations } from './ResponderDescription'; -import { - jobFields, - jobOperations, -} from './JobDescription'; +import { jobFields, jobOperations } from './JobDescription'; -import { - upperFirst, -} from 'lodash'; +import { upperFirst } from 'lodash'; -import { - IJob, -} from './AnalyzerInterface'; +import { IJob } from './AnalyzerInterface'; -import { - createHash, -} from 'crypto'; +import { createHash } from 'crypto'; import * as changeCase from 'change-case'; @@ -106,7 +84,6 @@ export class Cortex implements INodeType { methods = { loadOptions: { - async loadActiveAnalyzers(this: ILoadOptionsFunctions): Promise { // request the enabled analyzers from instance const requestResult = await cortexApiRequest.call( @@ -130,11 +107,7 @@ export class Cortex implements INodeType { async loadActiveResponders(this: ILoadOptionsFunctions): Promise { // request the enabled responders from instance - const requestResult = await cortexApiRequest.call( - this, - 'GET', - `/responder`, - ); + const requestResult = await cortexApiRequest.call(this, 'GET', `/responder`); const returnData: INodePropertyOptions[] = []; for (const responder of requestResult) { @@ -159,12 +132,10 @@ export class Cortex implements INodeType { // parse supported observable types into options const returnData: INodePropertyOptions[] = []; for (const dataType of requestResult.dataTypeList) { - returnData.push( - { - name: upperFirst(dataType as string), - value: dataType as string, - }, - ); + returnData.push({ + name: upperFirst(dataType as string), + value: dataType as string, + }); } return returnData; }, @@ -180,16 +151,13 @@ export class Cortex implements INodeType { // parse the accepted dataType into options const returnData: INodePropertyOptions[] = []; for (const dataType of requestResult.dataTypeList) { - returnData.push( - { - value: (dataType as string).split(':')[1], - name: changeCase.capitalCase((dataType as string).split(':')[1]), - }, - ); + returnData.push({ + value: (dataType as string).split(':')[1], + name: changeCase.capitalCase((dataType as string).split(':')[1]), + }); } return returnData; }, - }, }; @@ -204,11 +172,9 @@ export class Cortex implements INodeType { for (let i = 0; i < length; i++) { try { - if (resource === 'analyzer') { //https://github.com/TheHive-Project/CortexDocs/blob/master/api/api-guide.md#run if (operation === 'execute') { - let force = false; const analyzer = this.getNodeParameter('analyzer', i) as string; @@ -229,17 +195,22 @@ export class Cortex implements INodeType { } if (observableType === '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 = 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); @@ -260,7 +231,7 @@ export class Cortex implements INodeType { }, }; - responseData = await cortexApiRequest.call( + responseData = (await cortexApiRequest.call( this, 'POST', `/analyzer/${analyzer.split('::')[0]}/run`, @@ -268,22 +239,21 @@ export class Cortex implements INodeType { { force }, '', options, - ) as IJob; + )) as IJob; continue; - } else { const observableValue = this.getNodeParameter('observableValue', i) as string; body.data = observableValue; - responseData = await cortexApiRequest.call( + responseData = (await cortexApiRequest.call( this, 'POST', `/analyzer/${analyzer.split('::')[0]}/run`, body, { force }, - ) as IJob; + )) as IJob; } if (additionalFields.timeout) { @@ -301,25 +271,15 @@ export class Cortex implements INodeType { if (resource === 'job') { //https://github.com/TheHive-Project/CortexDocs/blob/master/api/api-guide.md#get-details-1 if (operation === 'get') { - const jobId = this.getNodeParameter('jobId', i) as string; - responseData = await cortexApiRequest.call( - this, - 'GET', - `/job/${jobId}`, - ); + responseData = await cortexApiRequest.call(this, 'GET', `/job/${jobId}`); } //https://github.com/TheHive-Project/CortexDocs/blob/master/api/api-guide.md#get-details-and-report if (operation === 'report') { - const jobId = this.getNodeParameter('jobId', i) as string; - responseData = await cortexApiRequest.call( - this, - 'GET', - `/job/${jobId}/report`, - ); + responseData = await cortexApiRequest.call(this, 'GET', `/job/${jobId}/report`); } } @@ -332,7 +292,6 @@ export class Cortex implements INodeType { const isJSON = this.getNodeParameter('jsonObject', i) as boolean; let body: IDataObject; - if (isJSON) { const entityJson = JSON.parse(this.getNodeParameter('objectData', i) as string); @@ -346,10 +305,9 @@ export class Cortex implements INodeType { message: entityJson.message || '', parameters: [], }; - } else { - - const values = (this.getNodeParameter('parameters', i) as IDataObject).values as IDataObject; + const values = (this.getNodeParameter('parameters', i) as IDataObject) + .values as IDataObject; body = { responderId, @@ -364,15 +322,12 @@ export class Cortex implements INodeType { const artifacts = (body.data as IDataObject).artifacts as IDataObject; if (artifacts) { - const artifactValues = (artifacts as IDataObject).artifactValues as IDataObject[]; if (artifactValues) { - const artifactData = []; for (const artifactvalue of artifactValues) { - const element: IDataObject = {}; element.message = artifactvalue.message as string; @@ -384,17 +339,24 @@ export class Cortex 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; @@ -413,19 +375,28 @@ export class Cortex implements INodeType { // deal with file observable if ((body.data as IDataObject).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 = (body.data as IDataObject).binaryPropertyName as string; + const binaryPropertyName = (body.data as IDataObject) + .binaryPropertyName 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); + const fileBufferData = await this.helpers.getBinaryDataBuffer( + i, + binaryPropertyName, + ); const sha256 = createHash('sha256').update(fileBufferData).digest('hex'); (body.data as IDataObject).attachment = { @@ -448,14 +419,13 @@ export class Cortex implements INodeType { label: getEntityLabel(body.data as IDataObject), ...body, }; - } - responseData = await cortexApiRequest.call( + responseData = (await cortexApiRequest.call( this, 'POST', `/responder/${responderId}/run`, body, - ) as IJob; + )) as IJob; } } @@ -464,7 +434,6 @@ export class Cortex 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/Cortex/GenericFunctions.ts b/packages/nodes-base/nodes/Cortex/GenericFunctions.ts index 2c23f68c85970..722cda2199616 100644 --- a/packages/nodes-base/nodes/Cortex/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cortex/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -9,14 +7,21 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; import moment from 'moment'; -export async function cortexApiRequest(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 cortexApiRequest( + 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 credentials = await this.getCredentials('cortexApi'); let options: OptionsWithUri = { @@ -26,7 +31,6 @@ export async function cortexApiRequest(this: IHookFunctions | IExecuteFunctions uri: uri || `${credentials.host}/api${resource}`, body, json: true, - }; if (Object.keys(option).length !== 0) { options = Object.assign({}, options, option); @@ -53,7 +57,7 @@ export function getEntityLabel(entity: IDataObject): string { break; case 'case_artifact': //@ts-ignore - label = `[${entity.dataType}] ${entity.data ? entity.data : (entity.attachment.name)}`; + label = `[${entity.dataType}] ${entity.data ? entity.data : entity.attachment.name}`; break; case 'alert': label = `[${entity.source}:${entity.sourceRef}] ${entity.title}`; @@ -74,7 +78,7 @@ export function getEntityLabel(entity: IDataObject): string { } export function splitTags(tags: string): string[] { - return tags.split(',').filter(tag => tag !== ' ' && tag); + return tags.split(',').filter((tag) => tag !== ' ' && tag); } export function prepareParameters(values: IDataObject): IDataObject { diff --git a/packages/nodes-base/nodes/Cortex/JobDescription.ts b/packages/nodes-base/nodes/Cortex/JobDescription.ts index 7aeccbf570909..1505e0632b39c 100644 --- a/packages/nodes-base/nodes/Cortex/JobDescription.ts +++ b/packages/nodes-base/nodes/Cortex/JobDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const jobOperations: INodeProperties[] = [ { @@ -12,9 +10,7 @@ export const jobOperations: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'job', - ], + resource: ['job'], }, }, options: [ @@ -43,13 +39,8 @@ export const jobFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'job', - ], - operation: [ - 'get', - 'report', - ], + resource: ['job'], + operation: ['get', 'report'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Cortex/ResponderDescription.ts b/packages/nodes-base/nodes/Cortex/ResponderDescription.ts index 26d502bda57c0..ada96a04f803b 100644 --- a/packages/nodes-base/nodes/Cortex/ResponderDescription.ts +++ b/packages/nodes-base/nodes/Cortex/ResponderDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - TLP, -} from './AnalyzerInterface'; +import { TLP } from './AnalyzerInterface'; export const respondersOperations: INodeProperties[] = [ { @@ -16,9 +12,7 @@ export const respondersOperations: INodeProperties[] = [ description: 'Choose an operation', displayOptions: { show: { - resource: [ - 'responder', - ], + resource: ['responder'], }, }, options: [ @@ -45,12 +39,11 @@ export const responderFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'responder', - ], + resource: ['responder'], }, }, - description: 'Choose the responder. Choose from the list, or specify an ID using an expression.', + description: + 'Choose the responder. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Entity Type Name or ID', @@ -59,19 +52,16 @@ export const responderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'responder', - ], + resource: ['responder'], }, }, typeOptions: { loadOptionsMethod: 'loadDataTypeOptions', - loadOptionsDependsOn: [ - 'responder', - ], + loadOptionsDependsOn: ['responder'], }, default: '', - description: 'Choose the Data type. Choose from the list, or specify an ID using an expression.', + description: + 'Choose the Data type. Choose from the list, or specify an ID using an expression.', }, { displayName: 'JSON Parameters', @@ -82,9 +72,7 @@ export const responderFields: INodeProperties[] = [ description: 'Choose between providing JSON object or seperated attributes', displayOptions: { show: { - resource: [ - 'responder', - ], + resource: ['responder'], }, }, }, @@ -95,12 +83,8 @@ export const responderFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'responder', - ], - jsonObject: [ - true, - ], + resource: ['responder'], + jsonObject: [true], }, }, default: '', @@ -135,7 +119,8 @@ export const responderFields: INodeProperties[] = [ name: 'owner', type: 'string', default: '', - description: 'User who owns the case. This is automatically set to current user when status is set to InProgress.', + description: + 'User who owns the case. This is automatically set to current user when status is set to InProgress.', }, { displayName: 'Severity', @@ -208,30 +193,16 @@ export const responderFields: INodeProperties[] = [ }, ], typeOptions: { - loadOptionsDependsOn: [ - 'entityType', - ], + loadOptionsDependsOn: ['entityType'], }, displayOptions: { show: { - resource: [ - 'responder', - ], - jsonObject: [ - false, - ], - entityType: [ - 'case', - ], + resource: ['responder'], + jsonObject: [false], + entityType: ['case'], }, hide: { - entityType: [ - '', - 'alert', - 'case_artifact', - 'case_task', - 'case_task_log', - ], + entityType: ['', 'alert', 'case_artifact', 'case_task', 'case_task_log'], }, }, default: {}, @@ -267,9 +238,7 @@ export const responderFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - dataType: [ - 'file', - ], + dataType: ['file'], }, }, default: 'data', @@ -280,9 +249,7 @@ export const responderFields: INodeProperties[] = [ type: 'string', displayOptions: { hide: { - dataType: [ - 'file', - ], + dataType: ['file'], }, }, default: '', @@ -497,33 +464,17 @@ export const responderFields: INodeProperties[] = [ }, ], typeOptions: { - loadOptionsDependsOn: [ - 'entityType', - ], + loadOptionsDependsOn: ['entityType'], }, displayOptions: { show: { - resource: [ - 'responder', - ], - jsonObject: [ - false, - ], - entityType: [ - 'alert', - ], + resource: ['responder'], + jsonObject: [false], + entityType: ['alert'], }, hide: { - responder: [ - '', - ], - entityType: [ - '', - 'case', - 'case_artifact', - 'case_task', - 'case_task_log', - ], + responder: [''], + entityType: ['', 'case', 'case_artifact', 'case_task', 'case_task_log'], }, }, default: {}, @@ -545,9 +496,7 @@ export const responderFields: INodeProperties[] = [ default: 'data', displayOptions: { show: { - dataType: [ - 'file', - ], + dataType: ['file'], }, }, description: 'Name of the binary property which contains the attachement data', @@ -559,9 +508,7 @@ export const responderFields: INodeProperties[] = [ default: '', displayOptions: { hide: { - dataType: [ - 'file', - ], + dataType: ['file'], }, }, }, @@ -683,7 +630,8 @@ export const responderFields: INodeProperties[] = [ { name: 'Amber', value: TLP.amber, - }, { + }, + { name: 'Red', value: TLP.red, }, @@ -694,33 +642,17 @@ export const responderFields: INodeProperties[] = [ }, ], typeOptions: { - loadOptionsDependsOn: [ - 'entityType', - ], + loadOptionsDependsOn: ['entityType'], }, displayOptions: { show: { - resource: [ - 'responder', - ], - jsonObject: [ - false, - ], - entityType: [ - 'case_artifact', - ], + resource: ['responder'], + jsonObject: [false], + entityType: ['case_artifact'], }, hide: { - responder: [ - '', - ], - entityType: [ - '', - 'case', - 'alert', - 'case_task', - 'case_task_log', - ], + responder: [''], + entityType: ['', 'case', 'alert', 'case_task', 'case_task_log'], }, }, default: {}, @@ -776,33 +708,17 @@ export const responderFields: INodeProperties[] = [ }, ], typeOptions: { - loadOptionsDependsOn: [ - 'entityType', - ], + loadOptionsDependsOn: ['entityType'], }, displayOptions: { show: { - resource: [ - 'responder', - ], - jsonObject: [ - false, - ], - entityType: [ - 'case_task', - ], + resource: ['responder'], + jsonObject: [false], + entityType: ['case_task'], }, hide: { - responder: [ - '', - ], - entityType: [ - '', - 'case', - 'alert', - 'case_artifact', - 'case_task_log', - ], + responder: [''], + entityType: ['', 'case', 'alert', 'case_artifact', 'case_task_log'], }, }, default: {}, @@ -851,33 +767,17 @@ export const responderFields: INodeProperties[] = [ }, ], typeOptions: { - loadOptionsDependsOn: [ - 'entityType', - ], + loadOptionsDependsOn: ['entityType'], }, displayOptions: { show: { - resource: [ - 'responder', - ], - jsonObject: [ - false, - ], - entityType: [ - 'case_task_log', - ], + resource: ['responder'], + jsonObject: [false], + entityType: ['case_task_log'], }, hide: { - responder: [ - '', - ], - entityType: [ - '', - 'case', - 'alert', - 'case_artifact', - 'case_task', - ], + responder: [''], + entityType: ['', 'case', 'alert', 'case_artifact', 'case_task'], }, }, default: {}, diff --git a/packages/nodes-base/nodes/CrateDb/CrateDb.node.ts b/packages/nodes-base/nodes/CrateDb/CrateDb.node.ts index b5fdfb2b0ca19..8848300c24385 100644 --- a/packages/nodes-base/nodes/CrateDb/CrateDb.node.ts +++ b/packages/nodes-base/nodes/CrateDb/CrateDb.node.ts @@ -85,7 +85,8 @@ export class CrateDb 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.', }, // ---------------------------------- @@ -128,7 +129,8 @@ export class CrateDb 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', }, // ---------------------------------- @@ -172,7 +174,8 @@ export class CrateDb 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', @@ -185,7 +188,8 @@ export class CrateDb 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', }, // ---------------------------------- @@ -230,7 +234,8 @@ export class CrateDb 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', @@ -238,14 +243,13 @@ export class CrateDb 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', }, ], }, @@ -279,7 +283,13 @@ export class CrateDb 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') { @@ -287,7 +297,13 @@ export class CrateDb 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({ @@ -300,24 +316,34 @@ export class CrateDb implements INodeType { // ---------------------------------- const additionalFields = this.getNodeParameter('additionalFields', 0) as IDataObject; - const mode = additionalFields.mode ?? 'multiple' as string; + const mode = additionalFields.mode ?? ('multiple' as string); - if(mode === 'independently') { - const updateItems = await pgUpdate(this.getNodeParameter, pgp, db, items, this.continueOnFail()); + if (mode === 'independently') { + const updateItems = await pgUpdate( + this.getNodeParameter, + pgp, + db, + items, + this.continueOnFail(), + ); returnItems = this.helpers.returnJsonArray(updateItems); - } else if(mode === 'multiple') { + } else if (mode === 'multiple') { // Crate db does not support multiple-update queries // Therefore we cannot invoke `pgUpdate` using multiple mode // so we have to call multiple updates manually here const table = this.getNodeParameter('table', 0) as string; const schema = this.getNodeParameter('schema', 0) as string; - const updateKeys = (this.getNodeParameter('updateKey', 0) as string).split(',').map(column => column.trim()); - const columns = (this.getNodeParameter('columns', 0) as string).split(',').map(column => column.trim()); + const updateKeys = (this.getNodeParameter('updateKey', 0) as string) + .split(',') + .map((column) => column.trim()); + const columns = (this.getNodeParameter('columns', 0) as string) + .split(',') + .map((column) => column.trim()); const queryColumns = columns.slice(); - updateKeys.forEach(updateKey => { + updateKeys.forEach((updateKey) => { if (!queryColumns.includes(updateKey)) { columns.unshift(updateKey); queryColumns.unshift('?' + updateKey); @@ -326,24 +352,36 @@ export class CrateDb implements INodeType { const cs = new pgp.helpers.ColumnSet(queryColumns, { table: { table, schema } }); - const where = ' WHERE ' + updateKeys.map(updateKey => pgp.as.name(updateKey) + ' = ${' + updateKey + '}').join(' AND '); + const where = + ' WHERE ' + + updateKeys + .map((updateKey) => pgp.as.name(updateKey) + ' = ${' + updateKey + '}') + .join(' AND '); // updateKeyValue = item.json[updateKey] as string | number; // if (updateKeyValue === undefined) { // throw new NodeOperationError(this.getNode(), 'No value found for update key!'); // } - const returning = generateReturning(pgp, this.getNodeParameter('returnFields', 0) as string); - const queries:string[] = []; + const returning = generateReturning( + pgp, + this.getNodeParameter('returnFields', 0) as string, + ); + const queries: string[] = []; for (let i = 0; i < items.length; i++) { const itemCopy = getItemCopy(items[i], columns); - queries.push(pgp.helpers.update(itemCopy, cs) + pgp.as.format(where, itemCopy) + returning); + queries.push( + pgp.helpers.update(itemCopy, cs) + pgp.as.format(where, itemCopy) + returning, + ); } const updateItems = await db.multi(pgp.helpers.concat(queries)); returnItems = this.helpers.returnJsonArray(getItemsCopy(items, columns) as IDataObject[]); } } 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/Cron/Cron.node.ts b/packages/nodes-base/nodes/Cron/Cron.node.ts index 0220bd2135ee3..5d018a126911c 100644 --- a/packages/nodes-base/nodes/Cron/Cron.node.ts +++ b/packages/nodes-base/nodes/Cron/Cron.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'; import { CronJob } from 'cron'; @@ -16,7 +12,6 @@ interface TriggerTime { [key: string]: string | number; } - export class Cron implements INodeType { description: INodeTypeDescription = { displayName: 'Cron', @@ -26,7 +21,8 @@ export class Cron implements INodeType { version: 1, description: 'Triggers the workflow at a specific time', eventTriggerDescription: '', - activationMessage: 'Your cron trigger will now trigger executions on the schedule you have defined.', + activationMessage: + 'Your cron trigger will now trigger executions on the schedule you have defined.', defaults: { name: 'Cron', color: '#00FF00', @@ -36,7 +32,8 @@ export class Cron 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: '', @@ -105,12 +102,7 @@ export class Cron implements INodeType { }, displayOptions: { hide: { - mode: [ - 'custom', - 'everyHour', - 'everyMinute', - 'everyX', - ], + mode: ['custom', 'everyHour', 'everyMinute', 'everyX'], }, }, default: 14, @@ -126,11 +118,7 @@ export class Cron implements INodeType { }, displayOptions: { hide: { - mode: [ - 'custom', - 'everyMinute', - 'everyX', - ], + mode: ['custom', 'everyMinute', 'everyX'], }, }, default: 0, @@ -142,9 +130,7 @@ export class Cron implements INodeType { type: 'number', displayOptions: { show: { - mode: [ - 'everyMonth', - ], + mode: ['everyMonth'], }, }, typeOptions: { @@ -160,9 +146,7 @@ export class Cron implements INodeType { type: 'options', displayOptions: { show: { - mode: [ - 'everyWeek', - ], + mode: ['everyWeek'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items @@ -205,13 +189,12 @@ export class Cron implements INodeType { type: 'string', displayOptions: { show: { - mode: [ - 'custom', - ], + mode: ['custom'], }, }, default: '* * * * * *', - description: 'Use custom cron expression. Values and ranges as follows:
  • Seconds: 0-59
  • Minutes: 0 - 59
  • Hours: 0 - 23
  • Day of Month: 1 - 31
  • Months: 0 - 11 (Jan - Dec)
  • Day of Week: 0 - 6 (Sun - Sat)
.', + description: + 'Use custom cron expression. Values and ranges as follows:
  • Seconds: 0-59
  • Minutes: 0 - 59
  • Hours: 0 - 23
  • Day of Month: 1 - 31
  • Months: 0 - 11 (Jan - Dec)
  • Day of Week: 0 - 6 (Sun - Sat)
.', }, { displayName: 'Value', @@ -223,9 +206,7 @@ export class Cron implements INodeType { }, displayOptions: { show: { - mode: [ - 'everyX', - ], + mode: ['everyX'], }, }, default: 2, @@ -237,9 +218,7 @@ export class Cron implements INodeType { type: 'options', displayOptions: { show: { - mode: [ - 'everyX', - ], + mode: ['everyX'], }, }, options: [ @@ -262,22 +241,19 @@ export class Cron implements INodeType { ], }; - - async trigger(this: ITriggerFunctions): Promise { - const triggerTimes = this.getNodeParameter('triggerTimes') as unknown as { item: TriggerTime[]; }; // Define the order the cron-time-parameter appear const parameterOrder = [ - 'second', // 0 - 59 - 'minute', // 0 - 59 - 'hour', // 0 - 23 + 'second', // 0 - 59 + 'minute', // 0 - 59 + 'hour', // 0 - 23 'dayOfMonth', // 1 - 31 - 'month', // 0 - 11(Jan - Dec) - 'weekday', // 0 - 6(Sun - Sat) + 'month', // 0 - 11(Jan - Dec) + 'weekday', // 0 - 6(Sun - Sat) ]; // Get all the trigger times diff --git a/packages/nodes-base/nodes/Crypto/Crypto.node.ts b/packages/nodes-base/nodes/Crypto/Crypto.node.ts index 2b1941c6f6622..72c03e1b0f157 100644 --- a/packages/nodes-base/nodes/Crypto/Crypto.node.ts +++ b/packages/nodes-base/nodes/Crypto/Crypto.node.ts @@ -1,10 +1,6 @@ -import { - set, -} from 'lodash'; +import { set } from 'lodash'; -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ILoadOptionsFunctions, @@ -79,9 +75,7 @@ export class Crypto implements INodeType { name: 'type', displayOptions: { show: { - action: [ - 'hash', - ], + action: ['hash'], }, }, type: 'options', @@ -112,9 +106,7 @@ export class Crypto implements INodeType { name: 'value', displayOptions: { show: { - action: [ - 'hash', - ], + action: ['hash'], }, }, type: 'string', @@ -130,9 +122,7 @@ export class Crypto implements INodeType { required: true, displayOptions: { show: { - action: [ - 'hash', - ], + action: ['hash'], }, }, description: 'Name of the property to which to write the hash', @@ -142,9 +132,7 @@ export class Crypto implements INodeType { name: 'encoding', displayOptions: { show: { - action: [ - 'hash', - ], + action: ['hash'], }, }, type: 'options', @@ -166,9 +154,7 @@ export class Crypto implements INodeType { name: 'type', displayOptions: { show: { - action: [ - 'hmac', - ], + action: ['hmac'], }, }, type: 'options', @@ -199,9 +185,7 @@ export class Crypto implements INodeType { name: 'value', displayOptions: { show: { - action: [ - 'hmac', - ], + action: ['hmac'], }, }, type: 'string', @@ -217,9 +201,7 @@ export class Crypto implements INodeType { required: true, displayOptions: { show: { - action: [ - 'hmac', - ], + action: ['hmac'], }, }, description: 'Name of the property to which to write the hmac', @@ -229,9 +211,7 @@ export class Crypto implements INodeType { name: 'secret', displayOptions: { show: { - action: [ - 'hmac', - ], + action: ['hmac'], }, }, type: 'string', @@ -243,9 +223,7 @@ export class Crypto implements INodeType { name: 'encoding', displayOptions: { show: { - action: [ - 'hmac', - ], + action: ['hmac'], }, }, type: 'options', @@ -267,9 +245,7 @@ export class Crypto implements INodeType { name: 'value', displayOptions: { show: { - action: [ - 'sign', - ], + action: ['sign'], }, }, type: 'string', @@ -285,9 +261,7 @@ export class Crypto implements INodeType { required: true, displayOptions: { show: { - action: [ - 'sign', - ], + action: ['sign'], }, }, description: 'Name of the property to which to write the signed value', @@ -297,13 +271,12 @@ export class Crypto implements INodeType { name: 'algorithm', displayOptions: { show: { - action: [ - 'sign', - ], + action: ['sign'], }, }, type: 'options', - 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: 'getHashes', }, @@ -315,9 +288,7 @@ export class Crypto implements INodeType { name: 'encoding', displayOptions: { show: { - action: [ - 'sign', - ], + action: ['sign'], }, }, type: 'options', @@ -339,9 +310,7 @@ export class Crypto implements INodeType { name: 'privateKey', displayOptions: { show: { - action: [ - 'sign', - ], + action: ['sign'], }, }, type: 'string', @@ -360,9 +329,7 @@ export class Crypto implements INodeType { required: true, displayOptions: { show: { - action: [ - 'generate', - ], + action: ['generate'], }, }, description: 'Name of the property to which to write the random string', @@ -372,9 +339,7 @@ export class Crypto implements INodeType { name: 'encodingType', displayOptions: { show: { - action: [ - 'generate', - ], + action: ['generate'], }, }, type: 'options', @@ -408,14 +373,8 @@ export class Crypto implements INodeType { description: 'Length of the generated string', displayOptions: { show: { - action: [ - 'generate', - ], - encodingType: [ - 'ascii', - 'base64', - 'hex', - ], + action: ['generate'], + encodingType: ['ascii', 'base64', 'hex'], }, }, }, @@ -451,9 +410,7 @@ export class Crypto implements INodeType { let item: INodeExecutionData; for (let i = 0; i < length; i++) { - try { - item = items[i]; const dataPropertyName = this.getNodeParameter('dataPropertyName', i) as string; const value = this.getNodeParameter('value', i, '') as string; @@ -466,9 +423,14 @@ export class Crypto implements INodeType { } else { const stringLength = this.getNodeParameter('stringLength', i) as number; if (encodingType === 'base64') { - newValue = randomBytes(stringLength).toString(encodingType as BufferEncoding).replace(/\W/g, '').slice(0, stringLength); + newValue = randomBytes(stringLength) + .toString(encodingType as BufferEncoding) + .replace(/\W/g, '') + .slice(0, stringLength); } else { - newValue = randomBytes(stringLength).toString(encodingType as BufferEncoding).slice(0, stringLength); + newValue = randomBytes(stringLength) + .toString(encodingType as BufferEncoding) + .slice(0, stringLength); } } } @@ -519,7 +481,6 @@ export class Crypto implements INodeType { set(newItem, `json.${dataPropertyName}`, newValue); returnData.push(newItem); - } catch (error) { if (this.continueOnFail()) { returnData.push({ diff --git a/packages/nodes-base/nodes/CustomerIo/CampaignDescription.ts b/packages/nodes-base/nodes/CustomerIo/CampaignDescription.ts index 53658aae92b40..70b8773ba2234 100644 --- a/packages/nodes-base/nodes/CustomerIo/CampaignDescription.ts +++ b/packages/nodes-base/nodes/CustomerIo/CampaignDescription.ts @@ -8,9 +8,7 @@ export const campaignOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'campaign', - ], + resource: ['campaign'], }, }, options: [ @@ -46,12 +44,8 @@ export const campaignFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'get', - ], + resource: ['campaign'], + operation: ['get'], }, }, description: 'The unique identifier for the campaign', @@ -67,12 +61,8 @@ export const campaignFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'getMetrics', - ], + resource: ['campaign'], + operation: ['getMetrics'], }, }, description: 'The unique identifier for the campaign', @@ -84,12 +74,8 @@ export const campaignFields: INodeProperties[] = [ default: 'days', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'getMetrics', - ], + resource: ['campaign'], + operation: ['getMetrics'], }, }, description: 'Specify metric period', @@ -119,12 +105,8 @@ export const campaignFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'getMetrics', - ], + resource: ['campaign'], + operation: ['getMetrics'], }, }, }, @@ -136,15 +118,9 @@ export const campaignFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'getMetrics', - ], - jsonParameters: [ - false, - ], + resource: ['campaign'], + operation: ['getMetrics'], + jsonParameters: [false], }, }, options: [ @@ -153,7 +129,8 @@ export const campaignFields: INodeProperties[] = [ name: 'steps', type: 'number', default: 0, - description: 'Integer specifying how many steps to return. Defaults to the maximum number of timeperiods available, or 12 when using the months period. Maximum timeperiods available are 24 hours, 45 days, 12 weeks and 120 months', + description: + 'Integer specifying how many steps to return. Defaults to the maximum number of timeperiods available, or 12 when using the months period. Maximum timeperiods available are 24 hours, 45 days, 12 weeks and 120 months', typeOptions: { minValue: 0, maxValue: 120, diff --git a/packages/nodes-base/nodes/CustomerIo/CustomerDescription.ts b/packages/nodes-base/nodes/CustomerIo/CustomerDescription.ts index 3310230c21d6c..80d66465b368b 100644 --- a/packages/nodes-base/nodes/CustomerIo/CustomerDescription.ts +++ b/packages/nodes-base/nodes/CustomerIo/CustomerDescription.ts @@ -8,16 +8,15 @@ export const customerOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'customer', - ], + resource: ['customer'], }, }, options: [ { name: 'Create or Update', value: 'upsert', - description: 'Create a new customer, or update the current one if it already exists (upsert)', + description: + 'Create a new customer, or update the current one if it already exists (upsert)', action: 'Create or update a customer', }, { @@ -32,7 +31,6 @@ export const customerOperations: INodeProperties[] = [ ]; export const customerFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* customer:delete */ /* -------------------------------------------------------------------------- */ @@ -44,12 +42,8 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'delete', - ], + resource: ['customer'], + operation: ['delete'], }, }, description: 'The unique identifier for the customer', @@ -66,12 +60,8 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'upsert', - ], + resource: ['customer'], + operation: ['upsert'], }, }, description: 'The unique identifier for the customer', @@ -83,12 +73,8 @@ export const customerFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'upsert', - ], + resource: ['customer'], + operation: ['upsert'], }, }, }, @@ -102,18 +88,13 @@ export const customerFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'upsert', - ], - jsonParameters: [ - true, - ], + resource: ['customer'], + operation: ['upsert'], + jsonParameters: [true], }, }, - description: 'Object of values to set as described here', + description: + 'Object of values to set as described here', }, { displayName: 'Additional Fields', @@ -123,15 +104,9 @@ export const customerFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'customer', - ], - operation: [ - 'upsert', - ], - jsonParameters: [ - false, - ], + resource: ['customer'], + operation: ['upsert'], + jsonParameters: [false], }, }, options: [ diff --git a/packages/nodes-base/nodes/CustomerIo/CustomerIo.node.ts b/packages/nodes-base/nodes/CustomerIo/CustomerIo.node.ts index bcd1a43b78976..581b166ebefe6 100644 --- a/packages/nodes-base/nodes/CustomerIo/CustomerIo.node.ts +++ b/packages/nodes-base/nodes/CustomerIo/CustomerIo.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, INodeExecutionData, @@ -8,27 +6,11 @@ import { INodeTypeDescription, NodeOperationError, } from 'n8n-workflow'; -import { - customerIoApiRequest, - validateJSON, -} from './GenericFunctions'; -import { - campaignFields, - campaignOperations, -} from './CampaignDescription'; -import { - customerFields, - customerOperations, -} from './CustomerDescription'; -import { - eventFields, - eventOperations, -} from './EventDescription'; -import { - segmentFields, - segmentOperations, -} from './SegmentDescription'; - +import { customerIoApiRequest, validateJSON } from './GenericFunctions'; +import { campaignFields, campaignOperations } from './CampaignDescription'; +import { customerFields, customerOperations } from './CustomerDescription'; +import { eventFields, eventOperations } from './EventDescription'; +import { segmentFields, segmentOperations } from './SegmentDescription'; export class CustomerIo implements INodeType { description: INodeTypeDescription = { @@ -100,9 +82,7 @@ export class CustomerIo implements INodeType { let responseData; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'campaign') { if (operation === 'get') { const campaignId = this.getNodeParameter('campaignId', i) as number; @@ -124,16 +104,20 @@ export class CustomerIo 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 { @@ -162,22 +146,25 @@ export class CustomerIo implements INodeType { } if (resource === 'customer') { - if (operation === 'upsert') { const id = this.getNodeParameter('id', i) as number; 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 { @@ -186,7 +173,7 @@ export class CustomerIo implements INodeType { if (additionalFields.customProperties) { const data: any = {}; // tslint:disable-line:no-any //@ts-ignore - additionalFields.customProperties.customProperty.map(property => { + additionalFields.customProperties.customProperty.map((property) => { data[property.key] = property.value; }); @@ -233,14 +220,20 @@ export class CustomerIo implements INodeType { body.name = eventName; 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 { @@ -249,7 +242,7 @@ export class CustomerIo implements INodeType { if (additionalFields.customAttributes) { //@ts-ignore - additionalFields.customAttributes.customAttribute.map(property => { + additionalFields.customAttributes.customAttribute.map((property) => { data[property.key] = property.value; }); } @@ -276,16 +269,20 @@ export class CustomerIo implements INodeType { body.name = eventName; 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 { @@ -294,7 +291,7 @@ export class CustomerIo implements INodeType { if (additionalFields.customAttributes) { //@ts-ignore - additionalFields.customAttributes.customAttribute.map(property => { + additionalFields.customAttributes.customAttribute.map((property) => { data[property.key] = property.value; }); } @@ -337,7 +334,6 @@ export class CustomerIo implements INodeType { } else { returnData.push(responseData as unknown as IDataObject); } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts b/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts index 9f0d3b848a430..4a43f0381286d 100644 --- a/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts +++ b/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts @@ -1,19 +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 { - customerIoApiRequest, - eventExists, -} from './GenericFunctions'; +import { customerIoApiRequest, eventExists } from './GenericFunctions'; interface IEvent { customer?: IDataObject; @@ -236,15 +225,20 @@ export class CustomerIoTrigger implements INodeType { const endpoint = '/reporting_webhooks'; - let { reporting_webhooks: webhooks } = await customerIoApiRequest.call(this, 'GET', endpoint, {}, 'beta'); + let { reporting_webhooks: webhooks } = await customerIoApiRequest.call( + this, + 'GET', + endpoint, + {}, + 'beta', + ); if (webhooks === null) { webhooks = []; } for (const webhook of webhooks) { - if (webhook.endpoint === webhookUrl && - eventExists(currentEvents, webhook.events)) { + if (webhook.endpoint === webhookUrl && eventExists(currentEvents, webhook.events)) { webhookData.webhookId = webhook.id; return true; } @@ -320,9 +314,7 @@ export class CustomerIoTrigger 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/CustomerIo/EventDescription.ts b/packages/nodes-base/nodes/CustomerIo/EventDescription.ts index be0ebc9436b55..a3268fc3e3bb6 100644 --- a/packages/nodes-base/nodes/CustomerIo/EventDescription.ts +++ b/packages/nodes-base/nodes/CustomerIo/EventDescription.ts @@ -8,9 +8,7 @@ export const eventOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'event', - ], + resource: ['event'], }, }, options: [ @@ -32,10 +30,9 @@ export const eventOperations: INodeProperties[] = [ ]; export const eventFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* event:track */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* event:track */ + /* -------------------------------------------------------------------------- */ { displayName: 'Customer ID', name: 'customerId', @@ -44,12 +41,8 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'track', - ], + resource: ['event'], + operation: ['track'], }, }, description: 'The unique identifier for the customer', @@ -61,12 +54,8 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'track', - ], + resource: ['event'], + operation: ['track'], }, }, description: 'Name of the event to track', @@ -78,12 +67,8 @@ export const eventFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'track', - ], + resource: ['event'], + operation: ['track'], }, }, }, @@ -97,18 +82,13 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'track', - ], - jsonParameters: [ - true, - ], + resource: ['event'], + operation: ['track'], + jsonParameters: [true], }, }, - description: 'Object of values to set as described here', + description: + 'Object of values to set as described here', }, { displayName: 'Additional Fields', @@ -118,15 +98,9 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'track', - ], - jsonParameters: [ - false, - ], + resource: ['event'], + operation: ['track'], + jsonParameters: [false], }, }, options: [ @@ -176,9 +150,9 @@ export const eventFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* event:track anonymous */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* event:track anonymous */ + /* -------------------------------------------------------------------------- */ { displayName: 'Event Name', name: 'eventName', @@ -187,12 +161,8 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'trackAnonymous', - ], + resource: ['event'], + operation: ['trackAnonymous'], }, }, description: 'The unique identifier for the customer', @@ -204,12 +174,8 @@ export const eventFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'trackAnonymous', - ], + resource: ['event'], + operation: ['trackAnonymous'], }, }, }, @@ -223,18 +189,13 @@ export const eventFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'trackAnonymous', - ], - jsonParameters: [ - true, - ], + resource: ['event'], + operation: ['trackAnonymous'], + jsonParameters: [true], }, }, - description: 'Object of values to set as described here', + description: + 'Object of values to set as described here', }, { displayName: 'Additional Fields', @@ -244,15 +205,9 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'trackAnonymous', - ], - jsonParameters: [ - false, - ], + resource: ['event'], + operation: ['trackAnonymous'], + jsonParameters: [false], }, }, options: [ diff --git a/packages/nodes-base/nodes/CustomerIo/GenericFunctions.ts b/packages/nodes-base/nodes/CustomerIo/GenericFunctions.ts index 903bf0026e26b..81e1d652baad0 100644 --- a/packages/nodes-base/nodes/CustomerIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/CustomerIo/GenericFunctions.ts @@ -1,22 +1,26 @@ -import { - IExecuteFunctions, - IHookFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { - IDataObject, IHttpRequestMethods, IHttpRequestOptions, NodeApiError, NodeOperationError, + IDataObject, + IHttpRequestMethods, + IHttpRequestOptions, + NodeApiError, + NodeOperationError, } from 'n8n-workflow'; -import { - get, -} from 'lodash'; +import { get } from 'lodash'; -export async function customerIoApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, baseApi?: string, query?: IDataObject): Promise { // tslint:disable-line:no-any +export async function customerIoApiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + body: object, + baseApi?: string, + query?: IDataObject, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('customerIoApi'); query = query || {}; const options: IHttpRequestOptions = { @@ -39,7 +43,7 @@ export async function customerIoApiRequest(this: IHookFunctions | IExecuteFuncti } try { - return await this.helpers.requestWithAuthentication.call(this, 'customerIoApi' ,options ); + return await this.helpers.requestWithAuthentication.call(this, 'customerIoApi', options); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -47,14 +51,17 @@ export async function customerIoApiRequest(this: IHookFunctions | IExecuteFuncti export function eventExists(currentEvents: string[], webhookEvents: IDataObject) { for (const currentEvent of currentEvents) { - if (get(webhookEvents, `${currentEvent.split('.')[0]}.${currentEvent.split('.')[1]}`) !== true) { + if ( + get(webhookEvents, `${currentEvent.split('.')[0]}.${currentEvent.split('.')[1]}`) !== true + ) { return false; } } return true; } -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/CustomerIo/SegmentDescription.ts b/packages/nodes-base/nodes/CustomerIo/SegmentDescription.ts index b3042e00abd31..cb224b94e7157 100644 --- a/packages/nodes-base/nodes/CustomerIo/SegmentDescription.ts +++ b/packages/nodes-base/nodes/CustomerIo/SegmentDescription.ts @@ -8,9 +8,7 @@ export const segmentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'segment', - ], + resource: ['segment'], }, }, options: [ @@ -30,10 +28,9 @@ export const segmentOperations: INodeProperties[] = [ ]; export const segmentFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* segment:add */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* segment:add */ + /* -------------------------------------------------------------------------- */ { displayName: 'Segment ID', name: 'segmentId', @@ -42,13 +39,8 @@ export const segmentFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - resource: [ - 'segment', - ], - operation: [ - 'add', - 'remove', - ], + resource: ['segment'], + operation: ['add', 'remove'], }, }, description: 'The unique identifier of the segment', @@ -61,13 +53,8 @@ export const segmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'segment', - ], - operation: [ - 'add', - 'remove', - ], + resource: ['segment'], + operation: ['add', 'remove'], }, }, description: 'A list of customer IDs to add to the segment', diff --git a/packages/nodes-base/nodes/DateTime/DateTime.node.ts b/packages/nodes-base/nodes/DateTime/DateTime.node.ts index de3ba29106336..bb3d7d5a89ac9 100644 --- a/packages/nodes-base/nodes/DateTime/DateTime.node.ts +++ b/packages/nodes-base/nodes/DateTime/DateTime.node.ts @@ -1,7 +1,4 @@ - -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -13,9 +10,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - set, -} from 'lodash'; +import { set } from 'lodash'; import moment from 'moment-timezone'; @@ -60,9 +55,7 @@ export class DateTime implements INodeType { name: 'value', displayOptions: { show: { - action: [ - 'format', - ], + action: ['format'], }, }, type: 'string', @@ -78,9 +71,7 @@ export class DateTime implements INodeType { required: true, displayOptions: { show: { - action: [ - 'format', - ], + action: ['format'], }, }, description: 'Name of the property to which to write the converted date', @@ -90,9 +81,7 @@ export class DateTime implements INodeType { name: 'custom', displayOptions: { show: { - action: [ - 'format', - ], + action: ['format'], }, }, type: 'boolean', @@ -104,12 +93,8 @@ export class DateTime implements INodeType { name: 'toFormat', displayOptions: { show: { - action: [ - 'format', - ], - custom: [ - true, - ], + action: ['format'], + custom: [true], }, }, type: 'string', @@ -123,12 +108,8 @@ export class DateTime implements INodeType { type: 'options', displayOptions: { show: { - action: [ - 'format', - ], - custom: [ - false, - ], + action: ['format'], + custom: [false], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items @@ -177,9 +158,7 @@ export class DateTime implements INodeType { name: 'options', displayOptions: { show: { - action: [ - 'format', - ], + action: ['format'], }, }, type: 'collection', @@ -201,7 +180,8 @@ export class DateTime implements INodeType { loadOptionsMethod: 'getTimezones', }, default: 'UTC', - description: 'The timezone to convert from. Choose from the list, or specify an ID using an expression.', + description: + 'The timezone to convert from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'To Timezone Name or ID', @@ -211,7 +191,8 @@ export class DateTime implements INodeType { loadOptionsMethod: 'getTimezones', }, default: 'UTC', - description: 'The timezone to convert to. Choose from the list, or specify an ID using an expression.', + description: + 'The timezone to convert to. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -220,9 +201,7 @@ export class DateTime implements INodeType { name: 'value', displayOptions: { show: { - action: [ - 'calculate', - ], + action: ['calculate'], }, }, type: 'string', @@ -235,9 +214,7 @@ export class DateTime implements INodeType { name: 'operation', displayOptions: { show: { - action: [ - 'calculate', - ], + action: ['calculate'], }, }, type: 'options', @@ -264,9 +241,7 @@ export class DateTime implements INodeType { name: 'duration', displayOptions: { show: { - action: [ - 'calculate', - ], + action: ['calculate'], }, }, type: 'number', @@ -283,9 +258,7 @@ export class DateTime implements INodeType { description: 'Time unit for Duration parameter above', displayOptions: { show: { - action: [ - 'calculate', - ], + action: ['calculate'], }, }, type: 'options', @@ -339,9 +312,7 @@ export class DateTime implements INodeType { required: true, displayOptions: { show: { - action: [ - 'calculate', - ], + action: ['calculate'], }, }, description: 'Name of the output property to which to write the converted date', @@ -354,9 +325,7 @@ export class DateTime implements INodeType { default: {}, displayOptions: { show: { - action: [ - 'calculate', - ], + action: ['calculate'], }, }, options: [ @@ -365,7 +334,8 @@ export class DateTime implements INodeType { name: 'fromFormat', type: 'string', default: '', - description: 'Format for parsing the value as a date. If unrecognized, specify the format for the value.', + description: + 'Format for parsing the value as a date. If unrecognized, specify the format for the value.', }, ], }, @@ -401,7 +371,6 @@ export class DateTime implements INodeType { for (let i = 0; i < length; i++) { try { - const action = this.getNodeParameter('action', 0) as string; item = items[i]; @@ -415,8 +384,15 @@ export class DateTime implements INodeType { if (currentDate === undefined) { continue; } - if (options.fromFormat === undefined && !moment(currentDate as string | number).isValid()) { - throw new NodeOperationError(this.getNode(), 'The date input format could not be recognized. Please set the "From Format" field', { itemIndex: i }); + if ( + options.fromFormat === undefined && + !moment(currentDate as string | number).isValid() + ) { + throw new NodeOperationError( + this.getNode(), + 'The date input format could not be recognized. Please set the "From Format" field', + { itemIndex: i }, + ); } if (Number.isInteger(currentDate as unknown as number)) { @@ -425,7 +401,11 @@ export class DateTime implements INodeType { if (options.fromTimezone || options.toTimezone) { const fromTimezone = options.fromTimezone || workflowTimezone; if (options.fromFormat) { - newDate = moment.tz(currentDate as string, options.fromFormat as string, fromTimezone as string); + newDate = moment.tz( + currentDate as string, + options.fromFormat as string, + fromTimezone as string, + ); } else { newDate = moment.tz(currentDate as string, fromTimezone as string); } @@ -442,7 +422,7 @@ export class DateTime implements INodeType { // If either a source or a target timezone got defined the // timezone of the date has to be changed. If a target-timezone // is set use it else fall back to workflow timezone. - newDate = newDate.tz(options.toTimezone as string || workflowTimezone); + newDate = newDate.tz((options.toTimezone as string) || workflowTimezone); } newDate = newDate.format(toFormat); @@ -476,7 +456,6 @@ export class DateTime implements INodeType { } if (action === 'calculate') { - const dateValue = this.getNodeParameter('value', i) as string; const operation = this.getNodeParameter('operation', i) as 'add' | 'subtract'; const duration = this.getNodeParameter('duration', i) as number; @@ -519,7 +498,6 @@ export class DateTime implements INodeType { returnData.push(newItem); } - } catch (error) { if (this.continueOnFail()) { returnData.push({ @@ -544,20 +522,29 @@ function parseDateByFormat(this: IExecuteFunctions, value: string, fromFormat: s const date = moment(value, fromFormat, true); if (moment(date).isValid()) return date; - throw new NodeOperationError(this.getNode(), 'Date input cannot be parsed. Please recheck the value and the "From Format" field.'); + throw new NodeOperationError( + this.getNode(), + 'Date input cannot be parsed. Please recheck the value and the "From Format" field.', + ); } function parseDateByDefault(this: IExecuteFunctions, value: string) { const isoValue = getIsoValue.call(this, value); if (moment(isoValue).isValid()) return moment(isoValue); - throw new NodeOperationError(this.getNode(), 'Unrecognized date input. Please specify a format in the "From Format" field.'); + throw new NodeOperationError( + this.getNode(), + 'Unrecognized date input. Please specify a format in the "From Format" field.', + ); } function getIsoValue(this: IExecuteFunctions, value: string) { try { return new Date(value).toISOString(); // may throw due to unpredictable input } catch (error) { - throw new NodeOperationError(this.getNode(), 'Unrecognized date input. Please specify a format in the "From Format" field.'); + throw new NodeOperationError( + this.getNode(), + 'Unrecognized date input. Please specify a format in the "From Format" field.', + ); } } diff --git a/packages/nodes-base/nodes/DeepL/DeepL.node.ts b/packages/nodes-base/nodes/DeepL/DeepL.node.ts index 1bce0b719e7cf..659c637501ad5 100644 --- a/packages/nodes-base/nodes/DeepL/DeepL.node.ts +++ b/packages/nodes-base/nodes/DeepL/DeepL.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,13 +9,9 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - deepLApiRequest, -} from './GenericFunctions'; +import { deepLApiRequest } from './GenericFunctions'; -import { - textOperations -} from './TextDescription'; +import { textOperations } from './TextDescription'; export class DeepL implements INodeType { description: INodeTypeDescription = { @@ -60,9 +54,7 @@ export class DeepL implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'language', - ], + resource: ['language'], }, }, options: [ @@ -83,7 +75,13 @@ export class DeepL implements INodeType { loadOptions: { async getLanguages(this: ILoadOptionsFunctions) { const returnData: INodePropertyOptions[] = []; - const languages = await deepLApiRequest.call(this, 'GET', '/languages', {}, { type: 'target' }); + const languages = await deepLApiRequest.call( + this, + 'GET', + '/languages', + {}, + { type: 'target' }, + ); for (const language of languages) { returnData.push({ name: language.name, @@ -92,8 +90,12 @@ export class DeepL 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; }); @@ -115,12 +117,11 @@ export class DeepL implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (resource === 'language') { - if (operation === 'translate') { let body: IDataObject = {}; const text = this.getNodeParameter('text', i) as string; const translateTo = this.getNodeParameter('translateTo', i) as string; - body = { target_lang: translateTo, 'text': text } as IDataObject; + body = { target_lang: translateTo, text } as IDataObject; if (additionalFields.sourceLang !== undefined) { body.source_lang = ['EN-GB', 'EN-US'].includes(additionalFields.sourceLang as string) @@ -134,7 +135,7 @@ export class DeepL implements INodeType { } } catch (error) { if (this.continueOnFail()) { - responseData.push({ $error: error, $json: this.getInputData(i)}); + responseData.push({ $error: error, $json: this.getInputData(i) }); continue; } throw error; diff --git a/packages/nodes-base/nodes/DeepL/GenericFunctions.ts b/packages/nodes-base/nodes/DeepL/GenericFunctions.ts index 2d3795e32a011..87cc1642ca83b 100644 --- a/packages/nodes-base/nodes/DeepL/GenericFunctions.ts +++ b/packages/nodes-base/nodes/DeepL/GenericFunctions.ts @@ -1,18 +1,8 @@ -import { - OptionsWithUri, -} from 'request'; - -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; - -import { - IDataObject, - JsonObject, - NodeApiError, -} from 'n8n-workflow'; +import { OptionsWithUri } from 'request'; + +import { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; + +import { IDataObject, JsonObject, NodeApiError } from 'n8n-workflow'; export async function deepLApiRequest( this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, @@ -23,7 +13,6 @@ export async function deepLApiRequest( uri?: string, headers: IDataObject = {}, ) { - const proApiEndpoint = 'https://api.deepl.com/v2'; const freeApiEndpoint = 'https://api-free.deepl.com/v2'; @@ -50,7 +39,6 @@ export async function deepLApiRequest( } return await this.helpers.requestWithAuthentication.call(this, 'deepLApi', options); - } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); } diff --git a/packages/nodes-base/nodes/DeepL/TextDescription.ts b/packages/nodes-base/nodes/DeepL/TextDescription.ts index 1d06bbf439806..44bad16a9784f 100644 --- a/packages/nodes-base/nodes/DeepL/TextDescription.ts +++ b/packages/nodes-base/nodes/DeepL/TextDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const textOperations: INodeProperties[] = [ { @@ -15,9 +13,7 @@ export const textOperations: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'translate', - ], + operation: ['translate'], }, }, }, @@ -29,13 +25,12 @@ export const textOperations: INodeProperties[] = [ loadOptionsMethod: 'getLanguages', }, default: '', - description: 'Language to translate to. Choose from the list, or specify an ID using an expression.', + description: + 'Language to translate to. Choose from the list, or specify an ID using an expression.', required: true, displayOptions: { show: { - operation: [ - 'translate', - ], + operation: ['translate'], }, }, }, @@ -51,7 +46,8 @@ export const textOperations: INodeProperties[] = [ name: 'sourceLang', type: 'options', default: '', - description: 'Language to translate from. Choose from the list, or specify an ID using an expression.', + description: + 'Language to translate from. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getLanguages', }, @@ -85,12 +81,14 @@ export const textOperations: INodeProperties[] = [ name: 'preserveFormatting', type: 'options', default: '0', - description: 'Whether the translation engine should respect the original formatting, even if it would usually correct some aspects', + description: + 'Whether the translation engine should respect the original formatting, even if it would usually correct some aspects', options: [ { name: 'Apply Corrections', value: '0', - description: 'Fix punctuation at the beginning and end of sentences and fixes lower/upper caseing at the beginning', + description: + 'Fix punctuation at the beginning and end of sentences and fixes lower/upper caseing at the beginning', }, { name: 'Do Not Correct', @@ -104,7 +102,8 @@ export const textOperations: INodeProperties[] = [ name: 'formality', type: 'options', default: 'default', - description: 'How formal or informal the target text should be. May not be supported with all languages.', + description: + 'How formal or informal the target text should be. May not be supported with all languages.', options: [ { name: 'Formal', diff --git a/packages/nodes-base/nodes/Demio/Demio.node.ts b/packages/nodes-base/nodes/Demio/Demio.node.ts index 3e528cde3ce9f..006cddcbcae9b 100644 --- a/packages/nodes-base/nodes/Demio/Demio.node.ts +++ b/packages/nodes-base/nodes/Demio/Demio.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -11,19 +9,11 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - demioApiRequest, -} from './GenericFunctions'; +import { demioApiRequest } from './GenericFunctions'; -import { - eventFields, - eventOperations, -} from './EventDescription'; +import { eventFields, eventOperations } from './EventDescription'; -import { - reportFields, - reportOperations, -} from './ReportDescription'; +import { reportFields, reportOperations } from './ReportDescription'; export class Demio implements INodeType { description: INodeTypeDescription = { @@ -76,17 +66,9 @@ export class Demio implements INodeType { loadOptions: { // Get all the events to display them to user so that he can // select them easily - async getEvents( - this: ILoadOptionsFunctions, - ): Promise { + async getEvents(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const events = await demioApiRequest.call( - this, - 'GET', - `/events`, - {}, - { type: 'upcoming' }, - ); + const events = await demioApiRequest.call(this, 'GET', `/events`, {}, { type: 'upcoming' }); for (const event of events) { returnData.push({ name: event.name, @@ -98,9 +80,7 @@ export class Demio implements INodeType { // Get all the sessions to display them to user so that he can // select them easily - async getEventSessions( - this: ILoadOptionsFunctions, - ): Promise { + async getEventSessions(this: ILoadOptionsFunctions): Promise { const eventId = this.getCurrentNodeParameter('eventId') as string; const qs: IDataObject = {}; @@ -111,12 +91,7 @@ export class Demio implements INodeType { } const returnData: INodePropertyOptions[] = []; - const { dates } = await demioApiRequest.call( - this, - 'GET', - `/event/${eventId}`, - {}, - ); + const { dates } = await demioApiRequest.call(this, 'GET', `/event/${eventId}`, {}); for (const date of dates) { returnData.push({ name: date.datetime, @@ -145,7 +120,11 @@ export class Demio implements INodeType { const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject; if (additionalFields.date_id !== undefined) { - responseData = await demioApiRequest.call(this, 'GET', `/event/${id}/date/${additionalFields.date_id}`); + responseData = await demioApiRequest.call( + this, + 'GET', + `/event/${id}/date/${additionalFields.date_id}`, + ); } else { Object.assign(qs, additionalFields); responseData = await demioApiRequest.call(this, 'GET', `/event/${id}`, {}, qs); @@ -163,7 +142,6 @@ export class Demio implements INodeType { const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.splice(0, limit); } - } if (operation === 'register') { const eventId = this.getNodeParameter('eventId', i) as string; @@ -180,8 +158,13 @@ export class Demio implements INodeType { Object.assign(body, additionalFields); if (additionalFields.customFieldsUi) { - const customFields = (additionalFields.customFieldsUi as IDataObject || {}).customFieldsValues as IDataObject[] || []; - const data = customFields.reduce((obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.value }), {}); + const customFields = + (((additionalFields.customFieldsUi as IDataObject) || {}) + .customFieldsValues as IDataObject[]) || []; + const data = customFields.reduce( + (obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.value }), + {}, + ); Object.assign(body, data); delete additionalFields.customFields; } @@ -196,7 +179,13 @@ export class Demio implements INodeType { Object.assign(qs, filters); - responseData = await demioApiRequest.call(this, 'GET', `/report/${sessionId}/participants`, {}, qs); + responseData = await demioApiRequest.call( + this, + 'GET', + `/report/${sessionId}/participants`, + {}, + qs, + ); responseData = responseData.participants; } } diff --git a/packages/nodes-base/nodes/Demio/EventDescription.ts b/packages/nodes-base/nodes/Demio/EventDescription.ts index 86e82e8150f78..3a1771d1dc3a8 100644 --- a/packages/nodes-base/nodes/Demio/EventDescription.ts +++ b/packages/nodes-base/nodes/Demio/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: [ @@ -40,7 +36,6 @@ export const eventOperations: INodeProperties[] = [ ]; export const eventFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* event:getAll */ /* -------------------------------------------------------------------------- */ @@ -50,12 +45,8 @@ export const eventFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'event', - ], + operation: ['getAll'], + resource: ['event'], }, }, default: false, @@ -67,15 +58,9 @@ export const eventFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'event', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['event'], + returnAll: [false], }, }, typeOptions: { @@ -93,12 +78,8 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'getAll', - ], + resource: ['event'], + operation: ['getAll'], }, }, options: [ @@ -136,12 +117,8 @@ export const eventFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'get', - ], + resource: ['event'], + operation: ['get'], }, }, }, @@ -153,12 +130,8 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'get', - ], + resource: ['event'], + operation: ['get'], }, }, options: [ @@ -186,18 +159,15 @@ export const eventFields: INodeProperties[] = [ 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', }, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'register', - ], + resource: ['event'], + operation: ['register'], }, }, default: '', @@ -208,15 +178,11 @@ export const eventFields: INodeProperties[] = [ type: 'string', default: '', required: true, - description: 'The registrant\'s first name', + description: "The registrant's first name", displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'register', - ], + resource: ['event'], + operation: ['register'], }, }, }, @@ -227,15 +193,11 @@ export const eventFields: INodeProperties[] = [ placeholder: 'name@email.com', default: '', required: true, - description: 'The registrant\'s email address', + description: "The registrant's email address", displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'register', - ], + resource: ['event'], + operation: ['register'], }, }, }, @@ -247,12 +209,8 @@ export const eventFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'event', - ], - operation: [ - 'register', - ], + resource: ['event'], + operation: ['register'], }, }, options: [ @@ -282,7 +240,8 @@ export const eventFields: INodeProperties[] = [ name: 'fieldId', type: 'string', default: '', - description: 'Each custom field\'s unique identifier can be found within the Event\'s Registration block in the Customize tab', + description: + "Each custom field's unique identifier can be found within the Event's Registration block in the Customize tab", }, { displayName: 'Value', @@ -300,7 +259,8 @@ export const eventFields: INodeProperties[] = [ name: 'ref_url', type: 'string', default: '', - description: 'Event Registration page URL. It can be useful when you do not know Event ID, but have Event link.', + description: + 'Event Registration page URL. It can be useful when you do not know Event ID, but have Event link.', }, { displayName: 'GDPR', @@ -329,12 +289,11 @@ export const eventFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getEventSessions', - loadOptionsDependsOn: [ - 'eventId', - ], + loadOptionsDependsOn: ['eventId'], }, default: '', - description: 'Event Session ID. Choose from the list, or specify an ID using an expression.', + description: + 'Event Session ID. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Website', diff --git a/packages/nodes-base/nodes/Demio/GenericFunctions.ts b/packages/nodes-base/nodes/Demio/GenericFunctions.ts index f311e65ee0ea3..1c1b760513b80 100644 --- a/packages/nodes-base/nodes/Demio/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Demio/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 demioApiRequest(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 demioApiRequest( + 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('demioApi'); let options: OptionsWithUri = { diff --git a/packages/nodes-base/nodes/Demio/ReportDescription.ts b/packages/nodes-base/nodes/Demio/ReportDescription.ts index 914efe81c0ae8..a0739e08fbff9 100644 --- a/packages/nodes-base/nodes/Demio/ReportDescription.ts +++ b/packages/nodes-base/nodes/Demio/ReportDescription.ts @@ -8,9 +8,7 @@ export const reportOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'report', - ], + resource: ['report'], }, }, options: [ @@ -26,7 +24,6 @@ export const reportOperations: INodeProperties[] = [ ]; export const reportFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* report:get */ /* -------------------------------------------------------------------------- */ @@ -34,18 +31,15 @@ export const reportFields: INodeProperties[] = [ 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', }, displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'get', - ], + resource: ['report'], + operation: ['get'], }, }, default: '', @@ -56,21 +50,16 @@ export const reportFields: INodeProperties[] = [ type: 'options', typeOptions: { loadOptionsMethod: 'getEventSessions', - loadOptionsDependsOn: [ - 'eventId', - ], + loadOptionsDependsOn: ['eventId'], }, default: '', required: true, - description: 'ID of the session. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the session. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'get', - ], + resource: ['report'], + operation: ['get'], }, }, }, @@ -82,12 +71,8 @@ export const reportFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'report', - ], - operation: [ - 'get', - ], + resource: ['report'], + operation: ['get'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Dhl/Dhl.node.ts b/packages/nodes-base/nodes/Dhl/Dhl.node.ts index bae7e9a017502..bb441377ea85f 100644 --- a/packages/nodes-base/nodes/Dhl/Dhl.node.ts +++ b/packages/nodes-base/nodes/Dhl/Dhl.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -13,10 +11,7 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - dhlApiRequest, - validateCredentials, -} from './GenericFunctions'; +import { dhlApiRequest, validateCredentials } from './GenericFunctions'; export class Dhl implements INodeType { description: INodeTypeDescription = { @@ -60,9 +55,7 @@ export class Dhl implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'shipment', - ], + resource: ['shipment'], }, }, options: [ @@ -93,7 +86,8 @@ export class Dhl implements INodeType { name: 'recipientPostalCode', type: 'string', default: '', - description: 'DHL will return more detailed information on the shipment when you provide the Recipient\'s Postal Code - it acts as a verification step', + description: + "DHL will return more detailed information on the shipment when you provide the Recipient's Postal Code - it acts as a verification step", }, ], }, @@ -102,7 +96,10 @@ export class Dhl implements INodeType { methods = { credentialTest: { - async dhlApiCredentialTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { + async dhlApiCredentialTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { try { await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject); } catch (error) { @@ -134,7 +131,6 @@ export class Dhl implements INodeType { try { if (resource === 'shipment') { if (operation === 'get') { - const trackingNumber = this.getNodeParameter('trackingNumber', i) as string; const options = this.getNodeParameter('options', i) as IDataObject; diff --git a/packages/nodes-base/nodes/Dhl/GenericFunctions.ts b/packages/nodes-base/nodes/Dhl/GenericFunctions.ts index 0ac33a22b1970..a3adde214885e 100644 --- a/packages/nodes-base/nodes/Dhl/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Dhl/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -16,9 +14,18 @@ import { NodeApiError, } from 'n8n-workflow'; -export async function dhlApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any - - const credentials = await this.getCredentials('dhlApi') as { apiKey: string }; +export async function dhlApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | 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 credentials = (await this.getCredentials('dhlApi')) as { apiKey: string }; let options: OptionsWithUri = { headers: { @@ -42,11 +49,15 @@ export async function dhlApiRequest(this: IHookFunctions | IExecuteFunctions | I } } -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 { apiKey } = credentials as { - apiKey: string, + apiKey: string; }; const options: OptionsWithUri = { diff --git a/packages/nodes-base/nodes/Discord/Discord.node.ts b/packages/nodes-base/nodes/Discord/Discord.node.ts index bfe65233cdf7b..d7a9eb256be9c 100644 --- a/packages/nodes-base/nodes/Discord/Discord.node.ts +++ b/packages/nodes-base/nodes/Discord/Discord.node.ts @@ -8,7 +8,6 @@ import { NodeOperationError, } from 'n8n-workflow'; - import { DiscordAttachment, DiscordWebhook } from './Interfaces'; export class Discord implements INodeType { description: INodeTypeDescription = { @@ -23,7 +22,7 @@ export class Discord implements INodeType { }, inputs: ['main'], outputs: ['main'], - properties:[ + properties: [ { displayName: 'Webhook URL', name: 'webhookUri', @@ -136,21 +135,27 @@ export class Discord implements INodeType { const options = this.getNodeParameter('options', i) as IDataObject; if (!body.content && !options.embeds) { - throw new NodeOperationError(this.getNode(), 'Either content or embeds must be set.', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Either content or embeds must be set.', { + itemIndex: i, + }); } if (options.embeds) { try { //@ts-expect-error body.embeds = JSON.parse(options.embeds); if (!Array.isArray(body.embeds)) { - throw new NodeOperationError(this.getNode(), 'Embeds must be an array of embeds.', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Embeds must be an array of embeds.', { + itemIndex: i, + }); } } catch (e) { - throw new NodeOperationError(this.getNode(), 'Embeds must be valid JSON.', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Embeds must be valid JSON.', { + itemIndex: i, + }); } } if (options.username) { - body.username = options.username as string; + body.username = options.username as string; } if (options.components) { @@ -158,13 +163,15 @@ export class Discord implements INodeType { //@ts-expect-error body.components = JSON.parse(options.components); } catch (e) { - throw new NodeOperationError(this.getNode(), 'Components must be valid JSON.', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Components must be valid JSON.', { + itemIndex: i, + }); } } if (options.allowed_mentions) { - //@ts-expect-error - body.allowed_mentions = JSON.parse(options.allowed_mentions); + //@ts-expect-error + body.allowed_mentions = JSON.parse(options.allowed_mentions); } if (options.avatarUrl) { @@ -202,7 +209,7 @@ export class Discord implements INodeType { let requestOptions; - if(!body.payload_json){ + if (!body.payload_json) { requestOptions = { resolveWithFullResponse: true, method: 'POST', @@ -213,7 +220,7 @@ export class Discord implements INodeType { }, json: true, }; - }else { + } else { requestOptions = { resolveWithFullResponse: true, method: 'POST', @@ -236,9 +243,7 @@ export class Discord implements INodeType { // remaining requests 0 // https://discord.com/developers/docs/topics/rate-limits if (!+remainingRatelimit) { - await new Promise((resolve) => - setTimeout(resolve, resetAfter || 1000), - ); + await new Promise((resolve) => setTimeout(resolve, resetAfter || 1000)); } break; @@ -249,9 +254,7 @@ export class Discord implements INodeType { if (error.statusCode === 429) { const retryAfter = error.response?.headers['retry-after'] || 1000; - await new Promise((resolve) => - setTimeout(resolve, +retryAfter), - ); + await new Promise((resolve) => setTimeout(resolve, +retryAfter)); continue; } @@ -261,10 +264,9 @@ export class Discord implements INodeType { } while (--maxTries); if (maxTries <= 0) { - throw new NodeApiError( - this.getNode(), - { error: 'Could not send Webhook message. Max amount of rate-limit retries reached.' }, - ); + throw new NodeApiError(this.getNode(), { + error: 'Could not send Webhook message. Max amount of rate-limit retries reached.', + }); } returnData.push({ success: true }); diff --git a/packages/nodes-base/nodes/Discourse/CategoryDescription.ts b/packages/nodes-base/nodes/Discourse/CategoryDescription.ts index c4f376ffc182f..d5c73c3ec6ef3 100644 --- a/packages/nodes-base/nodes/Discourse/CategoryDescription.ts +++ b/packages/nodes-base/nodes/Discourse/CategoryDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const categoryOperations: INodeProperties[] = [ { @@ -12,9 +10,7 @@ export const categoryOperations: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'category', - ], + resource: ['category'], }, }, options: [ @@ -52,12 +48,8 @@ export const categoryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'category', - ], - operation: [ - 'create', - ], + resource: ['category'], + operation: ['create'], }, }, default: '', @@ -70,12 +62,8 @@ export const categoryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'category', - ], - operation: [ - 'create', - ], + resource: ['category'], + operation: ['create'], }, }, default: '0000FF', @@ -88,12 +76,8 @@ export const categoryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'category', - ], - operation: [ - 'create', - ], + resource: ['category'], + operation: ['create'], }, }, default: '0000FF', @@ -109,12 +93,8 @@ export const categoryFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'category', - ], - operation: [ - 'getAll', - ], + resource: ['category'], + operation: ['getAll'], }, }, default: false, @@ -126,15 +106,9 @@ export const categoryFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'category', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['category'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -155,12 +129,8 @@ export const categoryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'category', - ], - operation: [ - 'update', - ], + resource: ['category'], + operation: ['update'], }, }, default: '', @@ -173,12 +143,8 @@ export const categoryFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'category', - ], - operation: [ - 'update', - ], + resource: ['category'], + operation: ['update'], }, }, default: '', @@ -192,12 +158,8 @@ export const categoryFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'category', - ], - operation: [ - 'update', - ], + resource: ['category'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Discourse/Discourse.node.ts b/packages/nodes-base/nodes/Discourse/Discourse.node.ts index 2957e16d07d26..fd0fa0505d4ba 100644 --- a/packages/nodes-base/nodes/Discourse/Discourse.node.ts +++ b/packages/nodes-base/nodes/Discourse/Discourse.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -15,39 +13,22 @@ import { JsonObject, } from 'n8n-workflow'; -import { - discourseApiRequest, -} from './GenericFunctions'; +import { discourseApiRequest } from './GenericFunctions'; -import { - postFields, - postOperations, -} from './PostDescription'; +import { postFields, postOperations } from './PostDescription'; -import { - categoryFields, - categoryOperations, -} from './CategoryDescription'; +import { categoryFields, categoryOperations } from './CategoryDescription'; -import { - groupFields, - groupOperations, -} from './GroupDescription'; +import { groupFields, groupOperations } from './GroupDescription'; // import { // searchFields, // searchOperations, // } from './SearchDescription'; -import { - userFields, - userOperations, -} from './UserDescription'; +import { userFields, userOperations } from './UserDescription'; -import { - userGroupFields, - userGroupOperations, -} from './UserGroupDescription'; +import { userGroupFields, userGroupOperations } from './UserGroupDescription'; import { OptionsWithUri } from 'request'; //import moment from 'moment'; @@ -122,19 +103,12 @@ export class Discourse implements INodeType { }; methods = { - loadOptions: { // Get all the calendars to display them to user so that he can // select them easily - async getCategories( - this: ILoadOptionsFunctions, - ): Promise { + async getCategories(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const { category_list } = await discourseApiRequest.call( - this, - 'GET', - `/categories.json`, - ); + const { category_list } = await discourseApiRequest.call(this, 'GET', `/categories.json`); for (const category of category_list.categories) { returnData.push({ name: category.name, @@ -169,12 +143,7 @@ export class Discourse implements INodeType { text_color: textColor, }; - responseData = await discourseApiRequest.call( - this, - 'POST', - `/categories.json`, - body, - ); + responseData = await discourseApiRequest.call(this, 'POST', `/categories.json`, body); responseData = responseData.category; } @@ -182,13 +151,7 @@ export class Discourse implements INodeType { if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; - responseData = await discourseApiRequest.call( - this, - 'GET', - `/categories.json`, - {}, - qs, - ); + responseData = await discourseApiRequest.call(this, 'GET', `/categories.json`, {}, qs); responseData = responseData.category_list.categories; @@ -230,12 +193,9 @@ export class Discourse implements INodeType { name, }; - responseData = await discourseApiRequest.call( - this, - 'POST', - `/admin/groups.json`, - { group: body }, - ); + responseData = await discourseApiRequest.call(this, 'POST', `/admin/groups.json`, { + group: body, + }); responseData = responseData.basic_group; } @@ -243,28 +203,15 @@ export class Discourse implements INodeType { if (operation === 'get') { const name = this.getNodeParameter('name', i) as string; - responseData = await discourseApiRequest.call( - this, - 'GET', - `/groups/${name}`, - {}, - qs, - ); + responseData = await discourseApiRequest.call(this, 'GET', `/groups/${name}`, {}, qs); responseData = responseData.group; - } //https://docs.discourse.org/#tag/Groups/paths/~1groups.json/get if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; - responseData = await discourseApiRequest.call( - this, - 'GET', - `/groups.json`, - {}, - qs, - ); + responseData = await discourseApiRequest.call(this, 'GET', `/groups.json`, {}, qs); responseData = responseData.groups; @@ -283,12 +230,9 @@ export class Discourse implements INodeType { name, }; - responseData = await discourseApiRequest.call( - this, - 'PUT', - `/groups/${groupId}.json`, - { group: body }, - ); + responseData = await discourseApiRequest.call(this, 'PUT', `/groups/${groupId}.json`, { + group: body, + }); } } if (resource === 'post') { @@ -305,37 +249,20 @@ export class Discourse implements INodeType { Object.assign(body, additionalFields); - responseData = await discourseApiRequest.call( - this, - 'POST', - `/posts.json`, - body, - ); + responseData = await discourseApiRequest.call(this, 'POST', `/posts.json`, body); } //https://docs.discourse.org/#tag/Posts/paths/~1posts~1{id}.json/get if (operation === 'get') { const postId = this.getNodeParameter('postId', i) as string; - responseData = await discourseApiRequest.call( - this, - 'GET', - `/posts/${postId}`, - {}, - qs, - ); + responseData = await discourseApiRequest.call(this, 'GET', `/posts/${postId}`, {}, qs); } //https://docs.discourse.org/#tag/Posts/paths/~1posts.json/get if (operation === 'getAll') { const returnAll = this.getNodeParameter('returnAll', i) as boolean; const limit = this.getNodeParameter('limit', i, 0) as number; - responseData = await discourseApiRequest.call( - this, - 'GET', - `/posts.json`, - {}, - qs, - ); + responseData = await discourseApiRequest.call(this, 'GET', `/posts.json`, {}, qs); responseData = responseData.latest_posts; //Getting all posts relying on https://github.com/discourse/discourse_api/blob/main/spec/discourse_api/api/posts_spec.rb @@ -437,12 +364,7 @@ export class Discourse implements INodeType { Object.assign(body, additionalFields); - responseData = await discourseApiRequest.call( - this, - 'POST', - `/users.json`, - body, - ); + responseData = await discourseApiRequest.call(this, 'POST', `/users.json`, body); } //https://docs.discourse.org/#tag/Users/paths/~1users~1{username}.json/get if (operation === 'get') { @@ -456,11 +378,7 @@ export class Discourse implements INodeType { endpoint = `/u/by-external/${externalId}.json`; } - responseData = await discourseApiRequest.call( - this, - 'GET', - endpoint, - ); + responseData = await discourseApiRequest.call(this, 'GET', endpoint); } //https://docs.discourse.org/#tag/Users/paths/~1admin~1users~1{id}.json/delete if (operation === 'getAll') { diff --git a/packages/nodes-base/nodes/Discourse/GenericFunctions.ts b/packages/nodes-base/nodes/Discourse/GenericFunctions.ts index 94152fef57815..48ed02174d6c6 100644 --- a/packages/nodes-base/nodes/Discourse/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Discourse/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 discourseApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, option = {}): Promise { // tslint:disable-line:no-any - - const credentials = await this.getCredentials('discourseApi') as { url: string }; +export async function discourseApiRequest( + 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('discourseApi')) as { url: string }; const options: OptionsWithUri = { method, @@ -34,8 +34,15 @@ export async function discourseApiRequest(this: IExecuteFunctions | IExecuteSing } } -export async function discourseApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function discourseApiRequestAllItems( + 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; @@ -44,8 +51,6 @@ export async function discourseApiRequestAllItems(this: IExecuteFunctions | ILoa responseData = await discourseApiRequest.call(this, method, endpoint, body, query); returnData.push.apply(returnData, responseData); query.page++; - } while ( - responseData.length !== 0 - ); + } while (responseData.length !== 0); return returnData; } diff --git a/packages/nodes-base/nodes/Discourse/GroupDescription.ts b/packages/nodes-base/nodes/Discourse/GroupDescription.ts index f9047da1a40bd..889f82abcf663 100644 --- a/packages/nodes-base/nodes/Discourse/GroupDescription.ts +++ b/packages/nodes-base/nodes/Discourse/GroupDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const groupOperations: INodeProperties[] = [ { @@ -12,9 +10,7 @@ export const groupOperations: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'group', - ], + resource: ['group'], }, }, options: [ @@ -58,13 +54,8 @@ export const groupFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'get', - 'create', - ], + resource: ['group'], + operation: ['get', 'create'], }, }, default: '', @@ -80,12 +71,8 @@ export const groupFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'getAll', - ], + resource: ['group'], + operation: ['getAll'], }, }, default: false, @@ -97,15 +84,9 @@ export const groupFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['group'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -126,12 +107,8 @@ export const groupFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'update', - ], + resource: ['group'], + operation: ['update'], }, }, default: '', @@ -144,12 +121,8 @@ export const groupFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'group', - ], - operation: [ - 'update', - ], + resource: ['group'], + operation: ['update'], }, }, default: '', diff --git a/packages/nodes-base/nodes/Discourse/PostDescription.ts b/packages/nodes-base/nodes/Discourse/PostDescription.ts index 1c87a3f19a7fa..325f8b3111686 100644 --- a/packages/nodes-base/nodes/Discourse/PostDescription.ts +++ b/packages/nodes-base/nodes/Discourse/PostDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const postOperations: INodeProperties[] = [ { @@ -12,9 +10,7 @@ export const postOperations: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'post', - ], + resource: ['post'], }, }, options: [ @@ -57,12 +53,8 @@ export const postFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], + resource: ['post'], + operation: ['create'], }, }, default: '', @@ -78,12 +70,8 @@ export const postFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'create', - ], + resource: ['post'], + operation: ['create'], }, }, default: '', @@ -96,12 +84,8 @@ export const postFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'post', - ], + operation: ['create'], + resource: ['post'], }, }, default: {}, @@ -114,7 +98,8 @@ export const postFields: INodeProperties[] = [ loadOptionsMethod: 'getCategories', }, default: '', - description: 'ID of the category. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the category. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Reply To Post Number', @@ -143,12 +128,8 @@ export const postFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'get', - ], + resource: ['post'], + operation: ['get'], }, }, default: '', @@ -164,12 +145,8 @@ export const postFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'getAll', - ], + resource: ['post'], + operation: ['getAll'], }, }, default: false, @@ -181,15 +158,9 @@ export const postFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['post'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -209,12 +180,8 @@ export const postFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'update', - ], + resource: ['post'], + operation: ['update'], }, }, default: '', @@ -230,12 +197,8 @@ export const postFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'update', - ], + resource: ['post'], + operation: ['update'], }, }, default: '', @@ -249,12 +212,8 @@ export const postFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'post', - ], - operation: [ - 'update', - ], + resource: ['post'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Discourse/SearchDescription.ts b/packages/nodes-base/nodes/Discourse/SearchDescription.ts index 06656cbcdb604..2149e1579a7e7 100644 --- a/packages/nodes-base/nodes/Discourse/SearchDescription.ts +++ b/packages/nodes-base/nodes/Discourse/SearchDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const searchOperations: INodeProperties[] = [ { @@ -12,9 +10,7 @@ export const searchOperations: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'search', - ], + resource: ['search'], }, }, options: [ @@ -40,12 +36,8 @@ export const searchFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'search', - ], - operation: [ - 'query', - ], + resource: ['search'], + operation: ['query'], }, }, default: '', @@ -57,12 +49,8 @@ export const searchFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'search', - ], - operation: [ - 'query', - ], + resource: ['search'], + operation: ['query'], }, }, default: true, diff --git a/packages/nodes-base/nodes/Discourse/UserDescription.ts b/packages/nodes-base/nodes/Discourse/UserDescription.ts index 1695393ff39a8..713a5da7a0cde 100644 --- a/packages/nodes-base/nodes/Discourse/UserDescription.ts +++ b/packages/nodes-base/nodes/Discourse/UserDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userOperations: INodeProperties[] = [ { @@ -12,9 +10,7 @@ export const userOperations: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], + resource: ['user'], }, }, options: [ @@ -52,12 +48,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, default: '', @@ -71,12 +63,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, default: '', @@ -89,12 +77,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, default: '', @@ -110,12 +94,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, default: '', @@ -129,12 +109,8 @@ export const userFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'create', - ], + resource: ['user'], + operation: ['create'], }, }, options: [ @@ -173,12 +149,8 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], + resource: ['user'], + operation: ['get'], }, }, default: 'username', @@ -191,15 +163,9 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], - by: [ - 'username', - ], + resource: ['user'], + operation: ['get'], + by: ['username'], }, }, default: '', @@ -212,15 +178,9 @@ export const userFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'get', - ], - by: [ - 'externalId', - ], + resource: ['user'], + operation: ['get'], + by: ['externalId'], }, }, default: '', @@ -258,12 +218,8 @@ export const userFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, default: '', @@ -275,12 +231,8 @@ export const userFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'user', - ], - operation: [ - 'getAll', - ], + resource: ['user'], + operation: ['getAll'], }, }, default: false, @@ -292,15 +244,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/Discourse/UserGroupDescription.ts b/packages/nodes-base/nodes/Discourse/UserGroupDescription.ts index 61d48a0ac2532..5a3eefe0bf2a3 100644 --- a/packages/nodes-base/nodes/Discourse/UserGroupDescription.ts +++ b/packages/nodes-base/nodes/Discourse/UserGroupDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const userGroupOperations: INodeProperties[] = [ { @@ -12,9 +10,7 @@ export const userGroupOperations: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'userGroup', - ], + resource: ['userGroup'], }, }, options: [ @@ -46,12 +42,8 @@ export const userGroupFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'userGroup', - ], - operation: [ - 'add', - ], + resource: ['userGroup'], + operation: ['add'], }, }, default: '', @@ -64,12 +56,8 @@ export const userGroupFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'userGroup', - ], - operation: [ - 'add', - ], + resource: ['userGroup'], + operation: ['add'], }, }, default: '', @@ -86,12 +74,8 @@ export const userGroupFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'userGroup', - ], - operation: [ - 'remove', - ], + resource: ['userGroup'], + operation: ['remove'], }, }, default: '', @@ -104,16 +88,11 @@ export const userGroupFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'userGroup', - ], - operation: [ - 'remove', - ], + resource: ['userGroup'], + operation: ['remove'], }, }, default: '', description: 'ID of the group to remove', }, - ]; diff --git a/packages/nodes-base/nodes/Disqus/Disqus.node.ts b/packages/nodes-base/nodes/Disqus/Disqus.node.ts index da9a3d87cd4e9..633335858294f 100644 --- a/packages/nodes-base/nodes/Disqus/Disqus.node.ts +++ b/packages/nodes-base/nodes/Disqus/Disqus.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, INodeExecutionData, @@ -11,7 +9,6 @@ import { import { disqusApiRequest, disqusApiRequestAllItems } from './GenericFunctions'; - export class Disqus implements INodeType { description: INodeTypeDescription = { displayName: 'Disqus', @@ -58,9 +55,7 @@ export class Disqus implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'forum', - ], + resource: ['forum'], }, }, options: [ @@ -103,12 +98,8 @@ export class Disqus implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'forum', - ], + operation: ['get'], + resource: ['forum'], }, }, description: 'The short name(aka ID) of the forum to get', @@ -120,12 +111,8 @@ export class Disqus implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'forum', - ], + operation: ['get'], + resource: ['forum'], }, }, default: {}, @@ -201,12 +188,8 @@ export class Disqus implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'getPosts', - ], - resource: [ - 'forum', - ], + operation: ['getPosts'], + resource: ['forum'], }, }, description: 'The short name(aka ID) of the forum to get', @@ -217,12 +200,8 @@ export class Disqus implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'forum', - ], - operation: [ - 'getPosts', - ], + resource: ['forum'], + operation: ['getPosts'], }, }, default: false, @@ -234,15 +213,9 @@ export class Disqus implements INodeType { type: 'number', displayOptions: { show: { - resource: [ - 'forum', - ], - operation: [ - 'getPosts', - ], - returnAll: [ - false, - ], + resource: ['forum'], + operation: ['getPosts'], + returnAll: [false], }, }, typeOptions: { @@ -259,12 +232,8 @@ export class Disqus implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getPosts', - ], - resource: [ - 'forum', - ], + operation: ['getPosts'], + resource: ['forum'], }, }, default: {}, @@ -393,12 +362,8 @@ export class Disqus implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'getCategories', - ], - resource: [ - 'forum', - ], + operation: ['getCategories'], + resource: ['forum'], }, }, description: 'The short name(aka ID) of the forum to get Categories', @@ -409,12 +374,8 @@ export class Disqus implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'forum', - ], - operation: [ - 'getCategories', - ], + resource: ['forum'], + operation: ['getCategories'], }, }, default: false, @@ -426,15 +387,9 @@ export class Disqus implements INodeType { type: 'number', displayOptions: { show: { - resource: [ - 'forum', - ], - operation: [ - 'getCategories', - ], - returnAll: [ - false, - ], + resource: ['forum'], + operation: ['getCategories'], + returnAll: [false], }, }, typeOptions: { @@ -451,12 +406,8 @@ export class Disqus implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getCategories', - ], - resource: [ - 'forum', - ], + operation: ['getCategories'], + resource: ['forum'], }, }, default: {}, @@ -492,12 +443,8 @@ export class Disqus implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'getThreads', - ], - resource: [ - 'forum', - ], + operation: ['getThreads'], + resource: ['forum'], }, }, description: 'The short name(aka ID) of the forum to get Threads', @@ -508,12 +455,8 @@ export class Disqus implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'forum', - ], - operation: [ - 'getThreads', - ], + resource: ['forum'], + operation: ['getThreads'], }, }, default: false, @@ -525,15 +468,9 @@ export class Disqus implements INodeType { type: 'number', displayOptions: { show: { - resource: [ - 'forum', - ], - operation: [ - 'getThreads', - ], - returnAll: [ - false, - ], + resource: ['forum'], + operation: ['getThreads'], + returnAll: [false], }, }, typeOptions: { @@ -550,12 +487,8 @@ export class Disqus implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'getThreads', - ], - resource: [ - 'forum', - ], + operation: ['getThreads'], + resource: ['forum'], }, }, default: {}, @@ -627,19 +560,18 @@ export class Disqus implements INodeType { name: 'threadId', type: 'string', default: '', - description: 'Looks up a thread by ID. You may pass us the "ident" query type instead of an ID by including "forum". You may pass us the "link" query type to filter by URL. You must pass the "forum" if you do not have the Pro API Access addon.', + description: + 'Looks up a thread by ID. You may pass us the "ident" query type instead of an ID by including "forum". You may pass us the "link" query type to filter by URL. You must pass the "forum" if you do not have the Pro API Access addon.', }, ], }, ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; - const resource = this.getNodeParameter('resource', 0) as string; const operation = this.getNodeParameter('operation', 0) as string; @@ -648,7 +580,6 @@ export class Disqus implements INodeType { let body: IDataObject | Buffer; let qs: IDataObject; - for (let i = 0; i < items.length; i++) { try { body = {}; @@ -677,7 +608,6 @@ export class Disqus implements INodeType { } catch (error) { throw error; } - } else if (operation === 'getPosts') { // ---------------------------------- // getPosts @@ -698,8 +628,13 @@ export class Disqus implements INodeType { try { let responseData: IDataObject = {}; - if(returnAll) { - responseData.response = await disqusApiRequestAllItems.call(this, requestMethod, qs, endpoint); + if (returnAll) { + responseData.response = await disqusApiRequestAllItems.call( + this, + requestMethod, + qs, + endpoint, + ); } else { const limit = this.getNodeParameter('limit', i) as string; qs.limit = limit; @@ -709,8 +644,7 @@ export class Disqus implements INodeType { } catch (error) { throw error; } - - } else if (operation === 'getCategories') { + } else if (operation === 'getCategories') { // ---------------------------------- // getCategories // ---------------------------------- @@ -730,19 +664,28 @@ export class Disqus implements INodeType { try { let responseData: IDataObject = {}; - if(returnAll) { - responseData.response = await disqusApiRequestAllItems.call(this, requestMethod, qs, endpoint); + if (returnAll) { + responseData.response = await disqusApiRequestAllItems.call( + this, + requestMethod, + qs, + endpoint, + ); } else { const limit = this.getNodeParameter('limit', i) as string; qs.limit = limit; - responseData = await disqusApiRequest.call(this, requestMethod, qs, endpoint) as IDataObject; + responseData = (await disqusApiRequest.call( + this, + requestMethod, + qs, + endpoint, + )) as IDataObject; } - returnData.push.apply(returnData, responseData.response as IDataObject[]) ; + returnData.push.apply(returnData, responseData.response as IDataObject[]); } catch (error) { throw error; } - - } else if (operation === 'getThreads') { + } else if (operation === 'getThreads') { // ---------------------------------- // getThreads // ---------------------------------- @@ -763,8 +706,13 @@ export class Disqus implements INodeType { try { let responseData: IDataObject = {}; - if(returnAll) { - responseData.response = await disqusApiRequestAllItems.call(this, requestMethod, qs, endpoint); + if (returnAll) { + responseData.response = await disqusApiRequestAllItems.call( + this, + requestMethod, + qs, + endpoint, + ); } else { const limit = this.getNodeParameter('limit', i) as string; qs.limit = limit; @@ -774,13 +722,17 @@ export class Disqus implements INodeType { } catch (error) { throw error; } - } 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/Disqus/GenericFunctions.ts b/packages/nodes-base/nodes/Disqus/GenericFunctions.ts index e475f22d17163..9cb326dffc034 100644 --- a/packages/nodes-base/nodes/Disqus/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Disqus/GenericFunctions.ts @@ -5,25 +5,25 @@ import { IHookFunctions, ILoadOptionsFunctions, } from 'n8n-core'; -import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function disqusApiRequest( - this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, - method: string, - qs: IDataObject = {}, - uri?: string, - body: IDataObject = {}, - option: IDataObject = {}, - ): Promise { // tslint:disable-line:no-any - - const credentials = await this.getCredentials('disqusApi') as IDataObject; + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + qs: IDataObject = {}, + uri?: string, + body: IDataObject = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { + const credentials = (await this.getCredentials('disqusApi')) as IDataObject; qs.api_key = credentials.accessToken; // Convert to query string into a format the API can read const queryStringElements: string[] = []; for (const key of Object.keys(qs)) { if (Array.isArray(qs[key])) { - (qs[key] as string[]).forEach(value => { + (qs[key] as string[]).forEach((value) => { queryStringElements.push(`${key}=${value}`); }); } else { @@ -54,14 +54,14 @@ export async function disqusApiRequest( * and return all results */ export async function disqusApiRequestAllItems( - this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, - method: string, - qs: IDataObject = {}, - uri?: string, - body: IDataObject = {}, - option: IDataObject = {}, - ): Promise { // tslint:disable-line:no-any - + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + qs: IDataObject = {}, + uri?: string, + body: IDataObject = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const returnData: IDataObject[] = []; let responseData; @@ -71,12 +71,9 @@ export async function disqusApiRequestAllItems( responseData = await disqusApiRequest.call(this, method, qs, uri, body, option); qs.cursor = responseData.cursor.id; returnData.push.apply(returnData, responseData.response); - } while ( - responseData.cursor.more === true && - responseData.cursor.hasNext === true - ); + } while (responseData.cursor.more === true && responseData.cursor.hasNext === true); return returnData; - } catch(error) { + } catch (error) { throw error; } } diff --git a/packages/nodes-base/nodes/Drift/ContactDescription.ts b/packages/nodes-base/nodes/Drift/ContactDescription.ts index c423ab5a27741..1b0f9e97a288c 100644 --- a/packages/nodes-base/nodes/Drift/ContactDescription.ts +++ b/packages/nodes-base/nodes/Drift/ContactDescription.ts @@ -8,9 +8,7 @@ export const contactOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'contact', - ], + resource: ['contact'], }, }, options: [ @@ -50,10 +48,9 @@ export const contactOperations: INodeProperties[] = [ ]; export const contactFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* contact:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contact:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Email', name: 'email', @@ -63,12 +60,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, description: 'The email of the contact', @@ -81,12 +74,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, options: [ @@ -106,9 +95,9 @@ export const contactFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* contact:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contact:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'Contact ID', name: 'contactId', @@ -117,12 +106,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, description: 'Unique identifier for the contact', @@ -135,12 +120,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, options: [ @@ -168,9 +149,9 @@ export const contactFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* contact:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contact:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Contact ID', name: 'contactId', @@ -179,19 +160,15 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], + resource: ['contact'], + operation: ['get'], }, }, description: 'Unique identifier for the contact', }, -/* -------------------------------------------------------------------------- */ -/* contact:delete */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* contact:delete */ + /* -------------------------------------------------------------------------- */ { displayName: 'Contact ID', name: 'contactId', @@ -200,12 +177,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'delete', - ], + resource: ['contact'], + operation: ['delete'], }, }, description: 'Unique identifier for the contact', diff --git a/packages/nodes-base/nodes/Drift/Drift.node.ts b/packages/nodes-base/nodes/Drift/Drift.node.ts index 66eaf8a9221b8..e2781af87add1 100644 --- a/packages/nodes-base/nodes/Drift/Drift.node.ts +++ b/packages/nodes-base/nodes/Drift/Drift.node.ts @@ -1,22 +1,8 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; -import { - IDataObject, - INodeExecutionData, - INodeType, - INodeTypeDescription, -} from 'n8n-workflow'; -import { - driftApiRequest, -} from './GenericFunctions'; -import { - contactFields, - contactOperations, -} from './ContactDescription'; -import { - IContact, -} from './ContactInterface'; +import { IExecuteFunctions } from 'n8n-core'; +import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; +import { driftApiRequest } from './GenericFunctions'; +import { contactFields, contactOperations } from './ContactDescription'; +import { IContact } from './ContactInterface'; export class Drift implements INodeType { description: INodeTypeDescription = { @@ -39,9 +25,7 @@ export class Drift implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -50,9 +34,7 @@ export class Drift implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -116,7 +98,9 @@ export class Drift implements INodeType { if (additionalFields.phone) { body.phone = additionalFields.phone as string; } - responseData = await driftApiRequest.call(this, 'POST', '/contacts', { attributes: body }); + responseData = await driftApiRequest.call(this, 'POST', '/contacts', { + attributes: body, + }); responseData = responseData.data; } //https://devdocs.drift.com/docs/updating-a-contact @@ -133,7 +117,9 @@ export class Drift implements INodeType { if (updateFields.email) { body.email = updateFields.email as string; } - responseData = await driftApiRequest.call(this, 'PATCH', `/contacts/${contactId}`, { attributes: body }); + responseData = await driftApiRequest.call(this, 'PATCH', `/contacts/${contactId}`, { + attributes: body, + }); responseData = responseData.data; } //https://devdocs.drift.com/docs/retrieving-contact diff --git a/packages/nodes-base/nodes/Drift/GenericFunctions.ts b/packages/nodes-base/nodes/Drift/GenericFunctions.ts index 424b35ce754fe..2115aeca0222e 100644 --- a/packages/nodes-base/nodes/Drift/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Drift/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,7 +10,17 @@ import { NodeOperationError, } from 'n8n-workflow'; -export async function driftApiRequest(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 driftApiRequest( + 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 { let options: OptionsWithUri = { headers: {}, method, diff --git a/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts b/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts index b75870a90d6b4..fbee220a58aa5 100644 --- a/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts +++ b/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts @@ -36,9 +36,7 @@ export class Dropbox implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -47,9 +45,7 @@ export class Dropbox implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -104,9 +100,7 @@ export class Dropbox implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'file', - ], + resource: ['file'], }, }, options: [ @@ -151,9 +145,7 @@ export class Dropbox implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'folder', - ], + resource: ['folder'], }, }, options: [ @@ -198,9 +190,7 @@ export class Dropbox implements INodeType { noDataExpression: true, displayOptions: { show: { - resource: [ - 'search', - ], + resource: ['search'], }, }, options: [ @@ -228,13 +218,8 @@ export class Dropbox implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'copy', - ], - resource: [ - 'file', - 'folder', - ], + operation: ['copy'], + resource: ['file', 'folder'], }, }, placeholder: '/invoices/original.txt', @@ -248,13 +233,8 @@ export class Dropbox implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'copy', - ], - resource: [ - 'file', - 'folder', - ], + operation: ['copy'], + resource: ['file', 'folder'], }, }, placeholder: '/invoices/copy.txt', @@ -272,20 +252,14 @@ export class Dropbox 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.', }, - // ---------------------------------- // file/folder:move // ---------------------------------- @@ -297,13 +271,8 @@ export class Dropbox implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'move', - ], - resource: [ - 'file', - 'folder', - ], + operation: ['move'], + resource: ['file', 'folder'], }, }, placeholder: '/invoices/old_name.txt', @@ -317,13 +286,8 @@ export class Dropbox implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'move', - ], - resource: [ - 'file', - 'folder', - ], + operation: ['move'], + resource: ['file', 'folder'], }, }, placeholder: '/invoices/new_name.txt', @@ -341,12 +305,8 @@ export class Dropbox implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'download', - ], - resource: [ - 'file', - ], + operation: ['download'], + resource: ['file'], }, }, placeholder: '/invoices/2019/invoice_1.pdf', @@ -360,12 +320,8 @@ export class Dropbox 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', @@ -382,16 +338,13 @@ export class Dropbox implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'upload', - ], - resource: [ - 'file', - ], + operation: ['upload'], + resource: ['file'], }, }, placeholder: '/invoices/2019/invoice_1.pdf', - description: 'The 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 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', @@ -400,12 +353,8 @@ export class Dropbox 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', @@ -417,17 +366,10 @@ export class Dropbox 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', @@ -440,20 +382,14 @@ export class Dropbox 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', }, // ---------------------------------- @@ -467,15 +403,12 @@ export class Dropbox implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'query', - ], - resource: [ - 'search', - ], + operation: ['query'], + resource: ['search'], }, }, - description: 'The string to search for. May match across multiple fields based on the request arguments.', + description: + 'The string to search for. May match across multiple fields based on the request arguments.', }, { displayName: 'File Status', @@ -494,15 +427,12 @@ export class Dropbox implements INodeType { default: 'active', displayOptions: { show: { - operation: [ - 'query', - ], - resource: [ - 'search', - ], + operation: ['query'], + resource: ['search'], }, }, - description: 'The string to search for. May match across multiple fields based on the request arguments.', + description: + 'The string to search for. May match across multiple fields based on the request arguments.', }, { displayName: 'Return All', @@ -510,12 +440,8 @@ export class Dropbox implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'query', - ], - resource: [ - 'search', - ], + operation: ['query'], + resource: ['search'], }, }, default: false, @@ -530,15 +456,9 @@ export class Dropbox implements INodeType { }, displayOptions: { show: { - resource: [ - 'search', - ], - operation: [ - 'query', - ], - returnAll: [ - false, - ], + resource: ['search'], + operation: ['query'], + returnAll: [false], }, }, default: 100, @@ -550,16 +470,13 @@ export class Dropbox implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'query', - ], - resource: [ - 'search', - ], + operation: ['query'], + resource: ['search'], }, }, 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', }, { displayName: 'Filters', @@ -569,12 +486,8 @@ export class Dropbox implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'search', - ], - operation: [ - 'query', - ], + resource: ['search'], + operation: ['query'], }, }, options: [ @@ -637,7 +550,8 @@ export class Dropbox implements INodeType { name: 'file_extensions', type: 'string', default: '', - description: 'Multiple file extensions can be set separated by comma. Example: jpg,pdf.', + description: + 'Multiple file extensions can be set separated by comma. Example: jpg,pdf.', }, { displayName: 'Folder', @@ -664,12 +578,8 @@ export class Dropbox implements INodeType { required: true, displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'folder', - ], + operation: ['create'], + resource: ['folder'], }, }, placeholder: '/invoices/2019', @@ -686,12 +596,8 @@ export class Dropbox implements INodeType { default: '', displayOptions: { show: { - operation: [ - 'list', - ], - resource: [ - 'folder', - ], + operation: ['list'], + resource: ['folder'], }, }, placeholder: '/invoices/2019/', @@ -703,12 +609,8 @@ export class Dropbox implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'list', - ], - resource: [ - 'folder', - ], + operation: ['list'], + resource: ['folder'], }, }, default: false, @@ -723,15 +625,9 @@ export class Dropbox implements INodeType { }, displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'list', - ], - returnAll: [ - false, - ], + resource: ['folder'], + operation: ['list'], + returnAll: [false], }, }, default: 100, @@ -745,12 +641,8 @@ export class Dropbox implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'folder', - ], - operation: [ - 'list', - ], + resource: ['folder'], + operation: ['list'], }, }, options: [ @@ -759,47 +651,50 @@ export class Dropbox implements INodeType { name: 'include_deleted', type: 'boolean', default: false, - description: 'Whether the results will include entries for files and folders that used to exist but were deleted. The default for this field is False.', + description: + 'Whether the results will include entries for files and folders that used to exist but were deleted. The default for this field is False.', }, { displayName: 'Include Shared Members', name: 'include_has_explicit_shared_members', type: 'boolean', default: false, - description: 'Whether the results will include a flag for each file indicating whether or not that file has any explicit members. The default for this field is False.', + description: + 'Whether the results will include a flag for each file indicating whether or not that file has any explicit members. The default for this field is False.', }, { displayName: 'Include Mounted Folders', name: 'include_mounted_folders', type: 'boolean', default: true, - description: 'Whether the results will include entries under mounted folders which includes app folder, shared folder and team folder. The default for this field is True.', + description: + 'Whether the results will include entries under mounted folders which includes app folder, shared folder and team folder. The default for this field is True.', }, { displayName: 'Include Non Downloadable Files', name: 'include_non_downloadable_files', type: 'boolean', default: true, - description: 'Whether to include files that are not downloadable, i.e. Google Docs. The default for this field is True.', + description: + 'Whether to include files that are not downloadable, i.e. Google Docs. The default for this field is True.', }, { displayName: 'Recursive', name: 'recursive', type: 'boolean', default: false, - description: 'Whether the list folder operation will be applied recursively to all subfolders and the response will contain contents of all subfolders. The default for this field is False.', + description: + 'Whether the list folder operation will be applied recursively to all subfolders and the response will contain contents of all subfolders. The default for this field is False.', }, ], }, ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: IDataObject[] = []; - const resource = this.getNodeParameter('resource', 0) as string; const operation = this.getNodeParameter('operation', 0) as string; @@ -814,17 +709,18 @@ export class Dropbox implements INodeType { let headers: IDataObject = {}; let simple = false; - const { accessType } = await getCredentials.call(this); if (accessType === 'full') { // get the root directory to set it as the default for all operations - const { root_info: { root_namespace_id } } = await getRootDirectory.call(this); + const { + root_info: { root_namespace_id }, + } = await getRootDirectory.call(this); headers = { 'dropbox-api-path-root': JSON.stringify({ '.tag': 'root', - 'root': root_namespace_id, + root: root_namespace_id, }), }; } @@ -846,7 +742,6 @@ export class Dropbox implements INodeType { }); endpoint = 'https://content.dropboxapi.com/2/files/download'; - } else if (operation === 'upload') { // ---------------------------------- // upload @@ -865,18 +760,23 @@ export class Dropbox implements INodeType { options = { json: false }; if (this.getNodeParameter('binaryData', i) === true) { - // Is binary file to 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 }, + ); } body = await this.helpers.getBinaryDataBuffer(i, propertyNameUpload); @@ -897,7 +797,6 @@ export class Dropbox implements INodeType { }; endpoint = 'https://api.dropboxapi.com/2/files/create_folder_v2'; - } else if (operation === 'list') { // ---------------------------------- // list @@ -923,7 +822,6 @@ export class Dropbox implements INodeType { Object.assign(body, filters); endpoint = 'https://api.dropboxapi.com/2/files/list_folder'; - } } else if (resource === 'search') { if (operation === 'query') { @@ -974,7 +872,6 @@ export class Dropbox implements INodeType { }; endpoint = 'https://api.dropboxapi.com/2/files/copy_v2'; - } else if (operation === 'delete') { // ---------------------------------- // delete @@ -986,7 +883,6 @@ export class Dropbox implements INodeType { }; endpoint = 'https://api.dropboxapi.com/2/files/delete_v2'; - } else if (operation === 'move') { // ---------------------------------- // move @@ -1001,7 +897,9 @@ export class Dropbox implements INodeType { endpoint = 'https://api.dropboxapi.com/2/files/move_v2'; } } 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 (resource === 'file' && operation === 'download') { @@ -1012,9 +910,25 @@ export class Dropbox implements INodeType { let responseData; if (returnAll === true) { - responseData = await dropboxpiRequestAllItems.call(this, property, requestMethod, endpoint, body, query, headers); + responseData = await dropboxpiRequestAllItems.call( + this, + property, + requestMethod, + endpoint, + body, + query, + headers, + ); } else { - responseData = await dropboxApiRequest.call(this, requestMethod, endpoint, body, query, headers, options); + responseData = await dropboxApiRequest.call( + this, + requestMethod, + endpoint, + body, + query, + headers, + options, + ); } if (resource === 'file' && operation === 'upload') { @@ -1022,7 +936,6 @@ export class Dropbox implements INodeType { } if (resource === 'file' && operation === 'download') { - const newItem: INodeExecutionData = { json: items[i].json, binary: {}, @@ -1040,23 +953,24 @@ export class Dropbox implements INodeType { const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string; const filePathDownload = this.getNodeParameter('path', i) as string; - items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(Buffer.from(responseData), filePathDownload); - + items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( + Buffer.from(responseData), + filePathDownload, + ); } else if (resource === 'folder' && operation === 'list') { - const propNames: { [key: string]: string } = { - 'id': 'id', - 'name': 'name', - 'client_modified': 'lastModifiedClient', - 'server_modified': 'lastModifiedServer', - 'rev': 'rev', - 'size': 'contentSize', + id: 'id', + name: 'name', + client_modified: 'lastModifiedClient', + server_modified: 'lastModifiedServer', + rev: 'rev', + size: 'contentSize', '.tag': 'type', - 'content_hash': 'contentHash', - 'path_lower': 'pathLower', - 'path_display': 'pathDisplay', - 'has_explicit_shared_members': 'hasExplicitSharedMembers', - 'is_downloadable': 'isDownloadable', + content_hash: 'contentHash', + path_lower: 'pathLower', + path_display: 'pathDisplay', + has_explicit_shared_members: 'hasExplicitSharedMembers', + is_downloadable: 'isDownloadable', }; if (returnAll === false) { @@ -1077,18 +991,24 @@ export class Dropbox implements INodeType { } } else if (resource === 'search' && operation === 'query') { if (returnAll === true) { - returnData.push.apply(returnData, (simple === true) ? simplify(responseData) : responseData); + returnData.push.apply( + returnData, + simple === true ? simplify(responseData) : responseData, + ); } else { - returnData.push.apply(returnData, (simple === true) ? simplify(responseData[property]) : responseData[property]); + returnData.push.apply( + returnData, + simple === true ? simplify(responseData[property]) : responseData[property], + ); } } else { returnData.push(responseData); } } catch (error) { if (this.continueOnFail()) { - if (resource === 'file' && operation === 'download'){ + 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/Dropbox/GenericFunctions.ts b/packages/nodes-base/nodes/Dropbox/GenericFunctions.ts index a05cc8dd132cd..825e2ddaf90e8 100644 --- a/packages/nodes-base/nodes/Dropbox/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Dropbox/GenericFunctions.ts @@ -1,15 +1,8 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; /** * Make an API request to Dropbox @@ -20,8 +13,16 @@ import { * @param {object} body * @returns {Promise} */ -export async function dropboxApiRequest(this: IHookFunctions | IExecuteFunctions, method: string, endpoint: string, body: object, query: IDataObject = {}, headers: object = {}, option: IDataObject = {}): Promise {// tslint:disable-line:no-any - +export async function dropboxApiRequest( + this: IHookFunctions | IExecuteFunctions, + method: string, + endpoint: string, + body: object, + query: IDataObject = {}, + headers: object = {}, + option: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const options: OptionsWithUri = { headers, method, @@ -41,7 +42,7 @@ export async function dropboxApiRequest(this: IHookFunctions | IExecuteFunctions try { if (authenticationMethod === 'accessToken') { - return await this.helpers.requestWithAuthentication.call(this,'dropboxApi',options); + return await this.helpers.requestWithAuthentication.call(this, 'dropboxApi', options); } else { return await this.helpers.requestOAuth2.call(this, 'dropboxOAuth2Api', options); } @@ -50,15 +51,24 @@ export async function dropboxApiRequest(this: IHookFunctions | IExecuteFunctions } } -export async function dropboxpiRequestAllItems(this: IExecuteFunctions | IHookFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}, headers: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function dropboxpiRequestAllItems( + this: IExecuteFunctions | IHookFunctions, + 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 resource = this.getNodeParameter('resource', 0) as string; const returnData: IDataObject[] = []; const paginationEndpoint: IDataObject = { - 'folder': 'https://api.dropboxapi.com/2/files/list_folder/continue', - 'search': 'https://api.dropboxapi.com/2/files/search/continue_v2', + folder: 'https://api.dropboxapi.com/2/files/list_folder/continue', + search: 'https://api.dropboxapi.com/2/files/search/continue_v2', }; let responseData; @@ -70,15 +80,18 @@ export async function dropboxpiRequestAllItems(this: IExecuteFunctions | IHookFu body = { cursor }; } returnData.push.apply(returnData, responseData[propertyName]); - } while ( - responseData.has_more !== false - ); + } while (responseData.has_more !== false); return returnData; } export function getRootDirectory(this: IHookFunctions | IExecuteFunctions) { - return dropboxApiRequest.call(this, 'POST', 'https://api.dropboxapi.com/2/users/get_current_account', {}); + return dropboxApiRequest.call( + this, + 'POST', + 'https://api.dropboxapi.com/2/users/get_current_account', + {}, + ); } export function simplify(data: IDataObject[]) { @@ -99,9 +112,8 @@ export function simplify(data: IDataObject[]) { export async function getCredentials(this: IExecuteFunctions) { const authenticationMethod = this.getNodeParameter('authentication', 0) as string; if (authenticationMethod === 'accessToken') { - return await this.getCredentials('dropboxApi') as IDataObject; + return (await this.getCredentials('dropboxApi')) as IDataObject; } else { - return await this.getCredentials('dropboxOAuth2Api') as IDataObject; + return (await this.getCredentials('dropboxOAuth2Api')) as IDataObject; } } - diff --git a/packages/nodes-base/nodes/Dropcontact/Dropcontact.node.ts b/packages/nodes-base/nodes/Dropcontact/Dropcontact.node.ts index f76f46660ddf3..bb2062d2d49c1 100644 --- a/packages/nodes-base/nodes/Dropcontact/Dropcontact.node.ts +++ b/packages/nodes-base/nodes/Dropcontact/Dropcontact.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -14,10 +12,7 @@ import { NodeApiError, } from 'n8n-workflow'; -import { - dropcontactApiRequest, - validateCredentials, -} from './GenericFunction'; +import { dropcontactApiRequest, validateCredentials } from './GenericFunction'; export class Dropcontact implements INodeType { description: INodeTypeDescription = { @@ -82,12 +77,8 @@ export class Dropcontact implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'fetchRequest', - ], + resource: ['contact'], + operation: ['fetchRequest'], }, }, default: '', @@ -99,12 +90,8 @@ export class Dropcontact implements INodeType { placeholder: 'name@email.com', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'enrich', - ], + resource: ['contact'], + operation: ['enrich'], }, }, default: '', @@ -115,17 +102,14 @@ export class Dropcontact implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'enrich', - ], + resource: ['contact'], + operation: ['enrich'], }, }, default: false, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'When off, waits for the contact data before completing. Waiting time can be adjusted with Extend Wait Time option. When on, returns a request_id that can be used later in the Fetch Request operation.', + description: + 'When off, waits for the contact data before completing. Waiting time can be adjusted with Extend Wait Time option. When on, returns a request_id that can be used later in the Fetch Request operation.', }, { displayName: 'Additional Fields', @@ -135,12 +119,8 @@ export class Dropcontact implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'enrich', - ], + resource: ['contact'], + operation: ['enrich'], }, }, options: [ @@ -212,12 +192,8 @@ export class Dropcontact implements INodeType { type: 'collection', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'enrich', - ], + resource: ['contact'], + operation: ['enrich'], }, }, placeholder: 'Add Option', @@ -232,20 +208,20 @@ export class Dropcontact implements INodeType { }, displayOptions: { show: { - '/simplify': [ - false, - ], + '/simplify': [false], }, }, default: 45, - description: 'When not simplifying the response, data will be fetched in two steps. This parameter controls how long to wait (in seconds) before trying the second step.', + description: + 'When not simplifying the response, data will be fetched in two steps. This parameter controls how long to wait (in seconds) before trying the second step.', }, { displayName: 'French Company Enrich', name: 'siren', type: 'boolean', default: false, - description: 'Whether you want the SIREN number, NAF code, TVA number, company address and informations about the company leader. Only applies to french companies.', + description: + 'Whether you want the SIREN number, NAF code, TVA number, company address and informations about the company leader. Only applies to french companies.', }, { displayName: 'Language', @@ -271,7 +247,10 @@ export class Dropcontact implements INodeType { methods = { credentialTest: { - async dropcontactApiCredentialTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { + async dropcontactApiCredentialTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, + ): Promise { try { await validateCredentials.call(this, credential.data as ICredentialDataDecryptedObject); } catch (error) { @@ -317,22 +296,36 @@ export class Dropcontact implements INodeType { data.push(body); } - responseData = await dropcontactApiRequest.call(this, 'POST', '/batch', { data, siren, language }, {}) as { request_id: string, error: string, success: boolean }; + responseData = (await dropcontactApiRequest.call( + this, + 'POST', + '/batch', + { data, siren, language }, + {}, + )) as { request_id: string; error: string; success: boolean }; if (!responseData.success) { if (this.continueOnFail()) { returnData.push({ error: responseData.reason || 'invalid request' }); } else { - throw new NodeApiError(this.getNode(), { error: responseData.reason || 'invalid request' }); + throw new NodeApiError(this.getNode(), { + error: responseData.reason || 'invalid request', + }); } } if (simplify === false) { const waitTime = this.getNodeParameter('options.waitTime', 0, 45) as number; // tslint:disable-next-line: no-any - const delay = (ms: any) => new Promise(res => setTimeout(res, ms * 1000)); + const delay = (ms: any) => new Promise((res) => setTimeout(res, ms * 1000)); await delay(waitTime); - responseData = await dropcontactApiRequest.call(this, 'GET', `/batch/${responseData.request_id}`, {}, {}); + responseData = await dropcontactApiRequest.call( + this, + 'GET', + `/batch/${responseData.request_id}`, + {}, + {}, + ); if (!responseData.success) { if (this.continueOnFail()) { responseData.push({ error: responseData.reason }); @@ -353,12 +346,20 @@ export class Dropcontact implements INodeType { if (operation === 'fetchRequest') { for (let i = 0; i < entryData.length; i++) { const requestId = this.getNodeParameter('requestId', i) as string; - responseData = await dropcontactApiRequest.call(this, 'GET', `/batch/${requestId}`, {}, {}) as { request_id: string, error: string, success: boolean }; + responseData = (await dropcontactApiRequest.call( + this, + 'GET', + `/batch/${requestId}`, + {}, + {}, + )) as { request_id: string; error: string; success: boolean }; if (!responseData.success) { if (this.continueOnFail()) { responseData.push({ error: responseData.reason || 'invalid request' }); } else { - throw new NodeApiError(this.getNode(), { error: responseData.reason || 'invalid request' }); + throw new NodeApiError(this.getNode(), { + error: responseData.reason || 'invalid request', + }); } } returnData.push(...responseData.data); diff --git a/packages/nodes-base/nodes/Dropcontact/GenericFunction.ts b/packages/nodes-base/nodes/Dropcontact/GenericFunction.ts index 362ae78f801e7..dafd841c4b588 100644 --- a/packages/nodes-base/nodes/Dropcontact/GenericFunction.ts +++ b/packages/nodes-base/nodes/Dropcontact/GenericFunction.ts @@ -1,7 +1,4 @@ -import { - IExecuteFunctions, - IHookFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IHookFunctions } from 'n8n-core'; import { ICredentialDataDecryptedObject, @@ -11,9 +8,7 @@ import { NodeApiError, } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; /** * Make an authenticated API request to Bubble. @@ -25,9 +20,8 @@ export async function dropcontactApiRequest( body: IDataObject, qs: IDataObject, ) { - - const { apiKey } = await this.getCredentials('dropcontactApi') as { - apiKey: string, + const { apiKey } = (await this.getCredentials('dropcontactApi')) as { + apiKey: string; }; const options: OptionsWithUri = { @@ -57,11 +51,15 @@ export async function dropcontactApiRequest( } } -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 { apiKey } = credentials as { - apiKey: string, + apiKey: string; }; const options: OptionsWithUri = { @@ -79,4 +77,3 @@ export async function validateCredentials(this: ICredentialTestFunctions, decryp return this.helpers.request!(options); } - diff --git a/packages/nodes-base/nodes/ERPNext/DocumentDescription.ts b/packages/nodes-base/nodes/ERPNext/DocumentDescription.ts index 001c18eedeb92..bcc26f6f3cfae 100644 --- a/packages/nodes-base/nodes/ERPNext/DocumentDescription.ts +++ b/packages/nodes-base/nodes/ERPNext/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: [ @@ -63,16 +59,13 @@ export const documentFields: INodeProperties[] = [ loadOptionsMethod: 'getDocTypes', }, default: '', - description: 'DocType whose documents to retrieve. Choose from the list, or specify an ID using an expression.', + description: + 'DocType whose documents to retrieve. Choose from the list, or specify an ID using an expression.', placeholder: 'Customer', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'getAll', - ], + resource: ['document'], + operation: ['getAll'], }, }, }, @@ -84,12 +77,8 @@ export const documentFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'getAll', - ], + resource: ['document'], + operation: ['getAll'], }, }, }, @@ -104,15 +93,9 @@ export const documentFields: INodeProperties[] = [ description: 'Max number of results to return', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['document'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -124,12 +107,8 @@ export const documentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'getAll', - ], + resource: ['document'], + operation: ['getAll'], }, }, options: [ @@ -139,12 +118,11 @@ export const documentFields: INodeProperties[] = [ type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getDocFilters', - loadOptionsDependsOn: [ - 'docType', - ], + loadOptionsDependsOn: ['docType'], }, default: [], - description: 'Comma-separated list of fields to return. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated list of fields to return. Choose from the list, or specify IDs using an expression.', placeholder: 'name,country', }, { @@ -166,12 +144,11 @@ export const documentFields: 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: 'getDocFields', - loadOptionsDependsOn: [ - 'docType', - ], + loadOptionsDependsOn: ['docType'], }, default: '', }, @@ -233,16 +210,13 @@ export const documentFields: INodeProperties[] = [ loadOptionsMethod: 'getDocTypes', }, required: true, - description: 'DocType you would like to create. Choose from the list, or specify an ID using an expression.', + description: + 'DocType you would like to create. Choose from the list, or specify an ID using an expression.', placeholder: 'Customer', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'create', - ], + resource: ['document'], + operation: ['create'], }, }, }, @@ -258,12 +232,8 @@ export const documentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'create', - ], + resource: ['document'], + operation: ['create'], }, }, options: [ @@ -276,12 +246,11 @@ export const documentFields: 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: 'getDocFields', - loadOptionsDependsOn: [ - 'docType', - ], + loadOptionsDependsOn: ['docType'], }, default: [], }, @@ -307,15 +276,12 @@ export const documentFields: INodeProperties[] = [ loadOptionsMethod: 'getDocTypes', }, default: '', - description: 'The type of document you would like to get. Choose from the list, or specify an ID using an expression.', + description: + 'The type of document you would like to get. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'get', - ], + resource: ['document'], + operation: ['get'], }, }, required: true, @@ -328,12 +294,8 @@ export const documentFields: INodeProperties[] = [ description: 'The name (ID) of document you would like to get', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'get', - ], + resource: ['document'], + operation: ['get'], }, }, required: true, @@ -350,15 +312,12 @@ export const documentFields: INodeProperties[] = [ loadOptionsMethod: 'getDocTypes', }, default: '', - description: 'The type of document you would like to delete. Choose from the list, or specify an ID using an expression.', + description: + 'The type of document you would like to delete. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'delete', - ], + resource: ['document'], + operation: ['delete'], }, }, required: true, @@ -371,12 +330,8 @@ export const documentFields: INodeProperties[] = [ description: 'The name (ID) of document you would like to get', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'delete', - ], + resource: ['document'], + operation: ['delete'], }, }, required: true, @@ -393,15 +348,12 @@ export const documentFields: INodeProperties[] = [ loadOptionsMethod: 'getDocTypes', }, default: '', - description: 'The type of document you would like to update. Choose from the list, or specify an ID using an expression.', + description: + 'The type of document you would like to update. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'update', - ], + resource: ['document'], + operation: ['update'], }, }, required: true, @@ -414,12 +366,8 @@ export const documentFields: INodeProperties[] = [ description: 'The name (ID) of document you would like to get', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'update', - ], + resource: ['document'], + operation: ['update'], }, }, required: true, @@ -436,12 +384,8 @@ export const documentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'update', - ], + resource: ['document'], + operation: ['update'], }, }, options: [ @@ -453,12 +397,11 @@ export const documentFields: 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: 'getDocFields', - loadOptionsDependsOn: [ - 'docType', - ], + loadOptionsDependsOn: ['docType'], }, default: '', }, diff --git a/packages/nodes-base/nodes/ERPNext/ERPNext.node.ts b/packages/nodes-base/nodes/ERPNext/ERPNext.node.ts index 00cd20452d0d7..188bdfd12d87e 100644 --- a/packages/nodes-base/nodes/ERPNext/ERPNext.node.ts +++ b/packages/nodes-base/nodes/ERPNext/ERPNext.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,21 +11,11 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - documentFields, - documentOperations, -} from './DocumentDescription'; +import { documentFields, documentOperations } from './DocumentDescription'; -import { - erpNextApiRequest, - erpNextApiRequestAllItems -} from './GenericFunctions'; +import { erpNextApiRequest, erpNextApiRequestAllItems } from './GenericFunctions'; -import { - DocumentProperties, - processNames, - toSQL, -} from './utils'; +import { DocumentProperties, processNames, toSQL } from './utils'; export class ERPNext implements INodeType { description: INodeTypeDescription = { @@ -71,7 +59,13 @@ export class ERPNext implements INodeType { methods = { loadOptions: { async getDocTypes(this: ILoadOptionsFunctions): Promise { - const data = await erpNextApiRequestAllItems.call(this, 'data', 'GET', '/api/resource/DocType', {}); + const data = await erpNextApiRequestAllItems.call( + this, + 'data', + 'GET', + '/api/resource/DocType', + {}, + ); const docTypes = data.map(({ name }: { name: string }) => { return { name, value: encodeURI(name) }; }); @@ -80,11 +74,18 @@ export class ERPNext implements INodeType { }, async getDocFilters(this: ILoadOptionsFunctions): Promise { const docType = this.getCurrentNodeParameter('docType') as string; - const { data } = await erpNextApiRequest.call(this, 'GET', `/api/resource/DocType/${docType}`, {}); - - const docFields = data.fields.map(({ label, fieldname }: { label: string, fieldname: string }) => { - return ({ name: label, value: fieldname }); - }); + const { data } = await erpNextApiRequest.call( + this, + 'GET', + `/api/resource/DocType/${docType}`, + {}, + ); + + const docFields = data.fields.map( + ({ label, fieldname }: { label: string; fieldname: string }) => { + return { name: label, value: fieldname }; + }, + ); docFields.unshift({ name: '*', value: '*' }); @@ -92,11 +93,18 @@ export class ERPNext implements INodeType { }, async getDocFields(this: ILoadOptionsFunctions): Promise { const docType = this.getCurrentNodeParameter('docType') as string; - const { data } = await erpNextApiRequest.call(this, 'GET', `/api/resource/DocType/${docType}`, {}); - - const docFields = data.fields.map(({ label, fieldname }: { label: string, fieldname: string }) => { - return ({ name: label, value: fieldname }); - }); + const { data } = await erpNextApiRequest.call( + this, + 'GET', + `/api/resource/DocType/${docType}`, + {}, + ); + + const docFields = data.fields.map( + ({ label, fieldname }: { label: string; fieldname: string }) => { + return { name: label, value: fieldname }; + }, + ); return processNames(docFields); }, @@ -116,18 +124,15 @@ export class ERPNext implements INodeType { const operation = this.getNodeParameter('operation', 0) as string; for (let i = 0; i < items.length; i++) { - // https://app.swaggerhub.com/apis-docs/alyf.de/ERPNext/11#/Resources/post_api_resource_Webhook // https://frappeframework.com/docs/user/en/guides/integration/rest_api/manipulating_documents if (resource === 'document') { - // ********************************************************************* // document // ********************************************************************* if (operation === 'get') { - // ---------------------------------- // document: get // ---------------------------------- @@ -137,12 +142,15 @@ export class ERPNext implements INodeType { const docType = this.getNodeParameter('docType', i) as string; const documentName = this.getNodeParameter('documentName', i) as string; - responseData = await erpNextApiRequest.call(this, 'GET', `/api/resource/${docType}/${documentName}`); + responseData = await erpNextApiRequest.call( + this, + 'GET', + `/api/resource/${docType}/${documentName}`, + ); responseData = responseData.data; } if (operation === 'getAll') { - // ---------------------------------- // document: getAll // ---------------------------------- @@ -152,14 +160,11 @@ export class ERPNext implements INodeType { const docType = this.getNodeParameter('docType', i) as string; const endpoint = `/api/resource/${docType}`; - const { - fields, - filters, - } = this.getNodeParameter('options', i) as { - fields: string[], + const { fields, filters } = this.getNodeParameter('options', i) as { + fields: string[]; filters: { - customProperty: Array<{ field: string, operator: string, value: string }>, - }, + customProperty: Array<{ field: string; operator: string; value: string }>; + }; }; // fields=["test", "example", "hi"] @@ -173,14 +178,11 @@ export class ERPNext implements INodeType { // filters=[["Person","first_name","=","Jane"]] // TODO: filters not working if (filters) { - qs.filters = JSON.stringify(filters.customProperty.map((filter) => { - return [ - docType, - filter.field, - toSQL(filter.operator), - filter.value, - ]; - })); + qs.filters = JSON.stringify( + filters.customProperty.map((filter) => { + return [docType, filter.field, toSQL(filter.operator), filter.value]; + }), + ); } const returnAll = this.getNodeParameter('returnAll', i) as boolean; @@ -191,13 +193,17 @@ export class ERPNext implements INodeType { qs.limit_start = 0; responseData = await erpNextApiRequest.call(this, 'GET', endpoint, {}, qs); responseData = responseData.data; - } else { - responseData = await erpNextApiRequestAllItems.call(this, 'data', 'GET', endpoint, {}, qs); + responseData = await erpNextApiRequestAllItems.call( + this, + 'data', + 'GET', + endpoint, + {}, + qs, + ); } - } else if (operation === 'create') { - // ---------------------------------- // document: create // ---------------------------------- @@ -207,20 +213,27 @@ export class ERPNext implements INodeType { const properties = this.getNodeParameter('properties', i) as DocumentProperties; if (!properties.customProperty.length) { - throw new NodeOperationError(this.getNode(), 'Please enter at least one property for the document to create.', { itemIndex: i },); + throw new NodeOperationError( + this.getNode(), + 'Please enter at least one property for the document to create.', + { itemIndex: i }, + ); } - properties.customProperty.forEach(property => { + properties.customProperty.forEach((property) => { body[property.field] = property.value; }); const docType = this.getNodeParameter('docType', i) as string; - responseData = await erpNextApiRequest.call(this, 'POST', `/api/resource/${docType}`, body); + responseData = await erpNextApiRequest.call( + this, + 'POST', + `/api/resource/${docType}`, + body, + ); responseData = responseData.data; - } else if (operation === 'delete') { - // ---------------------------------- // document: delete // ---------------------------------- @@ -230,10 +243,12 @@ export class ERPNext implements INodeType { const docType = this.getNodeParameter('docType', i) as string; const documentName = this.getNodeParameter('documentName', i) as string; - responseData = await erpNextApiRequest.call(this, 'DELETE', `/api/resource/${docType}/${documentName}`); - + responseData = await erpNextApiRequest.call( + this, + 'DELETE', + `/api/resource/${docType}/${documentName}`, + ); } else if (operation === 'update') { - // ---------------------------------- // document: update // ---------------------------------- @@ -243,26 +258,33 @@ export class ERPNext implements INodeType { const properties = this.getNodeParameter('properties', i) as DocumentProperties; if (!properties.customProperty.length) { - throw new NodeOperationError(this.getNode(), 'Please enter at least one property for the document to update.', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Please enter at least one property for the document to update.', + { itemIndex: i }, + ); } - properties.customProperty.forEach(property => { + properties.customProperty.forEach((property) => { body[property.field] = property.value; }); const docType = this.getNodeParameter('docType', i) as string; const documentName = this.getNodeParameter('documentName', i) as string; - responseData = await erpNextApiRequest.call(this, 'PUT', `/api/resource/${docType}/${documentName}`, body); + responseData = await erpNextApiRequest.call( + this, + 'PUT', + `/api/resource/${docType}/${documentName}`, + body, + ); responseData = responseData.data; - } } Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } return [this.helpers.returnJsonArray(returnData)]; } diff --git a/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts b/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts index 81b799b35da61..a4dd0ef82704d 100644 --- a/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts @@ -1,18 +1,8 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, - IHookFunctions, - IWebhookFunctions, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, IHookFunctions, IWebhookFunctions, NodeApiError } from 'n8n-workflow'; export async function erpNextApiRequest( this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, @@ -23,12 +13,12 @@ export async function erpNextApiRequest( uri?: string, option: IDataObject = {}, ) { - const credentials = await this.getCredentials('erpNextApi') as ERPNextApiCredentials; + const credentials = (await this.getCredentials('erpNextApi')) as ERPNextApiCredentials; const baseUrl = getBaseUrl(credentials); let options: OptionsWithUri = { headers: { - 'Accept': 'application/json', + Accept: 'application/json', 'Content-Type': 'application/json', }, method, @@ -49,18 +39,19 @@ export async function erpNextApiRequest( delete options.qs; } try { - return await this.helpers.requestWithAuthentication.call(this, 'erpNextApi',options); + return await this.helpers.requestWithAuthentication.call(this, 'erpNextApi', options); } catch (error) { if (error.statusCode === 403) { throw new NodeApiError(this.getNode(), { message: 'DocType unavailable.' }); } if (error.statusCode === 307) { - throw new NodeApiError(this.getNode(), { message: 'Please ensure the subdomain is correct.' }); + throw new NodeApiError(this.getNode(), { + message: 'Please ensure the subdomain is correct.', + }); } throw new NodeApiError(this.getNode(), error); - } } @@ -83,9 +74,7 @@ export async function erpNextApiRequestAllItems( responseData = await erpNextApiRequest.call(this, method, resource, body, query); returnData.push.apply(returnData, responseData[propertyName]); query!.limit_start += query!.limit_page_length - 1; - } while ( - responseData.data && responseData.data.length > 0 - ); + } while (responseData.data && responseData.data.length > 0); return returnData; } @@ -94,9 +83,7 @@ export async function erpNextApiRequestAllItems( * Return the base API URL based on the user's environment. */ const getBaseUrl = ({ environment, domain, subdomain }: ERPNextApiCredentials) => - environment === 'cloudHosted' - ? `https://${subdomain}.erpnext.com` - : domain; + environment === 'cloudHosted' ? `https://${subdomain}.erpnext.com` : domain; type ERPNextApiCredentials = { apiKey: string; diff --git a/packages/nodes-base/nodes/ERPNext/utils.ts b/packages/nodes-base/nodes/ERPNext/utils.ts index 3d9852d8ebd92..95c25770d96fe 100644 --- a/packages/nodes-base/nodes/ERPNext/utils.ts +++ b/packages/nodes-base/nodes/ERPNext/utils.ts @@ -1,29 +1,25 @@ -import { - flow, - sortBy, - uniqBy, -} from 'lodash'; +import { flow, sortBy, uniqBy } from 'lodash'; export type DocumentProperties = { - customProperty: Array<{ field: string; value: string; }>; + customProperty: Array<{ field: string; value: string }>; }; -type DocFields = Array<{ name: string, value: string }>; +type DocFields = Array<{ name: string; value: string }>; -const ensureName = (docFields: DocFields) => docFields.filter(o => o.name); +const ensureName = (docFields: DocFields) => docFields.filter((o) => o.name); const sortByName = (docFields: DocFields) => sortBy(docFields, ['name']); -const uniqueByName = (docFields: DocFields) => uniqBy(docFields, o => o.name); +const uniqueByName = (docFields: DocFields) => uniqBy(docFields, (o) => o.name); export const processNames = flow(ensureName, sortByName, uniqueByName); export const toSQL = (operator: string) => { const operators: { [key: string]: string } = { - 'is': '=', - 'isNot': '!=', - 'greater': '>', - 'less': '<', - 'equalsGreater': '>=', - 'equalsLess': '<=', + is: '=', + isNot: '!=', + greater: '>', + less: '<', + equalsGreater: '>=', + equalsLess: '<=', }; return operators[operator]; diff --git a/packages/nodes-base/nodes/EditImage/EditImage.node.ts b/packages/nodes-base/nodes/EditImage/EditImage.node.ts index f3e148b227af3..d9bdab6c3abee 100644 --- a/packages/nodes-base/nodes/EditImage/EditImage.node.ts +++ b/packages/nodes-base/nodes/EditImage/EditImage.node.ts @@ -1,7 +1,4 @@ -import { - BINARY_ENCODING, - IExecuteFunctions, -} from 'n8n-core'; +import { BINARY_ENCODING, IExecuteFunctions } from 'n8n-core'; import { IDataObject, ILoadOptionsFunctions, @@ -14,17 +11,12 @@ import { } from 'n8n-workflow'; import gm from 'gm'; import { file } from 'tmp-promise'; -import { - parse as pathParse, -} from 'path'; -import { - writeFile as fsWriteFile, -} from 'fs'; +import { parse as pathParse } from 'path'; +import { writeFile as fsWriteFile } from 'fs'; import { promisify } from 'util'; const fsWriteFileAsync = promisify(fsWriteFile); import getSystemFonts from 'get-system-fonts'; - const nodeOperations: INodePropertyOptions[] = [ { name: 'Blur', @@ -83,9 +75,7 @@ const nodeOperations: INodePropertyOptions[] = [ }, ]; - const nodeOperationOptions: INodeProperties[] = [ - // ---------------------------------- // create // ---------------------------------- @@ -99,9 +89,7 @@ const nodeOperationOptions: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], }, }, description: 'The background color of the image to create', @@ -116,9 +104,7 @@ const nodeOperationOptions: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], }, }, description: 'The width of the image to create', @@ -133,15 +119,12 @@ const nodeOperationOptions: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], }, }, description: 'The height of the image to create', }, - // ---------------------------------- // draw // ---------------------------------- @@ -151,9 +134,7 @@ const nodeOperationOptions: INodeProperties[] = [ type: 'options', displayOptions: { show: { - operation: [ - 'draw', - ], + operation: ['draw'], }, }, options: [ @@ -183,9 +164,7 @@ const nodeOperationOptions: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'draw', - ], + operation: ['draw'], }, }, description: 'The color of the primitive to draw', @@ -197,14 +176,8 @@ const nodeOperationOptions: INodeProperties[] = [ default: 50, displayOptions: { show: { - operation: [ - 'draw', - ], - primitive: [ - 'circle', - 'line', - 'rectangle', - ], + operation: ['draw'], + primitive: ['circle', 'line', 'rectangle'], }, }, description: 'X (horizontal) start position of the primitive', @@ -216,14 +189,8 @@ const nodeOperationOptions: INodeProperties[] = [ default: 50, displayOptions: { show: { - operation: [ - 'draw', - ], - primitive: [ - 'circle', - 'line', - 'rectangle', - ], + operation: ['draw'], + primitive: ['circle', 'line', 'rectangle'], }, }, description: 'Y (horizontal) start position of the primitive', @@ -235,14 +202,8 @@ const nodeOperationOptions: INodeProperties[] = [ default: 250, displayOptions: { show: { - operation: [ - 'draw', - ], - primitive: [ - 'circle', - 'line', - 'rectangle', - ], + operation: ['draw'], + primitive: ['circle', 'line', 'rectangle'], }, }, description: 'X (horizontal) end position of the primitive', @@ -254,14 +215,8 @@ const nodeOperationOptions: INodeProperties[] = [ default: 250, displayOptions: { show: { - operation: [ - 'draw', - ], - primitive: [ - 'circle', - 'line', - 'rectangle', - ], + operation: ['draw'], + primitive: ['circle', 'line', 'rectangle'], }, }, description: 'Y (horizontal) end position of the primitive', @@ -273,12 +228,8 @@ const nodeOperationOptions: INodeProperties[] = [ default: 0, displayOptions: { show: { - operation: [ - 'draw', - ], - primitive: [ - 'rectangle', - ], + operation: ['draw'], + primitive: ['rectangle'], }, }, description: 'The radius of the corner to create round corners', @@ -298,9 +249,7 @@ const nodeOperationOptions: INodeProperties[] = [ placeholder: 'Text to render', displayOptions: { show: { - operation: [ - 'text', - ], + operation: ['text'], }, }, description: 'Text to write on the image', @@ -312,9 +261,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 18, displayOptions: { show: { - operation: [ - 'text', - ], + operation: ['text'], }, }, description: 'Size of the text', @@ -326,9 +273,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: '#000000', displayOptions: { show: { - operation: [ - 'text', - ], + operation: ['text'], }, }, description: 'Color of the text', @@ -340,9 +285,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 50, displayOptions: { show: { - operation: [ - 'text', - ], + operation: ['text'], }, }, description: 'X (horizontal) position of the text', @@ -354,9 +297,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 50, displayOptions: { show: { - operation: [ - 'text', - ], + operation: ['text'], }, }, description: 'Y (vertical) position of the text', @@ -371,9 +312,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 80, displayOptions: { show: { - operation: [ - 'text', - ], + operation: ['text'], }, }, description: 'Max amount of characters in a line before a line-break should get added', @@ -393,9 +332,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 5, displayOptions: { show: { - operation: [ - 'blur', - ], + operation: ['blur'], }, }, description: 'How strong the blur should be', @@ -411,15 +348,12 @@ const nodeOperationOptions: INodeProperties[] = [ default: 2, displayOptions: { show: { - operation: [ - 'blur', - ], + operation: ['blur'], }, }, description: 'The sigma of the blur', }, - // ---------------------------------- // border // ---------------------------------- @@ -430,9 +364,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 10, displayOptions: { show: { - operation: [ - 'border', - ], + operation: ['border'], }, }, description: 'The width of the border', @@ -444,9 +376,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 10, displayOptions: { show: { - operation: [ - 'border', - ], + operation: ['border'], }, }, description: 'The height of the border', @@ -458,15 +388,12 @@ const nodeOperationOptions: INodeProperties[] = [ default: '#000000', displayOptions: { show: { - operation: [ - 'border', - ], + operation: ['border'], }, }, description: 'Color of the border', }, - // ---------------------------------- // composite // ---------------------------------- @@ -478,12 +405,11 @@ const nodeOperationOptions: INodeProperties[] = [ placeholder: 'data2', displayOptions: { show: { - operation: [ - 'composite', - ], + operation: ['composite'], }, }, - description: 'The name of the binary property which contains the data of the image to composite on top of image which is found in Property Name', + description: + 'The name of the binary property which contains the data of the image to composite on top of image which is found in Property Name', }, { displayName: 'Operator', @@ -491,9 +417,7 @@ const nodeOperationOptions: INodeProperties[] = [ type: 'options', displayOptions: { show: { - operation: [ - 'composite', - ], + operation: ['composite'], }, }, options: [ @@ -596,9 +520,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 0, displayOptions: { show: { - operation: [ - 'composite', - ], + operation: ['composite'], }, }, description: 'X (horizontal) position of composite image', @@ -610,9 +532,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 0, displayOptions: { show: { - operation: [ - 'composite', - ], + operation: ['composite'], }, }, description: 'Y (vertical) position of composite image', @@ -628,9 +548,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 500, displayOptions: { show: { - operation: [ - 'crop', - ], + operation: ['crop'], }, }, description: 'Crop width', @@ -642,9 +560,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 500, displayOptions: { show: { - operation: [ - 'crop', - ], + operation: ['crop'], }, }, description: 'Crop height', @@ -656,9 +572,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 0, displayOptions: { show: { - operation: [ - 'crop', - ], + operation: ['crop'], }, }, description: 'X (horizontal) position to crop from', @@ -670,9 +584,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 0, displayOptions: { show: { - operation: [ - 'crop', - ], + operation: ['crop'], }, }, description: 'Y (vertical) position to crop from', @@ -688,9 +600,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 500, displayOptions: { show: { - operation: [ - 'resize', - ], + operation: ['resize'], }, }, description: 'New width of the image', @@ -702,9 +612,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 500, displayOptions: { show: { - operation: [ - 'resize', - ], + operation: ['resize'], }, }, description: 'New height of the image', @@ -748,9 +656,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 'maximumArea', displayOptions: { show: { - operation: [ - 'resize', - ], + operation: ['resize'], }, }, description: 'How to resize the image', @@ -770,9 +676,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 0, displayOptions: { show: { - operation: [ - 'rotate', - ], + operation: ['rotate'], }, }, description: 'How much the image should be rotated', @@ -787,15 +691,13 @@ const nodeOperationOptions: INodeProperties[] = [ }, displayOptions: { show: { - operation: [ - 'rotate', - ], + operation: ['rotate'], }, }, - description: 'The color to use for the background when image gets rotated by anything which is not a multiple of 90', + description: + 'The color to use for the background when image gets rotated by anything which is not a multiple of 90', }, - // ---------------------------------- // shear // ---------------------------------- @@ -806,9 +708,7 @@ const nodeOperationOptions: INodeProperties[] = [ default: 0, displayOptions: { show: { - operation: [ - 'shear', - ], + operation: ['shear'], }, }, description: 'X (horizontal) shear degrees', @@ -820,15 +720,12 @@ const nodeOperationOptions: INodeProperties[] = [ default: 0, displayOptions: { show: { - operation: [ - 'shear', - ], + operation: ['shear'], }, }, description: 'Y (vertical) shear degrees', }, - // ---------------------------------- // transparent // ---------------------------------- @@ -839,16 +736,13 @@ const nodeOperationOptions: INodeProperties[] = [ default: '#ff0000', displayOptions: { show: { - operation: [ - 'transparent', - ], + operation: ['transparent'], }, }, description: 'The color to make transparent', }, ]; - export class EditImage implements INodeType { description: INodeTypeDescription = { displayName: 'Edit Image', @@ -882,8 +776,18 @@ export class EditImage implements INodeType { }, ...nodeOperations, ].sort((a, b) => { - if ((a as INodePropertyOptions).name.toLowerCase() < (b as INodePropertyOptions).name.toLowerCase()) { return -1; } - if ((a as INodePropertyOptions).name.toLowerCase() > (b as INodePropertyOptions).name.toLowerCase()) { return 1; } + if ( + (a as INodePropertyOptions).name.toLowerCase() < + (b as INodePropertyOptions).name.toLowerCase() + ) { + return -1; + } + if ( + (a as INodePropertyOptions).name.toLowerCase() > + (b as INodePropertyOptions).name.toLowerCase() + ) { + return 1; + } return 0; }) as INodePropertyOptions[], default: 'border', @@ -896,7 +800,6 @@ export class EditImage implements INodeType { description: 'Name of the binary property in which the image data can be found', }, - // ---------------------------------- // multiStep // ---------------------------------- @@ -911,9 +814,7 @@ export class EditImage implements INodeType { }, displayOptions: { show: { - operation: [ - 'multiStep', - ], + operation: ['multiStep'], }, }, description: 'The operations to perform', @@ -938,16 +839,15 @@ export class EditImage implements INodeType { type: 'options', displayOptions: { show: { - 'operation': [ - 'text', - ], + operation: ['text'], }, }, typeOptions: { loadOptionsMethod: 'getFonts', }, default: 'default', - description: 'The font to use. Choose from the list, or specify an ID using an expression.', + description: + 'The font to use. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -963,9 +863,7 @@ export class EditImage implements INodeType { default: {}, displayOptions: { hide: { - operation: [ - 'information', - ], + operation: ['information'], }, }, options: [ @@ -982,16 +880,15 @@ export class EditImage implements INodeType { type: 'options', displayOptions: { show: { - '/operation': [ - 'text', - ], + '/operation': ['text'], }, }, typeOptions: { loadOptionsMethod: 'getFonts', }, default: 'default', - description: 'The font to use. Choose from the list, or specify an ID using an expression.', + description: + 'The font to use. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Format', @@ -1033,11 +930,7 @@ export class EditImage implements INodeType { default: 100, displayOptions: { show: { - format: [ - 'jpeg', - 'png', - 'tiff', - ], + format: ['jpeg', 'png', 'tiff'], }, }, description: 'Sets the jpeg|png|tiff compression level from 0 to 100 (best)', @@ -1047,11 +940,9 @@ export class EditImage implements INodeType { ], }; - methods = { loadOptions: { async getFonts(this: ILoadOptionsFunctions): Promise { - // @ts-ignore const files = await getSystemFonts(); const returnData: INodePropertyOptions[] = []; @@ -1069,8 +960,12 @@ export class EditImage 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; }); @@ -1081,7 +976,6 @@ export class EditImage implements INodeType { return returnData; }, - }, }; @@ -1093,50 +987,26 @@ export class EditImage implements INodeType { let item: INodeExecutionData; for (let itemIndex = 0; itemIndex < length; itemIndex++) { - try { - item = items[itemIndex]; - const operation = this.getNodeParameter('operation', itemIndex) as string; const dataPropertyName = this.getNodeParameter('dataPropertyName', itemIndex) as string; - const options = this.getNodeParameter('options', itemIndex,{}) as IDataObject; + const options = this.getNodeParameter('options', itemIndex, {}) as IDataObject; const cleanupFunctions: Array<() => void> = []; let gmInstance: gm.State; const requiredOperationParameters: { - [key: string]: string[], + [key: string]: string[]; } = { - blur: [ - 'blur', - 'sigma', - ], - border: [ - 'borderColor', - 'borderWidth', - 'borderHeight', - ], - create: [ - 'backgroundColor', - 'height', - 'width', - ], - crop: [ - 'height', - 'positionX', - 'positionY', - 'width', - ], - composite: [ - 'dataPropertyNameComposite', - 'operator', - 'positionX', - 'positionY', - ], + blur: ['blur', 'sigma'], + border: ['borderColor', 'borderWidth', 'borderHeight'], + create: ['backgroundColor', 'height', 'width'], + crop: ['height', 'positionX', 'positionY', 'width'], + composite: ['dataPropertyNameComposite', 'operator', 'positionX', 'positionY'], draw: [ 'color', 'cornerRadius', @@ -1147,39 +1017,23 @@ export class EditImage implements INodeType { 'startPositionY', ], information: [], - resize: [ - 'height', - 'resizeOption', - 'width', - ], - rotate: [ - 'backgroundColor', - 'rotate', - ], - shear: [ - 'degreesX', - 'degreesY', - ], - text: [ - 'font', - 'fontColor', - 'fontSize', - 'lineLength', - 'positionX', - 'positionY', - 'text', - ], + resize: ['height', 'resizeOption', 'width'], + rotate: ['backgroundColor', 'rotate'], + shear: ['degreesX', 'degreesY'], + text: ['font', 'fontColor', 'fontSize', 'lineLength', 'positionX', 'positionY', 'text'], }; let operations: IDataObject[] = []; if (operation === 'multiStep') { // Operation parameters are already in the correct format - const operationsData = this.getNodeParameter('operations', itemIndex ,{ operations: [] }) as IDataObject; + const operationsData = this.getNodeParameter('operations', itemIndex, { + operations: [], + }) as IDataObject; operations = operationsData.operations as IDataObject[]; } else { // Operation parameters have to first get collected const operationParameters: IDataObject = {}; - requiredOperationParameters[operation].forEach(parameterName => { + requiredOperationParameters[operation].forEach((parameterName) => { try { operationParameters[parameterName] = this.getNodeParameter(parameterName, itemIndex); } catch (error) {} @@ -1196,14 +1050,23 @@ export class EditImage implements INodeType { if (operations[0].operation !== 'create') { // "create" generates a new image so does not require any incoming data. if (item.binary === undefined) { - throw new NodeOperationError(this.getNode(), 'Item does not contain any binary data.', { itemIndex }); + throw new NodeOperationError(this.getNode(), 'Item does not contain any binary data.', { + itemIndex, + }); } if (item.binary[dataPropertyName as string] === undefined) { - throw new NodeOperationError(this.getNode(), `Item does not contain any binary data with the name "${dataPropertyName}".`, { itemIndex }); + throw new NodeOperationError( + this.getNode(), + `Item does not contain any binary data with the name "${dataPropertyName}".`, + { itemIndex }, + ); } - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, dataPropertyName); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + itemIndex, + dataPropertyName, + ); gmInstance = gm(binaryDataBuffer); gmInstance = gmInstance.background('transparent'); } @@ -1234,29 +1097,45 @@ export class EditImage implements INodeType { for (let i = 0; i < operations.length; i++) { const operationData = operations[i]; if (operationData.operation === 'blur') { - gmInstance = gmInstance!.blur(operationData.blur as number, operationData.sigma as number); + gmInstance = gmInstance!.blur( + operationData.blur as number, + operationData.sigma as number, + ); } else if (operationData.operation === 'border') { - gmInstance = gmInstance!.borderColor(operationData.borderColor as string).border(operationData.borderWidth as number, operationData.borderHeight as number); + gmInstance = gmInstance! + .borderColor(operationData.borderColor as string) + .border(operationData.borderWidth as number, operationData.borderHeight as number); } else if (operationData.operation === 'composite') { const positionX = operationData.positionX as number; const positionY = operationData.positionY as number; const operator = operationData.operator as string; - const geometryString = (positionX >= 0 ? '+' : '') + positionX + (positionY >= 0 ? '+' : '') + positionY; + const geometryString = + (positionX >= 0 ? '+' : '') + positionX + (positionY >= 0 ? '+' : '') + positionY; if (item.binary![operationData.dataPropertyNameComposite as string] === undefined) { - throw new NodeOperationError(this.getNode(), `Item does not contain any binary data with the name "${operationData.dataPropertyNameComposite}".`, { itemIndex }); + throw new NodeOperationError( + this.getNode(), + `Item does not contain any binary data with the name "${operationData.dataPropertyNameComposite}".`, + { itemIndex }, + ); } const { fd, path, cleanup } = await file(); cleanupFunctions.push(cleanup); - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, operationData.dataPropertyNameComposite as string); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + itemIndex, + operationData.dataPropertyNameComposite as string, + ); await fsWriteFileAsync(fd, binaryDataBuffer); if (operations[0].operation === 'create') { // It seems like if the image gets created newly we have to create a new gm instance // else it fails for some reason - gmInstance = gm(gmInstance!.stream('png')).compose(operator).geometry(geometryString).composite(path); + gmInstance = gm(gmInstance!.stream('png')) + .compose(operator) + .geometry(geometryString) + .composite(path); } else { gmInstance = gmInstance!.compose(operator).geometry(geometryString).composite(path); } @@ -1267,21 +1146,46 @@ export class EditImage implements INodeType { gmInstance = gm(gmInstance.stream()); } } else if (operationData.operation === 'create') { - gmInstance = gm(operationData.width as number, operationData.height as number, operationData.backgroundColor as string); - if (!options.format) { - options.format = 'png'; - } + gmInstance = gm( + operationData.width as number, + operationData.height as number, + operationData.backgroundColor as string, + ); + if (!options.format) { + options.format = 'png'; + } } else if (operationData.operation === 'crop') { - gmInstance = gmInstance!.crop(operationData.width as number, operationData.height as number, operationData.positionX as number, operationData.positionY as number); + gmInstance = gmInstance!.crop( + operationData.width as number, + operationData.height as number, + operationData.positionX as number, + operationData.positionY as number, + ); } else if (operationData.operation === 'draw') { gmInstance = gmInstance!.fill(operationData.color as string); if (operationData.primitive === 'line') { - gmInstance = gmInstance.drawLine(operationData.startPositionX as number, operationData.startPositionY as number, operationData.endPositionX as number, operationData.endPositionY as number); + gmInstance = gmInstance.drawLine( + operationData.startPositionX as number, + operationData.startPositionY as number, + operationData.endPositionX as number, + operationData.endPositionY as number, + ); } else if (operationData.primitive === 'circle') { - gmInstance = gmInstance.drawCircle(operationData.startPositionX as number, operationData.startPositionY as number, operationData.endPositionX as number, operationData.endPositionY as number); + gmInstance = gmInstance.drawCircle( + operationData.startPositionX as number, + operationData.startPositionY as number, + operationData.endPositionX as number, + operationData.endPositionY as number, + ); } else if (operationData.primitive === 'rectangle') { - gmInstance = gmInstance.drawRectangle(operationData.startPositionX as number, operationData.startPositionY as number, operationData.endPositionX as number, operationData.endPositionY as number, operationData.cornerRadius as number || undefined); + gmInstance = gmInstance.drawRectangle( + operationData.startPositionX as number, + operationData.startPositionY as number, + operationData.endPositionX as number, + operationData.endPositionY as number, + (operationData.cornerRadius as number) || undefined, + ); } } else if (operationData.operation === 'resize') { const resizeOption = operationData.resizeOption as string; @@ -1300,18 +1204,31 @@ export class EditImage implements INodeType { option = '%'; } - gmInstance = gmInstance!.resize(operationData.width as number, operationData.height as number, option); + gmInstance = gmInstance!.resize( + operationData.width as number, + operationData.height as number, + option, + ); } else if (operationData.operation === 'rotate') { - gmInstance = gmInstance!.rotate(operationData.backgroundColor as string, operationData.rotate as number); + gmInstance = gmInstance!.rotate( + operationData.backgroundColor as string, + operationData.rotate as number, + ); } else if (operationData.operation === 'shear') { - gmInstance = gmInstance!.shear(operationData.degreesX as number, operationData.degreesY as number); + gmInstance = gmInstance!.shear( + operationData.degreesX as number, + operationData.degreesY as number, + ); } else if (operationData.operation === 'text') { // Split the text in multiple lines const lines: string[] = []; let currentLine = ''; (operationData.text as string).split('\n').forEach((textLine: string) => { textLine.split(' ').forEach((textPart: string) => { - if ((currentLine.length + textPart.length + 1) > (operationData.lineLength as number)) { + if ( + currentLine.length + textPart.length + 1 > + (operationData.lineLength as number) + ) { lines.push(currentLine.trim()); currentLine = `${textPart} `; return; @@ -1335,10 +1252,14 @@ export class EditImage implements INodeType { gmInstance = gmInstance! .fill(operationData.fontColor as string) .fontSize(operationData.fontSize as number) - .drawText(operationData.positionX as number, operationData.positionY as number, renderText); - } else if (operationData.operation === 'transparent') { - gmInstance = gmInstance!.transparent(operationData.color as string); - } + .drawText( + operationData.positionX as number, + operationData.positionY as number, + renderText, + ); + } else if (operationData.operation === 'transparent') { + gmInstance = gmInstance!.transparent(operationData.color as string); + } } if (item.binary !== undefined) { @@ -1348,7 +1269,9 @@ export class EditImage implements INodeType { Object.assign(newItem.binary, item.binary); // Make a deep copy of the binary data we change if (newItem.binary![dataPropertyName as string]) { - newItem.binary![dataPropertyName as string] = JSON.parse(JSON.stringify(newItem.binary![dataPropertyName as string])); + newItem.binary![dataPropertyName as string] = JSON.parse( + JSON.stringify(newItem.binary![dataPropertyName as string]), + ); } } @@ -1369,7 +1292,8 @@ export class EditImage implements INodeType { newItem.binary![dataPropertyName as string].mimeType = `image/${options.format}`; const fileName = newItem.binary![dataPropertyName as string].fileName; if (fileName && fileName.includes('.')) { - newItem.binary![dataPropertyName as string].fileName = fileName.split('.').slice(0, -1).join('.') + '.' + options.format; + newItem.binary![dataPropertyName as string].fileName = + fileName.split('.').slice(0, -1).join('.') + '.' + options.format; } } @@ -1377,10 +1301,10 @@ export class EditImage implements INodeType { newItem.binary![dataPropertyName as string].fileName = options.fileName as string; } - returnData.push(await (new Promise((resolve, reject) => { - gmInstance - .toBuffer(async (error: Error | null, buffer: Buffer) => { - cleanupFunctions.forEach(async cleanup => await cleanup()); + returnData.push( + await new Promise((resolve, reject) => { + gmInstance.toBuffer(async (error: Error | null, buffer: Buffer) => { + cleanupFunctions.forEach(async (cleanup) => await cleanup()); if (error) { return reject(error); @@ -1388,13 +1312,14 @@ export class EditImage implements INodeType { const binaryData = await this.helpers.prepareBinaryData(Buffer.from(buffer)); newItem.binary![dataPropertyName as string] = { - ...newItem.binary![dataPropertyName as string], ...binaryData, + ...newItem.binary![dataPropertyName as string], + ...binaryData, }; return resolve(newItem); }); - }))); - + }), + ); } catch (error) { if (this.continueOnFail()) { returnData.push({ diff --git a/packages/nodes-base/nodes/Egoi/Egoi.node.ts b/packages/nodes-base/nodes/Egoi/Egoi.node.ts index b0c91897e9bac..cbe3addea4f95 100644 --- a/packages/nodes-base/nodes/Egoi/Egoi.node.ts +++ b/packages/nodes-base/nodes/Egoi/Egoi.node.ts @@ -1,7 +1,4 @@ - -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -12,15 +9,9 @@ import { INodeTypeDescription, } from 'n8n-workflow'; -import { - egoiApiRequest, - egoiApiRequestAllItems, - simplify, -} from './GenericFunctions'; +import { egoiApiRequest, egoiApiRequestAllItems, simplify } from './GenericFunctions'; -import { - ICreateMemberBody, -} from './Interfaces'; +import { ICreateMemberBody } from './Interfaces'; import moment from 'moment-timezone'; @@ -103,16 +94,12 @@ export class Egoi implements INodeType { }, displayOptions: { show: { - operation: [ - 'getAll', - 'create', - 'update', - 'get', - ], + operation: ['getAll', 'create', 'update', 'get'], }, }, default: '', - description: 'ID of list to operate on. Choose from the list, or specify an ID using an expression.', + description: + 'ID of list to operate on. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Email', @@ -121,9 +108,7 @@ export class Egoi implements INodeType { placeholder: 'name@email.com', displayOptions: { show: { - operation: [ - 'create', - ], + operation: ['create'], }, }, default: '', @@ -135,12 +120,8 @@ export class Egoi implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, default: '', @@ -152,15 +133,13 @@ export class Egoi implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'create', - 'update', - ], + operation: ['create', 'update'], }, }, default: true, // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'By default the response just includes the contact ID. If this option gets activated, it will resolve the data automatically.', + description: + 'By default the response just includes the contact ID. If this option gets activated, it will resolve the data automatically.', }, { displayName: 'Additional Fields', @@ -169,12 +148,8 @@ export class Egoi implements INodeType { placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], + operation: ['create'], + resource: ['contact'], }, }, default: {}, @@ -214,12 +189,11 @@ export class Egoi implements INodeType { displayName: 'Field Name or ID', name: 'field_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: 'getExtraFields', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, default: '', }, @@ -270,7 +244,7 @@ export class Egoi implements INodeType { }, ], default: 'active', - description: 'Subscriber\'s current status', + description: "Subscriber's current status", }, { displayName: 'Tag Names or IDs', @@ -280,7 +254,8 @@ export class Egoi implements INodeType { loadOptionsMethod: 'getListTags', }, default: [], - description: 'List of tag IDs to be added. Choose from the list, or specify IDs using an expression.', + description: + 'List of tag IDs to be added. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -295,9 +270,7 @@ export class Egoi implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'update', - ], + operation: ['update'], }, }, options: [ @@ -344,12 +317,11 @@ export class Egoi implements INodeType { displayName: 'Field Name or ID', name: 'field_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: 'getExtraFields', - loadOptionsDependsOn: [ - 'list', - ], + loadOptionsDependsOn: ['list'], }, default: '', }, @@ -398,10 +370,9 @@ export class Egoi implements INodeType { name: 'Removed', value: 'removed', }, - ], default: 'active', - description: 'Subscriber\'s current status', + description: "Subscriber's current status", }, { displayName: 'Tag Names or IDs', @@ -411,7 +382,8 @@ export class Egoi implements INodeType { loadOptionsMethod: 'getListTags', }, default: [], - description: 'List of tag IDs to be added. Choose from the list, or specify IDs using an expression.', + description: + 'List of tag IDs to be added. Choose from the list, or specify IDs using an expression.', }, ], }, @@ -431,12 +403,8 @@ export class Egoi implements INodeType { ], displayOptions: { show: { - operation: [ - 'get', - ], - resource: [ - 'contact', - ], + operation: ['get'], + resource: ['contact'], }, }, default: 'id', @@ -448,15 +416,9 @@ export class Egoi implements INodeType { type: 'string', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], - by: [ - 'id', - ], + resource: ['contact'], + operation: ['get'], + by: ['id'], }, }, default: '', @@ -469,15 +431,9 @@ export class Egoi implements INodeType { placeholder: 'name@email.com', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], - by: [ - 'email', - ], + resource: ['contact'], + operation: ['get'], + by: ['email'], }, }, default: '', @@ -489,12 +445,8 @@ export class Egoi implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], + operation: ['getAll'], + resource: ['contact'], }, }, default: false, @@ -506,15 +458,9 @@ export class Egoi implements INodeType { type: 'number', displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], - returnAll: [ - false, - ], + operation: ['getAll'], + resource: ['contact'], + returnAll: [false], }, }, typeOptions: { @@ -530,17 +476,13 @@ export class Egoi implements INodeType { type: 'boolean', displayOptions: { show: { - operation: [ - 'get', - 'getAll', - ], - resource: [ - 'contact', - ], + operation: ['get', 'getAll'], + resource: ['contact'], }, }, 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', }, ], }; @@ -595,7 +537,6 @@ export class Egoi implements INodeType { }; async execute(this: IExecuteFunctions): Promise { - let responseData; const returnData: IDataObject[] = []; const items = this.getInputData(); @@ -622,11 +563,14 @@ export class Egoi implements INodeType { }; if (additionalFields.birth_date) { - additionalFields.birth_date = moment(additionalFields.birth_date as string).format('YYYY-MM-DD'); + additionalFields.birth_date = moment(additionalFields.birth_date as string).format( + 'YYYY-MM-DD', + ); } if (additionalFields.extraFieldsUi) { - const extraFields = (additionalFields.extraFieldsUi as IDataObject).extraFieldValues as IDataObject[]; + const extraFields = (additionalFields.extraFieldsUi as IDataObject) + .extraFieldValues as IDataObject[]; if (extraFields) { body.extra = extraFields as unknown as []; } @@ -634,24 +578,37 @@ export class Egoi implements INodeType { Object.assign(body.base, additionalFields); - responseData = await egoiApiRequest.call(this, 'POST', `/lists/${listId}/contacts`, body); + responseData = await egoiApiRequest.call( + this, + 'POST', + `/lists/${listId}/contacts`, + body, + ); const contactId = responseData.contact_id; if (additionalFields.tagIds) { const tags = additionalFields.tagIds as string[]; for (const tag of tags) { - await egoiApiRequest.call(this, 'POST', `/lists/${listId}/contacts/actions/attach-tag`, { tag_id: tag, contacts: [contactId] }); + await egoiApiRequest.call( + this, + 'POST', + `/lists/${listId}/contacts/actions/attach-tag`, + { tag_id: tag, contacts: [contactId] }, + ); } } if (resolveData) { - responseData = await egoiApiRequest.call(this, 'GET', `/lists/${listId}/contacts/${contactId}`); + responseData = await egoiApiRequest.call( + this, + 'GET', + `/lists/${listId}/contacts/${contactId}`, + ); } } if (operation === 'get') { - const listId = this.getNodeParameter('list', i) as string; const simple = this.getNodeParameter('simple', i) as boolean; @@ -689,7 +646,6 @@ export class Egoi implements INodeType { } if (operation === 'getAll') { - const listId = this.getNodeParameter('list', i) as string; const returnAll = this.getNodeParameter('returnAll', 0) as boolean; @@ -697,13 +653,23 @@ export class Egoi implements INodeType { const simple = this.getNodeParameter('simple', i) as boolean; if (returnAll) { - - responseData = await egoiApiRequestAllItems.call(this, 'items', 'GET', `/lists/${listId}/contacts`, {}); - + responseData = await egoiApiRequestAllItems.call( + this, + 'items', + 'GET', + `/lists/${listId}/contacts`, + {}, + ); } else { const limit = this.getNodeParameter('limit', i) as number; - responseData = await egoiApiRequest.call(this, 'GET', `/lists/${listId}/contacts`, {}, { limit }); + responseData = await egoiApiRequest.call( + this, + 'GET', + `/lists/${listId}/contacts`, + {}, + { limit }, + ); responseData = responseData.items; } @@ -720,17 +686,19 @@ export class Egoi implements INodeType { const updateFields = this.getNodeParameter('updateFields', i) as IDataObject; const body: ICreateMemberBody = { - base: { - }, + base: {}, extra: [], }; if (updateFields.birth_date) { - updateFields.birth_date = moment(updateFields.birth_date as string).format('YYYY-MM-DD'); + updateFields.birth_date = moment(updateFields.birth_date as string).format( + 'YYYY-MM-DD', + ); } if (updateFields.extraFieldsUi) { - const extraFields = (updateFields.extraFieldsUi as IDataObject).extraFieldValues as IDataObject[]; + const extraFields = (updateFields.extraFieldsUi as IDataObject) + .extraFieldValues as IDataObject[]; if (extraFields) { body.extra = extraFields as unknown as []; } @@ -738,17 +706,31 @@ export class Egoi implements INodeType { Object.assign(body.base, updateFields); - responseData = await egoiApiRequest.call(this, 'PATCH', `/lists/${listId}/contacts/${contactId}`, body); + responseData = await egoiApiRequest.call( + this, + 'PATCH', + `/lists/${listId}/contacts/${contactId}`, + body, + ); if (updateFields.tagIds) { const tags = updateFields.tagIds as string[]; for (const tag of tags) { - await egoiApiRequest.call(this, 'POST', `/lists/${listId}/contacts/actions/attach-tag`, { tag_id: tag, contacts: [contactId] }); + await egoiApiRequest.call( + this, + 'POST', + `/lists/${listId}/contacts/actions/attach-tag`, + { tag_id: tag, contacts: [contactId] }, + ); } } if (resolveData) { - responseData = await egoiApiRequest.call(this, 'GET', `/lists/${listId}/contacts/${contactId}`); + responseData = await egoiApiRequest.call( + this, + 'GET', + `/lists/${listId}/contacts/${contactId}`, + ); } } } @@ -757,11 +739,9 @@ export class Egoi implements INodeType { throw error; } else { // Return the actual reason as error - returnData.push( - { - error: error.message, - }, - ); + returnData.push({ + error: error.message, + }); continue; } } diff --git a/packages/nodes-base/nodes/Egoi/GenericFunctions.ts b/packages/nodes-base/nodes/Egoi/GenericFunctions.ts index cfc79f46e975f..8c18c7bc189de 100644 --- a/packages/nodes-base/nodes/Egoi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Egoi/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUrl, -} from 'request'; +import { OptionsWithUrl } from 'request'; import { IExecuteFunctions, @@ -9,9 +7,7 @@ import { ILoadOptionsFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; interface IContact { tags: []; @@ -23,7 +19,6 @@ const fieldCache: { [key: string]: IDataObject[]; } = {}; - export async function getFields(this: IExecuteFunctions, listId: string) { if (fieldCache[listId]) { return fieldCache[listId]; @@ -32,15 +27,22 @@ export async function getFields(this: IExecuteFunctions, listId: string) { return fieldCache[listId]; } - -export async function egoiApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, qs: IDataObject = {}, headers?: object): Promise { // tslint:disable-line:no-any - +export async function egoiApiRequest( + this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, + method: string, + endpoint: string, + // tslint:disable-next-line:no-any + body: any = {}, + qs: IDataObject = {}, + headers?: object, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('egoiApi'); const options: OptionsWithUrl = { headers: { - 'accept': 'application/json', - 'Apikey': `${credentials.apiKey}`, + accept: 'application/json', + Apikey: `${credentials.apiKey}`, }, method, qs, @@ -54,16 +56,22 @@ export async function egoiApiRequest(this: IHookFunctions | IExecuteFunctions | } try { - return await this.helpers.request!(options); - } catch (error) { throw new NodeApiError(this.getNode(), error); } } -export async function egoiApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function egoiApiRequestAllItems( + 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,14 +83,11 @@ export async function egoiApiRequestAllItems(this: IExecuteFunctions | ILoadOpti responseData = await egoiApiRequest.call(this, method, endpoint, 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 async function simplify(this: IExecuteFunctions, contacts: IContact[], listId: string) { let fields = await getFields.call(this, listId); @@ -96,7 +101,8 @@ export async function simplify(this: IExecuteFunctions, contacts: IContact[], li for (const contact of contacts) { const extras = contact.extra.reduce( - (acumulator: IDataObject, currentValue: IDataObject): any => { // tslint:disable-line:no-any + // tslint:disable-next-line:no-any + (acumulator: IDataObject, currentValue: IDataObject): any => { const key = fieldsKeyValue[currentValue.field_id as string] as string; return { [key]: currentValue.value, ...acumulator }; }, diff --git a/packages/nodes-base/nodes/Egoi/Interfaces.ts b/packages/nodes-base/nodes/Egoi/Interfaces.ts index 5506dfae3efcb..c803fda2d1ad0 100644 --- a/packages/nodes-base/nodes/Egoi/Interfaces.ts +++ b/packages/nodes-base/nodes/Egoi/Interfaces.ts @@ -1,4 +1,3 @@ - export interface ICreateMemberBody { base: { email?: string; diff --git a/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts b/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts index a74c5e9507f15..328918f330552 100644 --- a/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts +++ b/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -42,9 +40,7 @@ import { ElasticSecurityApiCredentials, } from './types'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; export class ElasticSecurity implements INodeType { description: INodeTypeDescription = { @@ -107,13 +103,17 @@ export class ElasticSecurity implements INodeType { methods = { loadOptions: { async getTags(this: ILoadOptionsFunctions): Promise { - const tags = await elasticSecurityApiRequest.call(this, 'GET', '/cases/tags') as string[]; - return tags.map(tag => ({ name: tag, value: tag })); + const tags = (await elasticSecurityApiRequest.call(this, 'GET', '/cases/tags')) as string[]; + return tags.map((tag) => ({ name: tag, value: tag })); }, async getConnectors(this: ILoadOptionsFunctions): Promise { const endpoint = '/cases/configure/connectors/_find'; - const connectors = await elasticSecurityApiRequest.call(this, 'GET', endpoint) as Connector[]; + const connectors = (await elasticSecurityApiRequest.call( + this, + 'GET', + endpoint, + )) as Connector[]; return connectors.map(({ name, id }) => ({ name, value: id })); }, }, @@ -172,17 +172,13 @@ export class ElasticSecurity implements INodeType { let responseData; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'case') { - // ********************************************************************** // case // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // case: create // ---------------------------------------- @@ -208,7 +204,10 @@ export class ElasticSecurity implements INodeType { type: fetchedType, } = await getConnector.call(this, connectorId); - const selectedConnectorType = this.getNodeParameter('connectorType', i) as ConnectorType; + const selectedConnectorType = this.getNodeParameter( + 'connectorType', + i, + ) as ConnectorType; if (fetchedType !== selectedConnectorType) { throw new NodeOperationError( @@ -260,9 +259,7 @@ export class ElasticSecurity implements INodeType { } responseData = await elasticSecurityApiRequest.call(this, 'POST', '/cases', body); - } else if (operation === 'delete') { - // ---------------------------------------- // case: delete // ---------------------------------------- @@ -272,9 +269,7 @@ export class ElasticSecurity implements INodeType { const caseId = this.getNodeParameter('caseId', i); await elasticSecurityApiRequest.call(this, 'DELETE', `/cases?ids=["${caseId}"]`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // case: get // ---------------------------------------- @@ -283,9 +278,7 @@ export class ElasticSecurity implements INodeType { const caseId = this.getNodeParameter('caseId', i); responseData = await elasticSecurityApiRequest.call(this, 'GET', `/cases/${caseId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // case: getAll // ---------------------------------------- @@ -293,10 +286,10 @@ export class ElasticSecurity implements INodeType { // https://www.elastic.co/guide/en/security/current/cases-api-find-cases.html const qs = {} as IDataObject; - const { - tags, - status, - } = this.getNodeParameter('filters', i) as IDataObject & { tags: string[], status: string }; + const { tags, status } = this.getNodeParameter('filters', i) as IDataObject & { + tags: string[]; + status: string; + }; const sortOptions = this.getNodeParameter('sortOptions', i) as IDataObject; qs.sortField = sortOptions.sortField ?? 'createdAt'; @@ -311,9 +304,7 @@ export class ElasticSecurity implements INodeType { } responseData = await handleListing.call(this, 'GET', '/cases/_find', {}, qs); - } else if (operation === 'getStatus') { - // ---------------------------------------- // case: getStatus // ---------------------------------------- @@ -321,9 +312,7 @@ export class ElasticSecurity implements INodeType { // https://www.elastic.co/guide/en/security/current/cases-api-get-status.html responseData = await elasticSecurityApiRequest.call(this, 'GET', '/cases/status'); - } else if (operation === 'update') { - // ---------------------------------------- // case: update // ---------------------------------------- @@ -353,17 +342,13 @@ export class ElasticSecurity implements INodeType { }); responseData = await elasticSecurityApiRequest.call(this, 'PATCH', '/cases', body); - } - } else if (resource === 'caseTag') { - // ********************************************************************** // caseTag // ********************************************************************** if (operation === 'add') { - // ---------------------------------------- // caseTag: add // ---------------------------------------- @@ -372,14 +357,8 @@ export class ElasticSecurity implements INodeType { const caseId = this.getNodeParameter('caseId', i); - const { - title, - connector, - owner, - description, - settings, - tags, - } = await elasticSecurityApiRequest.call(this, 'GET', `/cases/${caseId}`); + const { title, connector, owner, description, settings, tags } = + await elasticSecurityApiRequest.call(this, 'GET', `/cases/${caseId}`); const tagToAdd = this.getNodeParameter('tag', i); @@ -409,25 +388,25 @@ export class ElasticSecurity implements INodeType { }); responseData = await elasticSecurityApiRequest.call(this, 'PATCH', '/cases', body); - } else if (operation === 'remove') { - // https://www.elastic.co/guide/en/security/current/cases-api-update.html const caseId = this.getNodeParameter('caseId', i); const tagToRemove = this.getNodeParameter('tag', i) as string; - const { - title, - connector, - owner, - description, - settings, - tags, - } = await elasticSecurityApiRequest.call(this, 'GET', `/cases/${caseId}`) as IDataObject & { tags: string[] }; + const { title, connector, owner, description, settings, tags } = + (await elasticSecurityApiRequest.call( + this, + 'GET', + `/cases/${caseId}`, + )) as IDataObject & { tags: string[] }; if (!tags.includes(tagToRemove)) { - throw new NodeOperationError(this.getNode(), `Cannot remove tag "${tagToRemove}" from case ID ${caseId} because this case does not have this tag.`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `Cannot remove tag "${tagToRemove}" from case ID ${caseId} because this case does not have this tag.`, + { itemIndex: i }, + ); } const body = {}; @@ -448,17 +427,13 @@ export class ElasticSecurity implements INodeType { }); responseData = await elasticSecurityApiRequest.call(this, 'PATCH', '/cases', body); - } - } else if (resource === 'caseComment') { - // ********************************************************************** // caseComment // ********************************************************************** if (operation === 'add') { - // ---------------------------------------- // caseComment: add // ---------------------------------------- @@ -483,9 +458,7 @@ export class ElasticSecurity implements INodeType { const { comments } = responseData; responseData = comments[comments.length - 1]; } - } else if (operation === 'get') { - // ---------------------------------------- // caseComment: get // ---------------------------------------- @@ -497,9 +470,7 @@ export class ElasticSecurity implements INodeType { const endpoint = `/cases/${caseId}/comments/${commentId}`; responseData = await elasticSecurityApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // caseComment: getAll // ---------------------------------------- @@ -510,9 +481,7 @@ export class ElasticSecurity implements INodeType { const endpoint = `/cases/${caseId}/comments`; responseData = await handleListing.call(this, 'GET', endpoint); - } else if (operation === 'remove') { - // ---------------------------------------- // caseComment: remove // ---------------------------------------- @@ -525,9 +494,7 @@ export class ElasticSecurity implements INodeType { const endpoint = `/cases/${caseId}/comments/${commentId}`; await elasticSecurityApiRequest.call(this, 'DELETE', endpoint); responseData = { success: true }; - } else if (operation === 'update') { - // ---------------------------------------- // caseComment: update // ---------------------------------------- @@ -553,13 +520,9 @@ export class ElasticSecurity implements INodeType { const { comments } = responseData; responseData = comments[comments.length - 1]; } - } - } else if (resource === 'connector') { - if (operation === 'create') { - // ---------------------------------------- // connector: create // ---------------------------------------- @@ -601,16 +564,18 @@ export class ElasticSecurity implements INodeType { }; } - responseData = await elasticSecurityApiRequest.call(this, 'POST', '/actions/connector', body); - + responseData = await elasticSecurityApiRequest.call( + this, + 'POST', + '/actions/connector', + body, + ); } - } Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -618,7 +583,6 @@ export class ElasticSecurity implements INodeType { } throw error; } - } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts b/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts index cf6aa17406dd9..0d2628ce47b5c 100644 --- a/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts @@ -1,22 +1,10 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; - -import { - IDataObject, - ILoadOptionsFunctions, - NodeApiError, - NodeOperationError, -} from 'n8n-workflow'; - -import { - OptionsWithUri, -} from 'request'; - -import { - Connector, - ElasticSecurityApiCredentials, -} from './types'; +import { IExecuteFunctions } from 'n8n-core'; + +import { IDataObject, ILoadOptionsFunctions, NodeApiError, NodeOperationError } from 'n8n-workflow'; + +import { OptionsWithUri } from 'request'; + +import { Connector, ElasticSecurityApiCredentials } from './types'; export async function elasticSecurityApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, @@ -29,7 +17,7 @@ export async function elasticSecurityApiRequest( username, password, baseUrl: rawBaseUrl, - } = await this.getCredentials('elasticSecurityApi') as ElasticSecurityApiCredentials; + } = (await this.getCredentials('elasticSecurityApi')) as ElasticSecurityApiCredentials; const baseUrl = tolerateTrailingSlash(rawBaseUrl); @@ -83,9 +71,7 @@ export async function elasticSecurityApiRequestAllItems( responseData = await elasticSecurityApiRequest.call(this, method, endpoint, body, qs); page++; - const items = resource === 'case' - ? responseData.cases - : responseData; + const items = resource === 'case' ? responseData.cases : responseData; returnData.push(...items); } while (returnData.length < responseData.total); @@ -106,7 +92,13 @@ export async function handleListing( return await elasticSecurityApiRequestAllItems.call(this, method, endpoint, body, qs); } - const responseData = await elasticSecurityApiRequestAllItems.call(this, method, endpoint, body, qs); + const responseData = await elasticSecurityApiRequestAllItems.call( + this, + method, + endpoint, + body, + qs, + ); const limit = this.getNodeParameter('limit', 0) as number; return responseData.slice(0, limit); @@ -117,35 +109,26 @@ export async function handleListing( * * https://www.elastic.co/guide/en/kibana/master/get-connector-api.html */ -export async function getConnector( - this: IExecuteFunctions, - connectorId: string, -) { +export async function getConnector(this: IExecuteFunctions, connectorId: string) { const endpoint = `/actions/connector/${connectorId}`; const { id, name, connector_type_id: type, - } = await elasticSecurityApiRequest.call(this, 'GET', endpoint) as Connector; + } = (await elasticSecurityApiRequest.call(this, 'GET', endpoint)) as Connector; return { id, name, type }; } -export function throwOnEmptyUpdate( - this: IExecuteFunctions, - resource: string, -) { +export function throwOnEmptyUpdate(this: IExecuteFunctions, resource: string) { throw new NodeOperationError( this.getNode(), `Please enter at least one field to update for the ${resource}`, ); } -export async function getVersion( - this: IExecuteFunctions, - endpoint: string, -) { - const { version } = await elasticSecurityApiRequest.call(this, 'GET', endpoint) as { +export async function getVersion(this: IExecuteFunctions, endpoint: string) { + const { version } = (await elasticSecurityApiRequest.call(this, 'GET', endpoint)) as { version?: string; }; @@ -157,7 +140,5 @@ export async function getVersion( } 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/Elastic/ElasticSecurity/descriptions/CaseCommentDescription.ts b/packages/nodes-base/nodes/Elastic/ElasticSecurity/descriptions/CaseCommentDescription.ts index f5eb454972685..3f2bfcda926ab 100644 --- a/packages/nodes-base/nodes/Elastic/ElasticSecurity/descriptions/CaseCommentDescription.ts +++ b/packages/nodes-base/nodes/Elastic/ElasticSecurity/descriptions/CaseCommentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const caseCommentOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const caseCommentOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'caseComment', - ], + resource: ['caseComment'], }, }, options: [ @@ -64,12 +60,8 @@ export const caseCommentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'caseComment', - ], - operation: [ - 'add', - ], + resource: ['caseComment'], + operation: ['add'], }, }, }, @@ -81,12 +73,8 @@ export const caseCommentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'caseComment', - ], - operation: [ - 'add', - ], + resource: ['caseComment'], + operation: ['add'], }, }, }, @@ -96,12 +84,8 @@ export const caseCommentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'caseComment', - ], - operation: [ - 'add', - ], + resource: ['caseComment'], + operation: ['add'], }, }, default: true, @@ -115,12 +99,8 @@ export const caseCommentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'caseComment', - ], - operation: [ - 'add', - ], + resource: ['caseComment'], + operation: ['add'], }, }, options: [ @@ -128,7 +108,8 @@ export const caseCommentFields: INodeProperties[] = [ displayName: 'Owner', name: 'owner', type: 'string', - description: 'Valid application owner registered within the Cases Role Based Access Control system', + description: + 'Valid application owner registered within the Cases Role Based Access Control system', default: '', }, ], @@ -146,12 +127,8 @@ export const caseCommentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'caseComment', - ], - operation: [ - 'get', - ], + resource: ['caseComment'], + operation: ['get'], }, }, }, @@ -164,12 +141,8 @@ export const caseCommentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'caseComment', - ], - operation: [ - 'get', - ], + resource: ['caseComment'], + operation: ['get'], }, }, }, @@ -185,12 +158,8 @@ export const caseCommentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'caseComment', - ], - operation: [ - 'getAll', - ], + resource: ['caseComment'], + operation: ['getAll'], }, }, }, @@ -202,12 +171,8 @@ export const caseCommentFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'caseComment', - ], - operation: [ - 'getAll', - ], + resource: ['caseComment'], + operation: ['getAll'], }, }, }, @@ -222,15 +187,9 @@ export const caseCommentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'caseComment', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['caseComment'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -247,12 +206,8 @@ export const caseCommentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'caseComment', - ], - operation: [ - 'remove', - ], + resource: ['caseComment'], + operation: ['remove'], }, }, }, @@ -264,12 +219,8 @@ export const caseCommentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'caseComment', - ], - operation: [ - 'remove', - ], + resource: ['caseComment'], + operation: ['remove'], }, }, }, @@ -286,12 +237,8 @@ export const caseCommentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'caseComment', - ], - operation: [ - 'update', - ], + resource: ['caseComment'], + operation: ['update'], }, }, }, @@ -303,12 +250,8 @@ export const caseCommentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'caseComment', - ], - operation: [ - 'update', - ], + resource: ['caseComment'], + operation: ['update'], }, }, }, @@ -321,12 +264,8 @@ export const caseCommentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'caseComment', - ], - operation: [ - 'update', - ], + resource: ['caseComment'], + operation: ['update'], }, }, }, @@ -336,12 +275,8 @@ export const caseCommentFields: INodeProperties[] = [ type: 'boolean', displayOptions: { show: { - resource: [ - 'caseComment', - ], - operation: [ - 'update', - ], + resource: ['caseComment'], + operation: ['update'], }, }, default: true, diff --git a/packages/nodes-base/nodes/Elastic/ElasticSecurity/descriptions/CaseDescription.ts b/packages/nodes-base/nodes/Elastic/ElasticSecurity/descriptions/CaseDescription.ts index 4ed412fe6c04c..f29cc20769ace 100644 --- a/packages/nodes-base/nodes/Elastic/ElasticSecurity/descriptions/CaseDescription.ts +++ b/packages/nodes-base/nodes/Elastic/ElasticSecurity/descriptions/CaseDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const caseOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const caseOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'case', - ], + resource: ['case'], }, }, options: [ @@ -69,19 +65,16 @@ export const caseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], + resource: ['case'], + operation: ['create'], }, }, }, { displayName: 'Connector Name or ID', name: 'connectorId', - description: 'Connectors allow you to send Elastic Security cases into other systems (only ServiceNow, Jira, or IBM Resilient). Choose from the list, or specify an ID using an expression.', + description: + 'Connectors allow you to send Elastic Security cases into other systems (only ServiceNow, Jira, or IBM Resilient). Choose from the list, or specify an ID using an expression.', type: 'options', required: true, default: '', @@ -90,12 +83,8 @@ export const caseFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], + resource: ['case'], + operation: ['create'], }, }, }, @@ -121,12 +110,8 @@ export const caseFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], + resource: ['case'], + operation: ['create'], }, }, }, @@ -140,15 +125,9 @@ export const caseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], - connectorType: [ - '.jira', - ], + resource: ['case'], + operation: ['create'], + connectorType: ['.jira'], }, }, }, @@ -162,15 +141,9 @@ export const caseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], - connectorType: [ - '.jira', - ], + resource: ['case'], + operation: ['create'], + connectorType: ['.jira'], }, }, }, @@ -197,15 +170,9 @@ export const caseFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], - connectorType: [ - '.servicenow', - ], + resource: ['case'], + operation: ['create'], + connectorType: ['.servicenow'], }, }, }, @@ -232,15 +199,9 @@ export const caseFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], - connectorType: [ - '.servicenow', - ], + resource: ['case'], + operation: ['create'], + connectorType: ['.servicenow'], }, }, }, @@ -267,15 +228,9 @@ export const caseFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], - connectorType: [ - '.servicenow', - ], + resource: ['case'], + operation: ['create'], + connectorType: ['.servicenow'], }, }, }, @@ -289,37 +244,26 @@ export const caseFields: INodeProperties[] = [ placeholder: 'Helpdesk', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], - connectorType: [ - '.servicenow', - ], + resource: ['case'], + operation: ['create'], + connectorType: ['.servicenow'], }, }, }, { displayName: 'Issue Types', name: 'issueTypes', - description: 'Comma-separated list of numerical types of the IBM Resilient issue to create for this case', + description: + 'Comma-separated list of numerical types of the IBM Resilient issue to create for this case', type: 'string', placeholder: '123,456', required: true, default: '', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], - connectorType: [ - '.resilient', - ], + resource: ['case'], + operation: ['create'], + connectorType: ['.resilient'], }, }, }, @@ -335,15 +279,9 @@ export const caseFields: INodeProperties[] = [ default: 1, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], - connectorType: [ - '.resilient', - ], + resource: ['case'], + operation: ['create'], + connectorType: ['.resilient'], }, }, }, @@ -355,12 +293,8 @@ export const caseFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'create', - ], + resource: ['case'], + operation: ['create'], }, }, options: [ @@ -374,7 +308,8 @@ export const caseFields: INodeProperties[] = [ displayName: 'Owner', name: 'owner', type: 'string', - description: 'Valid application owner registered within the Cases Role Based Access Control system', + description: + 'Valid application owner registered within the Cases Role Based Access Control system', default: '', }, { @@ -398,12 +333,8 @@ export const caseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'delete', - ], + resource: ['case'], + operation: ['delete'], }, }, }, @@ -419,12 +350,8 @@ export const caseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'get', - ], + resource: ['case'], + operation: ['get'], }, }, }, @@ -440,12 +367,8 @@ export const caseFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'getAll', - ], + resource: ['case'], + operation: ['getAll'], }, }, }, @@ -460,19 +383,13 @@ export const caseFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['case'], + operation: ['getAll'], + returnAll: [false], }, }, }, -{ + { displayName: 'Filters', name: 'filters', type: 'collection', @@ -480,12 +397,8 @@ export const caseFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'getAll', - ], + resource: ['case'], + operation: ['getAll'], }, }, options: [ @@ -513,7 +426,8 @@ export const caseFields: 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', default: [], typeOptions: { loadOptionsMethod: 'getTags', @@ -529,12 +443,8 @@ export const caseFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'getAll', - ], + resource: ['case'], + operation: ['getAll'], }, }, options: [ @@ -590,12 +500,8 @@ export const caseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'update', - ], + resource: ['case'], + operation: ['update'], }, }, }, @@ -607,12 +513,8 @@ export const caseFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'case', - ], - operation: [ - 'update', - ], + resource: ['case'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Elastic/ElasticSecurity/descriptions/CaseTagDescription.ts b/packages/nodes-base/nodes/Elastic/ElasticSecurity/descriptions/CaseTagDescription.ts index 130a58eee4069..73fe8e2331028 100644 --- a/packages/nodes-base/nodes/Elastic/ElasticSecurity/descriptions/CaseTagDescription.ts +++ b/packages/nodes-base/nodes/Elastic/ElasticSecurity/descriptions/CaseTagDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const caseTagOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const caseTagOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'caseTag', - ], + resource: ['caseTag'], }, }, options: [ @@ -45,12 +41,8 @@ export const caseTagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'caseTag', - ], - operation: [ - 'add', - ], + resource: ['caseTag'], + operation: ['add'], }, }, }, @@ -58,7 +50,8 @@ export const caseTagFields: INodeProperties[] = [ displayName: 'Tag Name or ID', name: 'tag', type: 'options', - description: 'Tag to attach to the case. Choose from the list, or specify an ID using an expression.', + description: + 'Tag to attach to the case. Choose from the list, or specify an ID using an expression.', required: true, default: '', typeOptions: { @@ -66,12 +59,8 @@ export const caseTagFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'caseTag', - ], - operation: [ - 'add', - ], + resource: ['caseTag'], + operation: ['add'], }, }, }, @@ -87,12 +76,8 @@ export const caseTagFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'caseTag', - ], - operation: [ - 'remove', - ], + resource: ['caseTag'], + operation: ['remove'], }, }, }, @@ -100,7 +85,8 @@ export const caseTagFields: INodeProperties[] = [ displayName: 'Tag Name or ID', name: 'tag', type: 'options', - 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: { @@ -108,12 +94,8 @@ export const caseTagFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'caseTag', - ], - operation: [ - 'remove', - ], + resource: ['caseTag'], + operation: ['remove'], }, }, }, diff --git a/packages/nodes-base/nodes/Elastic/ElasticSecurity/descriptions/ConnectorDescription.ts b/packages/nodes-base/nodes/Elastic/ElasticSecurity/descriptions/ConnectorDescription.ts index 72e2889bc18b4..aee33d5e2f2a9 100644 --- a/packages/nodes-base/nodes/Elastic/ElasticSecurity/descriptions/ConnectorDescription.ts +++ b/packages/nodes-base/nodes/Elastic/ElasticSecurity/descriptions/ConnectorDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const connectorOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const connectorOperations: INodeProperties[] = [ type: 'options', displayOptions: { show: { - resource: [ - 'connector', - ], + resource: ['connector'], }, }, options: [ @@ -34,18 +30,15 @@ export const connectorFields: INodeProperties[] = [ { displayName: 'Connector Name', name: 'name', - description: 'Connectors allow you to send Elastic Security cases into other systems (only ServiceNow, Jira, or IBM Resilient)', + description: + 'Connectors allow you to send Elastic Security cases into other systems (only ServiceNow, Jira, or IBM Resilient)', type: 'string', required: true, default: '', displayOptions: { show: { - resource: [ - 'connector', - ], - operation: [ - 'create', - ], + resource: ['connector'], + operation: ['create'], }, }, }, @@ -71,12 +64,8 @@ export const connectorFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'connector', - ], - operation: [ - 'create', - ], + resource: ['connector'], + operation: ['create'], }, }, }, @@ -89,12 +78,8 @@ export const connectorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'connector', - ], - operation: [ - 'create', - ], + resource: ['connector'], + operation: ['create'], }, }, }, @@ -108,15 +93,9 @@ export const connectorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'connector', - ], - operation: [ - 'create', - ], - connectorType: [ - '.jira', - ], + resource: ['connector'], + operation: ['create'], + connectorType: ['.jira'], }, }, }, @@ -129,15 +108,9 @@ export const connectorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'connector', - ], - operation: [ - 'create', - ], - connectorType: [ - '.jira', - ], + resource: ['connector'], + operation: ['create'], + connectorType: ['.jira'], }, }, }, @@ -150,15 +123,9 @@ export const connectorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'connector', - ], - operation: [ - 'create', - ], - connectorType: [ - '.jira', - ], + resource: ['connector'], + operation: ['create'], + connectorType: ['.jira'], }, }, }, @@ -171,15 +138,9 @@ export const connectorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'connector', - ], - operation: [ - 'create', - ], - connectorType: [ - '.servicenow', - ], + resource: ['connector'], + operation: ['create'], + connectorType: ['.servicenow'], }, }, }, @@ -192,15 +153,9 @@ export const connectorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'connector', - ], - operation: [ - 'create', - ], - connectorType: [ - '.servicenow', - ], + resource: ['connector'], + operation: ['create'], + connectorType: ['.servicenow'], }, }, }, @@ -213,15 +168,9 @@ export const connectorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'connector', - ], - operation: [ - 'create', - ], - connectorType: [ - '.resilient', - ], + resource: ['connector'], + operation: ['create'], + connectorType: ['.resilient'], }, }, }, @@ -234,15 +183,9 @@ export const connectorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'connector', - ], - operation: [ - 'create', - ], - connectorType: [ - '.resilient', - ], + resource: ['connector'], + operation: ['create'], + connectorType: ['.resilient'], }, }, }, @@ -255,15 +198,9 @@ export const connectorFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'connector', - ], - operation: [ - 'create', - ], - connectorType: [ - '.resilient', - ], + resource: ['connector'], + operation: ['create'], + connectorType: ['.resilient'], }, }, }, diff --git a/packages/nodes-base/nodes/Elastic/ElasticSecurity/types.d.ts b/packages/nodes-base/nodes/Elastic/ElasticSecurity/types.d.ts index 7788a04255f92..268762ec621c7 100644 --- a/packages/nodes-base/nodes/Elastic/ElasticSecurity/types.d.ts +++ b/packages/nodes-base/nodes/Elastic/ElasticSecurity/types.d.ts @@ -9,7 +9,7 @@ export type ConnectorType = '.jira' | '.servicenow' | '.resilient'; export type Connector = { id: string; name: string; - connector_type_id: ConnectorType + connector_type_id: ConnectorType; }; export type ConnectorCreatePayload = @@ -18,39 +18,39 @@ export type ConnectorCreatePayload = | IbmResilientConnectorCreatePayload; type ServiceNowConnectorCreatePayload = { - connector_type_id: '.servicenow', - name: string, + connector_type_id: '.servicenow'; + name: string; secrets?: { username: string; password: string; - }, + }; config?: { apiUrl: string; - }, + }; }; type JiraConnectorCreatePayload = { - connector_type_id: '.jira', - name: string, + connector_type_id: '.jira'; + name: string; secrets?: { email: string; apiToken: string; - }, + }; config?: { apiUrl: string; projectKey: string; - }, + }; }; type IbmResilientConnectorCreatePayload = { - connector_type_id: '.resilient', - name: string, + connector_type_id: '.resilient'; + name: string; secrets?: { apiKeyId: string; apiKeySecret: string; - }, + }; config?: { apiUrl: string; orgId: string; - }, + }; }; diff --git a/packages/nodes-base/nodes/Elastic/Elasticsearch/Elasticsearch.node.ts b/packages/nodes-base/nodes/Elastic/Elasticsearch/Elasticsearch.node.ts index e7aab680de91c..4019683c62c3b 100644 --- a/packages/nodes-base/nodes/Elastic/Elasticsearch/Elasticsearch.node.ts +++ b/packages/nodes-base/nodes/Elastic/Elasticsearch/Elasticsearch.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -13,26 +11,13 @@ import { JsonObject, } from 'n8n-workflow'; -import { - elasticsearchApiRequest, -} from './GenericFunctions'; +import { elasticsearchApiRequest } from './GenericFunctions'; -import { - documentFields, - documentOperations, - indexFields, - indexOperations, -} from './descriptions'; +import { documentFields, documentOperations, indexFields, indexOperations } from './descriptions'; -import { - DocumentGetAllOptions, - ElasticsearchApiCredentials, - FieldsUiValues, -} from './types'; +import { DocumentGetAllOptions, ElasticsearchApiCredentials, FieldsUiValues } from './types'; -import { - omit, -} from 'lodash'; +import { omit } from 'lodash'; export class Elasticsearch implements INodeType { description: INodeTypeDescription = { @@ -89,9 +74,7 @@ export class Elasticsearch implements INodeType { let responseData; for (let i = 0; i < items.length; i++) { - if (resource === 'document') { - // ********************************************************************** // document // ********************************************************************** @@ -99,7 +82,6 @@ export class Elasticsearch implements INodeType { // https://www.elastic.co/guide/en/elasticsearch/reference/current/docs.html if (operation === 'delete') { - // ---------------------------------------- // document: delete // ---------------------------------------- @@ -111,9 +93,7 @@ export class Elasticsearch implements INodeType { const endpoint = `/${indexId}/_doc/${documentId}`; responseData = await elasticsearchApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // document: get // ---------------------------------------- @@ -142,9 +122,7 @@ export class Elasticsearch implements INodeType { ...responseData._source, }; } - } else if (operation === 'getAll') { - // ---------------------------------------- // document: getAll // ---------------------------------------- @@ -170,7 +148,13 @@ export class Elasticsearch implements INodeType { qs.size = this.getNodeParameter('limit', 0); } - responseData = await elasticsearchApiRequest.call(this, 'GET', `/${indexId}/_search`, body, qs); + responseData = await elasticsearchApiRequest.call( + this, + 'GET', + `/${indexId}/_search`, + body, + qs, + ); responseData = responseData.hits.hits; const simple = this.getNodeParameter('simple', 0) as IDataObject; @@ -183,9 +167,7 @@ export class Elasticsearch implements INodeType { }; }); } - } else if (operation === 'create') { - // ---------------------------------------- // document: create // ---------------------------------------- @@ -194,24 +176,22 @@ export class Elasticsearch implements INodeType { const body: IDataObject = {}; - const dataToSend = this.getNodeParameter('dataToSend', 0) as 'defineBelow' | 'autoMapInputData'; + const dataToSend = this.getNodeParameter('dataToSend', 0) as + | 'defineBelow' + | 'autoMapInputData'; if (dataToSend === 'defineBelow') { - const fields = this.getNodeParameter('fieldsUi.fieldValues', i, []) as FieldsUiValues; - fields.forEach(({ fieldId, fieldValue }) => body[fieldId] = fieldValue); - + fields.forEach(({ fieldId, fieldValue }) => (body[fieldId] = fieldValue)); } else { - const inputData = 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()); for (const key of Object.keys(inputData)) { if (inputsToIgnore.includes(key)) continue; body[key] = inputData[key]; } - } const qs = {} as IDataObject; @@ -234,9 +214,7 @@ export class Elasticsearch implements INodeType { const endpoint = `/${indexId}/_doc`; responseData = await elasticsearchApiRequest.call(this, 'POST', endpoint, body, qs); } - } else if (operation === 'update') { - // ---------------------------------------- // document: update // ---------------------------------------- @@ -245,24 +223,22 @@ export class Elasticsearch implements INodeType { const body = { doc: {} } as { doc: { [key: string]: string } }; - const dataToSend = this.getNodeParameter('dataToSend', 0) as 'defineBelow' | 'autoMapInputData'; + const dataToSend = this.getNodeParameter('dataToSend', 0) as + | 'defineBelow' + | 'autoMapInputData'; if (dataToSend === 'defineBelow') { - const fields = this.getNodeParameter('fieldsUi.fieldValues', i, []) as FieldsUiValues; - fields.forEach(({ fieldId, fieldValue }) => body.doc[fieldId] = fieldValue); - + fields.forEach(({ fieldId, fieldValue }) => (body.doc[fieldId] = fieldValue)); } else { - const inputData = 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()); for (const key of Object.keys(inputData)) { if (inputsToIgnore.includes(key)) continue; body.doc[key] = inputData[key] as string; } - } const indexId = this.getNodeParameter('indexId', i); @@ -275,11 +251,8 @@ export class Elasticsearch implements INodeType { const endpoint = `/${indexId}/_update/${documentId}`; responseData = await elasticsearchApiRequest.call(this, 'POST', endpoint, body, qs); - } - } else if (resource === 'index') { - // ********************************************************************** // index // ********************************************************************** @@ -287,7 +260,6 @@ export class Elasticsearch implements INodeType { // https://www.elastic.co/guide/en/elasticsearch/reference/current/indices.html if (operation === 'create') { - // ---------------------------------------- // index: create // ---------------------------------------- @@ -309,9 +281,7 @@ export class Elasticsearch implements INodeType { responseData = await elasticsearchApiRequest.call(this, 'PUT', `/${indexId}`); responseData = { id: indexId, ...responseData }; delete responseData.index; - } else if (operation === 'delete') { - // ---------------------------------------- // index: delete // ---------------------------------------- @@ -322,9 +292,7 @@ export class Elasticsearch implements INodeType { responseData = await elasticsearchApiRequest.call(this, 'DELETE', `/${indexId}`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // index: get // ---------------------------------------- @@ -342,9 +310,7 @@ export class Elasticsearch implements INodeType { responseData = await elasticsearchApiRequest.call(this, 'GET', `/${indexId}`, {}, qs); responseData = { id: indexId, ...responseData[indexId] }; - } else if (operation === 'getAll') { - // ---------------------------------------- // index: getAll // ---------------------------------------- @@ -352,7 +318,7 @@ export class Elasticsearch implements INodeType { // https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html responseData = await elasticsearchApiRequest.call(this, 'GET', '/_aliases'); - responseData = Object.keys(responseData).map(i => ({ indexId: i })); + responseData = Object.keys(responseData).map((i) => ({ indexId: i })); const returnAll = this.getNodeParameter('returnAll', i); @@ -360,15 +326,12 @@ export class Elasticsearch implements INodeType { const limit = this.getNodeParameter('limit', i) as number; responseData = responseData.slice(0, limit); } - } - } Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Elastic/Elasticsearch/GenericFunctions.ts b/packages/nodes-base/nodes/Elastic/Elasticsearch/GenericFunctions.ts index f6f9dee35e4fc..eef6ba236268b 100644 --- a/packages/nodes-base/nodes/Elastic/Elasticsearch/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Elastic/Elasticsearch/GenericFunctions.ts @@ -1,20 +1,10 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; -import { - IDataObject, - JsonObject, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, JsonObject, NodeApiError } from 'n8n-workflow'; -import { - ElasticsearchApiCredentials, -} from './types'; +import { ElasticsearchApiCredentials } from './types'; export async function elasticsearchApiRequest( this: IExecuteFunctions, @@ -23,10 +13,9 @@ export async function elasticsearchApiRequest( body: IDataObject = {}, qs: IDataObject = {}, ) { - const { - baseUrl, - ignoreSSLIssues, - } = await this.getCredentials('elasticsearchApi') as ElasticsearchApiCredentials; + const { baseUrl, ignoreSSLIssues } = (await this.getCredentials( + 'elasticsearchApi', + )) as ElasticsearchApiCredentials; const options: OptionsWithUri = { method, diff --git a/packages/nodes-base/nodes/Elastic/Elasticsearch/descriptions/DocumentDescription.ts b/packages/nodes-base/nodes/Elastic/Elasticsearch/descriptions/DocumentDescription.ts index a7bc5df013fdf..57a17d7e201c0 100644 --- a/packages/nodes-base/nodes/Elastic/Elasticsearch/descriptions/DocumentDescription.ts +++ b/packages/nodes-base/nodes/Elastic/Elasticsearch/descriptions/DocumentDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import * as placeholders from './placeholders'; @@ -12,9 +10,7 @@ export const documentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'document', - ], + resource: ['document'], }, }, options: [ @@ -66,12 +62,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'delete', - ], + resource: ['document'], + operation: ['delete'], }, }, }, @@ -84,12 +76,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'delete', - ], + resource: ['document'], + operation: ['delete'], }, }, }, @@ -106,12 +94,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'get', - ], + resource: ['document'], + operation: ['get'], }, }, }, @@ -124,12 +108,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'get', - ], + resource: ['document'], + operation: ['get'], }, }, }, @@ -141,12 +121,8 @@ export const documentFields: INodeProperties[] = [ description: 'Whether to return a simplified version of the response instead of the raw data', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'get', - ], + resource: ['document'], + operation: ['get'], }, }, }, @@ -158,12 +134,8 @@ export const documentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'get', - ], + resource: ['document'], + operation: ['get'], }, }, options: [ @@ -184,7 +156,8 @@ export const documentFields: INodeProperties[] = [ { displayName: 'Stored Fields', name: 'stored_fields', - description: 'Whether to retrieve the document fields stored in the index rather than the document _source. Defaults to false.', + description: + 'Whether to retrieve the document fields stored in the index rather than the document _source. Defaults to false.', type: 'boolean', default: false, }, @@ -203,12 +176,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'getAll', - ], + resource: ['document'], + operation: ['getAll'], }, }, }, @@ -220,12 +189,8 @@ export const documentFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'getAll', - ], + resource: ['document'], + operation: ['getAll'], }, }, }, @@ -240,15 +205,9 @@ export const documentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['document'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -260,12 +219,8 @@ export const documentFields: INodeProperties[] = [ description: 'Whether to return a simplified version of the response instead of the raw data', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'getAll', - ], + resource: ['document'], + operation: ['getAll'], }, }, }, @@ -277,12 +232,8 @@ export const documentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'getAll', - ], + resource: ['document'], + operation: ['getAll'], }, }, options: [ @@ -290,7 +241,8 @@ export const documentFields: INodeProperties[] = [ displayName: 'Allow No Indices', name: 'allow_no_indices', // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'If false, return an error if any of the following targets only missing/closed indices: wildcard expression, index alias, or _all value. Defaults to true.', + description: + 'If false, return an error if any of the following targets only missing/closed indices: wildcard expression, index alias, or _all value. Defaults to true.', type: 'boolean', default: true, }, @@ -298,14 +250,16 @@ export const documentFields: INodeProperties[] = [ displayName: 'Allow Partial Search Results', name: 'allow_partial_search_results', // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: '

If true, return partial results if there are shard request timeouts or shard failures.

If false, returns an error with no partial results. Defaults to true.

.', + description: + '

If true, return partial results if there are shard request timeouts or shard failures.

If false, returns an error with no partial results. Defaults to true.

.', type: 'boolean', default: true, }, { displayName: 'Batched Reduce Size', name: 'batched_reduce_size', - description: 'Number of shard results that should be reduced at once on the coordinating node. Defaults to 512.', + description: + 'Number of shard results that should be reduced at once on the coordinating node. Defaults to 512.', type: 'number', typeOptions: { minValue: 2, @@ -315,21 +269,24 @@ export const documentFields: INodeProperties[] = [ { displayName: 'CCS Minimize Roundtrips', name: 'ccs_minimize_roundtrips', - description: 'Whether network round-trips between the coordinating node and the remote clusters are minimized when executing cross-cluster search (CCS) requests. Defaults to true.', + description: + 'Whether network round-trips between the coordinating node and the remote clusters are minimized when executing cross-cluster search (CCS) requests. Defaults to true.', type: 'boolean', default: true, }, { displayName: 'Doc Value Fields', name: 'docvalue_fields', - description: 'Comma-separated list of fields to return as the docvalue representation of a field for each hit', + description: + 'Comma-separated list of fields to return as the docvalue representation of a field for each hit', type: 'string', default: '', }, { displayName: 'Expand Wildcards', name: 'expand_wildcards', - description: 'Type of index that wildcard expressions can match. Defaults to open', + description: + 'Type of index that wildcard expressions can match. Defaults to open', type: 'options', options: [ { @@ -358,35 +315,40 @@ export const documentFields: INodeProperties[] = [ { displayName: 'Explain', name: 'explain', - description: 'Whether to return detailed information about score computation as part of a hit. Defaults to false.', + description: + 'Whether to return detailed information about score computation as part of a hit. Defaults to false.', type: 'boolean', default: false, }, { displayName: 'Ignore Throttled', name: 'ignore_throttled', - description: 'Whether concrete, expanded or aliased indices are ignored when frozen. Defaults to true.', + description: + 'Whether concrete, expanded or aliased indices are ignored when frozen. Defaults to true.', type: 'boolean', default: true, }, { displayName: 'Ignore Unavailable', name: 'ignore_unavailable', - description: 'Whether missing or closed indices are not included in the response. Defaults to false.', + description: + 'Whether missing or closed indices are not included in the response. Defaults to false.', type: 'boolean', default: false, }, { displayName: 'Max Concurrent Shard Requests', name: 'max_concurrent_shard_requests', - description: 'Define the number of shard requests per node this search executes concurrently. Defaults to 5.', + description: + 'Define the number of shard requests per node this search executes concurrently. Defaults to 5.', type: 'number', default: 5, }, { displayName: 'Pre-Filter Shard Size', name: 'pre_filter_shard_size', - description: 'Define a threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting. Only used if the number of shards the search request expands to exceeds the threshold.', + description: + 'Define a threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting. Only used if the number of shards the search request expands to exceeds the threshold.', type: 'number', typeOptions: { minValue: 1, @@ -396,7 +358,8 @@ export const documentFields: INodeProperties[] = [ { displayName: 'Query', name: 'query', - description: 'Query in the Elasticsearch Query DSL', + description: + 'Query in the Elasticsearch Query DSL', type: 'json', typeOptions: { alwaysOpenEditWindow: true, @@ -407,7 +370,8 @@ export const documentFields: INodeProperties[] = [ { displayName: 'Request Cache', name: 'request_cache', - description: 'Whether the caching of search results is enabled for requests where size is 0. See Elasticsearch shard request cache settings.', + description: + 'Whether the caching of search results is enabled for requests where size is 0. See Elasticsearch shard request cache settings.', type: 'boolean', default: false, }, @@ -421,7 +385,8 @@ export const documentFields: INodeProperties[] = [ { displayName: 'Search Type', name: 'search_type', - description: 'How distributed term frequencies are calculated for relevance scoring. Defaults to Query then Fetch.', + description: + 'How distributed term frequencies are calculated for relevance scoring. Defaults to Query then Fetch.', type: 'options', options: [ { @@ -438,7 +403,8 @@ export const documentFields: INodeProperties[] = [ { displayName: 'Sequence Number and Primary Term', name: 'seq_no_primary_term', - description: 'Whether to return the sequence number and primary term of the last modification of each hit. See Optimistic concurrency control.', + description: + 'Whether to return the sequence number and primary term of the last modification of each hit. See Optimistic concurrency control.', type: 'boolean', default: false, }, @@ -473,7 +439,8 @@ export const documentFields: INodeProperties[] = [ { displayName: 'Stored Fields', name: 'stored_fields', - description: 'Whether to retrieve the document fields stored in the index rather than the document _source. Defaults to false.', + description: + 'Whether to retrieve the document fields stored in the index rather than the document _source. Defaults to false.', type: 'boolean', default: false, }, @@ -487,14 +454,16 @@ export const documentFields: INodeProperties[] = [ { displayName: 'Timeout', name: 'timeout', - description: 'Period to wait for active shards. Defaults to 1m (one minute). See the Elasticsearch time units reference', + description: + 'Period to wait for active shards. Defaults to 1m (one minute). See the Elasticsearch time units reference', type: 'string', default: '1m', }, { displayName: 'Track Scores', name: 'track_scores', - description: 'Whether to calculate and return document scores, even if the scores are not used for sorting. Defaults to false.', + description: + 'Whether to calculate and return document scores, even if the scores are not used for sorting. Defaults to false.', type: 'boolean', default: false, }, @@ -527,12 +496,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'create', - ], + resource: ['document'], + operation: ['create'], }, }, }, @@ -554,12 +519,8 @@ export const documentFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'create', - ], + resource: ['document'], + operation: ['create'], }, }, default: 'defineBelow', @@ -571,19 +532,14 @@ export const documentFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'create', - ], - dataToSend: [ - 'autoMapInputData', - ], + resource: ['document'], + operation: ['create'], + 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...', }, { @@ -597,15 +553,9 @@ export const documentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'create', - ], - dataToSend: [ - 'defineBelow', - ], + resource: ['document'], + operation: ['create'], + dataToSend: ['defineBelow'], }, }, default: {}, @@ -638,12 +588,8 @@ export const documentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'create', - ], + resource: ['document'], + operation: ['create'], }, }, options: [ @@ -664,7 +610,8 @@ export const documentFields: INodeProperties[] = [ { displayName: 'Timeout', name: 'timeout', - description: 'Period to wait for active shards. Defaults to 1m (one minute). See the Elasticsearch time units reference', + description: + 'Period to wait for active shards. Defaults to 1m (one minute). See the Elasticsearch time units reference', type: 'string', default: '1m', }, @@ -678,12 +625,8 @@ export const documentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'create', - ], + resource: ['document'], + operation: ['create'], }, }, options: [ @@ -697,7 +640,8 @@ export const documentFields: INodeProperties[] = [ { displayName: 'Refresh', name: 'refresh', - description: 'If true, Elasticsearch refreshes the affected shards to make this operation visible to search,if wait_for then wait for a refresh to make this operation visible to search,if false do nothing with refreshes', + description: + 'If true, Elasticsearch refreshes the affected shards to make this operation visible to search,if wait_for then wait for a refresh to make this operation visible to search,if false do nothing with refreshes', type: 'options', default: 'false', options: [ @@ -733,12 +677,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'update', - ], + resource: ['document'], + operation: ['update'], }, }, }, @@ -751,12 +691,8 @@ export const documentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'update', - ], + resource: ['document'], + operation: ['update'], }, }, }, @@ -778,12 +714,8 @@ export const documentFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'update', - ], + resource: ['document'], + operation: ['update'], }, }, default: 'defineBelow', @@ -795,19 +727,14 @@ export const documentFields: INodeProperties[] = [ type: 'string', displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'update', - ], - dataToSend: [ - 'autoMapInputData', - ], + resource: ['document'], + operation: ['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...', }, { @@ -821,15 +748,9 @@ export const documentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'update', - ], - dataToSend: [ - 'defineBelow', - ], + resource: ['document'], + operation: ['update'], + dataToSend: ['defineBelow'], }, }, default: {}, @@ -862,19 +783,16 @@ export const documentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'document', - ], - operation: [ - 'update', - ], + resource: ['document'], + operation: ['update'], }, }, options: [ { displayName: 'Refresh', name: 'refresh', - description: 'If true, Elasticsearch refreshes the affected shards to make this operation visible to search,if wait_for then wait for a refresh to make this operation visible to search,if false do nothing with refreshes', + description: + 'If true, Elasticsearch refreshes the affected shards to make this operation visible to search,if wait_for then wait for a refresh to make this operation visible to search,if false do nothing with refreshes', type: 'options', default: 'false', options: [ diff --git a/packages/nodes-base/nodes/Elastic/Elasticsearch/descriptions/IndexDescription.ts b/packages/nodes-base/nodes/Elastic/Elasticsearch/descriptions/IndexDescription.ts index a24eef3fe446a..09a923575e576 100644 --- a/packages/nodes-base/nodes/Elastic/Elasticsearch/descriptions/IndexDescription.ts +++ b/packages/nodes-base/nodes/Elastic/Elasticsearch/descriptions/IndexDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import * as placeholders from './placeholders'; @@ -12,9 +10,7 @@ export const indexOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'index', - ], + resource: ['index'], }, }, options: [ @@ -56,12 +52,8 @@ export const indexFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'index', - ], - operation: [ - 'create', - ], + resource: ['index'], + operation: ['create'], }, }, }, @@ -73,19 +65,16 @@ export const indexFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'index', - ], - operation: [ - 'create', - ], + resource: ['index'], + operation: ['create'], }, }, options: [ { displayName: 'Aliases', name: 'aliases', - description: 'Index aliases which include the index, as an alias object', + description: + 'Index aliases which include the index, as an alias object', type: 'json', typeOptions: { alwaysOpenEditWindow: true, @@ -96,14 +85,16 @@ export const indexFields: INodeProperties[] = [ { displayName: 'Include Type Name', name: 'include_type_name', - description: 'Whether a mapping type is expected in the body of mappings. Defaults to false.', + description: + 'Whether a mapping type is expected in the body of mappings. Defaults to false.', type: 'boolean', default: false, }, { displayName: 'Mappings', name: 'mappings', - description: 'Mapping for fields in the index, as mapping object', + description: + 'Mapping for fields in the index, as mapping object', type: 'json', typeOptions: { alwaysOpenEditWindow: true, @@ -114,14 +105,16 @@ export const indexFields: INodeProperties[] = [ { displayName: 'Master Timeout', name: 'master_timeout', - description: 'Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Defaults to 1m. See the Elasticsearch time units reference', + description: + 'Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Defaults to 1m. See the Elasticsearch time units reference', type: 'string', default: '1m', }, { displayName: 'Settings', name: 'settings', - description: 'Configuration options for the index, as an index settings object', + description: + 'Configuration options for the index, as an index settings object', type: 'json', typeOptions: { alwaysOpenEditWindow: true, @@ -132,14 +125,16 @@ export const indexFields: INodeProperties[] = [ { displayName: 'Timeout', name: 'timeout', - description: 'Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Defaults to 30s. See the Elasticsearch time units reference', + description: + 'Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error. Defaults to 30s. See the Elasticsearch time units reference', type: 'string', default: '30s', }, { displayName: 'Wait for Active Shards', name: 'wait_for_active_shards', - description: 'The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index. Default: 1, the primary shard', + description: + 'The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index. Default: 1, the primary shard', type: 'string', default: '1', }, @@ -158,12 +153,8 @@ export const indexFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'index', - ], - operation: [ - 'delete', - ], + resource: ['index'], + operation: ['delete'], }, }, }, @@ -180,12 +171,8 @@ export const indexFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'index', - ], - operation: [ - 'get', - ], + resource: ['index'], + operation: ['get'], }, }, }, @@ -197,12 +184,8 @@ export const indexFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'index', - ], - operation: [ - 'get', - ], + resource: ['index'], + operation: ['get'], }, }, options: [ @@ -210,14 +193,16 @@ export const indexFields: INodeProperties[] = [ displayName: 'Allow No Indices', name: 'allow_no_indices', // eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether - description: 'If false, return an error if any of the following targets only missing/closed indices: wildcard expression, index alias, or _all value. Defaults to true.', + description: + 'If false, return an error if any of the following targets only missing/closed indices: wildcard expression, index alias, or _all value. Defaults to true.', type: 'boolean', default: true, }, { displayName: 'Expand Wildcards', name: 'expand_wildcards', - description: 'Type of index that wildcard expressions can match. Defaults to open', + description: + 'Type of index that wildcard expressions can match. Defaults to open', type: 'options', options: [ { @@ -253,7 +238,8 @@ export const indexFields: INodeProperties[] = [ { displayName: 'Ignore Unavailable', name: 'ignore_unavailable', - description: 'Whether to request that target a missing index return an error. Defaults to false.', + description: + 'Whether to request that target a missing index return an error. Defaults to false.', type: 'boolean', default: false, }, @@ -274,7 +260,8 @@ export const indexFields: INodeProperties[] = [ { displayName: 'Master Timeout', name: 'master_timeout', - description: 'Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Defaults to 1m. See the Elasticsearch time units reference', + description: + 'Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Defaults to 1m. See the Elasticsearch time units reference', type: 'string', default: '1m', }, @@ -292,12 +279,8 @@ export const indexFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'index', - ], - operation: [ - 'getAll', - ], + resource: ['index'], + operation: ['getAll'], }, }, }, @@ -312,15 +295,9 @@ export const indexFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'index', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['index'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/EmailReadImap/EmailReadImap.node.ts b/packages/nodes-base/nodes/EmailReadImap/EmailReadImap.node.ts index 38488f2490294..06886b8cadcfe 100644 --- a/packages/nodes-base/nodes/EmailReadImap/EmailReadImap.node.ts +++ b/packages/nodes-base/nodes/EmailReadImap/EmailReadImap.node.ts @@ -20,10 +20,7 @@ import { ImapSimpleOptions, Message, } from 'imap-simple'; -import { - simpleParser, - Source as ParserSource, -} from 'mailparser'; +import { simpleParser, Source as ParserSource } from 'mailparser'; import _ from 'lodash'; @@ -70,7 +67,8 @@ export class EmailReadImap implements INodeType { }, ], default: 'read', - description: 'What to do after the email has been received. If "nothing" gets selected it will be processed multiple times.', + description: + 'What to do after the email has been received. If "nothing" gets selected it will be processed multiple times.', }, { displayName: 'Download Attachments', @@ -79,12 +77,11 @@ export class EmailReadImap implements INodeType { default: false, displayOptions: { show: { - format: [ - 'simple', - ], + format: ['simple'], }, }, - description: 'Whether attachments of emails should be downloaded. Only set if needed as it increases processing.', + description: + 'Whether attachments of emails should be downloaded. Only set if needed as it increases processing.', }, { displayName: 'Format', @@ -94,17 +91,20 @@ export class EmailReadImap implements INodeType { { 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', }, { name: 'Simple', value: 'simple', - description: 'Returns the full email; do not use if you wish to gather inline attachments', + description: + 'Returns the full email; do not use if you wish to gather inline attachments', }, ], default: 'simple', @@ -117,12 +117,11 @@ export class EmailReadImap implements INodeType { default: 'attachment_', displayOptions: { show: { - format: [ - 'resolved', - ], + format: ['resolved'], }, }, - 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: 'Property Prefix Name', @@ -131,15 +130,12 @@ export class EmailReadImap implements INodeType { default: 'attachment_', displayOptions: { show: { - format: [ - 'simple', - ], - downloadAttachments: [ - true, - ], + format: ['simple'], + downloadAttachments: [true], }, }, - 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: 'Options', @@ -153,7 +149,8 @@ export class EmailReadImap implements INodeType { name: 'customEmailConfig', type: 'string', default: '["UNSEEN"]', - description: 'Custom email fetching rules. See node-imap\'s search function for more details.', + description: + 'Custom email fetching rules. See node-imap\'s search function for more details.', }, { displayName: 'Ignore SSL Issues', @@ -174,8 +171,6 @@ export class EmailReadImap implements INodeType { ], }; - - async trigger(this: ITriggerFunctions): Promise { const credentials = await this.getCredentials('imap'); @@ -184,34 +179,41 @@ export class EmailReadImap implements INodeType { const options = this.getNodeParameter('options', {}) as IDataObject; const staticData = this.getWorkflowStaticData('node'); - Logger.debug('Loaded static data for node "EmailReadImap"', {staticData}); + Logger.debug('Loaded static data for node "EmailReadImap"', { staticData }); let connection: ImapSimple; // Returns the email text - const getText = async (parts: any[], message: Message, subtype: string) => { // tslint:disable-line:no-any + // tslint:disable-next-line:no-any + const getText = async (parts: any[], message: Message, subtype: string) => { if (!message.attributes.struct) { return ''; } const textParts = parts.filter((part) => { - return part.type.toUpperCase() === 'TEXT' && part.subtype.toUpperCase() === subtype.toUpperCase(); + return ( + part.type.toUpperCase() === 'TEXT' && part.subtype.toUpperCase() === subtype.toUpperCase() + ); }); if (textParts.length === 0) { return ''; } - try{ + try { return await connection.getPartData(message, textParts[0]); } catch { return ''; } }; - // Returns the email attachments - const getAttachment = async (connection: ImapSimple, parts: any[], message: Message): Promise => { // tslint:disable-line:no-any + const getAttachment = async ( + connection: ImapSimple, + // tslint:disable-next-line:no-any + parts: any[], + message: Message, + ): Promise => { if (!message.attributes.struct) { return []; } @@ -224,11 +226,13 @@ export class EmailReadImap implements INodeType { const attachmentPromises = []; let attachmentPromise; for (const attachmentPart of attachmentParts) { - attachmentPromise = connection.getPartData(message, attachmentPart) - .then((partData) => { - // Return it in the format n8n expects - return this.helpers.prepareBinaryData(partData, attachmentPart.disposition.params.filename); - }); + attachmentPromise = connection.getPartData(message, attachmentPart).then((partData) => { + // Return it in the format n8n expects + return this.helpers.prepareBinaryData( + partData, + attachmentPart.disposition.params.filename, + ); + }); attachmentPromises.push(attachmentPromise); } @@ -236,9 +240,11 @@ export class EmailReadImap implements INodeType { return Promise.all(attachmentPromises); }; - // Returns all the new unseen messages - const getNewEmails = async (connection: ImapSimple, searchCriteria: Array): Promise => { + const getNewEmails = async ( + connection: ImapSimple, + searchCriteria: Array, + ): Promise => { const format = this.getNodeParameter('format', 0) as string; let fetchOptions = {}; @@ -266,30 +272,36 @@ export class EmailReadImap implements INodeType { // All properties get by default moved to metadata except the ones // which are defined here which get set on the top level. - const topLevelProperties = [ - 'cc', - 'date', - 'from', - 'subject', - 'to', - ]; + const topLevelProperties = ['cc', 'date', 'from', 'subject', 'to']; if (format === 'resolved') { - const dataPropertyAttachmentsPrefixName = this.getNodeParameter('dataPropertyAttachmentsPrefixName') as string; + const dataPropertyAttachmentsPrefixName = this.getNodeParameter( + 'dataPropertyAttachmentsPrefixName', + ) as string; for (const message of results) { - if (staticData.lastMessageUid !== undefined && message.attributes.uid <= (staticData.lastMessageUid as number)) { + if ( + staticData.lastMessageUid !== undefined && + message.attributes.uid <= (staticData.lastMessageUid as number) + ) { continue; } - if (staticData.lastMessageUid === undefined || staticData.lastMessageUid as number < message.attributes.uid) { + if ( + staticData.lastMessageUid === undefined || + (staticData.lastMessageUid as number) < message.attributes.uid + ) { staticData.lastMessageUid = message.attributes.uid; } const part = _.find(message.parts, { which: '' }); if (part === undefined) { - throw new NodeOperationError(this.getNode(), 'Email part could not be parsed.',); + throw new NodeOperationError(this.getNode(), 'Email part could not be parsed.'); } - const parsedEmail = await parseRawEmail.call(this, part.body, dataPropertyAttachmentsPrefixName); + const parsedEmail = await parseRawEmail.call( + this, + part.body, + dataPropertyAttachmentsPrefixName, + ); newEmails.push(parsedEmail); } @@ -298,14 +310,22 @@ export class EmailReadImap implements INodeType { let dataPropertyAttachmentsPrefixName = ''; if (downloadAttachments === true) { - dataPropertyAttachmentsPrefixName = this.getNodeParameter('dataPropertyAttachmentsPrefixName') as string; + dataPropertyAttachmentsPrefixName = this.getNodeParameter( + 'dataPropertyAttachmentsPrefixName', + ) as string; } for (const message of results) { - if (staticData.lastMessageUid !== undefined && message.attributes.uid <= (staticData.lastMessageUid as number)) { + if ( + staticData.lastMessageUid !== undefined && + message.attributes.uid <= (staticData.lastMessageUid as number) + ) { continue; } - if (staticData.lastMessageUid === undefined || staticData.lastMessageUid as number < message.attributes.uid) { + if ( + staticData.lastMessageUid === undefined || + (staticData.lastMessageUid as number) < message.attributes.uid + ) { staticData.lastMessageUid = message.attributes.uid; } const parts = getParts(message.attributes.struct!); @@ -328,7 +348,8 @@ export class EmailReadImap implements INodeType { if (topLevelProperties.includes(propertyName)) { newEmail.json[propertyName] = messageBody[propertyName][0]; } else { - (newEmail.json.metadata as IDataObject)[propertyName] = messageBody[propertyName][0]; + (newEmail.json.metadata as IDataObject)[propertyName] = + messageBody[propertyName][0]; } } } @@ -348,10 +369,16 @@ export class EmailReadImap implements INodeType { } } else if (format === 'raw') { for (const message of results) { - if (staticData.lastMessageUid !== undefined && message.attributes.uid <= (staticData.lastMessageUid as number)) { + if ( + staticData.lastMessageUid !== undefined && + message.attributes.uid <= (staticData.lastMessageUid as number) + ) { continue; } - if (staticData.lastMessageUid === undefined || staticData.lastMessageUid as number < message.attributes.uid) { + if ( + staticData.lastMessageUid === undefined || + (staticData.lastMessageUid as number) < message.attributes.uid + ) { staticData.lastMessageUid = message.attributes.uid; } const part = _.find(message.parts, { which: 'TEXT' }); @@ -376,10 +403,7 @@ export class EmailReadImap implements INodeType { const returnedPromise: IDeferredPromise | undefined = await createDeferredPromise(); const establishConnection = (): Promise => { - - let searchCriteria = [ - 'UNSEEN', - ] as Array; + let searchCriteria = ['UNSEEN'] as Array; if (options.customEmailConfig !== undefined) { try { searchCriteria = JSON.parse(options.customEmailConfig as string); @@ -413,7 +437,7 @@ export class EmailReadImap implements INodeType { * - You can check if UIDs changed in the above example * by checking UIDValidity. */ - Logger.debug('Querying for new messages on node "EmailReadImap"', {searchCriteria}); + Logger.debug('Querying for new messages on node "EmailReadImap"', { searchCriteria }); } try { @@ -422,7 +446,9 @@ export class EmailReadImap implements INodeType { this.emit([returnData]); } } catch (error) { - Logger.error('Email Read Imap node encountered an error fetching new emails', { error }); + Logger.error('Email Read Imap node encountered an error fetching new emails', { + error, + }); // Wait with resolving till the returnedPromise got resolved, else n8n will be unhappy // if it receives an error before the workflow got activated returnedPromise.promise().then(() => { @@ -449,8 +475,8 @@ export class EmailReadImap implements INodeType { // Connect to the IMAP server and open the mailbox // that we get informed whenever a new email arrives - return imapConnect(config).then(async conn => { - conn.on('error', async error => { + return imapConnect(config).then(async (conn) => { + conn.on('error', async (error) => { const errorCode = error.code.toUpperCase(); if (['ECONNRESET', 'EPIPE'].includes(errorCode)) { Logger.verbose(`IMAP connection was reset (${errorCode}) - reconnecting.`, { error }); @@ -483,7 +509,7 @@ export class EmailReadImap implements INodeType { await connection.end(); connection = await establishConnection(); await connection.openBox(mailbox); - }, options.forceReconnect as number * 1000 * 60); + }, (options.forceReconnect as number) * 1000 * 60); } // When workflow and so node gets set to inactive close the connectoin @@ -503,7 +529,11 @@ export class EmailReadImap implements INodeType { } } -export async function parseRawEmail(this: ITriggerFunctions, messageEncoded: ParserSource, dataPropertyNameDownload: string): Promise { +export async function parseRawEmail( + this: ITriggerFunctions, + messageEncoded: ParserSource, + dataPropertyNameDownload: string, +): Promise { const responseData = await simpleParser(messageEncoded); const headers: IDataObject = {}; for (const header of responseData.headerLines) { @@ -517,10 +547,13 @@ export async function parseRawEmail(this: ITriggerFunctions, messageEncoded: Par 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; diff --git a/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts b/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts index 78207c40ce502..8ee14f8466905 100644 --- a/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts +++ b/packages/nodes-base/nodes/EmailSend/EmailSend.node.ts @@ -100,7 +100,8 @@ export class EmailSend implements INodeType { name: 'attachments', type: 'string', default: '', - description: 'Name of the binary properties that contain data to add to email as attachment. Multiple ones can be comma-separated.', + description: + 'Name of the binary properties that contain data to add to email as attachment. Multiple ones can be comma-separated.', }, { displayName: 'Options', @@ -121,7 +122,6 @@ export class EmailSend implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); @@ -131,7 +131,6 @@ export class EmailSend implements INodeType { for (let itemIndex = 0; itemIndex < length; itemIndex++) { try { - item = items[itemIndex]; const fromEmail = this.getNodeParameter('fromEmail', itemIndex) as string; @@ -181,9 +180,11 @@ export class EmailSend 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)) { @@ -210,7 +211,6 @@ export class EmailSend implements INodeType { item: itemIndex, }, }); - } catch (error) { if (this.continueOnFail()) { returnData.push({ @@ -229,5 +229,4 @@ export class EmailSend implements INodeType { return this.prepareOutputData(returnData); } - } diff --git a/packages/nodes-base/nodes/Emelia/CampaignDescription.ts b/packages/nodes-base/nodes/Emelia/CampaignDescription.ts index ef71d3f2a32cd..63e927d30dbe0 100644 --- a/packages/nodes-base/nodes/Emelia/CampaignDescription.ts +++ b/packages/nodes-base/nodes/Emelia/CampaignDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const campaignOperations: INodeProperties[] = [ { @@ -48,9 +46,7 @@ export const campaignOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'campaign', - ], + resource: ['campaign'], }, }, }, @@ -69,15 +65,12 @@ export const campaignFields: INodeProperties[] = [ }, default: [], required: true, - description: 'The ID of the campaign to add the contact to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the campaign to add the contact to. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'addContact', - ], + resource: ['campaign'], + operation: ['addContact'], }, }, }, @@ -90,12 +83,8 @@ export const campaignFields: INodeProperties[] = [ description: 'The email of the contact to add to the campaign', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'addContact', - ], + resource: ['campaign'], + operation: ['addContact'], }, }, }, @@ -107,12 +96,8 @@ export const campaignFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'addContact', - ], + resource: ['campaign'], + operation: ['addContact'], }, }, options: [ @@ -213,12 +198,8 @@ export const campaignFields: INodeProperties[] = [ description: 'The name of the campaign to create', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'create', - ], + resource: ['campaign'], + operation: ['create'], }, }, }, @@ -235,12 +216,8 @@ export const campaignFields: INodeProperties[] = [ description: 'The ID of the campaign to retrieve', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'get', - ], + resource: ['campaign'], + operation: ['get'], }, }, }, @@ -256,12 +233,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'], }, }, }, @@ -277,15 +250,9 @@ export const campaignFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['campaign'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -302,12 +269,8 @@ export const campaignFields: INodeProperties[] = [ description: 'The ID of the campaign to pause. The campaign must be in RUNNING mode.', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'pause', - ], + resource: ['campaign'], + operation: ['pause'], }, }, }, @@ -324,12 +287,8 @@ export const campaignFields: INodeProperties[] = [ description: 'The ID of the campaign to start. Email provider and contacts must be set.', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'start', - ], + resource: ['campaign'], + operation: ['start'], }, }, }, @@ -343,18 +302,15 @@ export const campaignFields: INodeProperties[] = [ type: 'options', default: '', required: true, - description: 'The ID of the campaign to duplicate. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the campaign to duplicate. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getCampaigns', }, displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'duplicate', - ], + resource: ['campaign'], + operation: ['duplicate'], }, }, }, @@ -367,12 +323,8 @@ export const campaignFields: INodeProperties[] = [ description: 'The name of the new campaign to create', displayOptions: { show: { - resource: [ - 'campaign', - ], - operation: [ - 'duplicate', - ], + resource: ['campaign'], + operation: ['duplicate'], }, }, }, @@ -384,12 +336,8 @@ export const campaignFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'duplicate', - ], - resource: [ - 'campaign', - ], + operation: ['duplicate'], + resource: ['campaign'], }, }, options: [ @@ -412,7 +360,8 @@ export const campaignFields: INodeProperties[] = [ name: 'copyMails', type: 'boolean', default: true, - description: 'Whether to copy all the steps of the email sequence from the original campaign', + description: + 'Whether to copy all the steps of the email sequence from the original campaign', }, { displayName: 'Copy Global Settings', diff --git a/packages/nodes-base/nodes/Emelia/ContactListDescription.ts b/packages/nodes-base/nodes/Emelia/ContactListDescription.ts index 32df21daed6a1..9f42a69397eb4 100644 --- a/packages/nodes-base/nodes/Emelia/ContactListDescription.ts +++ b/packages/nodes-base/nodes/Emelia/ContactListDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const contactListOperations: INodeProperties[] = [ { @@ -23,9 +21,7 @@ export const contactListOperations: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'contactList', - ], + resource: ['contactList'], }, }, }, @@ -44,15 +40,12 @@ export const contactListFields: INodeProperties[] = [ }, default: [], required: true, - description: 'The ID of the contact list to add the contact to. Choose from the list, or specify an ID using an expression.', + description: + 'The ID of the contact list to add the contact to. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'contactList', - ], - operation: [ - 'add', - ], + resource: ['contactList'], + operation: ['add'], }, }, }, @@ -65,12 +58,8 @@ export const contactListFields: INodeProperties[] = [ description: 'The email of the contact to add to the contact list', displayOptions: { show: { - resource: [ - 'contactList', - ], - operation: [ - 'add', - ], + resource: ['contactList'], + operation: ['add'], }, }, }, @@ -82,12 +71,8 @@ export const contactListFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contactList', - ], - operation: [ - 'add', - ], + resource: ['contactList'], + operation: ['add'], }, }, options: [ @@ -187,12 +172,8 @@ export const contactListFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'contactList', - ], - operation: [ - 'getAll', - ], + resource: ['contactList'], + operation: ['getAll'], }, }, }, @@ -208,15 +189,9 @@ export const contactListFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'contactList', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['contactList'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Emelia/Emelia.node.ts b/packages/nodes-base/nodes/Emelia/Emelia.node.ts index c6705961efd14..34dddc5889562 100644 --- a/packages/nodes-base/nodes/Emelia/Emelia.node.ts +++ b/packages/nodes-base/nodes/Emelia/Emelia.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -8,28 +6,16 @@ import { INodeExecutionData, INodeType, INodeTypeDescription, - JsonObject + JsonObject, } from 'n8n-workflow'; -import { - emeliaApiTest, - emeliaGraphqlRequest, - loadResource, -} from './GenericFunctions'; +import { emeliaApiTest, emeliaGraphqlRequest, loadResource } from './GenericFunctions'; -import { - campaignFields, - campaignOperations, -} from './CampaignDescription'; +import { campaignFields, campaignOperations } from './CampaignDescription'; -import { - contactListFields, - contactListOperations, -} from './ContactListDescription'; +import { contactListFields, contactListOperations } from './ContactListDescription'; -import { - isEmpty, -} from 'lodash'; +import { isEmpty } from 'lodash'; export class Emelia implements INodeType { description: INodeTypeDescription = { @@ -102,17 +88,13 @@ export class Emelia implements INodeType { const operation = this.getNodeParameter('operation', 0); for (let i = 0; i < items.length; i++) { - try { - if (resource === 'campaign') { - // ********************************** // campaign // ********************************** if (operation === 'addContact') { - // ---------------------------------- // campaign: addContact // ---------------------------------- @@ -128,8 +110,13 @@ export class Emelia implements INodeType { } if (additionalFields.customFieldsUi) { - const customFields = (additionalFields.customFieldsUi as IDataObject || {}).customFieldsValues as IDataObject[] || []; - const data = customFields.reduce((obj, value) => Object.assign(obj, { [`${value.fieldName}`]: value.value }), {}); + const customFields = + (((additionalFields.customFieldsUi as IDataObject) || {}) + .customFieldsValues as IDataObject[]) || []; + const data = customFields.reduce( + (obj, value) => Object.assign(obj, { [`${value.fieldName}`]: value.value }), + {}, + ); Object.assign(contact, data); //@ts-ignore delete contact.customFieldsUi; @@ -148,9 +135,7 @@ export class Emelia implements INodeType { }); returnData.push({ contactId: responseData.data.addContactToCampaignHook }); - } else if (operation === 'create') { - // ---------------------------------- // campaign: create // ---------------------------------- @@ -175,9 +160,7 @@ export class Emelia implements INodeType { }); returnData.push(responseData.data.createCampaign); - } else if (operation === 'get') { - // ---------------------------------- // campaign: get // ---------------------------------- @@ -218,9 +201,7 @@ export class Emelia implements INodeType { }); returnData.push(responseData.data.campaign); - } else if (operation === 'getAll') { - // ---------------------------------- // campaign: getAll // ---------------------------------- @@ -258,9 +239,7 @@ export class Emelia implements INodeType { } returnData.push(...campaigns); - } else if (operation === 'pause') { - // ---------------------------------- // campaign: pause // ---------------------------------- @@ -277,9 +256,7 @@ export class Emelia implements INodeType { }); returnData.push({ success: true }); - } else if (operation === 'start') { - // ---------------------------------- // campaign: start // ---------------------------------- @@ -296,9 +273,7 @@ export class Emelia implements INodeType { }); returnData.push({ success: true }); - } else if (operation === 'duplicate') { - // ---------------------------------- // campaign: duplicate // ---------------------------------- @@ -313,7 +288,9 @@ export class Emelia implements INodeType { copyProvider: true, ...options, }; - const { data: { duplicateCampaign } } = await emeliaGraphqlRequest.call(this, { + const { + data: { duplicateCampaign }, + } = await emeliaGraphqlRequest.call(this, { query: ` mutation duplicateCampaign( $fromId: ID! @@ -338,15 +315,12 @@ export class Emelia implements INodeType { returnData.push({ _id: duplicateCampaign }); } - } else if (resource === 'contactList') { - // ********************************** // ContactList // ********************************** if (operation === 'add') { - // ---------------------------------- // contactList: add // ---------------------------------- @@ -362,8 +336,13 @@ export class Emelia implements INodeType { } if (additionalFields.customFieldsUi) { - const customFields = (additionalFields.customFieldsUi as IDataObject || {}).customFieldsValues as IDataObject[] || []; - const data = customFields.reduce((obj, value) => Object.assign(obj, { [`${value.fieldName}`]: value.value }), {}); + const customFields = + (((additionalFields.customFieldsUi as IDataObject) || {}) + .customFieldsValues as IDataObject[]) || []; + const data = customFields.reduce( + (obj, value) => Object.assign(obj, { [`${value.fieldName}`]: value.value }), + {}, + ); Object.assign(contact, data); //@ts-ignore delete contact.customFieldsUi; @@ -382,9 +361,7 @@ export class Emelia implements INodeType { }); returnData.push({ contactId: responseData.data.addContactsToListHook }); - } else if (operation === 'getAll') { - // ---------------------------------- // contactList: getAll // ---------------------------------- @@ -414,18 +391,14 @@ export class Emelia implements INodeType { returnData.push(...contactLists); } - } - } catch (error) { - if (this.continueOnFail()) { returnData.push({ error: (error as JsonObject).message }); continue; } throw error; - } } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Emelia/EmeliaTrigger.node.ts b/packages/nodes-base/nodes/Emelia/EmeliaTrigger.node.ts index f22d2de225f02..9465dd3c1ba42 100644 --- a/packages/nodes-base/nodes/Emelia/EmeliaTrigger.node.ts +++ b/packages/nodes-base/nodes/Emelia/EmeliaTrigger.node.ts @@ -8,11 +8,7 @@ import { IWebhookResponseData, } from 'n8n-workflow'; -import { - emeliaApiRequest, - emeliaApiTest, - emeliaGraphqlRequest, -} from './GenericFunctions'; +import { emeliaApiRequest, emeliaApiTest, emeliaGraphqlRequest } from './GenericFunctions'; interface Campaign { _id: string; @@ -53,7 +49,8 @@ export class EmeliaTrigger implements INodeType { 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', }, @@ -115,12 +112,10 @@ export class EmeliaTrigger implements INodeType { variables: '{}', }); - return responseData.data.campaigns.map( - (campaign: Campaign) => ({ - name: campaign.name, - value: campaign._id, - }), - ); + return responseData.data.campaigns.map((campaign: Campaign) => ({ + name: campaign.name, + value: campaign._id, + })); }, }, }; @@ -147,7 +142,7 @@ export class EmeliaTrigger implements INodeType { const campaignId = this.getNodeParameter('campaignId') as string; const body = { hookUrl: webhookUrl, - events: events.map(e => e.toUpperCase()), + events: events.map((e) => e.toUpperCase()), campaignId, }; @@ -179,9 +174,7 @@ export class EmeliaTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/Emelia/GenericFunctions.ts b/packages/nodes-base/nodes/Emelia/GenericFunctions.ts index a1feb5efa177a..528c8ee5ed649 100644 --- a/packages/nodes-base/nodes/Emelia/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Emelia/GenericFunctions.ts @@ -1,7 +1,4 @@ -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { ICredentialsDecrypted, @@ -39,7 +36,7 @@ export async function emeliaApiRequest( body: object = {}, qs: object = {}, ) { - const { apiKey } = await this.getCredentials('emeliaApi') as { apiKey: string }; + const { apiKey } = (await this.getCredentials('emeliaApi')) as { apiKey: string }; const options = { headers: { @@ -55,7 +52,7 @@ export async function emeliaApiRequest( try { return await this.helpers.request!.call(this, options); } catch (error) { - throw new NodeApiError(this.getNode(), (error as JsonObject)); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -66,7 +63,7 @@ export async function loadResource( this: ILoadOptionsFunctions, resource: 'campaign' | 'contactList', ): Promise { - const mapping: { [key in 'campaign' | 'contactList']: { query: string, key: string } } = { + const mapping: { [key in 'campaign' | 'contactList']: { query: string; key: string } } = { campaign: { query: ` query GetCampaigns { @@ -91,13 +88,18 @@ export async function loadResource( const responseData = await emeliaGraphqlRequest.call(this, { query: mapping[resource].query }); - return responseData.data[mapping[resource].key].map((campaign: { name: string, _id: string }) => ({ - name: campaign.name, - value: campaign._id, - })); + return responseData.data[mapping[resource].key].map( + (campaign: { name: string; _id: string }) => ({ + name: campaign.name, + value: campaign._id, + }), + ); } -export async function emeliaApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise { +export async function emeliaApiTest( + this: ICredentialTestFunctions, + credential: ICredentialsDecrypted, +): Promise { const credentials = credential.data; const body = { diff --git a/packages/nodes-base/nodes/ErrorTrigger/ErrorTrigger.node.ts b/packages/nodes-base/nodes/ErrorTrigger/ErrorTrigger.node.ts index ff6fa1808b081..ab2db4010a04b 100644 --- a/packages/nodes-base/nodes/ErrorTrigger/ErrorTrigger.node.ts +++ b/packages/nodes-base/nodes/ErrorTrigger/ErrorTrigger.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 ErrorTrigger implements INodeType { description: INodeTypeDescription = { @@ -25,7 +20,8 @@ export class ErrorTrigger implements INodeType { outputs: ['main'], properties: [ { - displayName: 'This node will trigger when there is an error in another workflow, as long as that workflow is set up to do so. More info', + displayName: + 'This node will trigger when there is an error in another workflow, as long as that workflow is set up to do so. More info', name: 'notice', type: 'notice', default: '', @@ -33,13 +29,17 @@ export class ErrorTrigger implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const mode = this.getMode(); - if (mode === 'manual' && items.length === 1 && Object.keys(items[0].json).length === 0 && items[0].binary === undefined) { + if ( + mode === 'manual' && + items.length === 1 && + Object.keys(items[0].json).length === 0 && + items[0].binary === undefined + ) { // If we are in manual mode and no input data got provided we return // example data to allow to develope and test errorWorkflows easily diff --git a/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.node.ts b/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.node.ts index a094bd47cedd9..c4df2686ed781 100644 --- a/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.node.ts +++ b/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.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, } from 'n8n-workflow'; -import { - eventbriteApiRequest, - eventbriteApiRequestAllItems, -} from './GenericFunctions'; +import { eventbriteApiRequest, eventbriteApiRequestAllItems } from './GenericFunctions'; export class EventbriteTrigger implements INodeType { description: INodeTypeDescription = { @@ -39,9 +33,7 @@ export class EventbriteTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'privateKey', - ], + authentication: ['privateKey'], }, }, }, @@ -50,9 +42,7 @@ export class EventbriteTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -91,7 +81,8 @@ export class EventbriteTrigger implements INodeType { loadOptionsMethod: 'getOrganizations', }, default: '', - description: 'The Eventbrite Organization to work on. Choose from the list, or specify an ID using an expression.', + description: + 'The Eventbrite Organization to work on. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Event Name or ID', @@ -99,13 +90,12 @@ export class EventbriteTrigger implements INodeType { type: 'options', required: true, typeOptions: { - loadOptionsDependsOn: [ - 'organization', - ], + loadOptionsDependsOn: ['organization'], loadOptionsMethod: 'getEvents', }, default: '', - description: 'Limit the triggers to this event. Choose from the list, or specify an ID using an expression.', + description: + 'Limit the triggers to this event. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Actions', @@ -183,7 +173,8 @@ export class EventbriteTrigger 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 only contain the URL to receive the object data manually. If this option gets activated, it will resolve the data automatically.', + description: + 'By default does the webhook-data only contain the URL to receive the object data manually. If this option gets activated, it will resolve the data automatically.', }, ], }; @@ -194,7 +185,12 @@ export class EventbriteTrigger implements INodeType { // select them easily async getOrganizations(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; - const organizations = await eventbriteApiRequestAllItems.call(this, 'organizations', 'GET', '/users/me/organizations'); + const organizations = await eventbriteApiRequestAllItems.call( + this, + 'organizations', + 'GET', + '/users/me/organizations', + ); for (const organization of organizations) { const organizationName = organization.name; const organizationId = organization.id; @@ -210,7 +206,12 @@ export class EventbriteTrigger implements INodeType { async getEvents(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = [{ name: 'All', value: 'all' }]; const organization = this.getCurrentNodeParameter('organization'); - const events = await eventbriteApiRequestAllItems.call(this, 'events', 'GET', `/organizations/${organization}/events`); + const events = await eventbriteApiRequestAllItems.call( + this, + 'events', + 'GET', + `/organizations/${organization}/events`, + ); for (const event of events) { const eventName = event.name.text; const eventId = event.id; @@ -279,7 +280,7 @@ export class EventbriteTrigger implements INodeType { const endpoint = `/webhooks/${webhookData.webhookId}/`; try { responseData = await eventbriteApiRequest.call(this, 'DELETE', endpoint); - } catch(error) { + } catch (error) { return false; } if (!responseData.success) { @@ -295,7 +296,9 @@ export class EventbriteTrigger implements INodeType { const req = this.getRequestObject(); if (req.body.api_url === undefined) { - throw new NodeApiError(this.getNode(), req.body, { message: 'The received data does not contain required "api_url" property!' }); + throw new NodeApiError(this.getNode(), req.body, { + message: 'The received data does not contain required "api_url" property!', + }); } const resolveData = this.getNodeParameter('resolveData', false) as boolean; @@ -303,9 +306,7 @@ export class EventbriteTrigger implements INodeType { if (resolveData === false) { // Return the data as it got received return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } @@ -313,18 +314,24 @@ export class EventbriteTrigger implements INodeType { return { workflowData: [ this.helpers.returnJsonArray({ - placeholder: 'Test received. To display actual data of object get the webhook triggered by performing the action which triggers it.', + placeholder: + 'Test received. To display actual data of object get the webhook triggered by performing the action which triggers it.', }), ], }; } - const responseData = await eventbriteApiRequest.call(this, 'GET', '', {}, undefined, req.body.api_url); + const responseData = await eventbriteApiRequest.call( + this, + 'GET', + '', + {}, + undefined, + req.body.api_url, + ); return { - workflowData: [ - this.helpers.returnJsonArray(responseData), - ], + workflowData: [this.helpers.returnJsonArray(responseData)], }; } } diff --git a/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts b/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts index 9e3c50615e864..5b70a02010f73 100644 --- a/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -10,17 +8,30 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, JsonObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; +import { IDataObject, JsonObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function eventbriteApiRequest(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 eventbriteApiRequest( + 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 { let options: OptionsWithUri = { headers: {}, method, qs, body, - uri: uri ||`https://www.eventbriteapi.com/v3${resource}`, + uri: uri || `https://www.eventbriteapi.com/v3${resource}`, json: true, }; options = Object.assign({}, options, option); @@ -48,8 +59,16 @@ export async function eventbriteApiRequest(this: IHookFunctions | IExecuteFuncti * Make an API request to paginated flow endpoint * and return all results */ -export async function eventbriteApiRequestAllItems(this: IHookFunctions | IExecuteFunctions| ILoadOptionsFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function eventbriteApiRequestAllItems( + 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/ExecuteCommand/ExecuteCommand.node.ts b/packages/nodes-base/nodes/ExecuteCommand/ExecuteCommand.node.ts index 2a0a4512faf33..289c510252f6f 100644 --- a/packages/nodes-base/nodes/ExecuteCommand/ExecuteCommand.node.ts +++ b/packages/nodes-base/nodes/ExecuteCommand/ExecuteCommand.node.ts @@ -3,12 +3,11 @@ import { INodeExecutionData, INodeType, INodeTypeDescription, - NodeOperationError + NodeOperationError, } from 'n8n-workflow'; import { exec } from 'child_process'; - export interface IExecReturnData { exitCode: number; error?: Error; @@ -16,7 +15,6 @@ export interface IExecReturnData { stdout: string; } - /** * Promisifiy exec manually to also get the exit code * @@ -41,11 +39,12 @@ function execPromise(command: string): Promise { } resolve(returnData); - }).on('exit', code => { returnData.exitCode = code || 0; }); + }).on('exit', (code) => { + returnData.exitCode = code || 0; + }); }); } - export class ExecuteCommand implements INodeType { description: INodeTypeDescription = { displayName: 'Execute Command', @@ -82,9 +81,7 @@ export class ExecuteCommand implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { - let items = this.getInputData(); let command: string; @@ -96,35 +93,25 @@ export class ExecuteCommand implements INodeType { const returnItems: INodeExecutionData[] = []; for (let itemIndex = 0; itemIndex < items.length; itemIndex++) { - - try{ - + try { command = this.getNodeParameter('command', itemIndex) as string; - const { - error, - exitCode, - stdout, - stderr, - } = await execPromise(command); + const { error, exitCode, stdout, stderr } = await execPromise(command); if (error !== undefined) { throw new NodeOperationError(this.getNode(), error.message, { itemIndex }); } - returnItems.push( - { - json: { - exitCode, - stderr, - stdout, - }, - pairedItem: { - item: itemIndex, - }, + returnItems.push({ + json: { + exitCode, + stderr, + stdout, }, - ); - + pairedItem: { + item: itemIndex, + }, + }); } catch (error) { if (this.continueOnFail()) { returnItems.push({ diff --git a/packages/nodes-base/nodes/ExecuteWorkflow/ExecuteWorkflow.node.ts b/packages/nodes-base/nodes/ExecuteWorkflow/ExecuteWorkflow.node.ts index 83ff97d143cd4..7cc30ff279fa1 100644 --- a/packages/nodes-base/nodes/ExecuteWorkflow/ExecuteWorkflow.node.ts +++ b/packages/nodes-base/nodes/ExecuteWorkflow/ExecuteWorkflow.node.ts @@ -1,6 +1,4 @@ -import { - readFile as fsReadFile, -} from 'fs/promises'; +import { readFile as fsReadFile } from 'fs/promises'; import { IExecuteFunctions } from 'n8n-core'; import { @@ -12,7 +10,6 @@ import { NodeOperationError, } from 'n8n-workflow'; - export class ExecuteWorkflow implements INodeType { description: INodeTypeDescription = { displayName: 'Execute Workflow', @@ -68,9 +65,7 @@ export class ExecuteWorkflow implements INodeType { type: 'string', displayOptions: { show: { - source: [ - 'database', - ], + source: ['database'], }, }, default: '', @@ -87,9 +82,7 @@ export class ExecuteWorkflow implements INodeType { type: 'string', displayOptions: { show: { - source: [ - 'localFile', - ], + source: ['localFile'], }, }, default: '', @@ -112,9 +105,7 @@ export class ExecuteWorkflow implements INodeType { }, displayOptions: { show: { - source: [ - 'parameter', - ], + source: ['parameter'], }, }, default: '\n\n\n', @@ -131,9 +122,7 @@ export class ExecuteWorkflow implements INodeType { type: 'string', displayOptions: { show: { - source: [ - 'url', - ], + source: ['url'], }, }, default: '', @@ -142,7 +131,8 @@ export class ExecuteWorkflow implements INodeType { description: 'The URL from which to load the workflow from', }, { - displayName: 'Any data you pass into this node will be output by the start node of the workflow to be executed. More info', + displayName: + 'Any data you pass into this node will be output by the start node of the workflow to be executed. More info', name: 'executeWorkflowNotice', type: 'notice', default: '', @@ -157,21 +147,22 @@ export class ExecuteWorkflow implements INodeType { const workflowInfo: IExecuteWorkflowInfo = {}; try { - if (source === 'database') { // Read workflow from database workflowInfo.id = this.getNodeParameter('workflowId', 0) as string; - } else if (source === 'localFile') { // Read workflow from filesystem const workflowPath = this.getNodeParameter('workflowPath', 0) as string; let workflowJson; try { - workflowJson = await fsReadFile(workflowPath, { encoding: 'utf8' }) as string; + workflowJson = (await fsReadFile(workflowPath, { encoding: 'utf8' })) as string; } catch (error) { if (error.code === 'ENOENT') { - throw new NodeOperationError(this.getNode(), `The file "${workflowPath}" could not be found.`); + throw new NodeOperationError( + this.getNode(), + `The file "${workflowPath}" could not be found.`, + ); } throw error; @@ -182,15 +173,13 @@ export class ExecuteWorkflow implements INodeType { // Read workflow from parameter const workflowJson = this.getNodeParameter('workflowJson', 0) as string; workflowInfo.code = JSON.parse(workflowJson) as IWorkflowBase; - } else if (source === 'url') { // Read workflow from url const workflowUrl = this.getNodeParameter('workflowUrl', 0) as string; - const requestOptions = { headers: { - 'accept': 'application/json,text/*;q=0.99', + accept: 'application/json,text/*;q=0.99', }, method: 'GET', uri: workflowUrl, @@ -200,16 +189,14 @@ export class ExecuteWorkflow implements INodeType { const response = await this.helpers.request(requestOptions); workflowInfo.code = response; - } const receivedData = await this.executeWorkflow(workflowInfo, items); return receivedData; - } catch (error) { if (this.continueOnFail()) { - return this.prepareOutputData([{json:{ error: error.message }}]); + return this.prepareOutputData([{ json: { error: error.message } }]); } throw error; diff --git a/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts b/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts index 6b6cf21a002f7..f1676bba6b9a1 100644 --- a/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts +++ b/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts @@ -9,9 +9,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; export class FacebookGraphApi implements INodeType { description: INodeTypeDescription = { @@ -48,7 +46,8 @@ export class FacebookGraphApi implements INodeType { }, ], default: 'graph.facebook.com', - description: 'The Host URL of the request. Almost all requests are passed to the graph.facebook.com host URL. The single exception is video uploads, which use graph-video.facebook.com.', + description: + 'The Host URL of the request. Almost all requests are passed to the graph.facebook.com host URL. The single exception is video uploads, which use graph-video.facebook.com.', required: true, }, { @@ -152,7 +151,8 @@ export class FacebookGraphApi implements INodeType { name: 'node', type: 'string', default: '', - description: 'The node on which to operate. A node is an individual object with a unique ID. For example, there are many User node objects, each with a unique ID representing a person on Facebook.', + description: + 'The node on which to operate. A node is an individual object with a unique ID. For example, there are many User node objects, each with a unique ID representing a person on Facebook.', placeholder: 'me', required: true, }, @@ -161,7 +161,8 @@ export class FacebookGraphApi implements INodeType { name: 'edge', type: 'string', default: '', - description: 'Edge of the node on which to operate. Edges represent collections of objects which are attached to the node.', + description: + 'Edge of the node on which to operate. Edges represent collections of objects which are attached to the node.', placeholder: 'videos', }, { @@ -177,10 +178,7 @@ export class FacebookGraphApi implements INodeType { type: 'boolean', displayOptions: { show: { - httpRequestMethod: [ - 'POST', - 'PUT', - ], + httpRequestMethod: ['POST', 'PUT'], }, }, default: false, @@ -195,18 +193,14 @@ export class FacebookGraphApi implements INodeType { placeholder: 'file:data', displayOptions: { hide: { - sendBinaryData: [ - false, - ], + sendBinaryData: [false], }, show: { - httpRequestMethod: [ - 'POST', - 'PUT', - ], + httpRequestMethod: ['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: 'Options', @@ -225,9 +219,7 @@ export class FacebookGraphApi implements INodeType { }, displayOptions: { show: { - '/httpRequestMethod': [ - 'GET', - ], + '/httpRequestMethod': ['GET'], }, }, description: 'The list of fields to request in the GET request', @@ -286,7 +278,7 @@ export class FacebookGraphApi implements INodeType { name: 'queryParametersJson', type: 'json', default: '{}', - placeholder: '{\"field_name\": \"field_value\"}', + placeholder: '{"field_name": "field_value"}', description: 'The query parameters to send, defined as a JSON object', }, ], @@ -294,7 +286,6 @@ export class FacebookGraphApi implements INodeType { ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); @@ -320,7 +311,7 @@ export class FacebookGraphApi implements INodeType { uri = `${uri}/${edge}`; } - const requestOptions : OptionsWithUri = { + const requestOptions: OptionsWithUri = { headers: { accept: 'application/json,text/*;q=0.99', }, @@ -331,7 +322,11 @@ export class FacebookGraphApi implements INodeType { qs: { access_token: graphApiCredentials!.accessToken, }, - rejectUnauthorized: !this.getNodeParameter('allowUnauthorizedCerts', itemIndex, false) as boolean, + rejectUnauthorized: !this.getNodeParameter( + 'allowUnauthorizedCerts', + itemIndex, + false, + ) as boolean, }; if (options !== undefined) { @@ -339,7 +334,7 @@ export class FacebookGraphApi implements INodeType { if (options.fields !== undefined) { const fields = options.fields as IDataObject; if (fields.field !== undefined) { - const fieldsCsv = (fields.field as IDataObject[]).map(field => field.name).join(','); + const fieldsCsv = (fields.field as IDataObject[]).map((field) => field.name).join(','); requestOptions.qs.fields = fieldsCsv; } } @@ -358,10 +353,11 @@ export class FacebookGraphApi implements INodeType { // Add the query parameters defined as a JSON object if (options.queryParametersJson) { let queryParametersJsonObj = {}; - try - { + try { queryParametersJsonObj = JSON.parse(options.queryParametersJson as string); - } catch { /* Do nothing, at least for now */} + } catch { + /* Do nothing, at least for now */ + } const qs = requestOptions.qs; requestOptions.qs = { ...qs, @@ -374,10 +370,15 @@ export class FacebookGraphApi implements INodeType { if (sendBinaryData) { 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, + }); } - const binaryPropertyNameFull = this.getNodeParameter('binaryPropertyName', itemIndex) as string; + const binaryPropertyNameFull = this.getNodeParameter( + 'binaryPropertyName', + itemIndex, + ) as string; let propertyName = 'file'; let binaryPropertyName = binaryPropertyNameFull; @@ -388,12 +389,19 @@ export class FacebookGraphApi implements INodeType { } 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 binaryProperty = item.binary[binaryPropertyName] as IBinaryData; - const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, binaryPropertyName); + const binaryDataBuffer = await this.helpers.getBinaryDataBuffer( + itemIndex, + binaryPropertyName, + ); requestOptions.formData = { [propertyName]: { value: binaryDataBuffer, @@ -435,14 +443,16 @@ export class FacebookGraphApi implements INodeType { if (typeof response === 'string') { if (this.continueOnFail() === false) { - throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON.', { itemIndex }); + throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON.', { + itemIndex, + }); } returnItems.push({ json: { message: response } }); continue; } - returnItems.push({json: response}); + returnItems.push({ json: response }); } return [returnItems]; diff --git a/packages/nodes-base/nodes/Facebook/FacebookTrigger.node.ts b/packages/nodes-base/nodes/Facebook/FacebookTrigger.node.ts index bae6223d9d09f..881d178757b57 100644 --- a/packages/nodes-base/nodes/Facebook/FacebookTrigger.node.ts +++ b/packages/nodes-base/nodes/Facebook/FacebookTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -15,17 +12,11 @@ import { import { v4 as uuid } from 'uuid'; -import { - snakeCase, -} from 'change-case'; +import { snakeCase } from 'change-case'; -import { - facebookApiRequest, getAllFields, getFields, -} from './GenericFunctions'; +import { facebookApiRequest, getAllFields, getFields } from './GenericFunctions'; -import { - createHmac, -} from 'crypto'; +import { createHmac } from 'crypto'; export class FacebookTrigger implements INodeType { description: INodeTypeDescription = { @@ -142,12 +133,11 @@ export class FacebookTrigger implements INodeType { type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getObjectFields', - loadOptionsDependsOn: [ - 'object', - ], + loadOptionsDependsOn: ['object'], }, default: [], - description: 'The set of fields in this object that are subscribed to. Choose from the list, or specify IDs using an expression.', + description: + 'The set of fields in this object that are subscribed to. Choose from the list, or specify IDs using an expression.', }, { displayName: 'Options', @@ -168,7 +158,6 @@ export class FacebookTrigger implements INodeType { ], }; - methods = { loadOptions: { // Get all the available organizations to display them to user so that he can @@ -191,7 +180,11 @@ export class FacebookTrigger implements INodeType { const { data } = await facebookApiRequest.call(this, 'GET', `/${appId}/subscriptions`, {}); for (const webhook of data) { - if (webhook.target === webhookUrl && webhook.object === object && webhook.status === true) { + if ( + webhook.target === webhookUrl && + webhook.object === object && + webhook.status === true + ) { return true; } } @@ -209,20 +202,27 @@ export class FacebookTrigger implements INodeType { object: snakeCase(object), callback_url: webhookUrl, verify_token: uuid(), - fields: (fields.includes('*')) ? getAllFields(object) : fields, + fields: fields.includes('*') ? getAllFields(object) : fields, } as IDataObject; if (options.includeValues !== undefined) { body.include_values = options.includeValues; } - const responseData = await facebookApiRequest.call(this, 'POST', `/${appId}/subscriptions`, body); + const responseData = await facebookApiRequest.call( + this, + 'POST', + `/${appId}/subscriptions`, + body, + ); webhookData.verifyToken = body.verify_token; if (responseData.success !== true) { // Facebook did not return success, so something went wrong - throw new NodeApiError(this.getNode(), responseData, { message: 'Facebook webhook creation response did not contain the expected data.' }); + throw new NodeApiError(this.getNode(), responseData, { + message: 'Facebook webhook creation response did not contain the expected data.', + }); } return true; }, @@ -231,7 +231,9 @@ export class FacebookTrigger implements INodeType { const object = this.getNodeParameter('object') as string; try { - await facebookApiRequest.call(this, 'DELETE', `/${appId}/subscriptions`, { object: snakeCase(object) }); + await facebookApiRequest.call(this, 'DELETE', `/${appId}/subscriptions`, { + object: snakeCase(object), + }); } catch (error) { return false; } @@ -265,17 +267,17 @@ export class FacebookTrigger implements INodeType { // validate signature if app secret is set if (credentials.appSecret !== '') { - //@ts-ignore - const computedSignature = createHmac('sha1', credentials.appSecret as string).update(req.rawBody).digest('hex'); + const computedSignature = createHmac('sha1', credentials.appSecret as string) + //@ts-ignore + .update(req.rawBody) + .digest('hex'); if (headerData['x-hub-signature'] !== `sha1=${computedSignature}`) { return {}; } } return { - workflowData: [ - this.helpers.returnJsonArray(bodyData.entry as IDataObject[]), - ], + workflowData: [this.helpers.returnJsonArray(bodyData.entry as IDataObject[])], }; } } diff --git a/packages/nodes-base/nodes/Facebook/GenericFunctions.ts b/packages/nodes-base/nodes/Facebook/GenericFunctions.ts index c2bf8108eed87..079ea205efce0 100644 --- a/packages/nodes-base/nodes/Facebook/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Facebook/GenericFunctions.ts @@ -1,6 +1,4 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; import { IExecuteFunctions, @@ -10,16 +8,26 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, NodeApiError, -} from 'n8n-workflow'; - -import { - capitalCase, -} from 'change-case'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function facebookApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise { // tslint:disable-line:no-any +import { capitalCase } from 'change-case'; +export async function facebookApiRequest( + 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 { let credentials; if (this.getNode().name.includes('Trigger')) { @@ -51,7 +59,7 @@ export async function facebookApiRequest(this: IHookFunctions | IExecuteFunction export function getFields(object: string) { const data = { - 'adAccount': [ + adAccount: [ { value: 'in_process_ad_objects', }, @@ -59,7 +67,7 @@ export function getFields(object: string) { value: 'with_issues_ad_objects', }, ], - 'page': [ + page: [ { value: 'affiliation', description: `Describes changes to a page's Affliation profile field`, @@ -224,7 +232,7 @@ export function getFields(object: string) { description: `Describes changes to a page's Website profile field`, }, ], - 'application': [ + application: [ { value: 'ad_account', }, @@ -253,7 +261,7 @@ export function getFields(object: string) { value: 'plugin_comment_reply', }, ], - 'certificateTransparency': [ + certificateTransparency: [ { value: 'certificate', }, @@ -261,7 +269,7 @@ export function getFields(object: string) { value: 'phishing', }, ], - 'instagram': [ + instagram: [ { value: 'comments', description: 'Notifies you when an Instagram User comments on a media object that you own', @@ -271,7 +279,8 @@ export function getFields(object: string) { }, { value: 'mentions', - description: 'Notifies you when an Instagram User @mentions you in a comment or caption on a media object that you do not own', + description: + 'Notifies you when an Instagram User @mentions you in a comment or caption on a media object that you do not own', }, { value: 'messages', @@ -286,7 +295,7 @@ export function getFields(object: string) { value: 'story_insights', }, ], - 'permissions': [ + permissions: [ { value: 'bookmarked', description: 'Whether the user has added or removed the app bookmark', @@ -446,7 +455,7 @@ export function getFields(object: string) { value: 'social_ads', }, ], - 'users': [ + users: [ { value: 'about', }, @@ -523,7 +532,7 @@ export function getFields(object: string) { value: 'videos', }, ], - 'whatsappBusinessAccount': [ + whatsappBusinessAccount: [ { value: 'message_template_status_update', }, @@ -540,14 +549,20 @@ export function getFields(object: string) { value: 'account_update', }, ], - // tslint:disable-next-line: no-any + // tslint:disable-next-line: no-any } as { [key: string]: any }; - return [{ name: '*', value: '*' }].concat(data[object as string] || []) - .map((fieldObject: IDataObject) => - ({ ...fieldObject, name: (fieldObject.value !== '*') ? capitalCase(fieldObject.value as string) : fieldObject.value })); + return [{ name: '*', value: '*' }] + .concat(data[object as string] || []) + .map((fieldObject: IDataObject) => ({ + ...fieldObject, + name: + fieldObject.value !== '*' ? capitalCase(fieldObject.value as string) : fieldObject.value, + })); } export function getAllFields(object: string) { - return getFields(object).filter((field: IDataObject) => field.value !== '*').map((field: IDataObject) => field.value); + return getFields(object) + .filter((field: IDataObject) => field.value !== '*') + .map((field: IDataObject) => field.value); } diff --git a/packages/nodes-base/nodes/Figma/FigmaTrigger.node.ts b/packages/nodes-base/nodes/Figma/FigmaTrigger.node.ts index 0d3670305504e..b965c502c3ff6 100644 --- a/packages/nodes-base/nodes/Figma/FigmaTrigger.node.ts +++ b/packages/nodes-base/nodes/Figma/FigmaTrigger.node.ts @@ -1,26 +1,12 @@ -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 { - figmaApiRequest, -} from './GenericFunctions'; +import { figmaApiRequest } from './GenericFunctions'; -import { - snakeCase, -} from 'change-case'; +import { snakeCase } from 'change-case'; -import { - randomBytes, -} from 'crypto'; +import { randomBytes } from 'crypto'; export class FigmaTrigger implements INodeType { description: INodeTypeDescription = { @@ -58,7 +44,8 @@ export class FigmaTrigger implements INodeType { type: 'string', required: true, default: '', - description: 'Trigger will monitor this Figma Team for changes. Team ID can be found in the URL of a Figma Team page when viewed in a web browser: figma.com/files/team/{TEAM-ID}/.', + description: + 'Trigger will monitor this Figma Team for changes. Team ID can be found in the URL of a Figma Team page when viewed in a web browser: figma.com/files/team/{TEAM-ID}/.', }, { displayName: 'Trigger On', @@ -73,17 +60,20 @@ export class FigmaTrigger implements INodeType { { name: 'File Deleted', value: 'fileDelete', - description: 'Triggers whenever a file has been deleted. Does not trigger on all files within a folder, if the folder is deleted.', + description: + 'Triggers whenever a file has been deleted. Does not trigger on all files within a folder, if the folder is deleted.', }, { name: 'File Updated', value: 'fileUpdate', - description: 'Triggers whenever a file saves or is deleted. This occurs whenever a file is closed or within 30 seconds after changes have been made.', + description: + 'Triggers whenever a file saves or is deleted. This occurs whenever a file is closed or within 30 seconds after changes have been made.', }, { name: 'File Version Updated', value: 'fileVersionUpdate', - description: 'Triggers whenever a named version is created in the version history of a file', + description: + 'Triggers whenever a named version is created in the version history of a file', }, { name: 'Library Publish', @@ -107,12 +97,18 @@ export class FigmaTrigger implements INodeType { const triggerOn = this.getNodeParameter('triggerOn') as string; // Check all the webhooks which exist already if it is identical to the // one that is supposed to get created. - const { webhooks } = await figmaApiRequest.call(this, 'GET', `/v2/teams/${teamId}/webhooks`); + const { webhooks } = await figmaApiRequest.call( + this, + 'GET', + `/v2/teams/${teamId}/webhooks`, + ); for (const webhook of webhooks) { - if (webhook.endpoint === webhookUrl - && webhook.team_id === teamId - && webhook.event_type === snakeCase(triggerOn).toUpperCase() - && webhook.status === 'ACTIVE') { + if ( + webhook.endpoint === webhookUrl && + webhook.team_id === teamId && + webhook.event_type === snakeCase(triggerOn).toUpperCase() && + webhook.status === 'ACTIVE' + ) { webhookData.webhookId = webhook.id as string; return true; } @@ -147,7 +143,6 @@ export class FigmaTrigger implements INodeType { async delete(this: IHookFunctions): Promise { const webhookData = this.getWorkflowStaticData('node'); if (webhookData.webhookId !== undefined) { - const endpoint = `/v2/webhooks/${webhookData.webhookId}`; try { await figmaApiRequest.call(this, 'DELETE', endpoint); @@ -175,9 +170,7 @@ export class FigmaTrigger implements INodeType { } return { - workflowData: [ - this.helpers.returnJsonArray(bodyData), - ], + workflowData: [this.helpers.returnJsonArray(bodyData)], }; } } diff --git a/packages/nodes-base/nodes/Figma/GenericFunctions.ts b/packages/nodes-base/nodes/Figma/GenericFunctions.ts index aba1874620dbc..249f4e5efa046 100644 --- a/packages/nodes-base/nodes/Figma/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Figma/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'; +import { IDataObject, NodeApiError } from 'n8n-workflow'; -export async function figmaApiRequest(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 figmaApiRequest( + 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('figmaApi'); let options: OptionsWithUri = { diff --git a/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts b/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts index 35ead20f0938a..2c41fdd0ee36d 100644 --- a/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts +++ b/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts @@ -1,15 +1,15 @@ /* eslint-disable n8n-nodes-base/node-filename-against-convention */ -import {IExecuteFunctions} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { ILoadOptionsFunctions, - INodeExecutionData, INodePropertyOptions, + INodeExecutionData, + INodePropertyOptions, INodeType, INodeTypeDescription, NodeOperationError, } from 'n8n-workflow'; - -import {OptionsWithUri} from 'request'; +import { OptionsWithUri } from 'request'; import { getFields, getPortals, @@ -109,7 +109,8 @@ export class FileMaker implements INodeType { required: true, displayOptions: {}, placeholder: 'Layout Name', - description: 'FileMaker Layout Name. Choose from the list, or specify an ID using an expression.', + description: + 'FileMaker Layout Name. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Record ID', @@ -119,12 +120,7 @@ export class FileMaker implements INodeType { required: true, displayOptions: { show: { - action: [ - 'record', - 'edit', - 'delete', - 'duplicate', - ], + action: ['record', 'edit', 'delete', 'duplicate'], }, }, placeholder: 'Record ID', @@ -139,10 +135,7 @@ export class FileMaker implements INodeType { default: 1, displayOptions: { show: { - action: [ - 'find', - 'records', - ], + action: ['find', 'records'], }, }, }, @@ -158,10 +151,7 @@ export class FileMaker implements INodeType { default: 100, displayOptions: { show: { - action: [ - 'find', - 'records', - ], + action: ['find', 'records'], }, }, }, @@ -173,11 +163,7 @@ export class FileMaker implements INodeType { description: 'Whether to get portal data as well', displayOptions: { show: { - action: [ - 'record', - 'records', - 'find', - ], + action: ['record', 'records', 'find'], }, }, }, @@ -194,18 +180,13 @@ export class FileMaker implements INodeType { default: [], displayOptions: { show: { - action: [ - 'record', - 'records', - 'find', - ], - getPortals: [ - true, - ], + action: ['record', 'records', 'find'], + getPortals: [true], }, }, placeholder: 'Portals', - description: 'The portal result set to return. Use the portal object name or portal table name. If this parameter is omitted, the API will return all portal objects and records in the layout. For best performance, pass the portal object name or portal table name. Choose from the list, or specify an ID using an expression.', + description: + 'The portal result set to return. Use the portal object name or portal table name. If this parameter is omitted, the API will return all portal objects and records in the layout. For best performance, pass the portal object name or portal table name. Choose from the list, or specify an ID using an expression.', }, // ---------------------------------- // find/records @@ -214,7 +195,8 @@ export class FileMaker implements INodeType { displayName: 'Response Layout Name or ID', name: 'responseLayout', type: 'options', - 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: 'getResponseLayouts', }, @@ -222,9 +204,7 @@ export class FileMaker implements INodeType { default: '', displayOptions: { show: { - action: [ - 'find', - ], + action: ['find'], }, }, }, @@ -238,9 +218,7 @@ export class FileMaker implements INodeType { }, displayOptions: { show: { - action: [ - 'find', - ], + action: ['find'], }, }, default: {}, @@ -258,30 +236,32 @@ export class FileMaker implements INodeType { typeOptions: { multipleValues: true, }, - options: [{ - name: 'field', - displayName: 'Field', - values: [ - { - displayName: 'Field Name or ID', - name: 'name', - type: 'options', - default: '', - typeOptions: { - loadOptionsMethod: 'getFields', + options: [ + { + name: 'field', + displayName: 'Field', + values: [ + { + displayName: 'Field Name or ID', + name: 'name', + type: 'options', + default: '', + typeOptions: { + loadOptionsMethod: 'getFields', + }, + options: [], + description: + 'Search Field. Choose from the list, or specify an ID using an expression.', }, - options: [], - description: 'Search Field. Choose from the list, or specify an ID using an expression.', - }, - { - displayName: 'Value', - name: 'value', - type: 'string', - default: '', - description: 'Value to search', - }, - ], - }, + { + displayName: 'Value', + name: 'value', + type: 'string', + default: '', + description: 'Value to search', + }, + ], + }, ], description: 'Field Name', }, @@ -303,11 +283,7 @@ export class FileMaker implements INodeType { description: 'Whether to sort data', displayOptions: { show: { - action: [ - 'find', - 'record', - 'records', - ], + action: ['find', 'record', 'records'], }, }, }, @@ -321,13 +297,8 @@ export class FileMaker implements INodeType { }, displayOptions: { show: { - setSort: [ - true, - ], - action: [ - 'find', - 'records', - ], + setSort: [true], + action: ['find', 'records'], }, }, description: 'Sort rules', @@ -346,7 +317,8 @@ export class FileMaker implements INodeType { loadOptionsMethod: 'getFields', }, options: [], - description: 'Field Name. Choose from the list, or specify an ID using an expression.', + description: + 'Field Name. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Order', @@ -374,14 +346,11 @@ export class FileMaker implements INodeType { name: 'setScriptBefore', type: 'boolean', default: false, - description: 'Whether to define a script to be run before the action specified by the API call and after the subsequent sort', + description: + 'Whether to define a script to be run before the action specified by the API call and after the subsequent sort', displayOptions: { show: { - action: [ - 'find', - 'record', - 'records', - ], + action: ['find', 'record', 'records'], }, }, }, @@ -397,18 +366,13 @@ export class FileMaker implements INodeType { required: true, displayOptions: { show: { - action: [ - 'find', - 'record', - 'records', - ], - setScriptBefore: [ - true, - ], + action: ['find', 'record', 'records'], + setScriptBefore: [true], }, }, placeholder: 'Script Name', - description: 'The name of the FileMaker script to be run after the action specified by the API call and after the subsequent sort. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the FileMaker script to be run after the action specified by the API call and after the subsequent sort. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Script Parameter', @@ -417,14 +381,8 @@ export class FileMaker implements INodeType { default: '', displayOptions: { show: { - action: [ - 'find', - 'record', - 'records', - ], - setScriptBefore: [ - true, - ], + action: ['find', 'record', 'records'], + setScriptBefore: [true], }, }, placeholder: 'Script Parameters', @@ -435,14 +393,11 @@ export class FileMaker implements INodeType { name: 'setScriptSort', type: 'boolean', default: false, - description: 'Whether to define a script to be run after the action specified by the API call but before the subsequent sort', + description: + 'Whether to define a script to be run after the action specified by the API call but before the subsequent sort', displayOptions: { show: { - action: [ - 'find', - 'record', - 'records', - ], + action: ['find', 'record', 'records'], }, }, }, @@ -458,18 +413,13 @@ export class FileMaker implements INodeType { required: true, displayOptions: { show: { - action: [ - 'find', - 'record', - 'records', - ], - setScriptSort: [ - true, - ], + action: ['find', 'record', 'records'], + setScriptSort: [true], }, }, placeholder: 'Script Name', - description: 'The name of the FileMaker script to be run after the action specified by the API call but before the subsequent sort. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the FileMaker script to be run after the action specified by the API call but before the subsequent sort. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Script Parameter', @@ -478,14 +428,8 @@ export class FileMaker implements INodeType { default: '', displayOptions: { show: { - action: [ - 'find', - 'record', - 'records', - ], - setScriptSort: [ - true, - ], + action: ['find', 'record', 'records'], + setScriptSort: [true], }, }, placeholder: 'Script Parameters', @@ -496,14 +440,11 @@ export class FileMaker implements INodeType { name: 'setScriptAfter', type: 'boolean', default: false, - description: 'Whether to define a script to be run after the action specified by the API call but before the subsequent sort', + description: + 'Whether to define a script to be run after the action specified by the API call but before the subsequent sort', displayOptions: { show: { - action: [ - 'find', - 'record', - 'records', - ], + action: ['find', 'record', 'records'], }, }, }, @@ -519,18 +460,13 @@ export class FileMaker implements INodeType { required: true, displayOptions: { show: { - action: [ - 'find', - 'record', - 'records', - ], - setScriptAfter: [ - true, - ], + action: ['find', 'record', 'records'], + setScriptAfter: [true], }, }, placeholder: 'Script Name', - description: 'The name of the FileMaker script to be run after the action specified by the API call and after the subsequent sort. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the FileMaker script to be run after the action specified by the API call and after the subsequent sort. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Script Parameter', @@ -539,14 +475,8 @@ export class FileMaker implements INodeType { default: '', displayOptions: { show: { - action: [ - 'find', - 'record', - 'records', - ], - setScriptAfter: [ - true, - ], + action: ['find', 'record', 'records'], + setScriptAfter: [true], }, }, placeholder: 'Script Parameters', @@ -574,14 +504,13 @@ export class FileMaker implements INodeType { { displayName: 'Mod ID', name: 'modId', - description: 'The last modification ID. When you use modId, a record is edited only when the modId matches.', + description: + 'The last modification ID. When you use modId, a record is edited only when the modId matches.', type: 'number', default: '', displayOptions: { show: { - action: [ - 'edit', - ], + action: ['edit'], }, }, }, @@ -595,10 +524,7 @@ export class FileMaker implements INodeType { }, displayOptions: { show: { - action: [ - 'create', - 'edit', - ], + action: ['create', 'edit'], }, }, description: 'Fields to define', @@ -617,7 +543,8 @@ export class FileMaker implements INodeType { loadOptionsMethod: 'getFields', }, options: [], - description: 'Field Name. Choose from the list, or specify an ID using an expression.', + description: + 'Field Name. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Value', @@ -644,13 +571,12 @@ export class FileMaker implements INodeType { required: true, displayOptions: { show: { - action: [ - 'performscript', - ], + action: ['performscript'], }, }, placeholder: 'Script Name', - description: 'The name of the FileMaker script to be run. Choose from the list, or specify an ID using an expression.', + description: + 'The name of the FileMaker script to be run. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Script Parameter', @@ -659,9 +585,7 @@ export class FileMaker implements INodeType { default: '', displayOptions: { show: { - action: [ - 'performscript', - ], + action: ['performscript'], }, }, placeholder: 'Script Parameters', @@ -766,7 +690,6 @@ export class FileMaker implements INodeType { }, }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); const returnData: INodeExecutionData[] = []; @@ -795,7 +718,7 @@ export class FileMaker implements INodeType { requestOptions = { uri: '', headers: { - 'Authorization': `Bearer ${token}`, + Authorization: `Bearer ${token}`, }, method: 'GET', json: true, @@ -807,15 +730,15 @@ export class FileMaker implements INodeType { const recid = this.getNodeParameter('recid', i) as string; requestOptions.uri = url + `/databases/${database}/layouts/${layout}/records/${recid}`; requestOptions.qs = { - 'portal': JSON.stringify(parsePortals.call(this, i)), + portal: JSON.stringify(parsePortals.call(this, i)), ...parseScripts.call(this, i), }; } else if (action === 'records') { requestOptions.uri = url + `/databases/${database}/layouts/${layout}/records`; requestOptions.qs = { - '_offset': this.getNodeParameter('offset', i), - '_limit': this.getNodeParameter('limit', i), - 'portal': JSON.stringify(parsePortals.call(this, i)), + _offset: this.getNodeParameter('offset', i), + _limit: this.getNodeParameter('limit', i), + portal: JSON.stringify(parsePortals.call(this, i)), ...parseScripts.call(this, i), }; const sort = parseSort.call(this, i); @@ -826,9 +749,9 @@ export class FileMaker implements INodeType { requestOptions.uri = url + `/databases/${database}/layouts/${layout}/_find`; requestOptions.method = 'POST'; requestOptions.body = { - 'query': parseQuery.call(this, i), - 'offset': this.getNodeParameter('offset', i), - 'limit': this.getNodeParameter('limit', i), + query: parseQuery.call(this, i), + offset: this.getNodeParameter('offset', i), + limit: this.getNodeParameter('limit', i), 'layout.response': this.getNodeParameter('responseLayout', i), ...parseScripts.call(this, i), }; @@ -843,7 +766,7 @@ export class FileMaker implements INodeType { //TODO: handle portalData requestOptions.body = { - fieldData: {...parseFields.call(this, i)}, + fieldData: { ...parseFields.call(this, i) }, portalData: {}, ...parseScripts.call(this, i), }; @@ -855,13 +778,14 @@ export class FileMaker implements INodeType { //TODO: handle portalData requestOptions.body = { - fieldData: {...parseFields.call(this, i)}, + fieldData: { ...parseFields.call(this, i) }, portalData: {}, ...parseScripts.call(this, i), }; } else if (action === 'performscript') { const scriptName = this.getNodeParameter('script', i) as string; - requestOptions.uri = url + `/databases/${database}/layouts/${layout}/script/${scriptName}`; + requestOptions.uri = + url + `/databases/${database}/layouts/${layout}/script/${scriptName}`; requestOptions.qs = { 'script.param': this.getNodeParameter('scriptParam', i), }; @@ -881,7 +805,11 @@ export class FileMaker implements INodeType { ...parseScripts.call(this, i), }; } else { - throw new NodeOperationError(this.getNode(), `The action "${action}" is not implemented yet!`, { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + `The action "${action}" is not implemented yet!`, + { itemIndex: i }, + ); } // Now that the options are all set make the actual http request @@ -893,9 +821,13 @@ export class FileMaker implements INodeType { } if (typeof response === 'string') { - throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"', { itemIndex: i }); + throw new NodeOperationError( + this.getNode(), + 'Response body is not valid JSON. Change "Response Format" to "String"', + { itemIndex: i }, + ); } - returnData.push({json: response}); + returnData.push({ json: response }); } } catch (error) { await logout.call(this, token); @@ -904,7 +836,10 @@ export class FileMaker implements INodeType { throw error; } - throw new NodeOperationError(this.getNode(), `The action "${error.message}" is not implemented yet!`); + throw new NodeOperationError( + this.getNode(), + `The action "${error.message}" is not implemented yet!`, + ); } return this.prepareOutputData(returnData); diff --git a/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts b/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts index 9cb9d4abf2730..e829e95f67b78 100644 --- a/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts @@ -1,14 +1,8 @@ -import { - IExecuteFunctions, - IExecuteSingleFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { IExecuteFunctions, IExecuteSingleFunctions, 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'; interface ScriptsOptions { script?: any; //tslint:disable-line:no-any @@ -21,13 +15,13 @@ interface ScriptsOptions { interface LayoutObject { name: string; isFolder?: boolean; - folderLayoutNames?:LayoutObject[]; + folderLayoutNames?: LayoutObject[]; } interface ScriptObject { name: string; isFolder?: boolean; - folderScriptNames?:LayoutObject[]; + folderScriptNames?: LayoutObject[]; } /** @@ -37,7 +31,10 @@ interface ScriptObject { * @param {string} method * @returns {Promise} */ -export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions): Promise { // tslint:disable-line:no-any +export async function layoutsApiRequest( + this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions, +): Promise { + // tslint:disable-line:no-any const token = await getToken.call(this); const credentials = await this.getCredentials('fileMaker'); @@ -47,7 +44,7 @@ export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFu const url = `https://${host}/fmi/data/v1/databases/${db}/layouts`; const options: OptionsWithUri = { headers: { - 'Authorization': `Bearer ${token}`, + Authorization: `Bearer ${token}`, }, method: 'GET', uri: url, @@ -57,7 +54,7 @@ export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFu try { const responseData = await this.helpers.request!(options); const items = parseLayouts(responseData.response.layouts); - items.sort((a, b) => a.name > b.name ? 0 : 1); + items.sort((a, b) => (a.name > b.name ? 0 : 1)); return items; } catch (error) { throw new NodeApiError(this.getNode(), error); @@ -67,7 +64,7 @@ export async function layoutsApiRequest(this: ILoadOptionsFunctions | IExecuteFu function parseLayouts(layouts: LayoutObject[]): INodePropertyOptions[] { const returnData: INodePropertyOptions[] = []; for (const layout of layouts) { - if (layout.isFolder!) { + if (layout.isFolder!) { returnData.push(...parseLayouts(layout.folderLayoutNames!)); } else { returnData.push({ @@ -84,7 +81,10 @@ function parseLayouts(layouts: LayoutObject[]): INodePropertyOptions[] { * * @returns {Promise} */ -export async function getFields(this: ILoadOptionsFunctions): Promise { // tslint:disable-line:no-any +export async function getFields( + this: ILoadOptionsFunctions, + // tslint:disable-next-line:no-any +): Promise { const token = await getToken.call(this); const credentials = await this.getCredentials('fileMaker'); const layout = this.getCurrentNodeParameter('layout') as string; @@ -95,7 +95,7 @@ export async function getFields(this: ILoadOptionsFunctions): Promise { // const url = `https://${host}/fmi/data/v1/databases/${db}/layouts/${layout}`; const options: OptionsWithUri = { headers: { - 'Authorization': `Bearer ${token}`, + Authorization: `Bearer ${token}`, }, method: 'GET', uri: url, @@ -111,13 +111,15 @@ export async function getFields(this: ILoadOptionsFunctions): Promise { // } } - /** * Make an API request to ActiveCampaign * * @returns {Promise} */ -export async function getPortals(this: ILoadOptionsFunctions): Promise { // tslint:disable-line:no-any +export async function getPortals( + this: ILoadOptionsFunctions, + // tslint:disable-next-line:no-any +): Promise { const token = await getToken.call(this); const credentials = await this.getCredentials('fileMaker'); const layout = this.getCurrentNodeParameter('layout') as string; @@ -128,7 +130,7 @@ export async function getPortals(this: ILoadOptionsFunctions): Promise { // const url = `https://${host}/fmi/data/v1/databases/${db}/layouts/${layout}`; const options: OptionsWithUri = { headers: { - 'Authorization': `Bearer ${token}`, + Authorization: `Bearer ${token}`, }, method: 'GET', uri: url, @@ -138,7 +140,6 @@ export async function getPortals(this: ILoadOptionsFunctions): Promise { // try { const responseData = await this.helpers.request!(options); return responseData.response.portalMetaData; - } catch (error) { // If that data does not exist for some reason return the actual error throw error; @@ -150,7 +151,10 @@ export async function getPortals(this: ILoadOptionsFunctions): Promise { // * * @returns {Promise} */ -export async function getScripts(this: ILoadOptionsFunctions): Promise { // tslint:disable-line:no-any +export async function getScripts( + this: ILoadOptionsFunctions, + // tslint:disable-next-line:no-any +): Promise { const token = await getToken.call(this); const credentials = await this.getCredentials('fileMaker'); @@ -160,7 +164,7 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise { // const url = `https://${host}/fmi/data/v1/databases/${db}/scripts`; const options: OptionsWithUri = { headers: { - 'Authorization': `Bearer ${token}`, + Authorization: `Bearer ${token}`, }, method: 'GET', uri: url, @@ -170,9 +174,8 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise { // try { const responseData = await this.helpers.request!(options); const items = parseScriptsList(responseData.response.scripts); - items.sort((a, b) => a.name > b.name ? 0 : 1); + items.sort((a, b) => (a.name > b.name ? 0 : 1)); return items; - } catch (error) { // If that data does not exist for some reason return the actual error throw error; @@ -182,7 +185,7 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise { // function parseScriptsList(scripts: ScriptObject[]): INodePropertyOptions[] { const returnData: INodePropertyOptions[] = []; for (const script of scripts) { - if (script.isFolder!) { + if (script.isFolder!) { returnData.push(...parseScriptsList(script.folderScriptNames!)); } else if (script.name !== '-') { returnData.push({ @@ -194,7 +197,10 @@ function parseScriptsList(scripts: ScriptObject[]): INodePropertyOptions[] { return returnData; } -export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions): Promise { // tslint:disable-line:no-any +export async function getToken( + this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('fileMaker'); const host = credentials.host as string; @@ -218,11 +224,11 @@ export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions | pass: password as string, }; requestOptions.body = { - 'fmDataSource': [ + fmDataSource: [ { - 'database': host, - 'username': login as string, - 'password': password as string, + database: host, + username: login as string, + password: password as string, }, ], }; @@ -231,7 +237,10 @@ export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions | const response = await this.helpers.request!(requestOptions); if (typeof response === 'string') { - throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"'); + throw new NodeOperationError( + this.getNode(), + 'Response body is not valid JSON. Change "Response Format" to "String"', + ); } return response.response.token; @@ -240,7 +249,11 @@ export async function getToken(this: ILoadOptionsFunctions | IExecuteFunctions | } } -export async function logout(this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions, token: string): Promise { // tslint:disable-line:no-any +export async function logout( + this: ILoadOptionsFunctions | IExecuteFunctions | IExecuteSingleFunctions, + token: string, + // tslint:disable-next-line:no-any +): Promise { const credentials = await this.getCredentials('fileMaker'); const host = credentials.host as string; @@ -262,12 +275,16 @@ export async function logout(this: ILoadOptionsFunctions | IExecuteFunctions | I const response = await this.helpers.request!(requestOptions); if (typeof response === 'string') { - throw new NodeOperationError(this.getNode(), 'Response body is not valid JSON. Change "Response Format" to "String"'); + throw new NodeOperationError( + this.getNode(), + 'Response body is not valid JSON. Change "Response Format" to "String"', + ); } return response; } catch (error) { - const errorMessage = error.response.body.messages[0].message + '(' + error.response.body.messages[0].message + ')'; + const errorMessage = + error.response.body.messages[0].message + '(' + error.response.body.messages[0].message + ')'; if (errorMessage !== undefined) { throw errorMessage; @@ -289,8 +306,8 @@ export function parseSort(this: IExecuteFunctions, i: number): object | null { for (const parameterData of sortParametersUi!.rules as IDataObject[]) { // @ts-ignore sort.push({ - 'fieldName': parameterData!.name as string, - 'sortOrder': parameterData!.value, + fieldName: parameterData!.name as string, + sortOrder: parameterData!.value, }); } } @@ -298,7 +315,6 @@ export function parseSort(this: IExecuteFunctions, i: number): object | null { return sort; } - export function parseScripts(this: IExecuteFunctions, i: number): object | null { const setScriptAfter = this.getNodeParameter('setScriptAfter', i, false); const setScriptBefore = this.getNodeParameter('setScriptBefore', i, false); @@ -336,7 +352,6 @@ export function parsePortals(this: IExecuteFunctions, i: number): object | null return portals; } - export function parseQuery(this: IExecuteFunctions, i: number): object | null { let queries; const queriesParamUi = this.getNodeParameter('queries', i, {}) as IDataObject; @@ -345,7 +360,7 @@ export function parseQuery(this: IExecuteFunctions, i: number): object | null { queries = []; for (const queryParam of queriesParamUi!.query as IDataObject[]) { const query = { - 'omit': queryParam.omit ? 'true' : 'false', + omit: queryParam.omit ? 'true' : 'false', }; // @ts-ignore for (const field of queryParam!.fields!.field as IDataObject[]) { diff --git a/packages/nodes-base/nodes/Flow/Flow.node.ts b/packages/nodes-base/nodes/Flow/Flow.node.ts index 9c3e7948f0622..208f315d0b0c0 100644 --- a/packages/nodes-base/nodes/Flow/Flow.node.ts +++ b/packages/nodes-base/nodes/Flow/Flow.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, INodeExecutionData, @@ -9,17 +7,9 @@ import { NodeApiError, NodeOperationError, } from 'n8n-workflow'; -import { - flowApiRequest, - FlowApiRequestAllItems, -} from './GenericFunctions'; -import { - taskFields, - taskOpeations, -} from './TaskDescription'; -import { - ITask, TaskInfo, - } from './TaskInterface'; +import { flowApiRequest, FlowApiRequestAllItems } from './GenericFunctions'; +import { taskFields, taskOpeations } from './TaskDescription'; +import { ITask, TaskInfo } from './TaskInterface'; export class Flow implements INodeType { description: INodeTypeDescription = { @@ -52,7 +42,8 @@ export class Flow implements INodeType { { name: 'Task', value: 'task', - description: 'Tasks are units of work that can be private or assigned to a list. Through this endpoint, you can manipulate your tasks in Flow, including creating new ones.', + description: + 'Tasks are units of work that can be private or assigned to a list. Through this endpoint, you can manipulate your tasks in Flow, including creating new ones.', }, ], default: 'task', @@ -214,7 +205,7 @@ export class Flow implements INodeType { qs.include = (filters.include as string[]).join(','); } try { - responseData = await flowApiRequest.call(this,'GET', `/tasks/${taskId}`, {}, qs); + responseData = await flowApiRequest.call(this, 'GET', `/tasks/${taskId}`, {}, qs); } catch (error) { throw new NodeApiError(this.getNode(), error); } @@ -253,7 +244,14 @@ export class Flow implements INodeType { } try { if (returnAll === true) { - responseData = await FlowApiRequestAllItems.call(this, 'tasks', 'GET', '/tasks', {}, qs); + responseData = await FlowApiRequestAllItems.call( + this, + 'tasks', + 'GET', + '/tasks', + {}, + qs, + ); } else { qs.limit = this.getNodeParameter('limit', i) as number; responseData = await flowApiRequest.call(this, 'GET', '/tasks', {}, qs); diff --git a/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts b/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts index 3409dba7578e2..a133918b60c99 100644 --- a/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts +++ b/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { IDataObject, @@ -11,9 +8,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - flowApiRequest, -} from './GenericFunctions'; +import { flowApiRequest } from './GenericFunctions'; export class FlowTrigger implements INodeType { description: INodeTypeDescription = { @@ -50,17 +45,16 @@ export class FlowTrigger implements INodeType { type: 'options', noDataExpression: true, default: '', - options: - [ - { - name: 'Project', - value: 'list', - }, - { - name: 'Task', - value: 'task', - }, - ], + options: [ + { + name: 'Project', + value: 'list', + }, + { + name: 'Task', + value: 'task', + }, + ], description: 'Resource that triggers the webhook', }, { @@ -71,14 +65,10 @@ export class FlowTrigger implements INodeType { default: '', displayOptions: { show: { - resource:[ - 'list', - ], + resource: ['list'], }, hide: { - resource: [ - 'task', - ], + resource: ['task'], }, }, description: 'Lists IDs, perhaps known better as "Projects" separated by a comma (,)', @@ -91,20 +81,15 @@ export class FlowTrigger implements INodeType { default: '', displayOptions: { show: { - resource:[ - 'task', - ], + resource: ['task'], }, hide: { - resource: [ - 'list', - ], + resource: ['list'], }, }, description: 'Task IDs separated by a comma (,)', }, ], - }; // @ts-ignore webhookMethods = { @@ -154,7 +139,7 @@ export class FlowTrigger implements INodeType { resourceIds = (this.getNodeParameter('taskIds') as string).split(','); } // @ts-ignore - for (const resourceId of resourceIds ) { + for (const resourceId of resourceIds) { body = { organization_id: credentials.organizationId as number, integration_webhook: { @@ -165,12 +150,14 @@ export class FlowTrigger implements INodeType { }, }; try { - responseData = await flowApiRequest.call(this, 'POST', endpoint, body); - } catch(error) { + responseData = await flowApiRequest.call(this, 'POST', endpoint, body); + } catch (error) { return false; } - if (responseData.integration_webhook === undefined - || responseData.integration_webhook.id === undefined) { + if ( + responseData.integration_webhook === undefined || + responseData.integration_webhook.id === undefined + ) { // Required data is missing so was not successful return false; } @@ -188,7 +175,7 @@ export class FlowTrigger implements INodeType { // @ts-ignore if (webhookData.webhookIds.length > 0) { // @ts-ignore - for (const webhookId of webhookData.webhookIds ) { + for (const webhookId of webhookData.webhookIds) { const endpoint = `/integration_webhooks/${webhookId}`; try { await flowApiRequest.call(this, 'DELETE', endpoint, {}, qs); @@ -206,9 +193,7 @@ export class FlowTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [ - this.helpers.returnJsonArray(req.body), - ], + workflowData: [this.helpers.returnJsonArray(req.body)], }; } } diff --git a/packages/nodes-base/nodes/Flow/GenericFunctions.ts b/packages/nodes-base/nodes/Flow/GenericFunctions.ts index b4104dfb796dd..5b0f04422b7c5 100644 --- a/packages/nodes-base/nodes/Flow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Flow/GenericFunctions.ts @@ -5,17 +5,27 @@ import { IHookFunctions, ILoadOptionsFunctions, } from 'n8n-core'; -import { IDataObject, NodeApiError, NodeOperationError, } from 'n8n-workflow'; +import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow'; -export async function flowApiRequest(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 flowApiRequest( + 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('flowApi'); let options: OptionsWithUri = { - headers: { 'Authorization': `Bearer ${credentials.accessToken}`}, + headers: { Authorization: `Bearer ${credentials.accessToken}` }, method, qs, body, - uri: uri ||`https://api.getflow.com/v2${resource}`, + uri: uri || `https://api.getflow.com/v2${resource}`, json: true, }; options = Object.assign({}, options, option); @@ -34,8 +44,16 @@ export async function flowApiRequest(this: IHookFunctions | IExecuteFunctions | * Make an API request to paginated flow endpoint * and return all results */ -export async function FlowApiRequestAllItems(this: IHookFunctions | IExecuteFunctions, propertyName: string, method: string, resource: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function FlowApiRequestAllItems( + this: IHookFunctions | 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; @@ -45,14 +63,13 @@ export async function FlowApiRequestAllItems(this: IHookFunctions | IExecuteFunc let uri: string | undefined; do { - responseData = await flowApiRequest.call(this, method, resource, body, query, uri, { resolveWithFullResponse: true }); + responseData = await flowApiRequest.call(this, method, resource, body, query, uri, { + resolveWithFullResponse: true, + }); uri = responseData.headers.link; // @ts-ignore returnData.push.apply(returnData, responseData.body[propertyName]); - } while ( - responseData.headers.link !== undefined && - responseData.headers.link !== '' - ); + } while (responseData.headers.link !== undefined && responseData.headers.link !== ''); return returnData; } diff --git a/packages/nodes-base/nodes/Flow/TaskDescription.ts b/packages/nodes-base/nodes/Flow/TaskDescription.ts index f921646922d38..4aed9851a5f8f 100644 --- a/packages/nodes-base/nodes/Flow/TaskDescription.ts +++ b/packages/nodes-base/nodes/Flow/TaskDescription.ts @@ -8,9 +8,7 @@ export const taskOpeations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'task', - ], + resource: ['task'], }, }, options: [ @@ -44,10 +42,9 @@ export const taskOpeations: INodeProperties[] = [ ]; export const taskFields: INodeProperties[] = [ - -/* -------------------------------------------------------------------------- */ -/* task:create */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* task:create */ + /* -------------------------------------------------------------------------- */ { displayName: 'Workspace ID', name: 'workspaceId', @@ -56,12 +53,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, description: 'Create resources under the given workspace', @@ -74,12 +67,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, description: 'The title of the task', @@ -92,12 +81,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, options: [ @@ -113,7 +98,8 @@ export const taskFields: INodeProperties[] = [ name: 'listID', type: 'string', default: '', - description: 'Put the new task in a list ("project"). Omit this param to have the task be private.', + description: + 'Put the new task in a list ("project"). Omit this param to have the task be private.', }, { displayName: 'Starts On', @@ -134,14 +120,16 @@ export const taskFields: INodeProperties[] = [ name: 'mirrorParentSubscribers', type: 'boolean', default: false, - description: 'Whether this task will be a subtask, and this is true, the parent tasks\'s subscribers will be mirrored to this one', + description: + "Whether this task will be a subtask, and this is true, the parent tasks's subscribers will be mirrored to this one", }, { displayName: 'Mirror Parent Tags', name: 'mirrorParentTags', type: 'boolean', default: false, - description: 'Whether this task will be a subtask, and this is true, the parent tasks\'s tags will be mirrored to this one', + description: + "Whether this task will be a subtask, and this is true, the parent tasks's tags will be mirrored to this one", }, { displayName: 'Note Content', @@ -151,7 +139,7 @@ export const taskFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'Provide the content for the task\'s note', + description: "Provide the content for the task's note", }, { displayName: 'Note Mime Type', @@ -221,9 +209,9 @@ export const taskFields: INodeProperties[] = [ ], }, -/* -------------------------------------------------------------------------- */ -/* task:update */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* task:update */ + /* -------------------------------------------------------------------------- */ { displayName: 'Workspace ID', name: 'workspaceId', @@ -232,12 +220,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, description: 'Create resources under the given workspace', @@ -250,12 +234,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, }, @@ -267,12 +247,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, options: [ @@ -302,7 +278,8 @@ export const taskFields: INodeProperties[] = [ name: 'listID', type: 'string', default: '', - description: 'Put the new task in a list ("project"). Omit this param to have the task be private.', + description: + 'Put the new task in a list ("project"). Omit this param to have the task be private.', }, { displayName: 'Starts On', @@ -323,14 +300,16 @@ export const taskFields: INodeProperties[] = [ name: 'mirrorParentSubscribers', type: 'boolean', default: false, - description: 'Whether this task will be a subtask, and this is true, the parent tasks\'s subscribers will be mirrored to this one', + description: + "Whether this task will be a subtask, and this is true, the parent tasks's subscribers will be mirrored to this one", }, { displayName: 'Mirror Parent Tags', name: 'mirrorParentTags', type: 'boolean', default: false, - description: 'Whether this task will be a subtask, and this is true, the parent tasks\'s tags will be mirrored to this one', + description: + "Whether this task will be a subtask, and this is true, the parent tasks's tags will be mirrored to this one", }, { displayName: 'Note Content', @@ -340,7 +319,7 @@ export const taskFields: INodeProperties[] = [ alwaysOpenEditWindow: true, }, default: '', - description: 'Provide the content for the task\'s note', + description: "Provide the content for the task's note", }, { displayName: 'Note Mime Type', @@ -407,9 +386,9 @@ export const taskFields: INodeProperties[] = [ }, ], }, -/* -------------------------------------------------------------------------- */ -/* task:get */ -/* -------------------------------------------------------------------------- */ + /* -------------------------------------------------------------------------- */ + /* task:get */ + /* -------------------------------------------------------------------------- */ { displayName: 'Task ID', name: 'taskId', @@ -418,12 +397,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'get', - ], + resource: ['task'], + operation: ['get'], }, }, }, @@ -435,12 +410,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'get', - ], + resource: ['task'], + operation: ['get'], }, }, options: [ @@ -470,21 +441,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, @@ -496,15 +463,9 @@ export const taskFields: INodeProperties[] = [ type: 'number', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['task'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -522,12 +483,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Flow/TaskInterface.ts b/packages/nodes-base/nodes/Flow/TaskInterface.ts index 7cfe1c5d9790d..b08576efa0b4a 100644 --- a/packages/nodes-base/nodes/Flow/TaskInterface.ts +++ b/packages/nodes-base/nodes/Flow/TaskInterface.ts @@ -1,4 +1,3 @@ - export interface ITask { organization_id?: number; task?: TaskInfo; diff --git a/packages/nodes-base/nodes/FormIo/FormIoTrigger.node.ts b/packages/nodes-base/nodes/FormIo/FormIoTrigger.node.ts index 53bfc13b0ed12..601be9151d50f 100644 --- a/packages/nodes-base/nodes/FormIo/FormIoTrigger.node.ts +++ b/packages/nodes-base/nodes/FormIo/FormIoTrigger.node.ts @@ -1,7 +1,4 @@ -import { - IHookFunctions, - IWebhookFunctions, -} from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import { ILoadOptionsFunctions, @@ -11,9 +8,7 @@ import { IWebhookResponseData, } from 'n8n-workflow'; -import { - formIoApiRequest, -} from './GenericFunctions'; +import { formIoApiRequest } from './GenericFunctions'; export class FormIoTrigger implements INodeType { description: INodeTypeDescription = { @@ -53,21 +48,21 @@ export class FormIoTrigger implements INodeType { }, required: true, 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: 'Form Name or ID', name: 'formId', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'projectId', - ], + loadOptionsDependsOn: ['projectId'], loadOptionsMethod: 'getForms', }, required: true, 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: 'Trigger Events', @@ -91,7 +86,8 @@ export class FormIoTrigger 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', }, ], }; @@ -133,12 +129,19 @@ export class FormIoTrigger implements INodeType { const formId = this.getNodeParameter('formId') as string; const projectId = this.getNodeParameter('projectId') as string; const method = this.getNodeParameter('events') as string[]; - const actions = await formIoApiRequest.call(this, 'GET', `/project/${projectId}/form/${formId}/action`); + const actions = await formIoApiRequest.call( + this, + 'GET', + `/project/${projectId}/form/${formId}/action`, + ); for (const action of actions) { if (action.name === 'webhook') { - if (action.settings.url === webhookUrl && - // tslint:disable-next-line: no-any - (action.method.length === method.length && action.method.every((value: any) => method.includes(value)))) { + if ( + action.settings.url === webhookUrl && + action.method.length === method.length && + // tslint:disable-next-line:no-any + action.method.every((value: any) => method.includes(value)) + ) { webhookData.webhookId = action._id; return true; } @@ -158,9 +161,7 @@ export class FormIoTrigger implements INodeType { name: `webhook`, title: `webhook-n8n:${webhookUrl}`, method, - handler: [ - 'after', - ], + handler: ['after'], priority: 0, settings: { method: 'post', @@ -172,7 +173,12 @@ export class FormIoTrigger implements INodeType { }, }, }; - const webhook = await formIoApiRequest.call(this, 'POST', `/project/${projectId}/form/${formId}/action`, payload); + const webhook = await formIoApiRequest.call( + this, + 'POST', + `/project/${projectId}/form/${formId}/action`, + payload, + ); webhookData.webhookId = webhook._id; return true; }, @@ -181,7 +187,11 @@ export class FormIoTrigger implements INodeType { const webhookData = this.getWorkflowStaticData('node'); const formId = this.getNodeParameter('formId') as string; const projectId = this.getNodeParameter('projectId') as string; - await formIoApiRequest.call(this, 'DELETE', `/project/${projectId}/form/${formId}/action/${webhookData.webhookId}`); + await formIoApiRequest.call( + this, + 'DELETE', + `/project/${projectId}/form/${formId}/action/${webhookData.webhookId}`, + ); delete webhookData.webhookId; return true; }, @@ -196,9 +206,7 @@ export class FormIoTrigger implements INodeType { response = response.data; } return { - workflowData: [ - this.helpers.returnJsonArray(response), - ], + workflowData: [this.helpers.returnJsonArray(response)], }; } } diff --git a/packages/nodes-base/nodes/FormIo/GenericFunctions.ts b/packages/nodes-base/nodes/FormIo/GenericFunctions.ts index f9b8974bd9aef..00e4d69b92042 100644 --- a/packages/nodes-base/nodes/FormIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FormIo/GenericFunctions.ts @@ -1,14 +1,6 @@ -import { - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; - -import { - IHookFunctions, - IWebhookFunctions, - NodeApiError, -} from 'n8n-workflow'; +import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; +import { IHookFunctions, IWebhookFunctions, NodeApiError } from 'n8n-workflow'; interface IFormIoCredentials { environment: 'cloudHosted' | ' selfHosted'; @@ -21,7 +13,10 @@ interface IFormIoCredentials { * Method has the logic to get jwt token from Form.io * @param this */ -async function getToken(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, credentials: IFormIoCredentials) { +async function getToken( + this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, + credentials: IFormIoCredentials, +) { const base = credentials.domain || 'https://formio.form.io'; const options = { headers: { @@ -43,7 +38,9 @@ async function getToken(this: IExecuteFunctions | IWebhookFunctions | IHookFunct const responseObject = await this.helpers.request!(options); return responseObject.headers['x-jwt-token']; } catch (error) { - throw new Error(`Authentication Failed for Form.io. Please provide valid credentails/ endpoint details`); + throw new Error( + `Authentication Failed for Form.io. Please provide valid credentails/ endpoint details`, + ); } } @@ -52,9 +49,15 @@ async function getToken(this: IExecuteFunctions | IWebhookFunctions | IHookFunct * @param this * @param method */ -export async function formIoApiRequest(this: IHookFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, endpoint: string, body = {}, qs = {}): Promise { // tslint:disable-line:no-any - - const credentials = await this.getCredentials('formIoApi') as unknown as IFormIoCredentials; +export async function formIoApiRequest( + this: IHookFunctions | ILoadOptionsFunctions | IWebhookFunctions, + method: string, + endpoint: string, + body = {}, + qs = {}, + // tslint:disable-next-line:no-any +): Promise { + const credentials = (await this.getCredentials('formIoApi')) as unknown as IFormIoCredentials; const token = await getToken.call(this, credentials); diff --git a/packages/nodes-base/nodes/Formstack/FormstackTrigger.node.ts b/packages/nodes-base/nodes/Formstack/FormstackTrigger.node.ts index e2f88022543c2..a6bd837c735ea 100644 --- a/packages/nodes-base/nodes/Formstack/FormstackTrigger.node.ts +++ b/packages/nodes-base/nodes/Formstack/FormstackTrigger.node.ts @@ -1,21 +1,13 @@ -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, getFields, getForms, getSubmission, - IFormstackWebhookResponseBody + IFormstackWebhookResponseBody, } from './GenericFunctions'; export class FormstackTrigger implements INodeType { @@ -38,9 +30,7 @@ export class FormstackTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'accessToken', - ], + authentication: ['accessToken'], }, }, }, @@ -49,9 +39,7 @@ export class FormstackTrigger implements INodeType { required: true, displayOptions: { show: { - authentication: [ - 'oAuth2', - ], + authentication: ['oAuth2'], }, }, }, @@ -90,14 +78,16 @@ export class FormstackTrigger implements INodeType { }, default: '', required: true, - description: 'The Formstack form to monitor for new submissions. Choose from the list, or specify an ID using an expression.', + description: + 'The Formstack form to monitor for new submissions. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Simplify', 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', }, ], }; @@ -175,7 +165,7 @@ export class FormstackTrigger implements INodeType { // @ts-ignore async webhook(this: IWebhookFunctions): Promise { - const bodyData = (this.getBodyData() as unknown) as IFormstackWebhookResponseBody; + const bodyData = this.getBodyData() as unknown as IFormstackWebhookResponseBody; const simple = this.getNodeParameter('simple') as string; const response = bodyData as unknown as IDataObject; @@ -189,9 +179,7 @@ export class FormstackTrigger implements INodeType { } return { - workflowData: [ - this.helpers.returnJsonArray([response as unknown as IDataObject]), - ], + workflowData: [this.helpers.returnJsonArray([response as unknown as IDataObject])], }; } } diff --git a/packages/nodes-base/nodes/Formstack/GenericFunctions.ts b/packages/nodes-base/nodes/Formstack/GenericFunctions.ts index 5f0f880fe622d..07a4eb0f64824 100644 --- a/packages/nodes-base/nodes/Formstack/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Formstack/GenericFunctions.ts @@ -5,15 +5,9 @@ import { IWebhookFunctions, } from 'n8n-core'; -import { - IDataObject, - INodePropertyOptions, - NodeApiError, -} from 'n8n-workflow'; +import { IDataObject, INodePropertyOptions, NodeApiError } from 'n8n-workflow'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; export interface IFormstackFieldDefinitionType { id: string; @@ -58,7 +52,14 @@ export enum FormstackFieldFormat { * @param {object} body * @returns {Promise} */ -export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, endpoint: string, body: IDataObject = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any +export async function apiRequest( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + method: string, + endpoint: string, + body: IDataObject = {}, + query: IDataObject = {}, + // tslint:disable-next-line:no-any +): Promise { const authenticationMethod = this.getNodeParameter('authentication', 0); const options: OptionsWithUri = { @@ -76,7 +77,7 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa try { if (authenticationMethod === 'accessToken') { - const credentials = await this.getCredentials('formstackApi') as IDataObject; + const credentials = (await this.getCredentials('formstackApi')) as IDataObject; options.headers!['Authorization'] = `Bearer ${credentials.accessToken}`; return await this.helpers.request!(options); @@ -88,7 +89,6 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa } } - /** * Make an API request to paginated Formstack endpoint * and return all results @@ -101,8 +101,15 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa * @param {IDataObject} [query] * @returns {Promise} */ -export async function apiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, method: string, endpoint: string, body: IDataObject, dataKey: string, query?: IDataObject): Promise { // tslint:disable-line:no-any - +export async function apiRequestAllItems( + this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, + method: string, + endpoint: string, + body: IDataObject, + dataKey: string, + query?: IDataObject, + // tslint:disable-next-line:no-any +): Promise { if (query === undefined) { query = {}; } @@ -129,7 +136,6 @@ export async function apiRequestAllItems(this: IHookFunctions | IExecuteFunction return returnData; } - /** * Returns all the available forms * @@ -139,7 +145,9 @@ export async function apiRequestAllItems(this: IHookFunctions | IExecuteFunction */ export async function getForms(this: ILoadOptionsFunctions): Promise { const endpoint = 'form.json'; - const responseData = await apiRequestAllItems.call(this, 'GET', endpoint, {}, 'forms', { folders: false }); + const responseData = await apiRequestAllItems.call(this, 'GET', endpoint, {}, 'forms', { + folders: false, + }); if (responseData.items === undefined) { throw new Error('No data got returned'); @@ -154,7 +162,6 @@ export async function getForms(this: ILoadOptionsFunctions): Promise} */ -export async function getFields(this: IWebhookFunctions, formID: string): Promise> { +export async function getFields( + this: IWebhookFunctions, + formID: string, +): Promise> { const endpoint = `form/${formID}.json`; const responseData = await apiRequestAllItems.call(this, 'GET', endpoint, {}, 'fields'); @@ -174,14 +184,13 @@ export async function getFields(this: IWebhookFunctions, formID: string): Promis const fields = responseData.items as IFormstackFieldDefinitionType[]; const fieldMap: Record = {}; - fields.forEach(field => { + fields.forEach((field) => { fieldMap[field.id] = field; }); return fieldMap; } - /** * Returns all the fields of a form * @@ -190,7 +199,10 @@ export async function getFields(this: IWebhookFunctions, formID: string): Promis * @param {string} uniqueId * @returns {Promise} */ -export async function getSubmission(this: ILoadOptionsFunctions | IWebhookFunctions, uniqueId: string): Promise { +export async function getSubmission( + this: ILoadOptionsFunctions | IWebhookFunctions, + uniqueId: string, +): Promise { const endpoint = `submission/${uniqueId}.json`; const responseData = await apiRequestAllItems.call(this, 'GET', endpoint, {}, 'data'); diff --git a/packages/nodes-base/nodes/Freshdesk/ContactDescription.ts b/packages/nodes-base/nodes/Freshdesk/ContactDescription.ts index 89f63134e1e8a..8192ebbe07e3a 100644 --- a/packages/nodes-base/nodes/Freshdesk/ContactDescription.ts +++ b/packages/nodes-base/nodes/Freshdesk/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[] = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], + resource: ['contact'], }, }, options: [ @@ -53,7 +49,6 @@ export const contactOperations: INodeProperties[] = [ ]; export const contactFields: INodeProperties[] = [ - /* -------------------------------------------------------------------------- */ /* contact:create/update */ /* -------------------------------------------------------------------------- */ @@ -64,12 +59,8 @@ export const contactFields: INodeProperties[] = [ placeholder: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], + operation: ['create'], + resource: ['contact'], }, }, default: '', @@ -84,15 +75,12 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - operation: [ - 'create', - ], - resource: [ - 'contact', - ], + operation: ['create'], + resource: ['contact'], }, }, - description: 'Primary email address of the contact. If you want to associate additional email(s) with this contact, use the other_emails attribute.', + description: + 'Primary email address of the contact. If you want to associate additional email(s) with this contact, use the other_emails attribute.', }, { displayName: 'Contact ID', @@ -101,12 +89,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, required: true, @@ -118,13 +102,8 @@ export const contactFields: INodeProperties[] = [ placeholder: 'Add Field', displayOptions: { show: { - operation: [ - 'create', - 'update', - ], - resource: [ - 'contact', - ], + operation: ['create', 'update'], + resource: ['contact'], }, }, default: {}, @@ -159,7 +138,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { multipleValues: true, }, - description: 'Key value pairs containing the name and value of the custom field. Only dates in the format YYYY-MM-DD are accepted as input for custom date fields.', + description: + 'Key value pairs containing the name and value of the custom field. Only dates in the format YYYY-MM-DD are accepted as input for custom date fields.', default: [], options: [ { @@ -171,14 +151,14 @@ export const contactFields: INodeProperties[] = [ name: 'name', type: 'string', default: '', - description: 'Custom Field\'s name', + description: "Custom Field's name", }, { displayName: 'Value', name: 'value', type: 'string', default: '', - description: 'Custom Field\'s values', + description: "Custom Field's values", }, ], }, @@ -199,12 +179,11 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - '/operation': [ - 'update', - ], + '/operation': ['update'], }, }, - description: 'Primary email address of the contact. If you want to associate additional email(s) with this contact, use the other_emails attribute.', + description: + 'Primary email address of the contact. If you want to associate additional email(s) with this contact, use the other_emails attribute.', }, { displayName: 'Job Title', @@ -218,7 +197,8 @@ export const contactFields: INodeProperties[] = [ name: 'language', type: 'string', default: '', - description: 'Language of the contact. Default language is "en". This attribute can only be set if the Multiple Language feature is enabled (Garden plan and above).', + description: + 'Language of the contact. Default language is "en". This attribute can only be set if the Multiple Language feature is enabled (Garden plan and above).', }, { displayName: 'Mobile', @@ -234,9 +214,7 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - '/operation': [ - 'update', - ], + '/operation': ['update'], }, }, description: 'Name of the contact', @@ -250,7 +228,8 @@ export const contactFields: INodeProperties[] = [ multipleValues: true, }, placeholder: 'Add Company', - description: 'Additional companies associated with the contact. This attribute can only be set if the Multiple Companies feature is enabled (Estate plan and above).', + description: + 'Additional companies associated with the contact. This attribute can only be set if the Multiple Companies feature is enabled (Estate plan and above).', }, { displayName: 'Other Emails', @@ -285,7 +264,8 @@ export const contactFields: INodeProperties[] = [ name: 'time_zone', type: 'string', default: '', - description: 'Time zone of the contact. Default value is the time zone of the domain. This attribute can only be set if the Multiple Time Zone feature is enabled (Garden plan and above).', + description: + 'Time zone of the contact. Default value is the time zone of the domain. This attribute can only be set if the Multiple Time Zone feature is enabled (Garden plan and above).', }, { displayName: 'Twitter ID', @@ -306,7 +286,8 @@ export const contactFields: INodeProperties[] = [ name: 'view_all_tickets', type: 'boolean', default: false, - description: 'Whether the contact can see all the tickets that are associated with the company to which they belong', + description: + 'Whether the contact can see all the tickets that are associated with the company to which they belong', }, ], }, @@ -320,12 +301,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'delete', - ], + resource: ['contact'], + operation: ['delete'], }, }, required: true, @@ -340,12 +317,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], + resource: ['contact'], + operation: ['get'], }, }, required: true, @@ -361,12 +334,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - operation: [ - 'getAll', - ], - resource: [ - 'contact', - ], + operation: ['getAll'], + resource: ['contact'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Freshdesk/ContactInterface.ts b/packages/nodes-base/nodes/Freshdesk/ContactInterface.ts index 431f1589fe093..c0e6437ef7340 100644 --- a/packages/nodes-base/nodes/Freshdesk/ContactInterface.ts +++ b/packages/nodes-base/nodes/Freshdesk/ContactInterface.ts @@ -1,6 +1,4 @@ -import { - IDataObject, -} from 'n8n-workflow'; +import { IDataObject } from 'n8n-workflow'; export interface ICreateContactBody { address?: string; diff --git a/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts b/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts index 4554a35461a2a..ad4e8185997df 100644 --- a/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts +++ b/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts @@ -8,9 +8,7 @@ import { NodeOperationError, } from 'n8n-workflow'; -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { capitalize, @@ -19,14 +17,9 @@ import { // validateJSON, } from './GenericFunctions'; -import { - ICreateContactBody, -} from './ContactInterface'; +import { ICreateContactBody } from './ContactInterface'; -import { - contactFields, - contactOperations, -} from './ContactDescription'; +import { contactFields, contactOperations } from './ContactDescription'; enum Status { Open = 2, @@ -126,9 +119,7 @@ export class Freshdesk implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], + resource: ['ticket'], }, }, options: [ @@ -172,44 +163,46 @@ export class Freshdesk implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, options: [ { name: 'Email', value: 'email', - description: 'Email address of the requester. If no contact exists with this email address in Freshdesk, it will be added as a new contact.', + description: + 'Email address of the requester. If no contact exists with this email address in Freshdesk, it will be added as a new contact.', }, { name: 'Facebook ID', value: 'facebookId', - description: 'Facebook ID of the requester. If no contact exists with this facebook_id, then a new contact will be created.', + description: + 'Facebook ID of the requester. If no contact exists with this facebook_id, then a new contact will be created.', }, { name: 'Phone', value: 'phone', - description: 'Phone number of the requester. If no contact exists with this phone number in Freshdesk, it will be added as a new contact. If the phone number is set and the email address is not, then the name attribute is mandatory.', + description: + 'Phone number of the requester. If no contact exists with this phone number in Freshdesk, it will be added as a new contact. If the phone number is set and the email address is not, then the name attribute is mandatory.', }, { name: 'Requester ID', value: 'requesterId', - description: 'User ID of the requester. For existing contacts, the requester_id can be passed instead of the requester\'s email.', + description: + "User ID of the requester. For existing contacts, the requester_id can be passed instead of the requester's email.", }, { name: 'Twitter ID', value: 'twitterId', - description: 'Twitter handle of the requester. If no contact exists with this handle in Freshdesk, it will be added as a new contact.', + description: + 'Twitter handle of the requester. If no contact exists with this handle in Freshdesk, it will be added as a new contact.', }, { name: 'Unique External ID', value: 'uniqueExternalId', - description: 'External ID of the requester. If no contact exists with this external ID in Freshdesk, they will be added as a new contact.', + description: + 'External ID of the requester. If no contact exists with this external ID in Freshdesk, they will be added as a new contact.', }, ], default: 'requesterId', @@ -221,12 +214,8 @@ export class Freshdesk implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, default: '', @@ -239,12 +228,8 @@ export class Freshdesk implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, options: [ @@ -274,12 +259,8 @@ export class Freshdesk implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, options: [ @@ -309,12 +290,8 @@ export class Freshdesk implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, options: [ @@ -375,12 +352,8 @@ export class Freshdesk implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, options: [ @@ -392,14 +365,16 @@ export class Freshdesk implements INodeType { typeOptions: { loadOptionsMethod: 'getAgents', }, - description: 'ID of the agent to whom the ticket has been assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the agent to whom the ticket has been assigned. Choose from the list, or specify an ID using an expression.', }, { displayName: 'CC Emails', name: 'ccEmails', type: 'string', default: '', - description: 'Separated by a comma (,) email addresses added in the \'cc\' field of the incoming ticket email', + description: + "Separated by a comma (,) email addresses added in the 'cc' field of the incoming ticket email", }, { displayName: 'Company Name or ID', @@ -409,7 +384,8 @@ export class Freshdesk implements INodeType { typeOptions: { loadOptionsMethod: 'getCompanies', }, - description: 'Company ID of the requester. This attribute can only be set if the Multiple Companies feature is enabled (Estate plan and above). Choose from the list, or specify an ID using an expression.', + description: + 'Company ID of the requester. This attribute can only be set if the Multiple Companies feature is enabled (Estate plan and above). Choose from the list, or specify an ID using an expression.', }, { displayName: 'Description', @@ -434,7 +410,8 @@ export class Freshdesk implements INodeType { name: 'emailConfigId', type: 'number', default: '', - description: 'ID of email config which is used for this ticket. (i.e., support@yourcompany.com/sales@yourcompany.com) If product_id is given and email_config_id is not given, product\'s primary email_config_id will be set.', + description: + "ID of email config which is used for this ticket. (i.e., support@yourcompany.com/sales@yourcompany.com) If product_id is given and email_config_id is not given, product's primary email_config_id will be set.", }, { displayName: 'FR Due By', @@ -451,7 +428,8 @@ export class Freshdesk implements INodeType { typeOptions: { loadOptionsMethod: 'getGroups', }, - description: 'ID of the group to which the ticket has been assigned. The default value is the ID of the group that is associated with the given email_config_id. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the group to which the ticket has been assigned. The default value is the ID of the group that is associated with the given email_config_id. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Name', @@ -469,7 +447,8 @@ export class Freshdesk implements INodeType { typeOptions: { loadOptionsMethod: 'getProducts', }, - description: 'ID of the product to which the ticket is associated. It will be ignored if the email_config_id attribute is set in the request. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the product to which the ticket is associated. It will be ignored if the email_config_id attribute is set in the request. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Subject', @@ -491,7 +470,8 @@ export class Freshdesk implements INodeType { name: 'type', type: 'options', default: 'Question', - description: 'Helps categorize the ticket according to the different kinds of issues your support team deals with', + description: + 'Helps categorize the ticket according to the different kinds of issues your support team deals with', options: [ { name: 'Feature Request', @@ -598,12 +578,8 @@ export class Freshdesk implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'update', - ], + resource: ['ticket'], + operation: ['update'], }, }, default: '', @@ -616,12 +592,8 @@ export class Freshdesk implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'update', - ], + resource: ['ticket'], + operation: ['update'], }, }, options: [ @@ -633,14 +605,16 @@ export class Freshdesk implements INodeType { typeOptions: { loadOptionsMethod: 'getAgents', }, - description: 'ID of the agent to whom the ticket has been assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the agent to whom the ticket has been assigned. Choose from the list, or specify an ID using an expression.', }, { displayName: 'CC Emails', name: 'ccEmails', type: 'string', default: '', - description: 'Separated by a comma (,) email addresses added in the \'cc\' field of the incoming ticket email', + description: + "Separated by a comma (,) email addresses added in the 'cc' field of the incoming ticket email", }, { displayName: 'Company Name or ID', @@ -650,7 +624,8 @@ export class Freshdesk implements INodeType { typeOptions: { loadOptionsMethod: 'getCompanies', }, - description: 'Company ID of the requester. This attribute can only be set if the Multiple Companies feature is enabled (Estate plan and above). Choose from the list, or specify an ID using an expression.', + description: + 'Company ID of the requester. This attribute can only be set if the Multiple Companies feature is enabled (Estate plan and above). Choose from the list, or specify an ID using an expression.', }, { displayName: 'Due By', @@ -664,7 +639,8 @@ export class Freshdesk implements INodeType { name: 'emailConfigId', type: 'number', default: '', - description: 'ID of email config which is used for this ticket. (i.e., support@yourcompany.com/sales@yourcompany.com) If product_id is given and email_config_id is not given, product\'s primary email_config_id will be set.', + description: + "ID of email config which is used for this ticket. (i.e., support@yourcompany.com/sales@yourcompany.com) If product_id is given and email_config_id is not given, product's primary email_config_id will be set.", }, { displayName: 'FR Due By', @@ -681,7 +657,8 @@ export class Freshdesk implements INodeType { typeOptions: { loadOptionsMethod: 'getGroups', }, - description: 'ID of the group to which the ticket has been assigned. The default value is the ID of the group that is associated with the given email_config_id. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the group to which the ticket has been assigned. The default value is the ID of the group that is associated with the given email_config_id. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Name', @@ -699,7 +676,8 @@ export class Freshdesk implements INodeType { typeOptions: { loadOptionsMethod: 'getProducts', }, - description: 'ID of the product to which the ticket is associated. It will be ignored if the email_config_id attribute is set in the request. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the product to which the ticket is associated. It will be ignored if the email_config_id attribute is set in the request. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Priority', @@ -734,32 +712,38 @@ export class Freshdesk implements INodeType { { name: 'Email', value: 'email', - description: 'Email address of the requester. If no contact exists with this email address in Freshdesk, it will be added as a new contact.', + description: + 'Email address of the requester. If no contact exists with this email address in Freshdesk, it will be added as a new contact.', }, { name: 'Facebook ID', value: 'facebookId', - description: 'Facebook ID of the requester. If no contact exists with this facebook_id, then a new contact will be created.', + description: + 'Facebook ID of the requester. If no contact exists with this facebook_id, then a new contact will be created.', }, { name: 'Phone', value: 'phone', - description: 'Phone number of the requester. If no contact exists with this phone number in Freshdesk, it will be added as a new contact. If the phone number is set and the email address is not, then the name attribute is mandatory.', + description: + 'Phone number of the requester. If no contact exists with this phone number in Freshdesk, it will be added as a new contact. If the phone number is set and the email address is not, then the name attribute is mandatory.', }, { name: 'Requester ID', value: 'requesterId', - description: 'User ID of the requester. For existing contacts, the requester_id can be passed instead of the requester\'s email.', + description: + "User ID of the requester. For existing contacts, the requester_id can be passed instead of the requester's email.", }, { name: 'Twitter ID', value: 'twitterId', - description: 'Twitter handle of the requester. If no contact exists with this handle in Freshdesk, it will be added as a new contact.', + description: + 'Twitter handle of the requester. If no contact exists with this handle in Freshdesk, it will be added as a new contact.', }, { name: 'Unique External ID', value: 'uniqueExternalId', - description: 'External ID of the requester. If no contact exists with this external ID in Freshdesk, they will be added as a new contact.', + description: + 'External ID of the requester. If no contact exists with this external ID in Freshdesk, they will be added as a new contact.', }, ], default: 'requesterId', @@ -846,7 +830,8 @@ export class Freshdesk implements INodeType { name: 'type', type: 'options', default: 'Question', - description: 'Helps categorize the ticket according to the different kinds of issues your support team deals with', + description: + 'Helps categorize the ticket according to the different kinds of issues your support team deals with', options: [ { name: 'Feature Request', @@ -879,12 +864,8 @@ export class Freshdesk implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'get', - ], + resource: ['ticket'], + operation: ['get'], }, }, default: '', @@ -895,12 +876,8 @@ export class Freshdesk implements INodeType { type: 'boolean', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], + resource: ['ticket'], + operation: ['getAll'], }, }, default: false, @@ -912,15 +889,9 @@ export class Freshdesk implements INodeType { type: 'number', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['ticket'], + operation: ['getAll'], + returnAll: [false], }, }, typeOptions: { @@ -938,12 +909,8 @@ export class Freshdesk implements INodeType { default: {}, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], + resource: ['ticket'], + operation: ['getAll'], }, }, options: [ @@ -1042,12 +1009,8 @@ export class Freshdesk implements INodeType { required: true, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'delete', - ], + resource: ['ticket'], + operation: ['delete'], }, }, default: '', @@ -1161,7 +1124,9 @@ export class Freshdesk implements INodeType { if (requester === 'requesterId') { // @ts-ignore if (isNaN(value)) { - throw new NodeOperationError(this.getNode(), 'Requester Id must be a number', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Requester Id must be a number', { + itemIndex: i, + }); } body.requester_id = parseInt(value, 10); } else if (requester === 'email') { @@ -1246,7 +1211,9 @@ export class Freshdesk implements INodeType { if (updateFields.requester === 'requesterId') { // @ts-ignore if (isNaN(parseInt(value, 10))) { - throw new NodeOperationError(this.getNode(), 'Requester Id must be a number', { itemIndex: i }); + throw new NodeOperationError(this.getNode(), 'Requester Id must be a number', { + itemIndex: i, + }); } body.requester_id = parseInt(value as string, 10); } else if (updateFields.requester === 'email') { @@ -1306,7 +1273,12 @@ export class Freshdesk implements INodeType { if (updateFields.ccEmails) { body.cc_emails = (updateFields.ccEmails as string).split(',') as [string]; } - responseData = await freshdeskApiRequest.call(this, 'PUT', `/tickets/${ticketId}`, body); + responseData = await freshdeskApiRequest.call( + this, + 'PUT', + `/tickets/${ticketId}`, + body, + ); } //https://developers.freshdesk.com/api/#view_a_ticket if (operation === 'get') { @@ -1341,7 +1313,13 @@ export class Freshdesk implements INodeType { } } if (returnAll === true) { - responseData = await freshdeskApiRequestAllItems.call(this, 'GET', '/tickets', {}, qs); + responseData = await freshdeskApiRequestAllItems.call( + this, + 'GET', + '/tickets', + {}, + qs, + ); } else { qs.per_page = this.getNodeParameter('limit', i) as number; responseData = await freshdeskApiRequest.call(this, 'GET', '/tickets', {}, qs); @@ -1357,10 +1335,15 @@ export class Freshdesk implements INodeType { if (operation === 'create') { const name = this.getNodeParameter('name', i) as string; const email = this.getNodeParameter('email', i) as string; - const additionalFields = this.getNodeParameter('additionalFields', i, {}) as IDataObject; + const additionalFields = this.getNodeParameter( + 'additionalFields', + i, + {}, + ) as IDataObject; if (additionalFields.customFields) { - const metadata = (additionalFields.customFields as IDataObject).customField as IDataObject[]; + const metadata = (additionalFields.customFields as IDataObject) + .customField as IDataObject[]; additionalFields.custom_fields = {}; for (const data of metadata) { //@ts-ignore @@ -1375,24 +1358,39 @@ export class Freshdesk implements INodeType { body.email = email; } responseData = await freshdeskApiRequest.call(this, 'POST', '/contacts', body); - //https://developers.freshdesk.com/api/#delete_contact + //https://developers.freshdesk.com/api/#delete_contact } else if (operation === 'delete') { const contactId = this.getNodeParameter('contactId', i) as string; - responseData = await freshdeskApiRequest.call(this, 'DELETE', `/contacts/${contactId}`, {}); + responseData = await freshdeskApiRequest.call( + this, + 'DELETE', + `/contacts/${contactId}`, + {}, + ); } else if (operation === 'get') { const contactId = this.getNodeParameter('contactId', i) as string; - responseData = await freshdeskApiRequest.call(this, 'GET', `/contacts/${contactId}`, {}); - //https://developers.freshdesk.com/api/#list_all_contacts + responseData = await freshdeskApiRequest.call( + this, + 'GET', + `/contacts/${contactId}`, + {}, + ); + //https://developers.freshdesk.com/api/#list_all_contacts } else if (operation === 'getAll') { const qs = this.getNodeParameter('filters', i, {}) as IDataObject; responseData = await freshdeskApiRequest.call(this, 'GET', '/contacts', {}, qs); - //https://developers.freshdesk.com/api/#update_contact + //https://developers.freshdesk.com/api/#update_contact } else if (operation === 'update') { const contactId = this.getNodeParameter('contactId', i) as string; - const additionalFields = this.getNodeParameter('additionalFields', i, {}) as IDataObject; + const additionalFields = this.getNodeParameter( + 'additionalFields', + i, + {}, + ) as IDataObject; if (additionalFields.customFields) { - const metadata = (additionalFields.customFields as IDataObject).customField as IDataObject[]; + const metadata = (additionalFields.customFields as IDataObject) + .customField as IDataObject[]; additionalFields.custom_fields = {}; for (const data of metadata) { //@ts-ignore @@ -1402,7 +1400,12 @@ export class Freshdesk implements INodeType { } const body: ICreateContactBody = additionalFields; - responseData = await freshdeskApiRequest.call(this, 'PUT', `/contacts/${contactId}`, body); + responseData = await freshdeskApiRequest.call( + this, + 'PUT', + `/contacts/${contactId}`, + body, + ); } } diff --git a/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts b/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts index a4172e7ebe9cf..dc728c1888379 100644 --- a/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts @@ -1,19 +1,20 @@ -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - BINARY_ENCODING, - IExecuteFunctions, - ILoadOptionsFunctions, -} from 'n8n-core'; +import { BINARY_ENCODING, IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import { - IDataObject, NodeApiError, NodeOperationError, -} from 'n8n-workflow'; - -export async function freshdeskApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: 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 freshdeskApiRequest( + this: 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('freshdeskApi'); const apiKey = `${credentials.apiKey}:X`; @@ -45,17 +46,26 @@ export async function freshdeskApiRequest(this: IExecuteFunctions | ILoadOptions } } -export async function freshdeskApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise { // tslint:disable-line:no-any - +export async function freshdeskApiRequestAllItems( + 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; let uri: string | undefined; query.per_page = 100; do { - responseData = await freshdeskApiRequest.call(this, method, endpoint, body, query, uri, { resolveWithFullResponse: true }); + responseData = await freshdeskApiRequest.call(this, method, endpoint, body, query, uri, { + resolveWithFullResponse: true, + }); if (responseData.headers.link) { - uri = responseData.headers['link'].split(';')[0].replace('<', '').replace('>',''); + uri = responseData.headers['link'].split(';')[0].replace('<', '').replace('>', ''); } returnData.push.apply(returnData, responseData.body); } while ( @@ -65,7 +75,8 @@ export async function freshdeskApiRequestAllItems(this: IExecuteFunctions | ILoa 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/Freshservice/Freshservice.node.ts b/packages/nodes-base/nodes/Freshservice/Freshservice.node.ts index e415dd73eee3a..85338b8808a57 100644 --- a/packages/nodes-base/nodes/Freshservice/Freshservice.node.ts +++ b/packages/nodes-base/nodes/Freshservice/Freshservice.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -60,16 +58,9 @@ import { ticketOperations, } from './descriptions'; -import { - AddressFixedCollection, - LoadedResource, - LoadedUser, - RolesParameter, -} from './types'; +import { AddressFixedCollection, LoadedResource, LoadedUser, RolesParameter } from './types'; -import { - tz, -} from 'moment-timezone'; +import { tz } from 'moment-timezone'; export class Freshservice implements INodeType { description: INodeTypeDescription = { @@ -203,28 +194,32 @@ export class Freshservice implements INodeType { methods = { loadOptions: { async getAgents(this: ILoadOptionsFunctions): Promise { - const { agents } = await freshserviceApiRequest.call(this, 'GET', '/agents') as { + const { agents } = (await freshserviceApiRequest.call(this, 'GET', '/agents')) as { agents: LoadedUser[]; }; return toUserOptions(agents.filter((agent) => agent.active)); }, async getAgentGroups(this: ILoadOptionsFunctions): Promise { - const { groups } = await freshserviceApiRequest.call(this, 'GET', '/groups') as { + const { groups } = (await freshserviceApiRequest.call(this, 'GET', '/groups')) as { groups: LoadedResource[]; }; return toOptions(groups); }, async getAgentRoles(this: ILoadOptionsFunctions): Promise { - const { roles } = await freshserviceApiRequest.call(this, 'GET', '/roles') as { + const { roles } = (await freshserviceApiRequest.call(this, 'GET', '/roles')) as { roles: LoadedResource[]; }; return toOptions(roles); }, async getAssetTypes(this: ILoadOptionsFunctions): Promise { - const { asset_types } = await freshserviceApiRequest.call(this, 'GET', '/asset_types') as { + const { asset_types } = (await freshserviceApiRequest.call( + this, + 'GET', + '/asset_types', + )) as { asset_types: LoadedResource[]; }; return toOptions(asset_types); @@ -232,31 +227,41 @@ export class Freshservice implements INodeType { async getAssetTypeFields(this: ILoadOptionsFunctions): Promise { const assetType = this.getCurrentNodeParameter('assetTypeId'); - const { asset_type_fields } = await freshserviceApiRequest.call(this, 'GET', `/asset_types/${assetType}/fields`) as { + const { asset_type_fields } = (await freshserviceApiRequest.call( + this, + 'GET', + `/asset_types/${assetType}/fields`, + )) as { asset_type_fields: [{ fields: LoadedResource[] }]; }; // tslint:disable-next-line: no-any let fields: any[] = []; - fields = fields.concat(...asset_type_fields.map((data) => data.fields)).map(data => ({ name: data.label, id: data.name })); + fields = fields + .concat(...asset_type_fields.map((data) => data.fields)) + .map((data) => ({ name: data.label, id: data.name })); return toOptions(fields); }, async getDepartments(this: ILoadOptionsFunctions): Promise { - const { departments } = await freshserviceApiRequest.call(this, 'GET', '/departments') as { + const { departments } = (await freshserviceApiRequest.call( + this, + 'GET', + '/departments', + )) as { departments: LoadedResource[]; }; return toOptions(departments); }, async getLocations(this: ILoadOptionsFunctions): Promise { - const { locations } = await freshserviceApiRequest.call(this, 'GET', '/locations') as { + const { locations } = (await freshserviceApiRequest.call(this, 'GET', '/locations')) as { locations: LoadedResource[]; }; return toOptions(locations); }, async getRequesters(this: ILoadOptionsFunctions): Promise { - const { requesters } = await freshserviceApiRequest.call(this, 'GET', '/requesters') as { + const { requesters } = (await freshserviceApiRequest.call(this, 'GET', '/requesters')) as { requesters: LoadedUser[]; }; return toUserOptions(requesters); @@ -276,17 +281,13 @@ export class Freshservice implements INodeType { let responseData; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'agent') { - // ********************************************************************** // agent // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // agent: create // ---------------------------------------- @@ -310,27 +311,21 @@ export class Freshservice implements INodeType { } responseData = await freshserviceApiRequest.call(this, 'POST', '/agents', body); - } else if (operation === 'delete') { - // ---------------------------------------- // agent: delete // ---------------------------------------- const agentId = this.getNodeParameter('agentId', i); responseData = await freshserviceApiRequest.call(this, 'DELETE', `/agents/${agentId}`); - } else if (operation === 'get') { - // ---------------------------------------- // agent: get // ---------------------------------------- const agentId = this.getNodeParameter('agentId', i); responseData = await freshserviceApiRequest.call(this, 'GET', `/agents/${agentId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // agent: getAll // ---------------------------------------- @@ -343,9 +338,7 @@ export class Freshservice implements INodeType { } responseData = await handleListing.call(this, 'GET', '/agents', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // agent: update // ---------------------------------------- @@ -358,18 +351,19 @@ export class Freshservice implements INodeType { Object.assign(body, updateFields); const agentId = this.getNodeParameter('agentId', i); - responseData = await freshserviceApiRequest.call(this, 'PUT', `/agents/${agentId}`, body); - + responseData = await freshserviceApiRequest.call( + this, + 'PUT', + `/agents/${agentId}`, + body, + ); } - } else if (resource === 'agentGroup') { - // ********************************************************************** // agentGroup // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // agentGroup: create // ---------------------------------------- @@ -385,9 +379,7 @@ export class Freshservice implements INodeType { } responseData = await freshserviceApiRequest.call(this, 'POST', '/groups', body); - } else if (operation === 'delete') { - // ---------------------------------------- // agentGroup: delete // ---------------------------------------- @@ -395,9 +387,7 @@ export class Freshservice implements INodeType { const agentGroupId = this.getNodeParameter('agentGroupId', i); const endpoint = `/groups/${agentGroupId}`; responseData = await freshserviceApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // agentGroup: get // ---------------------------------------- @@ -405,17 +395,13 @@ export class Freshservice implements INodeType { const agentGroupId = this.getNodeParameter('agentGroupId', i); const endpoint = `/groups/${agentGroupId}`; responseData = await freshserviceApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // agentGroup: getAll // ---------------------------------------- responseData = await handleListing.call(this, 'GET', '/groups'); - } else if (operation === 'update') { - // ---------------------------------------- // agentGroup: update // ---------------------------------------- @@ -430,42 +416,32 @@ export class Freshservice implements INodeType { const agentGroupId = this.getNodeParameter('agentGroupId', i); const endpoint = `/groups/${agentGroupId}`; responseData = await freshserviceApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'agentRole') { - // ********************************************************************** // agentRole // ********************************************************************** if (operation === 'get') { - // ---------------------------------------- // agentRole: get // ---------------------------------------- const agentRoleId = this.getNodeParameter('agentRoleId', i); responseData = await freshserviceApiRequest.call(this, 'GET', `/roles/${agentRoleId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // agentRole: getAll // ---------------------------------------- responseData = await handleListing.call(this, 'GET', '/roles'); - } - } else if (resource === 'announcement') { - // ********************************************************************** // announcement // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // announcement: create // ---------------------------------------- @@ -495,9 +471,7 @@ export class Freshservice implements INodeType { } responseData = await freshserviceApiRequest.call(this, 'POST', '/announcements', body); - } else if (operation === 'delete') { - // ---------------------------------------- // announcement: delete // ---------------------------------------- @@ -505,9 +479,7 @@ export class Freshservice implements INodeType { const announcementId = this.getNodeParameter('announcementId', i); const endpoint = `/announcements/${announcementId}`; responseData = await freshserviceApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // announcement: get // ---------------------------------------- @@ -516,17 +488,13 @@ export class Freshservice implements INodeType { const endpoint = `/announcements/${announcementId}`; responseData = await freshserviceApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // announcement: getAll // ---------------------------------------- responseData = await handleListing.call(this, 'GET', '/announcements'); - } else if (operation === 'update') { - // ---------------------------------------- // announcement: update // ---------------------------------------- @@ -550,17 +518,13 @@ export class Freshservice implements INodeType { const announcementId = this.getNodeParameter('announcementId', i); const endpoint = `/announcements/${announcementId}`; responseData = await freshserviceApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'asset') { - // ********************************************************************** // asset // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // asset: create // ---------------------------------------- @@ -570,31 +534,42 @@ export class Freshservice implements INodeType { name: this.getNodeParameter('name', i), } as IDataObject; - const assetFields = this.getNodeParameter('assetFieldsUi.assetFieldValue', i, []) as IDataObject[]; + const assetFields = this.getNodeParameter( + 'assetFieldsUi.assetFieldValue', + i, + [], + ) as IDataObject[]; - Object.assign(body, { type_fields: assetFields.reduce((obj, value) => Object.assign(obj, { [`${value.name}`]: value.value }), {}) }); + Object.assign(body, { + type_fields: assetFields.reduce( + (obj, value) => Object.assign(obj, { [`${value.name}`]: value.value }), + {}, + ), + }); responseData = await freshserviceApiRequest.call(this, 'POST', '/assets', body); - } else if (operation === 'delete') { - // ---------------------------------------- // asset: delete // ---------------------------------------- const assetDisplayId = this.getNodeParameter('assetDisplayId', i); - responseData = await freshserviceApiRequest.call(this, 'DELETE', `/assets/${assetDisplayId}`); - + responseData = await freshserviceApiRequest.call( + this, + 'DELETE', + `/assets/${assetDisplayId}`, + ); } else if (operation === 'get') { - // ---------------------------------------- // asset: get // ---------------------------------------- const assetDisplayId = this.getNodeParameter('assetDisplayId', i); - responseData = await freshserviceApiRequest.call(this, 'GET', `/assets/${assetDisplayId}`); - + responseData = await freshserviceApiRequest.call( + this, + 'GET', + `/assets/${assetDisplayId}`, + ); } else if (operation === 'getAll') { - // ---------------------------------------- // asset: getAll // ---------------------------------------- @@ -607,9 +582,7 @@ export class Freshservice implements INodeType { } responseData = await handleListing.call(this, 'GET', '/assets', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // asset: update // ---------------------------------------- @@ -622,18 +595,19 @@ export class Freshservice implements INodeType { Object.assign(body, updateFields); const assetDisplayId = this.getNodeParameter('assetDisplayId', i); - responseData = await freshserviceApiRequest.call(this, 'PUT', `/assets/${assetDisplayId}`, body); - + responseData = await freshserviceApiRequest.call( + this, + 'PUT', + `/assets/${assetDisplayId}`, + body, + ); } - } else if (resource === 'assetType') { - // ********************************************************************** // assetType // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // assetType: create // ---------------------------------------- @@ -649,9 +623,7 @@ export class Freshservice implements INodeType { } responseData = await freshserviceApiRequest.call(this, 'POST', '/asset_types', body); - } else if (operation === 'delete') { - // ---------------------------------------- // assetType: delete // ---------------------------------------- @@ -660,9 +632,7 @@ export class Freshservice implements INodeType { const endpoint = `/asset_types/${assetTypeId}`; responseData = await freshserviceApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // assetType: get // ---------------------------------------- @@ -670,17 +640,13 @@ export class Freshservice implements INodeType { const assetTypeId = this.getNodeParameter('assetTypeId', i); const endpoint = `/asset_types/${assetTypeId}`; responseData = await freshserviceApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // assetType: getAll // ---------------------------------------- responseData = await handleListing.call(this, 'GET', '/asset_types'); - } else if (operation === 'update') { - // ---------------------------------------- // assetType: update // ---------------------------------------- @@ -695,17 +661,13 @@ export class Freshservice implements INodeType { const assetTypeId = this.getNodeParameter('assetTypeId', i); const endpoint = `/asset_types/${assetTypeId}`; responseData = await freshserviceApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'change') { - // ********************************************************************** // change // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // change: create // ---------------------------------------- @@ -729,27 +691,25 @@ export class Freshservice implements INodeType { } responseData = await freshserviceApiRequest.call(this, 'POST', '/changes', body); - } else if (operation === 'delete') { - // ---------------------------------------- // change: delete // ---------------------------------------- const changeId = this.getNodeParameter('changeId', i); - responseData = await freshserviceApiRequest.call(this, 'DELETE', `/changes/${changeId}`); - + responseData = await freshserviceApiRequest.call( + this, + 'DELETE', + `/changes/${changeId}`, + ); } else if (operation === 'get') { - // ---------------------------------------- // change: get // ---------------------------------------- const changeId = this.getNodeParameter('changeId', i); responseData = await freshserviceApiRequest.call(this, 'GET', `/changes/${changeId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // change: getAll // ---------------------------------------- @@ -762,9 +722,7 @@ export class Freshservice implements INodeType { } responseData = await handleListing.call(this, 'GET', '/changes', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // change: update // ---------------------------------------- @@ -777,18 +735,19 @@ export class Freshservice implements INodeType { Object.assign(body, updateFields); const changeId = this.getNodeParameter('changeId', i); - responseData = await freshserviceApiRequest.call(this, 'PUT', `/changes/${changeId}`, body); - + responseData = await freshserviceApiRequest.call( + this, + 'PUT', + `/changes/${changeId}`, + body, + ); } - } else if (resource === 'department') { - // ********************************************************************** // department // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // department: create // ---------------------------------------- @@ -810,9 +769,7 @@ export class Freshservice implements INodeType { } responseData = await freshserviceApiRequest.call(this, 'POST', '/departments', body); - } else if (operation === 'delete') { - // ---------------------------------------- // department: delete // ---------------------------------------- @@ -820,9 +777,7 @@ export class Freshservice implements INodeType { const departmentId = this.getNodeParameter('departmentId', i); const endpoint = `/departments/${departmentId}`; responseData = await freshserviceApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // department: get // ---------------------------------------- @@ -830,9 +785,7 @@ export class Freshservice implements INodeType { const departmentId = this.getNodeParameter('departmentId', i); const endpoint = `/departments/${departmentId}`; responseData = await freshserviceApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // department: getAll // ---------------------------------------- @@ -845,9 +798,7 @@ export class Freshservice implements INodeType { } responseData = await handleListing.call(this, 'GET', '/departments', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // department: update // ---------------------------------------- @@ -868,17 +819,13 @@ export class Freshservice implements INodeType { const departmentId = this.getNodeParameter('departmentId', i); const endpoint = `/departments/${departmentId}`; responseData = await freshserviceApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'location') { - // ********************************************************************** // location // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // location: create // ---------------------------------------- @@ -887,16 +834,15 @@ export class Freshservice implements INodeType { name: this.getNodeParameter('name', i), } as IDataObject; - const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject & AddressFixedCollection; + const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject & + AddressFixedCollection; if (Object.keys(additionalFields).length) { Object.assign(body, adjustAddress(additionalFields)); } responseData = await freshserviceApiRequest.call(this, 'POST', '/locations', body); - } else if (operation === 'delete') { - // ---------------------------------------- // location: delete // ---------------------------------------- @@ -904,9 +850,7 @@ export class Freshservice implements INodeType { const locationId = this.getNodeParameter('locationId', i); const endpoint = `/locations/${locationId}`; responseData = await freshserviceApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // location: get // ---------------------------------------- @@ -914,17 +858,13 @@ export class Freshservice implements INodeType { const locationId = this.getNodeParameter('locationId', i); const endpoint = `/locations/${locationId}`; responseData = await freshserviceApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // location: getAll // ---------------------------------------- responseData = await handleListing.call(this, 'GET', '/locations'); - } else if (operation === 'update') { - // ---------------------------------------- // location: update // ---------------------------------------- @@ -939,17 +879,13 @@ export class Freshservice implements INodeType { const locationId = this.getNodeParameter('locationId', i); const endpoint = `/locations/${locationId}`; responseData = await freshserviceApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'problem') { - // ********************************************************************** // problem // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // problem: create // ---------------------------------------- @@ -970,9 +906,7 @@ export class Freshservice implements INodeType { } responseData = await freshserviceApiRequest.call(this, 'POST', '/problems', body); - } else if (operation === 'delete') { - // ---------------------------------------- // problem: delete // ---------------------------------------- @@ -980,9 +914,7 @@ export class Freshservice implements INodeType { const problemId = this.getNodeParameter('problemId', i); const endpoint = `/problems/${problemId}`; responseData = await freshserviceApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // problem: get // ---------------------------------------- @@ -990,17 +922,13 @@ export class Freshservice implements INodeType { const problemId = this.getNodeParameter('problemId', i); const endpoint = `/problems/${problemId}`; responseData = await freshserviceApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // problem: getAll // ---------------------------------------- responseData = await handleListing.call(this, 'GET', '/problems'); - } else if (operation === 'update') { - // ---------------------------------------- // problem: update // ---------------------------------------- @@ -1015,17 +943,13 @@ export class Freshservice implements INodeType { const problemId = this.getNodeParameter('problemId', i); const endpoint = `/problems/${problemId}`; responseData = await freshserviceApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'product') { - // ********************************************************************** // product // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // product: create // ---------------------------------------- @@ -1042,9 +966,7 @@ export class Freshservice implements INodeType { } responseData = await freshserviceApiRequest.call(this, 'POST', '/products', body); - } else if (operation === 'delete') { - // ---------------------------------------- // product: delete // ---------------------------------------- @@ -1053,9 +975,7 @@ export class Freshservice implements INodeType { const endpoint = `/products/${productId}`; responseData = await freshserviceApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // product: get // ---------------------------------------- @@ -1063,17 +983,13 @@ export class Freshservice implements INodeType { const productId = this.getNodeParameter('productId', i); const endpoint = `/products/${productId}`; responseData = await freshserviceApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // product: getAll // ---------------------------------------- responseData = await handleListing.call(this, 'GET', '/products'); - } else if (operation === 'update') { - // ---------------------------------------- // product: update // ---------------------------------------- @@ -1086,17 +1002,13 @@ export class Freshservice implements INodeType { const productId = this.getNodeParameter('productId', i); const endpoint = `/products/${productId}`; responseData = await freshserviceApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'release') { - // ********************************************************************** // release // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // release: create // ---------------------------------------- @@ -1117,9 +1029,7 @@ export class Freshservice implements INodeType { } responseData = await freshserviceApiRequest.call(this, 'POST', '/releases', body); - } else if (operation === 'delete') { - // ---------------------------------------- // release: delete // ---------------------------------------- @@ -1127,9 +1037,7 @@ export class Freshservice implements INodeType { const releaseId = this.getNodeParameter('releaseId', i); const endpoint = `/releases/${releaseId}`; responseData = await freshserviceApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // release: get // ---------------------------------------- @@ -1137,17 +1045,13 @@ export class Freshservice implements INodeType { const releaseId = this.getNodeParameter('releaseId', i); const endpoint = `/releases/${releaseId}`; responseData = await freshserviceApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // release: getAll // ---------------------------------------- responseData = await handleListing.call(this, 'GET', '/releases'); - } else if (operation === 'update') { - // ---------------------------------------- // release: update // ---------------------------------------- @@ -1160,17 +1064,13 @@ export class Freshservice implements INodeType { const releaseId = this.getNodeParameter('releaseId', i); const endpoint = `/releases/${releaseId}`; responseData = await freshserviceApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'requester') { - // ********************************************************************** // requester // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // requester: create // ---------------------------------------- @@ -1194,9 +1094,7 @@ export class Freshservice implements INodeType { } responseData = await freshserviceApiRequest.call(this, 'POST', '/requesters', body); - } else if (operation === 'delete') { - // ---------------------------------------- // requester: delete // ---------------------------------------- @@ -1204,9 +1102,7 @@ export class Freshservice implements INodeType { const requesterId = this.getNodeParameter('requesterId', i); const endpoint = `/requesters/${requesterId}`; responseData = await freshserviceApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // requester: get // ---------------------------------------- @@ -1214,9 +1110,7 @@ export class Freshservice implements INodeType { const requesterId = this.getNodeParameter('requesterId', i); const endpoint = `/requesters/${requesterId}`; responseData = await freshserviceApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // requester: getAll // ---------------------------------------- @@ -1229,9 +1123,7 @@ export class Freshservice implements INodeType { } responseData = await handleListing.call(this, 'GET', '/requesters', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // requester: update // ---------------------------------------- @@ -1253,17 +1145,13 @@ export class Freshservice implements INodeType { const requesterId = this.getNodeParameter('requesterId', i); const endpoint = `/requesters/${requesterId}`; responseData = await freshserviceApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'requesterGroup') { - // ********************************************************************** // requesterGroup // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // requesterGroup: create // ---------------------------------------- @@ -1278,10 +1166,13 @@ export class Freshservice implements INodeType { Object.assign(body, additionalFields); } - responseData = await freshserviceApiRequest.call(this, 'POST', '/requester_groups', body); - + responseData = await freshserviceApiRequest.call( + this, + 'POST', + '/requester_groups', + body, + ); } else if (operation === 'delete') { - // ---------------------------------------- // requesterGroup: delete // ---------------------------------------- @@ -1289,9 +1180,7 @@ export class Freshservice implements INodeType { const requesterGroupId = this.getNodeParameter('requesterGroupId', i); const endpoint = `/requester_groups/${requesterGroupId}`; responseData = await freshserviceApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // requesterGroup: get // ---------------------------------------- @@ -1299,17 +1188,13 @@ export class Freshservice implements INodeType { const requesterGroupId = this.getNodeParameter('requesterGroupId', i); const endpoint = `/requester_groups/${requesterGroupId}`; responseData = await freshserviceApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // requesterGroup: getAll // ---------------------------------------- responseData = await handleListing.call(this, 'GET', '/requester_groups'); - } else if (operation === 'update') { - // ---------------------------------------- // requesterGroup: update // ---------------------------------------- @@ -1324,17 +1209,13 @@ export class Freshservice implements INodeType { const requesterGroupId = this.getNodeParameter('requesterGroupId', i); const endpoint = `/requester_groups/${requesterGroupId}`; responseData = await freshserviceApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'software') { - // ********************************************************************** // software // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // software: create // ---------------------------------------- @@ -1353,9 +1234,7 @@ export class Freshservice implements INodeType { } responseData = await freshserviceApiRequest.call(this, 'POST', '/applications', body); - } else if (operation === 'delete') { - // ---------------------------------------- // software: delete // ---------------------------------------- @@ -1363,9 +1242,7 @@ export class Freshservice implements INodeType { const softwareId = this.getNodeParameter('softwareId', i); const endpoint = `/applications/${softwareId}`; responseData = await freshserviceApiRequest.call(this, 'DELETE', endpoint); - } else if (operation === 'get') { - // ---------------------------------------- // software: get // ---------------------------------------- @@ -1373,17 +1250,13 @@ export class Freshservice implements INodeType { const softwareId = this.getNodeParameter('softwareId', i); const endpoint = `/applications/${softwareId}`; responseData = await freshserviceApiRequest.call(this, 'GET', endpoint); - } else if (operation === 'getAll') { - // ---------------------------------------- // software: getAll // ---------------------------------------- responseData = await handleListing.call(this, 'GET', '/applications'); - } else if (operation === 'update') { - // ---------------------------------------- // software: update // ---------------------------------------- @@ -1398,17 +1271,13 @@ export class Freshservice implements INodeType { const softwareId = this.getNodeParameter('softwareId', i); const endpoint = `/applications/${softwareId}`; responseData = await freshserviceApiRequest.call(this, 'PUT', endpoint, body); - } - } else if (resource === 'ticket') { - // ********************************************************************** // ticket // ********************************************************************** if (operation === 'create') { - // ---------------------------------------- // ticket: create // ---------------------------------------- @@ -1422,7 +1291,7 @@ export class Freshservice implements INodeType { } as IDataObject; const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject & { - cc_emails?: string, + cc_emails?: string; }; if (Object.keys(additionalFields).length) { @@ -1435,27 +1304,25 @@ export class Freshservice implements INodeType { } responseData = await freshserviceApiRequest.call(this, 'POST', '/tickets', body); - } else if (operation === 'delete') { - // ---------------------------------------- // ticket: delete // ---------------------------------------- const ticketId = this.getNodeParameter('ticketId', i); - responseData = await freshserviceApiRequest.call(this, 'DELETE', `/tickets/${ticketId}`); - + responseData = await freshserviceApiRequest.call( + this, + 'DELETE', + `/tickets/${ticketId}`, + ); } else if (operation === 'get') { - // ---------------------------------------- // ticket: get // ---------------------------------------- const ticketId = this.getNodeParameter('ticketId', i); responseData = await freshserviceApiRequest.call(this, 'GET', `/tickets/${ticketId}`); - } else if (operation === 'getAll') { - // ---------------------------------------- // ticket: getAll // ---------------------------------------- @@ -1472,9 +1339,7 @@ export class Freshservice implements INodeType { } responseData = await handleListing.call(this, 'GET', endpoint, {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // ticket: update // ---------------------------------------- @@ -1487,8 +1352,12 @@ export class Freshservice implements INodeType { Object.assign(body, updateFields); const ticketId = this.getNodeParameter('ticketId', i); - responseData = await freshserviceApiRequest.call(this, 'PUT', `/tickets/${ticketId}`, body); - + responseData = await freshserviceApiRequest.call( + this, + 'PUT', + `/tickets/${ticketId}`, + body, + ); } } @@ -1504,7 +1373,6 @@ export class Freshservice implements INodeType { }; responseData = responseData[special[resource]] ?? responseData[resource]; } - } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -1516,7 +1384,6 @@ export class Freshservice implements INodeType { Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts b/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts index 96b94184ae9c3..9db2010110cb4 100644 --- a/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts @@ -1,14 +1,6 @@ -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 { AddressFixedCollection, @@ -17,13 +9,9 @@ import { RolesParameter, } from './types'; -import { - OptionsWithUri, -} from 'request'; +import { OptionsWithUri } from 'request'; -import { - omit, -} from 'lodash'; +import { omit } from 'lodash'; export async function freshserviceApiRequest( this: IExecuteFunctions | IHookFunctions | ILoadOptionsFunctions, @@ -32,7 +20,9 @@ export async function freshserviceApiRequest( body: IDataObject = {}, qs: IDataObject = {}, ) { - const { apiKey, domain } = await this.getCredentials('freshserviceApi') as FreshserviceCredentials; + const { apiKey, domain } = (await this.getCredentials( + 'freshserviceApi', + )) as FreshserviceCredentials; const encodedApiKey = Buffer.from(`${apiKey}:X`).toString('base64'); const options: OptionsWithUri = { @@ -58,7 +48,6 @@ export async function freshserviceApiRequest( return await this.helpers.request!(options); } catch (error) { if (error.error.description === 'Validation failed') { - const numberOfErrors = error.error.errors.length; const message = 'Please check your parameters'; @@ -68,11 +57,10 @@ export async function freshserviceApiRequest( message, description: `For ${validationError.field}: ${validationError.message}`, }); - } else if (numberOfErrors > 1) { throw new NodeApiError(this.getNode(), error, { message, - description: 'For more information, expand \'details\' below and look at \'cause\' section', + description: "For more information, expand 'details' below and look at 'cause' section", }); } } @@ -99,9 +87,7 @@ export async function freshserviceApiRequestAllItems( if (!items.length) return returnData; returnData.push(...items); qs.page++; - } while ( - items.length >= 30 - ); + } while (items.length >= 30); return returnData; } @@ -145,23 +131,14 @@ export const toUserOptions = (loadedUsers: LoadedUser[]) => { /** * Ensure at least one role has been specified. */ -export function validateAssignmentScopeGroup( - this: IExecuteFunctions, - roles: RolesParameter, -) { +export function validateAssignmentScopeGroup(this: IExecuteFunctions, roles: RolesParameter) { if (!roles.roleProperties?.length) { - throw new NodeOperationError( - this.getNode(), - 'Please specify a role for the agent to create.', - ); + throw new NodeOperationError(this.getNode(), 'Please specify a role for the agent to create.'); } } -export function sanitizeAssignmentScopeGroup( - this: IExecuteFunctions, - roles: RolesParameter, -) { - roles.roleProperties.forEach(roleProperty => { +export function sanitizeAssignmentScopeGroup(this: IExecuteFunctions, roles: RolesParameter) { + roles.roleProperties.forEach((roleProperty) => { if (roleProperty.assignment_scope === 'specified_groups' && !roleProperty?.groups?.length) { throw new NodeOperationError( this.getNode(), @@ -192,19 +169,21 @@ export function adjustAgentRoles(roles: RolesParameter) { } export function formatFilters(filters: IDataObject) { - const query = Object.keys(filters).map(key => { - const value = filters[key]; + const query = Object.keys(filters) + .map((key) => { + const value = filters[key]; - if (!isNaN(Number(value))) { - return `${key}:${filters[key]}`; // number - } + if (!isNaN(Number(value))) { + return `${key}:${filters[key]}`; // number + } - if (typeof value === 'string' && value.endsWith('Z')) { - return `${key}:'${value.split('T')[0]}'`; // date - } + if (typeof value === 'string' && value.endsWith('Z')) { + return `${key}:'${value.split('T')[0]}'`; // date + } - return `${key}:'${filters[key]}'`; // string - }).join(' AND '); + return `${key}:'${filters[key]}'`; // string + }) + .join(' AND '); return { query: `"${query}"`, @@ -226,12 +205,14 @@ export function validateUpdateFields( throw new NodeOperationError( this.getNode(), - `Please enter at least one field to update for the ${twoWordResources[resource] ?? resource}.`, + `Please enter at least one field to update for the ${ + twoWordResources[resource] ?? resource + }.`, ); } } -export const toArray = (str: string) => str.split(',').map(e => e.trim()); +export const toArray = (str: string) => str.split(',').map((e) => e.trim()); export function adjustAddress(fixedCollection: IDataObject & AddressFixedCollection) { if (!fixedCollection.address) return fixedCollection; diff --git a/packages/nodes-base/nodes/Freshservice/constants.ts b/packages/nodes-base/nodes/Freshservice/constants.ts index 4223a31eb7cfe..4eedd3294722c 100644 --- a/packages/nodes-base/nodes/Freshservice/constants.ts +++ b/packages/nodes-base/nodes/Freshservice/constants.ts @@ -40,5 +40,5 @@ const RAW_LANGUAGES: { [key: string]: string } = { }; export const LANGUAGES = Object.keys(RAW_LANGUAGES).map((key) => { - return ({ value: key, name: RAW_LANGUAGES[key] }); + return { value: key, name: RAW_LANGUAGES[key] }; }); diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/AgentDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/AgentDescription.ts index 53c5fe8b3a6ef..7ece71a69096b 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/AgentDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/AgentDescription.ts @@ -1,10 +1,6 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; -import { - LANGUAGES, -} from '../constants'; +import { LANGUAGES } from '../constants'; export const agentOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const agentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'agent', - ], + resource: ['agent'], }, }, options: [ @@ -68,12 +62,8 @@ export const agentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'agent', - ], - operation: [ - 'create', - ], + resource: ['agent'], + operation: ['create'], }, }, }, @@ -85,12 +75,8 @@ export const agentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'agent', - ], - operation: [ - 'create', - ], + resource: ['agent'], + operation: ['create'], }, }, }, @@ -107,12 +93,8 @@ export const agentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'agent', - ], - operation: [ - 'create', - ], + resource: ['agent'], + operation: ['create'], }, }, options: [ @@ -123,7 +105,8 @@ export const agentFields: INodeProperties[] = [ { displayName: 'Role Name or ID', name: 'role', - description: 'Name of the role to assign to the agent. Choose from the list, or specify an ID using an expression.', + description: + 'Name of the role to assign to the agent. Choose from the list, or specify an ID using an expression.', type: 'options', typeOptions: { loadOptionsMethod: 'getAgentRoles', @@ -160,7 +143,8 @@ export const agentFields: INodeProperties[] = [ { displayName: 'Group Names or IDs', name: 'groups', - description: 'Groups in which the permissions granted by the role apply. Required only when Scope is Specified Groups - ignored otherwise. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', + description: + 'Groups in which the permissions granted by the role apply. Required only when Scope is Specified Groups - ignored otherwise. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', type: 'multiOptions', typeOptions: { loadOptionsMethod: 'getAgentGroups', @@ -179,12 +163,8 @@ export const agentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'agent', - ], - operation: [ - 'create', - ], + resource: ['agent'], + operation: ['create'], }, }, options: [ @@ -205,7 +185,8 @@ export const agentFields: INodeProperties[] = [ name: 'department_ids', type: 'multiOptions', default: [], - description: 'IDs of the departments to which the agent belongs. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', + description: + 'IDs of the departments to which the agent belongs. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -234,7 +215,8 @@ export const agentFields: INodeProperties[] = [ name: 'location_id', 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: 'getLocations', }, @@ -245,7 +227,8 @@ export const agentFields: INodeProperties[] = [ name: 'member_of', type: 'multiOptions', default: [], - description: 'Comma-separated IDs of the groups that the agent is a member of. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated IDs of the groups that the agent is a member of. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getAgentGroups', }, @@ -262,7 +245,8 @@ export const agentFields: INodeProperties[] = [ name: 'observer_of', type: 'multiOptions', default: [], - description: 'Comma-separated IDs of the groups that the agent is an observer of. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated IDs of the groups that the agent is an observer of. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getAgentGroups', }, @@ -338,12 +322,8 @@ export const agentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'agent', - ], - operation: [ - 'delete', - ], + resource: ['agent'], + operation: ['delete'], }, }, }, @@ -360,12 +340,8 @@ export const agentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'agent', - ], - operation: [ - 'get', - ], + resource: ['agent'], + operation: ['get'], }, }, }, @@ -381,12 +357,8 @@ export const agentFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'agent', - ], - operation: [ - 'getAll', - ], + resource: ['agent'], + operation: ['getAll'], }, }, }, @@ -401,15 +373,9 @@ export const agentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'agent', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['agent'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -421,12 +387,8 @@ export const agentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'agent', - ], - operation: [ - 'getAll', - ], + resource: ['agent'], + operation: ['getAll'], }, }, options: [ @@ -435,7 +397,8 @@ export const agentFields: INodeProperties[] = [ name: 'department_id', type: 'options', default: '', - description: 'ID of the department to which the agent belongs. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the department to which the agent belongs. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -477,7 +440,8 @@ export const agentFields: INodeProperties[] = [ name: 'location_id', type: 'options', default: '', - description: 'Choose from the list or specify an ID. Choose from the list, or specify an ID using an expression.', + description: + 'Choose from the list or specify an ID. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getLocations', }, @@ -509,12 +473,8 @@ export const agentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'agent', - ], - operation: [ - 'update', - ], + resource: ['agent'], + operation: ['update'], }, }, }, @@ -526,12 +486,8 @@ export const agentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'agent', - ], - operation: [ - 'update', - ], + resource: ['agent'], + operation: ['update'], }, }, options: [ @@ -552,7 +508,8 @@ export const agentFields: INodeProperties[] = [ name: 'department_ids', type: 'multiOptions', default: [], - description: 'IDs of the departments to which the agent belongs. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', + description: + 'IDs of the departments to which the agent belongs. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -594,7 +551,8 @@ export const agentFields: INodeProperties[] = [ name: 'location_id', type: 'options', default: '', - description: 'Choose from the list or specify an ID. Choose from the list, or specify an ID using an expression.', + description: + 'Choose from the list or specify an ID. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getLocations', }, @@ -605,7 +563,8 @@ export const agentFields: INodeProperties[] = [ name: 'member_of', type: 'multiOptions', default: [], - description: 'Comma-separated IDs of the groups that the agent is a member of. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated IDs of the groups that the agent is a member of. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getAgentGroups', }, @@ -622,7 +581,8 @@ export const agentFields: INodeProperties[] = [ name: 'observer_of', type: 'multiOptions', default: [], - description: 'Comma-separated IDs of the groups that the agent is an observer of. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated IDs of the groups that the agent is an observer of. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getAgentGroups', }, diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/AgentGroupDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/AgentGroupDescription.ts index 0b522b61471e9..f1c70913e100c 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/AgentGroupDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/AgentGroupDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const agentGroupOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const agentGroupOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'agentGroup', - ], + resource: ['agentGroup'], }, }, options: [ @@ -63,12 +59,8 @@ export const agentGroupFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'agentGroup', - ], - operation: [ - 'create', - ], + resource: ['agentGroup'], + operation: ['create'], }, }, }, @@ -80,12 +72,8 @@ export const agentGroupFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'agentGroup', - ], - operation: [ - 'create', - ], + resource: ['agentGroup'], + operation: ['create'], }, }, options: [ @@ -103,14 +91,16 @@ export const agentGroupFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getAgents', }, - description: 'ID of the user to whom an escalation email is sent if a ticket in this group is unassigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to whom an escalation email is sent if a ticket in this group is unassigned. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Member Names or IDs', name: 'members', type: 'multiOptions', default: [], - description: 'Comma-separated IDs of agents who are members of this group. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated IDs of agents who are members of this group. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getAgents', }, @@ -120,7 +110,8 @@ export const agentGroupFields: INodeProperties[] = [ name: 'observers', type: 'multiOptions', default: [], - description: 'Comma-separated agent IDs who are observers of this group. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated agent IDs who are observers of this group. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getAgents', }, @@ -128,7 +119,8 @@ export const agentGroupFields: INodeProperties[] = [ { displayName: 'Unassigned For', name: 'unassigned_for', - description: 'Time after which an escalation email is sent if a ticket in the group remains unassigned', + description: + 'Time after which an escalation email is sent if a ticket in the group remains unassigned', type: 'options', default: '30m', options: [ @@ -181,12 +173,8 @@ export const agentGroupFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'agentGroup', - ], - operation: [ - 'delete', - ], + resource: ['agentGroup'], + operation: ['delete'], }, }, }, @@ -203,12 +191,8 @@ export const agentGroupFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'agentGroup', - ], - operation: [ - 'get', - ], + resource: ['agentGroup'], + operation: ['get'], }, }, }, @@ -224,12 +208,8 @@ export const agentGroupFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'agentGroup', - ], - operation: [ - 'getAll', - ], + resource: ['agentGroup'], + operation: ['getAll'], }, }, }, @@ -244,15 +224,9 @@ export const agentGroupFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'agentGroup', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['agentGroup'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -269,12 +243,8 @@ export const agentGroupFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'agentGroup', - ], - operation: [ - 'update', - ], + resource: ['agentGroup'], + operation: ['update'], }, }, }, @@ -286,12 +256,8 @@ export const agentGroupFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'agentGroup', - ], - operation: [ - 'update', - ], + resource: ['agentGroup'], + operation: ['update'], }, }, options: [ @@ -306,7 +272,8 @@ export const agentGroupFields: INodeProperties[] = [ name: 'escalate_to', type: 'options', default: '', - description: 'ID of the agent to whom an escalation email is sent if a ticket in this group is unassigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the agent to whom an escalation email is sent if a ticket in this group is unassigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgents', }, @@ -316,7 +283,8 @@ export const agentGroupFields: INodeProperties[] = [ name: 'members', type: 'multiOptions', default: [], - description: 'Comma-separated IDs of agents who are members of this group. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated IDs of agents who are members of this group. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getAgents', }, @@ -332,7 +300,8 @@ export const agentGroupFields: INodeProperties[] = [ name: 'observers', type: 'multiOptions', default: [], - description: 'Comma-separated agent user IDs who are observers of this group. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated agent user IDs who are observers of this group. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getAgents', }, @@ -340,7 +309,8 @@ export const agentGroupFields: INodeProperties[] = [ { displayName: 'Unassigned For', name: 'unassigned_for', - description: 'Time after which an escalation email is sent if a ticket in the group remains unassigned', + description: + 'Time after which an escalation email is sent if a ticket in the group remains unassigned', type: 'options', default: '30m', options: [ diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/AgentRoleDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/AgentRoleDescription.ts index f18c8a420cbce..27c6879d10d4d 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/AgentRoleDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/AgentRoleDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const agentRoleOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const agentRoleOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'agentRole', - ], + resource: ['agentRole'], }, }, options: [ @@ -46,12 +42,8 @@ export const agentRoleFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'agentRole', - ], - operation: [ - 'get', - ], + resource: ['agentRole'], + operation: ['get'], }, }, }, @@ -67,12 +59,8 @@ export const agentRoleFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'agentRole', - ], - operation: [ - 'getAll', - ], + resource: ['agentRole'], + operation: ['getAll'], }, }, }, @@ -87,15 +75,9 @@ export const agentRoleFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'agentRole', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['agentRole'], + operation: ['getAll'], + returnAll: [false], }, }, }, diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/AnnouncementDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/AnnouncementDescription.ts index ccb5d4b7cbe3e..27178c1f22069 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/AnnouncementDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/AnnouncementDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const announcementOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const announcementOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'announcement', - ], + resource: ['announcement'], }, }, options: [ @@ -63,12 +59,8 @@ export const announcementFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'announcement', - ], - operation: [ - 'create', - ], + resource: ['announcement'], + operation: ['create'], }, }, }, @@ -81,12 +73,8 @@ export const announcementFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'announcement', - ], - operation: [ - 'create', - ], + resource: ['announcement'], + operation: ['create'], }, }, }, @@ -112,12 +100,8 @@ export const announcementFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'announcement', - ], - operation: [ - 'create', - ], + resource: ['announcement'], + operation: ['create'], }, }, }, @@ -130,12 +114,8 @@ export const announcementFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'announcement', - ], - operation: [ - 'create', - ], + resource: ['announcement'], + operation: ['create'], }, }, }, @@ -147,12 +127,8 @@ export const announcementFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'announcement', - ], - operation: [ - 'create', - ], + resource: ['announcement'], + operation: ['create'], }, }, options: [ @@ -161,14 +137,16 @@ export const announcementFields: INodeProperties[] = [ name: 'additional_emails', type: 'string', default: '', - description: 'Comma-separated additional email addresses to which the announcement needs to be sent', + description: + 'Comma-separated additional email addresses to which the announcement needs to be sent', }, { displayName: 'Department Names or IDs', name: 'departments', type: 'multiOptions', default: [], - description: 'Comma-separated IDs of departments that may view this announcement. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated IDs of departments that may view this announcement. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -202,12 +180,8 @@ export const announcementFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'announcement', - ], - operation: [ - 'delete', - ], + resource: ['announcement'], + operation: ['delete'], }, }, }, @@ -224,12 +198,8 @@ export const announcementFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'announcement', - ], - operation: [ - 'get', - ], + resource: ['announcement'], + operation: ['get'], }, }, }, @@ -245,12 +215,8 @@ export const announcementFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'announcement', - ], - operation: [ - 'getAll', - ], + resource: ['announcement'], + operation: ['getAll'], }, }, }, @@ -265,15 +231,9 @@ export const announcementFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'announcement', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['announcement'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -290,12 +250,8 @@ export const announcementFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'announcement', - ], - operation: [ - 'update', - ], + resource: ['announcement'], + operation: ['update'], }, }, }, @@ -307,12 +263,8 @@ export const announcementFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'announcement', - ], - operation: [ - 'update', - ], + resource: ['announcement'], + operation: ['update'], }, }, options: [ @@ -321,7 +273,8 @@ export const announcementFields: INodeProperties[] = [ name: 'additional_emails', type: 'string', default: '', - description: 'Comma-separated additional email addresses to which the announcement needs to be sent', + description: + 'Comma-separated additional email addresses to which the announcement needs to be sent', }, { displayName: 'Body', @@ -335,7 +288,8 @@ export const announcementFields: INodeProperties[] = [ name: 'departments', type: 'multiOptions', default: [], - description: 'Comma-separated IDs of departments that may view this announcement. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated IDs of departments that may view this announcement. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/AssetDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/AssetDescription.ts index 25246bdfa6820..e79d8cc2b6ded 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/AssetDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/AssetDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const assetOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const assetOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'asset', - ], + resource: ['asset'], }, }, options: [ @@ -63,12 +59,8 @@ export const assetFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'asset', - ], - operation: [ - 'create', - ], + resource: ['asset'], + operation: ['create'], }, }, }, @@ -76,7 +68,8 @@ export const assetFields: INodeProperties[] = [ displayName: 'Asset Type Name or ID', name: 'assetTypeId', type: 'options', - 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 assetFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'asset', - ], - operation: [ - 'create', - ], + resource: ['asset'], + operation: ['create'], }, }, }, @@ -103,12 +92,8 @@ export const assetFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'asset', - ], - operation: [ - 'create', - ], + resource: ['asset'], + operation: ['create'], }, }, default: {}, @@ -122,13 +107,12 @@ export const assetFields: INodeProperties[] = [ name: 'name', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'assetTypeId', - ], + loadOptionsDependsOn: ['assetTypeId'], loadOptionsMethod: 'getAssetTypeFields', }, 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', @@ -153,12 +137,8 @@ export const assetFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'asset', - ], - operation: [ - 'delete', - ], + resource: ['asset'], + operation: ['delete'], }, }, }, @@ -175,12 +155,8 @@ export const assetFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'asset', - ], - operation: [ - 'get', - ], + resource: ['asset'], + operation: ['get'], }, }, }, @@ -196,12 +172,8 @@ export const assetFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'asset', - ], - operation: [ - 'getAll', - ], + resource: ['asset'], + operation: ['getAll'], }, }, }, @@ -216,15 +188,9 @@ export const assetFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'asset', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['asset'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -236,12 +202,8 @@ export const assetFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'asset', - ], - operation: [ - 'getAll', - ], + resource: ['asset'], + operation: ['getAll'], }, }, options: [ @@ -250,7 +212,8 @@ export const assetFields: INodeProperties[] = [ name: 'agent_id', type: 'options', default: '', - description: 'ID of the agent by whom the asset is managed. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the agent by whom the asset is managed. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgents', }, @@ -267,7 +230,8 @@ export const assetFields: INodeProperties[] = [ name: 'asset_type_id', type: 'options', default: '', - description: 'ID of the asset type to filter by. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the asset type to filter by. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAssetTypes', }, @@ -277,7 +241,8 @@ export const assetFields: INodeProperties[] = [ name: 'department_id', type: 'options', default: '', - description: 'ID of the department to which the asset belongs. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the department to which the asset belongs. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -287,7 +252,8 @@ export const assetFields: INodeProperties[] = [ name: 'location_id', type: 'options', default: '', - description: 'ID of the location to filter by. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the location to filter by. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getLocations', }, @@ -314,12 +280,8 @@ export const assetFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'asset', - ], - operation: [ - 'update', - ], + resource: ['asset'], + operation: ['update'], }, }, }, @@ -333,12 +295,8 @@ export const assetFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'asset', - ], - operation: [ - 'update', - ], + resource: ['asset'], + operation: ['update'], }, }, default: {}, @@ -352,13 +310,12 @@ export const assetFields: INodeProperties[] = [ name: 'name', type: 'options', typeOptions: { - loadOptionsDependsOn: [ - 'assetTypeId', - ], + loadOptionsDependsOn: ['assetTypeId'], loadOptionsMethod: 'getAssetTypeFields', }, 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', diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/AssetTypeDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/AssetTypeDescription.ts index 1be79ef1d5686..a683b651d1634 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/AssetTypeDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/AssetTypeDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const assetTypeOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const assetTypeOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'assetType', - ], + resource: ['assetType'], }, }, options: [ @@ -63,12 +59,8 @@ export const assetTypeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'assetType', - ], - operation: [ - 'create', - ], + resource: ['assetType'], + operation: ['create'], }, }, }, @@ -80,12 +72,8 @@ export const assetTypeFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'assetType', - ], - operation: [ - 'create', - ], + resource: ['assetType'], + operation: ['create'], }, }, options: [ @@ -98,7 +86,8 @@ export const assetTypeFields: INodeProperties[] = [ { displayName: 'Parent Asset Type Name or ID', name: 'parent_asset_type_id', - 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', default: '', typeOptions: { @@ -120,12 +109,8 @@ export const assetTypeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'assetType', - ], - operation: [ - 'delete', - ], + resource: ['assetType'], + operation: ['delete'], }, }, }, @@ -142,12 +127,8 @@ export const assetTypeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'assetType', - ], - operation: [ - 'get', - ], + resource: ['assetType'], + operation: ['get'], }, }, }, @@ -163,12 +144,8 @@ export const assetTypeFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'assetType', - ], - operation: [ - 'getAll', - ], + resource: ['assetType'], + operation: ['getAll'], }, }, }, @@ -183,15 +160,9 @@ export const assetTypeFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'assetType', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['assetType'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -208,12 +179,8 @@ export const assetTypeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'assetType', - ], - operation: [ - 'update', - ], + resource: ['assetType'], + operation: ['update'], }, }, }, @@ -225,12 +192,8 @@ export const assetTypeFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'assetType', - ], - operation: [ - 'update', - ], + resource: ['assetType'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/ChangeDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/ChangeDescription.ts index 73aaf4bda20bf..1800b21213bca 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/ChangeDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/ChangeDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const changeOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const changeOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'change', - ], + resource: ['change'], }, }, options: [ @@ -59,7 +55,8 @@ export const changeFields: INodeProperties[] = [ displayName: 'Requester Name or ID', name: 'requesterId', // eslint-disable-next-line n8n-nodes-base/node-param-description-wrong-for-dynamic-options - description: 'ID of the requester of the change. Choose from the list or specify an ID. You can also specify the ID using an expression.', + description: + 'ID of the requester of the change. Choose from the list or specify an ID. You can also specify the ID using an expression.', type: 'options', required: true, default: '', @@ -68,12 +65,8 @@ export const changeFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'change', - ], - operation: [ - 'create', - ], + resource: ['change'], + operation: ['create'], }, }, }, @@ -85,12 +78,8 @@ export const changeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'change', - ], - operation: [ - 'create', - ], + resource: ['change'], + operation: ['create'], }, }, }, @@ -102,12 +91,8 @@ export const changeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'change', - ], - operation: [ - 'create', - ], + resource: ['change'], + operation: ['create'], }, }, }, @@ -119,12 +104,8 @@ export const changeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'change', - ], - operation: [ - 'create', - ], + resource: ['change'], + operation: ['create'], }, }, }, @@ -136,12 +117,8 @@ export const changeFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'change', - ], - operation: [ - 'create', - ], + resource: ['change'], + operation: ['create'], }, }, options: [ @@ -150,7 +127,8 @@ export const changeFields: INodeProperties[] = [ name: 'agent_id', type: 'options', default: '', - description: 'ID of the agent to whom the change is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the agent to whom the change is assigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgents', }, @@ -184,7 +162,8 @@ export const changeFields: INodeProperties[] = [ name: 'department_id', type: 'options', default: '', - description: 'ID of the department requesting the change. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the department requesting the change. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -201,7 +180,8 @@ export const changeFields: INodeProperties[] = [ name: 'group_id', type: 'options', default: '', - description: 'ID of the agent group to which the change is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the agent group to which the change is assigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgentGroups', }, @@ -328,12 +308,8 @@ export const changeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'change', - ], - operation: [ - 'delete', - ], + resource: ['change'], + operation: ['delete'], }, }, }, @@ -350,12 +326,8 @@ export const changeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'change', - ], - operation: [ - 'get', - ], + resource: ['change'], + operation: ['get'], }, }, }, @@ -371,12 +343,8 @@ export const changeFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'change', - ], - operation: [ - 'getAll', - ], + resource: ['change'], + operation: ['getAll'], }, }, }, @@ -391,15 +359,9 @@ export const changeFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'change', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['change'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -411,12 +373,8 @@ export const changeFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'change', - ], - operation: [ - 'getAll', - ], + resource: ['change'], + operation: ['getAll'], }, }, options: [ @@ -485,12 +443,8 @@ export const changeFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'change', - ], - operation: [ - 'update', - ], + resource: ['change'], + operation: ['update'], }, }, }, @@ -502,12 +456,8 @@ export const changeFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'change', - ], - operation: [ - 'update', - ], + resource: ['change'], + operation: ['update'], }, }, options: [ @@ -516,7 +466,8 @@ export const changeFields: INodeProperties[] = [ name: 'agent_id', type: 'options', default: '', - description: 'ID of the agent to whom the change is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the agent to whom the change is assigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgents', }, @@ -550,7 +501,8 @@ export const changeFields: INodeProperties[] = [ name: 'department_id', type: 'options', default: '', - description: 'ID of the department requesting the change. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the department requesting the change. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -567,7 +519,8 @@ export const changeFields: INodeProperties[] = [ name: 'group_id', type: 'options', default: '', - description: 'ID of the agent group to which the change is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the agent group to which the change is assigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgentGroups', }, @@ -622,7 +575,8 @@ export const changeFields: INodeProperties[] = [ name: 'requester_id', type: 'options', default: '', - description: 'ID of the requester of the change. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the requester of the change. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getRequesters', }, diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/DepartmentDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/DepartmentDescription.ts index e77b3b739e1d2..ce762b617cbce 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/DepartmentDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/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: [ @@ -63,12 +59,8 @@ export const departmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'department', - ], - operation: [ - 'create', - ], + resource: ['department'], + operation: ['create'], }, }, }, @@ -80,12 +72,8 @@ export const departmentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'department', - ], - operation: [ - 'create', - ], + resource: ['department'], + operation: ['create'], }, }, options: [ @@ -117,12 +105,8 @@ export const departmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'department', - ], - operation: [ - 'delete', - ], + resource: ['department'], + operation: ['delete'], }, }, }, @@ -139,12 +123,8 @@ export const departmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'department', - ], - operation: [ - 'get', - ], + resource: ['department'], + operation: ['get'], }, }, }, @@ -160,12 +140,8 @@ export const departmentFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'department', - ], - operation: [ - 'getAll', - ], + resource: ['department'], + operation: ['getAll'], }, }, }, @@ -180,15 +156,9 @@ export const departmentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'department', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['department'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -200,12 +170,8 @@ export const departmentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'department', - ], - operation: [ - 'getAll', - ], + resource: ['department'], + operation: ['getAll'], }, }, options: [ @@ -231,12 +197,8 @@ export const departmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'department', - ], - operation: [ - 'update', - ], + resource: ['department'], + operation: ['update'], }, }, }, @@ -248,12 +210,8 @@ export const departmentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'department', - ], - operation: [ - 'update', - ], + resource: ['department'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/LocationDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/LocationDescription.ts index 30e2f207575cc..3bafe487ed35e 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/LocationDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/LocationDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const locationOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const locationOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'location', - ], + resource: ['location'], }, }, options: [ @@ -64,12 +60,8 @@ export const locationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'location', - ], - operation: [ - 'create', - ], + resource: ['location'], + operation: ['create'], }, }, }, @@ -81,12 +73,8 @@ export const locationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'location', - ], - operation: [ - 'create', - ], + resource: ['location'], + operation: ['create'], }, }, options: [ @@ -156,12 +144,8 @@ export const locationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'location', - ], - operation: [ - 'delete', - ], + resource: ['location'], + operation: ['delete'], }, }, }, @@ -178,12 +162,8 @@ export const locationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'location', - ], - operation: [ - 'get', - ], + resource: ['location'], + operation: ['get'], }, }, }, @@ -199,12 +179,8 @@ export const locationFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'location', - ], - operation: [ - 'getAll', - ], + resource: ['location'], + operation: ['getAll'], }, }, }, @@ -219,15 +195,9 @@ export const locationFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'location', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['location'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -244,12 +214,8 @@ export const locationFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'location', - ], - operation: [ - 'update', - ], + resource: ['location'], + operation: ['update'], }, }, }, @@ -261,12 +227,8 @@ export const locationFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'location', - ], - operation: [ - 'update', - ], + resource: ['location'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/ProblemDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/ProblemDescription.ts index 426c02af15704..9438974a9c76d 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/ProblemDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/ProblemDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const problemOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const problemOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'problem', - ], + resource: ['problem'], }, }, options: [ @@ -63,19 +59,16 @@ export const problemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'problem', - ], - operation: [ - 'create', - ], + resource: ['problem'], + operation: ['create'], }, }, }, { displayName: 'Requester Name or ID', name: 'requesterId', - description: 'ID of the initiator of the problem. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the initiator of the problem. Choose from the list, or specify an ID using an expression.', type: 'options', required: true, default: '', @@ -84,12 +77,8 @@ export const problemFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'problem', - ], - operation: [ - 'create', - ], + resource: ['problem'], + operation: ['create'], }, }, }, @@ -101,12 +90,8 @@ export const problemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'problem', - ], - operation: [ - 'create', - ], + resource: ['problem'], + operation: ['create'], }, }, }, @@ -118,12 +103,8 @@ export const problemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'problem', - ], - operation: [ - 'create', - ], + resource: ['problem'], + operation: ['create'], }, }, options: [ @@ -132,7 +113,8 @@ export const problemFields: INodeProperties[] = [ name: 'agent_id', type: 'options', default: '', - description: 'ID of the agent to whom the problem is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the agent to whom the problem is assigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgents', }, @@ -142,7 +124,8 @@ export const problemFields: INodeProperties[] = [ name: 'department_id', type: 'options', default: '', - description: 'ID of the department initiating the problem. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the department initiating the problem. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -159,7 +142,8 @@ export const problemFields: INodeProperties[] = [ name: 'group_id', type: 'options', default: '', - description: 'ID of the agent group to which the problem is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the agent group to which the problem is assigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgentGroups', }, @@ -243,12 +227,8 @@ export const problemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'problem', - ], - operation: [ - 'delete', - ], + resource: ['problem'], + operation: ['delete'], }, }, }, @@ -265,12 +245,8 @@ export const problemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'problem', - ], - operation: [ - 'get', - ], + resource: ['problem'], + operation: ['get'], }, }, }, @@ -286,12 +262,8 @@ export const problemFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'problem', - ], - operation: [ - 'getAll', - ], + resource: ['problem'], + operation: ['getAll'], }, }, }, @@ -306,15 +278,9 @@ export const problemFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'problem', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['problem'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -331,12 +297,8 @@ export const problemFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'problem', - ], - operation: [ - 'update', - ], + resource: ['problem'], + operation: ['update'], }, }, }, @@ -348,12 +310,8 @@ export const problemFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'problem', - ], - operation: [ - 'update', - ], + resource: ['problem'], + operation: ['update'], }, }, options: [ @@ -362,7 +320,8 @@ export const problemFields: INodeProperties[] = [ name: 'agent_id', type: 'options', default: '', - description: 'ID of the agent to whom the problem is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the agent to whom the problem is assigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgents', }, @@ -372,7 +331,8 @@ export const problemFields: INodeProperties[] = [ name: 'department_id', type: 'options', default: '', - description: 'ID of the department initiating the problem. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the department initiating the problem. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -396,7 +356,8 @@ export const problemFields: INodeProperties[] = [ name: 'group_id', type: 'options', default: '', - description: 'ID of the agent group to which the problem is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the agent group to which the problem is assigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgentGroups', }, @@ -450,7 +411,8 @@ export const problemFields: INodeProperties[] = [ name: 'requester_id', type: 'options', default: '', - description: 'ID of the initiator of the problem. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the initiator of the problem. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getRequesters', }, diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/ProductDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/ProductDescription.ts index 5db77323c54b6..3b4e498285263 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/ProductDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/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: [ @@ -59,7 +55,8 @@ export const productFields: INodeProperties[] = [ displayName: 'Asset Type Name or ID', name: 'assetTypeId', type: 'options', - 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 productFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'create', - ], + resource: ['product'], + operation: ['create'], }, }, }, @@ -84,12 +77,8 @@ export const productFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'create', - ], + resource: ['product'], + operation: ['create'], }, }, }, @@ -101,12 +90,8 @@ export const productFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'create', - ], + resource: ['product'], + operation: ['create'], }, }, options: [ @@ -178,12 +163,8 @@ export const productFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'delete', - ], + resource: ['product'], + operation: ['delete'], }, }, }, @@ -200,12 +181,8 @@ export const productFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'get', - ], + resource: ['product'], + operation: ['get'], }, }, }, @@ -221,12 +198,8 @@ export const productFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'getAll', - ], + resource: ['product'], + operation: ['getAll'], }, }, }, @@ -241,15 +214,9 @@ export const productFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['product'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -266,12 +233,8 @@ export const productFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'update', - ], + resource: ['product'], + operation: ['update'], }, }, }, @@ -283,12 +246,8 @@ export const productFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'product', - ], - operation: [ - 'update', - ], + resource: ['product'], + operation: ['update'], }, }, options: [ @@ -296,7 +255,8 @@ export const productFields: INodeProperties[] = [ displayName: 'Asset Type Name or ID', name: 'asset_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: 'getAssetTypes', diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/ReleaseDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/ReleaseDescription.ts index bd81416607a24..6b40609bd227a 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/ReleaseDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/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: [ @@ -63,12 +59,8 @@ export const releaseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'create', - ], + resource: ['release'], + operation: ['create'], }, }, }, @@ -79,12 +71,8 @@ export const releaseFields: INodeProperties[] = [ default: 1, displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'create', - ], + resource: ['release'], + operation: ['create'], }, }, options: [ @@ -113,12 +101,8 @@ export const releaseFields: INodeProperties[] = [ default: 1, displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'create', - ], + resource: ['release'], + operation: ['create'], }, }, options: [ @@ -147,12 +131,8 @@ export const releaseFields: INodeProperties[] = [ default: 1, displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'create', - ], + resource: ['release'], + operation: ['create'], }, }, // eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items @@ -187,12 +167,8 @@ export const releaseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'create', - ], + resource: ['release'], + operation: ['create'], }, }, }, @@ -204,12 +180,8 @@ export const releaseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'create', - ], + resource: ['release'], + operation: ['create'], }, }, }, @@ -221,12 +193,8 @@ export const releaseFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'create', - ], + resource: ['release'], + operation: ['create'], }, }, options: [ @@ -235,7 +203,8 @@ export const releaseFields: INodeProperties[] = [ name: 'department_id', type: 'options', default: '', - description: 'ID of the department initiating the release. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the department initiating the release. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -252,7 +221,8 @@ export const releaseFields: INodeProperties[] = [ name: 'group_id', type: 'options', default: '', - description: 'ID of the agent group to which the release is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the agent group to which the release is assigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgentGroups', }, @@ -272,12 +242,8 @@ export const releaseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'delete', - ], + resource: ['release'], + operation: ['delete'], }, }, }, @@ -294,12 +260,8 @@ export const releaseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'get', - ], + resource: ['release'], + operation: ['get'], }, }, }, @@ -315,12 +277,8 @@ export const releaseFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'getAll', - ], + resource: ['release'], + operation: ['getAll'], }, }, }, @@ -335,15 +293,9 @@ export const releaseFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['release'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -360,12 +312,8 @@ export const releaseFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'update', - ], + resource: ['release'], + operation: ['update'], }, }, }, @@ -377,12 +325,8 @@ export const releaseFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'release', - ], - operation: [ - 'update', - ], + resource: ['release'], + operation: ['update'], }, }, options: [ @@ -391,7 +335,8 @@ export const releaseFields: INodeProperties[] = [ name: 'department_id', type: 'options', default: '', - description: 'ID of the department initiating the release. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the department initiating the release. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -408,7 +353,8 @@ export const releaseFields: INodeProperties[] = [ name: 'group_id', type: 'options', default: '', - description: 'ID of the agent group to which the release is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the agent group to which the release is assigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgentGroups', }, diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/RequesterDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/RequesterDescription.ts index 214ec0e812452..10802499bacfe 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/RequesterDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/RequesterDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; import { LANGUAGES } from '../constants'; export const requesterOperations: INodeProperties[] = [ @@ -11,9 +9,7 @@ export const requesterOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'requester', - ], + resource: ['requester'], }, }, options: [ @@ -64,12 +60,8 @@ export const requesterFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'requester', - ], - operation: [ - 'create', - ], + resource: ['requester'], + operation: ['create'], }, }, }, @@ -80,12 +72,8 @@ export const requesterFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'requester', - ], - operation: [ - 'create', - ], + resource: ['requester'], + operation: ['create'], }, }, }, @@ -97,12 +85,8 @@ export const requesterFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'requester', - ], - operation: [ - 'create', - ], + resource: ['requester'], + operation: ['create'], }, }, options: [ @@ -123,7 +107,8 @@ export const requesterFields: INodeProperties[] = [ name: 'department_ids', type: 'multiOptions', default: [], - description: 'Comma-separated IDs of the departments associated with the requester. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated IDs of the departments associated with the requester. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -150,7 +135,8 @@ export const requesterFields: INodeProperties[] = [ { displayName: 'Location Name or ID', name: 'location_id', - 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', default: '', typeOptions: { @@ -207,12 +193,8 @@ export const requesterFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'requester', - ], - operation: [ - 'delete', - ], + resource: ['requester'], + operation: ['delete'], }, }, }, @@ -229,12 +211,8 @@ export const requesterFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'requester', - ], - operation: [ - 'get', - ], + resource: ['requester'], + operation: ['get'], }, }, }, @@ -250,12 +228,8 @@ export const requesterFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'requester', - ], - operation: [ - 'getAll', - ], + resource: ['requester'], + operation: ['getAll'], }, }, }, @@ -270,15 +244,9 @@ export const requesterFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'requester', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['requester'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -290,19 +258,16 @@ export const requesterFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'requester', - ], - operation: [ - 'getAll', - ], + resource: ['requester'], + operation: ['getAll'], }, }, options: [ { displayName: 'Department Name or ID', name: 'department_id', - 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', default: '', typeOptions: { @@ -338,7 +303,8 @@ export const requesterFields: INodeProperties[] = [ displayName: 'Location Name or ID', name: 'location_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: 'getLocations', @@ -377,12 +343,8 @@ export const requesterFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'requester', - ], - operation: [ - 'update', - ], + resource: ['requester'], + operation: ['update'], }, }, }, @@ -394,12 +356,8 @@ export const requesterFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'requester', - ], - operation: [ - 'update', - ], + resource: ['requester'], + operation: ['update'], }, }, options: [ @@ -420,7 +378,8 @@ export const requesterFields: INodeProperties[] = [ name: 'department_ids', type: 'multiOptions', default: [], - description: 'Comma-separated IDs of the departments associated with the requester. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', + description: + 'Comma-separated IDs of the departments associated with the requester. Choose from the list or specify an ID using an expression. Choose from the list, or specify IDs using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -455,7 +414,8 @@ export const requesterFields: INodeProperties[] = [ name: 'location_id', 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: 'getLocations', }, diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/RequesterGroupDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/RequesterGroupDescription.ts index 06ef8f122683c..64ac2bc36868e 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/RequesterGroupDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/RequesterGroupDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const requesterGroupOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const requesterGroupOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'requesterGroup', - ], + resource: ['requesterGroup'], }, }, options: [ @@ -63,12 +59,8 @@ export const requesterGroupFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'requesterGroup', - ], - operation: [ - 'create', - ], + resource: ['requesterGroup'], + operation: ['create'], }, }, }, @@ -80,12 +72,8 @@ export const requesterGroupFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'requesterGroup', - ], - operation: [ - 'create', - ], + resource: ['requesterGroup'], + operation: ['create'], }, }, options: [ @@ -110,12 +98,8 @@ export const requesterGroupFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'requesterGroup', - ], - operation: [ - 'delete', - ], + resource: ['requesterGroup'], + operation: ['delete'], }, }, }, @@ -132,12 +116,8 @@ export const requesterGroupFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'requesterGroup', - ], - operation: [ - 'get', - ], + resource: ['requesterGroup'], + operation: ['get'], }, }, }, @@ -153,12 +133,8 @@ export const requesterGroupFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'requesterGroup', - ], - operation: [ - 'getAll', - ], + resource: ['requesterGroup'], + operation: ['getAll'], }, }, }, @@ -173,15 +149,9 @@ export const requesterGroupFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'requesterGroup', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['requesterGroup'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -198,12 +168,8 @@ export const requesterGroupFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'requesterGroup', - ], - operation: [ - 'update', - ], + resource: ['requesterGroup'], + operation: ['update'], }, }, }, @@ -215,12 +181,8 @@ export const requesterGroupFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'requesterGroup', - ], - operation: [ - 'update', - ], + resource: ['requesterGroup'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/SoftwareDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/SoftwareDescription.ts index 8b73c8b3e775d..176c4f8e22b74 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/SoftwareDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/SoftwareDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const softwareOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const softwareOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'software', - ], + resource: ['software'], }, }, options: [ @@ -77,12 +73,8 @@ export const softwareFields: INodeProperties[] = [ default: 'desktop', displayOptions: { show: { - resource: [ - 'software', - ], - operation: [ - 'create', - ], + resource: ['software'], + operation: ['create'], }, }, }, @@ -94,12 +86,8 @@ export const softwareFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'software', - ], - operation: [ - 'create', - ], + resource: ['software'], + operation: ['create'], }, }, }, @@ -111,12 +99,8 @@ export const softwareFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'software', - ], - operation: [ - 'create', - ], + resource: ['software'], + operation: ['create'], }, }, options: [ @@ -171,12 +155,8 @@ export const softwareFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'software', - ], - operation: [ - 'delete', - ], + resource: ['software'], + operation: ['delete'], }, }, }, @@ -193,12 +173,8 @@ export const softwareFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'software', - ], - operation: [ - 'get', - ], + resource: ['software'], + operation: ['get'], }, }, }, @@ -214,12 +190,8 @@ export const softwareFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'software', - ], - operation: [ - 'getAll', - ], + resource: ['software'], + operation: ['getAll'], }, }, }, @@ -234,15 +206,9 @@ export const softwareFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'software', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['software'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -259,12 +225,8 @@ export const softwareFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'software', - ], - operation: [ - 'update', - ], + resource: ['software'], + operation: ['update'], }, }, }, @@ -276,12 +238,8 @@ export const softwareFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'software', - ], - operation: [ - 'update', - ], + resource: ['software'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/Freshservice/descriptions/TicketDescription.ts b/packages/nodes-base/nodes/Freshservice/descriptions/TicketDescription.ts index b4eb5e9caf92a..621b3cc6c3b27 100644 --- a/packages/nodes-base/nodes/Freshservice/descriptions/TicketDescription.ts +++ b/packages/nodes-base/nodes/Freshservice/descriptions/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: [ @@ -65,12 +61,8 @@ export const ticketFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, }, @@ -81,12 +73,8 @@ export const ticketFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, }, @@ -98,12 +86,8 @@ export const ticketFields: INodeProperties[] = [ description: 'HTML supported', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, }, @@ -114,12 +98,8 @@ export const ticketFields: INodeProperties[] = [ default: 1, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, options: [ @@ -148,12 +128,8 @@ export const ticketFields: INodeProperties[] = [ default: 2, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, options: [ @@ -183,12 +159,8 @@ export const ticketFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'create', - ], + resource: ['ticket'], + operation: ['create'], }, }, options: [ @@ -204,7 +176,8 @@ export const ticketFields: INodeProperties[] = [ name: 'department_id', type: 'options', default: '', - description: 'ID of the department to which this ticket belongs. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the department to which this ticket belongs. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -214,7 +187,8 @@ export const ticketFields: INodeProperties[] = [ name: 'group_id', type: 'options', default: '', - description: 'ID of the group to which the ticket has been assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the group to which the ticket has been assigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgentGroups', }, @@ -250,7 +224,8 @@ export const ticketFields: INodeProperties[] = [ displayName: 'Requester Name or ID', name: 'requester_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: 'getRequesters', @@ -271,12 +246,8 @@ export const ticketFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'delete', - ], + resource: ['ticket'], + operation: ['delete'], }, }, }, @@ -293,12 +264,8 @@ export const ticketFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'get', - ], + resource: ['ticket'], + operation: ['get'], }, }, }, @@ -314,12 +281,8 @@ export const ticketFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], + resource: ['ticket'], + operation: ['getAll'], }, }, }, @@ -334,15 +297,9 @@ export const ticketFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['ticket'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -354,12 +311,8 @@ export const ticketFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'getAll', - ], + resource: ['ticket'], + operation: ['getAll'], }, }, options: [ @@ -368,7 +321,8 @@ export const ticketFields: INodeProperties[] = [ name: 'agent_id', type: 'options', default: '', - description: 'ID of the agent to whom the tickets have been assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the agent to whom the tickets have been assigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgents', }, @@ -378,7 +332,8 @@ export const ticketFields: INodeProperties[] = [ name: 'group_id', type: 'options', default: '', - description: 'ID of the group to which the tickets have been assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the group to which the tickets have been assigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgentGroups', }, @@ -480,12 +435,8 @@ export const ticketFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'update', - ], + resource: ['ticket'], + operation: ['update'], }, }, }, @@ -497,12 +448,8 @@ export const ticketFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'ticket', - ], - operation: [ - 'update', - ], + resource: ['ticket'], + operation: ['update'], }, }, options: [ @@ -511,7 +458,8 @@ export const ticketFields: INodeProperties[] = [ name: 'department_id', type: 'options', default: '', - description: 'ID of the department to which this ticket has been assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the department to which this ticket has been assigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getDepartments', }, @@ -536,7 +484,8 @@ export const ticketFields: INodeProperties[] = [ name: 'group_id', type: 'options', default: '', - description: 'ID of the group to which the ticket has been assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the group to which the ticket has been assigned. Choose from the list, or specify an ID using an expression.', typeOptions: { loadOptionsMethod: 'getAgentGroups', }, diff --git a/packages/nodes-base/nodes/Freshservice/types.d.ts b/packages/nodes-base/nodes/Freshservice/types.d.ts index 764a62ea275ea..61dd65e8bc07d 100644 --- a/packages/nodes-base/nodes/Freshservice/types.d.ts +++ b/packages/nodes-base/nodes/Freshservice/types.d.ts @@ -22,11 +22,11 @@ export type RolesParameter = IDataObject & { role: number; assignment_scope: 'entire_helpdesk' | 'member_groups' | 'specified_groups' | 'assigned_items'; groups?: number[]; - }> + }>; }; export type AddressFixedCollection = { address?: { - addressFields: object - } -} + addressFields: object; + }; +}; diff --git a/packages/nodes-base/nodes/FreshworksCrm/FreshworksCrm.node.ts b/packages/nodes-base/nodes/FreshworksCrm/FreshworksCrm.node.ts index 2ad3fd4e37d64..1a86fe02b01c9 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/FreshworksCrm.node.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/FreshworksCrm.node.ts @@ -1,6 +1,4 @@ -import { - IExecuteFunctions, -} from 'n8n-core'; +import { IExecuteFunctions } from 'n8n-core'; import { IDataObject, @@ -40,16 +38,9 @@ import { taskOperations, } from './descriptions'; -import { - FreshworksConfigResponse, - LoadedCurrency, - LoadedUser, - LoadOption, -} from './types'; +import { FreshworksConfigResponse, LoadedCurrency, LoadedUser, LoadOption } from './types'; -import { - tz, -} from 'moment-timezone'; +import { tz } from 'moment-timezone'; export class FreshworksCrm implements INodeType { description: INodeTypeDescription = { @@ -136,7 +127,11 @@ export class FreshworksCrm implements INodeType { loadOptions: { async getAccounts(this: ILoadOptionsFunctions) { const viewId = await getAllItemsViewId.call(this, { fromLoadOptions: true }); - const responseData = await handleListing.call(this, 'GET', `/sales_accounts/view/${viewId}`); + const responseData = await handleListing.call( + this, + 'GET', + `/sales_accounts/view/${viewId}`, + ); return responseData.map(({ name, id }) => ({ name, value: id })) as LoadOption[]; }, @@ -165,9 +160,11 @@ export class FreshworksCrm implements INodeType { }, async getCurrencies(this: ILoadOptionsFunctions) { - const response = await freshworksCrmApiRequest.call( - this, 'GET', '/selector/currencies', - ) as FreshworksConfigResponse; + const response = (await freshworksCrmApiRequest.call( + this, + 'GET', + '/selector/currencies', + )) as FreshworksConfigResponse; const key = Object.keys(response)[0]; @@ -224,16 +221,17 @@ export class FreshworksCrm implements INodeType { return await loadResource.call(this, 'territories'); }, - async getUsers(this: ILoadOptionsFunctions) { // for attendees, owners, and creators - const response = await freshworksCrmApiRequest.call( - this, 'GET', `/selector/owners`, - ) as FreshworksConfigResponse; + async getUsers(this: ILoadOptionsFunctions) { + // for attendees, owners, and creators + const response = (await freshworksCrmApiRequest.call( + this, + 'GET', + `/selector/owners`, + )) as FreshworksConfigResponse; const key = Object.keys(response)[0]; - return response[key].map( - ({ display_name, id }) => ({ name: display_name, value: id }), - ); + return response[key].map(({ display_name, id }) => ({ name: display_name, value: id })); }, }, }; @@ -249,11 +247,8 @@ export class FreshworksCrm implements INodeType { let responseData; for (let i = 0; i < items.length; i++) { - try { - if (resource === 'account') { - // ********************************************************************** // account // ********************************************************************** @@ -261,7 +256,6 @@ export class FreshworksCrm implements INodeType { // https://developers.freshworks.com/crm/api/#accounts if (operation === 'create') { - // ---------------------------------------- // account: create // ---------------------------------------- @@ -278,11 +272,14 @@ export class FreshworksCrm implements INodeType { Object.assign(body, additionalFields); } - responseData = await freshworksCrmApiRequest.call(this, 'POST', '/sales_accounts', body); + responseData = await freshworksCrmApiRequest.call( + this, + 'POST', + '/sales_accounts', + body, + ); responseData = responseData.sales_account; - } else if (operation === 'delete') { - // ---------------------------------------- // account: delete // ---------------------------------------- @@ -294,9 +291,7 @@ export class FreshworksCrm implements INodeType { const endpoint = `/sales_accounts/${accountId}`; await freshworksCrmApiRequest.call(this, 'DELETE', endpoint); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // account: get // ---------------------------------------- @@ -308,9 +303,7 @@ export class FreshworksCrm implements INodeType { const endpoint = `/sales_accounts/${accountId}`; responseData = await freshworksCrmApiRequest.call(this, 'GET', endpoint); responseData = responseData.sales_account; - } else if (operation === 'getAll') { - // ---------------------------------------- // account: getAll // ---------------------------------------- @@ -320,9 +313,7 @@ export class FreshworksCrm implements INodeType { const view = this.getNodeParameter('view', i) as string; responseData = await handleListing.call(this, 'GET', `/sales_accounts/view/${view}`); - } else if (operation === 'update') { - // ---------------------------------------- // account: update // ---------------------------------------- @@ -343,11 +334,8 @@ export class FreshworksCrm implements INodeType { const endpoint = `/sales_accounts/${accountId}`; responseData = await freshworksCrmApiRequest.call(this, 'PUT', endpoint, body); responseData = responseData.sales_account; - } - } else if (resource === 'appointment') { - // ********************************************************************** // appointment // ********************************************************************** @@ -355,7 +343,6 @@ export class FreshworksCrm implements INodeType { // https://developers.freshworks.com/crm/api/#appointments if (operation === 'create') { - // ---------------------------------------- // appointment: create // ---------------------------------------- @@ -369,7 +356,9 @@ export class FreshworksCrm implements INodeType { const startDate = this.getNodeParameter('fromDate', i) as string; const endDate = this.getNodeParameter('endDate', i) as string; - const attendees = this.getNodeParameter('attendees.attendee', i, []) as [{ type: string, contactId: string, userId: string }]; + const attendees = this.getNodeParameter('attendees.attendee', i, []) as [ + { type: string; contactId: string; userId: string }, + ]; const timezone = additionalFields.time_zone ?? defaultTimezone; @@ -385,7 +374,7 @@ export class FreshworksCrm implements INodeType { const body = { title: this.getNodeParameter('title', i), from_date: start.format(), - end_date: (allDay) ? start.format() : end.format(), + end_date: allDay ? start.format() : end.format(), } as IDataObject; Object.assign(body, additionalFields); @@ -395,9 +384,7 @@ export class FreshworksCrm implements INodeType { } responseData = await freshworksCrmApiRequest.call(this, 'POST', '/appointments', body); responseData = responseData.appointment; - } else if (operation === 'delete') { - // ---------------------------------------- // appointment: delete // ---------------------------------------- @@ -409,9 +396,7 @@ export class FreshworksCrm implements INodeType { const endpoint = `/appointments/${appointmentId}`; await freshworksCrmApiRequest.call(this, 'DELETE', endpoint); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // appointment: get // ---------------------------------------- @@ -423,9 +408,7 @@ export class FreshworksCrm implements INodeType { const endpoint = `/appointments/${appointmentId}`; responseData = await freshworksCrmApiRequest.call(this, 'GET', endpoint); responseData = responseData.appointment; - } else if (operation === 'getAll') { - // ---------------------------------------- // appointment: getAll // ---------------------------------------- @@ -447,9 +430,7 @@ export class FreshworksCrm implements INodeType { qs.include = include; } responseData = await handleListing.call(this, 'GET', '/appointments', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // appointment: update // ---------------------------------------- @@ -462,7 +443,9 @@ export class FreshworksCrm implements INodeType { time_zone: string; }; - const attendees = this.getNodeParameter('updateFields.attendees.attendee', i, []) as [{ type: string, contactId: string, userId: string }]; + const attendees = this.getNodeParameter('updateFields.attendees.attendee', i, []) as [ + { type: string; contactId: string; userId: string }, + ]; if (!Object.keys(updateFields).length) { throwOnEmptyUpdate.call(this, resource); @@ -493,11 +476,8 @@ export class FreshworksCrm implements INodeType { const endpoint = `/appointments/${appointmentId}`; responseData = await freshworksCrmApiRequest.call(this, 'PUT', endpoint, body); responseData = responseData.appointment; - } - } else if (resource === 'contact') { - // ********************************************************************** // contact // ********************************************************************** @@ -505,7 +485,6 @@ export class FreshworksCrm implements INodeType { // https://developers.freshworks.com/crm/api/#contacts if (operation === 'create') { - // ---------------------------------------- // contact: create // ---------------------------------------- @@ -526,9 +505,7 @@ export class FreshworksCrm implements INodeType { responseData = await freshworksCrmApiRequest.call(this, 'POST', '/contacts', body); responseData = responseData.contact; - } else if (operation === 'delete') { - // ---------------------------------------- // contact: delete // ---------------------------------------- @@ -540,9 +517,7 @@ export class FreshworksCrm implements INodeType { const endpoint = `/contacts/${contactId}`; await freshworksCrmApiRequest.call(this, 'DELETE', endpoint); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // contact: get // ---------------------------------------- @@ -554,9 +529,7 @@ export class FreshworksCrm implements INodeType { const endpoint = `/contacts/${contactId}`; responseData = await freshworksCrmApiRequest.call(this, 'GET', endpoint); responseData = responseData.contact; - } else if (operation === 'getAll') { - // ---------------------------------------- // contact: getAll // ---------------------------------------- @@ -566,9 +539,7 @@ export class FreshworksCrm implements INodeType { const view = this.getNodeParameter('view', i) as string; responseData = await handleListing.call(this, 'GET', `/contacts/view/${view}`); - } else if (operation === 'update') { - // ---------------------------------------- // contact: update // ---------------------------------------- @@ -589,11 +560,8 @@ export class FreshworksCrm implements INodeType { const endpoint = `/contacts/${contactId}`; responseData = await freshworksCrmApiRequest.call(this, 'PUT', endpoint, body); responseData = responseData.contact; - } - } else if (resource === 'deal') { - // ********************************************************************** // deal // ********************************************************************** @@ -601,7 +569,6 @@ export class FreshworksCrm implements INodeType { // https://developers.freshworks.com/crm/api/#deals if (operation === 'create') { - // ---------------------------------------- // deal: create // ---------------------------------------- @@ -621,9 +588,7 @@ export class FreshworksCrm implements INodeType { responseData = await freshworksCrmApiRequest.call(this, 'POST', '/deals', body); responseData = responseData.deal; - } else if (operation === 'delete') { - // ---------------------------------------- // deal: delete // ---------------------------------------- @@ -634,9 +599,7 @@ export class FreshworksCrm implements INodeType { await freshworksCrmApiRequest.call(this, 'DELETE', `/deals/${dealId}`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // deal: get // ---------------------------------------- @@ -647,9 +610,7 @@ export class FreshworksCrm implements INodeType { responseData = await freshworksCrmApiRequest.call(this, 'GET', `/deals/${dealId}`); responseData = responseData.deal; - } else if (operation === 'getAll') { - // ---------------------------------------- // deal: getAll // ---------------------------------------- @@ -659,9 +620,7 @@ export class FreshworksCrm implements INodeType { const view = this.getNodeParameter('view', i) as string; responseData = await handleListing.call(this, 'GET', `/deals/view/${view}`); - } else if (operation === 'update') { - // ---------------------------------------- // deal: update // ---------------------------------------- @@ -679,13 +638,15 @@ export class FreshworksCrm implements INodeType { const dealId = this.getNodeParameter('dealId', i); - responseData = await freshworksCrmApiRequest.call(this, 'PUT', `/deals/${dealId}`, body); + responseData = await freshworksCrmApiRequest.call( + this, + 'PUT', + `/deals/${dealId}`, + body, + ); responseData = responseData.deal; - } - } else if (resource === 'note') { - // ********************************************************************** // note // ********************************************************************** @@ -693,7 +654,6 @@ export class FreshworksCrm implements INodeType { // https://developers.freshworks.com/crm/api/#notes if (operation === 'create') { - // ---------------------------------------- // note: create // ---------------------------------------- @@ -708,9 +668,7 @@ export class FreshworksCrm implements INodeType { responseData = await freshworksCrmApiRequest.call(this, 'POST', '/notes', body); responseData = responseData.note; - } else if (operation === 'delete') { - // ---------------------------------------- // note: delete // ---------------------------------------- @@ -721,9 +679,7 @@ export class FreshworksCrm implements INodeType { await freshworksCrmApiRequest.call(this, 'DELETE', `/notes/${noteId}`); responseData = { success: true }; - } else if (operation === 'update') { - // ---------------------------------------- // note: update // ---------------------------------------- @@ -741,13 +697,15 @@ export class FreshworksCrm implements INodeType { const noteId = this.getNodeParameter('noteId', i); - responseData = await freshworksCrmApiRequest.call(this, 'PUT', `/notes/${noteId}`, body); + responseData = await freshworksCrmApiRequest.call( + this, + 'PUT', + `/notes/${noteId}`, + body, + ); responseData = responseData.note; - } - } else if (resource === 'salesActivity') { - // ********************************************************************** // salesActivity // ********************************************************************** @@ -755,7 +713,6 @@ export class FreshworksCrm implements INodeType { // https://developers.freshworks.com/crm/api/#sales-activities if (operation === 'create') { - // ---------------------------------------- // salesActivity: create // ---------------------------------------- @@ -781,11 +738,11 @@ export class FreshworksCrm implements INodeType { Object.assign(body, additionalFields); } - responseData = await freshworksCrmApiRequest.call(this, 'POST', '/sales_activities', { sales_activity: body }); + responseData = await freshworksCrmApiRequest.call(this, 'POST', '/sales_activities', { + sales_activity: body, + }); responseData = responseData.sales_activity; - } else if (operation === 'delete') { - // ---------------------------------------- // salesActivity: delete // ---------------------------------------- @@ -797,9 +754,7 @@ export class FreshworksCrm implements INodeType { const endpoint = `/sales_activities/${salesActivityId}`; await freshworksCrmApiRequest.call(this, 'DELETE', endpoint); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // salesActivity: get // ---------------------------------------- @@ -811,9 +766,7 @@ export class FreshworksCrm implements INodeType { const endpoint = `/sales_activities/${salesActivityId}`; responseData = await freshworksCrmApiRequest.call(this, 'GET', endpoint); responseData = responseData.sales_activity; - } else if (operation === 'getAll') { - // ---------------------------------------- // salesActivity: getAll // ---------------------------------------- @@ -821,9 +774,7 @@ export class FreshworksCrm implements INodeType { // https://developers.freshworks.com/crm/api/#list_all_sales_activities responseData = await handleListing.call(this, 'GET', '/sales_activities'); - } else if (operation === 'update') { - // ---------------------------------------- // salesActivity: update // ---------------------------------------- @@ -860,11 +811,8 @@ export class FreshworksCrm implements INodeType { const endpoint = `/sales_activities/${salesActivityId}`; responseData = await freshworksCrmApiRequest.call(this, 'PUT', endpoint, body); responseData = responseData.sales_activity; - } - } else if (resource === 'search') { - // ********************************************************************** // search // ********************************************************************** @@ -896,8 +844,8 @@ export class FreshworksCrm implements INodeType { if (operation === 'lookup') { // https://developers.freshworks.com/crm/api/#lookup_search let searchField = this.getNodeParameter('searchField', i) as string; - let fieldValue = this.getNodeParameter('fieldValue', i, '') as string; - let entities = this.getNodeParameter('options.entities', i) as string; + let fieldValue = this.getNodeParameter('fieldValue', i, '') as string; + let entities = this.getNodeParameter('options.entities', i) as string; if (Array.isArray(entities)) { entities = entities.join(','); } @@ -916,7 +864,6 @@ export class FreshworksCrm implements INodeType { responseData = await freshworksCrmApiRequest.call(this, 'GET', '/lookup', {}, qs); } } else if (resource === 'task') { - // ********************************************************************** // task // ********************************************************************** @@ -924,7 +871,6 @@ export class FreshworksCrm implements INodeType { // https://developers.freshworks.com/crm/api/#tasks if (operation === 'create') { - // ---------------------------------------- // task: create // ---------------------------------------- @@ -949,9 +895,7 @@ export class FreshworksCrm implements INodeType { responseData = await freshworksCrmApiRequest.call(this, 'POST', '/tasks', body); responseData = responseData.task; - } else if (operation === 'delete') { - // ---------------------------------------- // task: delete // ---------------------------------------- @@ -962,9 +906,7 @@ export class FreshworksCrm implements INodeType { await freshworksCrmApiRequest.call(this, 'DELETE', `/tasks/${taskId}`); responseData = { success: true }; - } else if (operation === 'get') { - // ---------------------------------------- // task: get // ---------------------------------------- @@ -975,9 +917,7 @@ export class FreshworksCrm implements INodeType { responseData = await freshworksCrmApiRequest.call(this, 'GET', `/tasks/${taskId}`); responseData = responseData.task; - } else if (operation === 'getAll') { - // ---------------------------------------- // task: getAll // ---------------------------------------- @@ -1002,9 +942,7 @@ export class FreshworksCrm implements INodeType { } responseData = await handleListing.call(this, 'GET', '/tasks', {}, qs); - } else if (operation === 'update') { - // ---------------------------------------- // task: update // ---------------------------------------- @@ -1030,13 +968,15 @@ export class FreshworksCrm implements INodeType { const taskId = this.getNodeParameter('taskId', i); - responseData = await freshworksCrmApiRequest.call(this, 'PUT', `/tasks/${taskId}`, body); + responseData = await freshworksCrmApiRequest.call( + this, + 'PUT', + `/tasks/${taskId}`, + body, + ); responseData = responseData.task; - } - } - } catch (error) { if (this.continueOnFail()) { returnData.push({ json: { error: error.message } }); @@ -1048,7 +988,6 @@ export class FreshworksCrm implements INodeType { Array.isArray(responseData) ? returnData.push(...responseData) : returnData.push(responseData); - } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts b/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts index e1d41870fdb8c..38992dfeae25c 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts @@ -1,17 +1,8 @@ -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 { FreshworksConfigResponse, @@ -20,9 +11,7 @@ import { ViewsResponse, } from './types'; -import { - omit, -} from 'lodash'; +import { omit } from 'lodash'; export async function freshworksCrmApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, @@ -31,7 +20,7 @@ export async function freshworksCrmApiRequest( body: IDataObject = {}, qs: IDataObject = {}, ) { - const { domain } = await this.getCredentials('freshworksCrmApi') as FreshworksCrmApiCredentials; + const { domain } = (await this.getCredentials('freshworksCrmApi')) as FreshworksCrmApiCredentials; const options: OptionsWithUri = { method, @@ -71,9 +60,13 @@ export async function getAllItemsViewId( keyword = 'My Deals'; // no 'All Deals' available } - const response = await freshworksCrmApiRequest.call(this, 'GET', `/${resource}s/filters`) as ViewsResponse; + const response = (await freshworksCrmApiRequest.call( + this, + 'GET', + `/${resource}s/filters`, + )) as ViewsResponse; - const view = response.filters.find(v => v.name.includes(keyword)); + const view = response.filters.find((v) => v.name.includes(keyword)); if (!view) { throw new NodeOperationError(this.getNode(), 'Failed to get all items view'); @@ -99,9 +92,7 @@ export async function freshworksCrmApiRequestAllItems( const key = Object.keys(response)[0]; returnData.push(...response[key]); qs.page++; - } while ( - response.meta.total_pages && qs.page <= response.meta.total_pages - ); + } while (response.meta.total_pages && qs.page <= response.meta.total_pages); return returnData; } @@ -132,19 +123,18 @@ export async function handleListing( * * See: https://developers.freshworks.com/crm/api/#admin_configuration */ -export async function loadResource( - this: ILoadOptionsFunctions, - resource: string, -) { - const response = await freshworksCrmApiRequest.call( - this, 'GET', `/selector/${resource}`, - ) as FreshworksConfigResponse; +export async function loadResource(this: ILoadOptionsFunctions, resource: string) { + const response = (await freshworksCrmApiRequest.call( + this, + 'GET', + `/selector/${resource}`, + )) as FreshworksConfigResponse; const key = Object.keys(response)[0]; return response[key].map(({ name, id }) => ({ name, value: id })); } -export function adjustAttendees(attendees: [{ type: string, contactId: string, userId: string }]) { +export function adjustAttendees(attendees: [{ type: string; contactId: string; userId: string }]) { return attendees.map((attendee) => { if (attendee.type === 'contact') { return { @@ -160,7 +150,6 @@ export function adjustAttendees(attendees: [{ type: string, contactId: string, u }); } - // /** // * Adjust attendee data from n8n UI to the format expected by Freshworks CRM API. // */ @@ -181,7 +170,7 @@ export function adjustAttendees(attendees: [{ type: string, contactId: string, u export function adjustAccounts(additionalFields: IDataObject & SalesAccounts) { if (!additionalFields?.sales_accounts) return additionalFields; - const adjusted = additionalFields.sales_accounts.map(accountId => { + const adjusted = additionalFields.sales_accounts.map((accountId) => { return { id: accountId, is_primary: false }; }); @@ -193,21 +182,13 @@ export function adjustAccounts(additionalFields: IDataObject & SalesAccounts) { }; } -export function throwOnEmptyUpdate( - this: IExecuteFunctions, - resource: string, -) { +export function throwOnEmptyUpdate(this: IExecuteFunctions, resource: string) { throw new NodeOperationError( this.getNode(), `Please enter at least one field to update for the ${resource}.`, ); } -export function throwOnEmptyFilter( - this: IExecuteFunctions, -) { - throw new NodeOperationError( - this.getNode(), - `Please select at least one filter.`, - ); +export function throwOnEmptyFilter(this: IExecuteFunctions) { + throw new NodeOperationError(this.getNode(), `Please select at least one filter.`); } diff --git a/packages/nodes-base/nodes/FreshworksCrm/descriptions/AccountDescription.ts b/packages/nodes-base/nodes/FreshworksCrm/descriptions/AccountDescription.ts index 849fb32e60460..7f6b9d3d6bf21 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/descriptions/AccountDescription.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/descriptions/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: [ @@ -64,12 +60,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'create', - ], + resource: ['account'], + operation: ['create'], }, }, }, @@ -81,12 +73,8 @@ export const accountFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'create', - ], + resource: ['account'], + operation: ['create'], }, }, options: [ @@ -112,7 +100,8 @@ export const accountFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getBusinessTypes', }, - description: 'ID of the business that the account belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the business that the account belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'City', @@ -143,7 +132,8 @@ export const accountFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getIndustryTypes', }, - description: 'ID of the industry that the account belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the industry that the account belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'LinkedIn', @@ -167,7 +157,8 @@ export const accountFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getUsers', }, - description: 'ID of the user to whom the account is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to whom the account is assigned. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Parent Sales Account ID', @@ -198,7 +189,8 @@ export const accountFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTerritories', }, - description: 'ID of the territory that the account belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the territory that the account belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Twitter', @@ -236,12 +228,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'delete', - ], + resource: ['account'], + operation: ['delete'], }, }, }, @@ -258,12 +246,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'get', - ], + resource: ['account'], + operation: ['get'], }, }, }, @@ -275,19 +259,16 @@ export const accountFields: INodeProperties[] = [ displayName: 'View Name or ID', name: 'view', type: 'options', - 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: 'getAccountViews', }, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getAll', - ], + resource: ['account'], + operation: ['getAll'], }, }, default: '', @@ -300,12 +281,8 @@ export const accountFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getAll', - ], + resource: ['account'], + operation: ['getAll'], }, }, }, @@ -320,15 +297,9 @@ export const accountFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['account'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -345,12 +316,8 @@ export const accountFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'update', - ], + resource: ['account'], + operation: ['update'], }, }, }, @@ -362,12 +329,8 @@ export const accountFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'account', - ], - operation: [ - 'update', - ], + resource: ['account'], + operation: ['update'], }, }, options: [ @@ -393,7 +356,8 @@ export const accountFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getBusinessTypes', }, - description: 'ID of the business that the account belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the business that the account belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'City', @@ -424,7 +388,8 @@ export const accountFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getIndustryTypes', }, - description: 'ID of the industry that the account belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the industry that the account belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'LinkedIn', @@ -455,7 +420,8 @@ export const accountFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getUsers', }, - description: 'ID of the user to whom the account is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to whom the account is assigned. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Parent Sales Account ID', @@ -486,7 +452,8 @@ export const accountFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTerritories', }, - description: 'ID of the territory that the account belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the territory that the account belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Twitter', diff --git a/packages/nodes-base/nodes/FreshworksCrm/descriptions/AppointmentDescription.ts b/packages/nodes-base/nodes/FreshworksCrm/descriptions/AppointmentDescription.ts index 98a86a894e498..4d2123fc1c0a7 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/descriptions/AppointmentDescription.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/descriptions/AppointmentDescription.ts @@ -1,10 +1,6 @@ -import { - tz, -} from 'moment-timezone'; +import { tz } from 'moment-timezone'; -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const appointmentOperations: INodeProperties[] = [ { @@ -14,9 +10,7 @@ export const appointmentOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'appointment', - ], + resource: ['appointment'], }, }, options: [ @@ -68,48 +62,38 @@ export const appointmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'appointment', - ], - operation: [ - 'create', - ], + resource: ['appointment'], + operation: ['create'], }, }, }, { displayName: 'Start Date', name: 'fromDate', - description: 'Timestamp that denotes the start of appointment. Start date if this is an all-day appointment.', + description: + 'Timestamp that denotes the start of appointment. Start date if this is an all-day appointment.', type: 'dateTime', required: true, default: '', displayOptions: { show: { - resource: [ - 'appointment', - ], - operation: [ - 'create', - ], + resource: ['appointment'], + operation: ['create'], }, }, }, { displayName: 'End Date', name: 'endDate', - description: 'Timestamp that denotes the end of appointment. End date if this is an all-day appointment.', + description: + 'Timestamp that denotes the end of appointment. End date if this is an all-day appointment.', type: 'dateTime', required: true, default: '', displayOptions: { show: { - resource: [ - 'appointment', - ], - operation: [ - 'create', - ], + resource: ['appointment'], + operation: ['create'], }, }, }, @@ -122,12 +106,8 @@ export const appointmentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'appointment', - ], - operation: [ - 'create', - ], + resource: ['appointment'], + operation: ['create'], }, }, placeholder: 'Add Attendee', @@ -157,12 +137,11 @@ export const appointmentFields: 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', displayOptions: { show: { - type: [ - 'user', - ], + type: ['user'], }, }, typeOptions: { @@ -175,9 +154,7 @@ export const appointmentFields: INodeProperties[] = [ name: 'contactId', displayOptions: { show: { - type: [ - 'contact', - ], + type: ['contact'], }, }, type: 'string', @@ -195,12 +172,8 @@ export const appointmentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'appointment', - ], - operation: [ - 'create', - ], + resource: ['appointment'], + operation: ['create'], }, }, options: [ @@ -212,7 +185,8 @@ export const appointmentFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getUsers', }, - description: 'ID of the user who created the appointment. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user who created the appointment. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Is All-Day', @@ -250,7 +224,8 @@ export const appointmentFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getOutcomes', }, - description: 'ID of outcome of Appointment sales activity type. Choose from the list, or specify an ID using an expression.', + description: + 'ID of outcome of Appointment sales activity type. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Target ID', @@ -285,7 +260,7 @@ export const appointmentFields: INodeProperties[] = [ type: 'options', default: '', description: 'Timezone that the appointment is scheduled in', - options: tz.names().map(tz => ({ name: tz, value: tz })), + options: tz.names().map((tz) => ({ name: tz, value: tz })), }, ], }, @@ -302,12 +277,8 @@ export const appointmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'appointment', - ], - operation: [ - 'delete', - ], + resource: ['appointment'], + operation: ['delete'], }, }, }, @@ -324,12 +295,8 @@ export const appointmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'appointment', - ], - operation: [ - 'get', - ], + resource: ['appointment'], + operation: ['get'], }, }, }, @@ -345,12 +312,8 @@ export const appointmentFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'appointment', - ], - operation: [ - 'getAll', - ], + resource: ['appointment'], + operation: ['getAll'], }, }, }, @@ -365,15 +328,9 @@ export const appointmentFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'appointment', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['appointment'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -385,12 +342,8 @@ export const appointmentFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'appointment', - ], - operation: [ - 'getAll', - ], + resource: ['appointment'], + operation: ['getAll'], }, }, options: [ @@ -445,12 +398,8 @@ export const appointmentFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'appointment', - ], - operation: [ - 'update', - ], + resource: ['appointment'], + operation: ['update'], }, }, }, @@ -462,12 +411,8 @@ export const appointmentFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'appointment', - ], - operation: [ - 'update', - ], + resource: ['appointment'], + operation: ['update'], }, }, options: [ @@ -505,12 +450,11 @@ export const appointmentFields: 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', displayOptions: { show: { - type: [ - 'user', - ], + type: ['user'], }, }, typeOptions: { @@ -523,9 +467,7 @@ export const appointmentFields: INodeProperties[] = [ name: 'contactId', displayOptions: { show: { - type: [ - 'contact', - ], + type: ['contact'], }, }, type: 'string', @@ -543,12 +485,14 @@ export const appointmentFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getUsers', }, - description: 'ID of the user who created the appointment. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user who created the appointment. Choose from the list, or specify an ID using an expression.', }, { displayName: 'End Date', name: 'endDate', - description: 'Timestamp that denotes the end of appointment. End date if this is an all-day appointment.', + description: + 'Timestamp that denotes the end of appointment. End date if this is an all-day appointment.', type: 'dateTime', default: '', }, @@ -588,12 +532,14 @@ export const appointmentFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getOutcomes', }, - description: 'ID of outcome of Appointment sales activity type. Choose from the list, or specify an ID using an expression.', + description: + 'ID of outcome of Appointment sales activity type. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Start Date', name: 'fromDate', - description: 'Timestamp that denotes the start of appointment. Start date if this is an all-day appointment.', + description: + 'Timestamp that denotes the start of appointment. Start date if this is an all-day appointment.', type: 'dateTime', default: '', }, @@ -630,7 +576,7 @@ export const appointmentFields: INodeProperties[] = [ type: 'options', default: '', description: 'Timezone that the appointment is scheduled in', - options: tz.names().map(tz => ({ name: tz, value: tz })), + options: tz.names().map((tz) => ({ name: tz, value: tz })), }, { displayName: 'Title', diff --git a/packages/nodes-base/nodes/FreshworksCrm/descriptions/ContactDescription.ts b/packages/nodes-base/nodes/FreshworksCrm/descriptions/ContactDescription.ts index d0805bde75c48..1e2e1fd44afa0 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/descriptions/ContactDescription.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/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: [ @@ -64,12 +60,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, }, @@ -82,12 +74,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, }, @@ -100,12 +88,8 @@ export const contactFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, }, @@ -117,12 +101,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'create', - ], + resource: ['contact'], + operation: ['create'], }, }, options: [ @@ -141,7 +121,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCampaigns', }, - description: 'ID of the campaign that led your contact to your webapp. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the campaign that led your contact to your webapp. Choose from the list, or specify an ID using an expression.', }, { displayName: 'City', @@ -158,7 +139,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getContactStatuses', }, - description: 'ID of the contact status that the contact belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the contact status that the contact belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Country', @@ -210,7 +192,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getLifecycleStages', }, - description: 'ID of the lifecycle stage that the contact belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the lifecycle stage that the contact belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'LinkedIn', @@ -241,7 +224,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getUsers', }, - description: 'ID of the user to whom the contact is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to whom the contact is assigned. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Sales Account Names or IDs', @@ -251,7 +235,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getAccounts', }, - description: 'Accounts which contact belongs to. Choose from the list, or specify IDs using an expression.', + description: + 'Accounts which contact belongs to. Choose from the list, or specify IDs using an expression.', }, { displayName: 'State', @@ -282,7 +267,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTerritories', }, - description: 'ID of the territory that the contact belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the territory that the contact belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Time Zone', @@ -327,12 +313,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'delete', - ], + resource: ['contact'], + operation: ['delete'], }, }, }, @@ -349,12 +331,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'get', - ], + resource: ['contact'], + operation: ['get'], }, }, }, @@ -366,15 +344,12 @@ export const contactFields: INodeProperties[] = [ displayName: 'View Name or ID', name: 'view', type: 'options', - 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: [ - 'contact', - ], - operation: [ - 'getAll', - ], + resource: ['contact'], + operation: ['getAll'], }, }, typeOptions: { @@ -390,12 +365,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'], }, }, }, @@ -410,15 +381,9 @@ export const contactFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['contact'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -435,12 +400,8 @@ export const contactFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, }, @@ -452,12 +413,8 @@ export const contactFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'contact', - ], - operation: [ - 'update', - ], + resource: ['contact'], + operation: ['update'], }, }, options: [ @@ -476,7 +433,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCampaigns', }, - description: 'ID of the campaign that led your contact to your webapp. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the campaign that led your contact to your webapp. Choose from the list, or specify an ID using an expression.', }, { displayName: 'City', @@ -493,7 +451,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getContactStatuses', }, - description: 'ID of the contact status that the contact belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the contact status that the contact belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Country', @@ -552,7 +511,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getLeadSources', }, - description: 'ID of the source where contact came from. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the source where contact came from. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Lifecycle Stage Name or ID', @@ -562,7 +522,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getLifecycleStages', }, - description: 'ID of the lifecycle stage that the contact belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the lifecycle stage that the contact belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'LinkedIn', @@ -593,7 +554,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getUsers', }, - description: 'ID of the user to whom the contact is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to whom the contact is assigned. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Sales Account Names or IDs', @@ -603,7 +565,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getAccounts', }, - description: 'Accounts which contact belongs to. Choose from the list, or specify IDs using an expression.', + description: + 'Accounts which contact belongs to. Choose from the list, or specify IDs using an expression.', }, { displayName: 'State', @@ -620,7 +583,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getSubscriptionStatuses', }, - description: 'Status of subscription that the contact is in. Choose from the list, or specify an ID using an expression.', + description: + 'Status of subscription that the contact is in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Subscription Types Name or ID', @@ -630,7 +594,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getSubscriptionTypes', }, - description: 'Type of subscription that the contact is in. Choose from the list, or specify an ID using an expression.', + description: + 'Type of subscription that the contact is in. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Territory Name or ID', @@ -640,7 +605,8 @@ export const contactFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTerritories', }, - description: 'ID of the territory that the contact belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the territory that the contact belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Time Zone', diff --git a/packages/nodes-base/nodes/FreshworksCrm/descriptions/DealDescription.ts b/packages/nodes-base/nodes/FreshworksCrm/descriptions/DealDescription.ts index e0f76a5efc2de..fab74fa27fb0c 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/descriptions/DealDescription.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/descriptions/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: [ @@ -64,12 +60,8 @@ export const dealFields: INodeProperties[] = [ default: 0, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, }, @@ -82,12 +74,8 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, }, @@ -99,12 +87,8 @@ export const dealFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'create', - ], + resource: ['deal'], + operation: ['create'], }, }, options: [ @@ -123,7 +107,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCampaigns', }, - description: 'ID of the campaign that landed this deal. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the campaign that landed this deal. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Currency Name or ID', @@ -133,7 +118,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCurrencies', }, - description: 'ID of the currency that the deal belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the currency that the deal belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Deal Payment Status Name or ID', @@ -143,7 +129,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getDealPaymentStatuses', }, - description: 'ID of the mode of payment for the deal. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the mode of payment for the deal. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Deal Pipeline Name or ID', @@ -153,7 +140,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getDealPipelines', }, - description: 'ID of the deal pipeline that it belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the deal pipeline that it belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Deal Product Name or ID', @@ -163,7 +151,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getDealProducts', }, - description: 'ID of the product that the deal belongs to (in a multi-product company). Choose from the list, or specify an ID using an expression.', + description: + 'ID of the product that the deal belongs to (in a multi-product company). Choose from the list, or specify an ID using an expression.', }, { displayName: 'Deal Reason Name or ID', @@ -173,7 +162,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getDealReasons', }, - description: 'ID of the reason for losing the deal. Can only be set if the deal is in \'Lost\' stage. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the reason for losing the deal. Can only be set if the deal is in \'Lost\' stage. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Deal Stage Name or ID', @@ -183,7 +173,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getDealStages', }, - description: 'ID of the deal stage that the deal belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the deal stage that the deal belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Deal Type Name or ID', @@ -193,7 +184,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getDealTypes', }, - description: 'ID of the deal type that the deal belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the deal type that the deal belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Lead Source ID', @@ -210,7 +202,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getUsers', }, - description: 'ID of the user to whom the deal is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to whom the deal is assigned. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Probability', @@ -231,7 +224,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getAccounts', }, - description: 'ID of the account that the deal belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the account that the deal belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Territory Name or ID', @@ -241,7 +235,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTerritories', }, - description: 'ID of the territory that the deal belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the territory that the deal belongs to. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -258,12 +253,8 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'delete', - ], + resource: ['deal'], + operation: ['delete'], }, }, }, @@ -280,12 +271,8 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'get', - ], + resource: ['deal'], + operation: ['get'], }, }, }, @@ -297,15 +284,12 @@ export const dealFields: INodeProperties[] = [ displayName: 'View Name or ID', name: 'view', type: 'options', - 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: [ - 'deal', - ], - operation: [ - 'getAll', - ], + resource: ['deal'], + operation: ['getAll'], }, }, typeOptions: { @@ -321,12 +305,8 @@ export const dealFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'getAll', - ], + resource: ['deal'], + operation: ['getAll'], }, }, }, @@ -341,15 +321,9 @@ export const dealFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['deal'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -366,12 +340,8 @@ export const dealFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], + resource: ['deal'], + operation: ['update'], }, }, }, @@ -383,12 +353,8 @@ export const dealFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'deal', - ], - operation: [ - 'update', - ], + resource: ['deal'], + operation: ['update'], }, }, options: [ @@ -420,7 +386,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCampaigns', }, - description: 'ID of the campaign that landed this deal. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the campaign that landed this deal. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Currency Name or ID', @@ -430,7 +397,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getCurrencies', }, - description: 'ID of the currency that the deal belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the currency that the deal belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Deal Payment Status Name or ID', @@ -440,7 +408,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getDealPaymentStatuses', }, - description: 'ID of the mode of payment for the deal. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the mode of payment for the deal. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Deal Pipeline Name or ID', @@ -450,7 +419,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getDealPipelines', }, - description: 'ID of the deal pipeline that it belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the deal pipeline that it belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Deal Product Name or ID', @@ -460,7 +430,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getDealProducts', }, - description: 'ID of the product that the deal belongs to (in a multi-product company). Choose from the list, or specify an ID using an expression.', + description: + 'ID of the product that the deal belongs to (in a multi-product company). Choose from the list, or specify an ID using an expression.', }, { displayName: 'Deal Reason Name or ID', @@ -470,7 +441,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getDealReasons', }, - description: 'ID of the reason for losing the deal. Can only be set if the deal is in \'Lost\' stage. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the reason for losing the deal. Can only be set if the deal is in \'Lost\' stage. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Deal Stage Name or ID', @@ -480,7 +452,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getDealStages', }, - description: 'ID of the deal stage that the deal belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the deal stage that the deal belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Deal Type Name or ID', @@ -490,7 +463,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getDealTypes', }, - description: 'ID of the deal type that the deal belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the deal type that the deal belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Lead Source ID', @@ -514,7 +488,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getUsers', }, - description: 'ID of the user to whom the deal is assigned. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user to whom the deal is assigned. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Probability', @@ -535,7 +510,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getAccounts', }, - description: 'ID of the account that the deal belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the account that the deal belongs to. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Territory Name or ID', @@ -545,7 +521,8 @@ export const dealFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getTerritories', }, - description: 'ID of the territory that the deal belongs to. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the territory that the deal belongs to. Choose from the list, or specify an ID using an expression.', }, ], }, diff --git a/packages/nodes-base/nodes/FreshworksCrm/descriptions/NoteDescription.ts b/packages/nodes-base/nodes/FreshworksCrm/descriptions/NoteDescription.ts index ba964868f2ee6..a20d0f31d4ac3 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/descriptions/NoteDescription.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/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: [ @@ -55,12 +51,8 @@ export const noteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'create', - ], + resource: ['note'], + operation: ['create'], }, }, }, @@ -87,30 +79,23 @@ export const noteFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'create', - ], + resource: ['note'], + operation: ['create'], }, }, }, { displayName: 'Target ID', name: 'targetable_id', - description: 'ID of the entity for which note is created. The type of entity is selected in "Target Type".', + description: + 'ID of the entity for which note is created. The type of entity is selected in "Target Type".', type: 'string', required: true, default: '', displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'create', - ], + resource: ['note'], + operation: ['create'], }, }, }, @@ -127,12 +112,8 @@ export const noteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'delete', - ], + resource: ['note'], + operation: ['delete'], }, }, }, @@ -149,12 +130,8 @@ export const noteFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'update', - ], + resource: ['note'], + operation: ['update'], }, }, }, @@ -166,12 +143,8 @@ export const noteFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'note', - ], - operation: [ - 'update', - ], + resource: ['note'], + operation: ['update'], }, }, options: [ diff --git a/packages/nodes-base/nodes/FreshworksCrm/descriptions/SalesActivityDescription.ts b/packages/nodes-base/nodes/FreshworksCrm/descriptions/SalesActivityDescription.ts index f7c30416ee8b6..45cdbbccbce4c 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/descriptions/SalesActivityDescription.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/descriptions/SalesActivityDescription.ts @@ -1,6 +1,4 @@ -import { - INodeProperties, -} from 'n8n-workflow'; +import { INodeProperties } from 'n8n-workflow'; export const salesActivityOperations: INodeProperties[] = [ { @@ -10,9 +8,7 @@ export const salesActivityOperations: INodeProperties[] = [ noDataExpression: true, displayOptions: { show: { - resource: [ - 'salesActivity', - ], + resource: ['salesActivity'], }, }, options: [ @@ -60,15 +56,12 @@ export const salesActivityFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getSalesActivityTypes', }, - description: 'ID of a sales activity type for which the sales activity is created. Choose from the list, or specify an ID using an expression.', + description: + 'ID of a sales activity type for which the sales activity is created. Choose from the list, or specify an ID using an expression.', displayOptions: { show: { - resource: [ - 'salesActivity', - ], - operation: [ - 'create', - ], + resource: ['salesActivity'], + operation: ['create'], }, }, }, @@ -81,19 +74,16 @@ export const salesActivityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'salesActivity', - ], - operation: [ - 'create', - ], + resource: ['salesActivity'], + operation: ['create'], }, }, }, { displayName: 'Owner Name or ID', name: 'ownerId', - description: 'ID of the user who owns the sales activity. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user who owns the sales activity. Choose from the list, or specify an ID using an expression.', type: 'options', default: '', typeOptions: { @@ -102,12 +92,8 @@ export const salesActivityFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'salesActivity', - ], - operation: [ - 'create', - ], + resource: ['salesActivity'], + operation: ['create'], }, }, }, @@ -120,12 +106,8 @@ export const salesActivityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'salesActivity', - ], - operation: [ - 'create', - ], + resource: ['salesActivity'], + operation: ['create'], }, }, }, @@ -138,12 +120,8 @@ export const salesActivityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'salesActivity', - ], - operation: [ - 'create', - ], + resource: ['salesActivity'], + operation: ['create'], }, }, }, @@ -170,30 +148,23 @@ export const salesActivityFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'salesActivity', - ], - operation: [ - 'create', - ], + resource: ['salesActivity'], + operation: ['create'], }, }, }, { displayName: 'Target ID', name: 'targetable_id', - description: 'ID of the entity for which the sales activity is created. The type of entity is selected in "Target Type".', + description: + 'ID of the entity for which the sales activity is created. The type of entity is selected in "Target Type".', type: 'string', required: true, default: '', displayOptions: { show: { - resource: [ - 'salesActivity', - ], - operation: [ - 'create', - ], + resource: ['salesActivity'], + operation: ['create'], }, }, }, @@ -205,12 +176,8 @@ export const salesActivityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'salesActivity', - ], - operation: [ - 'create', - ], + resource: ['salesActivity'], + operation: ['create'], }, }, options: [ @@ -222,7 +189,8 @@ export const salesActivityFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getUsers', }, - description: 'ID of the user who created the sales activity. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user who created the sales activity. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Latitude', @@ -260,7 +228,8 @@ export const salesActivityFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getOutcomes', }, - description: 'ID of a sales activity\'s outcome. Choose from the list, or specify an ID using an expression.', + description: + 'ID of a sales activity\'s outcome. Choose from the list, or specify an ID using an expression.', }, ], }, @@ -277,12 +246,8 @@ export const salesActivityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'salesActivity', - ], - operation: [ - 'delete', - ], + resource: ['salesActivity'], + operation: ['delete'], }, }, }, @@ -299,12 +264,8 @@ export const salesActivityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'salesActivity', - ], - operation: [ - 'get', - ], + resource: ['salesActivity'], + operation: ['get'], }, }, }, @@ -320,12 +281,8 @@ export const salesActivityFields: INodeProperties[] = [ description: 'Whether to return all results or only up to a given limit', displayOptions: { show: { - resource: [ - 'salesActivity', - ], - operation: [ - 'getAll', - ], + resource: ['salesActivity'], + operation: ['getAll'], }, }, }, @@ -340,15 +297,9 @@ export const salesActivityFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'salesActivity', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['salesActivity'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -365,12 +316,8 @@ export const salesActivityFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'salesActivity', - ], - operation: [ - 'update', - ], + resource: ['salesActivity'], + operation: ['update'], }, }, }, @@ -382,12 +329,8 @@ export const salesActivityFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'salesActivity', - ], - operation: [ - 'update', - ], + resource: ['salesActivity'], + operation: ['update'], }, }, options: [ @@ -399,7 +342,8 @@ export const salesActivityFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getUsers', }, - description: 'ID of the user who created the sales activity. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user who created the sales activity. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Start Date', @@ -444,7 +388,8 @@ export const salesActivityFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getUsers', }, - description: 'ID of the user who owns the sales activity. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user who owns the sales activity. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Sales Activity Outcome Name or ID', @@ -454,7 +399,8 @@ export const salesActivityFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getOutcomes', }, - description: 'ID of a sales activity\'s outcome. Choose from the list, or specify an ID using an expression.', + description: + 'ID of a sales activity\'s outcome. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Sales Activity Type Name or ID', @@ -464,7 +410,8 @@ export const salesActivityFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getSalesActivityTypes', }, - description: 'ID of a sales activity type for which the sales activity is updated. Choose from the list, or specify an ID using an expression.', + description: + 'ID of a sales activity type for which the sales activity is updated. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Start Date', @@ -478,7 +425,8 @@ export const salesActivityFields: INodeProperties[] = [ name: 'targetable_id', type: 'string', default: '', - description: 'ID of the entity for which the sales activity is updated. The type of entity is selected in "Target Type".', + description: + 'ID of the entity for which the sales activity is updated. The type of entity is selected in "Target Type".', }, { displayName: 'Target Type', diff --git a/packages/nodes-base/nodes/FreshworksCrm/descriptions/SearchDescription.ts b/packages/nodes-base/nodes/FreshworksCrm/descriptions/SearchDescription.ts index ed2a6bb20d14b..fd3ac017f9d95 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/descriptions/SearchDescription.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/descriptions/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: [ @@ -45,12 +41,8 @@ export const searchFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'search', - ], - operation: [ - 'query', - ], + resource: ['search'], + operation: ['query'], }, }, description: 'Enter a term that will be used for searching entities', @@ -81,12 +73,8 @@ export const searchFields: INodeProperties[] = [ default: [], displayOptions: { show: { - resource: [ - 'search', - ], - operation: [ - 'query', - ], + resource: ['search'], + operation: ['query'], }, }, description: 'Enter a term that will be used for searching entities', @@ -98,12 +86,8 @@ export const searchFields: INodeProperties[] = [ default: false, displayOptions: { show: { - resource: [ - 'search', - ], - operation: [ - 'query', - ], + resource: ['search'], + operation: ['query'], }, }, description: 'Whether to return all results or only up to a given limit', @@ -118,15 +102,9 @@ export const searchFields: INodeProperties[] = [ default: 25, displayOptions: { show: { - resource: [ - 'search', - ], - operation: [ - 'query', - ], - returnAll: [ - false, - ], + resource: ['search'], + operation: ['query'], + returnAll: [false], }, }, description: 'Max number of results to return', @@ -150,19 +128,16 @@ export const searchFields: INodeProperties[] = [ { name: 'Custom Field', value: 'customField', - description: 'Only allowed custom fields of type "Text field", "Number", "Dropdown" or "Radio button"', + description: + 'Only allowed custom fields of type "Text field", "Number", "Dropdown" or "Radio button"', }, ], required: true, default: '', displayOptions: { show: { - resource: [ - 'search', - ], - operation: [ - 'lookup', - ], + resource: ['search'], + operation: ['lookup'], }, }, description: 'Field against which the entities have to be searched', @@ -175,15 +150,9 @@ export const searchFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'search', - ], - operation: [ - 'lookup', - ], - searchField: [ - 'customField', - ], + resource: ['search'], + operation: ['lookup'], + searchField: ['customField'], }, }, }, @@ -195,15 +164,9 @@ export const searchFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'search', - ], - operation: [ - 'lookup', - ], - searchField: [ - 'customField', - ], + resource: ['search'], + operation: ['lookup'], + searchField: ['customField'], }, }, }, @@ -215,16 +178,9 @@ export const searchFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'search', - ], - operation: [ - 'lookup', - ], - searchField: [ - 'email', - 'name', - ], + resource: ['search'], + operation: ['lookup'], + searchField: ['email', 'name'], }, }, }, @@ -236,12 +192,8 @@ export const searchFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'search', - ], - operation: [ - 'lookup', - ], + resource: ['search'], + operation: ['lookup'], }, }, options: [ @@ -264,8 +216,8 @@ export const searchFields: INodeProperties[] = [ value: 'sales_account', }, ], - // eslint-disable-next-line n8n-nodes-base/node-param-description-unneeded-backticks - description: `Use 'entities' to query against related entities. You can include multiple entities at once, provided the field is available in both entities or else you'd receive an error response.`, + // eslint-disable-next-line n8n-nodes-base/node-param-description-unneeded-backticks + description: `Use 'entities' to query against related entities. You can include multiple entities at once, provided the field is available in both entities or else you'd receive an error response.`, }, ], }, diff --git a/packages/nodes-base/nodes/FreshworksCrm/descriptions/TaskDescription.ts b/packages/nodes-base/nodes/FreshworksCrm/descriptions/TaskDescription.ts index 5a43c4c2252f5..b23d49eb43570 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/descriptions/TaskDescription.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/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,19 +74,16 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, }, { displayName: 'Owner Name or ID', name: 'ownerId', - 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.', type: 'options', default: '', typeOptions: { @@ -103,12 +92,8 @@ export const taskFields: INodeProperties[] = [ required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, }, @@ -135,30 +120,23 @@ export const taskFields: INodeProperties[] = [ ], displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, }, { displayName: 'Target ID', name: 'targetable_id', - description: 'ID of the entity for which the task is created. The type of entity is selected in "Target Type".', + description: + 'ID of the entity for which the task is created. The type of entity is selected in "Target Type".', type: 'string', default: '', required: true, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, }, @@ -170,12 +148,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'create', - ], + resource: ['task'], + operation: ['create'], }, }, options: [ @@ -187,7 +161,8 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getUsers', }, - description: 'ID of the user who created the task. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user who created the task. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Outcome Name or ID', @@ -197,7 +172,8 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getOutcomes', }, - description: 'ID of the outcome of the task. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the outcome of the task. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Task Type ID', @@ -221,12 +197,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'delete', - ], + resource: ['task'], + operation: ['delete'], }, }, }, @@ -243,12 +215,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'get', - ], + resource: ['task'], + operation: ['get'], }, }, }, @@ -264,12 +232,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'], }, }, }, @@ -284,15 +248,9 @@ export const taskFields: INodeProperties[] = [ }, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], - returnAll: [ - false, - ], + resource: ['task'], + operation: ['getAll'], + returnAll: [false], }, }, }, @@ -304,12 +262,8 @@ export const taskFields: INodeProperties[] = [ placeholder: 'Add Filter', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'getAll', - ], + resource: ['task'], + operation: ['getAll'], }, }, options: [ @@ -376,12 +330,8 @@ export const taskFields: INodeProperties[] = [ default: '', displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, }, @@ -393,12 +343,8 @@ export const taskFields: INodeProperties[] = [ default: {}, displayOptions: { show: { - resource: [ - 'task', - ], - operation: [ - 'update', - ], + resource: ['task'], + operation: ['update'], }, }, options: [ @@ -410,7 +356,8 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getUsers', }, - description: 'ID of the user who created the sales activity. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the user who created the sales activity. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Due Date', @@ -427,7 +374,8 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getOutcomes', }, - description: 'ID of the outcome of the task. Choose from the list, or specify an ID using an expression.', + description: + 'ID of the outcome of the task. Choose from the list, or specify an ID using an expression.', }, { displayName: 'Owner Name or ID', @@ -437,14 +385,16 @@ export const taskFields: INodeProperties[] = [ typeOptions: { loadOptionsMethod: 'getUsers', }, - 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: 'Target ID', name: 'targetable_id', type: 'string', default: '', - description: 'ID of the entity for which the task is updated. The type of entity is selected in "Target Type".', + description: + 'ID of the entity for which the task is updated. The type of entity is selected in "Target Type".', }, { displayName: 'Target Type', diff --git a/packages/nodes-base/nodes/FreshworksCrm/types.d.ts b/packages/nodes-base/nodes/FreshworksCrm/types.d.ts index 4d2534236670f..cada7f7407764 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/types.d.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/types.d.ts @@ -1,7 +1,7 @@ export type FreshworksCrmApiCredentials = { apiKey: string; domain: string; -} +}; export type FreshworksConfigResponse = { [key: string]: T[]; @@ -29,7 +29,7 @@ export type SalesAccounts = { export type ViewsResponse = { filters: View[]; meta: object; -} +}; export type View = { id: number; diff --git a/packages/nodes-base/nodes/Ftp/Ftp.node.ts b/packages/nodes-base/nodes/Ftp/Ftp.node.ts index 2a28687eea3a5..c64c756f118c5 100644 --- a/packages/nodes-base/nodes/Ftp/Ftp.node.ts +++ b/packages/nodes-base/nodes/Ftp/Ftp.node.ts @@ -8,10 +8,7 @@ import { NodeApiError, NodeOperationError, } from 'n8n-workflow'; -import { - basename, - dirname, -} from 'path'; +import { basename, dirname } from 'path'; import ftpClient from 'promise-ftp'; import sftpClient from 'ssh2-sftp-client'; @@ -56,9 +53,7 @@ export class Ftp implements INodeType { required: true, displayOptions: { show: { - protocol: [ - 'ftp', - ], + protocol: ['ftp'], }, }, }, @@ -68,9 +63,7 @@ export class Ftp implements INodeType { required: true, displayOptions: { show: { - protocol: [ - 'sftp', - ], + protocol: ['sftp'], }, }, }, @@ -140,9 +133,7 @@ export class Ftp implements INodeType { displayName: 'Path', displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], }, }, name: 'path', @@ -159,9 +150,7 @@ export class Ftp implements INodeType { placeholder: 'Add Option', displayOptions: { show: { - operation: [ - 'delete', - ], + operation: ['delete'], }, }, default: {}, @@ -177,9 +166,7 @@ export class Ftp implements INodeType { displayName: 'Recursive', displayOptions: { show: { - folder: [ - true, - ], + folder: [true], }, }, name: 'recursive', @@ -197,9 +184,7 @@ export class Ftp implements INodeType { displayName: 'Path', displayOptions: { show: { - operation: [ - 'download', - ], + operation: ['download'], }, }, name: 'path', @@ -213,9 +198,7 @@ export class Ftp implements INodeType { displayName: 'Binary Property', displayOptions: { show: { - operation: [ - 'download', - ], + operation: ['download'], }, }, name: 'binaryPropertyName', @@ -232,9 +215,7 @@ export class Ftp implements INodeType { displayName: 'Old Path', displayOptions: { show: { - operation: [ - 'rename', - ], + operation: ['rename'], }, }, name: 'oldPath', @@ -246,9 +227,7 @@ export class Ftp implements INodeType { displayName: 'New Path', displayOptions: { show: { - operation: [ - 'rename', - ], + operation: ['rename'], }, }, name: 'newPath', @@ -264,9 +243,7 @@ export class Ftp implements INodeType { default: {}, displayOptions: { show: { - operation: [ - 'rename', - ], + operation: ['rename'], }, }, options: [ @@ -275,7 +252,8 @@ export class Ftp implements INodeType { name: 'createDirectories', type: 'boolean', default: false, - description: 'Whether to recursively create destination directory when renaming an existing file or folder', + description: + 'Whether to recursively create destination directory when renaming an existing file or folder', }, ], }, @@ -287,9 +265,7 @@ export class Ftp implements INodeType { displayName: 'Path', displayOptions: { show: { - operation: [ - 'upload', - ], + operation: ['upload'], }, }, name: 'path', @@ -302,9 +278,7 @@ export class Ftp implements INodeType { displayName: 'Binary Data', displayOptions: { show: { - operation: [ - 'upload', - ], + operation: ['upload'], }, }, name: 'binaryData', @@ -317,12 +291,8 @@ export class Ftp implements INodeType { displayName: 'Binary Property', displayOptions: { show: { - operation: [ - 'upload', - ], - binaryData: [ - true, - ], + operation: ['upload'], + binaryData: [true], }, }, name: 'binaryPropertyName', @@ -335,12 +305,8 @@ export class Ftp implements INodeType { displayName: 'File Content', displayOptions: { show: { - operation: [ - 'upload', - ], - binaryData: [ - false, - ], + operation: ['upload'], + binaryData: [false], }, }, name: 'fileContent', @@ -356,9 +322,7 @@ export class Ftp implements INodeType { displayName: 'Path', displayOptions: { show: { - operation: [ - 'list', - ], + operation: ['list'], }, }, name: 'path', @@ -371,21 +335,19 @@ export class Ftp implements INodeType { displayName: 'Recursive', displayOptions: { show: { - operation: [ - 'list', - ], + operation: ['list'], }, }, name: 'recursive', type: 'boolean', default: false, - description: 'Whether to return object representing all directories / objects recursively found within SFTP server', + description: + 'Whether to return object representing all directories / objects recursively found within SFTP server', required: true, }, ], }; - async execute(this: IExecuteFunctions): Promise { const items = this.getInputData(); // const returnData: IDataObject[] = []; @@ -403,7 +365,6 @@ export class Ftp implements INodeType { credentials = await this.getCredentials('ftp'); } try { - let ftp: ftpClient; let sftp: sftpClient; @@ -417,7 +378,6 @@ export class Ftp implements INodeType { privateKey: credentials.privateKey as string | undefined, passphrase: credentials.passphrase as string | undefined, }); - } else { ftp = new ftpClient(); await ftp.connect({ @@ -444,7 +404,6 @@ export class Ftp implements INodeType { items[i] = newItem; if (protocol === 'sftp') { - if (operation === 'list') { const path = this.getNodeParameter('path', i) as string; @@ -452,11 +411,17 @@ export class Ftp implements INodeType { if (recursive) { responseData = await callRecursiveList(path, sftp!, normalizeSFtpItem); - returnItems.push.apply(returnItems, this.helpers.returnJsonArray(responseData as unknown as IDataObject[])); + returnItems.push.apply( + returnItems, + this.helpers.returnJsonArray(responseData as unknown as IDataObject[]), + ); } else { responseData = await sftp!.list(path); - responseData.forEach(item => normalizeSFtpItem(item as sftpClient.FileInfo, path)); - returnItems.push.apply(returnItems, this.helpers.returnJsonArray(responseData as unknown as IDataObject[])); + responseData.forEach((item) => normalizeSFtpItem(item as sftpClient.FileInfo, path)); + returnItems.push.apply( + returnItems, + this.helpers.returnJsonArray(responseData as unknown as IDataObject[]), + ); } } @@ -475,7 +440,9 @@ export class Ftp implements INodeType { if (operation === 'rename') { const oldPath = this.getNodeParameter('oldPath', i) as string; - const { createDirectories = false } = this.getNodeParameter('options', i) as { createDirectories: boolean }; + const { createDirectories = false } = this.getNodeParameter('options', i) as { + createDirectories: boolean; + }; const newPath = this.getNodeParameter('newPath', i) as string; if (createDirectories) { @@ -492,10 +459,16 @@ export class Ftp implements INodeType { responseData = await sftp!.get(path); - const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string; + const dataPropertyNameDownload = this.getNodeParameter( + 'binaryPropertyName', + i, + ) as string; const filePathDownload = this.getNodeParameter('path', i) as string; - items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(responseData as Buffer, filePathDownload); + items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( + responseData as Buffer, + filePathDownload, + ); returnItems.push(items[i]); } @@ -509,20 +482,29 @@ export class Ftp 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 }, + ); } const buffer = await this.helpers.getBinaryDataBuffer(i, propertyNameUpload); await sftp!.put(buffer, remotePath); } else { // Is text file - const buffer = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8') as Buffer; + const buffer = Buffer.from( + this.getNodeParameter('fileContent', i) as string, + 'utf8', + ) as Buffer; await sftp!.put(buffer, remotePath); } @@ -531,7 +513,6 @@ export class Ftp implements INodeType { } if (protocol === 'ftp') { - if (operation === 'list') { const path = this.getNodeParameter('path', i) as string; @@ -539,11 +520,19 @@ export class Ftp implements INodeType { if (recursive) { responseData = await callRecursiveList(path, ftp!, normalizeFtpItem); - returnItems.push.apply(returnItems, this.helpers.returnJsonArray(responseData as unknown as IDataObject[])); + returnItems.push.apply( + returnItems, + this.helpers.returnJsonArray(responseData as unknown as IDataObject[]), + ); } else { responseData = await ftp!.list(path); - responseData.forEach(item => normalizeFtpItem(item as ftpClient.ListingElement, path)); - returnItems.push.apply(returnItems, this.helpers.returnJsonArray(responseData as unknown as IDataObject[])); + responseData.forEach((item) => + normalizeFtpItem(item as ftpClient.ListingElement, path), + ); + returnItems.push.apply( + returnItems, + this.helpers.returnJsonArray(responseData as unknown as IDataObject[]), + ); } } @@ -574,16 +563,21 @@ export class Ftp implements INodeType { // @ts-ignore responseData = Buffer.concat(chunks); - const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string; + const dataPropertyNameDownload = this.getNodeParameter( + 'binaryPropertyName', + i, + ) as string; const filePathDownload = this.getNodeParameter('path', i) as string; - items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(responseData, filePathDownload); + items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( + responseData, + filePathDownload, + ); returnItems.push(items[i]); } if (operation === 'rename') { - const oldPath = this.getNodeParameter('oldPath', i) as string; const newPath = this.getNodeParameter('newPath', i) as string; @@ -603,13 +597,19 @@ export class Ftp 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 }, + ); } const buffer = await this.helpers.getBinaryDataBuffer(i, propertyNameUpload); @@ -627,7 +627,10 @@ export class Ftp implements INodeType { } } else { // Is text file - const buffer = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8') as Buffer; + const buffer = Buffer.from( + this.getNodeParameter('fileContent', i) as string, + 'utf8', + ) as Buffer; try { await ftp!.put(buffer, remotePath); } catch (error) { @@ -650,7 +653,6 @@ export class Ftp implements INodeType { } else { await ftp!.end(); } - } catch (error) { if (this.continueOnFail()) { return this.prepareOutputData([{ json: { error: error.message } }]); @@ -662,11 +664,10 @@ export class Ftp implements INodeType { } } - function normalizeFtpItem(input: ftpClient.ListingElement, path: string, recursive = false) { const item = input as unknown as ReturnFtpItem; item.modifyTime = input.date; - item.path = (!recursive) ? `${path}${path.endsWith('/') ? '' : '/'}${item.name}` : path; + item.path = !recursive ? `${path}${path.endsWith('/') ? '' : '/'}${item.name}` : path; //@ts-ignore item.date = undefined; } @@ -675,10 +676,18 @@ function normalizeSFtpItem(input: sftpClient.FileInfo, path: string, recursive = const item = input as unknown as ReturnFtpItem; item.accessTime = new Date(input.accessTime); item.modifyTime = new Date(input.modifyTime); - item.path = (!recursive) ? `${path}${path.endsWith('/') ? '' : '/'}${item.name}` : path; + item.path = !recursive ? `${path}${path.endsWith('/') ? '' : '/'}${item.name}` : path; } -async function callRecursiveList(path: string, client: sftpClient | ftpClient, normalizeFunction: (input: ftpClient.ListingElement & sftpClient.FileInfo, path: string, recursive?: boolean) => void) { +async function callRecursiveList( + path: string, + client: sftpClient | ftpClient, + normalizeFunction: ( + input: ftpClient.ListingElement & sftpClient.FileInfo, + path: string, + recursive?: boolean, + ) => void, +) { const pathArray: string[] = [path]; let currentPath = path; const directoryItems: sftpClient.FileInfo[] = []; @@ -686,7 +695,8 @@ async function callRecursiveList(path: string, client: sftpClient | ftpClient, n do { // tslint:disable-next-line: array-type - const returnData: sftpClient.FileInfo[] | (string | ftpClient.ListingElement)[] = await client.list(pathArray[index]); + const returnData: sftpClient.FileInfo[] | (string | ftpClient.ListingElement)[] = + await client.list(pathArray[index]); // @ts-ignore returnData.map((item: sftpClient.FileInfo) => { @@ -705,10 +715,8 @@ async function callRecursiveList(path: string, client: sftpClient | ftpClient, n directoryItems.push(item); }); index++; - } while (index <= pathArray.length - 1); - return directoryItems; } diff --git a/packages/nodes-base/nodes/Function/Function.node.ts b/packages/nodes-base/nodes/Function/Function.node.ts index 7f678d2cb2dad..3976e962b0fab 100644 --- a/packages/nodes-base/nodes/Function/Function.node.ts +++ b/packages/nodes-base/nodes/Function/Function.node.ts @@ -16,7 +16,8 @@ export class Function implements INodeType { icon: 'fa:code', group: ['transform'], version: 1, - description: 'Run custom function code which gets executed once and allows you to add, remove, change and replace items', + description: + 'Run custom function code which gets executed once and allows you to add, remove, change and replace items', defaults: { name: 'Function', color: '#FF9922', @@ -61,7 +62,7 @@ return items;`, items = JSON.parse(JSON.stringify(items)); const cleanupData = (inputData: IDataObject): IDataObject => { - Object.keys(inputData).map(key => { + Object.keys(inputData).map((key) => { if (inputData[key] !== null && typeof inputData[key] === 'object') { if (inputData[key]!.constructor.name === 'Object') { // Is regular node.js object so check its data @@ -92,7 +93,7 @@ return items;`, const mode = this.getMode(); const options = { - console: (mode === 'manual') ? 'redirect' : 'inherit', + console: mode === 'manual' ? 'redirect' : 'inherit', sandbox, require: { external: false as boolean | { modules: string[] }, @@ -119,19 +120,28 @@ return items;`, try { // Execute the function code - items = (await vm.run(`module.exports = async function() {${functionCode}\n}()`, __dirname)); + items = await vm.run(`module.exports = async function() {${functionCode}\n}()`, __dirname); items = this.helpers.normalizeItems(items); // Do very basic validation of the data if (items === undefined) { - throw new NodeOperationError(this.getNode(), 'No data got returned. Always return an Array of items!'); + throw new NodeOperationError( + this.getNode(), + 'No data got returned. Always return an Array of items!', + ); } if (!Array.isArray(items)) { - throw new NodeOperationError(this.getNode(), 'Always an Array of items has to be returned!'); + throw new NodeOperationError( + this.getNode(), + 'Always an Array of items has to be returned!', + ); } for (const item of items) { if (item.json === undefined) { - throw new NodeOperationError(this.getNode(), 'All returned items have to contain a property named "json"!'); + throw new NodeOperationError( + this.getNode(), + 'All returned items have to contain a property named "json"!', + ); } if (typeof item.json !== 'object') { throw new NodeOperationError(this.getNode(), 'The json-property has to be an object!'); @@ -141,13 +151,16 @@ return items;`, if (item.binary !== undefined) { if (Array.isArray(item.binary) || typeof item.binary !== 'object') { - throw new NodeOperationError(this.getNode(), 'The binary-property has to be an object!'); + throw new NodeOperationError( + this.getNode(), + 'The binary-property has to be an object!', + ); } } } } catch (error) { if (this.continueOnFail()) { - items=[{json:{ error: error.message }}]; + items = [{ json: { error: error.message } }]; } else { // Try to find the line number which contains the error and attach to error message const stackLines = error.stack.split('\n'); diff --git a/packages/nodes-base/nodes/FunctionItem/FunctionItem.node.ts b/packages/nodes-base/nodes/FunctionItem/FunctionItem.node.ts index eb09ae4cdf34a..97b87a63b6956 100644 --- a/packages/nodes-base/nodes/FunctionItem/FunctionItem.node.ts +++ b/packages/nodes-base/nodes/FunctionItem/FunctionItem.node.ts @@ -60,7 +60,7 @@ return item;`, let item: INodeExecutionData; const cleanupData = (inputData: IDataObject): IDataObject => { - Object.keys(inputData).map(key => { + Object.keys(inputData).map((key) => { if (inputData[key] !== null && typeof inputData[key] === 'object') { if (inputData[key]!.constructor.name === 'Object') { // Is regular node.js object so check its data @@ -102,7 +102,7 @@ return item;`, const mode = this.getMode(); const options = { - console: (mode === 'manual') ? 'redirect' : 'inherit', + console: mode === 'manual' ? 'redirect' : 'inherit', sandbox, require: { external: false as boolean | { modules: string[] }, @@ -115,7 +115,9 @@ return item;`, } if (process.env.NODE_FUNCTION_ALLOW_EXTERNAL) { - options.require.external = { modules: process.env.NODE_FUNCTION_ALLOW_EXTERNAL.split(',') }; + options.require.external = { + modules: process.env.NODE_FUNCTION_ALLOW_EXTERNAL.split(','), + }; } const vm = new NodeVM(options); @@ -130,17 +132,22 @@ return item;`, let jsonData: IDataObject; try { // Execute the function code - jsonData = await vm.run(`module.exports = async function() {${functionCode}\n}()`, __dirname); + jsonData = await vm.run( + `module.exports = async function() {${functionCode}\n}()`, + __dirname, + ); } catch (error) { if (this.continueOnFail()) { - returnData.push({json:{ error: error.message }}); + returnData.push({ json: { error: error.message } }); continue; } else { // Try to find the line number which contains the error and attach to error message const stackLines = error.stack.split('\n'); if (stackLines.length > 0) { stackLines.shift(); - const lineParts = stackLines.find((line: string) => line.includes('FunctionItem')).split(':'); + const lineParts = stackLines + .find((line: string) => line.includes('FunctionItem')) + .split(':'); if (lineParts.length > 2) { const lineNumber = lineParts.splice(-2, 1); if (!isNaN(lineNumber)) { @@ -158,7 +165,10 @@ return item;`, // Do very basic validation of the data if (jsonData === undefined) { - throw new NodeOperationError(this.getNode(), 'No data got returned. Always an object has to be returned!'); + throw new NodeOperationError( + this.getNode(), + 'No data got returned. Always an object has to be returned!', + ); } const returnItem: INodeExecutionData = { diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index b783b94920af9..7dc371cd5aaf2 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -18,7 +18,7 @@ "dev": "npm run watch", "build": "tsc && gulp build:icons && gulp build:translations", "build:translations": "gulp build:translations", - "format": "cd ../.. && node_modules/prettier/bin-prettier.js packages/nodes-base/**/**.ts --write", + "format": "cd ../.. && node_modules/prettier/bin-prettier.js --write \"packages/nodes-base/**/*.ts\"", "lint": "tslint -p tsconfig.json -c tslint.json && cd ../../ && node_modules/eslint/bin/eslint.js packages/nodes-base/nodes packages/nodes-base/credentials", "lintfix": "tslint --fix -p tsconfig.json -c tslint.json && cd ../.. && node_modules/eslint/bin/eslint.js packages/nodes-base/nodes packages/nodes-base/credentials --fix", "watch": "tsc --watch",