mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-22 12:19:09 +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,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -14,17 +12,11 @@ import {
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
URL,
|
||||
} from 'url';
|
||||
import { URL } from 'url';
|
||||
|
||||
import {
|
||||
awsApiRequestSOAP,
|
||||
} from '../GenericFunctions';
|
||||
import { awsApiRequestSOAP } from '../GenericFunctions';
|
||||
|
||||
import {
|
||||
pascalCase,
|
||||
} from 'change-case';
|
||||
import { pascalCase } from 'change-case';
|
||||
|
||||
export class AwsSqs implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -71,15 +63,14 @@ export class AwsSqs implements INodeType {
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'sendMessage',
|
||||
],
|
||||
operation: ['sendMessage'],
|
||||
},
|
||||
},
|
||||
options: [],
|
||||
default: '',
|
||||
required: true,
|
||||
description: 'Queue to send a message to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
description:
|
||||
'Queue to send a message to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Queue Type',
|
||||
@@ -112,12 +103,8 @@ export class AwsSqs implements INodeType {
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'sendMessage',
|
||||
],
|
||||
sendInputData: [
|
||||
false,
|
||||
],
|
||||
operation: ['sendMessage'],
|
||||
sendInputData: [false],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
@@ -132,12 +119,11 @@ export class AwsSqs implements INodeType {
|
||||
name: 'messageGroupId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Tag that specifies that a message belongs to a specific message group. Applies only to FIFO (first-in-first-out) queues.',
|
||||
description:
|
||||
'Tag that specifies that a message belongs to a specific message group. Applies only to FIFO (first-in-first-out) queues.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
queueType: [
|
||||
'fifo',
|
||||
],
|
||||
queueType: ['fifo'],
|
||||
},
|
||||
},
|
||||
required: true,
|
||||
@@ -148,9 +134,7 @@ export class AwsSqs implements INodeType {
|
||||
type: 'collection',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'sendMessage',
|
||||
],
|
||||
operation: ['sendMessage'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
@@ -162,9 +146,7 @@ export class AwsSqs implements INodeType {
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/queueType': [
|
||||
'standard',
|
||||
],
|
||||
'/queueType': ['standard'],
|
||||
},
|
||||
},
|
||||
description: 'How long, in seconds, to delay a message for',
|
||||
@@ -201,7 +183,8 @@ export class AwsSqs implements INodeType {
|
||||
name: 'dataPropertyName',
|
||||
type: 'string',
|
||||
default: 'data',
|
||||
description: 'Name of the binary property which contains the data for the message attribute',
|
||||
description:
|
||||
'Name of the binary property which contains the data for the message attribute',
|
||||
},
|
||||
],
|
||||
},
|
||||
@@ -252,12 +235,11 @@ export class AwsSqs implements INodeType {
|
||||
name: 'messageDeduplicationId',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Token used for deduplication of sent messages. Applies only to FIFO (first-in-first-out) queues.',
|
||||
description:
|
||||
'Token used for deduplication of sent messages. Applies only to FIFO (first-in-first-out) queues.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
'/queueType': [
|
||||
'fifo',
|
||||
],
|
||||
'/queueType': ['fifo'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -270,10 +252,7 @@ export class AwsSqs implements INodeType {
|
||||
loadOptions: {
|
||||
// Get all the available queues to display them to user so that it can be selected easily
|
||||
async getQueues(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const params = [
|
||||
'Version=2012-11-05',
|
||||
`Action=ListQueues`,
|
||||
];
|
||||
const params = ['Version=2012-11-05', `Action=ListQueues`];
|
||||
|
||||
let data;
|
||||
try {
|
||||
@@ -307,7 +286,6 @@ export class AwsSqs implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: IDataObject[] = [];
|
||||
@@ -319,15 +297,14 @@ export class AwsSqs implements INodeType {
|
||||
const queueUrl = this.getNodeParameter('queue', i) as string;
|
||||
const queuePath = new URL(queueUrl).pathname;
|
||||
|
||||
const params = [
|
||||
'Version=2012-11-05',
|
||||
`Action=${pascalCase(operation)}`,
|
||||
];
|
||||
const params = ['Version=2012-11-05', `Action=${pascalCase(operation)}`];
|
||||
|
||||
const options = this.getNodeParameter('options', i, {}) as IDataObject;
|
||||
const sendInputData = this.getNodeParameter('sendInputData', i) as boolean;
|
||||
|
||||
const message = sendInputData ? JSON.stringify(items[i].json) : this.getNodeParameter('message', i) as string;
|
||||
const message = sendInputData
|
||||
? JSON.stringify(items[i].json)
|
||||
: (this.getNodeParameter('message', i) as string);
|
||||
params.push(`MessageBody=${message}`);
|
||||
|
||||
if (options.delaySeconds) {
|
||||
@@ -336,7 +313,11 @@ export class AwsSqs implements INodeType {
|
||||
|
||||
const queueType = this.getNodeParameter('queueType', i, {}) as string;
|
||||
if (queueType === 'fifo') {
|
||||
const messageDeduplicationId = this.getNodeParameter('options.messageDeduplicationId', i, '') as string;
|
||||
const messageDeduplicationId = this.getNodeParameter(
|
||||
'options.messageDeduplicationId',
|
||||
i,
|
||||
'',
|
||||
) as string;
|
||||
if (messageDeduplicationId) {
|
||||
params.push(`MessageDeduplicationId=${messageDeduplicationId}`);
|
||||
}
|
||||
@@ -349,7 +330,9 @@ export class AwsSqs implements INodeType {
|
||||
|
||||
let attributeCount = 0;
|
||||
// Add string values
|
||||
(this.getNodeParameter('options.messageAttributes.string', i, []) as INodeParameters[]).forEach((attribute) => {
|
||||
(
|
||||
this.getNodeParameter('options.messageAttributes.string', i, []) as INodeParameters[]
|
||||
).forEach((attribute) => {
|
||||
attributeCount++;
|
||||
params.push(`MessageAttribute.${attributeCount}.Name=${attribute.name}`);
|
||||
params.push(`MessageAttribute.${attributeCount}.Value.StringValue=${attribute.value}`);
|
||||
@@ -357,17 +340,27 @@ export class AwsSqs implements INodeType {
|
||||
});
|
||||
|
||||
// Add binary values
|
||||
(this.getNodeParameter('options.messageAttributes.binary', i, []) as INodeParameters[]).forEach((attribute) => {
|
||||
(
|
||||
this.getNodeParameter('options.messageAttributes.binary', i, []) as INodeParameters[]
|
||||
).forEach((attribute) => {
|
||||
attributeCount++;
|
||||
const dataPropertyName = attribute.dataPropertyName as string;
|
||||
const item = items[i];
|
||||
|
||||
if (item.binary === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data set. So message attribute cannot be added!', { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'No binary data set. So message attribute cannot be added!',
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
if (item.binary[dataPropertyName] === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), `The binary property "${dataPropertyName}" does not exist. So message attribute cannot be added!`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The binary property "${dataPropertyName}" does not exist. So message attribute cannot be added!`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
const binaryData = item.binary[dataPropertyName].data;
|
||||
@@ -378,7 +371,9 @@ export class AwsSqs implements INodeType {
|
||||
});
|
||||
|
||||
// Add number values
|
||||
(this.getNodeParameter('options.messageAttributes.number', i, []) as INodeParameters[]).forEach((attribute) => {
|
||||
(
|
||||
this.getNodeParameter('options.messageAttributes.number', i, []) as INodeParameters[]
|
||||
).forEach((attribute) => {
|
||||
attributeCount++;
|
||||
params.push(`MessageAttribute.${attributeCount}.Name=${attribute.name}`);
|
||||
params.push(`MessageAttribute.${attributeCount}.Value.StringValue=${attribute.value}`);
|
||||
@@ -387,7 +382,12 @@ export class AwsSqs implements INodeType {
|
||||
|
||||
let responseData;
|
||||
try {
|
||||
responseData = await awsApiRequestSOAP.call(this, 'sqs', 'GET', `${queuePath}?${params.join('&')}`);
|
||||
responseData = await awsApiRequestSOAP.call(
|
||||
this,
|
||||
'sqs',
|
||||
'GET',
|
||||
`${queuePath}?${params.join('&')}`,
|
||||
);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user