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

@@ -811,258 +811,270 @@ export class Dropbox implements INodeType {
}
for (let i = 0; i < items.length; i++) {
body = {};
try {
body = {};
if (resource === 'file') {
if (operation === 'download') {
// ----------------------------------
// download
// ----------------------------------
if (resource === 'file') {
if (operation === 'download') {
// ----------------------------------
// download
// ----------------------------------
requestMethod = 'POST';
requestMethod = 'POST';
query.arg = JSON.stringify({
path: this.getNodeParameter('path', i) as string,
});
query.arg = JSON.stringify({
path: this.getNodeParameter('path', i) as string,
});
endpoint = 'https://content.dropboxapi.com/2/files/download';
endpoint = 'https://content.dropboxapi.com/2/files/download';
} else if (operation === 'upload') {
// ----------------------------------
// upload
// ----------------------------------
} else if (operation === 'upload') {
// ----------------------------------
// upload
// ----------------------------------
requestMethod = 'POST';
headers['Content-Type'] = 'application/octet-stream';
requestMethod = 'POST';
headers['Content-Type'] = 'application/octet-stream';
query.arg = JSON.stringify({
mode: 'overwrite',
path: this.getNodeParameter('path', i) as string,
});
query.arg = JSON.stringify({
mode: 'overwrite',
path: this.getNodeParameter('path', i) as string,
});
endpoint = 'https://content.dropboxapi.com/2/files/upload';
endpoint = 'https://content.dropboxapi.com/2/files/upload';
options = { json: false };
options = { json: false };
if (this.getNodeParameter('binaryData', i) === true) {
if (this.getNodeParameter('binaryData', i) === true) {
// Is binary file to upload
const item = items[i];
// Is binary file to upload
const item = items[i];
if (item.binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
}
if (item.binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
}
const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string;
const propertyNameUpload = this.getNodeParameter('binaryPropertyName', i) as string;
if (item.binary[propertyNameUpload] === undefined) {
throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`);
}
if (item.binary[propertyNameUpload] === undefined) {
throw new NodeOperationError(this.getNode(), `No binary data property "${propertyNameUpload}" does not exists on item!`);
}
body = Buffer.from(item.binary[propertyNameUpload].data, BINARY_ENCODING);
} else {
// Is text file
body = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8');
}
}
} else if (resource === 'folder') {
if (operation === 'create') {
// ----------------------------------
// create
// ----------------------------------
requestMethod = 'POST';
body = {
path: this.getNodeParameter('path', i) as string,
};
endpoint = 'https://api.dropboxapi.com/2/files/create_folder_v2';
} else if (operation === 'list') {
// ----------------------------------
// list
// ----------------------------------
returnAll = this.getNodeParameter('returnAll', 0) as boolean;
const filters = this.getNodeParameter('filters', i) as IDataObject;
property = 'entries';
requestMethod = 'POST';
body = {
path: this.getNodeParameter('path', i) as string,
limit: 1000,
};
if (returnAll === false) {
const limit = this.getNodeParameter('limit', 0) as number;
body.limit = limit;
}
Object.assign(body, filters);
endpoint = 'https://api.dropboxapi.com/2/files/list_folder';
}
} else if (resource === 'search') {
if (operation === 'query') {
// ----------------------------------
// query
// ----------------------------------
returnAll = this.getNodeParameter('returnAll', 0) as boolean;
simple = this.getNodeParameter('simple', 0) as boolean;
const filters = this.getNodeParameter('filters', i) as IDataObject;
property = 'matches';
requestMethod = 'POST';
body = {
query: this.getNodeParameter('query', i) as string,
options: {
filename_only: true,
},
};
if (filters.file_extensions) {
filters.file_extensions = (filters.file_extensions as string).split(',');
}
Object.assign(body.options, filters);
if (returnAll === false) {
const limit = this.getNodeParameter('limit', i) as number;
Object.assign(body.options, { max_results: limit });
}
endpoint = 'https://api.dropboxapi.com/2/files/search_v2';
}
}
if (['file', 'folder', 'search'].includes(resource)) {
if (operation === 'copy') {
// ----------------------------------
// copy
// ----------------------------------
requestMethod = 'POST';
body = {
from_path: this.getNodeParameter('path', i) as string,
to_path: this.getNodeParameter('toPath', i) as string,
};
endpoint = 'https://api.dropboxapi.com/2/files/copy_v2';
} else if (operation === 'delete') {
// ----------------------------------
// delete
// ----------------------------------
requestMethod = 'POST';
body = {
path: this.getNodeParameter('path', i) as string,
};
endpoint = 'https://api.dropboxapi.com/2/files/delete_v2';
} else if (operation === 'move') {
// ----------------------------------
// move
// ----------------------------------
requestMethod = 'POST';
body = {
from_path: this.getNodeParameter('path', i) as string,
to_path: this.getNodeParameter('toPath', i) as string,
};
endpoint = 'https://api.dropboxapi.com/2/files/move_v2';
}
} else {
throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`);
}
if (resource === 'file' && operation === 'download') {
// Return the data as a buffer
options = { encoding: null };
}
let responseData;
if (returnAll === true) {
responseData = await dropboxpiRequestAllItems.call(this, property, requestMethod, endpoint, body, query, headers);
} else {
responseData = await dropboxApiRequest.call(this, requestMethod, endpoint, body, query, headers, options);
}
if (resource === 'file' && operation === 'upload') {
responseData = JSON.parse(responseData);
}
if (resource === 'file' && operation === 'download') {
const newItem: INodeExecutionData = {
json: items[i].json,
binary: {},
};
if (items[i].binary !== undefined) {
// Create a shallow copy of the binary data so that the old
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Object.assign(newItem.binary, items[i].binary);
}
items[i] = newItem;
const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string;
const filePathDownload = this.getNodeParameter('path', i) as string;
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(Buffer.from(responseData), filePathDownload);
} else if (resource === 'folder' && operation === 'list') {
const propNames: { [key: string]: string } = {
'id': 'id',
'name': 'name',
'client_modified': 'lastModifiedClient',
'server_modified': 'lastModifiedServer',
'rev': 'rev',
'size': 'contentSize',
'.tag': 'type',
'content_hash': 'contentHash',
'path_lower': 'pathLower',
'path_display': 'pathDisplay',
'has_explicit_shared_members': 'hasExplicitSharedMembers',
'is_downloadable': 'isDownloadable',
};
if (returnAll === false) {
responseData = responseData.entries;
}
for (const item of responseData) {
const newItem: IDataObject = {};
// Get the props and save them under a proper name
for (const propName of Object.keys(propNames)) {
if (item[propName] !== undefined) {
newItem[propNames[propName]] = item[propName];
body = Buffer.from(item.binary[propertyNameUpload].data, BINARY_ENCODING);
} else {
// Is text file
body = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'utf8');
}
}
} else if (resource === 'folder') {
if (operation === 'create') {
// ----------------------------------
// create
// ----------------------------------
returnData.push(newItem as IDataObject);
requestMethod = 'POST';
body = {
path: this.getNodeParameter('path', i) as string,
};
endpoint = 'https://api.dropboxapi.com/2/files/create_folder_v2';
} else if (operation === 'list') {
// ----------------------------------
// list
// ----------------------------------
returnAll = this.getNodeParameter('returnAll', 0) as boolean;
const filters = this.getNodeParameter('filters', i) as IDataObject;
property = 'entries';
requestMethod = 'POST';
body = {
path: this.getNodeParameter('path', i) as string,
limit: 1000,
};
if (returnAll === false) {
const limit = this.getNodeParameter('limit', 0) as number;
body.limit = limit;
}
Object.assign(body, filters);
endpoint = 'https://api.dropboxapi.com/2/files/list_folder';
}
} else if (resource === 'search') {
if (operation === 'query') {
// ----------------------------------
// query
// ----------------------------------
returnAll = this.getNodeParameter('returnAll', 0) as boolean;
simple = this.getNodeParameter('simple', 0) as boolean;
const filters = this.getNodeParameter('filters', i) as IDataObject;
property = 'matches';
requestMethod = 'POST';
body = {
query: this.getNodeParameter('query', i) as string,
options: {
filename_only: true,
},
};
if (filters.file_extensions) {
filters.file_extensions = (filters.file_extensions as string).split(',');
}
Object.assign(body.options, filters);
if (returnAll === false) {
const limit = this.getNodeParameter('limit', i) as number;
Object.assign(body.options, { max_results: limit });
}
endpoint = 'https://api.dropboxapi.com/2/files/search_v2';
}
}
} else if (resource === 'search' && operation === 'query') {
if (returnAll === true) {
returnData.push.apply(returnData, (simple === true) ? simplify(responseData) : responseData);
if (['file', 'folder', 'search'].includes(resource)) {
if (operation === 'copy') {
// ----------------------------------
// copy
// ----------------------------------
requestMethod = 'POST';
body = {
from_path: this.getNodeParameter('path', i) as string,
to_path: this.getNodeParameter('toPath', i) as string,
};
endpoint = 'https://api.dropboxapi.com/2/files/copy_v2';
} else if (operation === 'delete') {
// ----------------------------------
// delete
// ----------------------------------
requestMethod = 'POST';
body = {
path: this.getNodeParameter('path', i) as string,
};
endpoint = 'https://api.dropboxapi.com/2/files/delete_v2';
} else if (operation === 'move') {
// ----------------------------------
// move
// ----------------------------------
requestMethod = 'POST';
body = {
from_path: this.getNodeParameter('path', i) as string,
to_path: this.getNodeParameter('toPath', i) as string,
};
endpoint = 'https://api.dropboxapi.com/2/files/move_v2';
}
} else {
returnData.push.apply(returnData, (simple === true) ? simplify(responseData[property]) : responseData[property]);
throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`);
}
} else {
returnData.push(responseData);
if (resource === 'file' && operation === 'download') {
// Return the data as a buffer
options = { encoding: null };
}
let responseData;
if (returnAll === true) {
responseData = await dropboxpiRequestAllItems.call(this, property, requestMethod, endpoint, body, query, headers);
} else {
responseData = await dropboxApiRequest.call(this, requestMethod, endpoint, body, query, headers, options);
}
if (resource === 'file' && operation === 'upload') {
responseData = JSON.parse(responseData);
}
if (resource === 'file' && operation === 'download') {
const newItem: INodeExecutionData = {
json: items[i].json,
binary: {},
};
if (items[i].binary !== undefined) {
// Create a shallow copy of the binary data so that the old
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
Object.assign(newItem.binary, items[i].binary);
}
items[i] = newItem;
const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string;
const filePathDownload = this.getNodeParameter('path', i) as string;
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(Buffer.from(responseData), filePathDownload);
} else if (resource === 'folder' && operation === 'list') {
const propNames: { [key: string]: string } = {
'id': 'id',
'name': 'name',
'client_modified': 'lastModifiedClient',
'server_modified': 'lastModifiedServer',
'rev': 'rev',
'size': 'contentSize',
'.tag': 'type',
'content_hash': 'contentHash',
'path_lower': 'pathLower',
'path_display': 'pathDisplay',
'has_explicit_shared_members': 'hasExplicitSharedMembers',
'is_downloadable': 'isDownloadable',
};
if (returnAll === false) {
responseData = responseData.entries;
}
for (const item of responseData) {
const newItem: IDataObject = {};
// Get the props and save them under a proper name
for (const propName of Object.keys(propNames)) {
if (item[propName] !== undefined) {
newItem[propNames[propName]] = item[propName];
}
}
returnData.push(newItem as IDataObject);
}
} else if (resource === 'search' && operation === 'query') {
if (returnAll === true) {
returnData.push.apply(returnData, (simple === true) ? simplify(responseData) : responseData);
} else {
returnData.push.apply(returnData, (simple === true) ? simplify(responseData[property]) : responseData[property]);
}
} else {
returnData.push(responseData);
}
} catch (error) {
if (this.continueOnFail()) {
if (resource === 'file' && operation === 'download'){
items[i].json = { error: error.message };
}else{
returnData.push({ error: error.message });
}
continue;
}
throw error;
}
}