@atikk-co-jp/notion-mcp-server 0.6.0 → 0.8.0
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/README.ja.md +1 -0
- package/README.md +20 -2
- package/dist/src/converters/__tests__/block-to-markdown.test.js +482 -111
- package/dist/src/converters/__tests__/markdown-to-blocks.test.js +116 -13
- package/dist/src/converters/__tests__/page-to-markdown.test.js +83 -70
- package/dist/src/converters/__tests__/rich-text-to-markdown.test.js +23 -26
- package/dist/src/converters/block-to-markdown.d.ts +4 -13
- package/dist/src/converters/block-to-markdown.d.ts.map +1 -1
- package/dist/src/converters/block-to-markdown.js +117 -120
- package/dist/src/converters/index.d.ts +3 -3
- package/dist/src/converters/index.d.ts.map +1 -1
- package/dist/src/converters/index.js +1 -1
- package/dist/src/converters/markdown-to-blocks.d.ts +21 -7
- package/dist/src/converters/markdown-to-blocks.d.ts.map +1 -1
- package/dist/src/converters/markdown-to-blocks.js +56 -0
- package/dist/src/converters/page-to-markdown.d.ts +5 -20
- package/dist/src/converters/page-to-markdown.d.ts.map +1 -1
- package/dist/src/converters/page-to-markdown.js +47 -37
- package/dist/src/converters/rich-text-to-markdown.d.ts +3 -47
- package/dist/src/converters/rich-text-to-markdown.d.ts.map +1 -1
- package/dist/src/converters/rich-text-to-markdown.js +15 -14
- package/dist/src/notion-client.d.ts +5 -177
- package/dist/src/notion-client.d.ts.map +1 -1
- package/dist/src/notion-client.js +6 -172
- package/dist/src/schemas/descriptions/examples.d.ts +14 -0
- package/dist/src/schemas/descriptions/examples.d.ts.map +1 -0
- package/dist/src/schemas/descriptions/examples.js +87 -0
- package/dist/src/schemas/descriptions/fields.d.ts +146 -0
- package/dist/src/schemas/descriptions/fields.d.ts.map +1 -0
- package/dist/src/schemas/descriptions/fields.js +184 -0
- package/dist/src/schemas/descriptions/index.d.ts +3 -0
- package/dist/src/schemas/descriptions/index.d.ts.map +1 -0
- package/dist/src/schemas/descriptions/index.js +2 -0
- package/dist/src/schemas/index.d.ts +1 -5
- package/dist/src/schemas/index.d.ts.map +1 -1
- package/dist/src/schemas/index.js +2 -10
- package/dist/src/tools/__tests__/context-size.test.d.ts +2 -0
- package/dist/src/tools/__tests__/context-size.test.d.ts.map +1 -0
- package/dist/src/tools/__tests__/context-size.test.js +143 -0
- package/dist/src/tools/__tests__/error-handler.test.d.ts +2 -0
- package/dist/src/tools/__tests__/error-handler.test.d.ts.map +1 -0
- package/dist/src/tools/__tests__/error-handler.test.js +125 -0
- package/dist/src/tools/append-block-children.d.ts.map +1 -1
- package/dist/src/tools/append-block-children.js +8 -5
- package/dist/src/tools/append-blocks-simple.d.ts.map +1 -1
- package/dist/src/tools/append-blocks-simple.js +9 -13
- package/dist/src/tools/archive-database.d.ts.map +1 -1
- package/dist/src/tools/archive-database.js +4 -4
- package/dist/src/tools/archive-page.d.ts.map +1 -1
- package/dist/src/tools/archive-page.js +3 -3
- package/dist/src/tools/create-comment-simple.d.ts +4 -0
- package/dist/src/tools/create-comment-simple.d.ts.map +1 -0
- package/dist/src/tools/create-comment-simple.js +51 -0
- package/dist/src/tools/create-comment.d.ts.map +1 -1
- package/dist/src/tools/create-comment.js +28 -8
- package/dist/src/tools/create-database.d.ts.map +1 -1
- package/dist/src/tools/create-database.js +19 -25
- package/dist/src/tools/create-page-simple.d.ts +1 -1
- package/dist/src/tools/create-page-simple.d.ts.map +1 -1
- package/dist/src/tools/create-page-simple.js +41 -26
- package/dist/src/tools/create-page.d.ts.map +1 -1
- package/dist/src/tools/create-page.js +11 -7
- package/dist/src/tools/delete-block.d.ts.map +1 -1
- package/dist/src/tools/delete-block.js +2 -1
- package/dist/src/tools/get-block-children.d.ts +1 -1
- package/dist/src/tools/get-block-children.d.ts.map +1 -1
- package/dist/src/tools/get-block-children.js +13 -27
- package/dist/src/tools/index.d.ts +4 -3
- package/dist/src/tools/index.d.ts.map +1 -1
- package/dist/src/tools/index.js +5 -3
- package/dist/src/tools/list-comments.d.ts +1 -1
- package/dist/src/tools/list-comments.d.ts.map +1 -1
- package/dist/src/tools/list-comments.js +11 -10
- package/dist/src/tools/list-users.d.ts.map +1 -1
- package/dist/src/tools/list-users.js +4 -3
- package/dist/src/tools/move-page.d.ts.map +1 -1
- package/dist/src/tools/move-page.js +5 -4
- package/dist/src/tools/query-data-source.d.ts +1 -1
- package/dist/src/tools/query-data-source.d.ts.map +1 -1
- package/dist/src/tools/query-data-source.js +23 -24
- package/dist/src/tools/retrieve-block.d.ts +1 -1
- package/dist/src/tools/retrieve-block.d.ts.map +1 -1
- package/dist/src/tools/retrieve-block.js +13 -10
- package/dist/src/tools/retrieve-bot-user.js +1 -1
- package/dist/src/tools/retrieve-data-source.d.ts +1 -1
- package/dist/src/tools/retrieve-data-source.d.ts.map +1 -1
- package/dist/src/tools/retrieve-data-source.js +15 -11
- package/dist/src/tools/retrieve-database.d.ts +1 -1
- package/dist/src/tools/retrieve-database.d.ts.map +1 -1
- package/dist/src/tools/retrieve-database.js +11 -6
- package/dist/src/tools/retrieve-page-property.d.ts.map +1 -1
- package/dist/src/tools/retrieve-page-property.js +7 -7
- package/dist/src/tools/retrieve-page.d.ts +1 -1
- package/dist/src/tools/retrieve-page.d.ts.map +1 -1
- package/dist/src/tools/retrieve-page.js +15 -20
- package/dist/src/tools/retrieve-user.d.ts.map +1 -1
- package/dist/src/tools/retrieve-user.js +2 -1
- package/dist/src/tools/search.d.ts.map +1 -1
- package/dist/src/tools/search.js +10 -17
- package/dist/src/tools/update-block-simple.d.ts +1 -1
- package/dist/src/tools/update-block-simple.d.ts.map +1 -1
- package/dist/src/tools/update-block-simple.js +14 -4
- package/dist/src/tools/update-block.d.ts.map +1 -1
- package/dist/src/tools/update-block.js +8 -5
- package/dist/src/tools/update-data-source.d.ts.map +1 -1
- package/dist/src/tools/update-data-source.js +8 -8
- package/dist/src/tools/update-database.d.ts.map +1 -1
- package/dist/src/tools/update-database.js +22 -32
- package/dist/src/tools/update-page.d.ts.map +1 -1
- package/dist/src/tools/update-page.js +13 -8
- package/dist/src/utils/error-handler.d.ts +20 -0
- package/dist/src/utils/error-handler.d.ts.map +1 -1
- package/dist/src/utils/error-handler.js +63 -0
- package/dist/src/utils/index.d.ts +1 -1
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +1 -1
- package/package.json +2 -1
- package/dist/src/schemas/block.d.ts +0 -3787
- package/dist/src/schemas/block.d.ts.map +0 -1
- package/dist/src/schemas/block.js +0 -402
- package/dist/src/schemas/common.d.ts +0 -638
- package/dist/src/schemas/common.d.ts.map +0 -1
- package/dist/src/schemas/common.js +0 -163
- package/dist/src/schemas/database.d.ts +0 -687
- package/dist/src/schemas/database.d.ts.map +0 -1
- package/dist/src/schemas/database.js +0 -258
- package/dist/src/schemas/filter.d.ts +0 -611
- package/dist/src/schemas/filter.d.ts.map +0 -1
- package/dist/src/schemas/filter.js +0 -222
- package/dist/src/schemas/page.d.ts +0 -2607
- package/dist/src/schemas/page.d.ts.map +0 -1
- package/dist/src/schemas/page.js +0 -328
- package/dist/src/schemas/schemas.test.d.ts +0 -2
- package/dist/src/schemas/schemas.test.d.ts.map +0 -1
- package/dist/src/schemas/schemas.test.js +0 -418
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { describe, expect, it } from 'vitest';
|
|
2
2
|
import { markdownToBlocks, parseInlineMarkdown } from '../markdown-to-blocks.js';
|
|
3
|
+
/**
|
|
4
|
+
* BlockObjectRequestから特定のプロパティにアクセスするヘルパー
|
|
5
|
+
* SDK型は discriminated union なので、直接プロパティアクセスできない
|
|
6
|
+
*/
|
|
7
|
+
const getBlockProp = (block, prop) => block[prop];
|
|
3
8
|
describe('parseInlineMarkdown', () => {
|
|
4
9
|
describe('plain text', () => {
|
|
5
10
|
it('should return plain text as single rich text item', () => {
|
|
@@ -75,7 +80,7 @@ describe('markdownToBlocks', () => {
|
|
|
75
80
|
const result = markdownToBlocks('Hello world');
|
|
76
81
|
expect(result).toHaveLength(1);
|
|
77
82
|
expect(result[0].type).toBe('paragraph');
|
|
78
|
-
expect(result[0]
|
|
83
|
+
expect(getBlockProp(result[0], 'paragraph')).toEqual({
|
|
79
84
|
rich_text: [{ type: 'text', text: { content: 'Hello world' } }],
|
|
80
85
|
});
|
|
81
86
|
});
|
|
@@ -91,7 +96,7 @@ describe('markdownToBlocks', () => {
|
|
|
91
96
|
const result = markdownToBlocks('# Heading 1');
|
|
92
97
|
expect(result).toHaveLength(1);
|
|
93
98
|
expect(result[0].type).toBe('heading_1');
|
|
94
|
-
expect(result[0]
|
|
99
|
+
expect(getBlockProp(result[0], 'heading_1')).toEqual({
|
|
95
100
|
rich_text: [{ type: 'text', text: { content: 'Heading 1' } }],
|
|
96
101
|
});
|
|
97
102
|
});
|
|
@@ -130,7 +135,7 @@ describe('markdownToBlocks', () => {
|
|
|
130
135
|
const result = markdownToBlocks('- [ ] Task');
|
|
131
136
|
expect(result).toHaveLength(1);
|
|
132
137
|
expect(result[0].type).toBe('to_do');
|
|
133
|
-
expect(result[0]
|
|
138
|
+
expect(getBlockProp(result[0], 'to_do')).toEqual({
|
|
134
139
|
rich_text: [{ type: 'text', text: { content: 'Task' } }],
|
|
135
140
|
checked: false,
|
|
136
141
|
});
|
|
@@ -139,11 +144,11 @@ describe('markdownToBlocks', () => {
|
|
|
139
144
|
const result = markdownToBlocks('- [x] Done');
|
|
140
145
|
expect(result).toHaveLength(1);
|
|
141
146
|
expect(result[0].type).toBe('to_do');
|
|
142
|
-
expect(result[0]
|
|
147
|
+
expect(getBlockProp(result[0], 'to_do').checked).toBe(true);
|
|
143
148
|
});
|
|
144
149
|
it('should handle - [X] (uppercase)', () => {
|
|
145
150
|
const result = markdownToBlocks('- [X] Done');
|
|
146
|
-
expect(result[0]
|
|
151
|
+
expect(getBlockProp(result[0], 'to_do').checked).toBe(true);
|
|
147
152
|
});
|
|
148
153
|
});
|
|
149
154
|
describe('code blocks', () => {
|
|
@@ -151,18 +156,18 @@ describe('markdownToBlocks', () => {
|
|
|
151
156
|
const result = markdownToBlocks('```\nconst x = 1\n```');
|
|
152
157
|
expect(result).toHaveLength(1);
|
|
153
158
|
expect(result[0].type).toBe('code');
|
|
154
|
-
expect(result[0]
|
|
159
|
+
expect(getBlockProp(result[0], 'code')).toEqual({
|
|
155
160
|
rich_text: [{ type: 'text', text: { content: 'const x = 1' } }],
|
|
156
161
|
language: 'plain text',
|
|
157
162
|
});
|
|
158
163
|
});
|
|
159
164
|
it('should parse language from code fence', () => {
|
|
160
165
|
const result = markdownToBlocks('```typescript\nconst x: number = 1\n```');
|
|
161
|
-
expect(result[0]
|
|
166
|
+
expect(getBlockProp(result[0], 'code').language).toBe('typescript');
|
|
162
167
|
});
|
|
163
168
|
it('should handle multi-line code', () => {
|
|
164
169
|
const result = markdownToBlocks('```js\nline1\nline2\nline3\n```');
|
|
165
|
-
const code = result[0]
|
|
170
|
+
const code = getBlockProp(result[0], 'code');
|
|
166
171
|
expect(code.rich_text[0].text.content).toBe('line1\nline2\nline3');
|
|
167
172
|
});
|
|
168
173
|
});
|
|
@@ -171,14 +176,14 @@ describe('markdownToBlocks', () => {
|
|
|
171
176
|
const result = markdownToBlocks('> This is a quote');
|
|
172
177
|
expect(result).toHaveLength(1);
|
|
173
178
|
expect(result[0].type).toBe('quote');
|
|
174
|
-
expect(result[0]
|
|
179
|
+
expect(getBlockProp(result[0], 'quote')).toEqual({
|
|
175
180
|
rich_text: [{ type: 'text', text: { content: 'This is a quote' } }],
|
|
176
181
|
});
|
|
177
182
|
});
|
|
178
183
|
it('should combine consecutive quote lines', () => {
|
|
179
184
|
const result = markdownToBlocks('> Line 1\n> Line 2');
|
|
180
185
|
expect(result).toHaveLength(1);
|
|
181
|
-
const quote = result[0]
|
|
186
|
+
const quote = getBlockProp(result[0], 'quote');
|
|
182
187
|
expect(quote.rich_text[0].text.content).toBe('Line 1\nLine 2');
|
|
183
188
|
});
|
|
184
189
|
});
|
|
@@ -187,7 +192,7 @@ describe('markdownToBlocks', () => {
|
|
|
187
192
|
const result = markdownToBlocks('---');
|
|
188
193
|
expect(result).toHaveLength(1);
|
|
189
194
|
expect(result[0].type).toBe('divider');
|
|
190
|
-
expect(result[0]
|
|
195
|
+
expect(getBlockProp(result[0], 'divider')).toEqual({});
|
|
191
196
|
});
|
|
192
197
|
it('should handle ---- (multiple dashes)', () => {
|
|
193
198
|
const result = markdownToBlocks('----');
|
|
@@ -199,7 +204,7 @@ describe('markdownToBlocks', () => {
|
|
|
199
204
|
const result = markdownToBlocks('');
|
|
200
205
|
expect(result).toHaveLength(1);
|
|
201
206
|
expect(result[0].type).toBe('image');
|
|
202
|
-
expect(result[0]
|
|
207
|
+
expect(getBlockProp(result[0], 'image')).toEqual({
|
|
203
208
|
type: 'external',
|
|
204
209
|
external: { url: 'https://example.com/image.png' },
|
|
205
210
|
caption: [{ type: 'text', text: { content: 'Alt text' } }],
|
|
@@ -207,7 +212,88 @@ describe('markdownToBlocks', () => {
|
|
|
207
212
|
});
|
|
208
213
|
it('should handle image without alt text', () => {
|
|
209
214
|
const result = markdownToBlocks('');
|
|
210
|
-
expect(result[0]
|
|
215
|
+
expect(getBlockProp(result[0], 'image').caption).toEqual([]);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
describe('tables', () => {
|
|
219
|
+
it('should convert simple table to table block', () => {
|
|
220
|
+
const markdown = `| Name | Age |
|
|
221
|
+
|------|-----|
|
|
222
|
+
| Alice | 30 |
|
|
223
|
+
| Bob | 25 |`;
|
|
224
|
+
const result = markdownToBlocks(markdown);
|
|
225
|
+
expect(result).toHaveLength(1);
|
|
226
|
+
expect(result[0].type).toBe('table');
|
|
227
|
+
const table = result[0].table;
|
|
228
|
+
expect(table.table_width).toBe(2);
|
|
229
|
+
expect(table.has_column_header).toBe(true);
|
|
230
|
+
expect(table.has_row_header).toBe(false);
|
|
231
|
+
expect(table.children).toHaveLength(3); // header + 2 data rows
|
|
232
|
+
});
|
|
233
|
+
it('should handle table without header separator', () => {
|
|
234
|
+
const markdown = `| Name | Age |
|
|
235
|
+
| Alice | 30 |
|
|
236
|
+
| Bob | 25 |`;
|
|
237
|
+
const result = markdownToBlocks(markdown);
|
|
238
|
+
expect(result).toHaveLength(1);
|
|
239
|
+
expect(result[0].type).toBe('table');
|
|
240
|
+
const table = result[0].table;
|
|
241
|
+
expect(table.has_column_header).toBe(false);
|
|
242
|
+
expect(table.children).toHaveLength(3);
|
|
243
|
+
});
|
|
244
|
+
it('should parse inline formatting in table cells', () => {
|
|
245
|
+
const markdown = `| Feature | Status |
|
|
246
|
+
|---------|--------|
|
|
247
|
+
| **Bold** | *italic* |
|
|
248
|
+
| \`code\` | [link](https://example.com) |`;
|
|
249
|
+
const result = markdownToBlocks(markdown);
|
|
250
|
+
expect(result).toHaveLength(1);
|
|
251
|
+
expect(result[0].type).toBe('table');
|
|
252
|
+
const table = result[0].table;
|
|
253
|
+
// Check first data row (index 1, after header)
|
|
254
|
+
const firstDataRow = table.children[1].table_row.cells;
|
|
255
|
+
expect(firstDataRow[0][0].text.content).toBe('Bold');
|
|
256
|
+
expect(firstDataRow[0][0].annotations?.bold).toBe(true);
|
|
257
|
+
expect(firstDataRow[1][0].text.content).toBe('italic');
|
|
258
|
+
expect(firstDataRow[1][0].annotations?.italic).toBe(true);
|
|
259
|
+
// Check second data row
|
|
260
|
+
const secondDataRow = table.children[2].table_row.cells;
|
|
261
|
+
expect(secondDataRow[0][0].text.content).toBe('code');
|
|
262
|
+
expect(secondDataRow[0][0].annotations?.code).toBe(true);
|
|
263
|
+
});
|
|
264
|
+
it('should handle table with 3+ columns', () => {
|
|
265
|
+
const markdown = `| エージェント名 | 目的 | プロンプトの特徴 |
|
|
266
|
+
|--------------|------|----------------|
|
|
267
|
+
| ResearchAgent | トピックのリサーチ | 5つの視点 |
|
|
268
|
+
| ContentAgent | コンテンツ生成 | 品質ガイドライン |`;
|
|
269
|
+
const result = markdownToBlocks(markdown);
|
|
270
|
+
expect(result).toHaveLength(1);
|
|
271
|
+
expect(result[0].type).toBe('table');
|
|
272
|
+
const table = result[0].table;
|
|
273
|
+
expect(table.table_width).toBe(3);
|
|
274
|
+
expect(table.children).toHaveLength(3); // header + 2 data rows
|
|
275
|
+
});
|
|
276
|
+
it('should handle table with alignment indicators', () => {
|
|
277
|
+
const markdown = `| Left | Center | Right |
|
|
278
|
+
|:-----|:------:|------:|
|
|
279
|
+
| L | C | R |`;
|
|
280
|
+
const result = markdownToBlocks(markdown);
|
|
281
|
+
expect(result).toHaveLength(1);
|
|
282
|
+
expect(result[0].type).toBe('table');
|
|
283
|
+
const table = result[0].table;
|
|
284
|
+
expect(table.has_column_header).toBe(true);
|
|
285
|
+
});
|
|
286
|
+
it('should handle empty cells', () => {
|
|
287
|
+
const markdown = `| A | B |
|
|
288
|
+
|---|---|
|
|
289
|
+
| | value |
|
|
290
|
+
| value | |`;
|
|
291
|
+
const result = markdownToBlocks(markdown);
|
|
292
|
+
expect(result).toHaveLength(1);
|
|
293
|
+
const table = result[0].table;
|
|
294
|
+
// Empty cells should have empty content
|
|
295
|
+
expect(table.children[1].table_row.cells[0]).toEqual([]);
|
|
296
|
+
expect(table.children[2].table_row.cells[1]).toEqual([]);
|
|
211
297
|
});
|
|
212
298
|
});
|
|
213
299
|
describe('mixed content', () => {
|
|
@@ -241,5 +327,22 @@ const x = 1
|
|
|
241
327
|
expect(result[7].type).toBe('divider');
|
|
242
328
|
expect(result[8].type).toBe('image');
|
|
243
329
|
});
|
|
330
|
+
it('should handle document with tables among other content', () => {
|
|
331
|
+
const markdown = `## エージェント一覧
|
|
332
|
+
|
|
333
|
+
以下のエージェントがあります:
|
|
334
|
+
|
|
335
|
+
| Name | Purpose |
|
|
336
|
+
|------|---------|
|
|
337
|
+
| Agent1 | Research |
|
|
338
|
+
| Agent2 | Generate |
|
|
339
|
+
|
|
340
|
+
詳細は下記を参照。`;
|
|
341
|
+
const result = markdownToBlocks(markdown);
|
|
342
|
+
expect(result[0].type).toBe('heading_2');
|
|
343
|
+
expect(result[1].type).toBe('paragraph');
|
|
344
|
+
expect(result[2].type).toBe('table');
|
|
345
|
+
expect(result[3].type).toBe('paragraph');
|
|
346
|
+
});
|
|
244
347
|
});
|
|
245
348
|
});
|