n8n-nodes-notion-advanced 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 n8n Community
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,267 @@
1
+ # n8n Notion Advanced Node
2
+
3
+ A comprehensive n8n community node that provides complete access to the Notion API v2022-06-28 with support for all block types, rich text formatting, and CRUD operations.
4
+
5
+ ## Features
6
+
7
+ ### Complete Block Type Support
8
+ - **Basic Text Blocks**: paragraph, heading_1/2/3, bulleted_list_item, numbered_list_item, to_do, toggle, quote, callout, divider
9
+ - **Code Blocks**: code with syntax highlighting support for 170+ languages
10
+ - **Media Blocks**: image, video, audio, file, pdf with upload and external URL support
11
+ - **Interactive Blocks**: bookmark, embed, link_preview, equation (LaTeX)
12
+ - **Advanced Layout**: table, table_row, column_list, column, synced_block, template, table_of_contents
13
+ - **Database Integration**: child_database, child_page references
14
+
15
+ ### Rich Text Formatting
16
+ - **Annotations**: bold, italic, strikethrough, underline, code
17
+ - **Colors**: All 10 text colors and 9 background colors
18
+ - **Links**: Internal page links and external URLs
19
+ - **Mentions**: User, page, database, and date mentions
20
+ - **Equations**: Inline and block LaTeX math expressions
21
+
22
+ ### Operations
23
+ - **Pages**: Create, read, update, archive, search with full property support
24
+ - **Blocks**: Create, read, update, delete, get children, append children
25
+ - **Databases**: Get, query, create with complete schema support
26
+ - **Users**: Get, list workspace users
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ npm install n8n-notion-advanced-node
32
+ ```
33
+
34
+ 📖 **For detailed installation instructions including Docker setup, development mode, and troubleshooting, see [INSTALLATION.md](./INSTALLATION.md)**
35
+
36
+ ## Prerequisites
37
+
38
+ - n8n instance (self-hosted or cloud)
39
+ - Notion API integration with appropriate permissions
40
+ - Existing `notionApi` credentials configured in n8n
41
+
42
+ ## Usage
43
+
44
+ ### Setting up Credentials
45
+
46
+ This node uses the existing n8n Notion API credentials. Ensure you have:
47
+
48
+ 1. Created a Notion integration at https://developers.notion.com/
49
+ 2. Added the integration to your Notion workspace
50
+ 3. Configured the `notionApi` credential in n8n with your integration token
51
+
52
+ ### Basic Examples
53
+
54
+ #### Creating a Page
55
+
56
+ ```json
57
+ {
58
+ "resource": "page",
59
+ "operation": "create",
60
+ "parent": "page-id-or-url",
61
+ "title": "My New Page",
62
+ "properties": {
63
+ "property": [
64
+ {
65
+ "name": "Status",
66
+ "type": "select",
67
+ "value": "{\"name\": \"In Progress\"}"
68
+ }
69
+ ]
70
+ }
71
+ }
72
+ ```
73
+
74
+ #### Adding Blocks to a Page
75
+
76
+ ```json
77
+ {
78
+ "resource": "block",
79
+ "operation": "create",
80
+ "parentId": "page-id",
81
+ "blocks": {
82
+ "block": [
83
+ {
84
+ "type": "paragraph",
85
+ "content": "This is a simple paragraph"
86
+ },
87
+ {
88
+ "type": "heading_1",
89
+ "content": "Main Heading",
90
+ "properties": "{\"color\": \"blue\"}"
91
+ },
92
+ {
93
+ "type": "code",
94
+ "content": "console.log('Hello World');",
95
+ "properties": "{\"language\": \"javascript\"}"
96
+ }
97
+ ]
98
+ }
99
+ }
100
+ ```
101
+
102
+ #### Rich Text with Formatting
103
+
104
+ ```json
105
+ {
106
+ "type": "paragraph",
107
+ "richText": "[{\"type\": \"text\", \"text\": {\"content\": \"Bold text\"}, \"annotations\": {\"bold\": true}}, {\"type\": \"text\", \"text\": {\"content\": \" and \"}, \"annotations\": {}}, {\"type\": \"text\", \"text\": {\"content\": \"italic text\", \"link\": {\"url\": \"https://example.com\"}}, \"annotations\": {\"italic\": true, \"color\": \"blue\"}}]"
108
+ }
109
+ ```
110
+
111
+ ## Block Types Reference
112
+
113
+ ### Text Blocks
114
+
115
+ | Block Type | Properties | Description |
116
+ |------------|-----------|-------------|
117
+ | `paragraph` | `rich_text`, `color`, `children` | Basic text paragraph |
118
+ | `heading_1` | `rich_text`, `color`, `is_toggleable` | Top-level heading |
119
+ | `heading_2` | `rich_text`, `color`, `is_toggleable` | Second-level heading |
120
+ | `heading_3` | `rich_text`, `color`, `is_toggleable` | Third-level heading |
121
+ | `bulleted_list_item` | `rich_text`, `color`, `children` | Bullet point list item |
122
+ | `numbered_list_item` | `rich_text`, `color`, `children` | Numbered list item |
123
+ | `to_do` | `rich_text`, `checked`, `color`, `children` | Checkbox item |
124
+ | `toggle` | `rich_text`, `color`, `children` | Collapsible section |
125
+ | `quote` | `rich_text`, `color`, `children` | Block quote |
126
+ | `callout` | `rich_text`, `icon`, `color`, `children` | Highlighted callout |
127
+
128
+ ### Code Blocks
129
+
130
+ | Block Type | Properties | Description |
131
+ |------------|-----------|-------------|
132
+ | `code` | `rich_text`, `language`, `caption` | Code block with syntax highlighting |
133
+
134
+ **Supported Languages**: JavaScript, Python, Java, C++, HTML, CSS, SQL, JSON, XML, and 160+ more.
135
+
136
+ ### Media Blocks
137
+
138
+ | Block Type | Properties | Description |
139
+ |------------|-----------|-------------|
140
+ | `image` | `url`, `caption` | Image from URL or upload |
141
+ | `video` | `url`, `caption` | Video embed or upload |
142
+ | `audio` | `url`, `caption` | Audio file |
143
+ | `file` | `url`, `caption` | Generic file attachment |
144
+ | `pdf` | `url`, `caption` | PDF document |
145
+
146
+ ### Interactive Blocks
147
+
148
+ | Block Type | Properties | Description |
149
+ |------------|-----------|-------------|
150
+ | `bookmark` | `url`, `caption` | Website bookmark with preview |
151
+ | `embed` | `url`, `caption` | Embedded content |
152
+ | `link_preview` | `url` | Auto-generated link preview |
153
+ | `equation` | `expression` | LaTeX mathematical expression |
154
+
155
+ ### Layout Blocks
156
+
157
+ | Block Type | Properties | Description |
158
+ |------------|-----------|-------------|
159
+ | `table` | `table_width`, `has_column_header`, `has_row_header`, `children` | Data table |
160
+ | `table_row` | `cells` | Table row with cells |
161
+ | `column_list` | `children` | Container for columns |
162
+ | `column` | `children` | Individual column |
163
+ | `divider` | None | Horizontal divider line |
164
+
165
+ ### Advanced Blocks
166
+
167
+ | Block Type | Properties | Description |
168
+ |------------|-----------|-------------|
169
+ | `synced_block` | `synced_from`, `children` | Synchronized content block |
170
+ | `template` | `rich_text`, `children` | Template block |
171
+ | `table_of_contents` | `color` | Auto-generated table of contents |
172
+ | `child_database` | `title` | Inline database |
173
+ | `child_page` | `title` | Child page reference |
174
+
175
+ ## Rich Text Formatting
176
+
177
+ ### Annotations
178
+
179
+ ```json
180
+ {
181
+ "annotations": {
182
+ "bold": true,
183
+ "italic": false,
184
+ "strikethrough": false,
185
+ "underline": true,
186
+ "code": false,
187
+ "color": "blue"
188
+ }
189
+ }
190
+ ```
191
+
192
+ ### Colors
193
+
194
+ **Text Colors**: `default`, `gray`, `brown`, `orange`, `yellow`, `green`, `blue`, `purple`, `pink`, `red`
195
+
196
+ **Background Colors**: `gray_background`, `brown_background`, `orange_background`, `yellow_background`, `green_background`, `blue_background`, `purple_background`, `pink_background`, `red_background`
197
+
198
+ ### Links
199
+
200
+ ```json
201
+ {
202
+ "text": {
203
+ "content": "Link text",
204
+ "link": {
205
+ "url": "https://example.com"
206
+ }
207
+ }
208
+ }
209
+ ```
210
+
211
+ ## Error Handling
212
+
213
+ The node provides comprehensive error handling:
214
+
215
+ - **Credential Validation**: Automatically validates API credentials
216
+ - **Input Validation**: Validates all required fields and block structures
217
+ - **API Error Mapping**: Maps Notion API errors to user-friendly messages
218
+ - **Graceful Degradation**: Continues processing with `continueOnFail` option
219
+
220
+ ## Performance Features
221
+
222
+ - **Pagination Support**: Automatically handles paginated responses
223
+ - **Batch Operations**: Efficient bulk block creation and updates
224
+ - **Credential Caching**: Reuses authentication across requests
225
+ - **Request Optimization**: Minimizes API calls with intelligent batching
226
+
227
+ ## Troubleshooting
228
+
229
+ ### Common Issues
230
+
231
+ 1. **Permission Errors**: Ensure your Notion integration has access to the target pages/databases
232
+ 2. **Invalid Block Types**: Check that all block properties match the expected schema
233
+ 3. **Rate Limiting**: The node respects Notion's rate limits automatically
234
+ 4. **Large Content**: For pages with many blocks, consider using batch operations
235
+
236
+ ### Debug Tips
237
+
238
+ - Enable n8n's debug mode to see full API requests/responses
239
+ - Validate JSON strings in block properties before sending
240
+ - Test with simple blocks before adding complex formatting
241
+ - Check Notion's API documentation for the latest block schemas
242
+
243
+ ## API Reference
244
+
245
+ This node implements Notion API version `2022-06-28`. For the most up-to-date API documentation, visit:
246
+ https://developers.notion.com/reference
247
+
248
+ ## Contributing
249
+
250
+ Contributions are welcome! Please:
251
+
252
+ 1. Fork the repository
253
+ 2. Create a feature branch
254
+ 3. Add tests for new functionality
255
+ 4. Submit a pull request
256
+
257
+ ## License
258
+
259
+ MIT License - see LICENSE file for details.
260
+
261
+ ## Support
262
+
263
+ For issues and questions:
264
+ - Check the troubleshooting section
265
+ - Review Notion's API documentation
266
+ - Open an issue on GitHub
267
+ - Join the n8n community forum
@@ -0,0 +1,25 @@
1
+ import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
2
+ export declare class NotionAdvanced implements INodeType {
3
+ description: INodeTypeDescription;
4
+ execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
5
+ private executePage;
6
+ private executeBlock;
7
+ private executeDatabase;
8
+ private executeUser;
9
+ private createPage;
10
+ private getPage;
11
+ private updatePage;
12
+ private archivePage;
13
+ private searchPages;
14
+ private createBlocks;
15
+ private getBlock;
16
+ private updateBlock;
17
+ private deleteBlock;
18
+ private getBlockChildren;
19
+ private appendBlockChildren;
20
+ private getDatabase;
21
+ private queryDatabase;
22
+ private createDatabase;
23
+ private getUser;
24
+ private listUsers;
25
+ }