2021-07-10 04:44:23 -07:00
import {
INodeProperties
} from 'n8n-workflow' ;
2021-12-03 00:44:16 -08:00
export const stateOperations : INodeProperties [ ] = [
2021-07-10 04:44:23 -07:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2021-07-10 04:44:23 -07:00
displayOptions : {
show : {
resource : [
'state' ,
] ,
} ,
} ,
options : [
{
2022-06-03 10:23:49 -07:00
name : 'Create or Update' ,
2021-07-10 04:44:23 -07:00
value : 'upsert' ,
description : 'Create a new record, or update the current one if it already exists (upsert)' ,
} ,
{
name : 'Get' ,
value : 'get' ,
description : 'Get a state for a specific entity' ,
} ,
{
name : 'Get All' ,
value : 'getAll' ,
description : 'Get all states' ,
} ,
] ,
default : 'get' ,
} ,
2021-12-03 00:44:16 -08:00
] ;
2021-07-10 04:44:23 -07:00
2021-12-03 00:44:16 -08:00
export const stateFields : INodeProperties [ ] = [
2021-07-10 04:44:23 -07:00
/* -------------------------------------------------------------------------- */
/* state:get */
/* -------------------------------------------------------------------------- */
{
2022-06-03 10:23:49 -07:00
displayName : 'Entity Name or ID' ,
2021-07-10 04:44:23 -07:00
name : 'entityId' ,
2021-10-17 09:48:24 -07:00
type : 'options' ,
2022-06-20 07:54:01 -07:00
description : 'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/nodes/expressions.html#expressions">expression</a>' ,
2021-10-17 09:48:24 -07:00
typeOptions : {
loadOptionsMethod : 'getAllEntities' ,
} ,
2021-07-10 04:44:23 -07:00
displayOptions : {
show : {
operation : [
'get' ,
] ,
resource : [
'state' ,
] ,
} ,
} ,
required : true ,
default : '' ,
} ,
/* -------------------------------------------------------------------------- */
/* state:getAll */
/* -------------------------------------------------------------------------- */
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
resource : [
'state' ,
] ,
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2021-07-10 04:44:23 -07:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
operation : [
'getAll' ,
] ,
resource : [
'state' ,
] ,
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-10 04:44:23 -07:00
} ,
/* -------------------------------------------------------------------------- */
/* state:upsert */
/* -------------------------------------------------------------------------- */
{
2022-06-03 10:23:49 -07:00
displayName : 'Entity Name or ID' ,
2021-07-10 04:44:23 -07:00
name : 'entityId' ,
2021-10-17 09:48:24 -07:00
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getAllEntities' ,
} ,
2021-07-10 04:44:23 -07:00
displayOptions : {
show : {
operation : [
'upsert' ,
] ,
resource : [
'state' ,
] ,
} ,
} ,
required : true ,
default : '' ,
2022-06-03 10:23:49 -07:00
description : 'The entity ID for which a state will be created. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/nodes/expressions.html#expressions">expression</a>.' ,
2021-07-10 04:44:23 -07:00
} ,
{
displayName : 'State' ,
name : 'state' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
resource : [
'state' ,
] ,
operation : [
'upsert' ,
] ,
} ,
} ,
} ,
{
displayName : 'State Attributes' ,
name : 'stateAttributes' ,
type : 'fixedCollection' ,
typeOptions : {
multipleValues : true ,
} ,
placeholder : 'Add Attribute' ,
default : { } ,
displayOptions : {
show : {
resource : [
'state' ,
] ,
operation : [
'upsert' ,
] ,
} ,
} ,
options : [
{
displayName : 'Attributes' ,
name : 'attributes' ,
values : [
{
displayName : 'Name' ,
name : 'name' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Name of the attribute' ,
2021-07-10 04:44:23 -07:00
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Value of the attribute' ,
2021-07-10 04:44:23 -07:00
} ,
] ,
} ,
] ,
} ,
2021-12-03 00:44:16 -08:00
] ;