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,7 +1,4 @@
import {
IExecuteFunctions,
} from 'n8n-core';
import { IExecuteFunctions } from 'n8n-core';
import {
IDataObject,
@@ -12,15 +9,9 @@ import {
INodeTypeDescription,
} from 'n8n-workflow';
import {
egoiApiRequest,
egoiApiRequestAllItems,
simplify,
} from './GenericFunctions';
import { egoiApiRequest, egoiApiRequestAllItems, simplify } from './GenericFunctions';
import {
ICreateMemberBody,
} from './Interfaces';
import { ICreateMemberBody } from './Interfaces';
import moment from 'moment-timezone';
@@ -103,16 +94,12 @@ export class Egoi implements INodeType {
},
displayOptions: {
show: {
operation: [
'getAll',
'create',
'update',
'get',
],
operation: ['getAll', 'create', 'update', 'get'],
},
},
default: '',
description: 'ID of list to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'ID of list to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'Email',
@@ -121,9 +108,7 @@ export class Egoi implements INodeType {
placeholder: 'name@email.com',
displayOptions: {
show: {
operation: [
'create',
],
operation: ['create'],
},
},
default: '',
@@ -135,12 +120,8 @@ export class Egoi implements INodeType {
type: 'string',
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'update',
],
resource: ['contact'],
operation: ['update'],
},
},
default: '',
@@ -152,15 +133,13 @@ export class Egoi implements INodeType {
type: 'boolean',
displayOptions: {
show: {
operation: [
'create',
'update',
],
operation: ['create', 'update'],
},
},
default: true,
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
description: 'By default the response just includes the contact ID. If this option gets activated, it will resolve the data automatically.',
description:
'By default the response just includes the contact ID. If this option gets activated, it will resolve the data automatically.',
},
{
displayName: 'Additional Fields',
@@ -169,12 +148,8 @@ export class Egoi implements INodeType {
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'contact',
],
operation: ['create'],
resource: ['contact'],
},
},
default: {},
@@ -214,12 +189,11 @@ export class Egoi implements INodeType {
displayName: 'Field Name or ID',
name: 'field_id',
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: 'getExtraFields',
loadOptionsDependsOn: [
'list',
],
loadOptionsDependsOn: ['list'],
},
default: '',
},
@@ -270,7 +244,7 @@ export class Egoi implements INodeType {
},
],
default: 'active',
description: 'Subscriber\'s current status',
description: "Subscriber's current status",
},
{
displayName: 'Tag Names or IDs',
@@ -280,7 +254,8 @@ export class Egoi implements INodeType {
loadOptionsMethod: 'getListTags',
},
default: [],
description: 'List of tag IDs to be added. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'List of tag IDs to be added. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
],
},
@@ -295,9 +270,7 @@ export class Egoi implements INodeType {
default: {},
displayOptions: {
show: {
operation: [
'update',
],
operation: ['update'],
},
},
options: [
@@ -344,12 +317,11 @@ export class Egoi implements INodeType {
displayName: 'Field Name or ID',
name: 'field_id',
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: 'getExtraFields',
loadOptionsDependsOn: [
'list',
],
loadOptionsDependsOn: ['list'],
},
default: '',
},
@@ -398,10 +370,9 @@ export class Egoi implements INodeType {
name: 'Removed',
value: 'removed',
},
],
default: 'active',
description: 'Subscriber\'s current status',
description: "Subscriber's current status",
},
{
displayName: 'Tag Names or IDs',
@@ -411,7 +382,8 @@ export class Egoi implements INodeType {
loadOptionsMethod: 'getListTags',
},
default: [],
description: 'List of tag IDs to be added. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'List of tag IDs to be added. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
],
},
@@ -431,12 +403,8 @@ export class Egoi implements INodeType {
],
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'contact',
],
operation: ['get'],
resource: ['contact'],
},
},
default: 'id',
@@ -448,15 +416,9 @@ export class Egoi implements INodeType {
type: 'string',
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'get',
],
by: [
'id',
],
resource: ['contact'],
operation: ['get'],
by: ['id'],
},
},
default: '',
@@ -469,15 +431,9 @@ export class Egoi implements INodeType {
placeholder: 'name@email.com',
displayOptions: {
show: {
resource: [
'contact',
],
operation: [
'get',
],
by: [
'email',
],
resource: ['contact'],
operation: ['get'],
by: ['email'],
},
},
default: '',
@@ -489,12 +445,8 @@ export class Egoi implements INodeType {
type: 'boolean',
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'contact',
],
operation: ['getAll'],
resource: ['contact'],
},
},
default: false,
@@ -506,15 +458,9 @@ export class Egoi implements INodeType {
type: 'number',
displayOptions: {
show: {
operation: [
'getAll',
],
resource: [
'contact',
],
returnAll: [
false,
],
operation: ['getAll'],
resource: ['contact'],
returnAll: [false],
},
},
typeOptions: {
@@ -530,17 +476,13 @@ export class Egoi implements INodeType {
type: 'boolean',
displayOptions: {
show: {
operation: [
'get',
'getAll',
],
resource: [
'contact',
],
operation: ['get', 'getAll'],
resource: ['contact'],
},
},
default: true,
description: 'Whether to return a simplified version of the response instead of the raw data',
description:
'Whether to return a simplified version of the response instead of the raw data',
},
],
};
@@ -595,7 +537,6 @@ export class Egoi implements INodeType {
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
let responseData;
const returnData: IDataObject[] = [];
const items = this.getInputData();
@@ -622,11 +563,14 @@ export class Egoi implements INodeType {
};
if (additionalFields.birth_date) {
additionalFields.birth_date = moment(additionalFields.birth_date as string).format('YYYY-MM-DD');
additionalFields.birth_date = moment(additionalFields.birth_date as string).format(
'YYYY-MM-DD',
);
}
if (additionalFields.extraFieldsUi) {
const extraFields = (additionalFields.extraFieldsUi as IDataObject).extraFieldValues as IDataObject[];
const extraFields = (additionalFields.extraFieldsUi as IDataObject)
.extraFieldValues as IDataObject[];
if (extraFields) {
body.extra = extraFields as unknown as [];
}
@@ -634,24 +578,37 @@ export class Egoi implements INodeType {
Object.assign(body.base, additionalFields);
responseData = await egoiApiRequest.call(this, 'POST', `/lists/${listId}/contacts`, body);
responseData = await egoiApiRequest.call(
this,
'POST',
`/lists/${listId}/contacts`,
body,
);
const contactId = responseData.contact_id;
if (additionalFields.tagIds) {
const tags = additionalFields.tagIds as string[];
for (const tag of tags) {
await egoiApiRequest.call(this, 'POST', `/lists/${listId}/contacts/actions/attach-tag`, { tag_id: tag, contacts: [contactId] });
await egoiApiRequest.call(
this,
'POST',
`/lists/${listId}/contacts/actions/attach-tag`,
{ tag_id: tag, contacts: [contactId] },
);
}
}
if (resolveData) {
responseData = await egoiApiRequest.call(this, 'GET', `/lists/${listId}/contacts/${contactId}`);
responseData = await egoiApiRequest.call(
this,
'GET',
`/lists/${listId}/contacts/${contactId}`,
);
}
}
if (operation === 'get') {
const listId = this.getNodeParameter('list', i) as string;
const simple = this.getNodeParameter('simple', i) as boolean;
@@ -689,7 +646,6 @@ export class Egoi implements INodeType {
}
if (operation === 'getAll') {
const listId = this.getNodeParameter('list', i) as string;
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
@@ -697,13 +653,23 @@ export class Egoi implements INodeType {
const simple = this.getNodeParameter('simple', i) as boolean;
if (returnAll) {
responseData = await egoiApiRequestAllItems.call(this, 'items', 'GET', `/lists/${listId}/contacts`, {});
responseData = await egoiApiRequestAllItems.call(
this,
'items',
'GET',
`/lists/${listId}/contacts`,
{},
);
} else {
const limit = this.getNodeParameter('limit', i) as number;
responseData = await egoiApiRequest.call(this, 'GET', `/lists/${listId}/contacts`, {}, { limit });
responseData = await egoiApiRequest.call(
this,
'GET',
`/lists/${listId}/contacts`,
{},
{ limit },
);
responseData = responseData.items;
}
@@ -720,17 +686,19 @@ export class Egoi implements INodeType {
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const body: ICreateMemberBody = {
base: {
},
base: {},
extra: [],
};
if (updateFields.birth_date) {
updateFields.birth_date = moment(updateFields.birth_date as string).format('YYYY-MM-DD');
updateFields.birth_date = moment(updateFields.birth_date as string).format(
'YYYY-MM-DD',
);
}
if (updateFields.extraFieldsUi) {
const extraFields = (updateFields.extraFieldsUi as IDataObject).extraFieldValues as IDataObject[];
const extraFields = (updateFields.extraFieldsUi as IDataObject)
.extraFieldValues as IDataObject[];
if (extraFields) {
body.extra = extraFields as unknown as [];
}
@@ -738,17 +706,31 @@ export class Egoi implements INodeType {
Object.assign(body.base, updateFields);
responseData = await egoiApiRequest.call(this, 'PATCH', `/lists/${listId}/contacts/${contactId}`, body);
responseData = await egoiApiRequest.call(
this,
'PATCH',
`/lists/${listId}/contacts/${contactId}`,
body,
);
if (updateFields.tagIds) {
const tags = updateFields.tagIds as string[];
for (const tag of tags) {
await egoiApiRequest.call(this, 'POST', `/lists/${listId}/contacts/actions/attach-tag`, { tag_id: tag, contacts: [contactId] });
await egoiApiRequest.call(
this,
'POST',
`/lists/${listId}/contacts/actions/attach-tag`,
{ tag_id: tag, contacts: [contactId] },
);
}
}
if (resolveData) {
responseData = await egoiApiRequest.call(this, 'GET', `/lists/${listId}/contacts/${contactId}`);
responseData = await egoiApiRequest.call(
this,
'GET',
`/lists/${listId}/contacts/${contactId}`,
);
}
}
}
@@ -757,11 +739,9 @@ export class Egoi implements INodeType {
throw error;
} else {
// Return the actual reason as error
returnData.push(
{
error: error.message,
},
);
returnData.push({
error: error.message,
});
continue;
}
}