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

@@ -8,9 +8,7 @@ import {
NodeOperationError,
} from 'n8n-workflow';
import {
IExecuteFunctions,
} from 'n8n-core';
import { IExecuteFunctions } from 'n8n-core';
import {
capitalize,
@@ -19,14 +17,9 @@ import {
// validateJSON,
} from './GenericFunctions';
import {
ICreateContactBody,
} from './ContactInterface';
import { ICreateContactBody } from './ContactInterface';
import {
contactFields,
contactOperations,
} from './ContactDescription';
import { contactFields, contactOperations } from './ContactDescription';
enum Status {
Open = 2,
@@ -126,9 +119,7 @@ export class Freshdesk implements INodeType {
required: true,
displayOptions: {
show: {
resource: [
'ticket',
],
resource: ['ticket'],
},
},
options: [
@@ -172,44 +163,46 @@ export class Freshdesk implements INodeType {
required: true,
displayOptions: {
show: {
resource: [
'ticket',
],
operation: [
'create',
],
resource: ['ticket'],
operation: ['create'],
},
},
options: [
{
name: 'Email',
value: 'email',
description: 'Email address of the requester. If no contact exists with this email address in Freshdesk, it will be added as a new contact.',
description:
'Email address of the requester. If no contact exists with this email address in Freshdesk, it will be added as a new contact.',
},
{
name: 'Facebook ID',
value: 'facebookId',
description: 'Facebook ID of the requester. If no contact exists with this facebook_id, then a new contact will be created.',
description:
'Facebook ID of the requester. If no contact exists with this facebook_id, then a new contact will be created.',
},
{
name: 'Phone',
value: 'phone',
description: 'Phone number of the requester. If no contact exists with this phone number in Freshdesk, it will be added as a new contact. If the phone number is set and the email address is not, then the name attribute is mandatory.',
description:
'Phone number of the requester. If no contact exists with this phone number in Freshdesk, it will be added as a new contact. If the phone number is set and the email address is not, then the name attribute is mandatory.',
},
{
name: 'Requester ID',
value: 'requesterId',
description: 'User ID of the requester. For existing contacts, the requester_id can be passed instead of the requester\'s email.',
description:
"User ID of the requester. For existing contacts, the requester_id can be passed instead of the requester's email.",
},
{
name: 'Twitter ID',
value: 'twitterId',
description: 'Twitter handle of the requester. If no contact exists with this handle in Freshdesk, it will be added as a new contact.',
description:
'Twitter handle of the requester. If no contact exists with this handle in Freshdesk, it will be added as a new contact.',
},
{
name: 'Unique External ID',
value: 'uniqueExternalId',
description: 'External ID of the requester. If no contact exists with this external ID in Freshdesk, they will be added as a new contact.',
description:
'External ID of the requester. If no contact exists with this external ID in Freshdesk, they will be added as a new contact.',
},
],
default: 'requesterId',
@@ -221,12 +214,8 @@ export class Freshdesk implements INodeType {
required: true,
displayOptions: {
show: {
resource: [
'ticket',
],
operation: [
'create',
],
resource: ['ticket'],
operation: ['create'],
},
},
default: '',
@@ -239,12 +228,8 @@ export class Freshdesk implements INodeType {
required: true,
displayOptions: {
show: {
resource: [
'ticket',
],
operation: [
'create',
],
resource: ['ticket'],
operation: ['create'],
},
},
options: [
@@ -274,12 +259,8 @@ export class Freshdesk implements INodeType {
required: true,
displayOptions: {
show: {
resource: [
'ticket',
],
operation: [
'create',
],
resource: ['ticket'],
operation: ['create'],
},
},
options: [
@@ -309,12 +290,8 @@ export class Freshdesk implements INodeType {
required: true,
displayOptions: {
show: {
resource: [
'ticket',
],
operation: [
'create',
],
resource: ['ticket'],
operation: ['create'],
},
},
options: [
@@ -375,12 +352,8 @@ export class Freshdesk implements INodeType {
default: {},
displayOptions: {
show: {
resource: [
'ticket',
],
operation: [
'create',
],
resource: ['ticket'],
operation: ['create'],
},
},
options: [
@@ -392,14 +365,16 @@ export class Freshdesk implements INodeType {
typeOptions: {
loadOptionsMethod: 'getAgents',
},
description: 'ID of the agent to whom the ticket has been assigned. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'ID of the agent to whom the ticket has been assigned. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'CC Emails',
name: 'ccEmails',
type: 'string',
default: '',
description: 'Separated by a comma (,) email addresses added in the \'cc\' field of the incoming ticket email',
description:
"Separated by a comma (,) email addresses added in the 'cc' field of the incoming ticket email",
},
{
displayName: 'Company Name or ID',
@@ -409,7 +384,8 @@ export class Freshdesk implements INodeType {
typeOptions: {
loadOptionsMethod: 'getCompanies',
},
description: 'Company ID of the requester. This attribute can only be set if the Multiple Companies feature is enabled (Estate plan and above). Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'Company ID of the requester. This attribute can only be set if the Multiple Companies feature is enabled (Estate plan and above). Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'Description',
@@ -434,7 +410,8 @@ export class Freshdesk implements INodeType {
name: 'emailConfigId',
type: 'number',
default: '',
description: 'ID of email config which is used for this ticket. (i.e., support@yourcompany.com/sales@yourcompany.com) If product_id is given and email_config_id is not given, product\'s primary email_config_id will be set.',
description:
"ID of email config which is used for this ticket. (i.e., support@yourcompany.com/sales@yourcompany.com) If product_id is given and email_config_id is not given, product's primary email_config_id will be set.",
},
{
displayName: 'FR Due By',
@@ -451,7 +428,8 @@ export class Freshdesk implements INodeType {
typeOptions: {
loadOptionsMethod: 'getGroups',
},
description: 'ID of the group to which the ticket has been assigned. The default value is the ID of the group that is associated with the given email_config_id. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'ID of the group to which the ticket has been assigned. The default value is the ID of the group that is associated with the given email_config_id. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'Name',
@@ -469,7 +447,8 @@ export class Freshdesk implements INodeType {
typeOptions: {
loadOptionsMethod: 'getProducts',
},
description: 'ID of the product to which the ticket is associated. It will be ignored if the email_config_id attribute is set in the request. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'ID of the product to which the ticket is associated. It will be ignored if the email_config_id attribute is set in the request. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'Subject',
@@ -491,7 +470,8 @@ export class Freshdesk implements INodeType {
name: 'type',
type: 'options',
default: 'Question',
description: 'Helps categorize the ticket according to the different kinds of issues your support team deals with',
description:
'Helps categorize the ticket according to the different kinds of issues your support team deals with',
options: [
{
name: 'Feature Request',
@@ -598,12 +578,8 @@ export class Freshdesk implements INodeType {
required: true,
displayOptions: {
show: {
resource: [
'ticket',
],
operation: [
'update',
],
resource: ['ticket'],
operation: ['update'],
},
},
default: '',
@@ -616,12 +592,8 @@ export class Freshdesk implements INodeType {
default: {},
displayOptions: {
show: {
resource: [
'ticket',
],
operation: [
'update',
],
resource: ['ticket'],
operation: ['update'],
},
},
options: [
@@ -633,14 +605,16 @@ export class Freshdesk implements INodeType {
typeOptions: {
loadOptionsMethod: 'getAgents',
},
description: 'ID of the agent to whom the ticket has been assigned. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'ID of the agent to whom the ticket has been assigned. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'CC Emails',
name: 'ccEmails',
type: 'string',
default: '',
description: 'Separated by a comma (,) email addresses added in the \'cc\' field of the incoming ticket email',
description:
"Separated by a comma (,) email addresses added in the 'cc' field of the incoming ticket email",
},
{
displayName: 'Company Name or ID',
@@ -650,7 +624,8 @@ export class Freshdesk implements INodeType {
typeOptions: {
loadOptionsMethod: 'getCompanies',
},
description: 'Company ID of the requester. This attribute can only be set if the Multiple Companies feature is enabled (Estate plan and above). Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'Company ID of the requester. This attribute can only be set if the Multiple Companies feature is enabled (Estate plan and above). Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'Due By',
@@ -664,7 +639,8 @@ export class Freshdesk implements INodeType {
name: 'emailConfigId',
type: 'number',
default: '',
description: 'ID of email config which is used for this ticket. (i.e., support@yourcompany.com/sales@yourcompany.com) If product_id is given and email_config_id is not given, product\'s primary email_config_id will be set.',
description:
"ID of email config which is used for this ticket. (i.e., support@yourcompany.com/sales@yourcompany.com) If product_id is given and email_config_id is not given, product's primary email_config_id will be set.",
},
{
displayName: 'FR Due By',
@@ -681,7 +657,8 @@ export class Freshdesk implements INodeType {
typeOptions: {
loadOptionsMethod: 'getGroups',
},
description: 'ID of the group to which the ticket has been assigned. The default value is the ID of the group that is associated with the given email_config_id. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'ID of the group to which the ticket has been assigned. The default value is the ID of the group that is associated with the given email_config_id. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'Name',
@@ -699,7 +676,8 @@ export class Freshdesk implements INodeType {
typeOptions: {
loadOptionsMethod: 'getProducts',
},
description: 'ID of the product to which the ticket is associated. It will be ignored if the email_config_id attribute is set in the request. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'ID of the product to which the ticket is associated. It will be ignored if the email_config_id attribute is set in the request. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
},
{
displayName: 'Priority',
@@ -734,32 +712,38 @@ export class Freshdesk implements INodeType {
{
name: 'Email',
value: 'email',
description: 'Email address of the requester. If no contact exists with this email address in Freshdesk, it will be added as a new contact.',
description:
'Email address of the requester. If no contact exists with this email address in Freshdesk, it will be added as a new contact.',
},
{
name: 'Facebook ID',
value: 'facebookId',
description: 'Facebook ID of the requester. If no contact exists with this facebook_id, then a new contact will be created.',
description:
'Facebook ID of the requester. If no contact exists with this facebook_id, then a new contact will be created.',
},
{
name: 'Phone',
value: 'phone',
description: 'Phone number of the requester. If no contact exists with this phone number in Freshdesk, it will be added as a new contact. If the phone number is set and the email address is not, then the name attribute is mandatory.',
description:
'Phone number of the requester. If no contact exists with this phone number in Freshdesk, it will be added as a new contact. If the phone number is set and the email address is not, then the name attribute is mandatory.',
},
{
name: 'Requester ID',
value: 'requesterId',
description: 'User ID of the requester. For existing contacts, the requester_id can be passed instead of the requester\'s email.',
description:
"User ID of the requester. For existing contacts, the requester_id can be passed instead of the requester's email.",
},
{
name: 'Twitter ID',
value: 'twitterId',
description: 'Twitter handle of the requester. If no contact exists with this handle in Freshdesk, it will be added as a new contact.',
description:
'Twitter handle of the requester. If no contact exists with this handle in Freshdesk, it will be added as a new contact.',
},
{
name: 'Unique External ID',
value: 'uniqueExternalId',
description: 'External ID of the requester. If no contact exists with this external ID in Freshdesk, they will be added as a new contact.',
description:
'External ID of the requester. If no contact exists with this external ID in Freshdesk, they will be added as a new contact.',
},
],
default: 'requesterId',
@@ -846,7 +830,8 @@ export class Freshdesk implements INodeType {
name: 'type',
type: 'options',
default: 'Question',
description: 'Helps categorize the ticket according to the different kinds of issues your support team deals with',
description:
'Helps categorize the ticket according to the different kinds of issues your support team deals with',
options: [
{
name: 'Feature Request',
@@ -879,12 +864,8 @@ export class Freshdesk implements INodeType {
required: true,
displayOptions: {
show: {
resource: [
'ticket',
],
operation: [
'get',
],
resource: ['ticket'],
operation: ['get'],
},
},
default: '',
@@ -895,12 +876,8 @@ export class Freshdesk implements INodeType {
type: 'boolean',
displayOptions: {
show: {
resource: [
'ticket',
],
operation: [
'getAll',
],
resource: ['ticket'],
operation: ['getAll'],
},
},
default: false,
@@ -912,15 +889,9 @@ export class Freshdesk implements INodeType {
type: 'number',
displayOptions: {
show: {
resource: [
'ticket',
],
operation: [
'getAll',
],
returnAll: [
false,
],
resource: ['ticket'],
operation: ['getAll'],
returnAll: [false],
},
},
typeOptions: {
@@ -938,12 +909,8 @@ export class Freshdesk implements INodeType {
default: {},
displayOptions: {
show: {
resource: [
'ticket',
],
operation: [
'getAll',
],
resource: ['ticket'],
operation: ['getAll'],
},
},
options: [
@@ -1042,12 +1009,8 @@ export class Freshdesk implements INodeType {
required: true,
displayOptions: {
show: {
resource: [
'ticket',
],
operation: [
'delete',
],
resource: ['ticket'],
operation: ['delete'],
},
},
default: '',
@@ -1161,7 +1124,9 @@ export class Freshdesk implements INodeType {
if (requester === 'requesterId') {
// @ts-ignore
if (isNaN(value)) {
throw new NodeOperationError(this.getNode(), 'Requester Id must be a number', { itemIndex: i });
throw new NodeOperationError(this.getNode(), 'Requester Id must be a number', {
itemIndex: i,
});
}
body.requester_id = parseInt(value, 10);
} else if (requester === 'email') {
@@ -1246,7 +1211,9 @@ export class Freshdesk implements INodeType {
if (updateFields.requester === 'requesterId') {
// @ts-ignore
if (isNaN(parseInt(value, 10))) {
throw new NodeOperationError(this.getNode(), 'Requester Id must be a number', { itemIndex: i });
throw new NodeOperationError(this.getNode(), 'Requester Id must be a number', {
itemIndex: i,
});
}
body.requester_id = parseInt(value as string, 10);
} else if (updateFields.requester === 'email') {
@@ -1306,7 +1273,12 @@ export class Freshdesk implements INodeType {
if (updateFields.ccEmails) {
body.cc_emails = (updateFields.ccEmails as string).split(',') as [string];
}
responseData = await freshdeskApiRequest.call(this, 'PUT', `/tickets/${ticketId}`, body);
responseData = await freshdeskApiRequest.call(
this,
'PUT',
`/tickets/${ticketId}`,
body,
);
}
//https://developers.freshdesk.com/api/#view_a_ticket
if (operation === 'get') {
@@ -1341,7 +1313,13 @@ export class Freshdesk implements INodeType {
}
}
if (returnAll === true) {
responseData = await freshdeskApiRequestAllItems.call(this, 'GET', '/tickets', {}, qs);
responseData = await freshdeskApiRequestAllItems.call(
this,
'GET',
'/tickets',
{},
qs,
);
} else {
qs.per_page = this.getNodeParameter('limit', i) as number;
responseData = await freshdeskApiRequest.call(this, 'GET', '/tickets', {}, qs);
@@ -1357,10 +1335,15 @@ export class Freshdesk implements INodeType {
if (operation === 'create') {
const name = this.getNodeParameter('name', i) as string;
const email = this.getNodeParameter('email', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i, {}) as IDataObject;
const additionalFields = this.getNodeParameter(
'additionalFields',
i,
{},
) as IDataObject;
if (additionalFields.customFields) {
const metadata = (additionalFields.customFields as IDataObject).customField as IDataObject[];
const metadata = (additionalFields.customFields as IDataObject)
.customField as IDataObject[];
additionalFields.custom_fields = {};
for (const data of metadata) {
//@ts-ignore
@@ -1375,24 +1358,39 @@ export class Freshdesk implements INodeType {
body.email = email;
}
responseData = await freshdeskApiRequest.call(this, 'POST', '/contacts', body);
//https://developers.freshdesk.com/api/#delete_contact
//https://developers.freshdesk.com/api/#delete_contact
} else if (operation === 'delete') {
const contactId = this.getNodeParameter('contactId', i) as string;
responseData = await freshdeskApiRequest.call(this, 'DELETE', `/contacts/${contactId}`, {});
responseData = await freshdeskApiRequest.call(
this,
'DELETE',
`/contacts/${contactId}`,
{},
);
} else if (operation === 'get') {
const contactId = this.getNodeParameter('contactId', i) as string;
responseData = await freshdeskApiRequest.call(this, 'GET', `/contacts/${contactId}`, {});
//https://developers.freshdesk.com/api/#list_all_contacts
responseData = await freshdeskApiRequest.call(
this,
'GET',
`/contacts/${contactId}`,
{},
);
//https://developers.freshdesk.com/api/#list_all_contacts
} else if (operation === 'getAll') {
const qs = this.getNodeParameter('filters', i, {}) as IDataObject;
responseData = await freshdeskApiRequest.call(this, 'GET', '/contacts', {}, qs);
//https://developers.freshdesk.com/api/#update_contact
//https://developers.freshdesk.com/api/#update_contact
} else if (operation === 'update') {
const contactId = this.getNodeParameter('contactId', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i, {}) as IDataObject;
const additionalFields = this.getNodeParameter(
'additionalFields',
i,
{},
) as IDataObject;
if (additionalFields.customFields) {
const metadata = (additionalFields.customFields as IDataObject).customField as IDataObject[];
const metadata = (additionalFields.customFields as IDataObject)
.customField as IDataObject[];
additionalFields.custom_fields = {};
for (const data of metadata) {
//@ts-ignore
@@ -1402,7 +1400,12 @@ export class Freshdesk implements INodeType {
}
const body: ICreateContactBody = additionalFields;
responseData = await freshdeskApiRequest.call(this, 'PUT', `/contacts/${contactId}`, body);
responseData = await freshdeskApiRequest.call(
this,
'PUT',
`/contacts/${contactId}`,
body,
);
}
}