Skip to content

Commit

Permalink
✨ Add Notion node V2 (#2437)
Browse files Browse the repository at this point in the history
* ⚡ 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>
  • Loading branch information
RicardoE105 and janober authored Dec 29, 2021
1 parent aab5f5d commit 7a8425a
Show file tree
Hide file tree
Showing 15 changed files with 2,434 additions and 722 deletions.
2 changes: 1 addition & 1 deletion packages/cli/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ class App {
const testFunctionSearch =
credential.name === credentialType && !!credential.testedBy;
if (testFunctionSearch) {
foundTestFunction = (node as unknown as INodeType).methods!.credentialTest![
foundTestFunction = (nodeType as unknown as INodeType).methods!.credentialTest![
credential.testedBy!
];
}
Expand Down
24 changes: 12 additions & 12 deletions packages/nodes-base/nodes/Notion/BlockDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
blocks,
} from './Blocks';

export const blockOperations: INodeProperties[] = [
export const blockOperations = [
{
displayName: 'Operation',
name: 'operation',
Expand All @@ -20,28 +20,27 @@ export const blockOperations: INodeProperties[] = [
},
options: [
{
name: 'Append',
name: 'Append After',
value: 'append',
description: 'Append a block',
},
{
name: 'Get All',
name: 'Get Child Blocks',
value: 'getAll',
description: 'Get all children blocks',
},
],
default: 'append',
description: 'The operation to perform.',
},
];
] as INodeProperties[];

export const blockFields: INodeProperties[] = [
export const blockFields = [

/* -------------------------------------------------------------------------- */
/* block:append */
/* -------------------------------------------------------------------------- */
{
displayName: 'Block ID',
displayName: 'Block ID or Link',
name: 'blockId',
type: 'string',
default: '',
Expand All @@ -56,14 +55,14 @@ export const blockFields: INodeProperties[] = [
],
},
},
description: `The ID of block. A page it is also considered a block. Hence, a Page ID can be used as well.`,
description: `The Block URL from Notion's 'copy link' functionality (or just the ID contained within the URL). Pages are also blocks, so you can use a page URL/ID here too`,
},
...blocks('block', 'append'),
/* -------------------------------------------------------------------------- */
/* block:getAll */
/* -------------------------------------------------------------------------- */
{
displayName: 'Block ID',
displayName: 'Block ID or Link',
name: 'blockId',
type: 'string',
default: '',
Expand All @@ -78,6 +77,7 @@ export const blockFields: INodeProperties[] = [
],
},
},
description: `The Block URL from Notion's 'copy link' functionality (or just the ID contained within the URL). Pages are also blocks, so you can use a page URL/ID here too`,
},
{
displayName: 'Return All',
Expand All @@ -94,7 +94,7 @@ export const blockFields: INodeProperties[] = [
},
},
default: false,
description: 'If all results should be returned or only up to a given limit.',
description: 'If all results should be returned or only up to a given limit',
},
{
displayName: 'Limit',
Expand All @@ -118,6 +118,6 @@ export const blockFields: INodeProperties[] = [
maxValue: 100,
},
default: 50,
description: 'How many results to return.',
description: 'How many results to return',
},
];
] as INodeProperties[];
51 changes: 25 additions & 26 deletions packages/nodes-base/nodes/Notion/Blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,46 +95,46 @@ const annotation: INodeProperties[] = [
name: 'bold',
type: 'boolean',
default: false,
description: 'Whether the text is bolded.',
description: 'Whether the text is bolded',
},
{
displayName: 'Italic',
name: 'italic',
type: 'boolean',
default: false,
description: 'Whether the text is italicized.',
description: 'Whether the text is italicized',
},
{
displayName: 'Strikethrough',
name: 'strikethrough',
type: 'boolean',
default: false,
description: 'Whether the text is struck through.',
description: 'Whether the text is struck through',
},
{
displayName: 'Underline',
name: 'underline',
type: 'boolean',
default: false,
description: 'Whether the text is underlined.',
description: 'Whether the text is underlined',
},
{
displayName: 'Code',
name: 'code',
type: 'boolean',
default: false,
description: 'Whether the text is code style.',
description: 'Whether the text is code style',
},
{
displayName: 'Color',
name: 'color',
type: 'options',
options: colors,
default: '',
description: 'Color of the text.',
description: 'Color of the text',
},
],
description: 'All annotations that apply to this rich text.',
description: 'All annotations that apply to this rich text',
},
];

Expand Down Expand Up @@ -169,7 +169,7 @@ const typeMention: INodeProperties[] = [
},
],
default: '',
description: `An inline mention of a user, page, database, or date. In the app these are created by typing @ followed by the name of a user, page, database, or a date.`,
description: `An inline mention of a user, page, database, or date. In the app these are created by typing @ followed by the name of a user, page, database, or a date`,
},
{
displayName: 'User ID',
Expand All @@ -186,7 +186,7 @@ const typeMention: INodeProperties[] = [
},
},
default: '',
description: 'The id of the user being mentioned.',
description: 'The ID of the user being mentioned',
},
{
displayName: 'Page ID',
Expand All @@ -200,7 +200,7 @@ const typeMention: INodeProperties[] = [
},
},
default: '',
description: 'The id of the page being mentioned.',
description: 'The ID of the page being mentioned',
},
{
displayName: 'Database ID',
Expand All @@ -217,7 +217,7 @@ const typeMention: INodeProperties[] = [
},
},
default: '',
description: 'The id of the database being mentioned.',
description: 'The ID of the database being mentioned',
},
{
displayName: 'Range',
Expand All @@ -231,7 +231,7 @@ const typeMention: 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: 'Date',
Expand All @@ -248,7 +248,7 @@ const typeMention: 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',
Expand All @@ -265,7 +265,7 @@ const typeMention: 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',
Expand All @@ -282,7 +282,7 @@ const typeMention: INodeProperties[] = [
},
type: 'dateTime',
default: '',
description: `An ISO 8601 formatted date, with optional time. Represents the end of a date range.`,
description: `An ISO 8601 formatted date, with optional time. Represents the end of a date range`,
},
];

Expand Down Expand Up @@ -316,7 +316,8 @@ const typeText: INodeProperties[] = [
},
type: 'string',
default: '',
description: `Text content. This field contains the actual content of your text and is probably the field you'll use most often.`,
description: `Text content. This field contains the actual content
of your text and is probably the field you'll use most often`,
},
{
displayName: 'Is Link',
Expand Down Expand Up @@ -346,7 +347,7 @@ const typeText: INodeProperties[] = [
},
type: 'string',
default: '',
description: 'The URL that this link points to.',
description: 'The URL that this link points to',
},
];

Expand Down Expand Up @@ -395,8 +396,8 @@ export const text = (displayOptions: IDisplayOptions): INodeProperties[] => [
],
},
],
description: 'Rich text in the block.',
}];
description: 'Rich text in the block',
}] as INodeProperties[];


const todo = (type: string): INodeProperties[] => [{
Expand All @@ -411,8 +412,8 @@ const todo = (type: string): INodeProperties[] => [{
],
},
},
description: 'Whether the to_do is checked or not.',
}];
description: 'Whether the to_do is checked or not',
}] as INodeProperties[];

const title = (type: string): INodeProperties[] => [{
displayName: 'Title',
Expand All @@ -426,8 +427,8 @@ const title = (type: string): INodeProperties[] => [{
],
},
},
description: 'Plain text of page title.',
}];
description: 'Plain text of page title',
}] as INodeProperties[];

const richText = (displayOptions: IDisplayOptions): INodeProperties[] => [
{
Expand All @@ -449,7 +450,7 @@ const textContent = (displayOptions: IDisplayOptions): INodeProperties[] => [
},
];

const block = (blockType: string) => {
const block = (blockType: string): INodeProperties[] => {
const data: INodeProperties[] = [];
switch (blockType) {
case 'to_do':
Expand Down Expand Up @@ -549,7 +550,6 @@ export const blocks = (resource: string, operation: string): INodeProperties[] =
typeOptions: {
loadOptionsMethod: 'getBlockTypes',
},
description: 'Type of block',
default: 'paragraph',
},
...block('paragraph'),
Expand All @@ -566,4 +566,3 @@ export const blocks = (resource: string, operation: string): INodeProperties[] =
],
},
];

Loading

0 comments on commit 7a8425a

Please sign in to comment.