2023-01-27 03:22:44 -08:00
import type { INodeProperties } from 'n8n-workflow' ;
2022-03-20 01:54:31 -07:00
export const submissionOperations : INodeProperties [ ] = [
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2022-03-20 01:54:31 -07:00
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'submission' ] ,
2022-03-20 01:54:31 -07:00
} ,
} ,
options : [
{
name : 'Delete' ,
value : 'delete' ,
description : 'Delete a single submission' ,
2022-07-10 13:50:51 -07:00
action : 'Delete a submission' ,
2022-03-20 01:54:31 -07:00
} ,
{
name : 'Get' ,
value : 'get' ,
description : 'Get a single submission' ,
2022-07-10 13:50:51 -07:00
action : 'Get a submission' ,
2022-03-20 01:54:31 -07:00
} ,
{
2022-09-07 07:51:14 -07:00
name : 'Get Many' ,
2022-03-20 01:54:31 -07:00
value : 'getAll' ,
2022-09-13 03:36:36 -07:00
description : 'Get many submissions' ,
2022-09-08 08:10:13 -07:00
action : 'Get many submissions' ,
2022-03-20 01:54:31 -07:00
} ,
{
name : 'Get Validation Status' ,
value : 'getValidation' ,
description : 'Get the validation status for the submission' ,
2022-07-10 13:50:51 -07:00
action : 'Get the validation status for a submission' ,
2022-03-20 01:54:31 -07:00
} ,
{
name : 'Update Validation Status' ,
value : 'setValidation' ,
description : 'Set the validation status of the submission' ,
2022-07-10 13:50:51 -07:00
action : 'Update the validation status for a submission' ,
2022-03-20 01:54:31 -07:00
} ,
] ,
default : 'getAll' ,
} ,
] ;
export const submissionFields : INodeProperties [ ] = [
/* -------------------------------------------------------------------------- */
/* submission:get */
/* -------------------------------------------------------------------------- */
{
2022-06-03 10:23:49 -07:00
displayName : 'Form Name or ID' ,
2022-03-20 01:54:31 -07:00
name : 'formId' ,
type : 'options' ,
typeOptions : {
loadOptionsMethod : 'loadForms' ,
} ,
required : true ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'submission' ] ,
2022-12-06 02:00:53 -08:00
operation : [ 'get' , 'delete' , 'getValidation' , 'setValidation' , 'getAll' ] ,
2022-03-20 01:54:31 -07:00
} ,
} ,
2022-08-17 08:50:24 -07:00
description :
2024-09-12 07:53:36 -07:00
'Form ID (e.g. aSAvYreNzVEkrWg5Gdcvg). Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.' ,
2022-03-20 01:54:31 -07:00
} ,
{
displayName : 'Submission ID' ,
name : 'submissionId' ,
type : 'string' ,
required : true ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'submission' ] ,
operation : [ 'get' , 'delete' , 'getValidation' , 'setValidation' ] ,
2022-03-20 01:54:31 -07:00
} ,
} ,
description : 'Submission ID (number, e.g. 245128)' ,
} ,
{
displayName : 'Validation Status' ,
name : 'validationStatus' ,
type : 'options' ,
required : true ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'submission' ] ,
operation : [ 'setValidation' ] ,
2022-03-20 01:54:31 -07:00
} ,
} ,
default : '' ,
options : [
{
name : 'Approved' ,
value : 'validation_status_approved' ,
} ,
{
name : 'Not Approved' ,
value : 'validation_status_not_approved' ,
} ,
{
name : 'On Hold' ,
value : 'validation_status_on_hold' ,
} ,
] ,
description : 'Desired Validation Status' ,
} ,
/* -------------------------------------------------------------------------- */
/* submission:getAll */
/* -------------------------------------------------------------------------- */
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
required : true ,
default : false ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'submission' ] ,
operation : [ 'getAll' ] ,
2022-03-20 01:54:31 -07:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2022-03-20 01:54:31 -07:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
typeOptions : {
maxValue : 3000 ,
} ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'submission' ] ,
operation : [ 'getAll' ] ,
returnAll : [ false ] ,
2022-03-20 01:54:31 -07:00
} ,
} ,
default : 100 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2022-03-20 01:54:31 -07:00
} ,
2022-05-14 02:20:45 -07:00
{
displayName : 'Filter' ,
name : 'filterType' ,
type : 'options' ,
default : 'none' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'submission' ] ,
operation : [ 'getAll' ] ,
2022-05-14 02:20:45 -07:00
} ,
} ,
options : [
{
name : 'None' ,
value : 'none' ,
} ,
{
name : 'JSON' ,
value : 'json' ,
} ,
] ,
} ,
{
2022-08-17 08:50:24 -07:00
displayName :
'See <a href="https://github.com/SEL-Columbia/formhub/wiki/Formhub-Access-Points-(API)#api-parameters" target="_blank">Formhub API docs</a> to creating filters, using the MongoDB JSON format - e.g. {"_submission_time":{"$lt":"2021-10-01T01:02:03"}}' ,
2022-05-14 02:20:45 -07:00
name : 'jsonNotice' ,
type : 'notice' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'submission' ] ,
operation : [ 'getAll' ] ,
filterType : [ 'json' ] ,
2022-05-14 02:20:45 -07:00
} ,
} ,
default : '' ,
} ,
{
displayName : 'Filters (JSON)' ,
name : 'filterJson' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'submission' ] ,
operation : [ 'getAll' ] ,
filterType : [ 'json' ] ,
2022-05-14 02:20:45 -07:00
} ,
} ,
} ,
2022-03-20 01:54:31 -07:00
{
displayName : 'Options' ,
name : 'options' ,
type : 'collection' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
resource : [ 'submission' ] ,
operation : [ 'get' , 'getAll' ] ,
2022-03-20 01:54:31 -07:00
} ,
} ,
default : { } ,
2024-07-29 05:27:23 -07:00
placeholder : 'Add option' ,
2022-03-20 01:54:31 -07:00
options : [
2022-05-14 02:20:45 -07:00
{
displayName : 'Download Attachments' ,
name : 'download' ,
type : 'boolean' ,
default : false ,
2022-06-20 07:54:01 -07:00
description : 'Whether to download submitted attachments' ,
2022-05-14 02:20:45 -07:00
} ,
{
displayName : 'Attachments Naming Scheme' ,
name : 'binaryNamingScheme' ,
type : 'options' ,
default : 'sequence' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
download : [ true ] ,
2022-05-14 02:20:45 -07:00
} ,
} ,
options : [
{
name : 'Sequence (e.g. attachment_N)' ,
value : 'sequence' ,
} ,
{
name : 'Use Original Form Question ID' ,
value : 'question' ,
} ,
] ,
} ,
2022-03-20 01:54:31 -07:00
{
displayName : 'Attachments Prefix' ,
name : 'dataPropertyAttachmentsPrefixName' ,
type : 'string' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
download : [ true ] ,
binaryNamingScheme : [ 'sequence' ] ,
2022-03-20 01:54:31 -07:00
} ,
} ,
default : 'attachment_' ,
2022-08-17 08:50:24 -07:00
description :
'Prefix for name of the binary property to which to write the attachments. An index starting with 0 will be added. So if name is "attachment_" the first attachment is saved to "attachment_0"' ,
2022-03-20 01:54:31 -07:00
} ,
{
displayName : 'Fields to Retrieve' ,
name : 'fields' ,
type : 'string' ,
default : '' ,
2022-08-17 08:50:24 -07:00
description :
'Comma-separated list of fields to retrieve (e.g. _submission_time,_submitted_by). If left blank, all fields are retrieved.' ,
2022-03-20 01:54:31 -07:00
} ,
{
displayName : 'File Size' ,
name : 'version' ,
type : 'options' ,
displayOptions : {
show : {
2022-08-17 08:50:24 -07:00
download : [ true ] ,
2022-03-20 01:54:31 -07:00
} ,
} ,
default : 'download_url' ,
description : 'Attachment size to retrieve, if multiple versions are available' ,
options : [
{
name : 'Original' ,
value : 'download_url' ,
} ,
{
name : 'Small' ,
value : 'download_small_url' ,
} ,
{
name : 'Medium' ,
value : 'download_medium_url' ,
} ,
{
name : 'Large' ,
value : 'download_large_url' ,
} ,
] ,
} ,
{
displayName : 'Multiselect Mask' ,
name : 'selectMask' ,
type : 'string' ,
default : 'select_*' ,
2022-08-17 08:50:24 -07:00
description :
'Comma-separated list of wildcard-style selectors for fields that should be treated as multiselect fields, i.e. parsed as arrays.' ,
2022-03-20 01:54:31 -07:00
} ,
{
displayName : 'Number Mask' ,
name : 'numberMask' ,
type : 'string' ,
default : 'n_*, f_*' ,
2022-08-17 08:50:24 -07:00
description :
'Comma-separated list of wildcard-style selectors for fields that should be treated as numbers' ,
2022-03-20 01:54:31 -07:00
} ,
{
displayName : 'Reformat' ,
name : 'reformat' ,
type : 'boolean' ,
default : false ,
2022-08-17 08:50:24 -07:00
description :
'Whether to apply some reformatting to the submission data, such as parsing GeoJSON coordinates' ,
2022-03-20 01:54:31 -07:00
} ,
2022-05-14 02:20:45 -07:00
{
displayName : 'Sort' ,
name : 'sort' ,
type : 'json' ,
default : '' ,
description : 'Sort predicates, in MongoDB JSON format (e.g. {"_submission_time":1})' ,
} ,
2022-03-20 01:54:31 -07:00
] ,
} ,
] ;