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

@@ -1,6 +1,4 @@
import {
IExecuteFunctions,
} from 'n8n-core';
import { IExecuteFunctions } from 'n8n-core';
import {
IBinaryKeyData,
@@ -11,26 +9,15 @@ import {
NodeOperationError,
} from 'n8n-workflow';
import {
boxApiRequest,
boxApiRequestAllItems,
} from './GenericFunctions';
import { boxApiRequest, boxApiRequestAllItems } from './GenericFunctions';
import {
fileFields,
fileOperations,
} from './FileDescription';
import { fileFields, fileOperations } from './FileDescription';
import {
folderFields,
folderOperations,
} from './FolderDescription';
import { folderFields, folderOperations } from './FolderDescription';
import moment from 'moment-timezone';
import {
noCase,
} from 'change-case';
import { noCase } from 'change-case';
export class Box implements INodeType {
description: INodeTypeDescription = {
@@ -110,7 +97,13 @@ export class Box implements INodeType {
if (additionalFields.version) {
body.version = additionalFields.version as string;
}
responseData = await boxApiRequest.call(this, 'POST', `/files/${fileId}/copy`, body, qs);
responseData = await boxApiRequest.call(
this,
'POST',
`/files/${fileId}/copy`,
body,
qs,
);
returnData.push(responseData as IDataObject);
}
@@ -124,14 +117,25 @@ export class Box implements INodeType {
// https://developer.box.com/reference/get-files-id-content
if (operation === 'download') {
const fileId = this.getNodeParameter('fileId', i) as string;
const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string;
const dataPropertyNameDownload = this.getNodeParameter(
'binaryPropertyName',
i,
) as string;
responseData = await boxApiRequest.call(this, 'GET', `/files/${fileId}`);
const fileName = responseData.name;
let mimeType: string | undefined;
responseData = await boxApiRequest.call(this, 'GET', `/files/${fileId}/content`, {}, {}, undefined, { encoding: null, resolveWithFullResponse: true });
responseData = await boxApiRequest.call(
this,
'GET',
`/files/${fileId}/content`,
{},
{},
undefined,
{ encoding: null, resolveWithFullResponse: true },
);
const newItem: INodeExecutionData = {
json: items[i].json,
@@ -153,7 +157,11 @@ export class Box implements INodeType {
const data = Buffer.from(responseData.body);
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(data as unknown as Buffer, fileName, mimeType);
items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData(
data as unknown as Buffer,
fileName,
mimeType,
);
}
// https://developer.box.com/reference/get-files-id
if (operation === 'get') {
@@ -180,23 +188,36 @@ export class Box implements INodeType {
}
if (additionalFields.createdRangeUi) {
const createdRangeValues = (additionalFields.createdRangeUi as IDataObject).createdRangeValuesUi as IDataObject;
const createdRangeValues = (additionalFields.createdRangeUi as IDataObject)
.createdRangeValuesUi as IDataObject;
if (createdRangeValues) {
qs.created_at_range = `${moment.tz(createdRangeValues.from, timezone).format()},${moment.tz(createdRangeValues.to, timezone).format()}`;
qs.created_at_range = `${moment
.tz(createdRangeValues.from, timezone)
.format()},${moment.tz(createdRangeValues.to, timezone).format()}`;
}
delete qs.createdRangeUi;
}
if (additionalFields.updatedRangeUi) {
const updateRangeValues = (additionalFields.updatedRangeUi as IDataObject).updatedRangeValuesUi as IDataObject;
const updateRangeValues = (additionalFields.updatedRangeUi as IDataObject)
.updatedRangeValuesUi as IDataObject;
if (updateRangeValues) {
qs.updated_at_range = `${moment.tz(updateRangeValues.from, timezone).format()},${moment.tz(updateRangeValues.to, timezone).format()}`;
qs.updated_at_range = `${moment
.tz(updateRangeValues.from, timezone)
.format()},${moment.tz(updateRangeValues.to, timezone).format()}`;
}
delete qs.updatedRangeUi;
}
if (returnAll) {
responseData = await boxApiRequestAllItems.call(this, 'entries', 'GET', `/search`, {}, qs);
responseData = await boxApiRequestAllItems.call(
this,
'entries',
'GET',
`/search`,
{},
qs,
);
} else {
qs.limit = this.getNodeParameter('limit', i) as number;
responseData = await boxApiRequest.call(this, 'GET', `/search`, {}, qs);
@@ -211,13 +232,13 @@ export class Box implements INodeType {
const accessibleBy = this.getNodeParameter('accessibleBy', i) as string;
const options = this.getNodeParameter('options', i) as IDataObject;
// tslint:disable-next-line: no-any
const body: { accessible_by: IDataObject, [key: string]: any } = {
const body: { accessible_by: IDataObject; [key: string]: any } = {
accessible_by: {},
item: {
id: fileId,
type: 'file',
},
role: (role === 'coOwner') ? 'co-owner' : noCase(role),
role: role === 'coOwner' ? 'co-owner' : noCase(role),
...options,
};
@@ -268,15 +289,24 @@ export class Box implements INodeType {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', 0) as string;
if (items[i].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,
});
}
//@ts-ignore
if (items[i].binary[binaryPropertyName] === undefined) {
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i });
throw new NodeOperationError(
this.getNode(),
`No binary data property "${binaryPropertyName}" does not exists on item!`,
{ itemIndex: i },
);
}
const binaryData = (items[i].binary as IBinaryKeyData)[binaryPropertyName];
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(
i,
binaryPropertyName,
);
const body: IDataObject = {};
@@ -292,15 +322,24 @@ export class Box implements INodeType {
},
};
responseData = await boxApiRequest.call(this, 'POST', '', {}, {}, 'https://upload.box.com/api/2.0/files/content', { formData: body });
responseData = await boxApiRequest.call(
this,
'POST',
'',
{},
{},
'https://upload.box.com/api/2.0/files/content',
{ formData: body },
);
returnData.push.apply(returnData, responseData.entries as IDataObject[]);
} else {
const content = this.getNodeParameter('fileContent', i) as string;
if (fileName === '') {
throw new NodeOperationError(this.getNode(), 'File name must be set!', { itemIndex: i });
throw new NodeOperationError(this.getNode(), 'File name must be set!', {
itemIndex: i,
});
}
attributes['name'] = fileName;
@@ -316,7 +355,15 @@ export class Box implements INodeType {
contentType: 'text/plain',
},
};
responseData = await boxApiRequest.call(this, 'POST', '', {}, {}, 'https://upload.box.com/api/2.0/files/content', { formData: body });
responseData = await boxApiRequest.call(
this,
'POST',
'',
{},
{},
'https://upload.box.com/api/2.0/files/content',
{ formData: body },
);
returnData.push.apply(returnData, responseData.entries as IDataObject[]);
}
@@ -383,23 +430,36 @@ export class Box implements INodeType {
}
if (additionalFields.createdRangeUi) {
const createdRangeValues = (additionalFields.createdRangeUi as IDataObject).createdRangeValuesUi as IDataObject;
const createdRangeValues = (additionalFields.createdRangeUi as IDataObject)
.createdRangeValuesUi as IDataObject;
if (createdRangeValues) {
qs.created_at_range = `${moment.tz(createdRangeValues.from, timezone).format()},${moment.tz(createdRangeValues.to, timezone).format()}`;
qs.created_at_range = `${moment
.tz(createdRangeValues.from, timezone)
.format()},${moment.tz(createdRangeValues.to, timezone).format()}`;
}
delete qs.createdRangeUi;
}
if (additionalFields.updatedRangeUi) {
const updateRangeValues = (additionalFields.updatedRangeUi as IDataObject).updatedRangeValuesUi as IDataObject;
const updateRangeValues = (additionalFields.updatedRangeUi as IDataObject)
.updatedRangeValuesUi as IDataObject;
if (updateRangeValues) {
qs.updated_at_range = `${moment.tz(updateRangeValues.from, timezone).format()},${moment.tz(updateRangeValues.to, timezone).format()}`;
qs.updated_at_range = `${moment
.tz(updateRangeValues.from, timezone)
.format()},${moment.tz(updateRangeValues.to, timezone).format()}`;
}
delete qs.updatedRangeUi;
}
if (returnAll) {
responseData = await boxApiRequestAllItems.call(this, 'entries', 'GET', `/search`, {}, qs);
responseData = await boxApiRequestAllItems.call(
this,
'entries',
'GET',
`/search`,
{},
qs,
);
} else {
qs.limit = this.getNodeParameter('limit', i) as number;
responseData = await boxApiRequest.call(this, 'GET', `/search`, {}, qs);
@@ -414,13 +474,13 @@ export class Box implements INodeType {
const accessibleBy = this.getNodeParameter('accessibleBy', i) as string;
const options = this.getNodeParameter('options', i) as IDataObject;
// tslint:disable-next-line: no-any
const body: { accessible_by: IDataObject, [key: string]: any } = {
const body: { accessible_by: IDataObject; [key: string]: any } = {
accessible_by: {},
item: {
id: folderId,
type: 'folder',
},
role: (role === 'coOwner') ? 'co-owner' : noCase(role),
role: role === 'coOwner' ? 'co-owner' : noCase(role),
...options,
};

View File

@@ -1,18 +1,8 @@
import {
IHookFunctions,
IWebhookFunctions,
} from 'n8n-core';
import { IHookFunctions, IWebhookFunctions } from 'n8n-core';
import {
INodeType,
INodeTypeDescription,
IWebhookResponseData,
} from 'n8n-workflow';
import { INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow';
import {
boxApiRequest,
boxApiRequestAllItems,
} from './GenericFunctions';
import { boxApiRequest, boxApiRequestAllItems } from './GenericFunctions';
export class BoxTrigger implements INodeType {
description: INodeTypeDescription = {
@@ -191,12 +181,14 @@ export class BoxTrigger implements INodeType {
{
name: 'Metadata Instance Deleted',
value: 'METADATA_INSTANCE.DELETED',
description: 'An existing metadata template instance associated with a file or folder is deleted',
description:
'An existing metadata template instance associated with a file or folder is deleted',
},
{
name: 'Metadata Instance Updated',
value: 'METADATA_INSTANCE.UPDATED',
description: 'An attribute (value) is updated/deleted for an existing metadata template instance associated with a file or folder',
description:
'An attribute (value) is updated/deleted for an existing metadata template instance associated with a file or folder',
},
{
name: 'Sharedlink Created',
@@ -275,9 +267,11 @@ export class BoxTrigger implements INodeType {
const webhooks = await boxApiRequestAllItems.call(this, 'entries', 'GET', endpoint, {});
for (const webhook of webhooks) {
if (webhook.address === webhookUrl &&
if (
webhook.address === webhookUrl &&
webhook.target.id === targetId &&
webhook.target.type === targetType) {
webhook.target.type === targetType
) {
for (const event of events) {
if (!webhook.triggers.includes(event)) {
return false;
@@ -321,7 +315,6 @@ export class BoxTrigger implements INodeType {
async delete(this: IHookFunctions): Promise<boolean> {
const webhookData = this.getWorkflowStaticData('node');
if (webhookData.webhookId !== undefined) {
const endpoint = `/webhooks/${webhookData.webhookId}`;
try {
@@ -343,9 +336,7 @@ export class BoxTrigger implements INodeType {
const bodyData = this.getBodyData();
return {
workflowData: [
this.helpers.returnJsonArray(bodyData),
],
workflowData: [this.helpers.returnJsonArray(bodyData)],
};
}
}

View File

@@ -1,6 +1,4 @@
import {
INodeProperties,
} from 'n8n-workflow';
import { INodeProperties } from 'n8n-workflow';
export const fileOperations: INodeProperties[] = [
{
@@ -10,9 +8,7 @@ export const fileOperations: INodeProperties[] = [
noDataExpression: true,
displayOptions: {
show: {
resource: [
'file',
],
resource: ['file'],
},
},
options: [
@@ -64,7 +60,6 @@ export const fileOperations: INodeProperties[] = [
];
export const fileFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* file:copy */
/* -------------------------------------------------------------------------- */
@@ -75,12 +70,8 @@ export const fileFields: INodeProperties[] = [
required: true,
displayOptions: {
show: {
operation: [
'copy',
],
resource: [
'file',
],
operation: ['copy'],
resource: ['file'],
},
},
default: '',
@@ -92,15 +83,12 @@ export const fileFields: INodeProperties[] = [
default: '',
displayOptions: {
show: {
operation: [
'copy',
],
resource: [
'file',
],
operation: ['copy'],
resource: ['file'],
},
},
description: 'The ID of folder to copy the file to. If not defined will be copied to the root folder.',
description:
'The ID of folder to copy the file to. If not defined will be copied to the root folder.',
},
{
displayName: 'Additional Fields',
@@ -109,12 +97,8 @@ export const fileFields: INodeProperties[] = [
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'copy',
],
resource: [
'file',
],
operation: ['copy'],
resource: ['file'],
},
},
default: {},
@@ -124,7 +108,8 @@ export const fileFields: INodeProperties[] = [
name: 'fields',
type: 'string',
default: '',
description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
description:
'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
},
{
displayName: 'Name',
@@ -152,12 +137,8 @@ export const fileFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'delete',
],
resource: [
'file',
],
operation: ['delete'],
resource: ['file'],
},
},
default: '',
@@ -173,12 +154,8 @@ export const fileFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'download',
],
resource: [
'file',
],
operation: ['download'],
resource: ['file'],
},
},
default: '',
@@ -191,12 +168,8 @@ export const fileFields: INodeProperties[] = [
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',
@@ -211,12 +184,8 @@ export const fileFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'file',
],
operation: ['get'],
resource: ['file'],
},
},
default: '',
@@ -229,12 +198,8 @@ export const fileFields: INodeProperties[] = [
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'file',
],
operation: ['get'],
resource: ['file'],
},
},
default: {},
@@ -244,7 +209,8 @@ export const fileFields: INodeProperties[] = [
name: 'fields',
type: 'string',
default: '',
description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
description:
'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
},
],
},
@@ -258,16 +224,13 @@ export const fileFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'search',
],
resource: [
'file',
],
operation: ['search'],
resource: ['file'],
},
},
default: '',
description: 'The string to search for. This query is matched against item names, descriptions, text content of files, and various other fields of the different item types.',
description:
'The string to search for. This query is matched against item names, descriptions, text content of files, and various other fields of the different item types.',
},
{
displayName: 'Return All',
@@ -275,12 +238,8 @@ export const fileFields: INodeProperties[] = [
type: 'boolean',
displayOptions: {
show: {
operation: [
'search',
],
resource: [
'file',
],
operation: ['search'],
resource: ['file'],
},
},
default: false,
@@ -292,15 +251,9 @@ export const fileFields: INodeProperties[] = [
type: 'number',
displayOptions: {
show: {
operation: [
'search',
],
resource: [
'file',
],
returnAll: [
false,
],
operation: ['search'],
resource: ['file'],
returnAll: [false],
},
},
typeOptions: {
@@ -317,12 +270,8 @@ export const fileFields: INodeProperties[] = [
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'search',
],
resource: [
'file',
],
operation: ['search'],
resource: ['file'],
},
},
default: {},
@@ -332,7 +281,8 @@ export const fileFields: INodeProperties[] = [
name: 'contet_types',
type: 'string',
default: '',
description: 'Limits search results to items with the given content types. Content types are defined as a comma-separated lists of Box recognized content types.',
description:
'Limits search results to items with the given content types. Content types are defined as a comma-separated lists of Box recognized content types.',
},
{
displayName: 'Created At Range',
@@ -379,14 +329,16 @@ export const fileFields: INodeProperties[] = [
},
],
default: '',
description: 'Defines the direction in which search results are ordered. Default value is DESC.',
description:
'Defines the direction in which search results are ordered. Default value is DESC.',
},
{
displayName: 'Fields',
name: 'fields',
type: 'string',
default: '',
description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
description:
'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
},
{
displayName: 'File Extensions',
@@ -401,7 +353,8 @@ export const fileFields: INodeProperties[] = [
name: 'ancestor_folder_ids',
type: 'string',
default: '',
description: 'Limits search results to items within the given list of folders. Folders are defined as a comma-separated lists of folder IDs.',
description:
'Limits search results to items within the given list of folders. Folders are defined as a comma-separated lists of folder IDs.',
},
{
displayName: 'Scope',
@@ -426,7 +379,8 @@ export const fileFields: INodeProperties[] = [
type: 'string',
default: '',
placeholder: '1000000,5000000',
description: 'Limits search results to items within a given file size range. File size ranges are defined as comma-separated byte sizes.',
description:
'Limits search results to items within a given file size range. File size ranges are defined as comma-separated byte sizes.',
},
{
displayName: 'Sort',
@@ -443,7 +397,8 @@ export const fileFields: INodeProperties[] = [
},
],
default: 'relevance',
description: 'Returns the results ordered in descending order by date at which the item was last modified',
description:
'Returns the results ordered in descending order by date at which the item was last modified',
},
{
displayName: 'Trash Content',
@@ -497,7 +452,8 @@ export const fileFields: INodeProperties[] = [
name: 'owner_user_ids',
type: 'string',
default: '',
description: 'Limits search results to items owned by the given list of owners. Owners are defined as a comma-separated list of user IDs.',
description:
'Limits search results to items owned by the given list of owners. Owners are defined as a comma-separated list of user IDs.',
},
],
},
@@ -511,12 +467,8 @@ export const fileFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'file',
],
operation: ['share'],
resource: ['file'],
},
},
default: '',
@@ -538,12 +490,8 @@ export const fileFields: INodeProperties[] = [
],
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'file',
],
operation: ['share'],
resource: ['file'],
},
},
default: '',
@@ -555,15 +503,9 @@ export const fileFields: INodeProperties[] = [
type: 'boolean',
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'file',
],
accessibleBy: [
'user',
],
operation: ['share'],
resource: ['file'],
accessibleBy: ['user'],
},
},
default: true,
@@ -576,22 +518,14 @@ export const fileFields: INodeProperties[] = [
placeholder: 'name@email.com',
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'file',
],
useEmail: [
true,
],
accessibleBy: [
'user',
],
operation: ['share'],
resource: ['file'],
useEmail: [true],
accessibleBy: ['user'],
},
},
default: '',
description: 'The user\'s email address to share the file with',
description: "The user's email address to share the file with",
},
{
displayName: 'User ID',
@@ -599,22 +533,14 @@ export const fileFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'file',
],
useEmail: [
false,
],
accessibleBy: [
'user',
],
operation: ['share'],
resource: ['file'],
useEmail: [false],
accessibleBy: ['user'],
},
},
default: '',
description: 'The user\'s ID to share the file with',
description: "The user's ID to share the file with",
},
{
displayName: 'Group ID',
@@ -622,19 +548,13 @@ export const fileFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'file',
],
accessibleBy: [
'group',
],
operation: ['share'],
resource: ['file'],
accessibleBy: ['group'],
},
},
default: '',
description: 'The group\'s ID to share the file with',
description: "The group's ID to share the file with",
},
{
displayName: 'Role',
@@ -679,12 +599,8 @@ export const fileFields: INodeProperties[] = [
],
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'file',
],
operation: ['share'],
resource: ['file'],
},
},
default: 'editor',
@@ -697,12 +613,8 @@ export const fileFields: INodeProperties[] = [
placeholder: 'Add Option',
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'file',
],
operation: ['share'],
resource: ['file'],
},
},
default: {},
@@ -712,21 +624,24 @@ export const fileFields: INodeProperties[] = [
name: 'can_view_path',
type: 'boolean',
default: false,
description: 'Whether the invited users can see the entire parent path to the associated folder. The user will not gain privileges in any parent folder and therefore cannot see content the user is not collaborated on.',
description:
'Whether the invited users can see the entire parent path to the associated folder. The user will not gain privileges in any parent folder and therefore cannot see content the user is not collaborated on.',
},
{
displayName: 'Expires At',
name: 'expires_at',
type: 'dateTime',
default: '',
description: 'Set the expiration date for the collaboration. At this date, the collaboration will be automatically removed from the item.',
description:
'Set the expiration date for the collaboration. At this date, the collaboration will be automatically removed from the item.',
},
{
displayName: 'Fields',
name: 'fields',
type: 'string',
default: '',
description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
description:
'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
},
{
displayName: 'Notify',
@@ -748,12 +663,8 @@ export const fileFields: INodeProperties[] = [
placeholder: 'photo.png',
displayOptions: {
show: {
operation: [
'upload',
],
resource: [
'file',
],
operation: ['upload'],
resource: ['file'],
},
},
default: '',
@@ -767,12 +678,8 @@ export const fileFields: INodeProperties[] = [
required: true,
displayOptions: {
show: {
operation: [
'upload',
],
resource: [
'file',
],
operation: ['upload'],
resource: ['file'],
},
},
description: 'Whether the data to upload should be taken from binary field',
@@ -785,17 +692,10 @@ export const fileFields: INodeProperties[] = [
required: true,
displayOptions: {
show: {
binaryData: [
false,
],
operation: [
'upload',
],
resource: [
'file',
],
binaryData: [false],
operation: ['upload'],
resource: ['file'],
},
},
description: 'The text content of the file',
},
@@ -807,17 +707,10 @@ export const fileFields: INodeProperties[] = [
required: true,
displayOptions: {
show: {
binaryData: [
true,
],
operation: [
'upload',
],
resource: [
'file',
],
binaryData: [true],
operation: ['upload'],
resource: ['file'],
},
},
description: 'Name of the binary property which contains the data for the file',
},
@@ -827,15 +720,12 @@ export const fileFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'upload',
],
resource: [
'file',
],
operation: ['upload'],
resource: ['file'],
},
},
default: '',
description: 'ID of the parent folder that will contain the file. If not it will be uploaded to the root folder.',
description:
'ID of the parent folder that will contain the file. If not it will be uploaded to the root folder.',
},
];

View File

@@ -1,6 +1,4 @@
import {
INodeProperties,
} from 'n8n-workflow';
import { INodeProperties } from 'n8n-workflow';
export const folderOperations: INodeProperties[] = [
{
@@ -10,9 +8,7 @@ export const folderOperations: INodeProperties[] = [
noDataExpression: true,
displayOptions: {
show: {
resource: [
'folder',
],
resource: ['folder'],
},
},
options: [
@@ -58,7 +54,6 @@ export const folderOperations: INodeProperties[] = [
];
export const folderFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* folder:create */
/* -------------------------------------------------------------------------- */
@@ -69,16 +64,12 @@ export const folderFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'folder',
],
operation: ['create'],
resource: ['folder'],
},
},
default: '',
description: 'Folder\'s name',
description: "Folder's name",
},
{
displayName: 'Parent ID',
@@ -86,16 +77,13 @@ export const folderFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'folder',
],
operation: ['create'],
resource: ['folder'],
},
},
default: '',
description: 'ID of the folder you want to create the new folder in. if not defined it will be created on the root folder.',
description:
'ID of the folder you want to create the new folder in. if not defined it will be created on the root folder.',
},
{
displayName: 'Options',
@@ -103,12 +91,8 @@ export const folderFields: INodeProperties[] = [
type: 'collection',
displayOptions: {
show: {
operation: [
'create',
],
resource: [
'folder',
],
operation: ['create'],
resource: ['folder'],
},
},
default: {},
@@ -122,7 +106,8 @@ export const folderFields: INodeProperties[] = [
{
name: 'Collaborators',
value: 'collaborators',
description: 'Only emails from registered email addresses for collaborators will be accepted',
description:
'Only emails from registered email addresses for collaborators will be accepted',
},
{
name: 'Open',
@@ -138,7 +123,8 @@ export const folderFields: INodeProperties[] = [
name: 'fields',
type: 'string',
default: '',
description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
description:
'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
},
],
},
@@ -152,12 +138,8 @@ export const folderFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'get',
],
resource: [
'folder',
],
operation: ['get'],
resource: ['folder'],
},
},
default: '',
@@ -172,12 +154,8 @@ export const folderFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'delete',
],
resource: [
'folder',
],
operation: ['delete'],
resource: ['folder'],
},
},
default: '',
@@ -188,16 +166,13 @@ export const folderFields: INodeProperties[] = [
type: 'boolean',
displayOptions: {
show: {
operation: [
'delete',
],
resource: [
'folder',
],
operation: ['delete'],
resource: ['folder'],
},
},
default: false,
description: 'Whether to delete a folder that is not empty by recursively deleting the folder and all of its content',
description:
'Whether to delete a folder that is not empty by recursively deleting the folder and all of its content',
},
/* -------------------------------------------------------------------------- */
@@ -209,16 +184,13 @@ export const folderFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'search',
],
resource: [
'folder',
],
operation: ['search'],
resource: ['folder'],
},
},
default: '',
description: 'The string to search for. This query is matched against item names, descriptions, text content of files, and various other fields of the different item types.',
description:
'The string to search for. This query is matched against item names, descriptions, text content of files, and various other fields of the different item types.',
},
{
displayName: 'Return All',
@@ -226,12 +198,8 @@ export const folderFields: INodeProperties[] = [
type: 'boolean',
displayOptions: {
show: {
operation: [
'search',
],
resource: [
'folder',
],
operation: ['search'],
resource: ['folder'],
},
},
default: false,
@@ -243,15 +211,9 @@ export const folderFields: INodeProperties[] = [
type: 'number',
displayOptions: {
show: {
operation: [
'search',
],
resource: [
'folder',
],
returnAll: [
false,
],
operation: ['search'],
resource: ['folder'],
returnAll: [false],
},
},
typeOptions: {
@@ -268,12 +230,8 @@ export const folderFields: INodeProperties[] = [
placeholder: 'Add Field',
displayOptions: {
show: {
operation: [
'search',
],
resource: [
'folder',
],
operation: ['search'],
resource: ['folder'],
},
},
default: {},
@@ -283,7 +241,8 @@ export const folderFields: INodeProperties[] = [
name: 'contet_types',
type: 'string',
default: '',
description: 'Limits search results to items with the given content types. Content types are defined as a comma-separated lists of Box recognized content types.',
description:
'Limits search results to items with the given content types. Content types are defined as a comma-separated lists of Box recognized content types.',
},
{
displayName: 'Created At Range',
@@ -330,14 +289,16 @@ export const folderFields: INodeProperties[] = [
},
],
default: '',
description: 'Defines the direction in which search results are ordered. Default value is DESC.',
description:
'Defines the direction in which search results are ordered. Default value is DESC.',
},
{
displayName: 'Fields',
name: 'fields',
type: 'string',
default: '',
description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
description:
'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
},
{
displayName: 'File Extensions',
@@ -352,7 +313,8 @@ export const folderFields: INodeProperties[] = [
name: 'ancestor_folder_ids',
type: 'string',
default: '',
description: 'Limits search results to items within the given list of folders. Folders are defined as a comma-separated lists of folder IDs.',
description:
'Limits search results to items within the given list of folders. Folders are defined as a comma-separated lists of folder IDs.',
},
{
displayName: 'Scope',
@@ -377,7 +339,8 @@ export const folderFields: INodeProperties[] = [
type: 'string',
default: '',
placeholder: '1000000,5000000',
description: 'Limits search results to items within a given file size range. File size ranges are defined as comma-separated byte sizes.',
description:
'Limits search results to items within a given file size range. File size ranges are defined as comma-separated byte sizes.',
},
{
displayName: 'Sort',
@@ -394,7 +357,8 @@ export const folderFields: INodeProperties[] = [
},
],
default: 'relevance',
description: 'Returns the results ordered in descending order by date at which the item was last modified',
description:
'Returns the results ordered in descending order by date at which the item was last modified',
},
{
displayName: 'Trash Content',
@@ -448,7 +412,8 @@ export const folderFields: INodeProperties[] = [
name: 'owner_user_ids',
type: 'string',
default: '',
description: 'Limits search results to items owned by the given list of owners. Owners are defined as a comma-separated list of user IDs.',
description:
'Limits search results to items owned by the given list of owners. Owners are defined as a comma-separated list of user IDs.',
},
],
},
@@ -462,12 +427,8 @@ export const folderFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'folder',
],
operation: ['share'],
resource: ['folder'],
},
},
default: '',
@@ -489,12 +450,8 @@ export const folderFields: INodeProperties[] = [
],
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'folder',
],
operation: ['share'],
resource: ['folder'],
},
},
default: 'user',
@@ -506,15 +463,9 @@ export const folderFields: INodeProperties[] = [
type: 'boolean',
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'folder',
],
accessibleBy: [
'user',
],
operation: ['share'],
resource: ['folder'],
accessibleBy: ['user'],
},
},
default: true,
@@ -527,22 +478,14 @@ export const folderFields: INodeProperties[] = [
placeholder: 'name@email.com',
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'folder',
],
accessibleBy: [
'user',
],
useEmail: [
true,
],
operation: ['share'],
resource: ['folder'],
accessibleBy: ['user'],
useEmail: [true],
},
},
default: '',
description: 'The user\'s email address to share the folder with',
description: "The user's email address to share the folder with",
},
{
displayName: 'User ID',
@@ -550,22 +493,14 @@ export const folderFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'folder',
],
accessibleBy: [
'user',
],
useEmail: [
false,
],
operation: ['share'],
resource: ['folder'],
accessibleBy: ['user'],
useEmail: [false],
},
},
default: '',
description: 'The user\'s ID to share the folder with',
description: "The user's ID to share the folder with",
},
{
displayName: 'Group ID',
@@ -573,19 +508,13 @@ export const folderFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'folder',
],
accessibleBy: [
'group',
],
operation: ['share'],
resource: ['folder'],
accessibleBy: ['group'],
},
},
default: '',
description: 'The group\'s ID to share the folder with',
description: "The group's ID to share the folder with",
},
{
displayName: 'Role',
@@ -630,12 +559,8 @@ export const folderFields: INodeProperties[] = [
],
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'folder',
],
operation: ['share'],
resource: ['folder'],
},
},
default: 'editor',
@@ -648,12 +573,8 @@ export const folderFields: INodeProperties[] = [
placeholder: 'Add Option',
displayOptions: {
show: {
operation: [
'share',
],
resource: [
'folder',
],
operation: ['share'],
resource: ['folder'],
},
},
default: {},
@@ -663,21 +584,24 @@ export const folderFields: INodeProperties[] = [
name: 'can_view_path',
type: 'boolean',
default: false,
description: 'Whether the invited users can see the entire parent path to the associated folder. The user will not gain privileges in any parent folder and therefore cannot see content the user is not collaborated on.',
description:
'Whether the invited users can see the entire parent path to the associated folder. The user will not gain privileges in any parent folder and therefore cannot see content the user is not collaborated on.',
},
{
displayName: 'Expires At',
name: 'expires_at',
type: 'dateTime',
default: '',
description: 'Set the expiration date for the collaboration. At this date, the collaboration will be automatically removed from the item.',
description:
'Set the expiration date for the collaboration. At this date, the collaboration will be automatically removed from the item.',
},
{
displayName: 'Fields',
name: 'fields',
type: 'string',
default: '',
description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
description:
'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
},
{
displayName: 'Notify',
@@ -699,12 +623,8 @@ export const folderFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'update',
],
resource: [
'folder',
],
operation: ['update'],
resource: ['folder'],
},
},
default: '',
@@ -715,12 +635,8 @@ export const folderFields: INodeProperties[] = [
type: 'collection',
displayOptions: {
show: {
operation: [
'update',
],
resource: [
'folder',
],
operation: ['update'],
resource: ['folder'],
},
},
default: {},
@@ -731,14 +647,16 @@ export const folderFields: INodeProperties[] = [
name: 'can_non_owners_invite',
type: 'boolean',
default: false,
description: 'Whether users who are not the owner of the folder can invite new collaborators to the folder',
description:
'Whether users who are not the owner of the folder can invite new collaborators to the folder',
},
{
displayName: 'Can Non-Owners View Colaborators',
name: 'can_non_owners_view_collaborators',
type: 'boolean',
default: false,
description: 'Whether to restrict collaborators who are not the owner of this folder from viewing other collaborations on this folder',
description:
'Whether to restrict collaborators who are not the owner of this folder from viewing other collaborations on this folder',
},
{
displayName: 'Description',
@@ -752,14 +670,16 @@ export const folderFields: INodeProperties[] = [
name: 'fields',
type: 'string',
default: '',
description: 'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
description:
'A comma-separated list of attributes to include in the response. This can be used to request fields that are not normally returned in a standard response.',
},
{
displayName: 'Is Collaboration Restricted To Enterprise',
name: 'is_collaboration_restricted_to_enterprise',
type: 'boolean',
default: false,
description: 'Whether new invites to this folder are restricted to users within the enterprise. This does not affect existing collaborations.',
description:
'Whether new invites to this folder are restricted to users within the enterprise. This does not affect existing collaborations.',
},
{
displayName: 'Name',
@@ -773,7 +693,8 @@ export const folderFields: INodeProperties[] = [
name: 'parentId',
type: 'string',
default: '',
description: 'The parent folder for this folder. Use this to move the folder or to restore it out of the trash.',
description:
'The parent folder for this folder. Use this to move the folder or to restore it out of the trash.',
},
{
displayName: 'Shared Link',
@@ -815,13 +736,12 @@ export const folderFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
access: [
'open',
],
access: ['open'],
},
},
default: '',
description: 'The password required to access the shared link. Set the password to null to remove it.',
description:
'The password required to access the shared link. Set the password to null to remove it.',
},
{
displayName: 'Permissions',
@@ -849,7 +769,8 @@ export const folderFields: INodeProperties[] = [
name: 'vanity_name',
type: 'string',
default: '',
description: 'Defines a custom vanity name to use in the shared link URL, for example https://app.box.com/v/my-shared-link',
description:
'Defines a custom vanity name to use in the shared link URL, for example https://app.box.com/v/my-shared-link',
},
],
},
@@ -858,7 +779,8 @@ export const folderFields: INodeProperties[] = [
name: 'tags',
type: 'string',
default: '',
description: 'The tags for this item. These tags are shown in the Box web app and mobile apps next to an item.',
description:
'The tags for this item. These tags are shown in the Box web app and mobile apps next to an item.',
},
],
},

View File

@@ -1,6 +1,4 @@
import {
OptionsWithUri,
} from 'request';
import { OptionsWithUri } from 'request';
import {
IExecuteFunctions,
@@ -9,14 +7,19 @@ import {
ILoadOptionsFunctions,
} from 'n8n-core';
import {
IDataObject,
IOAuth2Options,
NodeApiError,
} from 'n8n-workflow';
export async function boxApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, resource: string, body: any = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
import { IDataObject, IOAuth2Options, NodeApiError } from 'n8n-workflow';
export async function boxApiRequest(
this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions,
method: string,
resource: string,
// tslint:disable-next-line:no-any
body: any = {},
qs: IDataObject = {},
uri?: string,
option: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
let options: OptionsWithUri = {
headers: {
'Content-Type': 'application/json',
@@ -40,14 +43,21 @@ export async function boxApiRequest(this: IExecuteFunctions | IExecuteSingleFunc
//@ts-ignore
return await this.helpers.requestOAuth2.call(this, 'boxOAuth2Api', options, oAuth2Options);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}
}
export async function boxApiRequestAllItems(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions, propertyName: string, method: string, endpoint: string, body: any = {}, query: IDataObject = {}): Promise<any> { // tslint:disable-line:no-any
export async function boxApiRequestAllItems(
this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions,
propertyName: string,
method: string,
endpoint: string,
// tslint:disable-next-line:no-any
body: any = {},
query: IDataObject = {},
// tslint:disable-next-line:no-any
): Promise<any> {
const returnData: IDataObject[] = [];
let responseData;
@@ -57,9 +67,7 @@ export async function boxApiRequestAllItems(this: IExecuteFunctions | ILoadOptio
responseData = await boxApiRequest.call(this, method, endpoint, body, query);
query.offset = responseData['offset'] + query.limit;
returnData.push.apply(returnData, responseData[propertyName]);
} while (
responseData[propertyName].length !== 0
);
} while (responseData[propertyName].length !== 0);
return returnData;
}