2021-04-17 00:25:51 -07:00
import {
INodeProperties ,
} from 'n8n-workflow' ;
2021-12-03 00:44:16 -08:00
export const itemOperations : INodeProperties [ ] = [
2021-04-17 00:25:51 -07:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2021-04-17 00:25:51 -07:00
default : 'get' ,
options : [
{
name : 'Create' ,
value : 'create' ,
2022-07-10 13:50:51 -07:00
action : 'Create an item' ,
2021-04-17 00:25:51 -07:00
} ,
{
name : 'Delete' ,
value : 'delete' ,
2022-07-10 13:50:51 -07:00
action : 'Delete an item' ,
2021-04-17 00:25:51 -07:00
} ,
{
name : 'Get' ,
value : 'get' ,
2022-07-10 13:50:51 -07:00
action : 'Get an item' ,
2021-04-17 00:25:51 -07:00
} ,
{
name : 'Get All' ,
value : 'getAll' ,
2022-07-10 13:50:51 -07:00
action : 'Get all items' ,
2021-04-17 00:25:51 -07:00
} ,
{
name : 'Update' ,
value : 'update' ,
2022-07-10 13:50:51 -07:00
action : 'Update an item' ,
2021-04-17 00:25:51 -07:00
} ,
] ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
} ,
} ,
} ,
2021-12-03 00:44:16 -08:00
] ;
2021-04-17 00:25:51 -07:00
2021-12-03 00:44:16 -08:00
export const itemFields : INodeProperties [ ] = [
2021-04-17 00:25:51 -07:00
// ----------------------------------
// item: create
// ----------------------------------
{
2022-06-03 10:23:49 -07:00
displayName : 'Site Name or ID' ,
2021-04-17 00:25:51 -07:00
name : 'siteId' ,
type : 'options' ,
required : true ,
typeOptions : {
loadOptionsMethod : 'getSites' ,
} ,
default : '' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'ID of the site containing the collection whose items to add to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-04-17 00:25:51 -07:00
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Collection Name or ID' ,
2021-04-17 00:25:51 -07:00
name : 'collectionId' ,
type : 'options' ,
required : true ,
typeOptions : {
loadOptionsMethod : 'getCollections' ,
loadOptionsDependsOn : [
'siteId' ,
] ,
} ,
default : '' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'ID of the collection to add an item to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-04-17 00:25:51 -07:00
} ,
{
displayName : 'Live' ,
name : 'live' ,
type : 'boolean' ,
required : true ,
default : false ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'Whether the item should be published on the live site' ,
2021-04-17 00:25:51 -07:00
} ,
{
displayName : 'Fields' ,
name : 'fieldsUi' ,
placeholder : 'Add Field' ,
type : 'fixedCollection' ,
typeOptions : {
multipleValues : true ,
} ,
default : { } ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'create' ,
] ,
} ,
} ,
options : [
{
displayName : 'Field' ,
name : 'fieldValues' ,
values : [
{
2022-06-03 10:23:49 -07:00
displayName : 'Field Name or ID' ,
2021-04-17 00:25:51 -07:00
name : 'fieldId' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getFields' ,
loadOptionsDependsOn : [
'collectionId' ,
] ,
} ,
default : '' ,
2022-07-14 13:05:11 -07:00
description : 'Field to set for the item to create. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-04-17 00:25:51 -07:00
} ,
{
displayName : 'Field Value' ,
name : 'fieldValue' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Value to set for the item to create' ,
2021-04-17 00:25:51 -07:00
} ,
] ,
} ,
] ,
} ,
// ----------------------------------
// item: get
// ----------------------------------
{
2022-06-03 10:23:49 -07:00
displayName : 'Site Name or ID' ,
2021-04-17 00:25:51 -07:00
name : 'siteId' ,
type : 'options' ,
required : true ,
typeOptions : {
loadOptionsMethod : 'getSites' ,
} ,
default : '' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'delete' ,
'get' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'ID of the site containing the collection whose items to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-04-17 00:25:51 -07:00
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Collection Name or ID' ,
2021-04-17 00:25:51 -07:00
name : 'collectionId' ,
type : 'options' ,
required : true ,
typeOptions : {
loadOptionsMethod : 'getCollections' ,
loadOptionsDependsOn : [
'siteId' ,
] ,
} ,
default : '' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'delete' ,
'get' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'ID of the collection whose items to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-04-17 00:25:51 -07:00
} ,
{
displayName : 'Item ID' ,
name : 'itemId' ,
type : 'string' ,
required : true ,
default : '' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'delete' ,
'get' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'ID of the item to operate on' ,
2021-04-17 00:25:51 -07:00
} ,
// ----------------------------------
// item: update
// ----------------------------------
{
2022-06-03 10:23:49 -07:00
displayName : 'Site Name or ID' ,
2021-04-17 00:25:51 -07:00
name : 'siteId' ,
type : 'options' ,
required : true ,
typeOptions : {
loadOptionsMethod : 'getSites' ,
} ,
default : '' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'update' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'ID of the site containing the collection whose items to update. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-04-17 00:25:51 -07:00
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Collection Name or ID' ,
2021-04-17 00:25:51 -07:00
name : 'collectionId' ,
type : 'options' ,
required : true ,
typeOptions : {
loadOptionsMethod : 'getCollections' ,
loadOptionsDependsOn : [
'siteId' ,
] ,
} ,
default : '' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'update' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'ID of the collection whose items to update. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-04-17 00:25:51 -07:00
} ,
{
displayName : 'Item ID' ,
name : 'itemId' ,
type : 'string' ,
required : true ,
default : '' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'update' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'ID of the item to update' ,
2021-04-17 00:25:51 -07:00
} ,
{
displayName : 'Live' ,
name : 'live' ,
type : 'boolean' ,
required : true ,
default : false ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'update' ,
] ,
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'Whether the item should be published on the live site' ,
2021-04-17 00:25:51 -07:00
} ,
{
displayName : 'Fields' ,
name : 'fieldsUi' ,
placeholder : 'Add Field' ,
type : 'fixedCollection' ,
typeOptions : {
multipleValues : true ,
} ,
default : { } ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'update' ,
] ,
} ,
} ,
options : [
{
displayName : 'Field' ,
name : 'fieldValues' ,
values : [
{
2022-06-03 10:23:49 -07:00
displayName : 'Field Name or ID' ,
2021-04-17 00:25:51 -07:00
name : 'fieldId' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'getFields' ,
loadOptionsDependsOn : [
'collectionId' ,
] ,
} ,
default : '' ,
2022-07-14 13:05:11 -07:00
description : 'Field to set for the item to update. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-04-17 00:25:51 -07:00
} ,
{
displayName : 'Field Value' ,
name : 'fieldValue' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Value to set for the item to update' ,
2021-04-17 00:25:51 -07:00
} ,
] ,
} ,
] ,
} ,
// ----------------------------------
// item:getAll
// ----------------------------------
{
2022-06-03 10:23:49 -07:00
displayName : 'Site Name or ID' ,
2021-04-17 00:25:51 -07:00
name : 'siteId' ,
type : 'options' ,
required : true ,
typeOptions : {
loadOptionsMethod : 'getSites' ,
} ,
default : '' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'ID of the site containing the collection whose items to retrieve. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-04-17 00:25:51 -07:00
} ,
{
2022-06-03 10:23:49 -07:00
displayName : 'Collection Name or ID' ,
2021-04-17 00:25:51 -07:00
name : 'collectionId' ,
type : 'options' ,
required : true ,
typeOptions : {
loadOptionsMethod : 'getCollections' ,
loadOptionsDependsOn : [
'siteId' ,
] ,
} ,
default : '' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
2022-07-14 13:05:11 -07:00
description : 'ID of the collection whose items to retrieve. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>.' ,
2021-04-17 00:25:51 -07:00
} ,
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'getAll' ,
] ,
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2021-04-17 00:25:51 -07:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
resource : [
'item' ,
] ,
operation : [
'getAll' ,
] ,
returnAll : [
false ,
] ,
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 100 ,
} ,
default : 100 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2021-04-17 00:25:51 -07:00
} ,
2021-12-03 00:44:16 -08:00
] ;