n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -11,13 +11,9 @@ import {
|
||||
|
||||
import { URLSearchParams } from 'url';
|
||||
|
||||
import {
|
||||
parseString,
|
||||
} from 'xml2js';
|
||||
import { parseString } from 'xml2js';
|
||||
|
||||
import {
|
||||
nextCloudApiRequest,
|
||||
} from './GenericFunctions';
|
||||
import { nextCloudApiRequest } from './GenericFunctions';
|
||||
|
||||
export class NextCloud implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -39,9 +35,7 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'accessToken',
|
||||
],
|
||||
authentication: ['accessToken'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -50,9 +44,7 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'oAuth2',
|
||||
],
|
||||
authentication: ['oAuth2'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -96,8 +88,6 @@ export class NextCloud implements INodeType {
|
||||
default: 'file',
|
||||
},
|
||||
|
||||
|
||||
|
||||
// ----------------------------------
|
||||
// operations
|
||||
// ----------------------------------
|
||||
@@ -108,9 +98,7 @@ export class NextCloud implements INodeType {
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -161,9 +149,7 @@ export class NextCloud implements INodeType {
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -214,9 +200,7 @@ export class NextCloud implements INodeType {
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
resource: ['user'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -269,13 +253,8 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'copy',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
'folder',
|
||||
],
|
||||
operation: ['copy'],
|
||||
resource: ['file', 'folder'],
|
||||
},
|
||||
},
|
||||
placeholder: '/invoices/original.txt',
|
||||
@@ -289,13 +268,8 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'copy',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
'folder',
|
||||
],
|
||||
operation: ['copy'],
|
||||
resource: ['file', 'folder'],
|
||||
},
|
||||
},
|
||||
placeholder: '/invoices/copy.txt',
|
||||
@@ -313,17 +287,13 @@ export class NextCloud 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. The path should start with "/".',
|
||||
description:
|
||||
'The path to delete. Can be a single file or a whole folder. The path should start with "/".',
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
@@ -337,13 +307,8 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'move',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
'folder',
|
||||
],
|
||||
operation: ['move'],
|
||||
resource: ['file', 'folder'],
|
||||
},
|
||||
},
|
||||
placeholder: '/invoices/old_name.txt',
|
||||
@@ -357,13 +322,8 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'move',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
'folder',
|
||||
],
|
||||
operation: ['move'],
|
||||
resource: ['file', 'folder'],
|
||||
},
|
||||
},
|
||||
placeholder: '/invoices/new_name.txt',
|
||||
@@ -381,16 +341,13 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'download',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['download'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
placeholder: '/invoices/2019/invoice_1.pdf',
|
||||
description: 'The file path of the file to download. Has to contain the full path. The path should start with "/".',
|
||||
description:
|
||||
'The file path of the file to download. Has to contain the full path. The path should start with "/".',
|
||||
},
|
||||
{
|
||||
displayName: 'Binary Property',
|
||||
@@ -400,12 +357,8 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
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',
|
||||
@@ -422,16 +375,13 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['upload'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
placeholder: '/invoices/2019/invoice_1.pdf',
|
||||
description: 'The absolute 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 absolute 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',
|
||||
@@ -441,12 +391,8 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['upload'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -457,17 +403,10 @@ export class NextCloud implements INodeType {
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
binaryDataUpload: [
|
||||
false,
|
||||
],
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
binaryDataUpload: [false],
|
||||
operation: ['upload'],
|
||||
resource: ['file'],
|
||||
},
|
||||
|
||||
},
|
||||
placeholder: '',
|
||||
description: 'The text content of the file to upload',
|
||||
@@ -480,20 +419,14 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
binaryDataUpload: [
|
||||
true,
|
||||
],
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
binaryDataUpload: [true],
|
||||
operation: ['upload'],
|
||||
resource: ['file'],
|
||||
},
|
||||
|
||||
},
|
||||
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',
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
@@ -507,17 +440,13 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'share',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
'folder',
|
||||
],
|
||||
operation: ['share'],
|
||||
resource: ['file', 'folder'],
|
||||
},
|
||||
},
|
||||
placeholder: '/invoices/2019/invoice_1.pdf',
|
||||
description: 'The file path of the file to share. Has to contain the full path. The path should start with "/".',
|
||||
description:
|
||||
'The file path of the file to share. Has to contain the full path. The path should start with "/".',
|
||||
},
|
||||
{
|
||||
displayName: 'Share Type',
|
||||
@@ -525,13 +454,8 @@ export class NextCloud implements INodeType {
|
||||
type: 'options',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'share',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
'folder',
|
||||
],
|
||||
operation: ['share'],
|
||||
resource: ['file', 'folder'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -565,16 +489,9 @@ export class NextCloud implements INodeType {
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'share',
|
||||
],
|
||||
shareType: [
|
||||
7,
|
||||
],
|
||||
resource: ['file', 'folder'],
|
||||
operation: ['share'],
|
||||
shareType: [7],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -587,16 +504,9 @@ export class NextCloud implements INodeType {
|
||||
placeholder: 'name@email.com',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'share',
|
||||
],
|
||||
shareType: [
|
||||
4,
|
||||
],
|
||||
resource: ['file', 'folder'],
|
||||
operation: ['share'],
|
||||
shareType: [4],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -608,16 +518,9 @@ export class NextCloud implements INodeType {
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'share',
|
||||
],
|
||||
shareType: [
|
||||
1,
|
||||
],
|
||||
resource: ['file', 'folder'],
|
||||
operation: ['share'],
|
||||
shareType: [1],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -629,16 +532,9 @@ export class NextCloud implements INodeType {
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'share',
|
||||
],
|
||||
shareType: [
|
||||
0,
|
||||
],
|
||||
resource: ['file', 'folder'],
|
||||
operation: ['share'],
|
||||
shareType: [0],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -652,13 +548,8 @@ export class NextCloud implements INodeType {
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'share',
|
||||
],
|
||||
resource: ['file', 'folder'],
|
||||
operation: ['share'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -668,16 +559,9 @@ export class NextCloud implements INodeType {
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/resource': [
|
||||
'file',
|
||||
'folder',
|
||||
],
|
||||
'/operation': [
|
||||
'share',
|
||||
],
|
||||
'/shareType': [
|
||||
3,
|
||||
],
|
||||
'/resource': ['file', 'folder'],
|
||||
'/operation': ['share'],
|
||||
'/shareType': [3],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -730,16 +614,13 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: ['create'],
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
placeholder: '/invoices/2019',
|
||||
description: 'The folder to create. The parent folder has to exist. The path should start with "/".',
|
||||
description:
|
||||
'The folder to create. The parent folder has to exist. The path should start with "/".',
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
@@ -752,12 +633,8 @@ export class NextCloud implements INodeType {
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'list',
|
||||
],
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: ['list'],
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
placeholder: '/invoices/2019/',
|
||||
@@ -779,12 +656,8 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
placeholder: 'john',
|
||||
@@ -798,12 +671,8 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
placeholder: 'john@email.com',
|
||||
@@ -817,12 +686,8 @@ export class NextCloud implements INodeType {
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -846,14 +711,8 @@ export class NextCloud implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
'get',
|
||||
'update',
|
||||
],
|
||||
resource: ['user'],
|
||||
operation: ['delete', 'get', 'update'],
|
||||
},
|
||||
},
|
||||
placeholder: 'john',
|
||||
@@ -868,12 +727,8 @@ export class NextCloud implements INodeType {
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['user'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -885,15 +740,9 @@ export class NextCloud implements INodeType {
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
resource: ['user'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -911,12 +760,8 @@ export class NextCloud implements INodeType {
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['user'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -950,12 +795,8 @@ export class NextCloud implements INodeType {
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'user',
|
||||
],
|
||||
operation: [
|
||||
'update',
|
||||
],
|
||||
resource: ['user'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -968,39 +809,38 @@ export class NextCloud implements INodeType {
|
||||
name: 'key',
|
||||
type: 'options',
|
||||
default: 'email',
|
||||
options:
|
||||
[
|
||||
{
|
||||
name: 'Address',
|
||||
value: 'address',
|
||||
description: 'The new address for the user',
|
||||
},
|
||||
{
|
||||
name: 'Display Name',
|
||||
value: 'displayname',
|
||||
description: 'The new display name for the user',
|
||||
},
|
||||
{
|
||||
name: 'Email',
|
||||
value: 'email',
|
||||
description: 'The new email for the user',
|
||||
},
|
||||
{
|
||||
name: 'Password',
|
||||
value: 'password',
|
||||
description: 'The new password for the user',
|
||||
},
|
||||
{
|
||||
name: 'Twitter',
|
||||
value: 'twitter',
|
||||
description: 'The new twitter handle for the user',
|
||||
},
|
||||
{
|
||||
name: 'Website',
|
||||
value: 'website',
|
||||
description: 'The new website for the user',
|
||||
},
|
||||
],
|
||||
options: [
|
||||
{
|
||||
name: 'Address',
|
||||
value: 'address',
|
||||
description: 'The new address for the user',
|
||||
},
|
||||
{
|
||||
name: 'Display Name',
|
||||
value: 'displayname',
|
||||
description: 'The new display name for the user',
|
||||
},
|
||||
{
|
||||
name: 'Email',
|
||||
value: 'email',
|
||||
description: 'The new email for the user',
|
||||
},
|
||||
{
|
||||
name: 'Password',
|
||||
value: 'password',
|
||||
description: 'The new password for the user',
|
||||
},
|
||||
{
|
||||
name: 'Twitter',
|
||||
value: 'twitter',
|
||||
description: 'The new twitter handle for the user',
|
||||
},
|
||||
{
|
||||
name: 'Website',
|
||||
value: 'website',
|
||||
description: 'The new website for the user',
|
||||
},
|
||||
],
|
||||
description: 'Key of the updated attribute',
|
||||
},
|
||||
{
|
||||
@@ -1017,7 +857,6 @@ export class NextCloud implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData().slice();
|
||||
const returnData: IDataObject[] = [];
|
||||
@@ -1052,7 +891,6 @@ export class NextCloud implements INodeType {
|
||||
|
||||
requestMethod = 'GET';
|
||||
endpoint = this.getNodeParameter('path', i) as string;
|
||||
|
||||
} else if (operation === 'upload') {
|
||||
// ----------------------------------
|
||||
// upload
|
||||
@@ -1066,14 +904,19 @@ export class NextCloud implements INodeType {
|
||||
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);
|
||||
@@ -1090,7 +933,6 @@ export class NextCloud implements INodeType {
|
||||
|
||||
requestMethod = 'MKCOL';
|
||||
endpoint = this.getNodeParameter('path', i) as string;
|
||||
|
||||
} else if (operation === 'list') {
|
||||
// ----------------------------------
|
||||
// list
|
||||
@@ -1098,7 +940,6 @@ export class NextCloud implements INodeType {
|
||||
|
||||
requestMethod = 'PROPFIND';
|
||||
endpoint = this.getNodeParameter('path', i) as string;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1112,7 +953,6 @@ export class NextCloud implements INodeType {
|
||||
endpoint = this.getNodeParameter('path', i) as string;
|
||||
const toPath = this.getNodeParameter('toPath', i) as string;
|
||||
headers.Destination = `${credentials.webDavUrl}/${encodeURI(toPath)}`;
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
// ----------------------------------
|
||||
// delete
|
||||
@@ -1120,7 +960,6 @@ export class NextCloud implements INodeType {
|
||||
|
||||
requestMethod = 'DELETE';
|
||||
endpoint = this.getNodeParameter('path', i) as string;
|
||||
|
||||
} else if (operation === 'move') {
|
||||
// ----------------------------------
|
||||
// move
|
||||
@@ -1130,7 +969,6 @@ export class NextCloud implements INodeType {
|
||||
endpoint = this.getNodeParameter('path', i) as string;
|
||||
const toPath = this.getNodeParameter('toPath', i) as string;
|
||||
headers.Destination = `${credentials.webDavUrl}/${encodeURI(toPath)}`;
|
||||
|
||||
} else if (operation === 'share') {
|
||||
// ----------------------------------
|
||||
// share
|
||||
@@ -1161,7 +999,6 @@ export class NextCloud implements INodeType {
|
||||
// @ts-ignore
|
||||
body = new URLSearchParams(bodyParameters).toString();
|
||||
}
|
||||
|
||||
} else if (resource === 'user') {
|
||||
if (operation === 'create') {
|
||||
// ----------------------------------
|
||||
@@ -1238,16 +1075,22 @@ export class NextCloud implements INodeType {
|
||||
const userid = this.getNodeParameter('userId', i) as string;
|
||||
endpoint = `ocs/v1.php/cloud/users/${userid}`;
|
||||
|
||||
body = Object.entries((this.getNodeParameter('updateFields', i) as IDataObject).field as IDataObject).map(entry => {
|
||||
const [key, value] = entry;
|
||||
return `${key}=${value}`;
|
||||
}).join('&');
|
||||
body = Object.entries(
|
||||
(this.getNodeParameter('updateFields', i) as IDataObject).field as IDataObject,
|
||||
)
|
||||
.map((entry) => {
|
||||
const [key, value] = entry;
|
||||
return `${key}=${value}`;
|
||||
})
|
||||
.join('&');
|
||||
|
||||
headers['OCS-APIRequest'] = true;
|
||||
headers['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
}
|
||||
} 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,
|
||||
});
|
||||
}
|
||||
|
||||
// Make sure that the webdav URL does never have a trailing slash because
|
||||
@@ -1264,7 +1107,15 @@ export class NextCloud implements INodeType {
|
||||
}
|
||||
|
||||
try {
|
||||
responseData = await nextCloudApiRequest.call(this, requestMethod, endpoint, body, headers, encoding, qs);
|
||||
responseData = await nextCloudApiRequest.call(
|
||||
this,
|
||||
requestMethod,
|
||||
endpoint,
|
||||
body,
|
||||
headers,
|
||||
encoding,
|
||||
qs,
|
||||
);
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
if (resource === 'file' && operation === 'download') {
|
||||
@@ -1279,7 +1130,6 @@ export class NextCloud implements INodeType {
|
||||
}
|
||||
|
||||
if (resource === 'file' && operation === 'download') {
|
||||
|
||||
const newItem: INodeExecutionData = {
|
||||
json: items[i].json,
|
||||
binary: {},
|
||||
@@ -1296,29 +1146,30 @@ export class NextCloud implements INodeType {
|
||||
|
||||
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string;
|
||||
|
||||
items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData(responseData, endpoint);
|
||||
|
||||
items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData(
|
||||
responseData,
|
||||
endpoint,
|
||||
);
|
||||
} else if (['file', 'folder'].includes(resource) && operation === 'share') {
|
||||
const jsonResponseData: IDataObject = await new Promise((resolve, reject) => {
|
||||
parseString(responseData, { explicitArray: false }, (err, data) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
const jsonResponseData: IDataObject = await new Promise((resolve, reject) => {
|
||||
parseString(responseData, { explicitArray: false }, (err, data) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
if (data.ocs.meta.status !== 'ok') {
|
||||
return reject(new NodeApiError(this.getNode(), data.ocs.meta.message || data.ocs.meta.status));
|
||||
}
|
||||
if (data.ocs.meta.status !== 'ok') {
|
||||
return reject(
|
||||
new NodeApiError(this.getNode(), data.ocs.meta.message || data.ocs.meta.status),
|
||||
);
|
||||
}
|
||||
|
||||
resolve(data.ocs.data as IDataObject);
|
||||
});
|
||||
resolve(data.ocs.data as IDataObject);
|
||||
});
|
||||
});
|
||||
|
||||
returnData.push(jsonResponseData as IDataObject);
|
||||
|
||||
returnData.push(jsonResponseData as IDataObject);
|
||||
} else if (resource === 'user') {
|
||||
|
||||
if (operation !== 'getAll') {
|
||||
|
||||
const jsonResponseData: IDataObject = await new Promise((resolve, reject) => {
|
||||
parseString(responseData, { explicitArray: false }, (err, data) => {
|
||||
if (err) {
|
||||
@@ -1326,7 +1177,9 @@ export class NextCloud implements INodeType {
|
||||
}
|
||||
|
||||
if (data.ocs.meta.status !== 'ok') {
|
||||
return reject(new NodeApiError(this.getNode(), data.ocs.meta.message || data.ocs.meta.status));
|
||||
return reject(
|
||||
new NodeApiError(this.getNode(), data.ocs.meta.message || data.ocs.meta.status),
|
||||
);
|
||||
}
|
||||
|
||||
if (operation === 'delete' || operation === 'update') {
|
||||
@@ -1339,7 +1192,6 @@ export class NextCloud implements INodeType {
|
||||
|
||||
returnData.push(jsonResponseData as IDataObject);
|
||||
} else {
|
||||
|
||||
const jsonResponseData: IDataObject[] = await new Promise((resolve, reject) => {
|
||||
parseString(responseData, { explicitArray: false }, (err, data) => {
|
||||
if (err) {
|
||||
@@ -1350,7 +1202,7 @@ export class NextCloud implements INodeType {
|
||||
return reject(new NodeApiError(this.getNode(), data.ocs.meta.message));
|
||||
}
|
||||
|
||||
if (typeof (data.ocs.data.users.element) === 'string') {
|
||||
if (typeof data.ocs.data.users.element === 'string') {
|
||||
resolve([data.ocs.data.users.element] as IDataObject[]);
|
||||
} else {
|
||||
resolve(data.ocs.data.users.element as IDataObject[]);
|
||||
@@ -1358,13 +1210,11 @@ export class NextCloud implements INodeType {
|
||||
});
|
||||
});
|
||||
|
||||
jsonResponseData.forEach(value => {
|
||||
jsonResponseData.forEach((value) => {
|
||||
returnData.push({ id: value } as IDataObject);
|
||||
});
|
||||
}
|
||||
|
||||
} else if (resource === 'folder' && operation === 'list') {
|
||||
|
||||
const jsonResponseData: IDataObject = await new Promise((resolve, reject) => {
|
||||
parseString(responseData, { explicitArray: false }, (err, data) => {
|
||||
if (err) {
|
||||
@@ -1380,10 +1230,12 @@ export class NextCloud implements INodeType {
|
||||
'd:getcontenttype': 'contentType',
|
||||
};
|
||||
|
||||
if (jsonResponseData['d:multistatus'] !== undefined &&
|
||||
if (
|
||||
jsonResponseData['d:multistatus'] !== undefined &&
|
||||
jsonResponseData['d:multistatus'] !== null &&
|
||||
(jsonResponseData['d:multistatus'] as IDataObject)['d:response'] !== undefined &&
|
||||
(jsonResponseData['d:multistatus'] as IDataObject)['d:response'] !== null) {
|
||||
(jsonResponseData['d:multistatus'] as IDataObject)['d:response'] !== null
|
||||
) {
|
||||
let skippedFirst = false;
|
||||
// @ts-ignore
|
||||
if (Array.isArray(jsonResponseData['d:multistatus']['d:response'])) {
|
||||
@@ -1423,7 +1275,6 @@ export class NextCloud implements INodeType {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
returnData.push(responseData as IDataObject);
|
||||
}
|
||||
@@ -1438,7 +1289,6 @@ export class NextCloud implements INodeType {
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (resource === 'file' && operation === 'download') {
|
||||
|
||||
Reference in New Issue
Block a user