n8n-nodes-notion-advanced 1.2.12-beta → 1.2.14-beta

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/package.json CHANGED
@@ -1,78 +1,69 @@
1
- {
2
- "name": "n8n-nodes-notion-advanced",
3
- "version": "1.2.12-beta",
4
- "description": "Advanced n8n Notion nodes: Full-featured workflow node + AI Agent Tool for intelligent Notion automation with 25+ block types (BETA)",
5
- "scripts": {
6
- "build": "node dev-notes/build-for-install.js",
7
- "build-ts": "tsc && npm run copy-files",
8
- "copy-files": "copyfiles -u 1 \"nodes/**/*.{png,svg}\" dist/",
9
- "dev": "tsc --watch",
10
- "format": "prettier --write .",
11
- "lint": "eslint . --ext .ts",
12
- "prepublishOnly": "npm run build"
13
- },
14
- "files": [
15
- "dist",
16
- "README.md",
17
- "LICENSE"
18
- ],
19
- "n8n": {
20
- "n8nNodesApiVersion": 1,
21
- "nodes": [
22
- "dist/nodes/NotionAdvanced/NotionAdvanced.node.js",
23
- "dist/nodes/NotionAdvanced/NotionAITool.node.js"
24
- ]
25
- },
26
- "keywords": [
27
- "n8n-community-node-package",
28
- "notion",
29
- "productivity",
30
- "api",
31
- "blocks",
32
- "rich-text",
33
- "database",
34
- "pages",
35
- "automation",
36
- "workflow",
37
- "integration",
38
- "notion-api",
39
- "block-types",
40
- "formatting",
41
- "ai",
42
- "ai-agent",
43
- "ai-tool",
44
- "chatgpt",
45
- "claude",
46
- "llm",
47
- "natural-language",
48
- "intelligent-automation"
49
- ],
50
- "license": "MIT",
51
- "homepage": "https://github.com/your-username/n8n-notion-advanced-node#readme",
52
- "author": {
53
- "name": "AZ-IT.US",
54
- "email": "azuniga6290@gmail.com"
55
- },
56
- "repository": {
57
- "type": "git",
58
- "url": "https://github.com/AZ-IT-US/n8n-notion-advanced-node.git"
59
- },
60
- "engines": {
61
- "node": ">=16.10",
62
- "pnpm": ">=7.18"
63
- },
64
- "packageManager": "pnpm@7.18.0",
65
- "devDependencies": {
66
- "@types/node": "^24.1.0",
67
- "@typescript-eslint/eslint-plugin": "^8.38.0",
68
- "@typescript-eslint/parser": "^8.38.0",
69
- "copyfiles": "^2.4.1",
70
- "eslint": "^9.32.0",
71
- "eslint-plugin-n8n-nodes-base": "^1.11.0",
72
- "prettier": "^3.6.2",
73
- "typescript": "^5.1.3"
74
- },
75
- "peerDependencies": {
76
- "n8n-workflow": "^1.82.0"
77
- }
78
- }
1
+ {
2
+ "name": "n8n-nodes-notion-advanced",
3
+ "version": "1.2.14-beta",
4
+ "description": "Advanced n8n Notion nodes: Full-featured workflow node + AI Agent Tool for intelligent Notion automation with 25+ block types (BETA)",
5
+ "scripts": {},
6
+ "files": [
7
+ "nodes",
8
+ "types"
9
+ ],
10
+ "n8n": {
11
+ "n8nNodesApiVersion": 1,
12
+ "nodes": [
13
+ "nodes/NotionAdvanced/NotionAdvanced.node.js",
14
+ "nodes/NotionAdvanced/NotionAITool.node.js"
15
+ ]
16
+ },
17
+ "keywords": [
18
+ "n8n-community-node-package",
19
+ "notion",
20
+ "productivity",
21
+ "api",
22
+ "blocks",
23
+ "rich-text",
24
+ "database",
25
+ "pages",
26
+ "automation",
27
+ "workflow",
28
+ "integration",
29
+ "notion-api",
30
+ "block-types",
31
+ "formatting",
32
+ "ai",
33
+ "ai-agent",
34
+ "ai-tool",
35
+ "chatgpt",
36
+ "claude",
37
+ "llm",
38
+ "natural-language",
39
+ "intelligent-automation"
40
+ ],
41
+ "license": "MIT",
42
+ "homepage": "https://github.com/your-username/n8n-notion-advanced-node#readme",
43
+ "author": {
44
+ "name": "AZ-IT.US",
45
+ "email": "azuniga6290@gmail.com"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/AZ-IT-US/n8n-notion-advanced-node.git"
50
+ },
51
+ "engines": {
52
+ "node": ">=16.10",
53
+ "pnpm": ">=7.18"
54
+ },
55
+ "packageManager": "pnpm@7.18.0",
56
+ "devDependencies": {
57
+ "@types/node": "^24.1.0",
58
+ "@typescript-eslint/eslint-plugin": "^8.38.0",
59
+ "@typescript-eslint/parser": "^8.38.0",
60
+ "copyfiles": "^2.4.1",
61
+ "eslint": "^9.32.0",
62
+ "eslint-plugin-n8n-nodes-base": "^1.11.0",
63
+ "prettier": "^3.6.2",
64
+ "typescript": "^5.1.3"
65
+ },
66
+ "peerDependencies": {
67
+ "n8n-workflow": "^1.82.0"
68
+ }
69
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
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 DELETED
@@ -1,306 +0,0 @@
1
- # n8n Notion Advanced Nodes
2
-
3
- A comprehensive n8n community package that provides complete access to the Notion API v2022-06-28 with support for all block types, rich text formatting, and CRUD operations. Includes both a full-featured workflow node and an AI Agent Tool for intelligent automation.
4
-
5
- ## What's Included
6
-
7
- ### 1. **Notion Advanced** - Full-Featured Workflow Node
8
- Complete Notion integration for traditional n8n workflows with comprehensive CRUD operations and all 25+ block types.
9
-
10
- ### 2. **Notion AI Tool** - AI Agent Integration
11
- Specialized tool designed for n8n's AI Agent Nodes, enabling natural language Notion automation.
12
-
13
- 📖 **For AI Agent usage, see [AI-TOOL-USAGE.md](./AI-TOOL-USAGE.md)**
14
-
15
- ## Features
16
-
17
- ### Complete Block Type Support
18
- - **Basic Text Blocks**: paragraph, heading_1/2/3, bulleted_list_item, numbered_list_item, to_do, toggle, quote, callout, divider
19
- - **Code Blocks**: code with syntax highlighting support for 170+ languages
20
- - **Media Blocks**: image, video, audio, file, pdf with upload and external URL support
21
- - **Interactive Blocks**: bookmark, embed, link_preview, equation (LaTeX)
22
- - **Advanced Layout**: table, table_row, column_list, column, synced_block, template, table_of_contents
23
- - **Database Integration**: child_database, child_page references
24
-
25
- ### Rich Text Formatting
26
- - **Annotations**: bold, italic, strikethrough, underline, code
27
- - **Colors**: All 10 text colors and 9 background colors
28
- - **Links**: Internal page links and external URLs
29
- - **Mentions**: User, page, database, and date mentions
30
- - **Equations**: Inline and block LaTeX math expressions
31
-
32
- ### Operations
33
- - **Pages**: Create, read, update, archive, search with full property support
34
- - **Blocks**: Create, read, update, delete, get children, append children
35
- - **Databases**: Get, query, create with complete schema support
36
- - **Users**: Get, list workspace users
37
-
38
- ## Installation
39
-
40
- ### Via n8n GUI (Recommended)
41
- 1. Open n8n Settings → Community Nodes
42
- 2. Click "Install a community node"
43
- 3. Enter: `n8n-nodes-notion-advanced`
44
- 4. Click Install
45
-
46
- ### Via npm
47
- ```bash
48
- npm install n8n-nodes-notion-advanced
49
- ```
50
-
51
- 📖 **For detailed installation instructions including Docker setup, development mode, and troubleshooting, see [INSTALLATION.md](./INSTALLATION.md)**
52
-
53
- ## Quick Start
54
-
55
- ### For AI Agents
56
- ```markdown
57
- 1. Add AI Agent Node to your workflow
58
- 2. Configure your chat model (OpenAI, Anthropic, etc.)
59
- 3. Add "Notion AI Tool" from available tools
60
- 4. Configure Notion credentials
61
- 5. AI Agent can now create/manage Notion content with natural language!
62
-
63
- Example: "Create a project plan page with timeline and milestones"
64
- ```
65
-
66
- ### For Traditional Workflows
67
- ```markdown
68
- 1. Add "Notion Advanced" node to your workflow
69
- 2. Configure Notion credentials
70
- 3. Choose resource (Page/Block/Database/User)
71
- 4. Select operation and configure parameters
72
- 5. Execute comprehensive Notion operations
73
- ```
74
-
75
- ## Prerequisites
76
-
77
- - n8n instance (self-hosted or cloud)
78
- - Notion API integration with appropriate permissions
79
- - Existing `notionApi` credentials configured in n8n
80
-
81
- ## Usage
82
-
83
- ### Setting up Credentials
84
-
85
- This node uses the existing n8n Notion API credentials. Ensure you have:
86
-
87
- 1. Created a Notion integration at https://developers.notion.com/
88
- 2. Added the integration to your Notion workspace
89
- 3. Configured the `notionApi` credential in n8n with your integration token
90
-
91
- ### Basic Examples
92
-
93
- #### Creating a Page
94
-
95
- ```json
96
- {
97
- "resource": "page",
98
- "operation": "create",
99
- "parent": "page-id-or-url",
100
- "title": "My New Page",
101
- "properties": {
102
- "property": [
103
- {
104
- "name": "Status",
105
- "type": "select",
106
- "value": "{\"name\": \"In Progress\"}"
107
- }
108
- ]
109
- }
110
- }
111
- ```
112
-
113
- #### Adding Blocks to a Page
114
-
115
- ```json
116
- {
117
- "resource": "block",
118
- "operation": "create",
119
- "parentId": "page-id",
120
- "blocks": {
121
- "block": [
122
- {
123
- "type": "paragraph",
124
- "content": "This is a simple paragraph"
125
- },
126
- {
127
- "type": "heading_1",
128
- "content": "Main Heading",
129
- "properties": "{\"color\": \"blue\"}"
130
- },
131
- {
132
- "type": "code",
133
- "content": "console.log('Hello World');",
134
- "properties": "{\"language\": \"javascript\"}"
135
- }
136
- ]
137
- }
138
- }
139
- ```
140
-
141
- #### Rich Text with Formatting
142
-
143
- ```json
144
- {
145
- "type": "paragraph",
146
- "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\"}}]"
147
- }
148
- ```
149
-
150
- ## Block Types Reference
151
-
152
- ### Text Blocks
153
-
154
- | Block Type | Properties | Description |
155
- |------------|-----------|-------------|
156
- | `paragraph` | `rich_text`, `color`, `children` | Basic text paragraph |
157
- | `heading_1` | `rich_text`, `color`, `is_toggleable` | Top-level heading |
158
- | `heading_2` | `rich_text`, `color`, `is_toggleable` | Second-level heading |
159
- | `heading_3` | `rich_text`, `color`, `is_toggleable` | Third-level heading |
160
- | `bulleted_list_item` | `rich_text`, `color`, `children` | Bullet point list item |
161
- | `numbered_list_item` | `rich_text`, `color`, `children` | Numbered list item |
162
- | `to_do` | `rich_text`, `checked`, `color`, `children` | Checkbox item |
163
- | `toggle` | `rich_text`, `color`, `children` | Collapsible section |
164
- | `quote` | `rich_text`, `color`, `children` | Block quote |
165
- | `callout` | `rich_text`, `icon`, `color`, `children` | Highlighted callout |
166
-
167
- ### Code Blocks
168
-
169
- | Block Type | Properties | Description |
170
- |------------|-----------|-------------|
171
- | `code` | `rich_text`, `language`, `caption` | Code block with syntax highlighting |
172
-
173
- **Supported Languages**: JavaScript, Python, Java, C++, HTML, CSS, SQL, JSON, XML, and 160+ more.
174
-
175
- ### Media Blocks
176
-
177
- | Block Type | Properties | Description |
178
- |------------|-----------|-------------|
179
- | `image` | `url`, `caption` | Image from URL or upload |
180
- | `video` | `url`, `caption` | Video embed or upload |
181
- | `audio` | `url`, `caption` | Audio file |
182
- | `file` | `url`, `caption` | Generic file attachment |
183
- | `pdf` | `url`, `caption` | PDF document |
184
-
185
- ### Interactive Blocks
186
-
187
- | Block Type | Properties | Description |
188
- |------------|-----------|-------------|
189
- | `bookmark` | `url`, `caption` | Website bookmark with preview |
190
- | `embed` | `url`, `caption` | Embedded content |
191
- | `link_preview` | `url` | Auto-generated link preview |
192
- | `equation` | `expression` | LaTeX mathematical expression |
193
-
194
- ### Layout Blocks
195
-
196
- | Block Type | Properties | Description |
197
- |------------|-----------|-------------|
198
- | `table` | `table_width`, `has_column_header`, `has_row_header`, `children` | Data table |
199
- | `table_row` | `cells` | Table row with cells |
200
- | `column_list` | `children` | Container for columns |
201
- | `column` | `children` | Individual column |
202
- | `divider` | None | Horizontal divider line |
203
-
204
- ### Advanced Blocks
205
-
206
- | Block Type | Properties | Description |
207
- |------------|-----------|-------------|
208
- | `synced_block` | `synced_from`, `children` | Synchronized content block |
209
- | `template` | `rich_text`, `children` | Template block |
210
- | `table_of_contents` | `color` | Auto-generated table of contents |
211
- | `child_database` | `title` | Inline database |
212
- | `child_page` | `title` | Child page reference |
213
-
214
- ## Rich Text Formatting
215
-
216
- ### Annotations
217
-
218
- ```json
219
- {
220
- "annotations": {
221
- "bold": true,
222
- "italic": false,
223
- "strikethrough": false,
224
- "underline": true,
225
- "code": false,
226
- "color": "blue"
227
- }
228
- }
229
- ```
230
-
231
- ### Colors
232
-
233
- **Text Colors**: `default`, `gray`, `brown`, `orange`, `yellow`, `green`, `blue`, `purple`, `pink`, `red`
234
-
235
- **Background Colors**: `gray_background`, `brown_background`, `orange_background`, `yellow_background`, `green_background`, `blue_background`, `purple_background`, `pink_background`, `red_background`
236
-
237
- ### Links
238
-
239
- ```json
240
- {
241
- "text": {
242
- "content": "Link text",
243
- "link": {
244
- "url": "https://example.com"
245
- }
246
- }
247
- }
248
- ```
249
-
250
- ## Error Handling
251
-
252
- The node provides comprehensive error handling:
253
-
254
- - **Credential Validation**: Automatically validates API credentials
255
- - **Input Validation**: Validates all required fields and block structures
256
- - **API Error Mapping**: Maps Notion API errors to user-friendly messages
257
- - **Graceful Degradation**: Continues processing with `continueOnFail` option
258
-
259
- ## Performance Features
260
-
261
- - **Pagination Support**: Automatically handles paginated responses
262
- - **Batch Operations**: Efficient bulk block creation and updates
263
- - **Credential Caching**: Reuses authentication across requests
264
- - **Request Optimization**: Minimizes API calls with intelligent batching
265
-
266
- ## Troubleshooting
267
-
268
- ### Common Issues
269
-
270
- 1. **Permission Errors**: Ensure your Notion integration has access to the target pages/databases
271
- 2. **Invalid Block Types**: Check that all block properties match the expected schema
272
- 3. **Rate Limiting**: The node respects Notion's rate limits automatically
273
- 4. **Large Content**: For pages with many blocks, consider using batch operations
274
-
275
- ### Debug Tips
276
-
277
- - Enable n8n's debug mode to see full API requests/responses
278
- - Validate JSON strings in block properties before sending
279
- - Test with simple blocks before adding complex formatting
280
- - Check Notion's API documentation for the latest block schemas
281
-
282
- ## API Reference
283
-
284
- This node implements Notion API version `2022-06-28`. For the most up-to-date API documentation, visit:
285
- https://developers.notion.com/reference
286
-
287
- ## Contributing
288
-
289
- Contributions are welcome! Please:
290
-
291
- 1. Fork the repository
292
- 2. Create a feature branch
293
- 3. Add tests for new functionality
294
- 4. Submit a pull request
295
-
296
- ## License
297
-
298
- MIT License - see LICENSE file for details.
299
-
300
- ## Support
301
-
302
- For issues and questions:
303
- - Check the troubleshooting section
304
- - Review Notion's API documentation
305
- - Open an issue on GitHub
306
- - Join the n8n community forum
@@ -1,3 +0,0 @@
1
- <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <path d="M4.459 4.208c.746.606 1.026.56 2.428.466l13.215-.793c.28 0 .047-.28-.046-.326L17.86 1.968c-.42-.326-.981-.7-2.055-.607L3.533 2.221c-.466.047-.56.28-.374.466l1.3.979zM5.206 6.678v14.018c0 .746.373 1.027 1.214.98l14.523-.84c.841-.046.935-.56.935-1.167V6.305c0-.607-.28-.887-.747-.84l-15.177.887c-.56.047-.748.327-.748.746v-.42zm14.337.793c.093.42 0 .84-.42.888l-.7.14v10.264c-.608.327-1.168.514-1.635.514-.748 0-.935-.234-1.495-.933l-4.577-7.186v6.952L12.21 18s0 .84-1.168.84l-3.222.186c-.093-.186 0-.653.327-.746l.84-.233V9.854L7.822 9.76c-.094-.42.14-1.026.793-1.073l3.456-.233 4.764 7.279v-6.44l-1.215-.139c-.093-.514.28-.887.747-.933l3.176-.233z" fill="currentColor"/>
3
- </svg>
package/dist/package.json DELETED
@@ -1,69 +0,0 @@
1
- {
2
- "name": "n8n-nodes-notion-advanced",
3
- "version": "1.2.12-beta",
4
- "description": "Advanced n8n Notion nodes: Full-featured workflow node + AI Agent Tool for intelligent Notion automation with 25+ block types (BETA)",
5
- "scripts": {},
6
- "files": [
7
- "nodes",
8
- "types"
9
- ],
10
- "n8n": {
11
- "n8nNodesApiVersion": 1,
12
- "nodes": [
13
- "nodes/NotionAdvanced/NotionAdvanced.node.js",
14
- "nodes/NotionAdvanced/NotionAITool.node.js"
15
- ]
16
- },
17
- "keywords": [
18
- "n8n-community-node-package",
19
- "notion",
20
- "productivity",
21
- "api",
22
- "blocks",
23
- "rich-text",
24
- "database",
25
- "pages",
26
- "automation",
27
- "workflow",
28
- "integration",
29
- "notion-api",
30
- "block-types",
31
- "formatting",
32
- "ai",
33
- "ai-agent",
34
- "ai-tool",
35
- "chatgpt",
36
- "claude",
37
- "llm",
38
- "natural-language",
39
- "intelligent-automation"
40
- ],
41
- "license": "MIT",
42
- "homepage": "https://github.com/your-username/n8n-notion-advanced-node#readme",
43
- "author": {
44
- "name": "AZ-IT.US",
45
- "email": "azuniga6290@gmail.com"
46
- },
47
- "repository": {
48
- "type": "git",
49
- "url": "https://github.com/AZ-IT-US/n8n-notion-advanced-node.git"
50
- },
51
- "engines": {
52
- "node": ">=16.10",
53
- "pnpm": ">=7.18"
54
- },
55
- "packageManager": "pnpm@7.18.0",
56
- "devDependencies": {
57
- "@types/node": "^24.1.0",
58
- "@typescript-eslint/eslint-plugin": "^8.38.0",
59
- "@typescript-eslint/parser": "^8.38.0",
60
- "copyfiles": "^2.4.1",
61
- "eslint": "^9.32.0",
62
- "eslint-plugin-n8n-nodes-base": "^1.11.0",
63
- "prettier": "^3.6.2",
64
- "typescript": "^5.1.3"
65
- },
66
- "peerDependencies": {
67
- "n8n-workflow": "^1.82.0"
68
- }
69
- }
@@ -1,15 +0,0 @@
1
- import type { RichTextObject, Block } from '../types/NotionTypes';
2
- export declare function testRichTextCreation(): void;
3
- export declare function testRichTextParsing(): void;
4
- export declare function testBlockCreation(): void;
5
- export declare function testBlockInputConversion(): void;
6
- export declare function testBlockValidation(): void;
7
- export declare function testTableCreation(): void;
8
- export declare function testComplexRichText(): void;
9
- export declare function testAllBlockTypes(): void;
10
- export declare function testTypicalWorkflow(): void;
11
- export declare function runAllTests(): void;
12
- export declare const testData: {
13
- sampleRichText: RichTextObject[];
14
- sampleBlocks: Block[];
15
- };
@@ -1,290 +0,0 @@
1
- "use strict";
2
- // Test file for Notion Advanced Node
3
- // Note: These are conceptual tests. In a real environment, you would use Jest or similar testing framework
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.testData = void 0;
6
- exports.testRichTextCreation = testRichTextCreation;
7
- exports.testRichTextParsing = testRichTextParsing;
8
- exports.testBlockCreation = testBlockCreation;
9
- exports.testBlockInputConversion = testBlockInputConversion;
10
- exports.testBlockValidation = testBlockValidation;
11
- exports.testTableCreation = testTableCreation;
12
- exports.testComplexRichText = testComplexRichText;
13
- exports.testAllBlockTypes = testAllBlockTypes;
14
- exports.testTypicalWorkflow = testTypicalWorkflow;
15
- exports.runAllTests = runAllTests;
16
- const NotionUtils_1 = require("../nodes/NotionAdvanced/NotionUtils");
17
- // Test Rich Text Creation
18
- function testRichTextCreation() {
19
- var _a, _b, _c;
20
- console.log('Testing Rich Text Creation...');
21
- // Test basic rich text
22
- const basicText = (0, NotionUtils_1.createRichText)('Hello World');
23
- console.assert(basicText.type === 'text', 'Basic text type should be text');
24
- console.assert(((_a = basicText.text) === null || _a === void 0 ? void 0 : _a.content) === 'Hello World', 'Content should match');
25
- console.assert(basicText.annotations.bold === false, 'Bold should default to false');
26
- // Test formatted rich text
27
- const formattedText = (0, NotionUtils_1.createRichText)('Bold Text', { bold: true, color: 'red' });
28
- console.assert(formattedText.annotations.bold === true, 'Bold should be true');
29
- console.assert(formattedText.annotations.color === 'red', 'Color should be red');
30
- // Test rich text with link
31
- const linkedText = (0, NotionUtils_1.createRichText)('Link Text', {}, 'https://example.com');
32
- console.assert(((_c = (_b = linkedText.text) === null || _b === void 0 ? void 0 : _b.link) === null || _c === void 0 ? void 0 : _c.url) === 'https://example.com', 'Link URL should match');
33
- console.log('✅ Rich Text Creation tests passed');
34
- }
35
- // Test Rich Text Parsing
36
- function testRichTextParsing() {
37
- var _a;
38
- console.log('Testing Rich Text Parsing...');
39
- // Test string input
40
- const stringResult = (0, NotionUtils_1.parseRichTextInput)('Simple string');
41
- console.assert(Array.isArray(stringResult), 'Should return array');
42
- console.assert(stringResult.length === 1, 'Should have one element');
43
- console.assert(((_a = stringResult[0].text) === null || _a === void 0 ? void 0 : _a.content) === 'Simple string', 'Content should match');
44
- // Test array input
45
- const arrayInput = [
46
- { text: 'First part', annotations: { bold: true } },
47
- { text: 'Second part', annotations: { italic: true } }
48
- ];
49
- const arrayResult = (0, NotionUtils_1.parseRichTextInput)(arrayInput);
50
- console.assert(arrayResult.length === 2, 'Should have two elements');
51
- // Test object input
52
- const objectInput = { text: 'Object text', annotations: { color: 'blue' } };
53
- const objectResult = (0, NotionUtils_1.parseRichTextInput)(objectInput);
54
- console.assert(objectResult.length === 1, 'Should have one element');
55
- console.log('✅ Rich Text Parsing tests passed');
56
- }
57
- // Test Block Creation
58
- function testBlockCreation() {
59
- var _a, _b;
60
- console.log('Testing Block Creation...');
61
- // Test paragraph block
62
- const paragraph = (0, NotionUtils_1.createParagraphBlock)('Test paragraph', 'blue');
63
- console.assert(paragraph.type === 'paragraph', 'Type should be paragraph');
64
- console.assert('paragraph' in paragraph && paragraph.paragraph.color === 'blue', 'Color should be blue');
65
- // Test heading blocks
66
- const h1 = (0, NotionUtils_1.createHeadingBlock)(1, 'Main Title', 'red');
67
- console.assert(h1.type === 'heading_1', 'Type should be heading_1');
68
- console.assert('heading_1' in h1 && ((_a = h1.heading_1) === null || _a === void 0 ? void 0 : _a.color) === 'red', 'Color should be red');
69
- const h2 = (0, NotionUtils_1.createHeadingBlock)(2, 'Section Title');
70
- console.assert(h2.type === 'heading_2', 'Type should be heading_2');
71
- const h3 = (0, NotionUtils_1.createHeadingBlock)(3, 'Sub Title', undefined, true);
72
- console.assert(h3.type === 'heading_3', 'Type should be heading_3');
73
- console.assert('heading_3' in h3 && ((_b = h3.heading_3) === null || _b === void 0 ? void 0 : _b.is_toggleable) === true, 'Should be toggleable');
74
- // Test code block
75
- const code = (0, NotionUtils_1.createCodeBlock)('console.log("test");', 'javascript');
76
- console.assert(code.type === 'code', 'Type should be code');
77
- console.assert('code' in code && code.code.language === 'javascript', 'Language should be javascript');
78
- console.log('✅ Block Creation tests passed');
79
- }
80
- // Test Block Input Conversion
81
- function testBlockInputConversion() {
82
- console.log('Testing Block Input Conversion...');
83
- // Test paragraph conversion
84
- const paragraphInput = {
85
- type: 'paragraph',
86
- content: 'Test content',
87
- properties: { color: 'green' }
88
- };
89
- const paragraphBlock = (0, NotionUtils_1.convertBlockInput)(paragraphInput);
90
- console.assert(paragraphBlock.type === 'paragraph', 'Type should be paragraph');
91
- // Test heading conversion
92
- const headingInput = {
93
- type: 'heading_1',
94
- content: 'Heading text',
95
- properties: { color: 'blue', isToggleable: true }
96
- };
97
- const headingBlock = (0, NotionUtils_1.convertBlockInput)(headingInput);
98
- console.assert(headingBlock.type === 'heading_1', 'Type should be heading_1');
99
- // Test code conversion
100
- const codeInput = {
101
- type: 'code',
102
- content: 'print("Hello")',
103
- properties: { language: 'python' }
104
- };
105
- const codeBlock = (0, NotionUtils_1.convertBlockInput)(codeInput);
106
- console.assert(codeBlock.type === 'code', 'Type should be code');
107
- console.assert('code' in codeBlock && codeBlock.code.language === 'python', 'Language should be python');
108
- console.log('✅ Block Input Conversion tests passed');
109
- }
110
- // Test Block Validation
111
- function testBlockValidation() {
112
- console.log('Testing Block Validation...');
113
- // Test valid paragraph
114
- const validParagraph = (0, NotionUtils_1.createParagraphBlock)('Valid content');
115
- try {
116
- (0, NotionUtils_1.validateBlock)(validParagraph);
117
- console.log('Valid paragraph passed validation');
118
- }
119
- catch (error) {
120
- console.error('Valid paragraph failed validation:', error);
121
- }
122
- // Test valid code block
123
- const validCode = (0, NotionUtils_1.createCodeBlock)('Valid code', 'javascript');
124
- try {
125
- (0, NotionUtils_1.validateBlock)(validCode);
126
- console.log('Valid code block passed validation');
127
- }
128
- catch (error) {
129
- console.error('Valid code block failed validation:', error);
130
- }
131
- console.log('✅ Block Validation tests passed');
132
- }
133
- // Test Table Creation
134
- function testTableCreation() {
135
- console.log('Testing Table Creation...');
136
- const tableData = [
137
- [[(0, NotionUtils_1.createRichText)('Header 1')], [(0, NotionUtils_1.createRichText)('Header 2')]],
138
- [[(0, NotionUtils_1.createRichText)('Cell 1')], [(0, NotionUtils_1.createRichText)('Cell 2')]],
139
- [[(0, NotionUtils_1.createRichText)('Cell 3')], [(0, NotionUtils_1.createRichText)('Cell 4')]]
140
- ];
141
- const table = (0, NotionUtils_1.createTableBlock)(2, tableData, true, false);
142
- console.assert(table.type === 'table', 'Type should be table');
143
- console.assert('table' in table && table.table.table_width === 2, 'Width should be 2');
144
- console.assert('table' in table && table.table.has_column_header === true, 'Should have column header');
145
- console.assert('table' in table && table.table.has_row_header === false, 'Should not have row header');
146
- console.log('✅ Table Creation tests passed');
147
- }
148
- // Test Complex Rich Text
149
- function testComplexRichText() {
150
- var _a, _b;
151
- console.log('Testing Complex Rich Text...');
152
- const complexRichText = [
153
- (0, NotionUtils_1.createRichText)('Normal text '),
154
- (0, NotionUtils_1.createRichText)('bold text', { bold: true }),
155
- (0, NotionUtils_1.createRichText)(' and '),
156
- (0, NotionUtils_1.createRichText)('italic blue text', { italic: true, color: 'blue' }),
157
- (0, NotionUtils_1.createRichText)(' with a ', {}),
158
- (0, NotionUtils_1.createRichText)('link', { underline: true }, 'https://example.com')
159
- ];
160
- console.assert(complexRichText.length === 6, 'Should have 6 rich text objects');
161
- console.assert(complexRichText[1].annotations.bold === true, 'Second element should be bold');
162
- console.assert(complexRichText[3].annotations.italic === true, 'Fourth element should be italic');
163
- console.assert(complexRichText[3].annotations.color === 'blue', 'Fourth element should be blue');
164
- console.assert(((_b = (_a = complexRichText[5].text) === null || _a === void 0 ? void 0 : _a.link) === null || _b === void 0 ? void 0 : _b.url) === 'https://example.com', 'Last element should have link');
165
- console.log('✅ Complex Rich Text tests passed');
166
- }
167
- // Test All Block Types
168
- function testAllBlockTypes() {
169
- console.log('Testing All Block Types...');
170
- const blockTypes = [
171
- 'paragraph', 'heading_1', 'heading_2', 'heading_3',
172
- 'bulleted_list_item', 'numbered_list_item', 'to_do',
173
- 'toggle', 'quote', 'callout', 'code', 'divider',
174
- 'equation', 'image', 'bookmark', 'embed'
175
- ];
176
- for (const blockType of blockTypes) {
177
- try {
178
- const blockInput = {
179
- type: blockType,
180
- content: 'Test content',
181
- properties: {}
182
- };
183
- // Special cases for specific block types
184
- if (blockType === 'equation') {
185
- blockInput.properties = { expression: 'E = mc^2' };
186
- }
187
- else if (['image', 'bookmark', 'embed'].includes(blockType)) {
188
- blockInput.properties = { url: 'https://example.com' };
189
- }
190
- else if (blockType === 'code') {
191
- blockInput.properties = { language: 'javascript' };
192
- }
193
- else if (blockType === 'callout') {
194
- blockInput.properties = { icon: '💡' };
195
- }
196
- const block = (0, NotionUtils_1.convertBlockInput)(blockInput);
197
- (0, NotionUtils_1.validateBlock)(block);
198
- console.log(`✓ ${blockType} block created and validated`);
199
- }
200
- catch (error) {
201
- console.error(`✗ ${blockType} block failed:`, error);
202
- }
203
- }
204
- console.log('✅ All Block Types tests completed');
205
- }
206
- // Integration test for typical workflow
207
- function testTypicalWorkflow() {
208
- console.log('Testing Typical Workflow...');
209
- // Simulate creating a documentation page
210
- const pageBlocks = [
211
- {
212
- type: 'heading_1',
213
- content: 'API Documentation',
214
- properties: { color: 'blue' }
215
- },
216
- {
217
- type: 'paragraph',
218
- content: 'This document describes the REST API endpoints.',
219
- properties: {}
220
- },
221
- {
222
- type: 'heading_2',
223
- content: 'Authentication',
224
- properties: {}
225
- },
226
- {
227
- type: 'paragraph',
228
- richText: [
229
- (0, NotionUtils_1.createRichText)('Use the '),
230
- (0, NotionUtils_1.createRichText)('Authorization', { code: true }),
231
- (0, NotionUtils_1.createRichText)(' header with your API key.')
232
- ]
233
- },
234
- {
235
- type: 'code',
236
- content: 'curl -H "Authorization: Bearer YOUR_API_KEY" https://api.example.com/users',
237
- properties: { language: 'bash' }
238
- },
239
- {
240
- type: 'callout',
241
- content: 'Keep your API key secure and never commit it to version control.',
242
- properties: { icon: '🔒', color: 'yellow_background' }
243
- }
244
- ];
245
- try {
246
- const convertedBlocks = pageBlocks.map(NotionUtils_1.convertBlockInput);
247
- convertedBlocks.forEach(NotionUtils_1.validateBlock);
248
- console.log(`✓ Successfully processed ${convertedBlocks.length} blocks for documentation page`);
249
- }
250
- catch (error) {
251
- console.error('✗ Typical workflow failed:', error);
252
- }
253
- console.log('✅ Typical Workflow test completed');
254
- }
255
- // Run all tests
256
- function runAllTests() {
257
- console.log('🧪 Running Notion Advanced Node Tests...\n');
258
- try {
259
- testRichTextCreation();
260
- testRichTextParsing();
261
- testBlockCreation();
262
- testBlockInputConversion();
263
- testBlockValidation();
264
- testTableCreation();
265
- testComplexRichText();
266
- testAllBlockTypes();
267
- testTypicalWorkflow();
268
- console.log('\n🎉 All tests completed successfully!');
269
- }
270
- catch (error) {
271
- console.error('\n❌ Tests failed:', error);
272
- }
273
- }
274
- // Export test data for external use
275
- exports.testData = {
276
- sampleRichText: [
277
- (0, NotionUtils_1.createRichText)('Normal text '),
278
- (0, NotionUtils_1.createRichText)('bold', { bold: true }),
279
- (0, NotionUtils_1.createRichText)(' and '),
280
- (0, NotionUtils_1.createRichText)('italic', { italic: true })
281
- ],
282
- sampleBlocks: [
283
- (0, NotionUtils_1.createParagraphBlock)('Sample paragraph'),
284
- (0, NotionUtils_1.createHeadingBlock)(1, 'Sample heading'),
285
- (0, NotionUtils_1.createCodeBlock)('console.log("test");', 'javascript')
286
- ]
287
- };
288
- // Export for use as module or run tests directly
289
- // Uncomment the following line to run tests when this file is executed:
290
- // runAllTests();
File without changes
File without changes