2023-01-27 03:22:44 -08:00
import type { INodeProperties } from 'n8n-workflow' ;
2021-03-03 16:09:31 -08:00
2021-12-03 00:44:16 -08:00
export const objectOperations : INodeProperties [ ] = [
2021-03-03 16:09:31 -08:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2021-03-03 16:09:31 -08:00
default : 'get' ,
options : [
{
name : 'Create' ,
value : 'create' ,
2022-07-10 13:50:51 -07:00
action : 'Create an object' ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'Delete' ,
value : 'delete' ,
2022-07-10 13:50:51 -07:00
action : 'Delete an object' ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'Get' ,
value : 'get' ,
2022-07-10 13:50:51 -07:00
action : 'Get an object' ,
2021-03-03 16:09:31 -08:00
} ,
{
2022-09-07 07:51:14 -07:00
name : 'Get Many' ,
2021-03-03 16:09:31 -08:00
value : 'getAll' ,
2022-09-08 08:10:13 -07:00
action : 'Get many objects' ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'Update' ,
value : 'update' ,
2022-07-10 13:50:51 -07:00
action : 'Update an object' ,
2021-03-03 16:09:31 -08:00
} ,
] ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'object' ] ,
2021-03-03 16:09:31 -08:00
} ,
} ,
} ,
2021-12-03 00:44:16 -08:00
] ;
2021-03-03 16:09:31 -08:00
2021-12-03 00:44:16 -08:00
export const objectFields : INodeProperties [ ] = [
2021-03-03 16:09:31 -08:00
// ----------------------------------
// object: create
// ----------------------------------
{
displayName : 'Type Name' ,
name : 'typeName' ,
type : 'string' ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'Name of data type of the object to create' ,
2021-03-03 16:09:31 -08:00
default : '' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'object' ] ,
operation : [ 'create' ] ,
2021-03-03 16:09:31 -08:00
} ,
} ,
} ,
{
displayName : 'Properties' ,
name : 'properties' ,
placeholder : 'Add Property' ,
type : 'fixedCollection' ,
typeOptions : {
multipleValues : true ,
} ,
default : { } ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'object' ] ,
operation : [ 'create' ] ,
2021-03-03 16:09:31 -08:00
} ,
} ,
options : [
{
displayName : 'Property' ,
name : 'property' ,
values : [
{
displayName : 'Key' ,
name : 'key' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Field to set for the object to create' ,
2021-03-03 16:09:31 -08:00
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Value to set for the object to create' ,
2021-03-03 16:09:31 -08:00
} ,
] ,
} ,
] ,
} ,
// ----------------------------------
// object: get
// ----------------------------------
{
displayName : 'Type Name' ,
name : 'typeName' ,
type : 'string' ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'Name of data type of the object to retrieve' ,
2021-03-03 16:09:31 -08:00
default : '' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'object' ] ,
operation : [ 'get' , 'delete' ] ,
2021-03-03 16:09:31 -08:00
} ,
} ,
} ,
{
displayName : 'Object ID' ,
name : 'objectId' ,
type : 'string' ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'ID of the object to retrieve' ,
2021-03-03 16:09:31 -08:00
default : '' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'object' ] ,
operation : [ 'get' , 'delete' ] ,
2021-03-03 16:09:31 -08:00
} ,
} ,
} ,
// ----------------------------------
// object: update
// ----------------------------------
{
displayName : 'Type Name' ,
name : 'typeName' ,
type : 'string' ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'Name of data type of the object to update' ,
2021-03-03 16:09:31 -08:00
default : '' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'object' ] ,
operation : [ 'update' ] ,
2021-03-03 16:09:31 -08:00
} ,
} ,
} ,
{
displayName : 'Object ID' ,
name : 'objectId' ,
type : 'string' ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'ID of the object to update' ,
2021-03-03 16:09:31 -08:00
default : '' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'object' ] ,
operation : [ 'update' ] ,
2021-03-03 16:09:31 -08:00
} ,
} ,
} ,
{
displayName : 'Properties' ,
name : 'properties' ,
placeholder : 'Add Property' ,
type : 'fixedCollection' ,
typeOptions : {
multipleValues : true ,
} ,
default : { } ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'object' ] ,
operation : [ 'update' ] ,
2021-03-03 16:09:31 -08:00
} ,
} ,
options : [
{
displayName : 'Property' ,
name : 'property' ,
values : [
{
displayName : 'Key' ,
name : 'key' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Field to set for the object to create' ,
2021-03-03 16:09:31 -08:00
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Value to set for the object to create' ,
2021-03-03 16:09:31 -08:00
} ,
] ,
} ,
] ,
} ,
// ----------------------------------
// object:getAll
// ----------------------------------
{
displayName : 'Type Name' ,
name : 'typeName' ,
type : 'string' ,
required : true ,
2022-05-06 14:01:25 -07:00
description : 'Name of data type of the object to create' ,
2021-03-03 16:09:31 -08:00
default : '' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'object' ] ,
operation : [ 'getAll' ] ,
2021-03-03 16:09:31 -08:00
} ,
} ,
} ,
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'object' ] ,
operation : [ 'getAll' ] ,
2021-03-03 16:09:31 -08: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-03-03 16:09:31 -08:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'object' ] ,
operation : [ 'getAll' ] ,
returnAll : [ false ] ,
2021-03-03 16:09:31 -08:00
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 100 ,
} ,
default : 100 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2021-03-03 16:09:31 -08:00
} ,
{
displayName : 'JSON Parameters' ,
name : 'jsonParameters' ,
type : 'boolean' ,
default : false ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
resource : [ 'object' ] ,
operation : [ 'getAll' ] ,
2021-03-03 16:09:31 -08:00
} ,
} ,
} ,
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
operation : [ 'getAll' ] ,
resource : [ 'object' ] ,
2021-03-03 16:09:31 -08:00
} ,
} ,
default : { } ,
placeholder : 'Add Field' ,
options : [
{
displayName : 'Filters' ,
name : 'filters' ,
placeholder : 'Add Filter' ,
type : 'fixedCollection' ,
typeOptions : {
multipleValues : true ,
} ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
'/jsonParameters' : [ false ] ,
2021-03-03 16:09:31 -08:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Filter' ,
name : 'filter' ,
values : [
{
displayName : 'Key' ,
name : 'key' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Field to set for the object to create' ,
2021-03-03 16:09:31 -08:00
} ,
{
displayName : 'Constrain' ,
name : 'constraint_type' ,
type : 'options' ,
2022-06-03 10:23:49 -07:00
// eslint-disable-next-line n8n-nodes-base/node-param-options-type-unsorted-items
2021-03-03 16:09:31 -08:00
options : [
{
name : 'Equals' ,
value : 'equals' ,
2022-05-06 14:01:25 -07:00
description : 'Use to test strict equality, for all field types' ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'Not Equal' ,
value : 'not equal' ,
description : 'Use to test strict equality, for all field types' ,
} ,
{
name : 'Is Empty' ,
value : 'is_empty' ,
2022-08-01 13:47:55 -07:00
description :
"Use to test whether a thing's given field is empty, for all field types" ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'Is Not Empty' ,
value : 'is_not_empty' ,
2022-08-01 13:47:55 -07:00
description :
"Use to test whether a thing's given field is not empty, for all field types" ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'Text Contains' ,
value : 'text contains' ,
2022-08-01 13:47:55 -07:00
description :
'Use to test if a text field contains a string, for text fields only' ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'Not Text Contains' ,
value : 'not text contains' ,
2022-08-01 13:47:55 -07:00
description :
'Use to test if a text field does not contain a string, for text fields only' ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'Greater Than' ,
value : 'greater than' ,
2022-08-01 13:47:55 -07:00
description :
"Use to compare a thing's field value relative to a string or number, for text, number, and date fields" ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'Less Than' ,
value : 'less than' ,
2022-08-01 13:47:55 -07:00
description :
"Use to compare a thing's field value relative to a string or number, for text, number, and date fields" ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'In' ,
value : 'in' ,
2022-08-01 13:47:55 -07:00
description :
"Use to test whether a thing's field is in a list, for all field types" ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'Not In' ,
value : 'not in' ,
2022-08-01 13:47:55 -07:00
description :
"Use to test whether a thing's field is not in a list, for all field types" ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'Contains' ,
value : 'contains' ,
2022-08-01 13:47:55 -07:00
description :
'Use to test whether a list field contains an entry, for list fields only' ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'Not Contains' ,
value : 'not contains' ,
2022-08-01 13:47:55 -07:00
description :
'Use to test whether a list field does not contains an entry, for list fields only' ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'Empty' ,
value : 'empty' ,
2022-05-06 14:01:25 -07:00
description : 'Use to test whether a list field is empty, for list fields only' ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'Not Empty' ,
value : 'not empty' ,
2022-08-01 13:47:55 -07:00
description :
'Use to test whether a list field is not empty, for list fields only' ,
2021-03-03 16:09:31 -08:00
} ,
{
name : 'Geographic Search' ,
value : 'geographic_search' ,
2022-08-01 13:47:55 -07:00
description :
'Use to test if the current thing is within a radius from a central address. To use this, the value sent with the constraint must have an address and a range. See <a href="https://manual.bubble.io/core-resources/api/data-api">link</a>.' ,
2021-03-03 16:09:31 -08:00
} ,
] ,
default : '' ,
} ,
{
displayName : 'Value' ,
name : 'value' ,
type : 'string' ,
displayOptions : {
hide : {
2022-08-01 13:47:55 -07:00
constraint_type : [ 'is_empty' , 'is_not_empty' , 'empty' , 'not empty' ] ,
2021-03-03 16:09:31 -08:00
} ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Value to set for the object to create' ,
2021-03-03 16:09:31 -08:00
} ,
] ,
} ,
] ,
} ,
{
displayName : 'Filters (JSON)' ,
name : 'filtersJson' ,
type : 'json' ,
default : '' ,
displayOptions : {
show : {
2022-08-01 13:47:55 -07:00
'/jsonParameters' : [ true ] ,
2021-03-03 16:09:31 -08:00
} ,
} ,
2022-12-29 03:20:43 -08:00
placeholder :
'[ { "key": "name", "constraint_type": "text contains", "value": "cafe" } , { "key": "address", "constraint_type": "geographic_search", "value": { "range":10, "origin_address":"New York" } } ]' ,
2022-08-01 13:47:55 -07:00
description :
'Refine the list that is returned by the Data API with search constraints, exactly as you define a search in Bubble. See <a href="https://manual.bubble.io/core-resources/api/data-api#search-constraints">link</a>.' ,
2021-03-03 16:09:31 -08:00
} ,
{
displayName : 'Sort' ,
name : 'sort' ,
placeholder : 'Add Sort' ,
type : 'fixedCollection' ,
typeOptions : {
multipleValues : false ,
} ,
default : { } ,
options : [
{
displayName : 'Sort' ,
name : 'sortValue' ,
values : [
{
displayName : 'Sort Field' ,
name : 'sort_field' ,
type : 'string' ,
default : '' ,
2022-08-01 13:47:55 -07:00
description :
'Specify the field to use for sorting. Either use a fielddefined for the current typeor use <code>_random_sorting</code> to get the entries in a random order.' ,
2021-03-03 16:09:31 -08:00
} ,
{
displayName : 'Descending' ,
name : 'descending' ,
type : 'boolean' ,
default : false ,
} ,
{
displayName : 'Geo Reference' ,
name : 'geo_reference' ,
type : 'string' ,
default : '' ,
2022-08-01 13:47:55 -07:00
description :
"When the field's type is geographic address, you need to add another parameter geo_reference and provide an address as a string" ,
2021-03-03 16:09:31 -08:00
} ,
] ,
} ,
] ,
} ,
] ,
} ,
2021-12-03 00:44:16 -08:00
] ;