From b2b5a971885ab663823043ab127575f84d6a78f4 Mon Sep 17 00:00:00 2001 From: brianinoa Date: Mon, 20 Jun 2022 15:22:10 +0200 Subject: [PATCH] :rotating_light: Autofix node linting --- credentials/HttpBinApi.credentials.ts | 30 ++-- nodes/HttpBin/HttpBin.node.ts | 46 +++--- nodes/HttpBin/HttpVerbDescriptions.ts | 220 ++++++++++++-------------- 3 files changed, 143 insertions(+), 153 deletions(-) diff --git a/credentials/HttpBinApi.credentials.ts b/credentials/HttpBinApi.credentials.ts index efd8639..8ccd44f 100644 --- a/credentials/HttpBinApi.credentials.ts +++ b/credentials/HttpBinApi.credentials.ts @@ -4,18 +4,18 @@ import { ICredentialType, IHttpRequestOptions, INodeProperties, -} from "n8n-workflow"; +} from 'n8n-workflow'; export class HttpBinApi implements ICredentialType { - name = "httpbinApi"; - displayName = "HttpBin API"; - documentationUrl = "httpbin"; + name = 'httpbinApi'; + displayName = 'HttpBin API'; + documentationUrl = 'httpbin'; properties: INodeProperties[] = [ { - displayName: "Token", - name: "token", - type: "string", - default: "", + displayName: 'Token', + name: 'token', + type: 'string', + default: '', }, // { // displayName: "API Key", @@ -24,10 +24,10 @@ export class HttpBinApi implements ICredentialType { // default: "", // }, { - displayName: "Domain", - name: "domain", - type: "string", - default: "https://httpbin.org", + displayName: 'Domain', + name: 'domain', + type: 'string', + default: 'https://httpbin.org', }, ]; @@ -41,7 +41,7 @@ export class HttpBinApi implements ICredentialType { authenticate = async ( credentials: ICredentialDataDecryptedObject, - requestOptions: IHttpRequestOptions + requestOptions: IHttpRequestOptions, ): Promise => { const headers = requestOptions.headers || {}; const authentication = { Authorization: `Bearer ${credentials.token}` }; @@ -53,8 +53,8 @@ export class HttpBinApi implements ICredentialType { test: ICredentialTestRequest = { request: { - baseURL: "={{$credentials?.domain}}", - url: "/bearer", + baseURL: '={{$credentials?.domain}}', + url: '/bearer', }, }; } diff --git a/nodes/HttpBin/HttpBin.node.ts b/nodes/HttpBin/HttpBin.node.ts index 3f6fa51..b4454d4 100644 --- a/nodes/HttpBin/HttpBin.node.ts +++ b/nodes/HttpBin/HttpBin.node.ts @@ -1,33 +1,33 @@ -import { INodeType, INodeTypeDescription } from "n8n-workflow"; -import { httpVerbOperations, httpVerbFields } from "./HttpVerbDescriptions"; +import { INodeType, INodeTypeDescription } from 'n8n-workflow'; +import { httpVerbFields, httpVerbOperations } from './HttpVerbDescriptions'; export class HttpBin implements INodeType { description: INodeTypeDescription = { - displayName: "HttpBin", - name: "httpbin", - icon: "file:httpbin.svg", - group: ["transform"], + displayName: 'HttpBin', + name: 'httpbin', + icon: 'file:httpbin.svg', + group: ['transform'], version: 1, subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}', - description: "Interact with HttpBin API", + description: 'Interact with HttpBin API', defaults: { - name: "HttpBin", - color: "#3b4151", + name: 'HttpBin', + color: '#3b4151', }, - inputs: ["main"], - outputs: ["main"], + inputs: ['main'], + outputs: ['main'], credentials: [ { - name: "httpbinApi", + name: 'httpbinApi', required: false, }, ], requestDefaults: { - baseURL: "https://httpbin.org", - url: "", + baseURL: 'https://httpbin.org', + url: '', headers: { - Accept: "application/json", - "Content-Type": "application/json", + Accept: 'application/json', + 'Content-Type': 'application/json', }, }, /** @@ -44,17 +44,17 @@ export class HttpBin implements INodeType { */ properties: [ { - displayName: "Resource", - name: "resource", - type: "options", + displayName: 'Resource', + name: 'resource', + type: 'options', noDataExpression: true, options: [ { - name: "HTTP Verbs", - value: "httpverbs", - } + name: 'HTTP Verbs', + value: 'httpverbs', + }, ], - default: "httpverbs", + default: 'httpverbs', }, ...httpVerbOperations, diff --git a/nodes/HttpBin/HttpVerbDescriptions.ts b/nodes/HttpBin/HttpVerbDescriptions.ts index 03f2df9..df0b8ac 100644 --- a/nodes/HttpBin/HttpVerbDescriptions.ts +++ b/nodes/HttpBin/HttpVerbDescriptions.ts @@ -1,249 +1,239 @@ -import { INodeProperties } from "n8n-workflow"; +import { INodeProperties } from 'n8n-workflow'; -/** - * This maps the operations to when the Resource option HTTP Verbs is selected - */ -export const httpVerbOperations: Array = [ +// This maps the operations to when the Resource option HTTP Verbs is selected +export const httpVerbOperations: INodeProperties[] = [ { - displayName: "Operation", - name: "operation", - type: "options", + displayName: 'Operation', + name: 'operation', + type: 'options', noDataExpression: true, displayOptions: { show: { - resource: ["httpverbs"], + resource: ['httpverbs'], }, }, options: [ { - name: "GET", - value: "get", + name: 'GET', + value: 'get', routing: { request: { - method: "GET", - url: "/get", + method: 'GET', + url: '/get', }, }, }, { - name: "DELETE", - value: "delete", + name: 'DELETE', + value: 'delete', routing: { request: { - method: "DELETE", - url: "/delete", + method: 'DELETE', + url: '/delete', }, }, }, ], - default: "get", + default: 'get', }, ]; -/** - * - * Here we define what to show when the GET Operation is selected - * - * We do that by adding operation: ["get"], to "displayOptions.show" - */ -const getOperation: Array = [ +// Here we define what to show when the GET Operation is selected +// We do that by adding operation: ["get"], to "displayOptions.show" +const getOperation: INodeProperties[] = [ { - name: "typeofData", - default: "queryParameter", - description: "Select type of data to send [Query Parameters]", - displayName: "Type of Data", + name: 'typeofData', + default: 'queryParameter', + description: 'Select type of data to send [Query Parameters]', + displayName: 'Type of Data', displayOptions: { show: { - resource: ["httpverbs"], - operation: ["get"], + resource: ['httpverbs'], + operation: ['get'], }, }, - type: "options", + type: 'options', options: [ { - name: "Query", - value: "queryParameter", + name: 'Query', + value: 'queryParameter', }, ], required: true, }, { - name: "arguments", + name: 'arguments', default: {}, - description: "The request's query parameters", - displayName: "Query Parameters", + description: 'The request\'s query parameters', + displayName: 'Query Parameters', displayOptions: { show: { - resource: ["httpverbs"], - operation: ["get"], + resource: ['httpverbs'], + operation: ['get'], }, }, options: [ { - name: "keyvalue", - displayName: "Key:Value", + name: 'keyvalue', + displayName: 'Key:Value', values: [ { - displayName: "Key", - name: "key", - type: "string", - default: "", + displayName: 'Key', + name: 'key', + type: 'string', + default: '', required: true, - description: "Key of query parameter", + description: 'Key of query parameter', }, { - displayName: "Value", - name: "value", - type: "string", - default: "", + displayName: 'Value', + name: 'value', + type: 'string', + default: '', routing: { send: { - property: "={{$parent.key}}", - type: "query", + property: '={{$parent.key}}', + type: 'query', }, }, required: true, - description: "Value of query parameter", + description: 'Value of query parameter', }, ], }, ], - type: "fixedCollection", + type: 'fixedCollection', typeOptions: { multipleValues: true, }, }, ]; -/** - * - * Here we define what to show when the DELETE Operation is selected - * - * We do that by adding operation: ["delete"], to "displayOptions.show" - */ -const deleteOperation: Array = [ +// Here we define what to show when the DELETE Operation is selected +// We do that by adding operation: ["delete"], to "displayOptions.show" +const deleteOperation: INodeProperties[] = [ { - name: "typeofData", - default: "queryParameter", + name: 'typeofData', + default: 'queryParameter', description: - "Select type of data to send [Query Parameter Arguments, JSON-Body]", - displayName: "Type of Data", + 'Select type of data to send [Query Parameter Arguments, JSON-Body]', + displayName: 'Type of Data', displayOptions: { show: { - resource: ["httpverbs"], - operation: ["delete"], + resource: ['httpverbs'], + operation: ['delete'], }, }, options: [ { - name: "Query", - value: "queryParameter", + name: 'Query', + value: 'queryParameter', }, { - name: "JSON", - value: "jsonData", + name: 'JSON', + value: 'jsonData', }, ], required: true, - type: "options", + type: 'options', }, { - name: "arguments", + name: 'arguments', default: {}, - description: "The request's query parameters", - displayName: "Query Parameters", + description: 'The request\'s query parameters', + displayName: 'Query Parameters', displayOptions: { show: { - resource: ["httpverbs"], - operation: ["delete"], - typeofData: ["queryParameter"], + resource: ['httpverbs'], + operation: ['delete'], + typeofData: ['queryParameter'], }, }, options: [ { - name: "keyvalue", - displayName: "Key:Value", + name: 'keyvalue', + displayName: 'Key:Value', values: [ { - displayName: "Key", - name: "key", - type: "string", - default: "", + displayName: 'Key', + name: 'key', + type: 'string', + default: '', required: true, - description: "Key of query parameter", + description: 'Key of query parameter', }, { - displayName: "Value", - name: "value", - type: "string", - default: "", + displayName: 'Value', + name: 'value', + type: 'string', + default: '', routing: { send: { - property: "={{$parent.key}}", - type: "query", + property: '={{$parent.key}}', + type: 'query', }, }, required: true, - description: "Value of query parameter", + description: 'Value of query parameter', }, ], }, ], - type: "fixedCollection", + type: 'fixedCollection', typeOptions: { multipleValues: true, }, }, { - name: "arguments", + name: 'arguments', default: {}, - description: "The request's JSON properties", - displayName: "JSON Object", + description: 'The request\'s JSON properties', + displayName: 'JSON Object', displayOptions: { show: { - resource: ["httpverbs"], - operation: ["delete"], - typeofData: ["jsonData"], + resource: ['httpverbs'], + operation: ['delete'], + typeofData: ['jsonData'], }, }, options: [ { - name: "keyvalue", - displayName: "Key:Value", + name: 'keyvalue', + displayName: 'Key:Value', values: [ { - displayName: "Key", - name: "key", - type: "string", - default: "", + displayName: 'Key', + name: 'key', + type: 'string', + default: '', required: true, - description: "Key of json property", + description: 'Key of json property', }, { - displayName: "Value", - name: "value", - type: "string", - default: "", + displayName: 'Value', + name: 'value', + type: 'string', + default: '', routing: { send: { - property: "={{$parent.key}}", - type: "body", + property: '={{$parent.key}}', + type: 'body', }, }, required: true, - description: "Value of json property", + description: 'Value of json property', }, ], }, ], - type: "fixedCollection", + type: 'fixedCollection', typeOptions: { multipleValues: true, }, }, ]; -export const httpVerbFields: Array = [ +export const httpVerbFields: INodeProperties[] = [ /* -------------------------------------------------------------------------- */ /* Http Verbs:Get */ /* -------------------------------------------------------------------------- */