refactor: Format nodes-base package (A-F) (#3800)

* 🔨 prettier formated nodes - A

* 🔨 prettier formated nodes - B

*  prettier formated nodes - C

*  prettier formated nodes - D

*  prettier formated nodes - E-F

* 🎨 Adjust nodes-base formatting command (#3805)

* Format additional files in nodes A-F (#3811)

*  fixes

* 🎨 Add Mindee to ignored dirs

Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
Michael Kret
2022-08-01 23:47:55 +03:00
committed by GitHub
parent 2c17e6f3ca
commit 0ecbb4a19d
411 changed files with 12906 additions and 20148 deletions

View File

@@ -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;
}

View File

@@ -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 brandfetchApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
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<any> {
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);
}