2023-01-27 03:22:44 -08:00
import type { INodeProperties } from 'n8n-workflow' ;
2021-07-10 04:44:23 -07:00
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 : {
2022-08-17 08:50:24 -07:00
resource : [ 'state' ] ,
2021-07-10 04:44:23 -07:00
} ,
} ,
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)' ,
2022-07-10 13:50:51 -07:00
action : 'Create or update a state' ,
2021-07-10 04:44:23 -07:00
} ,
{
name : 'Get' ,
value : 'get' ,
description : 'Get a state for a specific entity' ,
2022-07-10 13:50:51 -07:00
action : 'Get a state' ,
2021-07-10 04:44:23 -07:00
} ,
{
2022-09-07 07:51:14 -07:00
name : 'Get Many' ,
2021-07-10 04:44:23 -07:00
value : 'getAll' ,
2022-09-13 03:36:36 -07:00
description : 'Get many states' ,
2022-09-08 08:10:13 -07:00
action : 'Get many states' ,
2021-07-10 04:44:23 -07:00
} ,
] ,
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-08-17 08:50:24 -07:00
description :
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>' ,
2021-10-17 09:48:24 -07:00
typeOptions : {
loadOptionsMethod : 'getAllEntities' ,
} ,
2021-07-10 04:44:23 -07:00
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'get' ] ,
resource : [ 'state' ] ,
2021-07-10 04:44:23 -07:00
} ,
} ,
required : true ,
default : '' ,
} ,
/* -------------------------------------------------------------------------- */
/* state:getAll */
/* -------------------------------------------------------------------------- */
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
operation : [ 'getAll' ] ,
resource : [ 'state' ] ,
2021-07-10 04:44:23 -07:00
} ,
} ,
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 : {
2022-08-17 08:50:24 -07:00
operation : [ 'getAll' ] ,
resource : [ 'state' ] ,
returnAll : [ false ] ,
2021-07-10 04:44:23 -07:00
} ,
} ,
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 : {
2022-08-17 08:50:24 -07:00
operation : [ 'upsert' ] ,
resource : [ 'state' ] ,
2021-07-10 04:44:23 -07:00
} ,
} ,
required : true ,
default : '' ,
2022-08-17 08:50:24 -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/code-examples/expressions/">expression</a>.' ,
2021-07-10 04:44:23 -07:00
} ,
{
displayName : 'State' ,
name : 'state' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'state' ] ,
operation : [ 'upsert' ] ,
2021-07-10 04:44:23 -07:00
} ,
} ,
} ,
{
displayName : 'State Attributes' ,
name : 'stateAttributes' ,
type : 'fixedCollection' ,
typeOptions : {
multipleValues : true ,
} ,
placeholder : 'Add Attribute' ,
default : { } ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'state' ] ,
operation : [ 'upsert' ] ,
2021-07-10 04:44:23 -07:00
} ,
} ,
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
] ;