2021-07-17 05:14:12 -07:00
import {
INodeProperties ,
} from 'n8n-workflow' ;
2021-12-03 00:44:16 -08:00
export const itemOperations : INodeProperties [ ] = [
2021-07-17 05:14:12 -07:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2021-07-17 05:14:12 -07:00
displayOptions : {
show : {
resource : [
'item' ,
] ,
} ,
} ,
options : [
{
name : 'Create or Update' ,
value : 'upsert' ,
2022-05-20 14:47:24 -07:00
description : 'Create a new record, or update the current one if it already exists (upsert)' ,
2022-07-10 13:50:51 -07:00
action : 'Create or update an item' ,
2021-07-17 05:14:12 -07:00
} ,
{
name : 'Delete' ,
value : 'delete' ,
description : 'Delete an item' ,
2022-07-10 13:50:51 -07:00
action : 'Delete an item' ,
2021-07-17 05:14:12 -07:00
} ,
{
name : 'Get' ,
value : 'get' ,
description : 'Get an item' ,
2022-07-10 13:50:51 -07:00
action : 'Get an item' ,
2021-07-17 05:14:12 -07:00
} ,
{
name : 'Get All' ,
value : 'getAll' ,
description : 'Get all items' ,
2022-07-10 13:50:51 -07:00
action : 'Get all items' ,
2021-07-17 05:14:12 -07:00
} ,
] ,
default : 'upsert' ,
} ,
2021-12-03 00:44:16 -08:00
] ;
2021-07-17 05:14:12 -07:00
2021-12-03 00:44:16 -08:00
export const itemFields : INodeProperties [ ] = [
2021-07-17 05:14:12 -07:00
// ----------------------------------
// all
// ----------------------------------
{
2022-06-03 10:23:49 -07:00
displayName : 'Table Name or ID' ,
2021-07-17 05:14:12 -07:00
name : 'tableName' ,
2022-06-03 10:23:49 -07:00
description : 'Table to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/nodes/expressions.html#expressions">expression</a>.' ,
2021-07-17 05:14:12 -07:00
type : 'options' ,
required : true ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
} ,
} ,
default : [ ] ,
typeOptions : {
loadOptionsMethod : 'getTables' ,
} ,
} ,
// ----------------------------------
// upsert
// ----------------------------------
{
displayName : 'Data to Send' ,
name : 'dataToSend' ,
type : 'options' ,
options : [
{
2022-06-03 10:23:49 -07:00
name : 'Auto-Map Input Data to Columns' ,
2021-07-17 05:14:12 -07:00
value : 'autoMapInputData' ,
description : 'Use when node input properties match destination column names' ,
} ,
{
name : 'Define Below for Each Column' ,
value : 'defineBelow' ,
description : 'Set the value for each destination column' ,
} ,
] ,
displayOptions : {
show : {
operation : [
'upsert' ,
] ,
} ,
} ,
default : 'defineBelow' ,
description : 'Whether to insert the input data this node receives in the new row' ,
} ,
{
displayName : 'Inputs to Ignore' ,
name : 'inputsToIgnore' ,
type : 'string' ,
displayOptions : {
show : {
operation : [
'upsert' ,
] ,
dataToSend : [
'autoMapInputData' ,
] ,
} ,
} ,
default : '' ,
description : 'List of input properties to avoid sending, separated by commas. Leave empty to send all properties.' ,
placeholder : 'Enter properties...' ,
} ,
{
displayName : 'Fields to Send' ,
name : 'fieldsUi' ,
placeholder : 'Add Field' ,
type : 'fixedCollection' ,
typeOptions : {
multipleValueButtonText : 'Add Field to Send' ,
multipleValues : true ,
} ,
displayOptions : {
show : {
operation : [
'upsert' ,
] ,
dataToSend : [
'defineBelow' ,
] ,
} ,
} ,
default : { } ,
options : [
{
displayName : 'Field' ,
name : 'fieldValues' ,
values : [
{
displayName : 'Field ID' ,
name : 'fieldId' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Field Value' ,
name : 'fieldValue' ,
type : 'string' ,
default : '' ,
} ,
] ,
} ,
] ,
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'upsert' ,
] ,
} ,
} ,
options : [
{
displayName : 'Expression Attribute Values' ,
name : 'eavUi' ,
2022-04-22 09:29:51 -07:00
description : 'Substitution tokens for attribute names in an expression. Only needed when the parameter "condition expression" is set.' ,
2021-07-17 05:14:12 -07:00
placeholder : 'Add Attribute Value' ,
type : 'fixedCollection' ,
2022-04-22 09:29:51 -07:00
default : { } ,
2021-07-17 05:14:12 -07:00
required : true ,
typeOptions : {
multipleValues : true ,
minValue : 1 ,
} ,
options : [
{
name : 'eavValues' ,
displayName : 'Expression Attribute Vaue' ,
values : [
{
displayName : 'Attribute' ,
name : 'attribute' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Type' ,
name : 'type' ,
type : 'options' ,
options : [
{
name : 'Number' ,
value : 'N' ,
} ,
{
name : 'String' ,
value : 'S' ,
} ,
] ,
default : 'S' ,
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
} ,
] ,
} ,
] ,
} ,
{
displayName : 'Condition Expression' ,
name : 'conditionExpression' ,
type : 'string' ,
default : '' ,
2022-04-22 09:29:51 -07:00
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>.' ,
2021-07-17 05:14:12 -07:00
} ,
{
displayName : 'Expression Attribute Names' ,
name : 'eanUi' ,
placeholder : 'Add Expression' ,
type : 'fixedCollection' ,
2022-04-22 09:29:51 -07:00
default : { } ,
2021-07-17 05:14:12 -07:00
typeOptions : {
multipleValues : true ,
} ,
options : [
{
name : 'eanValues' ,
displayName : 'Expression' ,
values : [
{
displayName : 'Key' ,
name : 'key' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
} ,
] ,
} ,
] ,
2022-04-22 09:29:51 -07:00
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>.' ,
2021-07-17 05:14:12 -07:00
} ,
] ,
} ,
// ----------------------------------
// delete
// ----------------------------------
{
displayName : 'Return' ,
name : 'returnValues' ,
type : 'options' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'delete' ,
] ,
} ,
} ,
options : [
{
name : 'Attribute Values' ,
value : 'ALL_OLD' ,
description : 'The content of the old item is returned' ,
} ,
{
name : 'Nothing' ,
value : 'NONE' ,
description : 'Nothing is returned' ,
} ,
] ,
default : 'NONE' ,
description : 'Use ReturnValues if you want to get the item attributes as they appeared before they were deleted' ,
} ,
{
displayName : 'Keys' ,
name : 'keysUi' ,
type : 'fixedCollection' ,
placeholder : 'Add Key' ,
default : { } ,
typeOptions : {
multipleValues : true ,
} ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'delete' ,
] ,
} ,
} ,
options : [
{
displayName : 'Key' ,
name : 'keyValues' ,
values : [
{
displayName : 'Key' ,
name : 'key' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Type' ,
name : 'type' ,
type : 'options' ,
options : [
{
name : 'Binary' ,
value : 'B' ,
} ,
{
name : 'Number' ,
value : 'N' ,
} ,
{
name : 'String' ,
value : 'S' ,
} ,
] ,
default : 'S' ,
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
} ,
] ,
} ,
] ,
2022-07-10 02:10:50 -07:00
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.' ,
2021-07-17 05:14:12 -07:00
} ,
{
2022-05-20 14:47:24 -07:00
displayName : 'Simplify' ,
2021-07-17 05:14:12 -07:00
name : 'simple' ,
type : 'boolean' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'delete' ,
] ,
returnValues : [
'ALL_OLD' ,
] ,
} ,
} ,
default : true ,
description : 'Whether to return a simplified version of the response instead of the raw data' ,
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'delete' ,
] ,
} ,
} ,
options : [
{
displayName : 'Condition Expression' ,
name : 'conditionExpression' ,
type : 'string' ,
default : '' ,
description : 'A condition that must be satisfied in order for a conditional delete to succeed' ,
} ,
{
displayName : 'Expression Attribute Names' ,
name : 'eanUi' ,
placeholder : 'Add Expression' ,
type : 'fixedCollection' ,
2022-04-22 09:29:51 -07:00
default : { } ,
2021-07-17 05:14:12 -07:00
typeOptions : {
multipleValues : true ,
} ,
options : [
{
name : 'eanValues' ,
displayName : 'Expression' ,
values : [
{
displayName : 'Key' ,
name : 'key' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
} ,
] ,
} ,
] ,
2022-04-22 09:29:51 -07:00
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>.' ,
2021-07-17 05:14:12 -07:00
} ,
{
displayName : 'Expression Attribute Values' ,
name : 'expressionAttributeUi' ,
2022-04-22 09:29:51 -07:00
description : 'Substitution tokens for attribute names in an expression. Only needed when the parameter "condition expression" is set.' ,
2021-07-17 05:14:12 -07:00
placeholder : 'Add Attribute Value' ,
type : 'fixedCollection' ,
2022-04-22 09:29:51 -07:00
default : { } ,
2021-07-17 05:14:12 -07:00
required : true ,
typeOptions : {
multipleValues : true ,
minValue : 1 ,
} ,
options : [
{
name : 'expressionAttributeValues' ,
displayName : 'Expression Attribute Vaue' ,
values : [
{
displayName : 'Attribute' ,
name : 'attribute' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Type' ,
name : 'type' ,
type : 'options' ,
options : [
{
name : 'Number' ,
value : 'N' ,
} ,
{
name : 'String' ,
value : 'S' ,
} ,
] ,
default : 'S' ,
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
} ,
] ,
} ,
] ,
} ,
] ,
} ,
// ----------------------------------
// get
// ----------------------------------
{
displayName : 'Select' ,
name : 'select' ,
type : 'options' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'get' ,
] ,
} ,
} ,
options : [
{
name : 'All Attributes' ,
value : 'ALL_ATTRIBUTES' ,
} ,
{
name : 'All Projected Attributes' ,
value : 'ALL_PROJECTED_ATTRIBUTES' ,
} ,
{
name : 'Specific Attributes' ,
value : 'SPECIFIC_ATTRIBUTES' ,
description : 'Select them in Attributes to Select under Additional Fields' ,
} ,
] ,
default : 'ALL_ATTRIBUTES' ,
} ,
{
2022-05-20 14:47:24 -07:00
displayName : 'Simplify' ,
2021-07-17 05:14:12 -07:00
name : 'simple' ,
type : 'boolean' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'get' ,
] ,
select : [
'ALL_PROJECTED_ATTRIBUTES' ,
'ALL_ATTRIBUTES' ,
] ,
} ,
} ,
default : true ,
description : 'Whether to return a simplified version of the response instead of the raw data' ,
} ,
{
displayName : 'Keys' ,
name : 'keysUi' ,
type : 'fixedCollection' ,
placeholder : 'Add Key' ,
default : { } ,
typeOptions : {
multipleValues : true ,
} ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'get' ,
] ,
} ,
} ,
options : [
{
displayName : 'Key' ,
name : 'keyValues' ,
values : [
{
displayName : 'Key' ,
name : 'key' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Type' ,
name : 'type' ,
type : 'options' ,
options : [
{
name : 'Binary' ,
value : 'B' ,
} ,
{
name : 'Number' ,
value : 'N' ,
} ,
{
name : 'String' ,
value : 'S' ,
} ,
] ,
default : 'S' ,
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
} ,
] ,
} ,
] ,
2022-07-10 02:10:50 -07:00
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.' ,
2021-07-17 05:14:12 -07:00
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'get' ,
] ,
} ,
} ,
options : [
{
displayName : 'Attributes to Select' ,
name : 'projectionExpression' ,
type : 'string' ,
2022-06-03 10:23:49 -07:00
// eslint-disable-next-line n8n-nodes-base/node-param-placeholder-miscased-id
2021-07-17 05:14:12 -07:00
placeholder : 'id, name' ,
default : '' ,
} ,
{
displayName : 'Expression Attribute Names' ,
name : 'eanUi' ,
placeholder : 'Add Expression' ,
type : 'fixedCollection' ,
2022-04-22 09:29:51 -07:00
default : { } ,
2021-07-17 05:14:12 -07:00
typeOptions : {
multipleValues : true ,
} ,
options : [
{
name : 'eanValues' ,
displayName : 'Expression' ,
values : [
{
displayName : 'Key' ,
name : 'key' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
} ,
] ,
} ,
] ,
2022-04-22 09:29:51 -07:00
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>.' ,
2021-07-17 05:14:12 -07:00
} ,
{
displayName : 'Read Type' ,
name : 'readType' ,
type : 'options' ,
options : [
{
2022-06-03 10:23:49 -07:00
name : 'Strongly Consistent Read' ,
2021-07-17 05:14:12 -07:00
value : 'stronglyConsistentRead' ,
} ,
{
2022-06-03 10:23:49 -07:00
name : 'Eventually Consistent Read' ,
2021-07-17 05:14:12 -07:00
value : 'eventuallyConsistentRead' ,
} ,
] ,
default : 'eventuallyConsistentRead' ,
2022-04-22 09:29:51 -07:00
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>.' ,
2021-07-17 05:14:12 -07:00
} ,
] ,
} ,
// ----------------------------------
// Get All
// ----------------------------------
2021-08-13 23:59:14 -07:00
{
displayName : 'Scan' ,
name : 'scan' ,
type : 'boolean' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
default : false ,
2022-04-22 09:29:51 -07:00
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>.' ,
2021-08-13 23:59:14 -07:00
} ,
{
displayName : 'Filter Expression' ,
name : 'filterExpression' ,
type : 'string' ,
displayOptions : {
show : {
scan : [
true ,
] ,
} ,
} ,
default : '' ,
2022-07-10 02:10:50 -07:00
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.' ,
2021-08-13 23:59:14 -07:00
} ,
2021-07-17 05:14:12 -07:00
{
displayName : 'Key Condition Expression' ,
name : 'keyConditionExpression' ,
2021-11-25 09:10:06 -08:00
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>' ,
2022-06-03 10:23:49 -07:00
// eslint-disable-next-line n8n-nodes-base/node-param-placeholder-miscased-id
2021-07-17 05:14:12 -07:00
placeholder : 'id = :id' ,
default : '' ,
type : 'string' ,
required : true ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'getAll' ,
] ,
2021-08-13 23:59:14 -07:00
scan : [
false ,
] ,
2021-07-17 05:14:12 -07:00
} ,
} ,
} ,
{
displayName : 'Expression Attribute Values' ,
name : 'eavUi' ,
description : 'Substitution tokens for attribute names in an expression' ,
placeholder : 'Add Attribute Value' ,
type : 'fixedCollection' ,
2022-04-22 09:29:51 -07:00
default : { } ,
2021-07-17 05:14:12 -07:00
required : true ,
typeOptions : {
multipleValues : true ,
minValue : 1 ,
} ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
options : [
{
name : 'eavValues' ,
displayName : 'Expression Attribute Vaue' ,
values : [
{
displayName : 'Attribute' ,
name : 'attribute' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Type' ,
name : 'type' ,
type : 'options' ,
options : [
{
name : 'Number' ,
value : 'N' ,
} ,
{
name : 'String' ,
value : 'S' ,
} ,
] ,
default : 'S' ,
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
} ,
] ,
} ,
] ,
} ,
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
default : false ,
description : 'Whether to return all results or only up to a given limit' ,
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
returnAll : [
false ,
] ,
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 100 ,
} ,
default : 50 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2021-07-17 05:14:12 -07:00
} ,
{
displayName : 'Select' ,
name : 'select' ,
type : 'options' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
options : [
{
name : 'All Attributes' ,
value : 'ALL_ATTRIBUTES' ,
} ,
{
name : 'All Projected Attributes' ,
value : 'ALL_PROJECTED_ATTRIBUTES' ,
} ,
{
name : 'Count' ,
value : 'COUNT' ,
} ,
{
name : 'Specific Attributes' ,
value : 'SPECIFIC_ATTRIBUTES' ,
description : 'Select them in Attributes to Select under Additional Fields' ,
} ,
] ,
default : 'ALL_ATTRIBUTES' ,
} ,
{
2022-05-20 14:47:24 -07:00
displayName : 'Simplify' ,
2021-07-17 05:14:12 -07:00
name : 'simple' ,
type : 'boolean' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'getAll' ,
] ,
select : [
'ALL_PROJECTED_ATTRIBUTES' ,
'ALL_ATTRIBUTES' ,
'SPECIFIC_ATTRIBUTES' ,
] ,
} ,
} ,
default : true ,
description : 'Whether to return a simplified version of the response instead of the raw data' ,
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
placeholder : 'Add Field' ,
default : { } ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
options : [
{
displayName : 'Index Name' ,
name : 'indexName' ,
2021-11-25 09:10:06 -08:00
description : 'Name of the index to query. It can be any secondary local or global index on the table.' ,
2021-07-17 05:14:12 -07:00
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Attributes to Select' ,
name : 'projectionExpression' ,
type : 'string' ,
default : '' ,
2022-07-10 02:10:50 -07:00
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.' ,
2021-07-17 05:14:12 -07:00
} ,
{
displayName : 'Filter Expression' ,
name : 'filterExpression' ,
type : 'string' ,
2021-08-13 23:59:14 -07:00
displayOptions : {
show : {
'/scan' : [
false ,
] ,
} ,
} ,
2021-07-17 05:14:12 -07:00
default : '' ,
2022-04-22 09:29:51 -07:00
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.' ,
2021-07-17 05:14:12 -07:00
} ,
{
displayName : 'Expression Attribute Names' ,
name : 'eanUi' ,
placeholder : 'Add Expression' ,
type : 'fixedCollection' ,
2022-04-22 09:29:51 -07:00
default : { } ,
2021-07-17 05:14:12 -07:00
typeOptions : {
multipleValues : true ,
} ,
options : [
{
name : 'eanValues' ,
displayName : 'Expression' ,
values : [
{
displayName : 'Key' ,
name : 'key' ,
type : 'string' ,
default : '' ,
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
} ,
] ,
} ,
] ,
2022-04-22 09:29:51 -07:00
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>.' ,
2021-07-17 05:14:12 -07:00
} ,
] ,
} ,
2021-12-03 00:44:16 -08:00
] ;