From c1a4f2ab5f84c33f16212176b257162f5bf4769e Mon Sep 17 00:00:00 2001 From: Preben Huybrechts Date: Sat, 7 Jan 2023 16:15:33 +0100 Subject: [PATCH] Format --- credentials/AzureStorageApi.credentials.ts | 12 ++++---- .../AzureBlobStorage/AzureBlobDescription.ts | 17 ++++++----- .../AzureBlobStorage/AzureBlobStorage.node.ts | 30 ++++++++++++------- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/credentials/AzureStorageApi.credentials.ts b/credentials/AzureStorageApi.credentials.ts index 172ca10..bafe82c 100644 --- a/credentials/AzureStorageApi.credentials.ts +++ b/credentials/AzureStorageApi.credentials.ts @@ -1,18 +1,16 @@ -import { - ICredentialType, - INodeProperties, -} from 'n8n-workflow'; +import { ICredentialType, INodeProperties } from 'n8n-workflow'; export class AzureStorageApi implements ICredentialType { name = 'azureStorageApi'; displayName = 'Azure Blob Storage API'; - documentationUrl = 'https://learn.microsoft.com/en-us/azure/storage/common/storage-account-keys-manage?toc=%2Fazure%2Fstorage%2Fblobs%2Ftoc.json&bc=%2Fazure%2Fstorage%2Fblobs%2Fbreadcrumb%2Ftoc.json&tabs=azure-portal#view-account-access-keys'; + documentationUrl = + 'https://learn.microsoft.com/en-us/azure/storage/common/storage-account-keys-manage?toc=%2Fazure%2Fstorage%2Fblobs%2Ftoc.json&bc=%2Fazure%2Fstorage%2Fblobs%2Fbreadcrumb%2Ftoc.json&tabs=azure-portal#view-account-access-keys'; properties: INodeProperties[] = [ { displayName: 'Connection string', name: 'connectionString', type: 'string', default: '', - } - ]; + }, + ]; } diff --git a/nodes/AzureBlobStorage/AzureBlobDescription.ts b/nodes/AzureBlobStorage/AzureBlobDescription.ts index 0e979ca..075d62e 100644 --- a/nodes/AzureBlobStorage/AzureBlobDescription.ts +++ b/nodes/AzureBlobStorage/AzureBlobDescription.ts @@ -26,7 +26,7 @@ export const containerOperations: INodeProperties[] = [ value: 'getMany', description: 'List all the containers in a storage account', action: 'Get many containers', - } + }, ], default: 'getMany', @@ -40,10 +40,10 @@ export const containerOperations: INodeProperties[] = [ displayOptions: { show: { resource: ['container'], - operation: ['create'] + operation: ['create'], }, }, - default: "" + default: '', }, ]; @@ -73,7 +73,7 @@ export const blobOperations: INodeProperties[] = [ value: 'getMany', description: 'List blobs inside a container', action: 'Get many blobs', - } + }, ], default: 'getMany', @@ -89,8 +89,8 @@ export const blobOperations: INodeProperties[] = [ resource: ['blob'], }, }, - default: "", - description: "The name of the storage container" + default: '', + description: 'The name of the storage container', }, { displayName: 'Blob Name', @@ -104,7 +104,8 @@ export const blobOperations: INodeProperties[] = [ operation: ['upload'], }, }, - description: 'Name of the blob that will be created. You can create folders like this: my-folder/my-file.txt.', + description: + 'Name of the blob that will be created. You can create folders like this: my-folder/my-file.txt.', }, { displayName: 'Binary Property', @@ -120,4 +121,4 @@ export const blobOperations: INodeProperties[] = [ }, description: 'Name of the binary property to which to write the data of the read file', }, -]; \ No newline at end of file +]; diff --git a/nodes/AzureBlobStorage/AzureBlobStorage.node.ts b/nodes/AzureBlobStorage/AzureBlobStorage.node.ts index db93691..c5dd963 100644 --- a/nodes/AzureBlobStorage/AzureBlobStorage.node.ts +++ b/nodes/AzureBlobStorage/AzureBlobStorage.node.ts @@ -1,4 +1,12 @@ -import { IBinaryKeyData, IDataObject, IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription, NodeOperationError } from 'n8n-workflow'; +import { + IBinaryKeyData, + IDataObject, + IExecuteFunctions, + INodeExecutionData, + INodeType, + INodeTypeDescription, + NodeOperationError, +} from 'n8n-workflow'; import { containerOperations, blobOperations } from './AzureBlobDescription'; export class AzureBlobStorage implements INodeType { @@ -41,7 +49,7 @@ export class AzureBlobStorage implements INodeType { }, ...containerOperations, - ...blobOperations + ...blobOperations, ], }; @@ -49,8 +57,8 @@ export class AzureBlobStorage implements INodeType { const resource = this.getNodeParameter('resource', 0) as string; const operation = this.getNodeParameter('operation', 0) as string; //Get credentials the user provided for this node - const credentials = await this.getCredentials('azureStorageApi') as IDataObject; - const { BlobServiceClient } = require("@azure/storage-blob"); + const credentials = (await this.getCredentials('azureStorageApi')) as IDataObject; + const { BlobServiceClient } = require('@azure/storage-blob'); const blobServiceClient = BlobServiceClient.fromConnectionString(credentials.connectionString); const items = this.getInputData(); @@ -66,8 +74,7 @@ export class AzureBlobStorage implements INodeType { returnData.push(createContainerResponse as IDataObject); } - } - else if (resource === 'blob') { + } else if (resource === 'blob') { const containerName = this.getNodeParameter('container', i) as string; const containerClient = blobServiceClient.getContainerClient(containerName); @@ -78,8 +85,7 @@ export class AzureBlobStorage implements INodeType { arr.push(blob); } returnData.push.apply(returnData, arr as IDataObject[]); - } - else if (operation === 'upload') { + } else if (operation === 'upload') { const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; if (items[i].binary === undefined) { @@ -101,12 +107,15 @@ export class AzureBlobStorage implements INodeType { } const blobName = this.getNodeParameter('blobName', i) as string; const blockBlobClient = containerClient.getBlockBlobClient(blobName); - const uploadBlobResponse = await blockBlobClient.upload(binaryDataBuffer, binaryDataBuffer.length); + const uploadBlobResponse = await blockBlobClient.upload( + binaryDataBuffer, + binaryDataBuffer.length, + ); returnData.push(uploadBlobResponse as IDataObject); } } } - + // No node input if (resource === 'container') { if (operation === 'getMany') { @@ -117,7 +126,6 @@ export class AzureBlobStorage implements INodeType { } returnData.push.apply(returnData, arr as IDataObject[]); } - } return [this.helpers.returnJsonArray(returnData)];