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 {
INodeProperties,
} from 'n8n-workflow';
import { INodeProperties } from 'n8n-workflow';
export const contactOperations: INodeProperties[] = [
{
@@ -10,9 +8,7 @@ export const contactOperations: INodeProperties[] = [
noDataExpression: true,
displayOptions: {
show: {
resource: [
'contact',
],
resource: ['contact'],
},
},
options: [
@@ -62,12 +58,8 @@ export const contactFields: INodeProperties[] = [
placeholder: 'name@email.com',
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'create',
],
resource: ['contact'],
operation: ['create'],
},
},
default: '',
@@ -81,16 +73,13 @@ export const contactFields: INodeProperties[] = [
},
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'create',
],
resource: ['contact'],
operation: ['create'],
},
},
default: '',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
description:
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
},
{
displayName: 'Additional Fields',
@@ -100,12 +89,8 @@ export const contactFields: INodeProperties[] = [
default: {},
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'create',
],
resource: ['contact'],
operation: ['create'],
},
},
options: [
@@ -130,7 +115,8 @@ export const contactFields: INodeProperties[] = [
typeOptions: {
loadOptionsMethod: 'getCustomFields',
},
description: 'The end user specified key of the user defined data. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'The end user specified key of the user defined data. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
default: '',
},
{
@@ -148,14 +134,15 @@ export const contactFields: INodeProperties[] = [
displayName: 'Day Of Cycle',
name: 'dayOfCycle',
type: 'string',
description: 'The day on which the contact is in the Autoresponder cycle. null indicates the contacts is not in the cycle.',
description:
'The day on which the contact is in the Autoresponder cycle. null indicates the contacts is not in the cycle.',
default: '',
},
{
displayName: 'IP Address',
name: 'ipAddress',
type: 'string',
description: 'The contact\'s IP address. IPv4 and IPv6 formats are accepted.',
description: "The contact's IP address. IPv4 and IPv6 formats are accepted.",
default: '',
},
{
@@ -184,7 +171,8 @@ export const contactFields: INodeProperties[] = [
displayName: 'Tag Names or IDs',
name: 'tags',
type: 'multiOptions',
description: 'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
description:
'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getTags',
},
@@ -203,12 +191,8 @@ export const contactFields: INodeProperties[] = [
required: true,
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'delete',
],
resource: ['contact'],
operation: ['delete'],
},
},
default: '',
@@ -222,12 +206,8 @@ export const contactFields: INodeProperties[] = [
default: {},
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'delete',
],
resource: ['contact'],
operation: ['delete'],
},
},
options: [
@@ -235,14 +215,16 @@ export const contactFields: INodeProperties[] = [
displayName: 'IP Address',
name: 'ipAddress',
type: 'string',
description: 'This makes it possible to pass the IP from which the contact unsubscribed. Used only if the messageId was send.',
description:
'This makes it possible to pass the IP from which the contact unsubscribed. Used only if the messageId was send.',
default: '',
},
{
displayName: 'Message ID',
name: 'messageId',
type: 'string',
description: 'The ID of a message (such as a newsletter, an autoresponder, or an RSS-newsletter). When passed, this method will simulate the unsubscribe process, as if the contact clicked the unsubscribe link in a given message.',
description:
'The ID of a message (such as a newsletter, an autoresponder, or an RSS-newsletter). When passed, this method will simulate the unsubscribe process, as if the contact clicked the unsubscribe link in a given message.',
default: '',
},
],
@@ -258,12 +240,8 @@ export const contactFields: INodeProperties[] = [
required: true,
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'get',
],
resource: ['contact'],
operation: ['get'],
},
},
default: '',
@@ -277,12 +255,8 @@ export const contactFields: INodeProperties[] = [
default: {},
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'get',
],
resource: ['contact'],
operation: ['get'],
},
},
options: [
@@ -290,7 +264,8 @@ export const contactFields: INodeProperties[] = [
displayName: 'Fields',
name: 'fields',
type: 'string',
description: 'List of fields that should be returned. ID is always returned. Fields should be separated by comma',
description:
'List of fields that should be returned. ID is always returned. Fields should be separated by comma',
default: '',
},
],
@@ -305,12 +280,8 @@ export const contactFields: INodeProperties[] = [
type: 'boolean',
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'getAll',
],
resource: ['contact'],
operation: ['getAll'],
},
},
default: false,
@@ -327,15 +298,9 @@ export const contactFields: INodeProperties[] = [
default: 20,
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'getAll',
],
returnAll: [
false,
],
resource: ['contact'],
operation: ['getAll'],
returnAll: [false],
},
},
},
@@ -347,12 +312,8 @@ export const contactFields: INodeProperties[] = [
default: {},
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'getAll',
],
resource: ['contact'],
operation: ['getAll'],
},
},
options: [
@@ -396,13 +357,15 @@ export const contactFields: INodeProperties[] = [
name: 'exactMatch',
type: 'boolean',
default: false,
description: 'Whether to search for contacts with the exact value of the email and name provided in the query string. Without this flag, matching is done via a standard \'like\' comparison, which may sometimes be slow.',
description:
"Whether to search for contacts with the exact value of the email and name provided in the query string. Without this flag, matching is done via a standard 'like' comparison, which may sometimes be slow.",
},
{
displayName: 'Fields',
name: 'fields',
type: 'string',
description: 'List of fields that should be returned. ID is always returned. Fields should be separated by comma',
description:
'List of fields that should be returned. ID is always returned. Fields should be separated by comma',
default: '',
},
{
@@ -526,12 +489,8 @@ export const contactFields: INodeProperties[] = [
required: true,
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'update',
],
resource: ['contact'],
operation: ['update'],
},
},
default: '',
@@ -545,12 +504,8 @@ export const contactFields: INodeProperties[] = [
default: {},
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'update',
],
resource: ['contact'],
operation: ['update'],
},
},
options: [
@@ -558,7 +513,8 @@ export const contactFields: INodeProperties[] = [
displayName: 'Campaign Name or ID',
name: 'campaignId',
type: 'options',
description: 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
description:
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getCampaigns',
},
@@ -585,7 +541,8 @@ export const contactFields: INodeProperties[] = [
typeOptions: {
loadOptionsMethod: 'getCustomFields',
},
description: 'The end user specified key of the user defined data. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'The end user specified key of the user defined data. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
default: '',
},
{
@@ -603,7 +560,8 @@ export const contactFields: INodeProperties[] = [
displayName: 'Day Of Cycle',
name: 'dayOfCycle',
type: 'string',
description: 'The day on which the contact is in the Autoresponder cycle. null indicates the contacts is not in the cycle.',
description:
'The day on which the contact is in the Autoresponder cycle. null indicates the contacts is not in the cycle.',
default: '',
},
{
@@ -617,7 +575,7 @@ export const contactFields: INodeProperties[] = [
displayName: 'IP Address',
name: 'ipAddress',
type: 'string',
description: 'The contact\'s IP address. IPv4 and IPv6 formats are accepted.',
description: "The contact's IP address. IPv4 and IPv6 formats are accepted.",
default: '',
},
{
@@ -646,7 +604,8 @@ export const contactFields: INodeProperties[] = [
displayName: 'Tag Names or IDs',
name: 'tags',
type: 'multiOptions',
description: 'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
description:
'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getTags',
},
@@ -654,5 +613,4 @@ export const contactFields: INodeProperties[] = [
},
],
},
];

View File

@@ -1,6 +1,4 @@
import {
OptionsWithUri,
} from 'request';
import { OptionsWithUri } from 'request';
import {
IExecuteFunctions,
@@ -9,12 +7,19 @@ import {
IWebhookFunctions,
} from 'n8n-core';
import {
IDataObject, NodeApiError
} from 'n8n-workflow';
export async function getresponseApiRequest(this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
import { IDataObject, NodeApiError } from 'n8n-workflow';
export async function getresponseApiRequest(
this: IWebhookFunctions | IHookFunctions | IExecuteFunctions | 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> {
const authentication = this.getNodeParameter('authentication', 0, 'apiKey') as string;
let options: OptionsWithUri = {
@@ -44,20 +49,33 @@ export async function getresponseApiRequest(this: IWebhookFunctions | IHookFunct
}
}
export async function getResponseApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
export async function getResponseApiRequestAllItems(
this: IExecuteFunctions | ILoadOptionsFunctions,
method: string,
endpoint: string,
// tslint:disable-next-line:no-any
body: any = {},
query: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const returnData: IDataObject[] = [];
let responseData;
query.page = 1;
do {
responseData = await getresponseApiRequest.call(this, method, endpoint, body, query, undefined, { resolveWithFullResponse: true });
responseData = await getresponseApiRequest.call(
this,
method,
endpoint,
body,
query,
undefined,
{ resolveWithFullResponse: true },
);
query.page++;
returnData.push.apply(returnData, responseData.body);
} while (
responseData.headers.TotalPages !== responseData.headers.CurrentPage
);
} while (responseData.headers.TotalPages !== responseData.headers.CurrentPage);
return returnData;
}

View File

@@ -1,6 +1,4 @@
import {
IExecuteFunctions,
} from 'n8n-core';
import { IExecuteFunctions } from 'n8n-core';
import {
IDataObject,
@@ -11,15 +9,9 @@ import {
INodeTypeDescription,
} from 'n8n-workflow';
import {
getresponseApiRequest,
getResponseApiRequestAllItems,
} from './GenericFunctions';
import { getresponseApiRequest, getResponseApiRequestAllItems } from './GenericFunctions';
import {
contactFields,
contactOperations,
} from './ContactDescription';
import { contactFields, contactOperations } from './ContactDescription';
import moment from 'moment-timezone';
@@ -44,9 +36,7 @@ export class GetResponse implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'apiKey',
],
authentication: ['apiKey'],
},
},
},
@@ -55,9 +45,7 @@ export class GetResponse implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'oAuth2',
],
authentication: ['oAuth2'],
},
},
},
@@ -101,15 +89,9 @@ export class GetResponse implements INodeType {
loadOptions: {
// Get all the campaigns to display them to user so that he can
// select them easily
async getCampaigns(
this: ILoadOptionsFunctions,
): Promise<INodePropertyOptions[]> {
async getCampaigns(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const campaigns = await getresponseApiRequest.call(
this,
'GET',
`/campaigns`,
);
const campaigns = await getresponseApiRequest.call(this, 'GET', `/campaigns`);
for (const campaign of campaigns) {
returnData.push({
name: campaign.name as string,
@@ -120,15 +102,9 @@ export class GetResponse implements INodeType {
},
// Get all the tagd to display them to user so that he can
// select them easily
async getTags(
this: ILoadOptionsFunctions,
): Promise<INodePropertyOptions[]> {
async getTags(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const tags = await getresponseApiRequest.call(
this,
'GET',
`/tags`,
);
const tags = await getresponseApiRequest.call(this, 'GET', `/tags`);
for (const tag of tags) {
returnData.push({
name: tag.name as string,
@@ -139,15 +115,9 @@ export class GetResponse implements INodeType {
},
// Get all the custom fields to display them to user so that he can
// select them easily
async getCustomFields(
this: ILoadOptionsFunctions,
): Promise<INodePropertyOptions[]> {
async getCustomFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const customFields = await getresponseApiRequest.call(
this,
'GET',
`/custom-fields`,
);
const customFields = await getresponseApiRequest.call(this, 'GET', `/custom-fields`);
for (const customField of customFields) {
returnData.push({
name: customField.name as string,
@@ -188,7 +158,8 @@ export class GetResponse implements INodeType {
Object.assign(body, additionalFields);
if (additionalFields.customFieldsUi) {
const customFieldValues = (additionalFields.customFieldsUi as IDataObject).customFieldValues as IDataObject[];
const customFieldValues = (additionalFields.customFieldsUi as IDataObject)
.customFieldValues as IDataObject[];
if (customFieldValues) {
body.customFieldValues = customFieldValues;
for (let i = 0; i < customFieldValues.length; i++) {
@@ -212,7 +183,13 @@ export class GetResponse implements INodeType {
Object.assign(qs, options);
responseData = await getresponseApiRequest.call(this, 'DELETE', `/contacts/${contactId}`, {}, qs);
responseData = await getresponseApiRequest.call(
this,
'DELETE',
`/contacts/${contactId}`,
{},
qs,
);
responseData = { success: true };
}
@@ -224,7 +201,13 @@ export class GetResponse implements INodeType {
Object.assign(qs, options);
responseData = await getresponseApiRequest.call(this, 'GET', `/contacts/${contactId}`, {}, qs);
responseData = await getresponseApiRequest.call(
this,
'GET',
`/contacts/${contactId}`,
{},
qs,
);
}
//https://apireference.getresponse.com/?_ga=2.160836350.2102802044.1604719933-1897033509.1604598019#operation/getContactList
if (operation === 'getAll') {
@@ -236,32 +219,23 @@ export class GetResponse implements INodeType {
Object.assign(qs, options);
const isNotQuery = [
'sortBy',
'sortOrder',
'additionalFlags',
'fields',
'exactMatch',
];
const isNotQuery = ['sortBy', 'sortOrder', 'additionalFlags', 'fields', 'exactMatch'];
const isDate = [
'createdOnFrom',
'createdOnTo',
'changeOnFrom',
'changeOnTo',
];
const isDate = ['createdOnFrom', 'createdOnTo', 'changeOnFrom', 'changeOnTo'];
const dateMapToKey: { [key: string]: string; } = {
'createdOnFrom': '[createdOn][from]',
'createdOnTo': '[createdOn][to]',
'changeOnFrom': '[changeOn][from]',
'changeOnTo': '[changeOn][to]',
const dateMapToKey: { [key: string]: string } = {
createdOnFrom: '[createdOn][from]',
createdOnTo: '[createdOn][to]',
changeOnFrom: '[changeOn][from]',
changeOnTo: '[changeOn][to]',
};
for (const key of Object.keys(qs)) {
if (!isNotQuery.includes(key)) {
if (isDate.includes(key)) {
qs[`query${dateMapToKey[key]}`] = moment.tz(qs[key], timezone).format('YYYY-MM-DDTHH:mm:ssZZ');
qs[`query${dateMapToKey[key]}`] = moment
.tz(qs[key], timezone)
.format('YYYY-MM-DDTHH:mm:ssZZ');
} else {
qs[`query[${key}]`] = qs[key];
}
@@ -279,7 +253,13 @@ export class GetResponse implements INodeType {
}
if (returnAll) {
responseData = await getResponseApiRequestAllItems.call(this, 'GET', `/contacts`, {}, qs);
responseData = await getResponseApiRequestAllItems.call(
this,
'GET',
`/contacts`,
{},
qs,
);
} else {
qs.perPage = this.getNodeParameter('limit', i) as number;
responseData = await getresponseApiRequest.call(this, 'GET', `/contacts`, {}, qs);
@@ -287,7 +267,6 @@ export class GetResponse implements INodeType {
}
//https://apireference.getresponse.com/?_ga=2.160836350.2102802044.1604719933-1897033509.1604598019#operation/updateContact
if (operation === 'update') {
const contactId = this.getNodeParameter('contactId', i) as string;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
@@ -297,19 +276,24 @@ export class GetResponse implements INodeType {
Object.assign(body, updateFields);
if (updateFields.customFieldsUi) {
const customFieldValues = (updateFields.customFieldsUi as IDataObject).customFieldValues as IDataObject[];
const customFieldValues = (updateFields.customFieldsUi as IDataObject)
.customFieldValues as IDataObject[];
if (customFieldValues) {
body.customFieldValues = customFieldValues;
delete body.customFieldsUi;
}
}
responseData = await getresponseApiRequest.call(this, 'POST', `/contacts/${contactId}`, body);
responseData = await getresponseApiRequest.call(
this,
'POST',
`/contacts/${contactId}`,
body,
);
}
}
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]);
} else if (responseData !== undefined) {
returnData.push(responseData as IDataObject);
}

View File

@@ -1,7 +1,4 @@
import {
IHookFunctions,
IWebhookFunctions,
} from 'n8n-core';
import { IHookFunctions, IWebhookFunctions } from 'n8n-core';
import {
IDataObject,
@@ -14,10 +11,7 @@ import {
NodeOperationError,
} from 'n8n-workflow';
import {
getresponseApiRequest,
getResponseApiRequestAllItems,
} from './GenericFunctions';
import { getresponseApiRequest, getResponseApiRequestAllItems } from './GenericFunctions';
export class GetResponseTrigger implements INodeType {
description: INodeTypeDescription = {
@@ -39,9 +33,7 @@ export class GetResponseTrigger implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'apiKey',
],
authentication: ['apiKey'],
},
},
},
@@ -50,9 +42,7 @@ export class GetResponseTrigger implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'oAuth2',
],
authentication: ['oAuth2'],
},
},
},
@@ -120,7 +110,8 @@ export class GetResponseTrigger implements INodeType {
displayName: 'List Names or IDs',
name: 'listIds',
type: 'multiOptions',
description: 'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
description:
'Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
typeOptions: {
loadOptionsMethod: 'getLists',
},
@@ -176,7 +167,9 @@ export class GetResponseTrigger implements INodeType {
if (data.url !== webhookUrl) {
if (deleteCurrentSubscription === false) {
throw new NodeApiError(this.getNode(), data, { message: `The webhook (${data.url}) is active in the account. Delete it manually or set the parameter "Delete Current Subscription" to true, and the node will delete it for you.` });
throw new NodeApiError(this.getNode(), data, {
message: `The webhook (${data.url}) is active in the account. Delete it manually or set the parameter "Delete Current Subscription" to true, and the node will delete it for you.`,
});
}
}
} catch (error) {
@@ -195,10 +188,13 @@ export class GetResponseTrigger implements INodeType {
const body = {
url: webhookUrl,
actions: events.reduce((accumulator: { [key: string]: boolean }, currentValue: string) => {
accumulator[currentValue] = true;
return accumulator;
}, {}),
actions: events.reduce(
(accumulator: { [key: string]: boolean }, currentValue: string) => {
accumulator[currentValue] = true;
return accumulator;
},
{},
),
};
await getresponseApiRequest.call(this, 'POST', '/accounts/callbacks', body);
@@ -226,9 +222,7 @@ export class GetResponseTrigger implements INodeType {
}
return {
workflowData: [
this.helpers.returnJsonArray(query),
],
workflowData: [this.helpers.returnJsonArray(query)],
};
}
}