n8n-3867-progressively-apply-prettier-to-all (#3873)

* 🔨 formatting nodes with prettier
This commit is contained in:
Michael Kret
2022-08-17 18:50:24 +03:00
committed by GitHub
parent f2d326c7f0
commit 91d7e16c81
1072 changed files with 42357 additions and 59109 deletions

View File

@@ -1,6 +1,4 @@
import {
IExecuteFunctions,
} from 'n8n-core';
import { IExecuteFunctions } from 'n8n-core';
import {
IBinaryKeyData,
@@ -20,29 +18,15 @@ import {
parseRawEmail,
} from './GenericFunctions';
import {
messageFields,
messageOperations,
} from './MessageDescription';
import { messageFields, messageOperations } from './MessageDescription';
import {
messageLabelFields,
messageLabelOperations,
} from './MessageLabelDescription';
import { messageLabelFields, messageLabelOperations } from './MessageLabelDescription';
import {
labelFields,
labelOperations,
} from './LabelDescription';
import { labelFields, labelOperations } from './LabelDescription';
import {
draftFields,
draftOperations,
} from './DraftDescription';
import { draftFields, draftOperations } from './DraftDescription';
import {
isEmpty,
} from 'lodash';
import { isEmpty } from 'lodash';
export interface IEmail {
from?: string;
@@ -83,9 +67,7 @@ export class Gmail implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'serviceAccount',
],
authentication: ['serviceAccount'],
},
},
},
@@ -94,9 +76,7 @@ export class Gmail implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'oAuth2',
],
authentication: ['oAuth2'],
},
},
},
@@ -170,9 +150,7 @@ export class Gmail implements INodeType {
loadOptions: {
// Get all the labels to display them to user so that he can
// select them easily
async getLabels(
this: ILoadOptionsFunctions,
): Promise<INodePropertyOptions[]> {
async getLabels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const labels = await googleApiRequestAllItems.call(
this,
@@ -212,7 +190,10 @@ export class Gmail implements INodeType {
//https://developers.google.com/gmail/api/v1/reference/users/labels/create
const labelName = this.getNodeParameter('name', i) as string;
const labelListVisibility = this.getNodeParameter('labelListVisibility', i) as string;
const messageListVisibility = this.getNodeParameter('messageListVisibility', i) as string;
const messageListVisibility = this.getNodeParameter(
'messageListVisibility',
i,
) as string;
method = 'POST';
endpoint = '/gmail/v1/users/me/labels';
@@ -233,7 +214,6 @@ export class Gmail implements INodeType {
endpoint = `/gmail/v1/users/me/labels/${labelId}`;
responseData = await googleApiRequest.call(this, method, endpoint, body, qs);
responseData = { success: true };
}
if (operation === 'get') {
// https://developers.google.com/gmail/api/v1/reference/users/labels/get
@@ -328,15 +308,20 @@ export class Gmail implements INodeType {
const attachmentsUi = additionalFields.attachmentsUi as IDataObject;
const attachmentsBinary = [];
if (!isEmpty(attachmentsUi)) {
if (attachmentsUi.hasOwnProperty('attachmentsBinary')
&& !isEmpty(attachmentsUi.attachmentsBinary)
&& items[i].binary) {
if (
attachmentsUi.hasOwnProperty('attachmentsBinary') &&
!isEmpty(attachmentsUi.attachmentsBinary) &&
items[i].binary
) {
// @ts-ignore
for (const { property } of attachmentsUi.attachmentsBinary as IDataObject[]) {
for (const binaryProperty of (property as string).split(',')) {
if (items[i].binary![binaryProperty] !== undefined) {
const binaryData = items[i].binary![binaryProperty];
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty);
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(
i,
binaryProperty,
);
attachmentsBinary.push({
name: binaryData.fileName || 'unknown',
content: binaryDataBuffer,
@@ -356,7 +341,7 @@ export class Gmail implements INodeType {
}
const email: IEmail = {
from: additionalFields.senderName as string || '',
from: (additionalFields.senderName as string) || '',
to: toStr,
cc: ccStr,
bcc: bccStr,
@@ -365,7 +350,7 @@ export class Gmail implements INodeType {
attachments: attachmentsList,
};
if (this.getNodeParameter('includeHtml', i, false) as boolean === true) {
if ((this.getNodeParameter('includeHtml', i, false) as boolean) === true) {
email.htmlBody = this.getNodeParameter('htmlMessage', i) as string;
}
@@ -379,7 +364,6 @@ export class Gmail implements INodeType {
responseData = await googleApiRequest.call(this, method, endpoint, body, qs);
}
if (operation === 'reply') {
const id = this.getNodeParameter('messageId', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
@@ -415,15 +399,20 @@ export class Gmail implements INodeType {
const attachmentsUi = additionalFields.attachmentsUi as IDataObject;
const attachmentsBinary = [];
if (!isEmpty(attachmentsUi)) {
if (attachmentsUi.hasOwnProperty('attachmentsBinary')
&& !isEmpty(attachmentsUi.attachmentsBinary)
&& items[i].binary) {
if (
attachmentsUi.hasOwnProperty('attachmentsBinary') &&
!isEmpty(attachmentsUi.attachmentsBinary) &&
items[i].binary
) {
// @ts-ignore
for (const { property } of attachmentsUi.attachmentsBinary as IDataObject[]) {
for (const binaryProperty of (property as string).split(',')) {
if (items[i].binary![binaryProperty] !== undefined) {
const binaryData = items[i].binary![binaryProperty];
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty);
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(
i,
binaryProperty,
);
attachmentsBinary.push({
name: binaryData.fileName || 'unknown',
content: binaryDataBuffer,
@@ -458,7 +447,7 @@ export class Gmail implements INodeType {
}
const email: IEmail = {
from: additionalFields.senderName as string || '',
from: (additionalFields.senderName as string) || '',
to: toStr,
cc: ccStr,
bcc: bccStr,
@@ -467,7 +456,7 @@ export class Gmail implements INodeType {
attachments: attachmentsList,
};
if (this.getNodeParameter('includeHtml', i, false) as boolean === true) {
if ((this.getNodeParameter('includeHtml', i, false) as boolean) === true) {
email.htmlBody = this.getNodeParameter('htmlMessage', i) as string;
}
@@ -505,9 +494,14 @@ export class Gmail implements INodeType {
let nodeExecutionData: INodeExecutionData;
if (format === 'resolved') {
const dataPropertyNameDownload = additionalFields.dataPropertyAttachmentsPrefixName as string || 'attachment_';
const dataPropertyNameDownload =
(additionalFields.dataPropertyAttachmentsPrefixName as string) || 'attachment_';
nodeExecutionData = await parseRawEmail.call(this, responseData, dataPropertyNameDownload);
nodeExecutionData = await parseRawEmail.call(
this,
responseData,
dataPropertyNameDownload,
);
} else {
nodeExecutionData = {
json: responseData,
@@ -558,7 +552,6 @@ export class Gmail implements INodeType {
const format = additionalFields.format || 'resolved';
if (format !== 'ids') {
if (format === 'resolved') {
qs.format = 'raw';
} else {
@@ -575,9 +568,14 @@ export class Gmail implements INodeType {
);
if (format === 'resolved') {
const dataPropertyNameDownload = additionalFields.dataPropertyAttachmentsPrefixName as string || 'attachment_';
const dataPropertyNameDownload =
(additionalFields.dataPropertyAttachmentsPrefixName as string) || 'attachment_';
responseData[i] = await parseRawEmail.call(this, responseData[i], dataPropertyNameDownload);
responseData[i] = await parseRawEmail.call(
this,
responseData[i],
dataPropertyNameDownload,
);
}
}
}
@@ -585,7 +583,6 @@ export class Gmail implements INodeType {
if (format !== 'resolved') {
responseData = this.helpers.returnJsonArray(responseData);
}
}
if (operation === 'delete') {
// https://developers.google.com/gmail/api/v1/reference/users/messages/delete
@@ -639,14 +636,19 @@ export class Gmail implements INodeType {
const attachmentsBinary = [];
if (!isEmpty(attachmentsUi)) {
if (!isEmpty(attachmentsUi)) {
if (attachmentsUi.hasOwnProperty('attachmentsBinary')
&& !isEmpty(attachmentsUi.attachmentsBinary)
&& items[i].binary) {
if (
attachmentsUi.hasOwnProperty('attachmentsBinary') &&
!isEmpty(attachmentsUi.attachmentsBinary) &&
items[i].binary
) {
for (const { property } of attachmentsUi.attachmentsBinary as IDataObject[]) {
for (const binaryProperty of (property as string).split(',')) {
if (items[i].binary![binaryProperty] !== undefined) {
const binaryData = items[i].binary![binaryProperty];
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty);
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(
i,
binaryProperty,
);
attachmentsBinary.push({
name: binaryData.fileName || 'unknown',
content: binaryDataBuffer,
@@ -676,7 +678,7 @@ export class Gmail implements INodeType {
attachments: attachmentsList,
};
if (this.getNodeParameter('includeHtml', i, false) as boolean === true) {
if ((this.getNodeParameter('includeHtml', i, false) as boolean) === true) {
email.htmlBody = this.getNodeParameter('htmlMessage', i) as string;
}
@@ -713,9 +715,14 @@ export class Gmail implements INodeType {
let nodeExecutionData: INodeExecutionData;
if (format === 'resolved') {
const dataPropertyNameDownload = additionalFields.dataPropertyAttachmentsPrefixName as string || 'attachment_';
const dataPropertyNameDownload =
(additionalFields.dataPropertyAttachmentsPrefixName as string) || 'attachment_';
nodeExecutionData = await parseRawEmail.call(this, responseData.message, dataPropertyNameDownload);
nodeExecutionData = await parseRawEmail.call(
this,
responseData.message,
dataPropertyNameDownload,
);
// Add the draft-id
nodeExecutionData.json.messageId = nodeExecutionData.json.id;
@@ -780,7 +787,6 @@ export class Gmail implements INodeType {
}
for (let i = 0; i < responseData.length; i++) {
responseData[i] = await googleApiRequest.call(
this,
'GET',
@@ -790,9 +796,14 @@ export class Gmail implements INodeType {
);
if (format === 'resolved') {
const dataPropertyNameDownload = additionalFields.dataPropertyAttachmentsPrefixName as string || 'attachment_';
const dataPropertyNameDownload =
(additionalFields.dataPropertyAttachmentsPrefixName as string) || 'attachment_';
const id = responseData[i].id;
responseData[i] = await parseRawEmail.call(this, responseData[i].message, dataPropertyNameDownload);
responseData[i] = await parseRawEmail.call(
this,
responseData[i].message,
dataPropertyNameDownload,
);
// Add the draft-id
responseData[i].json.messageId = responseData[i].json.id;