mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import {
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
@@ -11,32 +9,12 @@ import {
|
||||
NodeApiError,
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import {
|
||||
leadFields,
|
||||
leadOpeations,
|
||||
} from './LeadDescription';
|
||||
import {
|
||||
intercomApiRequest,
|
||||
intercomApiRequestAllItems,
|
||||
validateJSON,
|
||||
} from './GenericFunctions';
|
||||
import {
|
||||
IAvatar,
|
||||
ILead,
|
||||
ILeadCompany,
|
||||
} from './LeadInterface';
|
||||
import {
|
||||
userFields,
|
||||
userOpeations,
|
||||
} from './UserDescription';
|
||||
import {
|
||||
IUser,
|
||||
IUserCompany,
|
||||
} from './UserInterface';
|
||||
import {
|
||||
companyFields,
|
||||
companyOperations,
|
||||
} from './CompanyDescription';
|
||||
import { leadFields, leadOpeations } from './LeadDescription';
|
||||
import { intercomApiRequest, intercomApiRequestAllItems, validateJSON } from './GenericFunctions';
|
||||
import { IAvatar, ILead, ILeadCompany } from './LeadInterface';
|
||||
import { userFields, userOpeations } from './UserDescription';
|
||||
import { IUser, IUserCompany } from './UserInterface';
|
||||
import { companyFields, companyOperations } from './CompanyDescription';
|
||||
import { ICompany } from './CompanyInteface';
|
||||
|
||||
export class Intercom implements INodeType {
|
||||
@@ -70,7 +48,8 @@ export class Intercom implements INodeType {
|
||||
{
|
||||
name: 'Company',
|
||||
value: 'company',
|
||||
description: 'Companies allow you to represent commercial organizations using your product',
|
||||
description:
|
||||
'Companies allow you to represent commercial organizations using your product',
|
||||
},
|
||||
{
|
||||
name: 'Lead',
|
||||
@@ -180,7 +159,7 @@ export class Intercom implements INodeType {
|
||||
if (additionalFields.companies) {
|
||||
const companies: ILeadCompany[] = [];
|
||||
// @ts-ignore
|
||||
additionalFields.companies.forEach(o => {
|
||||
additionalFields.companies.forEach((o) => {
|
||||
const company: ILeadCompany = {};
|
||||
company.company_id = o;
|
||||
companies.push(company);
|
||||
@@ -188,17 +167,22 @@ export class Intercom implements INodeType {
|
||||
body.companies = companies;
|
||||
}
|
||||
if (!jsonActive) {
|
||||
const customAttributesValues = (this.getNodeParameter('customAttributesUi', i) as IDataObject).customAttributesValues as IDataObject[];
|
||||
const customAttributesValues = (
|
||||
this.getNodeParameter('customAttributesUi', i) as IDataObject
|
||||
).customAttributesValues as IDataObject[];
|
||||
if (customAttributesValues) {
|
||||
const customAttributes = {};
|
||||
for (let i = 0; i < customAttributesValues.length; i++) {
|
||||
// @ts-ignore
|
||||
customAttributes[customAttributesValues[i].name] = customAttributesValues[i].value;
|
||||
customAttributes[customAttributesValues[i].name] =
|
||||
customAttributesValues[i].value;
|
||||
}
|
||||
body.custom_attributes = customAttributes;
|
||||
}
|
||||
} else {
|
||||
const customAttributesJson = validateJSON(this.getNodeParameter('customAttributesJson', i) as string);
|
||||
const customAttributesJson = validateJSON(
|
||||
this.getNodeParameter('customAttributesJson', i) as string,
|
||||
);
|
||||
if (customAttributesJson) {
|
||||
body.custom_attributes = customAttributesJson;
|
||||
}
|
||||
@@ -251,7 +235,14 @@ export class Intercom implements INodeType {
|
||||
|
||||
try {
|
||||
if (returnAll === true) {
|
||||
responseData = await intercomApiRequestAllItems.call(this, 'contacts', '/contacts', 'GET', {}, qs);
|
||||
responseData = await intercomApiRequestAllItems.call(
|
||||
this,
|
||||
'contacts',
|
||||
'/contacts',
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs.per_page = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await intercomApiRequest.call(this, '/contacts', 'GET', {}, qs);
|
||||
@@ -338,7 +329,7 @@ export class Intercom implements INodeType {
|
||||
if (additionalFields.companies) {
|
||||
const companies: IUserCompany[] = [];
|
||||
// @ts-ignore
|
||||
additionalFields.companies.forEach(o => {
|
||||
additionalFields.companies.forEach((o) => {
|
||||
const company: IUserCompany = {};
|
||||
company.company_id = o;
|
||||
companies.push(company);
|
||||
@@ -349,17 +340,22 @@ export class Intercom implements INodeType {
|
||||
body.session_count = additionalFields.sessionCount as number;
|
||||
}
|
||||
if (!jsonActive) {
|
||||
const customAttributesValues = (this.getNodeParameter('customAttributesUi', i) as IDataObject).customAttributesValues as IDataObject[];
|
||||
const customAttributesValues = (
|
||||
this.getNodeParameter('customAttributesUi', i) as IDataObject
|
||||
).customAttributesValues as IDataObject[];
|
||||
if (customAttributesValues) {
|
||||
const customAttributes = {};
|
||||
for (let i = 0; i < customAttributesValues.length; i++) {
|
||||
// @ts-ignore
|
||||
customAttributes[customAttributesValues[i].name] = customAttributesValues[i].value;
|
||||
customAttributes[customAttributesValues[i].name] =
|
||||
customAttributesValues[i].value;
|
||||
}
|
||||
body.custom_attributes = customAttributes;
|
||||
}
|
||||
} else {
|
||||
const customAttributesJson = validateJSON(this.getNodeParameter('customAttributesJson', i) as string);
|
||||
const customAttributesJson = validateJSON(
|
||||
this.getNodeParameter('customAttributesJson', i) as string,
|
||||
);
|
||||
if (customAttributesJson) {
|
||||
body.custom_attributes = customAttributesJson;
|
||||
}
|
||||
@@ -393,7 +389,13 @@ export class Intercom implements INodeType {
|
||||
}
|
||||
try {
|
||||
if (selectBy === 'id') {
|
||||
responseData = await intercomApiRequest.call(this, `/users/${value}`, 'GET', {}, qs);
|
||||
responseData = await intercomApiRequest.call(
|
||||
this,
|
||||
`/users/${value}`,
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
responseData = await intercomApiRequest.call(this, '/users', 'GET', {}, qs);
|
||||
}
|
||||
@@ -408,7 +410,14 @@ export class Intercom implements INodeType {
|
||||
|
||||
try {
|
||||
if (returnAll === true) {
|
||||
responseData = await intercomApiRequestAllItems.call(this, 'users', '/users', 'GET', {}, qs);
|
||||
responseData = await intercomApiRequestAllItems.call(
|
||||
this,
|
||||
'users',
|
||||
'/users',
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs.per_page = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await intercomApiRequest.call(this, '/users', 'GET', {}, qs);
|
||||
@@ -423,7 +432,11 @@ export class Intercom implements INodeType {
|
||||
try {
|
||||
responseData = await intercomApiRequest.call(this, `/users/${id}`, 'DELETE');
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `Intercom Error: ${JSON.stringify(error)}`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`Intercom Error: ${JSON.stringify(error)}`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -455,17 +468,22 @@ export class Intercom implements INodeType {
|
||||
body.industry = additionalFields.industry as string;
|
||||
}
|
||||
if (!jsonActive) {
|
||||
const customAttributesValues = (this.getNodeParameter('customAttributesUi', i) as IDataObject).customAttributesValues as IDataObject[];
|
||||
const customAttributesValues = (
|
||||
this.getNodeParameter('customAttributesUi', i) as IDataObject
|
||||
).customAttributesValues as IDataObject[];
|
||||
if (customAttributesValues) {
|
||||
const customAttributes = {};
|
||||
for (let i = 0; i < customAttributesValues.length; i++) {
|
||||
// @ts-ignore
|
||||
customAttributes[customAttributesValues[i].name] = customAttributesValues[i].value;
|
||||
customAttributes[customAttributesValues[i].name] =
|
||||
customAttributesValues[i].value;
|
||||
}
|
||||
body.custom_attributes = customAttributes;
|
||||
}
|
||||
} else {
|
||||
const customAttributesJson = validateJSON(this.getNodeParameter('customAttributesJson', i) as string);
|
||||
const customAttributesJson = validateJSON(
|
||||
this.getNodeParameter('customAttributesJson', i) as string,
|
||||
);
|
||||
if (customAttributesJson) {
|
||||
body.custom_attributes = customAttributesJson;
|
||||
}
|
||||
@@ -473,7 +491,11 @@ export class Intercom implements INodeType {
|
||||
try {
|
||||
responseData = await intercomApiRequest.call(this, '/companies', 'POST', body, qs);
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `Intercom Error: ${JSON.stringify(error)}`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`Intercom Error: ${JSON.stringify(error)}`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
}
|
||||
if (operation === 'get') {
|
||||
@@ -487,12 +509,22 @@ export class Intercom implements INodeType {
|
||||
}
|
||||
try {
|
||||
if (selectBy === 'id') {
|
||||
responseData = await intercomApiRequest.call(this, `/companies/${value}`, 'GET', {}, qs);
|
||||
responseData = await intercomApiRequest.call(
|
||||
this,
|
||||
`/companies/${value}`,
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
responseData = await intercomApiRequest.call(this, '/companies', 'GET', {}, qs);
|
||||
}
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `Intercom Error: ${JSON.stringify(error)}`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`Intercom Error: ${JSON.stringify(error)}`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
@@ -502,14 +534,25 @@ export class Intercom implements INodeType {
|
||||
|
||||
try {
|
||||
if (returnAll === true) {
|
||||
responseData = await intercomApiRequestAllItems.call(this, 'companies', '/companies', 'GET', {}, qs);
|
||||
responseData = await intercomApiRequestAllItems.call(
|
||||
this,
|
||||
'companies',
|
||||
'/companies',
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs.per_page = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await intercomApiRequest.call(this, '/companies', 'GET', {}, qs);
|
||||
responseData = responseData.companies;
|
||||
}
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `Intercom Error: ${JSON.stringify(error)}`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`Intercom Error: ${JSON.stringify(error)}`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
}
|
||||
if (operation === 'users') {
|
||||
@@ -524,18 +567,37 @@ export class Intercom implements INodeType {
|
||||
try {
|
||||
if (listBy === 'id') {
|
||||
if (returnAll === true) {
|
||||
responseData = await intercomApiRequestAllItems.call(this, 'users', `/companies/${value}/users`, 'GET', {}, qs);
|
||||
responseData = await intercomApiRequestAllItems.call(
|
||||
this,
|
||||
'users',
|
||||
`/companies/${value}/users`,
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs.per_page = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await intercomApiRequest.call(this, `/companies/${value}/users`, 'GET', {}, qs);
|
||||
responseData = await intercomApiRequest.call(
|
||||
this,
|
||||
`/companies/${value}/users`,
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.users;
|
||||
}
|
||||
|
||||
} else {
|
||||
qs.type = 'users';
|
||||
|
||||
if (returnAll === true) {
|
||||
responseData = await intercomApiRequestAllItems.call(this, 'users', '/companies', 'GET', {}, qs);
|
||||
responseData = await intercomApiRequestAllItems.call(
|
||||
this,
|
||||
'users',
|
||||
'/companies',
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs.per_page = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await intercomApiRequest.call(this, '/companies', 'GET', {}, qs);
|
||||
@@ -543,7 +605,11 @@ export class Intercom implements INodeType {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
throw new NodeOperationError(this.getNode(), `Intercom Error: ${JSON.stringify(error)}`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`Intercom Error: ${JSON.stringify(error)}`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user