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

@@ -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: <code>"sendKey1:binaryProperty1,sendKey2:binaryProperty2</code>',
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: <code>"sendKey1:binaryProperty1,sendKey2:binaryProperty2</code>',
},
{
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<INodeExecutionData[][]> {
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];