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

@@ -36,9 +36,7 @@ export class Dropbox implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'accessToken',
],
authentication: ['accessToken'],
},
},
},
@@ -47,9 +45,7 @@ export class Dropbox implements INodeType {
required: true,
displayOptions: {
show: {
authentication: [
'oAuth2',
],
authentication: ['oAuth2'],
},
},
},
@@ -104,9 +100,7 @@ export class Dropbox implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'file',
],
resource: ['file'],
},
},
options: [
@@ -151,9 +145,7 @@ export class Dropbox implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'folder',
],
resource: ['folder'],
},
},
options: [
@@ -198,9 +190,7 @@ export class Dropbox implements INodeType {
noDataExpression: true,
displayOptions: {
show: {
resource: [
'search',
],
resource: ['search'],
},
},
options: [
@@ -228,13 +218,8 @@ export class Dropbox implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'copy',
],
resource: [
'file',
'folder',
],
operation: ['copy'],
resource: ['file', 'folder'],
},
},
placeholder: '/invoices/original.txt',
@@ -248,13 +233,8 @@ export class Dropbox implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'copy',
],
resource: [
'file',
'folder',
],
operation: ['copy'],
resource: ['file', 'folder'],
},
},
placeholder: '/invoices/copy.txt',
@@ -272,20 +252,14 @@ export class Dropbox implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'delete',
],
resource: [
'file',
'folder',
],
operation: ['delete'],
resource: ['file', 'folder'],
},
},
placeholder: '/invoices/2019/invoice_1.pdf',
description: 'The path to delete. Can be a single file or a whole folder.',
},
// ----------------------------------
// file/folder:move
// ----------------------------------
@@ -297,13 +271,8 @@ export class Dropbox implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'move',
],
resource: [
'file',
'folder',
],
operation: ['move'],
resource: ['file', 'folder'],
},
},
placeholder: '/invoices/old_name.txt',
@@ -317,13 +286,8 @@ export class Dropbox implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'move',
],
resource: [
'file',
'folder',
],
operation: ['move'],
resource: ['file', 'folder'],
},
},
placeholder: '/invoices/new_name.txt',
@@ -341,12 +305,8 @@ export class Dropbox implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'download',
],
resource: [
'file',
],
operation: ['download'],
resource: ['file'],
},
},
placeholder: '/invoices/2019/invoice_1.pdf',
@@ -360,12 +320,8 @@ export class Dropbox implements INodeType {
default: 'data',
displayOptions: {
show: {
operation: [
'download',
],
resource: [
'file',
],
operation: ['download'],
resource: ['file'],
},
},
description: 'Name of the binary property to which to write the data of the read file',
@@ -382,16 +338,13 @@ export class Dropbox implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'upload',
],
resource: [
'file',
],
operation: ['upload'],
resource: ['file'],
},
},
placeholder: '/invoices/2019/invoice_1.pdf',
description: 'The file path of the file to upload. Has to contain the full path. The parent folder has to exist. Existing files get overwritten.',
description:
'The file path of the file to upload. Has to contain the full path. The parent folder has to exist. Existing files get overwritten.',
},
{
displayName: 'Binary Data',
@@ -400,12 +353,8 @@ export class Dropbox implements INodeType {
default: false,
displayOptions: {
show: {
operation: [
'upload',
],
resource: [
'file',
],
operation: ['upload'],
resource: ['file'],
},
},
description: 'Whether the data to upload should be taken from binary field',
@@ -417,17 +366,10 @@ export class Dropbox implements INodeType {
default: '',
displayOptions: {
show: {
operation: [
'upload',
],
resource: [
'file',
],
binaryData: [
false,
],
operation: ['upload'],
resource: ['file'],
binaryData: [false],
},
},
placeholder: '',
description: 'The text content of the file to upload',
@@ -440,20 +382,14 @@ export class Dropbox implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'upload',
],
resource: [
'file',
],
binaryData: [
true,
],
operation: ['upload'],
resource: ['file'],
binaryData: [true],
},
},
placeholder: '',
description: 'Name of the binary property which contains the data for the file to be uploaded',
description:
'Name of the binary property which contains the data for the file to be uploaded',
},
// ----------------------------------
@@ -467,15 +403,12 @@ export class Dropbox implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'query',
],
resource: [
'search',
],
operation: ['query'],
resource: ['search'],
},
},
description: 'The string to search for. May match across multiple fields based on the request arguments.',
description:
'The string to search for. May match across multiple fields based on the request arguments.',
},
{
displayName: 'File Status',
@@ -494,15 +427,12 @@ export class Dropbox implements INodeType {
default: 'active',
displayOptions: {
show: {
operation: [
'query',
],
resource: [
'search',
],
operation: ['query'],
resource: ['search'],
},
},
description: 'The string to search for. May match across multiple fields based on the request arguments.',
description:
'The string to search for. May match across multiple fields based on the request arguments.',
},
{
displayName: 'Return All',
@@ -510,12 +440,8 @@ export class Dropbox implements INodeType {
type: 'boolean',
displayOptions: {
show: {
operation: [
'query',
],
resource: [
'search',
],
operation: ['query'],
resource: ['search'],
},
},
default: false,
@@ -530,15 +456,9 @@ export class Dropbox implements INodeType {
},
displayOptions: {
show: {
resource: [
'search',
],
operation: [
'query',
],
returnAll: [
false,
],
resource: ['search'],
operation: ['query'],
returnAll: [false],
},
},
default: 100,
@@ -550,16 +470,13 @@ export class Dropbox implements INodeType {
type: 'boolean',
displayOptions: {
show: {
operation: [
'query',
],
resource: [
'search',
],
operation: ['query'],
resource: ['search'],
},
},
default: true,
description: 'Whether to return a simplified version of the response instead of the raw data',
description:
'Whether to return a simplified version of the response instead of the raw data',
},
{
displayName: 'Filters',
@@ -569,12 +486,8 @@ export class Dropbox implements INodeType {
default: {},
displayOptions: {
show: {
resource: [
'search',
],
operation: [
'query',
],
resource: ['search'],
operation: ['query'],
},
},
options: [
@@ -637,7 +550,8 @@ export class Dropbox implements INodeType {
name: 'file_extensions',
type: 'string',
default: '',
description: 'Multiple file extensions can be set separated by comma. Example: jpg,pdf.',
description:
'Multiple file extensions can be set separated by comma. Example: jpg,pdf.',
},
{
displayName: 'Folder',
@@ -664,12 +578,8 @@ export class Dropbox implements INodeType {
required: true,
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'folder',
],
operation: ['create'],
resource: ['folder'],
},
},
placeholder: '/invoices/2019',
@@ -686,12 +596,8 @@ export class Dropbox implements INodeType {
default: '',
displayOptions: {
show: {
operation: [
'list',
],
resource: [
'folder',
],
operation: ['list'],
resource: ['folder'],
},
},
placeholder: '/invoices/2019/',
@@ -703,12 +609,8 @@ export class Dropbox implements INodeType {
type: 'boolean',
displayOptions: {
show: {
operation: [
'list',
],
resource: [
'folder',
],
operation: ['list'],
resource: ['folder'],
},
},
default: false,
@@ -723,15 +625,9 @@ export class Dropbox implements INodeType {
},
displayOptions: {
show: {
resource: [
'folder',
],
operation: [
'list',
],
returnAll: [
false,
],
resource: ['folder'],
operation: ['list'],
returnAll: [false],
},
},
default: 100,
@@ -745,12 +641,8 @@ export class Dropbox implements INodeType {
default: {},
displayOptions: {
show: {
resource: [
'folder',
],
operation: [
'list',
],
resource: ['folder'],
operation: ['list'],
},
},
options: [
@@ -759,47 +651,50 @@ export class Dropbox implements INodeType {
name: 'include_deleted',
type: 'boolean',
default: false,
description: 'Whether the results will include entries for files and folders that used to exist but were deleted. The default for this field is False.',
description:
'Whether the results will include entries for files and folders that used to exist but were deleted. The default for this field is False.',
},
{
displayName: 'Include Shared Members',
name: 'include_has_explicit_shared_members',
type: 'boolean',
default: false,
description: 'Whether the results will include a flag for each file indicating whether or not that file has any explicit members. The default for this field is False.',
description:
'Whether the results will include a flag for each file indicating whether or not that file has any explicit members. The default for this field is False.',
},
{
displayName: 'Include Mounted Folders',
name: 'include_mounted_folders',
type: 'boolean',
default: true,
description: 'Whether the results will include entries under mounted folders which includes app folder, shared folder and team folder. The default for this field is True.',
description:
'Whether the results will include entries under mounted folders which includes app folder, shared folder and team folder. The default for this field is True.',
},
{
displayName: 'Include Non Downloadable Files',
name: 'include_non_downloadable_files',
type: 'boolean',
default: true,
description: 'Whether to include files that are not downloadable, i.e. Google Docs. The default for this field is True.',
description:
'Whether to include files that are not downloadable, i.e. Google Docs. The default for this field is True.',
},
{
displayName: 'Recursive',
name: 'recursive',
type: 'boolean',
default: false,
description: 'Whether the list folder operation will be applied recursively to all subfolders and the response will contain contents of all subfolders. The default for this field is False.',
description:
'Whether the list folder operation will be applied recursively to all subfolders and the response will contain contents of all subfolders. The default for this field is False.',
},
],
},
],
};
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const items = this.getInputData();
const returnData: IDataObject[] = [];
const resource = this.getNodeParameter('resource', 0) as string;
const operation = this.getNodeParameter('operation', 0) as string;
@@ -814,17 +709,18 @@ export class Dropbox implements INodeType {
let headers: IDataObject = {};
let simple = false;
const { accessType } = await getCredentials.call(this);
if (accessType === 'full') {
// get the root directory to set it as the default for all operations
const { root_info: { root_namespace_id } } = await getRootDirectory.call(this);
const {
root_info: { root_namespace_id },
} = await getRootDirectory.call(this);
headers = {
'dropbox-api-path-root': JSON.stringify({
'.tag': 'root',
'root': root_namespace_id,
root: root_namespace_id,
}),
};
}
@@ -846,7 +742,6 @@ export class Dropbox implements INodeType {
});
endpoint = 'https://content.dropboxapi.com/2/files/download';
} else if (operation === 'upload') {
// ----------------------------------
// upload
@@ -865,18 +760,23 @@ export class Dropbox implements INodeType {
options = { json: false };
if (this.getNodeParameter('binaryData', i) === true) {
// Is binary file to upload
const item = items[i];
if (item.binary === undefined) {
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i });
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {
itemIndex: i,
});
}
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!`, { itemIndex: i });
throw new NodeOperationError(
this.getNode(),
`No binary data property "${propertyNameUpload}" does not exists on item!`,
{ itemIndex: i },
);
}
body = await this.helpers.getBinaryDataBuffer(i, propertyNameUpload);
@@ -897,7 +797,6 @@ export class Dropbox implements INodeType {
};
endpoint = 'https://api.dropboxapi.com/2/files/create_folder_v2';
} else if (operation === 'list') {
// ----------------------------------
// list
@@ -923,7 +822,6 @@ export class Dropbox implements INodeType {
Object.assign(body, filters);
endpoint = 'https://api.dropboxapi.com/2/files/list_folder';
}
} else if (resource === 'search') {
if (operation === 'query') {
@@ -974,7 +872,6 @@ export class Dropbox implements INodeType {
};
endpoint = 'https://api.dropboxapi.com/2/files/copy_v2';
} else if (operation === 'delete') {
// ----------------------------------
// delete
@@ -986,7 +883,6 @@ export class Dropbox implements INodeType {
};
endpoint = 'https://api.dropboxapi.com/2/files/delete_v2';
} else if (operation === 'move') {
// ----------------------------------
// move
@@ -1001,7 +897,9 @@ export class Dropbox implements INodeType {
endpoint = 'https://api.dropboxapi.com/2/files/move_v2';
}
} else {
throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, { itemIndex: i });
throw new NodeOperationError(this.getNode(), `The resource "${resource}" is not known!`, {
itemIndex: i,
});
}
if (resource === 'file' && operation === 'download') {
@@ -1012,9 +910,25 @@ export class Dropbox implements INodeType {
let responseData;
if (returnAll === true) {
responseData = await dropboxpiRequestAllItems.call(this, property, requestMethod, endpoint, body, query, headers);
responseData = await dropboxpiRequestAllItems.call(
this,
property,
requestMethod,
endpoint,
body,
query,
headers,
);
} else {
responseData = await dropboxApiRequest.call(this, requestMethod, endpoint, body, query, headers, options);
responseData = await dropboxApiRequest.call(
this,
requestMethod,
endpoint,
body,
query,
headers,
options,
);
}
if (resource === 'file' && operation === 'upload') {
@@ -1022,7 +936,6 @@ export class Dropbox implements INodeType {
}
if (resource === 'file' && operation === 'download') {
const newItem: INodeExecutionData = {
json: items[i].json,
binary: {},
@@ -1040,23 +953,24 @@ export class Dropbox implements INodeType {
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);
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',
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',
content_hash: 'contentHash',
path_lower: 'pathLower',
path_display: 'pathDisplay',
has_explicit_shared_members: 'hasExplicitSharedMembers',
is_downloadable: 'isDownloadable',
};
if (returnAll === false) {
@@ -1077,18 +991,24 @@ export class Dropbox implements INodeType {
}
} else if (resource === 'search' && operation === 'query') {
if (returnAll === true) {
returnData.push.apply(returnData, (simple === true) ? simplify(responseData) : responseData);
returnData.push.apply(
returnData,
simple === true ? simplify(responseData) : responseData,
);
} else {
returnData.push.apply(returnData, (simple === true) ? simplify(responseData[property]) : responseData[property]);
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'){
if (resource === 'file' && operation === 'download') {
items[i].json = { error: error.message };
}else{
} else {
returnData.push({ error: error.message });
}
continue;