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 {
parse as urlParse,
} from 'url';
import { parse as urlParse } from 'url';
import {
IHookFunctions,
IWebhookFunctions,
} from 'n8n-core';
import { IHookFunctions, IWebhookFunctions } from 'n8n-core';
import {
IDataObject,
@@ -17,17 +12,10 @@ import {
NodeOperationError,
} from 'n8n-workflow';
import {
zendeskApiRequest,
zendeskApiRequestAllItems,
} from './GenericFunctions';
import {
conditionFields,
} from './ConditionDescription';
import { zendeskApiRequest, zendeskApiRequestAllItems } from './GenericFunctions';
import { conditionFields } from './ConditionDescription';
import {
triggerPlaceholders
} from './TriggerPlaceholders';
import { triggerPlaceholders } from './TriggerPlaceholders';
export class ZendeskTrigger implements INodeType {
description: INodeTypeDescription = {
@@ -48,9 +36,7 @@ export class ZendeskTrigger implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'apiToken',
],
authentication: ['apiToken'],
},
},
},
@@ -59,9 +45,7 @@ export class ZendeskTrigger implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'oAuth2',
],
authentication: ['oAuth2'],
},
},
},
@@ -110,9 +94,7 @@ export class ZendeskTrigger implements INodeType {
type: 'collection',
displayOptions: {
show: {
service: [
'support',
],
service: ['support'],
},
},
default: {},
@@ -120,7 +102,8 @@ export class ZendeskTrigger implements INodeType {
{
displayName: 'Field Names or IDs',
name: 'fields',
description: 'The fields to return the values of. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'The fields to return the values of. Choose from the list, or specify IDs using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
type: 'multiOptions',
default: [],
typeOptions: {
@@ -140,9 +123,7 @@ export class ZendeskTrigger implements INodeType {
},
displayOptions: {
show: {
service: [
'support',
],
service: ['support'],
},
},
description: 'The condition to set',
@@ -151,21 +132,16 @@ export class ZendeskTrigger implements INodeType {
{
name: 'all',
displayName: 'All',
values: [
...conditionFields,
],
values: [...conditionFields],
},
{
name: 'any',
displayName: 'Any',
values: [
...conditionFields,
],
values: [...conditionFields],
},
],
},
],
};
methods = {
loadOptions: {
@@ -183,7 +159,12 @@ export class ZendeskTrigger implements INodeType {
'multiselect',
'tagger',
];
const fields = await zendeskApiRequestAllItems.call(this, 'ticket_fields', 'GET', '/ticket_fields');
const fields = await zendeskApiRequestAllItems.call(
this,
'ticket_fields',
'GET',
'/ticket_fields',
);
for (const field of fields) {
if (customFields.includes(field.type) && field.removable && field.active) {
const fieldName = field.title;
@@ -246,7 +227,8 @@ export class ZendeskTrigger implements INodeType {
const conditions = this.getNodeParameter('conditions') as IDataObject;
let endpoint = '';
const resultAll = [], resultAny = [];
const resultAll = [],
resultAny = [];
const conditionsAll = conditions.all as [IDataObject];
if (conditionsAll) {
@@ -254,8 +236,7 @@ export class ZendeskTrigger implements INodeType {
const aux: IDataObject = {};
aux.field = conditionAll.field;
aux.operator = conditionAll.operation;
if (conditionAll.operation !== 'changed'
&& conditionAll.operation !== 'not_changed') {
if (conditionAll.operation !== 'changed' && conditionAll.operation !== 'not_changed') {
aux.value = conditionAll.value;
} else {
aux.value = null;
@@ -270,8 +251,7 @@ export class ZendeskTrigger implements INodeType {
const aux: IDataObject = {};
aux.field = conditionAny.field;
aux.operator = conditionAny.operation;
if (conditionAny.operation !== 'changed'
&& conditionAny.operation !== 'not_changed') {
if (conditionAny.operation !== 'changed' && conditionAny.operation !== 'not_changed') {
aux.value = conditionAny.value;
} else {
aux.value = null;
@@ -296,18 +276,24 @@ export class ZendeskTrigger implements INodeType {
}
endpoint = `/triggers/active`;
const triggers = await zendeskApiRequestAllItems.call(this, 'triggers', 'GET', endpoint);
const triggers = await zendeskApiRequestAllItems.call(this, 'triggers', 'GET', endpoint);
for (const trigger of triggers) {
const toDeleteTriggers = [];
// this trigger belong to the current target
if (trigger.actions[0].value[0].toString() === webhookData.targetId?.toString()) {
toDeleteTriggers.push(trigger.id);
}
// delete all trigger attach to this target;
if (toDeleteTriggers.length !== 0) {
await zendeskApiRequest.call(this, 'DELETE', '/triggers/destroy_many', {}, { ids: toDeleteTriggers.join(',') } );
}
const toDeleteTriggers = [];
// this trigger belong to the current target
if (trigger.actions[0].value[0].toString() === webhookData.targetId?.toString()) {
toDeleteTriggers.push(trigger.id);
}
// delete all trigger attach to this target;
if (toDeleteTriggers.length !== 0) {
await zendeskApiRequest.call(
this,
'DELETE',
'/triggers/destroy_many',
{},
{ ids: toDeleteTriggers.join(',') },
);
}
}
return false;
@@ -319,7 +305,8 @@ export class ZendeskTrigger implements INodeType {
if (service === 'support') {
const message: IDataObject = {};
const resultAll = [], resultAny = [];
const resultAll = [],
resultAny = [];
const conditions = this.getNodeParameter('conditions') as IDataObject;
const options = this.getNodeParameter('options') as IDataObject;
@@ -342,8 +329,10 @@ export class ZendeskTrigger implements INodeType {
const aux: IDataObject = {};
aux.field = conditionAll.field;
aux.operator = conditionAll.operation;
if (conditionAll.operation !== 'changed'
&& conditionAll.operation !== 'not_changed') {
if (
conditionAll.operation !== 'changed' &&
conditionAll.operation !== 'not_changed'
) {
aux.value = conditionAll.value;
} else {
aux.value = null;
@@ -358,8 +347,10 @@ export class ZendeskTrigger implements INodeType {
const aux: IDataObject = {};
aux.field = conditionAny.field;
aux.operator = conditionAny.operation;
if (conditionAny.operation !== 'changed'
&& conditionAny.operation !== 'not_changed') {
if (
conditionAny.operation !== 'changed' &&
conditionAny.operation !== 'not_changed'
) {
aux.value = conditionAny.value;
} else {
aux.value = null;
@@ -376,7 +367,7 @@ export class ZendeskTrigger implements INodeType {
conditions: {
all: resultAll,
any: resultAny,
},
},
actions: [
{
field: 'notification_webhook',
@@ -388,14 +379,12 @@ export class ZendeskTrigger implements INodeType {
const bodyTarget: IDataObject = {
webhook: {
name:'n8n webhook',
name: 'n8n webhook',
endpoint: webhookUrl,
http_method:'POST',
status:'active',
request_format:'json',
subscriptions: [
'conditional_ticket_events',
],
http_method: 'POST',
status: 'active',
request_format: 'json',
subscriptions: ['conditional_ticket_events'],
},
};
let target: IDataObject = {};
@@ -407,7 +396,8 @@ export class ZendeskTrigger implements INodeType {
} else {
// create a webhook
// https://developer.zendesk.com/api-reference/event-connectors/webhooks/webhooks/#create-or-clone-webhook
target = (await zendeskApiRequest.call(this, 'POST', '/webhooks', bodyTarget)).webhook as IDataObject;
target = (await zendeskApiRequest.call(this, 'POST', '/webhooks', bodyTarget))
.webhook as IDataObject;
}
// @ts-ignore
@@ -424,7 +414,7 @@ export class ZendeskTrigger implements INodeType {
try {
await zendeskApiRequest.call(this, 'DELETE', `/triggers/${webhookData.webhookId}`);
await zendeskApiRequest.call(this, 'DELETE', `/webhooks/${webhookData.targetId}`);
} catch(error) {
} catch (error) {
return false;
}
delete webhookData.triggerId;
@@ -437,9 +427,7 @@ export class ZendeskTrigger 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)],
};
}
}