2021-04-03 02:07:21 -07:00
|
|
|
import {
|
|
|
|
INodeProperties,
|
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
2021-12-03 00:44:16 -08:00
|
|
|
export const documentOperations: INodeProperties[] = [
|
2021-04-03 02:07:21 -07:00
|
|
|
{
|
|
|
|
displayName: 'Operation',
|
|
|
|
name: 'operation',
|
|
|
|
type: 'options',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'document',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'Create',
|
|
|
|
value: 'create',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Create a document',
|
2021-04-03 02:07:21 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Delete',
|
|
|
|
value: 'delete',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Delete a document',
|
2021-04-03 02:07:21 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Get',
|
|
|
|
value: 'get',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Retrieve a document',
|
2021-04-03 02:07:21 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Get All',
|
|
|
|
value: 'getAll',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Retrieve all documents',
|
2021-04-03 02:07:21 -07:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Update',
|
|
|
|
value: 'update',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Update a document',
|
2021-04-03 02:07:21 -07:00
|
|
|
},
|
|
|
|
],
|
|
|
|
default: 'create',
|
|
|
|
description: 'Operation to perform.',
|
|
|
|
},
|
2021-12-03 00:44:16 -08:00
|
|
|
];
|
2021-04-03 02:07:21 -07:00
|
|
|
|
2021-12-03 00:44:16 -08:00
|
|
|
export const documentFields: INodeProperties[] = [
|
2021-04-03 02:07:21 -07:00
|
|
|
// ----------------------------------
|
|
|
|
// document: getAll
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'DocType',
|
|
|
|
name: 'docType',
|
|
|
|
type: 'options',
|
|
|
|
typeOptions: {
|
|
|
|
loadOptionsMethod: 'getDocTypes',
|
|
|
|
},
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'DocType whose documents to retrieve',
|
2021-04-03 02:07:21 -07:00
|
|
|
placeholder: 'Customer',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'document',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'getAll',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Return All',
|
|
|
|
name: 'returnAll',
|
|
|
|
type: 'boolean',
|
|
|
|
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-03 02:07:21 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'document',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'getAll',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Limit',
|
|
|
|
name: 'limit',
|
|
|
|
type: 'number',
|
|
|
|
default: 10,
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Max number of results to return',
|
2021-04-03 02:07:21 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'document',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'getAll',
|
|
|
|
],
|
|
|
|
returnAll: [
|
|
|
|
false,
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Options',
|
|
|
|
name: 'options',
|
|
|
|
type: 'collection',
|
|
|
|
placeholder: 'Add Field',
|
|
|
|
default: {},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'document',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'getAll',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
displayName: 'Fields',
|
|
|
|
name: 'fields',
|
|
|
|
type: 'multiOptions',
|
|
|
|
typeOptions: {
|
|
|
|
loadOptionsMethod: 'getDocFilters',
|
|
|
|
loadOptionsDependsOn: [
|
|
|
|
'docType',
|
|
|
|
],
|
|
|
|
},
|
2022-04-22 09:29:51 -07:00
|
|
|
default: [],
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Comma-separated list of fields to return',
|
2021-04-03 02:07:21 -07:00
|
|
|
placeholder: 'name,country',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Filters',
|
|
|
|
name: 'filters',
|
|
|
|
type: 'fixedCollection',
|
2021-12-03 00:44:16 -08:00
|
|
|
default: {},
|
2021-04-03 02:07:21 -07:00
|
|
|
placeholder: 'Add Filter',
|
|
|
|
description: 'Custom Properties',
|
|
|
|
typeOptions: {
|
|
|
|
multipleValues: true,
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
displayName: 'Property',
|
|
|
|
name: 'customProperty',
|
|
|
|
values: [
|
|
|
|
{
|
|
|
|
displayName: 'Field',
|
|
|
|
name: 'field',
|
|
|
|
type: 'options',
|
|
|
|
typeOptions: {
|
|
|
|
loadOptionsMethod: 'getDocFields',
|
|
|
|
loadOptionsDependsOn: [
|
|
|
|
'docType',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Operator',
|
|
|
|
name: 'operator',
|
|
|
|
type: 'options',
|
|
|
|
default: 'is',
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
name: 'IS',
|
|
|
|
value: 'is',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'IS NOT',
|
|
|
|
value: 'isNot',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'IS GREATER',
|
|
|
|
value: 'greater',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'IS LESS',
|
|
|
|
value: 'less',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'EQUALS, or GREATER',
|
|
|
|
value: 'equalsGreater',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'EQUALS, or LESS',
|
|
|
|
value: 'equalsLess',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Value',
|
|
|
|
name: 'value',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Value of the operator condition',
|
2021-04-03 02:07:21 -07:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// document: create
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'DocType',
|
|
|
|
name: 'docType',
|
|
|
|
type: 'options',
|
|
|
|
default: '',
|
|
|
|
typeOptions: {
|
|
|
|
loadOptionsMethod: 'getDocTypes',
|
|
|
|
},
|
|
|
|
required: true,
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'DocType you would like to create',
|
2021-04-03 02:07:21 -07:00
|
|
|
placeholder: 'Customer',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'document',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'create',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Properties',
|
|
|
|
name: 'properties',
|
|
|
|
type: 'fixedCollection',
|
|
|
|
placeholder: 'Add Property',
|
|
|
|
required: true,
|
|
|
|
default: {},
|
|
|
|
typeOptions: {
|
|
|
|
multipleValues: true,
|
|
|
|
},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'document',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'create',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
displayName: 'Property',
|
|
|
|
name: 'customProperty',
|
|
|
|
placeholder: 'Add Property',
|
|
|
|
values: [
|
|
|
|
{
|
|
|
|
displayName: 'Field',
|
|
|
|
name: 'field',
|
|
|
|
type: 'options',
|
|
|
|
typeOptions: {
|
|
|
|
loadOptionsMethod: 'getDocFields',
|
|
|
|
loadOptionsDependsOn: [
|
|
|
|
'docType',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
default: [],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Value',
|
|
|
|
name: 'value',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// document: get
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'DocType',
|
|
|
|
name: 'docType',
|
|
|
|
type: 'options',
|
|
|
|
typeOptions: {
|
|
|
|
loadOptionsMethod: 'getDocTypes',
|
|
|
|
},
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'The type of document you would like to get',
|
2021-04-03 02:07:21 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'document',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'get',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Document Name',
|
|
|
|
name: 'documentName',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'The name (ID) of document you would like to get',
|
2021-04-03 02:07:21 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'document',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'get',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// document: delete
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'DocType',
|
|
|
|
name: 'docType',
|
|
|
|
type: 'options',
|
|
|
|
typeOptions: {
|
|
|
|
loadOptionsMethod: 'getDocTypes',
|
|
|
|
},
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'The type of document you would like to delete',
|
2021-04-03 02:07:21 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'document',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'delete',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Document Name',
|
|
|
|
name: 'documentName',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'The name (ID) of document you would like to get',
|
2021-04-03 02:07:21 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'document',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'delete',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------------------------------
|
|
|
|
// document: update
|
|
|
|
// ----------------------------------
|
|
|
|
{
|
|
|
|
displayName: 'DocType',
|
|
|
|
name: 'docType',
|
|
|
|
type: 'options',
|
|
|
|
typeOptions: {
|
|
|
|
loadOptionsMethod: 'getDocTypes',
|
|
|
|
},
|
|
|
|
default: '',
|
|
|
|
description: 'The type of document you would like to update',
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'document',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'update',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Document Name',
|
|
|
|
name: 'documentName',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'The name (ID) of document you would like to get',
|
2021-04-03 02:07:21 -07:00
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'document',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'update',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Properties',
|
|
|
|
name: 'properties',
|
|
|
|
type: 'fixedCollection',
|
|
|
|
placeholder: 'Add Property',
|
2022-05-06 14:01:25 -07:00
|
|
|
description: 'Properties of request body',
|
2021-04-03 02:07:21 -07:00
|
|
|
default: {},
|
|
|
|
typeOptions: {
|
|
|
|
multipleValues: true,
|
|
|
|
},
|
|
|
|
displayOptions: {
|
|
|
|
show: {
|
|
|
|
resource: [
|
|
|
|
'document',
|
|
|
|
],
|
|
|
|
operation: [
|
|
|
|
'update',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
options: [
|
|
|
|
{
|
|
|
|
displayName: 'Property',
|
|
|
|
name: 'customProperty',
|
|
|
|
values: [
|
|
|
|
{
|
|
|
|
displayName: 'Field',
|
|
|
|
name: 'field',
|
|
|
|
type: 'options',
|
|
|
|
typeOptions: {
|
|
|
|
loadOptionsMethod: 'getDocFields',
|
|
|
|
loadOptionsDependsOn: [
|
|
|
|
'docType',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
displayName: 'Value',
|
|
|
|
name: 'value',
|
|
|
|
type: 'string',
|
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2021-12-03 00:44:16 -08:00
|
|
|
];
|