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:
Michael Kret
2022-08-01 23:47:55 +03:00
committed by GitHub
parent 2c17e6f3ca
commit 0ecbb4a19d
411 changed files with 12906 additions and 20148 deletions

View File

@@ -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 });

View File

@@ -1,10 +1,6 @@
import {
URL,
} from 'url';
import { URL } from 'url';
import {
sign,
} from 'aws4';
import { sign } from 'aws4';
import {
IExecuteFunctions,
@@ -13,17 +9,14 @@ import {
IWebhookFunctions,
} from 'n8n-core';
import {
ICredentialDataDecryptedObject,
IDataObject,
INodeExecutionData,
} from 'n8n-workflow';
import { ICredentialDataDecryptedObject, IDataObject, INodeExecutionData } from 'n8n-workflow';
import {
IRequestBody,
} from './types';
import { IRequestBody } from './types';
function getEndpointForService(service: string, credentials: ICredentialDataDecryptedObject): string {
function getEndpointForService(
service: string,
credentials: ICredentialDataDecryptedObject,
): string {
let endpoint;
if (service === 'lambda' && credentials.lambdaEndpoint) {
endpoint = credentials.lambdaEndpoint;
@@ -35,7 +28,15 @@ function getEndpointForService(service: string, credentials: ICredentialDataDecr
return (endpoint as string).replace('{region}', credentials.region as string);
}
export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: object | IRequestBody, headers?: object): Promise<any> { // tslint:disable-line:no-any
export async function awsApiRequest(
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions,
service: string,
method: string,
path: string,
body?: object | IRequestBody,
headers?: object,
// tslint:disable-next-line:no-any
): Promise<any> {
const credentials = await this.getCredentials('aws');
// Concatenate path and instantiate URL object so it parses correctly query strings
@@ -43,18 +44,23 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I
const securityHeaders = {
accessKeyId: `${credentials.accessKeyId}`.trim(),
secretAccessKey: `${credentials.secretAccessKey}`.trim(),
sessionToken: credentials.temporaryCredentials ? `${credentials.sessionToken}`.trim() : undefined,
sessionToken: credentials.temporaryCredentials
? `${credentials.sessionToken}`.trim()
: undefined,
};
const options = sign({
// @ts-ignore
uri: endpoint,
service,
region: credentials.region as string,
method,
path: '/',
headers: { ...headers },
body: JSON.stringify(body),
}, securityHeaders);
const options = sign(
{
// @ts-ignore
uri: endpoint,
service,
region: credentials.region as string,
method,
path: '/',
headers: { ...headers },
body: JSON.stringify(body),
},
securityHeaders,
);
try {
return JSON.parse(await this.helpers.request!(options));
@@ -66,7 +72,11 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I
if (error.statusCode === 403) {
if (errorMessage === 'The security token included in the request is invalid.') {
throw new Error('The AWS credentials are not valid!');
} else if (errorMessage.startsWith('The request signature we calculated does not match the signature you provided')) {
} else if (
errorMessage.startsWith(
'The request signature we calculated does not match the signature you provided',
)
) {
throw new Error('The AWS credentials are not valid!');
}
}
@@ -75,9 +85,15 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I
}
}
export async function awsApiRequestAllItems(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions, service: string, method: string, path: string, body?: IRequestBody, headers?: object): Promise<any> { // tslint:disable-line:no-any
export async function awsApiRequestAllItems(
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions | IWebhookFunctions,
service: string,
method: string,
path: string,
body?: IRequestBody,
headers?: object,
// tslint:disable-next-line:no-any
): Promise<any> {
const returnData: IDataObject[] = [];
let responseData;
@@ -88,9 +104,7 @@ export async function awsApiRequestAllItems(this: IHookFunctions | IExecuteFunct
body!.ExclusiveStartKey = responseData.LastEvaluatedKey;
}
returnData.push(...responseData.Items);
} while (
responseData.LastEvaluatedKey !== undefined
);
} while (responseData.LastEvaluatedKey !== undefined);
return returnData;
}

View File

@@ -1,6 +1,4 @@
import {
INodeProperties,
} from 'n8n-workflow';
import { INodeProperties } from 'n8n-workflow';
export const itemOperations: INodeProperties[] = [
{
@@ -10,9 +8,7 @@ export const itemOperations: INodeProperties[] = [
noDataExpression: true,
displayOptions: {
show: {
resource: [
'item',
],
resource: ['item'],
},
},
options: [
@@ -52,14 +48,13 @@ export const itemFields: INodeProperties[] = [
{
displayName: 'Table Name or ID',
name: 'tableName',
description: 'Table to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
description:
'Table to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.',
type: 'options',
required: true,
displayOptions: {
show: {
resource: [
'item',
],
resource: ['item'],
},
},
default: [],
@@ -89,9 +84,7 @@ export const itemFields: INodeProperties[] = [
],
displayOptions: {
show: {
operation: [
'upsert',
],
operation: ['upsert'],
},
},
default: 'defineBelow',
@@ -103,16 +96,13 @@ export const itemFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
operation: [
'upsert',
],
dataToSend: [
'autoMapInputData',
],
operation: ['upsert'],
dataToSend: ['autoMapInputData'],
},
},
default: '',
description: 'List of input properties to avoid sending, separated by commas. Leave empty to send all properties.',
description:
'List of input properties to avoid sending, separated by commas. Leave empty to send all properties.',
placeholder: 'Enter properties...',
},
{
@@ -126,12 +116,8 @@ export const itemFields: INodeProperties[] = [
},
displayOptions: {
show: {
operation: [
'upsert',
],
dataToSend: [
'defineBelow',
],
operation: ['upsert'],
dataToSend: ['defineBelow'],
},
},
default: {},
@@ -164,19 +150,16 @@ export const itemFields: INodeProperties[] = [
default: {},
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'upsert',
],
resource: ['item'],
operation: ['upsert'],
},
},
options: [
{
displayName: 'Expression Attribute Values',
name: 'eavUi',
description: 'Substitution tokens for attribute names in an expression. Only needed when the parameter "condition expression" is set.',
description:
'Substitution tokens for attribute names in an expression. Only needed when the parameter "condition expression" is set.',
placeholder: 'Add Attribute Value',
type: 'fixedCollection',
default: {},
@@ -227,7 +210,8 @@ export const itemFields: INodeProperties[] = [
name: 'conditionExpression',
type: 'string',
default: '',
description: 'A condition that must be satisfied in order for a conditional upsert to succeed. <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html">View details</a>.',
description:
'A condition that must be satisfied in order for a conditional upsert to succeed. <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html">View details</a>.',
},
{
displayName: 'Expression Attribute Names',
@@ -258,7 +242,8 @@ export const itemFields: INodeProperties[] = [
],
},
],
description: 'One or more substitution tokens for attribute names in an expression. <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html">View details</a>.',
description:
'One or more substitution tokens for attribute names in an expression. <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html">View details</a>.',
},
],
},
@@ -272,12 +257,8 @@ export const itemFields: INodeProperties[] = [
type: 'options',
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'delete',
],
resource: ['item'],
operation: ['delete'],
},
},
options: [
@@ -293,7 +274,8 @@ export const itemFields: INodeProperties[] = [
},
],
default: 'NONE',
description: 'Use ReturnValues if you want to get the item attributes as they appeared before they were deleted',
description:
'Use ReturnValues if you want to get the item attributes as they appeared before they were deleted',
},
{
displayName: 'Keys',
@@ -306,12 +288,8 @@ export const itemFields: INodeProperties[] = [
},
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'delete',
],
resource: ['item'],
operation: ['delete'],
},
},
options: [
@@ -354,7 +332,8 @@ export const itemFields: INodeProperties[] = [
],
},
],
description: 'Item\'s primary key. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key.',
description:
"Item's primary key. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key.",
},
{
displayName: 'Simplify',
@@ -362,15 +341,9 @@ export const itemFields: INodeProperties[] = [
type: 'boolean',
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'delete',
],
returnValues: [
'ALL_OLD',
],
resource: ['item'],
operation: ['delete'],
returnValues: ['ALL_OLD'],
},
},
default: true,
@@ -384,12 +357,8 @@ export const itemFields: INodeProperties[] = [
default: {},
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'delete',
],
resource: ['item'],
operation: ['delete'],
},
},
options: [
@@ -398,7 +367,8 @@ export const itemFields: INodeProperties[] = [
name: 'conditionExpression',
type: 'string',
default: '',
description: 'A condition that must be satisfied in order for a conditional delete to succeed',
description:
'A condition that must be satisfied in order for a conditional delete to succeed',
},
{
displayName: 'Expression Attribute Names',
@@ -429,12 +399,14 @@ export const itemFields: INodeProperties[] = [
],
},
],
description: 'One or more substitution tokens for attribute names in an expression. Check <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html">Info</a>.',
description:
'One or more substitution tokens for attribute names in an expression. Check <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html">Info</a>.',
},
{
displayName: 'Expression Attribute Values',
name: 'expressionAttributeUi',
description: 'Substitution tokens for attribute names in an expression. Only needed when the parameter "condition expression" is set.',
description:
'Substitution tokens for attribute names in an expression. Only needed when the parameter "condition expression" is set.',
placeholder: 'Add Attribute Value',
type: 'fixedCollection',
default: {},
@@ -492,12 +464,8 @@ export const itemFields: INodeProperties[] = [
type: 'options',
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'get',
],
resource: ['item'],
operation: ['get'],
},
},
options: [
@@ -523,16 +491,9 @@ export const itemFields: INodeProperties[] = [
type: 'boolean',
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'get',
],
select: [
'ALL_PROJECTED_ATTRIBUTES',
'ALL_ATTRIBUTES',
],
resource: ['item'],
operation: ['get'],
select: ['ALL_PROJECTED_ATTRIBUTES', 'ALL_ATTRIBUTES'],
},
},
default: true,
@@ -549,12 +510,8 @@ export const itemFields: INodeProperties[] = [
},
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'get',
],
resource: ['item'],
operation: ['get'],
},
},
options: [
@@ -597,7 +554,8 @@ export const itemFields: INodeProperties[] = [
],
},
],
description: 'Item\'s primary key. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key.',
description:
"Item's primary key. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key.",
},
{
displayName: 'Additional Fields',
@@ -607,12 +565,8 @@ export const itemFields: INodeProperties[] = [
default: {},
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'get',
],
resource: ['item'],
operation: ['get'],
},
},
options: [
@@ -653,7 +607,8 @@ export const itemFields: INodeProperties[] = [
],
},
],
description: 'One or more substitution tokens for attribute names in an expression. <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html">View details</a>.',
description:
'One or more substitution tokens for attribute names in an expression. <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html">View details</a>.',
},
{
displayName: 'Read Type',
@@ -670,7 +625,8 @@ export const itemFields: INodeProperties[] = [
},
],
default: 'eventuallyConsistentRead',
description: 'Type of read to perform on the table. <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadConsistency.html">View details</a>.',
description:
'Type of read to perform on the table. <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.ReadConsistency.html">View details</a>.',
},
],
},
@@ -684,16 +640,13 @@ export const itemFields: INodeProperties[] = [
type: 'boolean',
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'getAll',
],
resource: ['item'],
operation: ['getAll'],
},
},
default: false,
description: 'Whether to do an scan or query. Check <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-query-scan.html" >differences</a>.',
description:
'Whether to do an scan or query. Check <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-query-scan.html" >differences</a>.',
},
{
displayName: 'Filter Expression',
@@ -701,18 +654,18 @@ export const itemFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
scan: [
true,
],
scan: [true],
},
},
default: '',
description: 'A filter expression determines which items within the Scan results should be returned to you. All of the other results are discarded. Empty value will return all Scan results.',
description:
'A filter expression determines which items within the Scan results should be returned to you. All of the other results are discarded. Empty value will return all Scan results.',
},
{
displayName: 'Key Condition Expression',
name: 'keyConditionExpression',
description: 'Condition to determine the items to be retrieved. The condition must perform an equality test on a single partition key value, in this format: <code>partitionKeyName = :partitionkeyval</code>',
description:
'Condition to determine the items to be retrieved. The condition must perform an equality test on a single partition key value, in this format: <code>partitionKeyName = :partitionkeyval</code>',
// eslint-disable-next-line n8n-nodes-base/node-param-placeholder-miscased-id
placeholder: 'id = :id',
default: '',
@@ -720,15 +673,9 @@ export const itemFields: INodeProperties[] = [
required: true,
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'getAll',
],
scan: [
false,
],
resource: ['item'],
operation: ['getAll'],
scan: [false],
},
},
},
@@ -746,12 +693,8 @@ export const itemFields: INodeProperties[] = [
},
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'getAll',
],
resource: ['item'],
operation: ['getAll'],
},
},
options: [
@@ -797,12 +740,8 @@ export const itemFields: INodeProperties[] = [
type: 'boolean',
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'getAll',
],
resource: ['item'],
operation: ['getAll'],
},
},
default: false,
@@ -814,12 +753,8 @@ export const itemFields: INodeProperties[] = [
type: 'number',
displayOptions: {
show: {
operation: [
'getAll',
],
returnAll: [
false,
],
operation: ['getAll'],
returnAll: [false],
},
},
typeOptions: {
@@ -835,12 +770,8 @@ export const itemFields: INodeProperties[] = [
type: 'options',
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'getAll',
],
resource: ['item'],
operation: ['getAll'],
},
},
options: [
@@ -870,17 +801,9 @@ export const itemFields: INodeProperties[] = [
type: 'boolean',
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'getAll',
],
select: [
'ALL_PROJECTED_ATTRIBUTES',
'ALL_ATTRIBUTES',
'SPECIFIC_ATTRIBUTES',
],
resource: ['item'],
operation: ['getAll'],
select: ['ALL_PROJECTED_ATTRIBUTES', 'ALL_ATTRIBUTES', 'SPECIFIC_ATTRIBUTES'],
},
},
default: true,
@@ -894,19 +817,16 @@ export const itemFields: INodeProperties[] = [
default: {},
displayOptions: {
show: {
resource: [
'item',
],
operation: [
'getAll',
],
resource: ['item'],
operation: ['getAll'],
},
},
options: [
{
displayName: 'Index Name',
name: 'indexName',
description: 'Name of the index to query. It can be any secondary local or global index on the table.',
description:
'Name of the index to query. It can be any secondary local or global index on the table.',
type: 'string',
default: '',
},
@@ -915,7 +835,8 @@ export const itemFields: INodeProperties[] = [
name: 'projectionExpression',
type: 'string',
default: '',
description: 'Text that identifies one or more attributes to retrieve from the table. These attributes can include scalars, sets, or elements of a JSON document. The attributes in the expression must be separated by commas.',
description:
'Text that identifies one or more attributes to retrieve from the table. These attributes can include scalars, sets, or elements of a JSON document. The attributes in the expression must be separated by commas.',
},
{
displayName: 'Filter Expression',
@@ -923,13 +844,12 @@ export const itemFields: INodeProperties[] = [
type: 'string',
displayOptions: {
show: {
'/scan': [
false,
],
'/scan': [false],
},
},
default: '',
description: 'Text that contains conditions that DynamoDB applies after the Query operation, but before the data is returned. Items that do not satisfy the FilterExpression criteria are not returned.',
description:
'Text that contains conditions that DynamoDB applies after the Query operation, but before the data is returned. Items that do not satisfy the FilterExpression criteria are not returned.',
},
{
displayName: 'Expression Attribute Names',
@@ -960,7 +880,8 @@ export const itemFields: INodeProperties[] = [
],
},
],
description: 'One or more substitution tokens for attribute names in an expression. Check <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html">Info</a>.',
description:
'One or more substitution tokens for attribute names in an expression. Check <a href="https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html">Info</a>.',
},
],
},

View File

@@ -32,27 +32,36 @@ export interface IAttributeNameUi {
}
type AttributeValueType =
| 'B' // binary
| 'BOOL' // boolean
| 'BS' // binary set
| 'L' // list
| 'M' // map
| 'N' // number
| 'B' // binary
| 'BOOL' // boolean
| 'BS' // binary set
| 'L' // list
| 'M' // map
| 'N' // number
| 'NULL'
| 'NS' // number set
| 'S' // string
| 'SS'; // string set
| 'NS' // number set
| 'S' // string
| 'SS'; // string set
export type PartitionKey = {
details: {
name: string;
type: string;
value: string;
},
};
};
export enum EAttributeValueType {
S = 'S', SS = 'SS', M = 'M', L = 'L', NS = 'NS', N = 'N', BOOL = 'BOOL', B = 'B', BS = 'BS', NULL = 'NULL',
S = 'S',
SS = 'SS',
M = 'M',
L = 'L',
NS = 'NS',
N = 'N',
BOOL = 'BOOL',
B = 'B',
BS = 'BS',
NULL = 'NULL',
}
export interface IExpressionAttributeValue {
@@ -74,6 +83,6 @@ export type PutItemUi = {
export type AdjustedPutItem = {
[attribute: string]: {
[type: string]: string
}
[type: string]: string;
};
};

View File

@@ -1,7 +1,4 @@
import {
IDataObject,
INodeExecutionData,
} from 'n8n-workflow';
import { IDataObject, INodeExecutionData } from 'n8n-workflow';
import {
AdjustedPutItem,
@@ -14,9 +11,10 @@ import {
PutItemUi,
} from './types';
const addColon = (attribute: string) => attribute = attribute.charAt(0) === ':' ? attribute : `:${attribute}`;
const addColon = (attribute: string) =>
(attribute = attribute.charAt(0) === ':' ? attribute : `:${attribute}`);
const addPound = (key: string) => key = key.charAt(0) === '#' ? key : `#${key}`;
const addPound = (key: string) => (key = key.charAt(0) === '#' ? key : `#${key}`);
export function adjustExpressionAttributeValues(eavUi: IAttributeValueUi[]) {
const eav: IAttributeValue = {};
@@ -100,7 +98,7 @@ export function validateJSON(input: any): object {
export function copyInputItem(item: INodeExecutionData, properties: string[]): IDataObject {
// Prepare the data to insert and copy it to be returned
let newItem: IDataObject;
newItem = {};
newItem = {};
for (const property of properties) {
if (item.json[property] === undefined) {
newItem[property] = null;