Add Notion node V2 (#2437)

*  Add versioning

*  Add credentials verification

*  Add folmula filtering

*  Add file support

*  Apply internal review

*  Improvements

*  Add page updated event to trigger

*  Use name instead of id when setting expression in select type

*  improvements

*  Improvements

*  Improvement to descriptions

*  Add filter to databasePage:getAll

*  Improvements

*  Add database:search operation

*  Add page:archive operation

*  Allow clearing fields date type

*  Allow setting single value in people type field

* asasas

* asasas

* aaaaa

*  Improvements

*  Fix merging issues

* 🐛 Fix filename

*  Minor fix

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Ricardo Espinoza
2021-12-29 17:23:22 -05:00
committed by GitHub
parent aab5f5ddab
commit 7a8425a152
15 changed files with 2434 additions and 722 deletions

View File

@@ -2,6 +2,11 @@ import {
INodeProperties,
} from 'n8n-workflow';
import {
getConditions,
getSearchFilters,
} from './GenericFunctions';
import {
blocks,
text,
@@ -11,13 +16,54 @@ import {
filters,
} from './Filters';
export const databasePageOperations: INodeProperties[] = [
export const databasePageOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
version: [
2,
],
resource: [
'databasePage',
],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a pages in a database',
},
{
name: 'Get',
value: 'get',
description: 'Get a page in a database',
},
{
name: 'Get All',
value: 'getAll',
description: 'Get all pages in a database',
},
{
name: 'Update',
value: 'update',
description: 'Update pages in a database',
},
],
default: 'create',
},
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
version: [
1,
],
resource: [
'databasePage',
],
@@ -41,17 +87,16 @@ export const databasePageOperations: INodeProperties[] = [
},
],
default: 'create',
description: 'The operation to perform.',
},
];
] as INodeProperties[];
export const databasePageFields: INodeProperties[] = [
export const databasePageFields = [
/* -------------------------------------------------------------------------- */
/* databasePage:create */
/* databasePage:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'Database ID',
displayName: 'Database Name or ID',
name: 'databaseId',
type: 'options',
default: '',
@@ -69,10 +114,30 @@ export const databasePageFields: INodeProperties[] = [
],
},
},
description: 'The ID of the database that this databasePage belongs to.',
description: `The Database Page URL from Notion's 'copy link' functionality (or just the ID contained within the URL)`,
},
{
displayName: 'Simple',
displayName: 'Title',
name: 'title',
type: 'string',
default: '',
displayOptions: {
show: {
version: [
2,
],
resource: [
'databasePage',
],
operation: [
'create',
],
},
},
description: 'Page title. Appears at the top of the page and can be found via Quick Find',
},
{
displayName: 'Simplify Output',
name: 'simple',
type: 'boolean',
displayOptions: {
@@ -86,7 +151,7 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: true,
description: 'When set to true a simplify version of the response will be used else the raw data.',
description: 'Whether to return a simplified version of the response instead of the raw data',
},
{
displayName: 'Properties',
@@ -194,7 +259,7 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: '',
description: `Phone number. No structure is enforced.`,
description: `Phone number. No structure is enforced`,
},
{
displayName: 'Options',
@@ -212,7 +277,7 @@ export const databasePageFields: INodeProperties[] = [
},
default: [],
description: `Name of the options you want to set.
Multiples can be defined separated by comma.`,
Multiples can be defined separated by comma`,
},
{
displayName: 'Option',
@@ -229,7 +294,7 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: '',
description: `Name of the option you want to set.`,
description: `Name of the option you want to set`,
},
{
displayName: 'Email',
@@ -243,7 +308,7 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: '',
description: 'Email address.',
description: 'Email address',
},
{
displayName: 'URL',
@@ -257,7 +322,7 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: '',
description: 'Web address.',
description: 'Web address',
},
{
displayName: 'User IDs',
@@ -274,7 +339,7 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: [],
description: 'List of users. Multiples can be defined separated by comma.',
description: 'List of users. Multiples can be defined separated by comma',
},
{
displayName: 'Relation IDs',
@@ -291,7 +356,7 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: [],
description: 'List of databases that belong to another database. Multiples can be defined separated by comma.',
description: 'List of databases that belong to another database. Multiples can be defined separated by comma',
},
{
displayName: 'Checked',
@@ -319,7 +384,7 @@ export const databasePageFields: INodeProperties[] = [
},
type: 'number',
default: 0,
description: 'Number value.',
description: 'Number value',
},
{
displayName: 'Range',
@@ -333,7 +398,7 @@ export const databasePageFields: INodeProperties[] = [
},
type: 'boolean',
default: false,
description: 'Weather or not you want to define a date range.',
description: 'Weather or not you want to define a date range',
},
{
displayName: 'Include Time',
@@ -347,7 +412,7 @@ export const databasePageFields: INodeProperties[] = [
},
type: 'boolean',
default: true,
description: 'Weather or not to include the time in the date.',
description: 'Weather or not to include the time in the date',
},
{
displayName: 'Date',
@@ -364,7 +429,7 @@ export const databasePageFields: INodeProperties[] = [
},
type: 'dateTime',
default: '',
description: 'An ISO 8601 format date, with optional time.',
description: 'An ISO 8601 format date, with optional time',
},
{
displayName: 'Date Start',
@@ -381,7 +446,7 @@ export const databasePageFields: INodeProperties[] = [
},
type: 'dateTime',
default: '',
description: 'An ISO 8601 format date, with optional time.',
description: 'An ISO 8601 format date, with optional time',
},
{
displayName: 'Date End',
@@ -399,7 +464,7 @@ export const databasePageFields: INodeProperties[] = [
type: 'dateTime',
default: '',
description: `
An ISO 8601 formatted date, with optional time. Represents the end of a date range.`,
An ISO 8601 formatted date, with optional time. Represents the end of a date range`,
},
{
displayName: 'Timezone',
@@ -416,7 +481,49 @@ export const databasePageFields: INodeProperties[] = [
loadOptionsMethod: 'getTimezones',
},
default: 'default',
description: 'Time zone to use. By default n8n timezone is used.',
description: 'Time zone to use. By default n8n timezone is used',
},
{
displayName: 'File URLs',
name: 'fileUrls',
placeholder: 'Add File',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
sortable: true,
},
displayOptions: {
show: {
'/version': [
2,
],
type: [
'files',
],
},
},
default: {},
options: [
{
name: 'fileUrl',
displayName: 'File',
values: [
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
},
{
displayName: 'File URL',
name: 'url',
type: 'string',
default: '',
description: 'Link to externally hosted file',
},
],
},
],
},
],
},
@@ -424,10 +531,10 @@ export const databasePageFields: INodeProperties[] = [
},
...blocks('databasePage', 'create'),
/* -------------------------------------------------------------------------- */
/* databasePage:update */
/* databasePage:update */
/* -------------------------------------------------------------------------- */
{
displayName: 'Page ID',
displayName: 'Database Page Link or ID',
name: 'pageId',
type: 'string',
default: '',
@@ -442,10 +549,10 @@ export const databasePageFields: INodeProperties[] = [
],
},
},
description: 'The ID of the databasePage to update.',
description: `The Database Page URL from Notion's 'copy link' functionality (or just the ID contained within the URL)`,
},
{
displayName: 'Simplify Response',
displayName: 'Simplify Output',
name: 'simple',
type: 'boolean',
displayOptions: {
@@ -459,7 +566,7 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: true,
description: 'Return a simplified version of the response instead of the raw data.',
description: 'Whether to return a simplified version of the response instead of the raw data',
},
{
displayName: 'Properties',
@@ -567,7 +674,7 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: '',
description: `Phone number. No structure is enforced.`,
description: `Phone number. No structure is enforced`,
},
{
displayName: 'Options',
@@ -584,8 +691,6 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: [],
description: `Name of the options you want to set.
Multiples can be defined separated by comma.`,
},
{
displayName: 'Option',
@@ -602,7 +707,6 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: '',
description: `Name of the option you want to set.`,
},
{
displayName: 'Email',
@@ -616,7 +720,6 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: '',
description: 'Email address.',
},
{
displayName: 'URL',
@@ -630,7 +733,7 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: '',
description: 'Web address.',
description: 'Web address',
},
{
displayName: 'User IDs',
@@ -647,7 +750,7 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: [],
description: 'List of users. Multiples can be defined separated by comma.',
description: 'List of users. Multiples can be defined separated by comma',
},
{
displayName: 'Relation IDs',
@@ -664,7 +767,7 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: [],
description: 'List of databases that belong to another database. Multiples can be defined separated by comma.',
description: 'List of databases that belong to another database. Multiples can be defined separated by comma',
},
{
displayName: 'Checked',
@@ -692,7 +795,7 @@ export const databasePageFields: INodeProperties[] = [
},
type: 'number',
default: 0,
description: 'Number value.',
description: 'Number value',
},
{
displayName: 'Range',
@@ -706,7 +809,7 @@ export const databasePageFields: INodeProperties[] = [
},
type: 'boolean',
default: false,
description: 'Weather or not you want to define a date range.',
description: 'Weather or not you want to define a date range',
},
{
displayName: 'Include Time',
@@ -720,7 +823,7 @@ export const databasePageFields: INodeProperties[] = [
},
type: 'boolean',
default: true,
description: 'Weather or not to include the time in the date.',
description: 'Weather or not to include the time in the date',
},
{
displayName: 'Date',
@@ -737,7 +840,7 @@ export const databasePageFields: INodeProperties[] = [
},
type: 'dateTime',
default: '',
description: 'An ISO 8601 format date, with optional time.',
description: 'An ISO 8601 format date, with optional time',
},
{
displayName: 'Date Start',
@@ -754,7 +857,7 @@ export const databasePageFields: INodeProperties[] = [
},
type: 'dateTime',
default: '',
description: 'An ISO 8601 format date, with optional time.',
description: 'An ISO 8601 format date, with optional time',
},
{
displayName: 'Date End',
@@ -772,7 +875,7 @@ export const databasePageFields: INodeProperties[] = [
type: 'dateTime',
default: '',
description: `
An ISO 8601 formatted date, with optional time. Represents the end of a date range.`,
An ISO 8601 formatted date, with optional time. Represents the end of a date range`,
},
{
displayName: 'Timezone',
@@ -789,17 +892,103 @@ export const databasePageFields: INodeProperties[] = [
loadOptionsMethod: 'getTimezones',
},
default: 'default',
description: 'Time zone to use. By default n8n timezone is used.',
description: 'Time zone to use. By default n8n timezone is used',
},
{
displayName: 'File URLs',
name: 'fileUrls',
placeholder: 'Add File',
type: 'fixedCollection',
typeOptions: {
multipleValues: true,
sortable: true,
},
displayOptions: {
show: {
'/version': [
2,
],
type: [
'files',
],
},
},
default: {},
options: [
{
name: 'fileUrl',
displayName: 'File',
values: [
{
displayName: 'Name',
name: 'name',
type: 'string',
default: '',
},
{
displayName: 'File URL',
name: 'url',
type: 'string',
default: '',
description: 'Link to externally hosted file',
},
],
},
],
},
],
},
],
},
/* -------------------------------------------------------------------------- */
/* databasePage:get */
/* -------------------------------------------------------------------------- */
{
displayName: 'Database Page Link or ID',
name: 'pageId',
type: 'string',
default: '',
required: true,
displayOptions: {
show: {
version: [
2,
],
resource: [
'databasePage',
],
operation: [
'get',
],
},
},
description: `The Database Page URL from Notion's 'copy link' functionality (or just the ID contained within the URL)`,
},
{
displayName: 'Simplify Output',
name: 'simple',
type: 'boolean',
displayOptions: {
show: {
version: [
2,
],
resource: [
'databasePage',
],
operation: [
'get',
],
},
},
default: true,
description: 'Whether to return a simplified version of the response instead of the raw data',
},
/* -------------------------------------------------------------------------- */
/* databasePage:getAll */
/* -------------------------------------------------------------------------- */
{
displayName: 'Database ID',
displayName: 'Database Name or ID',
name: 'databaseId',
type: 'options',
typeOptions: {
@@ -833,7 +1022,7 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: false,
description: 'If all results should be returned or only up to a given limit.',
description: 'Whether to return all results or only up to a given limit',
},
{
displayName: 'Limit',
@@ -857,10 +1046,10 @@ export const databasePageFields: INodeProperties[] = [
maxValue: 100,
},
default: 50,
description: 'How many results to return.',
description: 'How many results to return',
},
{
displayName: 'Simple',
displayName: 'Simplify Output',
name: 'simple',
type: 'boolean',
displayOptions: {
@@ -874,8 +1063,9 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: true,
description: 'When set to true a simplify version of the response will be used else the raw data.',
description: 'Whether to return a simplified version of the response instead of the raw data',
},
...getSearchFilters('databasePage'),
{
displayName: 'Options',
name: 'options',
@@ -893,6 +1083,26 @@ export const databasePageFields: INodeProperties[] = [
default: {},
placeholder: 'Add Field',
options: [
{
displayName: 'Download Files',
name: 'downloadFiles',
type: 'boolean',
displayOptions: {
show: {
'/version': [
2,
],
'/resource': [
'databasePage',
],
'/operation': [
'getAll',
],
},
},
default: false,
description: 'If a database field contains a file, whether to download it',
},
{
displayName: 'Filters',
name: 'filter',
@@ -901,13 +1111,20 @@ export const databasePageFields: INodeProperties[] = [
typeOptions: {
multipleValues: false,
},
displayOptions: {
show: {
'/version': [
1,
],
},
},
default: {},
options: [
{
displayName: 'Single Condition',
name: 'singleCondition',
values: [
...filters,
...filters(getConditions()),
],
},
{
@@ -928,14 +1145,14 @@ export const databasePageFields: INodeProperties[] = [
displayName: 'OR',
name: 'or',
values: [
...filters,
...filters(getConditions()),
],
},
{
displayName: 'AND',
name: 'and',
values: [
...filters,
...filters(getConditions()),
],
},
],
@@ -963,7 +1180,7 @@ export const databasePageFields: INodeProperties[] = [
name: 'timestamp',
type: 'boolean',
default: false,
description: `Whether or not to use the record's timestamp to sort the response.`,
description: `Whether or not to use the record's timestamp to sort the response`,
},
{
displayName: 'Property Name',
@@ -983,7 +1200,7 @@ export const databasePageFields: INodeProperties[] = [
],
},
default: '',
description: 'The name of the property to filter by.',
description: 'The name of the property to filter by',
},
{
displayName: 'Property Name',
@@ -1007,7 +1224,7 @@ export const databasePageFields: INodeProperties[] = [
},
},
default: '',
description: 'The name of the property to filter by.',
description: 'The name of the property to filter by',
},
{
displayName: 'Type',
@@ -1037,7 +1254,7 @@ export const databasePageFields: INodeProperties[] = [
},
],
default: '',
description: 'The direction to sort.',
description: 'The direction to sort',
},
],
},
@@ -1045,4 +1262,4 @@ export const databasePageFields: INodeProperties[] = [
},
],
},
];
] as INodeProperties[];