mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
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:
@@ -1,20 +1,10 @@
|
||||
import { paramCase, snakeCase } from 'change-case';
|
||||
|
||||
import {
|
||||
paramCase,
|
||||
snakeCase,
|
||||
} from 'change-case';
|
||||
import { createHash } from 'crypto';
|
||||
|
||||
import {
|
||||
createHash,
|
||||
} from 'crypto';
|
||||
import { Builder } from 'xml2js';
|
||||
|
||||
import {
|
||||
Builder,
|
||||
} from 'xml2js';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IBinaryKeyData,
|
||||
@@ -26,20 +16,11 @@ import {
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
bucketFields,
|
||||
bucketOperations,
|
||||
} from './BucketDescription';
|
||||
import { bucketFields, bucketOperations } from './BucketDescription';
|
||||
|
||||
import {
|
||||
folderFields,
|
||||
folderOperations,
|
||||
} from './FolderDescription';
|
||||
import { folderFields, folderOperations } from './FolderDescription';
|
||||
|
||||
import {
|
||||
fileFields,
|
||||
fileOperations,
|
||||
} from './FileDescription';
|
||||
import { fileFields, fileOperations } from './FileDescription';
|
||||
|
||||
import {
|
||||
awsApiRequestREST,
|
||||
@@ -121,7 +102,8 @@ export class AwsS3 implements INodeType {
|
||||
headers['x-amz-acl'] = paramCase(additionalFields.acl as string);
|
||||
}
|
||||
if (additionalFields.bucketObjectLockEnabled) {
|
||||
headers['x-amz-bucket-object-lock-enabled'] = additionalFields.bucketObjectLockEnabled as boolean;
|
||||
headers['x-amz-bucket-object-lock-enabled'] =
|
||||
additionalFields.bucketObjectLockEnabled as boolean;
|
||||
}
|
||||
if (additionalFields.grantFullControl) {
|
||||
headers['x-amz-grant-full-control'] = '';
|
||||
@@ -146,7 +128,7 @@ export class AwsS3 implements INodeType {
|
||||
|
||||
const body: IDataObject = {
|
||||
CreateBucketConfiguration: {
|
||||
'$': {
|
||||
$: {
|
||||
xmlns: 'http://s3.amazonaws.com/doc/2006-03-01/',
|
||||
},
|
||||
},
|
||||
@@ -159,7 +141,15 @@ export class AwsS3 implements INodeType {
|
||||
const builder = new Builder();
|
||||
data = builder.buildObject(body);
|
||||
}
|
||||
responseData = await awsApiRequestSOAP.call(this, `${name}.s3`, 'PUT', '', data, qs, headers);
|
||||
responseData = await awsApiRequestSOAP.call(
|
||||
this,
|
||||
`${name}.s3`,
|
||||
'PUT',
|
||||
'',
|
||||
data,
|
||||
qs,
|
||||
headers,
|
||||
);
|
||||
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
@@ -168,7 +158,15 @@ export class AwsS3 implements INodeType {
|
||||
if (operation === 'delete') {
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(this, `${name}.s3`, 'DELETE', '', '', {}, headers);
|
||||
responseData = await awsApiRequestSOAP.call(
|
||||
this,
|
||||
`${name}.s3`,
|
||||
'DELETE',
|
||||
'',
|
||||
'',
|
||||
{},
|
||||
headers,
|
||||
);
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
|
||||
@@ -176,10 +174,24 @@ export class AwsS3 implements INodeType {
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
||||
if (returnAll) {
|
||||
responseData = await awsApiRequestSOAPAllItems.call(this, 'ListAllMyBucketsResult.Buckets.Bucket', 's3', 'GET', '');
|
||||
responseData = await awsApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListAllMyBucketsResult.Buckets.Bucket',
|
||||
's3',
|
||||
'GET',
|
||||
'',
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', 0) as number;
|
||||
responseData = await awsApiRequestSOAPAllItems.call(this, 'ListAllMyBucketsResult.Buckets.Bucket', 's3', 'GET', '', '', qs);
|
||||
responseData = await awsApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListAllMyBucketsResult.Buckets.Bucket',
|
||||
's3',
|
||||
'GET',
|
||||
'',
|
||||
'',
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.slice(0, qs.limit);
|
||||
}
|
||||
returnData.push.apply(returnData, responseData);
|
||||
@@ -217,16 +229,38 @@ export class AwsS3 implements INodeType {
|
||||
|
||||
qs['list-type'] = 2;
|
||||
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' });
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._ as string;
|
||||
|
||||
if (returnAll) {
|
||||
responseData = await awsApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', `${bucketName}.s3`, 'GET', '', '', qs, {}, {}, region);
|
||||
responseData = await awsApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
`${bucketName}.s3`,
|
||||
'GET',
|
||||
'',
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
} else {
|
||||
qs['max-keys'] = this.getNodeParameter('limit', 0) as number;
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', qs, {}, {}, region);
|
||||
responseData = await awsApiRequestSOAP.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
'GET',
|
||||
'',
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
responseData = responseData.ListBucketResult.Contents;
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
@@ -251,13 +285,27 @@ export class AwsS3 implements INodeType {
|
||||
path = `/${additionalFields.parentFolderKey}${folderName}/`;
|
||||
}
|
||||
if (additionalFields.storageClass) {
|
||||
headers['x-amz-storage-class'] = (snakeCase(additionalFields.storageClass as string)).toUpperCase();
|
||||
headers['x-amz-storage-class'] = snakeCase(
|
||||
additionalFields.storageClass as string,
|
||||
).toUpperCase();
|
||||
}
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' });
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._;
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'PUT', path, '', qs, headers, {}, region);
|
||||
responseData = await awsApiRequestSOAP.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
'PUT',
|
||||
path,
|
||||
'',
|
||||
qs,
|
||||
headers,
|
||||
{},
|
||||
region,
|
||||
);
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObjects.html
|
||||
@@ -265,24 +313,45 @@ export class AwsS3 implements INodeType {
|
||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
||||
const folderKey = this.getNodeParameter('folderKey', i) as string;
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' });
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._;
|
||||
|
||||
responseData = await awsApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', `${bucketName}.s3`, 'GET', '/', '', { 'list-type': 2, prefix: folderKey }, {}, {}, region);
|
||||
responseData = await awsApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
`${bucketName}.s3`,
|
||||
'GET',
|
||||
'/',
|
||||
'',
|
||||
{ 'list-type': 2, prefix: folderKey },
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
|
||||
// folder empty then just delete it
|
||||
if (responseData.length === 0) {
|
||||
responseData = await awsApiRequestSOAP.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
'DELETE',
|
||||
`/${folderKey}`,
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'DELETE', `/${folderKey}`, '', qs, {}, {}, region);
|
||||
|
||||
responseData = { deleted: [ { 'Key': folderKey } ] };
|
||||
|
||||
responseData = { deleted: [{ Key: folderKey }] };
|
||||
} else {
|
||||
// delete everything inside the folder
|
||||
// delete everything inside the folder
|
||||
const body: IDataObject = {
|
||||
Delete: {
|
||||
'$': {
|
||||
$: {
|
||||
xmlns: 'http://s3.amazonaws.com/doc/2006-03-01/',
|
||||
},
|
||||
Object: [],
|
||||
@@ -303,7 +372,17 @@ export class AwsS3 implements INodeType {
|
||||
|
||||
headers['Content-Type'] = 'application/xml';
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'POST', '/', data, { delete: '' } , headers, {}, region);
|
||||
responseData = await awsApiRequestSOAP.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
'POST',
|
||||
'/',
|
||||
data,
|
||||
{ delete: '' },
|
||||
headers,
|
||||
{},
|
||||
region,
|
||||
);
|
||||
|
||||
responseData = { deleted: responseData.DeleteResult.Deleted };
|
||||
}
|
||||
@@ -325,18 +404,45 @@ export class AwsS3 implements INodeType {
|
||||
|
||||
qs['list-type'] = 2;
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' });
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._;
|
||||
|
||||
if (returnAll) {
|
||||
responseData = await awsApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', `${bucketName}.s3`, 'GET', '', '', qs, {}, {}, region);
|
||||
responseData = await awsApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
`${bucketName}.s3`,
|
||||
'GET',
|
||||
'',
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', 0) as number;
|
||||
responseData = await awsApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', `${bucketName}.s3`, 'GET', '', '', qs, {}, {}, region);
|
||||
responseData = await awsApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
`${bucketName}.s3`,
|
||||
'GET',
|
||||
'',
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
responseData = responseData.filter((e: IDataObject) => (e.Key as string).endsWith('/') && e.Size === '0' && e.Key !== options.folderKey);
|
||||
responseData = responseData.filter(
|
||||
(e: IDataObject) =>
|
||||
(e.Key as string).endsWith('/') && e.Size === '0' && e.Key !== options.folderKey,
|
||||
);
|
||||
if (qs.limit) {
|
||||
responseData = responseData.splice(0, qs.limit as number);
|
||||
}
|
||||
@@ -357,7 +463,9 @@ export class AwsS3 implements INodeType {
|
||||
headers['x-amz-request-payer'] = 'requester';
|
||||
}
|
||||
if (additionalFields.storageClass) {
|
||||
headers['x-amz-storage-class'] = (snakeCase(additionalFields.storageClass as string)).toUpperCase();
|
||||
headers['x-amz-storage-class'] = snakeCase(
|
||||
additionalFields.storageClass as string,
|
||||
).toUpperCase();
|
||||
}
|
||||
if (additionalFields.acl) {
|
||||
headers['x-amz-acl'] = paramCase(additionalFields.acl as string);
|
||||
@@ -375,37 +483,52 @@ export class AwsS3 implements INodeType {
|
||||
headers['x-amz-grant-write-acp'] = '';
|
||||
}
|
||||
if (additionalFields.lockLegalHold) {
|
||||
headers['x-amz-object-lock-legal-hold'] = (additionalFields.lockLegalHold as boolean) ? 'ON' : 'OFF';
|
||||
headers['x-amz-object-lock-legal-hold'] = (additionalFields.lockLegalHold as boolean)
|
||||
? 'ON'
|
||||
: 'OFF';
|
||||
}
|
||||
if (additionalFields.lockMode) {
|
||||
headers['x-amz-object-lock-mode'] = (additionalFields.lockMode as string).toUpperCase();
|
||||
headers['x-amz-object-lock-mode'] = (
|
||||
additionalFields.lockMode as string
|
||||
).toUpperCase();
|
||||
}
|
||||
if (additionalFields.lockRetainUntilDate) {
|
||||
headers['x-amz-object-lock-retain-until-date'] = additionalFields.lockRetainUntilDate as string;
|
||||
headers['x-amz-object-lock-retain-until-date'] =
|
||||
additionalFields.lockRetainUntilDate as string;
|
||||
}
|
||||
if (additionalFields.serverSideEncryption) {
|
||||
headers['x-amz-server-side-encryption'] = additionalFields.serverSideEncryption as string;
|
||||
headers['x-amz-server-side-encryption'] =
|
||||
additionalFields.serverSideEncryption as string;
|
||||
}
|
||||
if (additionalFields.encryptionAwsKmsKeyId) {
|
||||
headers['x-amz-server-side-encryption-aws-kms-key-id'] = additionalFields.encryptionAwsKmsKeyId as string;
|
||||
headers['x-amz-server-side-encryption-aws-kms-key-id'] =
|
||||
additionalFields.encryptionAwsKmsKeyId as string;
|
||||
}
|
||||
if (additionalFields.serverSideEncryptionContext) {
|
||||
headers['x-amz-server-side-encryption-context'] = additionalFields.serverSideEncryptionContext as string;
|
||||
headers['x-amz-server-side-encryption-context'] =
|
||||
additionalFields.serverSideEncryptionContext as string;
|
||||
}
|
||||
if (additionalFields.serversideEncryptionCustomerAlgorithm) {
|
||||
headers['x-amz-server-side-encryption-customer-algorithm'] = additionalFields.serversideEncryptionCustomerAlgorithm as string;
|
||||
headers['x-amz-server-side-encryption-customer-algorithm'] =
|
||||
additionalFields.serversideEncryptionCustomerAlgorithm as string;
|
||||
}
|
||||
if (additionalFields.serversideEncryptionCustomerKey) {
|
||||
headers['x-amz-server-side-encryption-customer-key'] = additionalFields.serversideEncryptionCustomerKey as string;
|
||||
headers['x-amz-server-side-encryption-customer-key'] =
|
||||
additionalFields.serversideEncryptionCustomerKey as string;
|
||||
}
|
||||
if (additionalFields.serversideEncryptionCustomerKeyMD5) {
|
||||
headers['x-amz-server-side-encryption-customer-key-MD5'] = additionalFields.serversideEncryptionCustomerKeyMD5 as string;
|
||||
headers['x-amz-server-side-encryption-customer-key-MD5'] =
|
||||
additionalFields.serversideEncryptionCustomerKeyMD5 as string;
|
||||
}
|
||||
if (additionalFields.taggingDirective) {
|
||||
headers['x-amz-tagging-directive'] = (additionalFields.taggingDirective as string).toUpperCase();
|
||||
headers['x-amz-tagging-directive'] = (
|
||||
additionalFields.taggingDirective as string
|
||||
).toUpperCase();
|
||||
}
|
||||
if (additionalFields.metadataDirective) {
|
||||
headers['x-amz-metadata-directive'] = (additionalFields.metadataDirective as string).toUpperCase();
|
||||
headers['x-amz-metadata-directive'] = (
|
||||
additionalFields.metadataDirective as string
|
||||
).toUpperCase();
|
||||
}
|
||||
|
||||
const destinationParts = destinationPath.split('/');
|
||||
@@ -414,17 +537,27 @@ export class AwsS3 implements INodeType {
|
||||
|
||||
const destination = `/${destinationParts.slice(2, destinationParts.length).join('/')}`;
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' });
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._;
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'PUT', destination, '', qs, headers, {}, region);
|
||||
responseData = await awsApiRequestSOAP.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
'PUT',
|
||||
destination,
|
||||
'',
|
||||
qs,
|
||||
headers,
|
||||
{},
|
||||
region,
|
||||
);
|
||||
returnData.push(responseData.CopyObjectResult);
|
||||
|
||||
}
|
||||
//https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html
|
||||
if (operation === 'download') {
|
||||
|
||||
const bucketName = this.getNodeParameter('bucketName', i) as string;
|
||||
|
||||
const fileKey = this.getNodeParameter('fileKey', i) as string;
|
||||
@@ -432,14 +565,29 @@ export class AwsS3 implements INodeType {
|
||||
const fileName = fileKey.split('/')[fileKey.split('/').length - 1];
|
||||
|
||||
if (fileKey.substring(fileKey.length - 1) === '/') {
|
||||
throw new NodeOperationError(this.getNode(), 'Downloding a whole directory is not yet supported, please provide a file key');
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Downloding a whole directory is not yet supported, please provide a file key',
|
||||
);
|
||||
}
|
||||
|
||||
let region = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' });
|
||||
let region = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
region = region.LocationConstraint._;
|
||||
|
||||
const response = await awsApiRequestREST.call(this, `${bucketName}.s3`, 'GET', `/${fileKey}`, '', qs, {}, { encoding: null, resolveWithFullResponse: true }, region);
|
||||
const response = await awsApiRequestREST.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
'GET',
|
||||
`/${fileKey}`,
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{ encoding: null, resolveWithFullResponse: true },
|
||||
region,
|
||||
);
|
||||
|
||||
let mimeType: string | undefined;
|
||||
if (response.headers['content-type']) {
|
||||
@@ -460,11 +608,18 @@ export class AwsS3 implements INodeType {
|
||||
|
||||
items[i] = newItem;
|
||||
|
||||
const dataPropertyNameDownload = this.getNodeParameter('binaryPropertyName', i) as string;
|
||||
const dataPropertyNameDownload = this.getNodeParameter(
|
||||
'binaryPropertyName',
|
||||
i,
|
||||
) as string;
|
||||
|
||||
const data = Buffer.from(response.body as string, 'utf8');
|
||||
|
||||
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://docs.aws.amazon.com/AmazonS3/latest/API/API_DeleteObject.html
|
||||
if (operation === 'delete') {
|
||||
@@ -478,11 +633,23 @@ export class AwsS3 implements INodeType {
|
||||
qs.versionId = options.versionId as string;
|
||||
}
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' });
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._;
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'DELETE', `/${fileKey}`, '', qs, {}, {}, region);
|
||||
responseData = await awsApiRequestSOAP.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
'DELETE',
|
||||
`/${fileKey}`,
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
@@ -504,19 +671,45 @@ export class AwsS3 implements INodeType {
|
||||
|
||||
qs['list-type'] = 2;
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' });
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._;
|
||||
|
||||
if (returnAll) {
|
||||
responseData = await awsApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', `${bucketName}.s3`, 'GET', '', '', qs, {}, {}, region);
|
||||
responseData = await awsApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
`${bucketName}.s3`,
|
||||
'GET',
|
||||
'',
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', 0) as number;
|
||||
responseData = await awsApiRequestSOAPAllItems.call(this, 'ListBucketResult.Contents', `${bucketName}.s3`, 'GET', '', '', qs, {}, {}, region);
|
||||
responseData = await awsApiRequestSOAPAllItems.call(
|
||||
this,
|
||||
'ListBucketResult.Contents',
|
||||
`${bucketName}.s3`,
|
||||
'GET',
|
||||
'',
|
||||
'',
|
||||
qs,
|
||||
{},
|
||||
{},
|
||||
region,
|
||||
);
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
responseData = responseData.filter((e: IDataObject) => !(e.Key as string).endsWith('/') && e.Size !== '0');
|
||||
responseData = responseData.filter(
|
||||
(e: IDataObject) => !(e.Key as string).endsWith('/') && e.Size !== '0',
|
||||
);
|
||||
if (qs.limit) {
|
||||
responseData = responseData.splice(0, qs.limit as number);
|
||||
}
|
||||
@@ -529,7 +722,8 @@ export class AwsS3 implements INodeType {
|
||||
const fileName = this.getNodeParameter('fileName', i) as string;
|
||||
const isBinaryData = this.getNodeParameter('binaryData', i) as boolean;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const tagsValues = (this.getNodeParameter('tagsUi', i) as IDataObject).tagsValues as IDataObject[];
|
||||
const tagsValues = (this.getNodeParameter('tagsUi', i) as IDataObject)
|
||||
.tagsValues as IDataObject[];
|
||||
let path = '/';
|
||||
let body;
|
||||
|
||||
@@ -540,7 +734,9 @@ export class AwsS3 implements INodeType {
|
||||
path = `/${additionalFields.parentFolderKey}/`;
|
||||
}
|
||||
if (additionalFields.storageClass) {
|
||||
headers['x-amz-storage-class'] = (snakeCase(additionalFields.storageClass as string)).toUpperCase();
|
||||
headers['x-amz-storage-class'] = snakeCase(
|
||||
additionalFields.storageClass as string,
|
||||
).toUpperCase();
|
||||
}
|
||||
if (additionalFields.acl) {
|
||||
headers['x-amz-acl'] = paramCase(additionalFields.acl as string);
|
||||
@@ -558,39 +754,54 @@ export class AwsS3 implements INodeType {
|
||||
headers['x-amz-grant-write-acp'] = '';
|
||||
}
|
||||
if (additionalFields.lockLegalHold) {
|
||||
headers['x-amz-object-lock-legal-hold'] = (additionalFields.lockLegalHold as boolean) ? 'ON' : 'OFF';
|
||||
headers['x-amz-object-lock-legal-hold'] = (additionalFields.lockLegalHold as boolean)
|
||||
? 'ON'
|
||||
: 'OFF';
|
||||
}
|
||||
if (additionalFields.lockMode) {
|
||||
headers['x-amz-object-lock-mode'] = (additionalFields.lockMode as string).toUpperCase();
|
||||
headers['x-amz-object-lock-mode'] = (
|
||||
additionalFields.lockMode as string
|
||||
).toUpperCase();
|
||||
}
|
||||
if (additionalFields.lockRetainUntilDate) {
|
||||
headers['x-amz-object-lock-retain-until-date'] = additionalFields.lockRetainUntilDate as string;
|
||||
headers['x-amz-object-lock-retain-until-date'] =
|
||||
additionalFields.lockRetainUntilDate as string;
|
||||
}
|
||||
if (additionalFields.serverSideEncryption) {
|
||||
headers['x-amz-server-side-encryption'] = additionalFields.serverSideEncryption as string;
|
||||
headers['x-amz-server-side-encryption'] =
|
||||
additionalFields.serverSideEncryption as string;
|
||||
}
|
||||
if (additionalFields.encryptionAwsKmsKeyId) {
|
||||
headers['x-amz-server-side-encryption-aws-kms-key-id'] = additionalFields.encryptionAwsKmsKeyId as string;
|
||||
headers['x-amz-server-side-encryption-aws-kms-key-id'] =
|
||||
additionalFields.encryptionAwsKmsKeyId as string;
|
||||
}
|
||||
if (additionalFields.serverSideEncryptionContext) {
|
||||
headers['x-amz-server-side-encryption-context'] = additionalFields.serverSideEncryptionContext as string;
|
||||
headers['x-amz-server-side-encryption-context'] =
|
||||
additionalFields.serverSideEncryptionContext as string;
|
||||
}
|
||||
if (additionalFields.serversideEncryptionCustomerAlgorithm) {
|
||||
headers['x-amz-server-side-encryption-customer-algorithm'] = additionalFields.serversideEncryptionCustomerAlgorithm as string;
|
||||
headers['x-amz-server-side-encryption-customer-algorithm'] =
|
||||
additionalFields.serversideEncryptionCustomerAlgorithm as string;
|
||||
}
|
||||
if (additionalFields.serversideEncryptionCustomerKey) {
|
||||
headers['x-amz-server-side-encryption-customer-key'] = additionalFields.serversideEncryptionCustomerKey as string;
|
||||
headers['x-amz-server-side-encryption-customer-key'] =
|
||||
additionalFields.serversideEncryptionCustomerKey as string;
|
||||
}
|
||||
if (additionalFields.serversideEncryptionCustomerKeyMD5) {
|
||||
headers['x-amz-server-side-encryption-customer-key-MD5'] = additionalFields.serversideEncryptionCustomerKeyMD5 as string;
|
||||
headers['x-amz-server-side-encryption-customer-key-MD5'] =
|
||||
additionalFields.serversideEncryptionCustomerKeyMD5 as string;
|
||||
}
|
||||
if (tagsValues) {
|
||||
const tags: string[] = [];
|
||||
tagsValues.forEach((o: IDataObject) => { tags.push(`${o.key}=${o.value}`); });
|
||||
tagsValues.forEach((o: IDataObject) => {
|
||||
tags.push(`${o.key}=${o.value}`);
|
||||
});
|
||||
headers['x-amz-tagging'] = tags.join('&');
|
||||
}
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', { location: '' });
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'GET', '', '', {
|
||||
location: '',
|
||||
});
|
||||
|
||||
const region = responseData.LocationConstraint._;
|
||||
|
||||
@@ -598,15 +809,24 @@ export class AwsS3 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,
|
||||
});
|
||||
}
|
||||
|
||||
if ((items[i].binary as IBinaryKeyData)[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,
|
||||
);
|
||||
|
||||
body = binaryDataBuffer;
|
||||
|
||||
@@ -614,10 +834,18 @@ export class AwsS3 implements INodeType {
|
||||
|
||||
headers['Content-MD5'] = createHash('md5').update(body).digest('base64');
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'PUT', `${path}${fileName || binaryData.fileName}`, body, qs, headers, {}, region);
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
'PUT',
|
||||
`${path}${fileName || binaryData.fileName}`,
|
||||
body,
|
||||
qs,
|
||||
headers,
|
||||
{},
|
||||
region,
|
||||
);
|
||||
} else {
|
||||
|
||||
const fileContent = this.getNodeParameter('fileContent', i) as string;
|
||||
|
||||
body = Buffer.from(fileContent, 'utf8');
|
||||
@@ -626,7 +854,17 @@ export class AwsS3 implements INodeType {
|
||||
|
||||
headers['Content-MD5'] = createHash('md5').update(fileContent).digest('base64');
|
||||
|
||||
responseData = await awsApiRequestSOAP.call(this, `${bucketName}.s3`, 'PUT', `${path}${fileName}`, body, qs, headers, {}, region);
|
||||
responseData = await awsApiRequestSOAP.call(
|
||||
this,
|
||||
`${bucketName}.s3`,
|
||||
'PUT',
|
||||
`${path}${fileName}`,
|
||||
body,
|
||||
qs,
|
||||
headers,
|
||||
{},
|
||||
region,
|
||||
);
|
||||
}
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
INodeProperties,
|
||||
} from 'n8n-workflow';
|
||||
import { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const bucketOperations: INodeProperties[] = [
|
||||
{
|
||||
@@ -10,9 +8,7 @@ export const bucketOperations: INodeProperties[] = [
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'bucket',
|
||||
],
|
||||
resource: ['bucket'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -46,10 +42,9 @@ export const bucketOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const bucketFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* bucket:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* bucket:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
@@ -58,12 +53,8 @@ export const bucketFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'bucket',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['bucket'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
description: 'A succinct description of the nature, symptoms, cause, or effect of the bucket',
|
||||
@@ -75,12 +66,8 @@ export const bucketFields: INodeProperties[] = [
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'bucket',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['bucket'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -122,7 +109,8 @@ export const bucketFields: INodeProperties[] = [
|
||||
name: 'grantFullControl',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to allow grantee the read, write, read ACP, and write ACP permissions on the bucket',
|
||||
description:
|
||||
'Whether to allow grantee the read, write, read ACP, and write ACP permissions on the bucket',
|
||||
},
|
||||
{
|
||||
displayName: 'Grant Read',
|
||||
@@ -143,7 +131,8 @@ export const bucketFields: INodeProperties[] = [
|
||||
name: 'grantWrite',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to allow grantee to create, overwrite, and delete any object in the bucket',
|
||||
description:
|
||||
'Whether to allow grantee to create, overwrite, and delete any object in the bucket',
|
||||
},
|
||||
{
|
||||
displayName: 'Grant Write ACP',
|
||||
@@ -157,14 +146,15 @@ export const bucketFields: INodeProperties[] = [
|
||||
name: 'region',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Region you want to create the bucket in, by default the buckets are created on the region defined on the credentials',
|
||||
description:
|
||||
'Region you want to create the bucket in, by default the buckets are created on the region defined on the credentials',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* bucket:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* bucket:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
@@ -173,32 +163,24 @@ export const bucketFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'bucket',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
resource: ['bucket'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
description: 'Name of the AWS S3 bucket to delete',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* bucket:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* bucket:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'bucket',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['bucket'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -210,15 +192,9 @@ export const bucketFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'bucket',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['bucket'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -228,9 +204,9 @@ export const bucketFields: INodeProperties[] = [
|
||||
default: 100,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* bucket:search */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* bucket:search */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Bucket Name',
|
||||
name: 'bucketName',
|
||||
@@ -239,12 +215,8 @@ export const bucketFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'bucket',
|
||||
],
|
||||
operation: [
|
||||
'search',
|
||||
],
|
||||
resource: ['bucket'],
|
||||
operation: ['search'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -254,12 +226,8 @@ export const bucketFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'search',
|
||||
],
|
||||
resource: [
|
||||
'bucket',
|
||||
],
|
||||
operation: ['search'],
|
||||
resource: ['bucket'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -271,15 +239,9 @@ export const bucketFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'search',
|
||||
],
|
||||
resource: [
|
||||
'bucket',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['search'],
|
||||
resource: ['bucket'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -296,12 +258,8 @@ export const bucketFields: INodeProperties[] = [
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'bucket',
|
||||
],
|
||||
operation: [
|
||||
'search',
|
||||
],
|
||||
resource: ['bucket'],
|
||||
operation: ['search'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -332,7 +290,8 @@ export const bucketFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
|
||||
description: 'The owner field is not present in listV2 by default, if you want to return owner field with each key in the result then set the fetch owner field to true',
|
||||
description:
|
||||
'The owner field is not present in listV2 by default, if you want to return owner field with each key in the result then set the fetch owner field to true',
|
||||
},
|
||||
{
|
||||
displayName: 'Prefix',
|
||||
@@ -346,14 +305,16 @@ export const bucketFields: INodeProperties[] = [
|
||||
name: 'requesterPays',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.',
|
||||
description:
|
||||
'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.',
|
||||
},
|
||||
{
|
||||
displayName: 'Start After',
|
||||
name: 'startAfter',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'StartAfter is where you want Amazon S3 to start listing from. Amazon S3 starts listing after this specified key.',
|
||||
description:
|
||||
'StartAfter is where you want Amazon S3 to start listing from. Amazon S3 starts listing after this specified key.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -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: [
|
||||
@@ -52,10 +48,9 @@ export const fileOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const fileFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:copy */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:copy */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Source Path',
|
||||
name: 'sourcePath',
|
||||
@@ -65,15 +60,12 @@ export const fileFields: INodeProperties[] = [
|
||||
placeholder: '/bucket/my-image.jpg',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'copy',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['copy'],
|
||||
},
|
||||
},
|
||||
description: 'The name of the source bucket and key name of the source object, separated by a slash (/)',
|
||||
description:
|
||||
'The name of the source bucket and key name of the source object, separated by a slash (/)',
|
||||
},
|
||||
{
|
||||
displayName: 'Destination Path',
|
||||
@@ -84,15 +76,12 @@ export const fileFields: INodeProperties[] = [
|
||||
placeholder: '/bucket/my-second-image.jpg',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'copy',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['copy'],
|
||||
},
|
||||
},
|
||||
description: 'The name of the destination bucket and key name of the destination object, separated by a slash (/)',
|
||||
description:
|
||||
'The name of the destination bucket and key name of the destination object, separated by a slash (/)',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
@@ -101,12 +90,8 @@ export const fileFields: INodeProperties[] = [
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'copy',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['copy'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -153,7 +138,8 @@ export const fileFields: INodeProperties[] = [
|
||||
name: 'grantFullControl',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to give the grantee READ, READ_ACP, and WRITE_ACP permissions on the object',
|
||||
description:
|
||||
'Whether to give the grantee READ, READ_ACP, and WRITE_ACP permissions on the object',
|
||||
},
|
||||
{
|
||||
displayName: 'Grant Read',
|
||||
@@ -205,7 +191,7 @@ export const fileFields: INodeProperties[] = [
|
||||
name: 'lockRetainUntilDate',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'The date and time when you want this object\'s Object Lock to expire',
|
||||
description: "The date and time when you want this object's Object Lock to expire",
|
||||
},
|
||||
{
|
||||
displayName: 'Metadata Directive',
|
||||
@@ -222,14 +208,16 @@ export const fileFields: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
description: 'Specifies whether the metadata is copied from the source object or replaced with metadata provided in the request',
|
||||
description:
|
||||
'Specifies whether the metadata is copied from the source object or replaced with metadata provided in the request',
|
||||
},
|
||||
{
|
||||
displayName: 'Requester Pays',
|
||||
name: 'requesterPays',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.',
|
||||
description:
|
||||
'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.',
|
||||
},
|
||||
{
|
||||
displayName: 'Server Side Encryption',
|
||||
@@ -246,7 +234,8 @@ export const fileFields: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
description: 'The server-side encryption algorithm used when storing this object in Amazon S3',
|
||||
description:
|
||||
'The server-side encryption algorithm used when storing this object in Amazon S3',
|
||||
},
|
||||
{
|
||||
displayName: 'Server Side Encryption Context',
|
||||
@@ -267,14 +256,16 @@ export const fileFields: INodeProperties[] = [
|
||||
name: 'serversideEncryptionCustomerAlgorithm',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Specifies the algorithm to use to when encrypting the object (for example, AES256)',
|
||||
description:
|
||||
'Specifies the algorithm to use to when encrypting the object (for example, AES256)',
|
||||
},
|
||||
{
|
||||
displayName: 'Server Side Encryption Customer Key',
|
||||
name: 'serversideEncryptionCustomerKey',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data',
|
||||
description:
|
||||
'Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data',
|
||||
},
|
||||
{
|
||||
displayName: 'Server Side Encryption Customer Key MD5',
|
||||
@@ -331,13 +322,14 @@ export const fileFields: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
description: 'Specifies whether the metadata is copied from the source object or replaced with metadata provided in the request',
|
||||
description:
|
||||
'Specifies whether the metadata is copied from the source object or replaced with metadata provided in the request',
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:upload */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:upload */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Bucket Name',
|
||||
name: 'bucketName',
|
||||
@@ -346,12 +338,8 @@ export const fileFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['upload'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -364,15 +352,9 @@ export const fileFields: INodeProperties[] = [
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
binaryData: [
|
||||
false,
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['upload'],
|
||||
binaryData: [false],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -383,15 +365,9 @@ export const fileFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
binaryData: [
|
||||
true,
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['upload'],
|
||||
binaryData: [true],
|
||||
},
|
||||
},
|
||||
description: 'If not set the binary data filename will be used',
|
||||
@@ -403,12 +379,8 @@ export const fileFields: INodeProperties[] = [
|
||||
default: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['upload'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
description: 'Whether the data to upload should be taken from binary field',
|
||||
@@ -420,15 +392,9 @@ export const fileFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
binaryData: [
|
||||
false,
|
||||
],
|
||||
operation: ['upload'],
|
||||
resource: ['file'],
|
||||
binaryData: [false],
|
||||
},
|
||||
},
|
||||
placeholder: '',
|
||||
@@ -442,17 +408,10 @@ export const fileFields: INodeProperties[] = [
|
||||
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',
|
||||
@@ -464,12 +423,8 @@ export const fileFields: INodeProperties[] = [
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['upload'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -516,7 +471,8 @@ export const fileFields: INodeProperties[] = [
|
||||
name: 'grantFullControl',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to give the grantee READ, READ_ACP, and WRITE_ACP permissions on the object',
|
||||
description:
|
||||
'Whether to give the grantee READ, READ_ACP, and WRITE_ACP permissions on the object',
|
||||
},
|
||||
{
|
||||
displayName: 'Grant Read',
|
||||
@@ -568,7 +524,7 @@ export const fileFields: INodeProperties[] = [
|
||||
name: 'lockRetainUntilDate',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'The date and time when you want this object\'s Object Lock to expire',
|
||||
description: "The date and time when you want this object's Object Lock to expire",
|
||||
},
|
||||
{
|
||||
displayName: 'Parent Folder Key',
|
||||
@@ -582,7 +538,8 @@ export const fileFields: INodeProperties[] = [
|
||||
name: 'requesterPays',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.',
|
||||
description:
|
||||
'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.',
|
||||
},
|
||||
{
|
||||
displayName: 'Server Side Encryption',
|
||||
@@ -599,7 +556,8 @@ export const fileFields: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
description: 'The server-side encryption algorithm used when storing this object in Amazon S3',
|
||||
description:
|
||||
'The server-side encryption algorithm used when storing this object in Amazon S3',
|
||||
},
|
||||
{
|
||||
displayName: 'Server Side Encryption Context',
|
||||
@@ -620,14 +578,16 @@ export const fileFields: INodeProperties[] = [
|
||||
name: 'serversideEncryptionCustomerAlgorithm',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Specifies the algorithm to use to when encrypting the object (for example, AES256)',
|
||||
description:
|
||||
'Specifies the algorithm to use to when encrypting the object (for example, AES256)',
|
||||
},
|
||||
{
|
||||
displayName: 'Server Side Encryption Customer Key',
|
||||
name: 'serversideEncryptionCustomerKey',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data',
|
||||
description:
|
||||
'Specifies the customer-provided encryption key for Amazon S3 to use in encrypting data',
|
||||
},
|
||||
{
|
||||
displayName: 'Server Side Encryption Customer Key MD5',
|
||||
@@ -682,12 +642,8 @@ export const fileFields: INodeProperties[] = [
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'upload',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['upload'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -712,9 +668,9 @@ export const fileFields: INodeProperties[] = [
|
||||
],
|
||||
description: 'Optional extra headers to add to the message (most headers are allowed)',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:download */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:download */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Bucket Name',
|
||||
name: 'bucketName',
|
||||
@@ -723,12 +679,8 @@ export const fileFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'download',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['download'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -740,12 +692,8 @@ export const fileFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'download',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['download'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -757,19 +705,15 @@ 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',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Bucket Name',
|
||||
name: 'bucketName',
|
||||
@@ -778,12 +722,8 @@ export const fileFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -795,12 +735,8 @@ export const fileFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -812,12 +748,8 @@ export const fileFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -829,9 +761,9 @@ export const fileFields: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* file:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Bucket Name',
|
||||
name: 'bucketName',
|
||||
@@ -840,12 +772,8 @@ export const fileFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -855,12 +783,8 @@ export const fileFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['file'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -872,15 +796,9 @@ export const fileFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['file'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -898,12 +816,8 @@ export const fileFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'file',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['file'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -913,7 +827,8 @@ export const fileFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
|
||||
description: 'The owner field is not present in listV2 by default, if you want to return owner field with each key in the result then set the fetch owner field to true',
|
||||
description:
|
||||
'The owner field is not present in listV2 by default, if you want to return owner field with each key in the result then set the fetch owner field to true',
|
||||
},
|
||||
{
|
||||
displayName: 'Folder Key',
|
||||
|
||||
@@ -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: [
|
||||
@@ -40,10 +36,9 @@ export const folderOperations: INodeProperties[] = [
|
||||
];
|
||||
|
||||
export const folderFields: INodeProperties[] = [
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Bucket Name',
|
||||
name: 'bucketName',
|
||||
@@ -52,12 +47,8 @@ export const folderFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -69,12 +60,8 @@ export const folderFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -85,12 +72,8 @@ export const folderFields: INodeProperties[] = [
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -107,7 +90,8 @@ export const folderFields: INodeProperties[] = [
|
||||
name: 'requesterPays',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.',
|
||||
description:
|
||||
'Whether the requester will pay for requests and data transfer. While Requester Pays is enabled, anonymous access to this bucket is disabled.',
|
||||
},
|
||||
{
|
||||
displayName: 'Storage Class',
|
||||
@@ -148,9 +132,9 @@ export const folderFields: INodeProperties[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:delete */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Bucket Name',
|
||||
name: 'bucketName',
|
||||
@@ -159,12 +143,8 @@ export const folderFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -176,18 +156,14 @@ export const folderFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'delete',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* folder:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Bucket Name',
|
||||
name: 'bucketName',
|
||||
@@ -196,12 +172,8 @@ export const folderFields: INodeProperties[] = [
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -211,12 +183,8 @@ export const folderFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['folder'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
@@ -228,15 +196,9 @@ export const folderFields: INodeProperties[] = [
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
returnAll: [
|
||||
false,
|
||||
],
|
||||
operation: ['getAll'],
|
||||
resource: ['folder'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
@@ -254,12 +216,8 @@ export const folderFields: INodeProperties[] = [
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: [
|
||||
'folder',
|
||||
],
|
||||
operation: [
|
||||
'getAll',
|
||||
],
|
||||
resource: ['folder'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
@@ -269,7 +227,8 @@ export const folderFields: INodeProperties[] = [
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
// eslint-disable-next-line n8n-nodes-base/node-param-description-boolean-without-whether
|
||||
description: 'The owner field is not present in listV2 by default, if you want to return owner field with each key in the result then set the fetch owner field to true',
|
||||
description:
|
||||
'The owner field is not present in listV2 by default, if you want to return owner field with each key in the result then set the fetch owner field to true',
|
||||
},
|
||||
{
|
||||
displayName: 'Folder Key',
|
||||
|
||||
@@ -1,23 +1,12 @@
|
||||
import {
|
||||
URL,
|
||||
} from 'url';
|
||||
import { URL } from 'url';
|
||||
|
||||
import {
|
||||
Request,
|
||||
sign,
|
||||
} from 'aws4';
|
||||
import { Request, sign } from 'aws4';
|
||||
|
||||
import {
|
||||
get,
|
||||
} from 'lodash';
|
||||
import { get } from 'lodash';
|
||||
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
parseString,
|
||||
} from 'xml2js';
|
||||
import { parseString } from 'xml2js';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
@@ -26,21 +15,41 @@ import {
|
||||
IWebhookFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject, JsonObject, NodeApiError, NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, JsonObject, NodeApiError, NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string | Buffer, query: IDataObject = {}, headers?: object, option: IDataObject = {}, region?: string): Promise<any> { // tslint:disable-line:no-any
|
||||
export async function awsApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions,
|
||||
service: string,
|
||||
method: string,
|
||||
path: string,
|
||||
body?: string | Buffer,
|
||||
query: IDataObject = {},
|
||||
headers?: object,
|
||||
option: IDataObject = {},
|
||||
region?: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials('aws');
|
||||
|
||||
const endpoint = new URL(((credentials.s3Endpoint as string || '').replace('{region}', credentials.region as string) || `https://${service}.${credentials.region}.amazonaws.com`) + path);
|
||||
const endpoint = new URL(
|
||||
(((credentials.s3Endpoint as string) || '').replace('{region}', credentials.region as string) ||
|
||||
`https://${service}.${credentials.region}.amazonaws.com`) + path,
|
||||
);
|
||||
|
||||
// Sign AWS API request with the user credentials
|
||||
const signOpts = {headers: headers || {}, host: endpoint.host, method, path: `${endpoint.pathname}?${queryToString(query).replace(/\+/g, '%2B')}`, body} as Request;
|
||||
const signOpts = {
|
||||
headers: headers || {},
|
||||
host: endpoint.host,
|
||||
method,
|
||||
path: `${endpoint.pathname}?${queryToString(query).replace(/\+/g, '%2B')}`,
|
||||
body,
|
||||
} as Request;
|
||||
const securityHeaders = {
|
||||
accessKeyId: `${credentials.accessKeyId}`.trim(),
|
||||
secretAccessKey: `${credentials.secretAccessKey}`.trim(),
|
||||
sessionToken: credentials.temporaryCredentials ? `${credentials.sessionToken}`.trim() : undefined,
|
||||
sessionToken: credentials.temporaryCredentials
|
||||
? `${credentials.sessionToken}`.trim()
|
||||
: undefined,
|
||||
};
|
||||
|
||||
sign(signOpts, securityHeaders);
|
||||
@@ -59,12 +68,33 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), (error as JsonObject));
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, service: string, method: string, path: string, body?: string, query: IDataObject = {}, headers?: object, options: IDataObject = {}, region?: string): Promise<any> { // tslint:disable-line:no-any
|
||||
const response = await awsApiRequest.call(this, service, method, path, body, query, headers, options, region);
|
||||
export async function awsApiRequestREST(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
|
||||
service: string,
|
||||
method: string,
|
||||
path: string,
|
||||
body?: string,
|
||||
query: IDataObject = {},
|
||||
headers?: object,
|
||||
options: IDataObject = {},
|
||||
region?: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const response = await awsApiRequest.call(
|
||||
this,
|
||||
service,
|
||||
method,
|
||||
path,
|
||||
body,
|
||||
query,
|
||||
headers,
|
||||
options,
|
||||
region,
|
||||
);
|
||||
try {
|
||||
return JSON.parse(response);
|
||||
} catch (error) {
|
||||
@@ -72,8 +102,29 @@ export async function awsApiRequestREST(this: IHookFunctions | IExecuteFunctions
|
||||
}
|
||||
}
|
||||
|
||||
export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: string | Buffer, query: IDataObject = {}, headers?: object, option: IDataObject = {}, region?: string): Promise<any> { // tslint:disable-line:no-any
|
||||
const response = await awsApiRequest.call(this, service, method, path, body, query, headers, option, region);
|
||||
export async function awsApiRequestSOAP(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions,
|
||||
service: string,
|
||||
method: string,
|
||||
path: string,
|
||||
body?: string | Buffer,
|
||||
query: IDataObject = {},
|
||||
headers?: object,
|
||||
option: IDataObject = {},
|
||||
region?: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const response = await awsApiRequest.call(
|
||||
this,
|
||||
service,
|
||||
method,
|
||||
path,
|
||||
body,
|
||||
query,
|
||||
headers,
|
||||
option,
|
||||
region,
|
||||
);
|
||||
try {
|
||||
return await new Promise((resolve, reject) => {
|
||||
parseString(response, { explicitArray: false }, (err, data) => {
|
||||
@@ -88,18 +139,42 @@ export async function awsApiRequestSOAP(this: IHookFunctions | IExecuteFunctions
|
||||
}
|
||||
}
|
||||
|
||||
export async function awsApiRequestSOAPAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, propertyName: string, service: string, method: string, path: string, body?: string, query: IDataObject = {}, headers: IDataObject = {}, option: IDataObject = {}, region?: string): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
export async function awsApiRequestSOAPAllItems(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions,
|
||||
propertyName: string,
|
||||
service: string,
|
||||
method: string,
|
||||
path: string,
|
||||
body?: string,
|
||||
query: IDataObject = {},
|
||||
headers: IDataObject = {},
|
||||
option: IDataObject = {},
|
||||
region?: string,
|
||||
// tslint:disable-next-line:no-any
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
|
||||
do {
|
||||
responseData = await awsApiRequestSOAP.call(this, service, method, path, body, query, headers, option, region);
|
||||
responseData = await awsApiRequestSOAP.call(
|
||||
this,
|
||||
service,
|
||||
method,
|
||||
path,
|
||||
body,
|
||||
query,
|
||||
headers,
|
||||
option,
|
||||
region,
|
||||
);
|
||||
|
||||
//https://forums.aws.amazon.com/thread.jspa?threadID=55746
|
||||
if (get(responseData, `${propertyName.split('.')[0]}.NextContinuationToken`)) {
|
||||
query['continuation-token'] = get(responseData, `${propertyName.split('.')[0]}.NextContinuationToken`);
|
||||
query['continuation-token'] = get(
|
||||
responseData,
|
||||
`${propertyName.split('.')[0]}.NextContinuationToken`,
|
||||
);
|
||||
}
|
||||
if (get(responseData, propertyName)) {
|
||||
if (Array.isArray(get(responseData, propertyName))) {
|
||||
@@ -120,5 +195,7 @@ export async function awsApiRequestSOAPAllItems(this: IHookFunctions | IExecuteF
|
||||
}
|
||||
|
||||
function queryToString(params: IDataObject) {
|
||||
return Object.keys(params).map(key => key + '=' + params[key]).join('&');
|
||||
return Object.keys(params)
|
||||
.map((key) => key + '=' + params[key])
|
||||
.join('&');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user