n8n-nodes-notion-advanced 1.1.25-beta → 1.1.27-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 +8 -13
- package/LICENSE +0 -21
- package/README.md +0 -306
- package/dist/package.json +0 -78
- package/dist/tests/NotionAdvanced.test.d.ts +0 -15
- package/dist/tests/NotionAdvanced.test.js +0 -290
- package/dist/types/NotionTypes.d.ts +0 -359
- package/dist/types/NotionTypes.js +0 -3
- package/dist/types/NotionTypes.ts +0 -411
- /package/{dist/NotionAdvanced → NotionAdvanced}/notion.svg +0 -0
- /package/{dist/nodes → nodes}/NotionAdvanced/NotionAITool.node.d.ts +0 -0
- /package/{dist/nodes → nodes}/NotionAdvanced/NotionAITool.node.js +0 -0
- /package/{dist/nodes → nodes}/NotionAdvanced/NotionAITool.node.ts +0 -0
- /package/{dist/nodes → nodes}/NotionAdvanced/NotionAdvanced.node.d.ts +0 -0
- /package/{dist/nodes → nodes}/NotionAdvanced/NotionAdvanced.node.js +0 -0
- /package/{dist/nodes → nodes}/NotionAdvanced/NotionAdvanced.node.ts +0 -0
- /package/{dist/nodes → nodes}/NotionAdvanced/NotionUtils.d.ts +0 -0
- /package/{dist/nodes → nodes}/NotionAdvanced/NotionUtils.js +0 -0
- /package/{dist/nodes → nodes}/NotionAdvanced/NotionUtils.ts +0 -0
- /package/{dist/nodes → nodes}/NotionAdvanced/notion.svg +0 -0
@@ -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();
|
@@ -1,359 +0,0 @@
|
|
1
|
-
export type NotionColor = 'default' | 'gray' | 'brown' | 'orange' | 'yellow' | 'green' | 'blue' | 'purple' | 'pink' | 'red' | 'gray_background' | 'brown_background' | 'orange_background' | 'yellow_background' | 'green_background' | 'blue_background' | 'purple_background' | 'pink_background' | 'red_background';
|
2
|
-
export interface RichTextAnnotations {
|
3
|
-
bold?: boolean;
|
4
|
-
italic?: boolean;
|
5
|
-
strikethrough?: boolean;
|
6
|
-
underline?: boolean;
|
7
|
-
code?: boolean;
|
8
|
-
color?: NotionColor;
|
9
|
-
}
|
10
|
-
export interface TextLink {
|
11
|
-
url: string;
|
12
|
-
}
|
13
|
-
export interface RichTextText {
|
14
|
-
content: string;
|
15
|
-
link?: TextLink | null;
|
16
|
-
}
|
17
|
-
export interface RichTextMention {
|
18
|
-
type: 'user' | 'page' | 'database' | 'date' | 'link_preview' | 'template_mention';
|
19
|
-
user?: {
|
20
|
-
id: string;
|
21
|
-
};
|
22
|
-
page?: {
|
23
|
-
id: string;
|
24
|
-
};
|
25
|
-
database?: {
|
26
|
-
id: string;
|
27
|
-
};
|
28
|
-
date?: {
|
29
|
-
start: string;
|
30
|
-
end?: string;
|
31
|
-
time_zone?: string;
|
32
|
-
};
|
33
|
-
link_preview?: {
|
34
|
-
url: string;
|
35
|
-
};
|
36
|
-
template_mention?: {
|
37
|
-
type: 'template_mention_date' | 'template_mention_user';
|
38
|
-
template_mention_date?: string;
|
39
|
-
template_mention_user?: string;
|
40
|
-
};
|
41
|
-
}
|
42
|
-
export interface RichTextEquation {
|
43
|
-
expression: string;
|
44
|
-
}
|
45
|
-
export interface RichTextObject {
|
46
|
-
type: 'text' | 'mention' | 'equation';
|
47
|
-
text?: RichTextText;
|
48
|
-
mention?: RichTextMention;
|
49
|
-
equation?: RichTextEquation;
|
50
|
-
annotations: RichTextAnnotations;
|
51
|
-
plain_text: string;
|
52
|
-
href?: string | null;
|
53
|
-
}
|
54
|
-
export interface FileObject {
|
55
|
-
type: 'external' | 'file';
|
56
|
-
external?: {
|
57
|
-
url: string;
|
58
|
-
};
|
59
|
-
file?: {
|
60
|
-
url: string;
|
61
|
-
expiry_time?: string;
|
62
|
-
};
|
63
|
-
caption?: RichTextObject[];
|
64
|
-
}
|
65
|
-
export interface EmojiObject {
|
66
|
-
type: 'emoji';
|
67
|
-
emoji: string;
|
68
|
-
}
|
69
|
-
export interface Parent {
|
70
|
-
type: 'database_id' | 'page_id' | 'workspace' | 'block_id';
|
71
|
-
database_id?: string;
|
72
|
-
page_id?: string;
|
73
|
-
workspace?: boolean;
|
74
|
-
block_id?: string;
|
75
|
-
}
|
76
|
-
export interface ParagraphBlock {
|
77
|
-
type: 'paragraph';
|
78
|
-
paragraph: {
|
79
|
-
rich_text: RichTextObject[];
|
80
|
-
color?: NotionColor;
|
81
|
-
children?: Block[];
|
82
|
-
};
|
83
|
-
}
|
84
|
-
export interface HeadingBlock {
|
85
|
-
type: 'heading_1' | 'heading_2' | 'heading_3';
|
86
|
-
heading_1?: {
|
87
|
-
rich_text: RichTextObject[];
|
88
|
-
color?: NotionColor;
|
89
|
-
is_toggleable?: boolean;
|
90
|
-
};
|
91
|
-
heading_2?: {
|
92
|
-
rich_text: RichTextObject[];
|
93
|
-
color?: NotionColor;
|
94
|
-
is_toggleable?: boolean;
|
95
|
-
};
|
96
|
-
heading_3?: {
|
97
|
-
rich_text: RichTextObject[];
|
98
|
-
color?: NotionColor;
|
99
|
-
is_toggleable?: boolean;
|
100
|
-
};
|
101
|
-
}
|
102
|
-
export interface BulletedListItemBlock {
|
103
|
-
type: 'bulleted_list_item';
|
104
|
-
bulleted_list_item: {
|
105
|
-
rich_text: RichTextObject[];
|
106
|
-
color?: NotionColor;
|
107
|
-
children?: Block[];
|
108
|
-
};
|
109
|
-
}
|
110
|
-
export interface NumberedListItemBlock {
|
111
|
-
type: 'numbered_list_item';
|
112
|
-
numbered_list_item: {
|
113
|
-
rich_text: RichTextObject[];
|
114
|
-
color?: NotionColor;
|
115
|
-
children?: Block[];
|
116
|
-
};
|
117
|
-
}
|
118
|
-
export interface ToDoBlock {
|
119
|
-
type: 'to_do';
|
120
|
-
to_do: {
|
121
|
-
rich_text: RichTextObject[];
|
122
|
-
checked?: boolean;
|
123
|
-
color?: NotionColor;
|
124
|
-
children?: Block[];
|
125
|
-
};
|
126
|
-
}
|
127
|
-
export interface ToggleBlock {
|
128
|
-
type: 'toggle';
|
129
|
-
toggle: {
|
130
|
-
rich_text: RichTextObject[];
|
131
|
-
color?: NotionColor;
|
132
|
-
children?: Block[];
|
133
|
-
};
|
134
|
-
}
|
135
|
-
export interface QuoteBlock {
|
136
|
-
type: 'quote';
|
137
|
-
quote: {
|
138
|
-
rich_text: RichTextObject[];
|
139
|
-
color?: NotionColor;
|
140
|
-
children?: Block[];
|
141
|
-
};
|
142
|
-
}
|
143
|
-
export interface CalloutBlock {
|
144
|
-
type: 'callout';
|
145
|
-
callout: {
|
146
|
-
rich_text: RichTextObject[];
|
147
|
-
icon?: EmojiObject | FileObject;
|
148
|
-
color?: NotionColor;
|
149
|
-
children?: Block[];
|
150
|
-
};
|
151
|
-
}
|
152
|
-
export interface CodeBlock {
|
153
|
-
type: 'code';
|
154
|
-
code: {
|
155
|
-
rich_text: RichTextObject[];
|
156
|
-
language?: string;
|
157
|
-
caption?: RichTextObject[];
|
158
|
-
};
|
159
|
-
}
|
160
|
-
export interface DividerBlock {
|
161
|
-
type: 'divider';
|
162
|
-
divider: Record<string, never>;
|
163
|
-
}
|
164
|
-
export interface ImageBlock {
|
165
|
-
type: 'image';
|
166
|
-
image: FileObject;
|
167
|
-
}
|
168
|
-
export interface VideoBlock {
|
169
|
-
type: 'video';
|
170
|
-
video: FileObject;
|
171
|
-
}
|
172
|
-
export interface AudioBlock {
|
173
|
-
type: 'audio';
|
174
|
-
audio: FileObject;
|
175
|
-
}
|
176
|
-
export interface FileBlock {
|
177
|
-
type: 'file';
|
178
|
-
file: FileObject;
|
179
|
-
}
|
180
|
-
export interface PdfBlock {
|
181
|
-
type: 'pdf';
|
182
|
-
pdf: FileObject;
|
183
|
-
}
|
184
|
-
export interface BookmarkBlock {
|
185
|
-
type: 'bookmark';
|
186
|
-
bookmark: {
|
187
|
-
url: string;
|
188
|
-
caption?: RichTextObject[];
|
189
|
-
};
|
190
|
-
}
|
191
|
-
export interface EmbedBlock {
|
192
|
-
type: 'embed';
|
193
|
-
embed: {
|
194
|
-
url: string;
|
195
|
-
caption?: RichTextObject[];
|
196
|
-
};
|
197
|
-
}
|
198
|
-
export interface LinkPreviewBlock {
|
199
|
-
type: 'link_preview';
|
200
|
-
link_preview: {
|
201
|
-
url: string;
|
202
|
-
};
|
203
|
-
}
|
204
|
-
export interface EquationBlock {
|
205
|
-
type: 'equation';
|
206
|
-
equation: {
|
207
|
-
expression: string;
|
208
|
-
};
|
209
|
-
}
|
210
|
-
export interface TableBlock {
|
211
|
-
type: 'table';
|
212
|
-
table: {
|
213
|
-
table_width: number;
|
214
|
-
has_column_header?: boolean;
|
215
|
-
has_row_header?: boolean;
|
216
|
-
children?: TableRowBlock[];
|
217
|
-
};
|
218
|
-
}
|
219
|
-
export interface TableRowBlock {
|
220
|
-
type: 'table_row';
|
221
|
-
table_row: {
|
222
|
-
cells: RichTextObject[][];
|
223
|
-
};
|
224
|
-
}
|
225
|
-
export interface ColumnListBlock {
|
226
|
-
type: 'column_list';
|
227
|
-
column_list: {
|
228
|
-
children?: ColumnBlock[];
|
229
|
-
};
|
230
|
-
}
|
231
|
-
export interface ColumnBlock {
|
232
|
-
type: 'column';
|
233
|
-
column: {
|
234
|
-
children?: Block[];
|
235
|
-
};
|
236
|
-
}
|
237
|
-
export interface SyncedBlock {
|
238
|
-
type: 'synced_block';
|
239
|
-
synced_block: {
|
240
|
-
synced_from?: {
|
241
|
-
type: 'block_id';
|
242
|
-
block_id: string;
|
243
|
-
} | null;
|
244
|
-
children?: Block[];
|
245
|
-
};
|
246
|
-
}
|
247
|
-
export interface TemplateBlock {
|
248
|
-
type: 'template';
|
249
|
-
template: {
|
250
|
-
rich_text: RichTextObject[];
|
251
|
-
children?: Block[];
|
252
|
-
};
|
253
|
-
}
|
254
|
-
export interface TableOfContentsBlock {
|
255
|
-
type: 'table_of_contents';
|
256
|
-
table_of_contents: {
|
257
|
-
color?: NotionColor;
|
258
|
-
};
|
259
|
-
}
|
260
|
-
export interface ChildDatabaseBlock {
|
261
|
-
type: 'child_database';
|
262
|
-
child_database: {
|
263
|
-
title: string;
|
264
|
-
};
|
265
|
-
}
|
266
|
-
export interface ChildPageBlock {
|
267
|
-
type: 'child_page';
|
268
|
-
child_page: {
|
269
|
-
title: string;
|
270
|
-
};
|
271
|
-
}
|
272
|
-
export interface BaseBlock {
|
273
|
-
object: 'block';
|
274
|
-
id: string;
|
275
|
-
parent: Parent;
|
276
|
-
created_time: string;
|
277
|
-
created_by: {
|
278
|
-
object: 'user';
|
279
|
-
id: string;
|
280
|
-
};
|
281
|
-
last_edited_time: string;
|
282
|
-
last_edited_by: {
|
283
|
-
object: 'user';
|
284
|
-
id: string;
|
285
|
-
};
|
286
|
-
archived: boolean;
|
287
|
-
has_children: boolean;
|
288
|
-
}
|
289
|
-
export type Block = ParagraphBlock | HeadingBlock | BulletedListItemBlock | NumberedListItemBlock | ToDoBlock | ToggleBlock | QuoteBlock | CalloutBlock | CodeBlock | DividerBlock | ImageBlock | VideoBlock | AudioBlock | FileBlock | PdfBlock | BookmarkBlock | EmbedBlock | LinkPreviewBlock | EquationBlock | TableBlock | TableRowBlock | ColumnListBlock | ColumnBlock | SyncedBlock | TemplateBlock | TableOfContentsBlock | ChildDatabaseBlock | ChildPageBlock;
|
290
|
-
export type BlockWithId = Block & BaseBlock;
|
291
|
-
export interface PropertyValue {
|
292
|
-
id: string;
|
293
|
-
type: string;
|
294
|
-
[key: string]: any;
|
295
|
-
}
|
296
|
-
export interface PageProperties {
|
297
|
-
[key: string]: PropertyValue;
|
298
|
-
}
|
299
|
-
export interface NotionPage {
|
300
|
-
object: 'page';
|
301
|
-
id: string;
|
302
|
-
created_time: string;
|
303
|
-
created_by: {
|
304
|
-
object: 'user';
|
305
|
-
id: string;
|
306
|
-
};
|
307
|
-
last_edited_time: string;
|
308
|
-
last_edited_by: {
|
309
|
-
object: 'user';
|
310
|
-
id: string;
|
311
|
-
};
|
312
|
-
archived: boolean;
|
313
|
-
properties: PageProperties;
|
314
|
-
parent: Parent;
|
315
|
-
url: string;
|
316
|
-
icon?: EmojiObject | FileObject | null;
|
317
|
-
cover?: FileObject | null;
|
318
|
-
}
|
319
|
-
export interface NotionApiResponse<T = any> {
|
320
|
-
object: string;
|
321
|
-
results?: T[];
|
322
|
-
next_cursor?: string | null;
|
323
|
-
has_more?: boolean;
|
324
|
-
type?: string;
|
325
|
-
[key: string]: any;
|
326
|
-
}
|
327
|
-
export interface NotionSearchResponse extends NotionApiResponse {
|
328
|
-
results: (NotionPage | any)[];
|
329
|
-
}
|
330
|
-
export interface NotionBlockChildrenResponse extends NotionApiResponse {
|
331
|
-
results: BlockWithId[];
|
332
|
-
}
|
333
|
-
export type NotionResource = 'page' | 'block' | 'database' | 'user';
|
334
|
-
export type NotionPageOperation = 'create' | 'get' | 'update' | 'archive' | 'search';
|
335
|
-
export type NotionBlockOperation = 'create' | 'get' | 'update' | 'delete' | 'getChildren' | 'append';
|
336
|
-
export type NotionDatabaseOperation = 'get' | 'query' | 'create';
|
337
|
-
export type NotionUserOperation = 'get' | 'list';
|
338
|
-
export interface NotionCredentials {
|
339
|
-
apiKey: string;
|
340
|
-
}
|
341
|
-
export interface BlockInput {
|
342
|
-
type: string;
|
343
|
-
content?: string;
|
344
|
-
richText?: RichTextObject[];
|
345
|
-
properties?: {
|
346
|
-
[key: string]: any;
|
347
|
-
};
|
348
|
-
children?: BlockInput[];
|
349
|
-
}
|
350
|
-
export interface PageInput {
|
351
|
-
title: string;
|
352
|
-
parent: string;
|
353
|
-
properties?: {
|
354
|
-
[key: string]: any;
|
355
|
-
};
|
356
|
-
children?: BlockInput[];
|
357
|
-
icon?: string;
|
358
|
-
cover?: string;
|
359
|
-
}
|