Add full continue-on-fail support to all nodes (#1996)

* Update Compression node

* Update Crypto node

* Update DateTime node

* Update EditImage node

* Update EmailSend node

* Update ExecuteWorkflow node

* Update FTP node

* Update Function node

* Update FunctionItem node

* Update ExecuteCommand node

* Update OpenWeatherMap node

* Update ReadBinaryFile node

* Update ReadPdf node

* Update RssFeedRead node & add URL validation

* Update SpreadsheetFile node

* Update Switch node

* Update WriteBinaryFile node

* Update Xml node

* Update ActiveCampaign node

* Update Airtable node

* Update ApiTemplateIo node

* Update Asana node

* Update AwsLambda node

* Update AwsSns node

* Update AwsComprehend node

* Update AwsRekognition node

* Update AwsS3 node

* Fix Error item

* Update AwsSes node

* Update AwsSqs node

* Update Amqp node

* Update Bitly node

* Update Box node

* Update Brandfetch node

* Update CircleCi node

* Update Clearbit node

* Update ClickUp node

* Update Cockpit node

* Update CoinGecko node

* Update Contentful node

* Update ConvertKit node

* Update Cortex node

* Update CustomerIo node

* Update DeepL node

* Update Demio node

* Update Disqus node

* Update Drift node

* Update Dropbox node

* Update GetResponse node

* Refactor & Update Ghost node

* Update Github node

* Update Gitlab node

* Update GoogleAnalytics node

* Update GoogleBooks node

* Update GoogleCalendar node

* Update GoogleDrive node

* Update Gmail node

* Update GoogleSheets node

* Update GoogleSlides node

* Update GoogleTasks node

* Update Gotify node

* Update GraphQL node

* Update HackerNews node

* Update Harvest node

* Update HtmlExtract node

* Update Hubspot node

* Update Hunter node

* Update Intercom node

* Update Kafka node

* Refactor & update Line node

* Update LinkedIn node

* Update Mailchimp node

* Update Mandrill node

* Update Matrix node

* Update Mautic node

* Update Medium node

* Update MessageBird node

* Update Mindee node

* Update Mocean node

* Update MondayCom node

* Update MicrosoftExcel node

* Update MicrosoftOneDrive node

* Update MicrosoftOutlook node

* Update Affinity node

* Update Chargebee node

* Update Discourse node

* Update Freshdesk node

* Update YouTube node

* Update InvoiceNinja node

* Update MailerLite node

* Update Mailgun node

* Update Mailjet node

* Update Mattermost node

* Update Nasa node

* Update NextCloud node

* Update OpenThesaurus node

* Update Orbit node

* Update PagerDuty node

* Update PayPal node

* Update Peekalink node

* Update Phantombuster node

* Update PostHog node

* Update ProfitWell node

* Refactor & Update Pushbullet node

* Update QuickBooks node

* Update Raindrop node

* Update Reddit node

* Update Rocketchat node

* Update S3 node

* Update Salesforce node

* Update SendGrid node

* Update SentryIo node

* Update Shopify node

* Update Signl4 node

* Update Slack node

* Update Spontit node

* Update Spotify node

* Update Storyblok node

* Refactor & Update Strapi node

* Refactor & Update Strava node

* Update Taiga node

* Refactor & update Tapfiliate node

* Update Telegram node

* Update TheHive node

* Update Todoist node

* Update TravisCi node

* Update Trello node

* Update Twilio node

* Update Twist node

* Update Twitter node

* Update Uplead node

* Update UProc node

* Update Vero node

* Update Webflow node

* Update Wekan node

* Update Wordpress node

* Update Xero node

* Update Yourls node

* Update Zendesk node

* Update ZohoCrm node

* Refactor & Update Zoom node

* Update Zulip node

* Update Clockify node

* Update MongoDb node

* Update MySql node

* Update MicrosoftTeams node

* Update Stackby node

* Refactor Discourse node

* Support corner-case in Github node update

* Support corner-case in Gitlab node update

* Refactor & Update GoogleContacts node

* Refactor Mindee node

* Update Coda node

* Lint fixes

* Update Beeminder node

* Update Google Firebase RealtimeDatabase node

* Update HelpScout node

* Update Mailcheck node

* Update Paddle node

* Update Pipedrive node

* Update Pushover node

* Update Segment node

* Refactor & Update Vonage node

* Added new conditions to warnings on execute batch cmd

* Added keep only properties flag

* Fixed code for keep only props

* Added dependencies for image editing

Co-authored-by: dali <servfrdali@yahoo.fr>
This commit is contained in:
Omar Ajoue
2021-07-20 08:58:54 +02:00
committed by GitHub
parent 6a9401aa51
commit d6239d5bfb
159 changed files with 35795 additions and 33847 deletions

View File

@@ -1148,283 +1148,291 @@ export class Freshdesk implements INodeType {
const resource = this.getNodeParameter('resource', 0) as string;
const operation = this.getNodeParameter('operation', 0) as string;
for (let i = 0; i < items.length; i++) {
if (resource === 'ticket') {
//https://developers.freshdesk.com/api/#create_ticket
if (operation === 'create') {
const requester = this.getNodeParameter('requester', i) as string;
const value = this.getNodeParameter('requesterIdentificationValue', i) as string;
const status = this.getNodeParameter('status', i) as string;
const priority = this.getNodeParameter('priority', i) as string;
const source = this.getNodeParameter('source', i) as string;
const options = this.getNodeParameter('options', i) as IDataObject;
//const jsonActive = this.getNodeParameter('jsonParameters') as boolean;
const body: ICreateTicketBody = {
// @ts-ignore
status: Status[capitalize(status)],
// @ts-ignore
priority: Priority[capitalize(priority)],
// @ts-ignore
source: Source[capitalize(source)],
};
if (requester === 'requesterId') {
// @ts-ignore
if (isNaN(value)) {
throw new NodeOperationError(this.getNode(), 'Requester Id must be a number');
}
body.requester_id = parseInt(value, 10);
} else if (requester === 'email') {
body.email = value;
} else if (requester === 'facebookId') {
body.facebook_id = value;
} else if (requester === 'phone') {
body.phone = value;
} else if (requester === 'twitterId') {
body.twitter_id = value;
} else if (requester === 'uniqueExternalId') {
body.unique_external_id = value;
}
// if (!jsonActive) {
// const customFieldsUi = this.getNodeParameter('customFieldsUi') as IDataObject;
// if (Object.keys(customFieldsUi).length > 0) {
// const aux: IDataObject = {};
// // @ts-ignore
// customFieldsUi.customFieldsValues.forEach( o => {
// aux[`${o.key}`] = o.value;
// return aux;
// });
// body.custom_fields = aux;
// } else {
// body.custom_fields = validateJSON(this.getNodeParameter('customFielsJson') as string);
// }
if (options.name) {
body.name = options.name as string;
}
if (options.subject) {
body.subject = options.subject as string;
} else {
body.subject = 'null';
}
if (options.type) {
body.type = options.type as string;
}
if (options.description) {
body.description = options.description as string;
} else {
body.description = 'null';
}
if (options.agent) {
body.responder_id = options.agent as number;
}
if (options.company) {
body.company_id = options.company as number;
}
if (options.product) {
body.product_id = options.product as number;
}
if (options.group) {
body.group_id = options.group as number;
}
if (options.frDueBy) {
body.fr_due_by = options.frDueBy as string;
}
if (options.emailConfigId) {
body.email_config_id = options.emailConfigId as number;
}
if (options.dueBy) {
body.due_by = options.dueBy as string;
}
if (options.tags) {
body.tags = (options.tags as string).split(',') as [string];
}
if (options.ccEmails) {
body.cc_emails = (options.ccEmails as string).split(',') as [string];
}
responseData = await freshdeskApiRequest.call(this, 'POST', '/tickets', body);
}
//https://developers.freshdesk.com/api/#update_ticket
if (operation === 'update') {
const ticketId = this.getNodeParameter('ticketId', i) as string;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const body: ICreateTicketBody = {};
if (updateFields.requester) {
const value = updateFields.requesterIdentificationValue as string;
if (updateFields.requester === 'requesterId') {
try {
if (resource === 'ticket') {
//https://developers.freshdesk.com/api/#create_ticket
if (operation === 'create') {
const requester = this.getNodeParameter('requester', i) as string;
const value = this.getNodeParameter('requesterIdentificationValue', i) as string;
const status = this.getNodeParameter('status', i) as string;
const priority = this.getNodeParameter('priority', i) as string;
const source = this.getNodeParameter('source', i) as string;
const options = this.getNodeParameter('options', i) as IDataObject;
//const jsonActive = this.getNodeParameter('jsonParameters') as boolean;
const body: ICreateTicketBody = {
// @ts-ignore
if (isNaN(parseInt(value, 10))) {
status: Status[capitalize(status)],
// @ts-ignore
priority: Priority[capitalize(priority)],
// @ts-ignore
source: Source[capitalize(source)],
};
if (requester === 'requesterId') {
// @ts-ignore
if (isNaN(value)) {
throw new NodeOperationError(this.getNode(), 'Requester Id must be a number');
}
body.requester_id = parseInt(value as string, 10);
} else if (updateFields.requester === 'email') {
body.email = value as string;
} else if (updateFields.requester === 'facebookId') {
body.facebook_id = value as string;
} else if (updateFields.requester === 'phone') {
body.phone = value as string;
} else if (updateFields.requester === 'twitterId') {
body.twitter_id = value as string;
} else if (updateFields.requester === 'uniqueExternalId') {
body.unique_external_id = value as string;
body.requester_id = parseInt(value, 10);
} else if (requester === 'email') {
body.email = value;
} else if (requester === 'facebookId') {
body.facebook_id = value;
} else if (requester === 'phone') {
body.phone = value;
} else if (requester === 'twitterId') {
body.twitter_id = value;
} else if (requester === 'uniqueExternalId') {
body.unique_external_id = value;
}
}
if (updateFields.status) {
//@ts-ignore
body.status = Status[capitalize(updateFields.status)];
}
if (updateFields.priority) {
//@ts-ignore
body.priority = Priority[capitalize(updateFields.priority)];
}
if (updateFields.source) {
//@ts-ignore
body.source = Source[capitalize(updateFields.source)];
}
if (updateFields.name) {
body.name = updateFields.name as string;
}
if (updateFields.type) {
body.type = updateFields.type as string;
}
if (updateFields.agent) {
body.responder_id = updateFields.agent as number;
}
if (updateFields.company) {
body.company_id = updateFields.company as number;
}
if (updateFields.product) {
body.product_id = updateFields.product as number;
}
if (updateFields.group) {
body.group_id = updateFields.group as number;
}
if (updateFields.frDueBy) {
body.fr_due_by = updateFields.frDueBy as string;
}
if (updateFields.emailConfigId) {
body.email_config_id = updateFields.emailConfigId as number;
}
if (updateFields.dueBy) {
body.due_by = updateFields.dueBy as string;
}
if (updateFields.tags) {
body.tags = (updateFields.tags as string).split(',') as [string];
}
if (updateFields.ccEmails) {
body.cc_emails = (updateFields.ccEmails as string).split(',') as [string];
}
responseData = await freshdeskApiRequest.call(this, 'PUT', `/tickets/${ticketId}`, body);
}
//https://developers.freshdesk.com/api/#view_a_ticket
if (operation === 'get') {
const ticketId = this.getNodeParameter('ticketId', i) as string;
responseData = await freshdeskApiRequest.call(this, 'GET', `/tickets/${ticketId}`);
}
//https://developers.freshdesk.com/api/#list_all_tickets
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const options = this.getNodeParameter('options', i) as IDataObject;
if (options.requesterId) {
qs.requester_id = options.requesterId as string;
}
if (options.requesterEmail) {
qs.email = options.requesterEmail as string;
}
if (options.companyId) {
qs.company_id = options.companyId as string;
}
if (options.updatedSince) {
qs.updated_since = options.updatedSince as string;
}
if (options.orderBy) {
qs.order_by = options.orderBy as string;
}
if (options.order) {
qs.order_type = options.order as string;
}
if (options.include) {
if ((options.include as string[]).length !== 0) {
qs.include = (options.include as string[]).join(',');
}
}
if (returnAll === true) {
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);
}
}
//https://developers.freshdesk.com/api/#delete_a_ticket
if (operation === 'delete') {
const ticketId = this.getNodeParameter('ticketId', i) as string;
responseData = await freshdeskApiRequest.call(this, 'DELETE', `/tickets/${ticketId}`);
}
} else if (resource === 'contact') {
//https://developers.freshdesk.com/api/#create_contact
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;
if (additionalFields.customFields) {
const metadata = (additionalFields.customFields as IDataObject).customField as IDataObject[];
additionalFields.custom_fields = {};
for (const data of metadata) {
// if (!jsonActive) {
// const customFieldsUi = this.getNodeParameter('customFieldsUi') as IDataObject;
// if (Object.keys(customFieldsUi).length > 0) {
// const aux: IDataObject = {};
// // @ts-ignore
// customFieldsUi.customFieldsValues.forEach( o => {
// aux[`${o.key}`] = o.value;
// return aux;
// });
// body.custom_fields = aux;
// } else {
// body.custom_fields = validateJSON(this.getNodeParameter('customFielsJson') as string);
// }
if (options.name) {
body.name = options.name as string;
}
if (options.subject) {
body.subject = options.subject as string;
} else {
body.subject = 'null';
}
if (options.type) {
body.type = options.type as string;
}
if (options.description) {
body.description = options.description as string;
} else {
body.description = 'null';
}
if (options.agent) {
body.responder_id = options.agent as number;
}
if (options.company) {
body.company_id = options.company as number;
}
if (options.product) {
body.product_id = options.product as number;
}
if (options.group) {
body.group_id = options.group as number;
}
if (options.frDueBy) {
body.fr_due_by = options.frDueBy as string;
}
if (options.emailConfigId) {
body.email_config_id = options.emailConfigId as number;
}
if (options.dueBy) {
body.due_by = options.dueBy as string;
}
if (options.tags) {
body.tags = (options.tags as string).split(',') as [string];
}
if (options.ccEmails) {
body.cc_emails = (options.ccEmails as string).split(',') as [string];
}
responseData = await freshdeskApiRequest.call(this, 'POST', '/tickets', body);
}
//https://developers.freshdesk.com/api/#update_ticket
if (operation === 'update') {
const ticketId = this.getNodeParameter('ticketId', i) as string;
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
const body: ICreateTicketBody = {};
if (updateFields.requester) {
const value = updateFields.requesterIdentificationValue as string;
if (updateFields.requester === 'requesterId') {
// @ts-ignore
if (isNaN(parseInt(value, 10))) {
throw new NodeOperationError(this.getNode(), 'Requester Id must be a number');
}
body.requester_id = parseInt(value as string, 10);
} else if (updateFields.requester === 'email') {
body.email = value as string;
} else if (updateFields.requester === 'facebookId') {
body.facebook_id = value as string;
} else if (updateFields.requester === 'phone') {
body.phone = value as string;
} else if (updateFields.requester === 'twitterId') {
body.twitter_id = value as string;
} else if (updateFields.requester === 'uniqueExternalId') {
body.unique_external_id = value as string;
}
}
if (updateFields.status) {
//@ts-ignore
additionalFields.custom_fields[data.name as string] = data.value;
body.status = Status[capitalize(updateFields.status)];
}
delete additionalFields.customFields;
}
const body: ICreateContactBody = additionalFields;
body.name = name;
if (email) {
body.email = email;
}
responseData = await freshdeskApiRequest.call(this, 'POST', '/contacts', body);
//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}`, {});
} 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
} 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
} else if (operation === 'update') {
const contactId = this.getNodeParameter('contactId', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i, {}) as IDataObject;
if (additionalFields.customFields) {
const metadata = (additionalFields.customFields as IDataObject).customField as IDataObject[];
additionalFields.custom_fields = {};
for (const data of metadata) {
if (updateFields.priority) {
//@ts-ignore
additionalFields.custom_fields[data.name as string] = data.value;
body.priority = Priority[capitalize(updateFields.priority)];
}
delete additionalFields.customFields;
if (updateFields.source) {
//@ts-ignore
body.source = Source[capitalize(updateFields.source)];
}
if (updateFields.name) {
body.name = updateFields.name as string;
}
if (updateFields.type) {
body.type = updateFields.type as string;
}
if (updateFields.agent) {
body.responder_id = updateFields.agent as number;
}
if (updateFields.company) {
body.company_id = updateFields.company as number;
}
if (updateFields.product) {
body.product_id = updateFields.product as number;
}
if (updateFields.group) {
body.group_id = updateFields.group as number;
}
if (updateFields.frDueBy) {
body.fr_due_by = updateFields.frDueBy as string;
}
if (updateFields.emailConfigId) {
body.email_config_id = updateFields.emailConfigId as number;
}
if (updateFields.dueBy) {
body.due_by = updateFields.dueBy as string;
}
if (updateFields.tags) {
body.tags = (updateFields.tags as string).split(',') as [string];
}
if (updateFields.ccEmails) {
body.cc_emails = (updateFields.ccEmails as string).split(',') as [string];
}
responseData = await freshdeskApiRequest.call(this, 'PUT', `/tickets/${ticketId}`, body);
}
//https://developers.freshdesk.com/api/#view_a_ticket
if (operation === 'get') {
const ticketId = this.getNodeParameter('ticketId', i) as string;
responseData = await freshdeskApiRequest.call(this, 'GET', `/tickets/${ticketId}`);
}
//https://developers.freshdesk.com/api/#list_all_tickets
if (operation === 'getAll') {
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const options = this.getNodeParameter('options', i) as IDataObject;
if (options.requesterId) {
qs.requester_id = options.requesterId as string;
}
if (options.requesterEmail) {
qs.email = options.requesterEmail as string;
}
if (options.companyId) {
qs.company_id = options.companyId as string;
}
if (options.updatedSince) {
qs.updated_since = options.updatedSince as string;
}
if (options.orderBy) {
qs.order_by = options.orderBy as string;
}
if (options.order) {
qs.order_type = options.order as string;
}
if (options.include) {
if ((options.include as string[]).length !== 0) {
qs.include = (options.include as string[]).join(',');
}
}
if (returnAll === true) {
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);
}
}
//https://developers.freshdesk.com/api/#delete_a_ticket
if (operation === 'delete') {
const ticketId = this.getNodeParameter('ticketId', i) as string;
responseData = await freshdeskApiRequest.call(this, 'DELETE', `/tickets/${ticketId}`);
}
} else if (resource === 'contact') {
//https://developers.freshdesk.com/api/#create_contact
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;
if (additionalFields.customFields) {
const metadata = (additionalFields.customFields as IDataObject).customField as IDataObject[];
additionalFields.custom_fields = {};
for (const data of metadata) {
//@ts-ignore
additionalFields.custom_fields[data.name as string] = data.value;
}
delete additionalFields.customFields;
}
const body: ICreateContactBody = additionalFields;
body.name = name;
if (email) {
body.email = email;
}
responseData = await freshdeskApiRequest.call(this, 'POST', '/contacts', body);
//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}`, {});
} 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
} 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
} else if (operation === 'update') {
const contactId = this.getNodeParameter('contactId', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i, {}) as IDataObject;
if (additionalFields.customFields) {
const metadata = (additionalFields.customFields as IDataObject).customField as IDataObject[];
additionalFields.custom_fields = {};
for (const data of metadata) {
//@ts-ignore
additionalFields.custom_fields[data.name as string] = data.value;
}
delete additionalFields.customFields;
}
const body: ICreateContactBody = additionalFields;
responseData = await freshdeskApiRequest.call(this, 'PUT', `/contacts/${contactId}`, body);
}
}
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]);
} else {
if (responseData === undefined) {
responseData = {
success: true,
};
}
const body: ICreateContactBody = additionalFields;
responseData = await freshdeskApiRequest.call(this, 'PUT', `/contacts/${contactId}`, body);
returnData.push(responseData as IDataObject);
}
}
if (Array.isArray(responseData)) {
returnData.push.apply(returnData, responseData as IDataObject[]);
} else {
if (responseData === undefined) {
responseData = {
success: true,
};
} catch (error) {
if (this.continueOnFail()) {
returnData.push({ error: error.message });
continue;
}
returnData.push(responseData as IDataObject);
throw error;
}
}
return [this.helpers.returnJsonArray(returnData)];