mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 12:44:07 -08:00
feat(AWS DynamoDB Node): Improve error handling + add optional GetAll Scan FilterExpression (#3318)
* FilterExpression, ExpressionAttributeValues optional * Returns AWS JSON messages not in response body * 🔨 fixed filterExpression missing in request body * ⚡ linter fixes * Reintroduced 'fix' block at :311 results in duplication * ⚡ lock file fix * ⚡ fix Co-authored-by: Michael Kret <michael.k@radency.com>
This commit is contained in:
parent
82a254a8d9
commit
732c8fcf84
|
@ -307,11 +307,13 @@ export class AwsDynamoDB implements INodeType {
|
|||
|
||||
const body: IRequestBody = {
|
||||
TableName: this.getNodeParameter('tableName', i) as string,
|
||||
ExpressionAttributeValues: adjustExpressionAttributeValues(eavUi),
|
||||
};
|
||||
|
||||
if (scan === true) {
|
||||
body['FilterExpression'] = this.getNodeParameter('filterExpression', i) as string;
|
||||
const filterExpression = this.getNodeParameter('filterExpression', i) as string;
|
||||
if (filterExpression) {
|
||||
body['FilterExpression'] = filterExpression;
|
||||
}
|
||||
} else {
|
||||
body['KeyConditionExpression'] = this.getNodeParameter('keyConditionExpression', i) as string;
|
||||
}
|
||||
|
@ -332,6 +334,12 @@ export class AwsDynamoDB implements INodeType {
|
|||
body.ExpressionAttributeNames = expressionAttributeName;
|
||||
}
|
||||
|
||||
const expressionAttributeValues = adjustExpressionAttributeValues(eavUi);
|
||||
|
||||
if (Object.keys(expressionAttributeValues).length) {
|
||||
body.ExpressionAttributeValues = expressionAttributeValues;
|
||||
}
|
||||
|
||||
if (indexName) {
|
||||
body.IndexName = indexName;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ export async function awsApiRequest(this: IHookFunctions | IExecuteFunctions | I
|
|||
try {
|
||||
return JSON.parse(await this.helpers.request!(options));
|
||||
} catch (error) {
|
||||
const errorMessage = (error.response && error.response.body.message) || (error.response && error.response.body.Message) || error.message;
|
||||
const errorMessage = (error.response && error.response.body && error.response.body.message) || (error.response && error.response.body && error.response.body.Message) || error.message;
|
||||
if (error.statusCode === 403) {
|
||||
if (errorMessage === 'The security token included in the request is invalid.') {
|
||||
throw new Error('The AWS credentials are not valid!');
|
||||
|
|
|
@ -350,7 +350,7 @@ 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',
|
||||
|
@ -593,7 +593,7 @@ 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',
|
||||
|
@ -695,7 +695,6 @@ export const itemFields: INodeProperties[] = [
|
|||
displayName: 'Filter Expression',
|
||||
name: 'filterExpression',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
scan: [
|
||||
|
@ -704,7 +703,7 @@ export const itemFields: INodeProperties[] = [
|
|||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'A filter expression determines which items within the Scan results should be returned to you. All of the other results are discarded.',
|
||||
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',
|
||||
|
@ -912,7 +911,7 @@ 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',
|
||||
|
|
Loading…
Reference in a new issue