2023-01-27 03:22:44 -08:00
import type { INodeProperties } from 'n8n-workflow' ;
2021-04-17 00:25:51 -07:00
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
} ,
{
2022-09-07 07:51:14 -07:00
name : 'Get Many' ,
2021-04-17 00:25:51 -07:00
value : 'getAll' ,
2022-09-08 08:10:13 -07:00
action : 'Get many 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 : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
} ,
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 : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'create' ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'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/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' ,
2022-08-17 08:50:24 -07:00
loadOptionsDependsOn : [ 'siteId' ] ,
2021-04-17 00:25:51 -07:00
} ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'create' ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'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/expressions/">expression</a>.' ,
2021-04-17 00:25:51 -07:00
} ,
{
displayName : 'Live' ,
name : 'live' ,
type : 'boolean' ,
required : true ,
default : false ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'create' ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
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 : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'create' ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
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' ,
2022-08-17 08:50:24 -07:00
loadOptionsDependsOn : [ 'collectionId' ] ,
2021-04-17 00:25:51 -07:00
} ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'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/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 : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'delete' , 'get' ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'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/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' ,
2022-08-17 08:50:24 -07:00
loadOptionsDependsOn : [ 'siteId' ] ,
2021-04-17 00:25:51 -07:00
} ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'delete' , 'get' ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'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/expressions/">expression</a>.' ,
2021-04-17 00:25:51 -07:00
} ,
{
displayName : 'Item ID' ,
name : 'itemId' ,
type : 'string' ,
required : true ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'delete' , 'get' ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
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 : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'update' ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'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/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' ,
2022-08-17 08:50:24 -07:00
loadOptionsDependsOn : [ 'siteId' ] ,
2021-04-17 00:25:51 -07:00
} ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'update' ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'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/expressions/">expression</a>.' ,
2021-04-17 00:25:51 -07:00
} ,
{
displayName : 'Item ID' ,
name : 'itemId' ,
type : 'string' ,
required : true ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'update' ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
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 : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'update' ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
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 : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'update' ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
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' ,
2022-08-17 08:50:24 -07:00
loadOptionsDependsOn : [ 'collectionId' ] ,
2021-04-17 00:25:51 -07:00
} ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'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/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 : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'getAll' ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'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/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' ,
2022-08-17 08:50:24 -07:00
loadOptionsDependsOn : [ 'siteId' ] ,
2021-04-17 00:25:51 -07:00
} ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'getAll' ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'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/expressions/">expression</a>.' ,
2021-04-17 00:25:51 -07:00
} ,
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'getAll' ] ,
2021-04-17 00:25:51 -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-04-17 00:25:51 -07:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'item' ] ,
operation : [ 'getAll' ] ,
returnAll : [ false ] ,
2021-04-17 00:25:51 -07:00
} ,
} ,
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
] ;