mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +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,7 +1,5 @@
|
||||
/* eslint-disable n8n-nodes-base/node-filename-against-convention */
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -12,15 +10,9 @@ import {
|
||||
NodeParameterValue,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
awsApiRequest,
|
||||
awsApiRequestAllItems,
|
||||
} from './GenericFunctions';
|
||||
import { awsApiRequest, awsApiRequestAllItems } from './GenericFunctions';
|
||||
|
||||
import {
|
||||
itemFields,
|
||||
itemOperations,
|
||||
} from './ItemDescription';
|
||||
import { itemFields, itemOperations } from './ItemDescription';
|
||||
|
||||
import {
|
||||
FieldsUiValues,
|
||||
@@ -102,22 +94,30 @@ export class AwsDynamoDB implements INodeType {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
|
||||
try {
|
||||
|
||||
if (resource === 'item') {
|
||||
|
||||
if (operation === 'upsert') {
|
||||
|
||||
// ----------------------------------
|
||||
// upsert
|
||||
// ----------------------------------
|
||||
|
||||
// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html
|
||||
|
||||
const eavUi = this.getNodeParameter('additionalFields.eavUi.eavValues', i, []) as IAttributeValueUi[];
|
||||
const conditionExpession = this.getNodeParameter('conditionExpression', i, '') as string;
|
||||
const eanUi = this.getNodeParameter('additionalFields.eanUi.eanValues', i, []) as IAttributeNameUi[];
|
||||
const eavUi = this.getNodeParameter(
|
||||
'additionalFields.eavUi.eavValues',
|
||||
i,
|
||||
[],
|
||||
) as IAttributeValueUi[];
|
||||
const conditionExpession = this.getNodeParameter(
|
||||
'conditionExpression',
|
||||
i,
|
||||
'',
|
||||
) as string;
|
||||
const eanUi = this.getNodeParameter(
|
||||
'additionalFields.eanUi.eanValues',
|
||||
i,
|
||||
[],
|
||||
) as IAttributeNameUi[];
|
||||
|
||||
const body: IRequestBody = {
|
||||
TableName: this.getNodeParameter('tableName', i) as string,
|
||||
@@ -139,14 +139,15 @@ export class AwsDynamoDB implements INodeType {
|
||||
body.ConditionExpression = conditionExpession;
|
||||
}
|
||||
|
||||
const dataToSend = this.getNodeParameter('dataToSend', 0) as 'defineBelow' | 'autoMapInputData';
|
||||
const dataToSend = this.getNodeParameter('dataToSend', 0) as
|
||||
| 'defineBelow'
|
||||
| 'autoMapInputData';
|
||||
const item: { [key: string]: string } = {};
|
||||
|
||||
if (dataToSend === 'autoMapInputData') {
|
||||
|
||||
const incomingKeys = Object.keys(items[i].json);
|
||||
const rawInputsToIgnore = this.getNodeParameter('inputsToIgnore', i) as string;
|
||||
const inputsToIgnore = rawInputsToIgnore.split(',').map(c => c.trim());
|
||||
const inputsToIgnore = rawInputsToIgnore.split(',').map((c) => c.trim());
|
||||
|
||||
for (const key of incomingKeys) {
|
||||
if (inputsToIgnore.includes(key)) continue;
|
||||
@@ -154,13 +155,10 @@ export class AwsDynamoDB implements INodeType {
|
||||
}
|
||||
|
||||
body.Item = adjustPutItem(item as PutItemUi);
|
||||
|
||||
} else {
|
||||
|
||||
const fields = this.getNodeParameter('fieldsUi.fieldValues', i, []) as FieldsUiValues;
|
||||
fields.forEach(({ fieldId, fieldValue }) => item[fieldId] = fieldValue);
|
||||
fields.forEach(({ fieldId, fieldValue }) => (item[fieldId] = fieldValue));
|
||||
body.Item = adjustPutItem(item as PutItemUi);
|
||||
|
||||
}
|
||||
|
||||
const headers = {
|
||||
@@ -170,9 +168,7 @@ export class AwsDynamoDB implements INodeType {
|
||||
|
||||
responseData = await awsApiRequest.call(this, 'dynamodb', 'POST', '/', body, headers);
|
||||
responseData = item;
|
||||
|
||||
} else if (operation === 'delete') {
|
||||
|
||||
// ----------------------------------
|
||||
// delete
|
||||
// ----------------------------------
|
||||
@@ -186,12 +182,22 @@ export class AwsDynamoDB implements INodeType {
|
||||
ReturnValues: this.getNodeParameter('returnValues', 0) as string,
|
||||
};
|
||||
|
||||
const eavUi = this.getNodeParameter('additionalFields.eavUi.eavValues', i, []) as IAttributeValueUi[];
|
||||
const eanUi = this.getNodeParameter('additionalFields.eanUi.eanValues', i, []) as IAttributeNameUi[];
|
||||
const eavUi = this.getNodeParameter(
|
||||
'additionalFields.eavUi.eavValues',
|
||||
i,
|
||||
[],
|
||||
) as IAttributeValueUi[];
|
||||
const eanUi = this.getNodeParameter(
|
||||
'additionalFields.eanUi.eanValues',
|
||||
i,
|
||||
[],
|
||||
) as IAttributeNameUi[];
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const simple = this.getNodeParameter('simple', 0, false) as boolean;
|
||||
|
||||
const items = this.getNodeParameter('keysUi.keyValues', i, []) as [{ key: string, type: string, value: string }];
|
||||
const items = this.getNodeParameter('keysUi.keyValues', i, []) as [
|
||||
{ key: string; type: string; value: string },
|
||||
];
|
||||
|
||||
for (const item of items) {
|
||||
let value = item.value as NodeParameterValue;
|
||||
@@ -229,9 +235,7 @@ export class AwsDynamoDB implements INodeType {
|
||||
} else if (simple === true) {
|
||||
responseData = decodeItem(responseData.Attributes);
|
||||
}
|
||||
|
||||
} else if (operation === 'get') {
|
||||
|
||||
// ----------------------------------
|
||||
// get
|
||||
// ----------------------------------
|
||||
@@ -242,7 +246,11 @@ export class AwsDynamoDB implements INodeType {
|
||||
const simple = this.getNodeParameter('simple', 0, false) as boolean;
|
||||
const select = this.getNodeParameter('select', 0) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const eanUi = this.getNodeParameter('additionalFields.eanUi.eanValues', i, []) as IAttributeNameUi[];
|
||||
const eanUi = this.getNodeParameter(
|
||||
'additionalFields.eanUi.eanValues',
|
||||
i,
|
||||
[],
|
||||
) as IAttributeNameUi[];
|
||||
|
||||
// tslint:disable-next-line: no-any
|
||||
const body: { [key: string]: any } = {
|
||||
@@ -289,9 +297,7 @@ export class AwsDynamoDB implements INodeType {
|
||||
if (simple && responseData) {
|
||||
responseData = decodeItem(responseData);
|
||||
}
|
||||
|
||||
} else if (operation === 'getAll') {
|
||||
|
||||
// ----------------------------------
|
||||
// getAll
|
||||
// ----------------------------------
|
||||
@@ -303,7 +309,11 @@ export class AwsDynamoDB implements INodeType {
|
||||
const select = this.getNodeParameter('select', 0) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
||||
const scan = this.getNodeParameter('scan', 0) as boolean;
|
||||
const eanUi = this.getNodeParameter('options.eanUi.eanValues', i, []) as IAttributeNameUi[];
|
||||
const eanUi = this.getNodeParameter(
|
||||
'options.eanUi.eanValues',
|
||||
i,
|
||||
[],
|
||||
) as IAttributeNameUi[];
|
||||
|
||||
const body: IRequestBody = {
|
||||
TableName: this.getNodeParameter('tableName', i) as string,
|
||||
@@ -315,14 +325,16 @@ export class AwsDynamoDB implements INodeType {
|
||||
body['FilterExpression'] = filterExpression;
|
||||
}
|
||||
} else {
|
||||
body['KeyConditionExpression'] = this.getNodeParameter('keyConditionExpression', i) as string;
|
||||
body['KeyConditionExpression'] = this.getNodeParameter(
|
||||
'keyConditionExpression',
|
||||
i,
|
||||
) as string;
|
||||
}
|
||||
|
||||
const {
|
||||
indexName,
|
||||
projectionExpression,
|
||||
filterExpression,
|
||||
} = this.getNodeParameter('options', i) as {
|
||||
const { indexName, projectionExpression, filterExpression } = this.getNodeParameter(
|
||||
'options',
|
||||
i,
|
||||
) as {
|
||||
indexName: string;
|
||||
projectionExpression: string;
|
||||
filterExpression: string;
|
||||
@@ -358,11 +370,18 @@ export class AwsDynamoDB implements INodeType {
|
||||
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Amz-Target': (scan) ? 'DynamoDB_20120810.Scan' : 'DynamoDB_20120810.Query',
|
||||
'X-Amz-Target': scan ? 'DynamoDB_20120810.Scan' : 'DynamoDB_20120810.Query',
|
||||
};
|
||||
|
||||
if (returnAll === true && select !== 'COUNT') {
|
||||
responseData = await awsApiRequestAllItems.call(this, 'dynamodb', 'POST', '/', body, headers);
|
||||
responseData = await awsApiRequestAllItems.call(
|
||||
this,
|
||||
'dynamodb',
|
||||
'POST',
|
||||
'/',
|
||||
body,
|
||||
headers,
|
||||
);
|
||||
} else {
|
||||
body.Limit = this.getNodeParameter('limit', 0, 1) as number;
|
||||
responseData = await awsApiRequest.call(this, 'dynamodb', 'POST', '/', body, headers);
|
||||
@@ -373,14 +392,12 @@ export class AwsDynamoDB implements INodeType {
|
||||
if (simple === true) {
|
||||
responseData = responseData.map(simplify);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Array.isArray(responseData)
|
||||
? returnData.push(...responseData)
|
||||
: returnData.push(responseData);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ error: error.message });
|
||||
|
||||
Reference in New Issue
Block a user