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,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,15 +10,22 @@ import {
NodeOperationError,
} from 'n8n-workflow';
export async function postmarkApiRequest(this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions, method : string, endpoint : string, body: any = {}, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
export async function postmarkApiRequest(
this: IExecuteFunctions | IWebhookFunctions | IHookFunctions | ILoadOptionsFunctions,
method: string,
endpoint: string,
// tslint:disable-next-line:no-any
body: any = {},
option: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const credentials = await this.getCredentials('postmarkApi');
let options: OptionsWithUri = {
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-Postmark-Server-Token' : credentials.serverToken,
Accept: 'application/json',
'X-Postmark-Server-Token': credentials.serverToken,
},
method,
body,
@@ -43,9 +45,9 @@ export async function postmarkApiRequest(this: IExecuteFunctions | IWebhookFunct
}
// tslint:disable-next-line: no-any
export function convertTriggerObjectToStringArray (webhookObject : any) : string[] {
export function convertTriggerObjectToStringArray(webhookObject: any): string[] {
const triggers = webhookObject.Triggers;
const webhookEvents : string[] = [];
const webhookEvents: string[] = [];
// Translate Webhook trigger settings to string array
if (triggers.Open.Enabled) {
@@ -81,7 +83,7 @@ export function convertTriggerObjectToStringArray (webhookObject : any) : string
return webhookEvents;
}
export function eventExists (currentEvents : string[], webhookEvents: string[]) {
export function eventExists(currentEvents: string[], webhookEvents: string[]) {
for (const currentEvent of currentEvents) {
if (!webhookEvents.includes(currentEvent)) {
return false;

View File

@@ -1,18 +1,11 @@
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 {
convertTriggerObjectToStringArray,
eventExists,
postmarkApiRequest
postmarkApiRequest,
} from './GenericFunctions';
export class PostmarkTrigger implements INodeType {
@@ -93,9 +86,7 @@ export class PostmarkTrigger implements INodeType {
default: false,
displayOptions: {
show: {
events: [
'open',
],
events: ['open'],
},
},
},
@@ -107,15 +98,11 @@ export class PostmarkTrigger implements INodeType {
default: false,
displayOptions: {
show: {
events: [
'bounce',
'spamComplaint',
],
events: ['bounce', 'spamComplaint'],
},
},
},
],
};
// @ts-ignore (because of request)
@@ -150,7 +137,10 @@ export class PostmarkTrigger implements INodeType {
// If webhooks exist, check if any match current settings
for (const webhook of responseData.Webhooks) {
if (webhook.Url === webhookUrl && eventExists(events, convertTriggerObjectToStringArray(webhook))) {
if (
webhook.Url === webhookUrl &&
eventExists(events, convertTriggerObjectToStringArray(webhook))
) {
webhookData.webhookId = webhook.ID;
// webhook identical to current settings. re-assign webhook id to found webhook.
return true;
@@ -165,24 +155,24 @@ export class PostmarkTrigger implements INodeType {
const endpoint = `/webhooks`;
// tslint:disable-next-line: no-any
const body : any = {
const body: any = {
Url: webhookUrl,
Triggers: {
Open:{
Open: {
Enabled: false,
PostFirstOpenOnly: false,
},
Click:{
Click: {
Enabled: false,
},
Delivery:{
Delivery: {
Enabled: false,
},
Bounce:{
Bounce: {
Enabled: false,
IncludeContent: false,
},
SpamComplaint:{
SpamComplaint: {
Enabled: false,
IncludeContent: false,
},
@@ -210,7 +200,9 @@ export class PostmarkTrigger implements INodeType {
}
if (events.includes('spamComplaint')) {
body.Triggers.SpamComplaint.Enabled = true;
body.Triggers.SpamComplaint.IncludeContent = this.getNodeParameter('includeContent') as boolean;
body.Triggers.SpamComplaint.IncludeContent = this.getNodeParameter(
'includeContent',
) as boolean;
}
if (events.includes('subscriptionChange')) {
body.Triggers.SubscriptionChange.Enabled = true;
@@ -255,9 +247,7 @@ export class PostmarkTrigger implements INodeType {
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
const req = this.getRequestObject();
return {
workflowData: [
this.helpers.returnJsonArray(req.body),
],
workflowData: [this.helpers.returnJsonArray(req.body)],
};
}
}