@atikk-co-jp/notion-mcp-server 0.1.0 → 0.2.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/README.ja.md +97 -6
- package/README.md +97 -6
- package/dist/bin/cli.js +10 -10
- package/dist/src/converters/__tests__/block-to-markdown.test.d.ts +2 -0
- package/dist/src/converters/__tests__/block-to-markdown.test.d.ts.map +1 -0
- package/dist/src/converters/__tests__/block-to-markdown.test.js +611 -0
- package/dist/src/converters/__tests__/page-to-markdown.test.d.ts +2 -0
- package/dist/src/converters/__tests__/page-to-markdown.test.d.ts.map +1 -0
- package/dist/src/converters/__tests__/page-to-markdown.test.js +567 -0
- package/dist/src/converters/__tests__/rich-text-to-markdown.test.d.ts +2 -0
- package/dist/src/converters/__tests__/rich-text-to-markdown.test.d.ts.map +1 -0
- package/dist/src/converters/__tests__/rich-text-to-markdown.test.js +353 -0
- package/dist/src/converters/block-to-markdown.d.ts +38 -0
- package/dist/src/converters/block-to-markdown.d.ts.map +1 -0
- package/dist/src/converters/block-to-markdown.js +484 -0
- package/dist/src/converters/index.d.ts +9 -0
- package/dist/src/converters/index.d.ts.map +1 -0
- package/dist/src/converters/index.js +11 -0
- package/dist/src/converters/page-to-markdown.d.ts +64 -0
- package/dist/src/converters/page-to-markdown.d.ts.map +1 -0
- package/dist/src/converters/page-to-markdown.js +189 -0
- package/dist/src/converters/rich-text-to-markdown.d.ts +61 -0
- package/dist/src/converters/rich-text-to-markdown.d.ts.map +1 -0
- package/dist/src/converters/rich-text-to-markdown.js +95 -0
- package/dist/src/index.d.ts +6 -6
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -5
- package/dist/src/notion-client.d.ts +58 -15
- package/dist/src/notion-client.d.ts.map +1 -1
- package/dist/src/notion-client.js +23 -13
- package/dist/src/schemas/block.d.ts +2158 -622
- package/dist/src/schemas/block.d.ts.map +1 -1
- package/dist/src/schemas/block.js +283 -76
- package/dist/src/schemas/common.d.ts +518 -6
- package/dist/src/schemas/common.d.ts.map +1 -1
- package/dist/src/schemas/common.js +120 -42
- package/dist/src/schemas/database.d.ts +687 -0
- package/dist/src/schemas/database.d.ts.map +1 -0
- package/dist/src/schemas/database.js +264 -0
- package/dist/src/schemas/filter.d.ts +509 -3
- package/dist/src/schemas/filter.d.ts.map +1 -1
- package/dist/src/schemas/filter.js +110 -13
- package/dist/src/schemas/index.d.ts +5 -4
- package/dist/src/schemas/index.d.ts.map +1 -1
- package/dist/src/schemas/index.js +7 -5
- package/dist/src/schemas/page.d.ts +2152 -19
- package/dist/src/schemas/page.d.ts.map +1 -1
- package/dist/src/schemas/page.js +216 -22
- package/dist/src/schemas/schemas.test.d.ts +2 -0
- package/dist/src/schemas/schemas.test.d.ts.map +1 -0
- package/dist/src/schemas/schemas.test.js +418 -0
- package/dist/src/server.d.ts +2 -2
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/server.js +6 -6
- package/dist/src/tools/append-block-children.d.ts +2 -2
- package/dist/src/tools/append-block-children.d.ts.map +1 -1
- package/dist/src/tools/append-block-children.js +16 -10
- package/dist/src/tools/create-comment.d.ts +2 -2
- package/dist/src/tools/create-comment.d.ts.map +1 -1
- package/dist/src/tools/create-comment.js +15 -9
- package/dist/src/tools/create-database.d.ts +4 -0
- package/dist/src/tools/create-database.d.ts.map +1 -0
- package/dist/src/tools/create-database.js +57 -0
- package/dist/src/tools/create-page.d.ts +2 -2
- package/dist/src/tools/create-page.d.ts.map +1 -1
- package/dist/src/tools/create-page.js +22 -24
- package/dist/src/tools/get-block-children.d.ts +2 -2
- package/dist/src/tools/get-block-children.d.ts.map +1 -1
- package/dist/src/tools/get-block-children.js +39 -6
- package/dist/src/tools/index.d.ts +13 -11
- package/dist/src/tools/index.d.ts.map +1 -1
- package/dist/src/tools/index.js +13 -9
- package/dist/src/tools/query-database.d.ts +2 -2
- package/dist/src/tools/query-database.d.ts.map +1 -1
- package/dist/src/tools/query-database.js +27 -18
- package/dist/src/tools/retrieve-page.d.ts +2 -2
- package/dist/src/tools/retrieve-page.d.ts.map +1 -1
- package/dist/src/tools/retrieve-page.js +44 -4
- package/dist/src/tools/search.d.ts +2 -2
- package/dist/src/tools/search.d.ts.map +1 -1
- package/dist/src/tools/search.js +18 -12
- package/dist/src/tools/update-database.d.ts +4 -0
- package/dist/src/tools/update-database.d.ts.map +1 -0
- package/dist/src/tools/update-database.js +74 -0
- package/dist/src/tools/update-page.d.ts +2 -2
- package/dist/src/tools/update-page.d.ts.map +1 -1
- package/dist/src/tools/update-page.js +23 -18
- package/dist/src/utils/error-handler.d.ts +1 -1
- package/dist/src/utils/error-handler.d.ts.map +1 -1
- package/dist/src/utils/error-handler.js +14 -14
- package/dist/src/utils/index.d.ts +2 -2
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +2 -2
- package/dist/src/utils/response-formatter.d.ts +13 -1
- package/dist/src/utils/response-formatter.d.ts.map +1 -1
- package/dist/src/utils/response-formatter.js +46 -3
- package/package.json +11 -2
|
@@ -0,0 +1,567 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { pagePropertiesToObject, pagePropertiesToSimple, pagesToSimple, pageToSimple, } from '../page-to-markdown.js';
|
|
3
|
+
describe('pagePropertiesToObject', () => {
|
|
4
|
+
describe('text properties', () => {
|
|
5
|
+
it('converts title property', () => {
|
|
6
|
+
const properties = {
|
|
7
|
+
Name: {
|
|
8
|
+
type: 'title',
|
|
9
|
+
title: [{ type: 'text', text: { content: 'My Page' }, plain_text: 'My Page' }],
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
13
|
+
Name: 'My Page',
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
it('converts rich_text property', () => {
|
|
17
|
+
const properties = {
|
|
18
|
+
Description: {
|
|
19
|
+
type: 'rich_text',
|
|
20
|
+
rich_text: [
|
|
21
|
+
{ type: 'text', text: { content: 'Some description' }, plain_text: 'Some description' },
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
26
|
+
Description: 'Some description',
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
it('handles empty rich_text', () => {
|
|
30
|
+
const properties = {
|
|
31
|
+
Description: {
|
|
32
|
+
type: 'rich_text',
|
|
33
|
+
rich_text: [],
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
37
|
+
Description: '',
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe('number property', () => {
|
|
42
|
+
it('converts number property', () => {
|
|
43
|
+
const properties = {
|
|
44
|
+
Count: {
|
|
45
|
+
type: 'number',
|
|
46
|
+
number: 42,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
50
|
+
Count: 42,
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
it('handles null number', () => {
|
|
54
|
+
const properties = {
|
|
55
|
+
Count: {
|
|
56
|
+
type: 'number',
|
|
57
|
+
number: null,
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
61
|
+
Count: null,
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
describe('select properties', () => {
|
|
66
|
+
it('converts select property', () => {
|
|
67
|
+
const properties = {
|
|
68
|
+
Status: {
|
|
69
|
+
type: 'select',
|
|
70
|
+
select: { id: '123', name: 'Done', color: 'green' },
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
74
|
+
Status: 'Done',
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
it('handles null select', () => {
|
|
78
|
+
const properties = {
|
|
79
|
+
Status: {
|
|
80
|
+
type: 'select',
|
|
81
|
+
select: null,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
85
|
+
Status: null,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
it('converts multi_select property', () => {
|
|
89
|
+
const properties = {
|
|
90
|
+
Tags: {
|
|
91
|
+
type: 'multi_select',
|
|
92
|
+
multi_select: [
|
|
93
|
+
{ id: '1', name: 'Bug', color: 'red' },
|
|
94
|
+
{ id: '2', name: 'Feature', color: 'green' },
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
99
|
+
Tags: ['Bug', 'Feature'],
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
it('handles empty multi_select', () => {
|
|
103
|
+
const properties = {
|
|
104
|
+
Tags: {
|
|
105
|
+
type: 'multi_select',
|
|
106
|
+
multi_select: [],
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
110
|
+
Tags: [],
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
it('converts status property', () => {
|
|
114
|
+
const properties = {
|
|
115
|
+
Progress: {
|
|
116
|
+
type: 'status',
|
|
117
|
+
status: { id: '123', name: 'In Progress', color: 'blue' },
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
121
|
+
Progress: 'In Progress',
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
describe('date property', () => {
|
|
126
|
+
it('converts date property with start only', () => {
|
|
127
|
+
const properties = {
|
|
128
|
+
DueDate: {
|
|
129
|
+
type: 'date',
|
|
130
|
+
date: { start: '2024-01-15' },
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
134
|
+
DueDate: '2024-01-15',
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
it('converts date property with start and end', () => {
|
|
138
|
+
const properties = {
|
|
139
|
+
Period: {
|
|
140
|
+
type: 'date',
|
|
141
|
+
date: { start: '2024-01-01', end: '2024-01-31' },
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
145
|
+
Period: '2024-01-01 → 2024-01-31',
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
it('handles null date', () => {
|
|
149
|
+
const properties = {
|
|
150
|
+
DueDate: {
|
|
151
|
+
type: 'date',
|
|
152
|
+
date: null,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
156
|
+
DueDate: null,
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
describe('checkbox property', () => {
|
|
161
|
+
it('converts checkbox true', () => {
|
|
162
|
+
const properties = {
|
|
163
|
+
Completed: {
|
|
164
|
+
type: 'checkbox',
|
|
165
|
+
checkbox: true,
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
169
|
+
Completed: true,
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
it('converts checkbox false', () => {
|
|
173
|
+
const properties = {
|
|
174
|
+
Completed: {
|
|
175
|
+
type: 'checkbox',
|
|
176
|
+
checkbox: false,
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
180
|
+
Completed: false,
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
describe('url/email/phone properties', () => {
|
|
185
|
+
it('converts url property', () => {
|
|
186
|
+
const properties = {
|
|
187
|
+
Website: {
|
|
188
|
+
type: 'url',
|
|
189
|
+
url: 'https://example.com',
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
193
|
+
Website: 'https://example.com',
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
it('converts email property', () => {
|
|
197
|
+
const properties = {
|
|
198
|
+
Email: {
|
|
199
|
+
type: 'email',
|
|
200
|
+
email: 'test@example.com',
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
204
|
+
Email: 'test@example.com',
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
it('converts phone_number property', () => {
|
|
208
|
+
const properties = {
|
|
209
|
+
Phone: {
|
|
210
|
+
type: 'phone_number',
|
|
211
|
+
phone_number: '+1-234-567-8900',
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
215
|
+
Phone: '+1-234-567-8900',
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
describe('relation property', () => {
|
|
220
|
+
it('converts relation property', () => {
|
|
221
|
+
const properties = {
|
|
222
|
+
Related: {
|
|
223
|
+
type: 'relation',
|
|
224
|
+
relation: [{ id: 'page-1' }, { id: 'page-2' }],
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
228
|
+
Related: ['page-1', 'page-2'],
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
it('handles empty relation', () => {
|
|
232
|
+
const properties = {
|
|
233
|
+
Related: {
|
|
234
|
+
type: 'relation',
|
|
235
|
+
relation: [],
|
|
236
|
+
},
|
|
237
|
+
};
|
|
238
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
239
|
+
Related: [],
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
describe('people property', () => {
|
|
244
|
+
it('converts people property with names', () => {
|
|
245
|
+
const properties = {
|
|
246
|
+
Assignees: {
|
|
247
|
+
type: 'people',
|
|
248
|
+
people: [
|
|
249
|
+
{ id: 'user-1', name: 'John' },
|
|
250
|
+
{ id: 'user-2', name: 'Jane' },
|
|
251
|
+
],
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
255
|
+
Assignees: ['John', 'Jane'],
|
|
256
|
+
});
|
|
257
|
+
});
|
|
258
|
+
it('converts people property without names (uses id)', () => {
|
|
259
|
+
const properties = {
|
|
260
|
+
Assignees: {
|
|
261
|
+
type: 'people',
|
|
262
|
+
people: [{ id: 'user-1' }, { id: 'user-2' }],
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
266
|
+
Assignees: ['user-1', 'user-2'],
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
describe('files property', () => {
|
|
271
|
+
it('converts files property with names', () => {
|
|
272
|
+
const properties = {
|
|
273
|
+
Attachments: {
|
|
274
|
+
type: 'files',
|
|
275
|
+
files: [
|
|
276
|
+
{ name: 'doc.pdf', external: { url: 'https://example.com/doc.pdf' } },
|
|
277
|
+
{ name: 'image.png', file: { url: 'https://s3.amazonaws.com/image.png' } },
|
|
278
|
+
],
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
282
|
+
Attachments: ['doc.pdf', 'image.png'],
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
describe('time properties', () => {
|
|
287
|
+
it('converts created_time property', () => {
|
|
288
|
+
const properties = {
|
|
289
|
+
Created: {
|
|
290
|
+
type: 'created_time',
|
|
291
|
+
created_time: '2024-01-15T10:00:00.000Z',
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
295
|
+
Created: '2024-01-15T10:00:00.000Z',
|
|
296
|
+
});
|
|
297
|
+
});
|
|
298
|
+
it('converts last_edited_time property', () => {
|
|
299
|
+
const properties = {
|
|
300
|
+
Updated: {
|
|
301
|
+
type: 'last_edited_time',
|
|
302
|
+
last_edited_time: '2024-01-15T10:00:00.000Z',
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
306
|
+
Updated: '2024-01-15T10:00:00.000Z',
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
describe('formula property', () => {
|
|
311
|
+
it('converts formula string result', () => {
|
|
312
|
+
const properties = {
|
|
313
|
+
Formula: {
|
|
314
|
+
type: 'formula',
|
|
315
|
+
formula: { type: 'string', string: 'result' },
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
319
|
+
Formula: 'result',
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
it('converts formula number result', () => {
|
|
323
|
+
const properties = {
|
|
324
|
+
Formula: {
|
|
325
|
+
type: 'formula',
|
|
326
|
+
formula: { type: 'number', number: 100 },
|
|
327
|
+
},
|
|
328
|
+
};
|
|
329
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
330
|
+
Formula: 100,
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
it('converts formula boolean result', () => {
|
|
334
|
+
const properties = {
|
|
335
|
+
Formula: {
|
|
336
|
+
type: 'formula',
|
|
337
|
+
formula: { type: 'boolean', boolean: true },
|
|
338
|
+
},
|
|
339
|
+
};
|
|
340
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
341
|
+
Formula: true,
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
describe('unique_id property', () => {
|
|
346
|
+
it('converts unique_id with prefix', () => {
|
|
347
|
+
const properties = {
|
|
348
|
+
ID: {
|
|
349
|
+
type: 'unique_id',
|
|
350
|
+
unique_id: { prefix: 'TASK', number: 123 },
|
|
351
|
+
},
|
|
352
|
+
};
|
|
353
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
354
|
+
ID: 'TASK-123',
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
it('converts unique_id without prefix', () => {
|
|
358
|
+
const properties = {
|
|
359
|
+
ID: {
|
|
360
|
+
type: 'unique_id',
|
|
361
|
+
unique_id: { number: 456 },
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
expect(pagePropertiesToObject(properties)).toEqual({
|
|
365
|
+
ID: '456',
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
describe('handles undefined/null properties', () => {
|
|
370
|
+
it('handles undefined properties', () => {
|
|
371
|
+
expect(pagePropertiesToObject(undefined)).toEqual({});
|
|
372
|
+
});
|
|
373
|
+
it('handles null properties', () => {
|
|
374
|
+
expect(pagePropertiesToObject(null)).toEqual({});
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
describe('pagePropertiesToSimple', () => {
|
|
379
|
+
it('returns array with name, type, and value', () => {
|
|
380
|
+
const properties = {
|
|
381
|
+
Name: {
|
|
382
|
+
type: 'title',
|
|
383
|
+
title: [{ type: 'text', text: { content: 'Test' }, plain_text: 'Test' }],
|
|
384
|
+
},
|
|
385
|
+
Status: {
|
|
386
|
+
type: 'select',
|
|
387
|
+
select: { id: '1', name: 'Done', color: 'green' },
|
|
388
|
+
},
|
|
389
|
+
};
|
|
390
|
+
const result = pagePropertiesToSimple(properties);
|
|
391
|
+
expect(result).toHaveLength(2);
|
|
392
|
+
expect(result).toContainEqual({ name: 'Name', type: 'title', value: 'Test' });
|
|
393
|
+
expect(result).toContainEqual({ name: 'Status', type: 'select', value: 'Done' });
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
describe('pageToSimple', () => {
|
|
397
|
+
it('converts page object to simple format', () => {
|
|
398
|
+
const page = {
|
|
399
|
+
id: 'page-123',
|
|
400
|
+
url: 'https://notion.so/page-123',
|
|
401
|
+
properties: {
|
|
402
|
+
Name: {
|
|
403
|
+
type: 'title',
|
|
404
|
+
title: [{ type: 'text', text: { content: 'My Page' }, plain_text: 'My Page' }],
|
|
405
|
+
},
|
|
406
|
+
Status: {
|
|
407
|
+
type: 'select',
|
|
408
|
+
select: { id: '1', name: 'Active', color: 'green' },
|
|
409
|
+
},
|
|
410
|
+
},
|
|
411
|
+
};
|
|
412
|
+
const result = pageToSimple(page);
|
|
413
|
+
expect(result).toEqual({
|
|
414
|
+
id: 'page-123',
|
|
415
|
+
url: 'https://notion.so/page-123',
|
|
416
|
+
properties: {
|
|
417
|
+
Name: 'My Page',
|
|
418
|
+
Status: 'Active',
|
|
419
|
+
},
|
|
420
|
+
});
|
|
421
|
+
});
|
|
422
|
+
it('handles missing url', () => {
|
|
423
|
+
const page = {
|
|
424
|
+
id: 'page-123',
|
|
425
|
+
properties: {
|
|
426
|
+
Name: {
|
|
427
|
+
type: 'title',
|
|
428
|
+
title: [{ type: 'text', text: { content: 'Test' }, plain_text: 'Test' }],
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
};
|
|
432
|
+
const result = pageToSimple(page);
|
|
433
|
+
expect(result.url).toBe('');
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
describe('pagesToSimple', () => {
|
|
437
|
+
it('converts array of pages to simple format', () => {
|
|
438
|
+
const pages = [
|
|
439
|
+
{
|
|
440
|
+
id: 'page-1',
|
|
441
|
+
url: 'https://notion.so/page-1',
|
|
442
|
+
properties: {
|
|
443
|
+
Name: {
|
|
444
|
+
type: 'title',
|
|
445
|
+
title: [{ type: 'text', text: { content: 'Page 1' }, plain_text: 'Page 1' }],
|
|
446
|
+
},
|
|
447
|
+
},
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
id: 'page-2',
|
|
451
|
+
url: 'https://notion.so/page-2',
|
|
452
|
+
properties: {
|
|
453
|
+
Name: {
|
|
454
|
+
type: 'title',
|
|
455
|
+
title: [{ type: 'text', text: { content: 'Page 2' }, plain_text: 'Page 2' }],
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
},
|
|
459
|
+
];
|
|
460
|
+
const result = pagesToSimple(pages);
|
|
461
|
+
expect(result).toHaveLength(2);
|
|
462
|
+
expect(result[0]).toEqual({
|
|
463
|
+
id: 'page-1',
|
|
464
|
+
url: 'https://notion.so/page-1',
|
|
465
|
+
properties: { Name: 'Page 1' },
|
|
466
|
+
});
|
|
467
|
+
expect(result[1]).toEqual({
|
|
468
|
+
id: 'page-2',
|
|
469
|
+
url: 'https://notion.so/page-2',
|
|
470
|
+
properties: { Name: 'Page 2' },
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
it('handles empty array', () => {
|
|
474
|
+
expect(pagesToSimple([])).toEqual([]);
|
|
475
|
+
});
|
|
476
|
+
it('handles undefined input', () => {
|
|
477
|
+
expect(pagesToSimple(undefined)).toEqual([]);
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
describe('real world data', () => {
|
|
481
|
+
it('converts actual Notion page properties', () => {
|
|
482
|
+
// 実際のNotionから取得したデータ形式
|
|
483
|
+
const properties = {
|
|
484
|
+
依存チケット: {
|
|
485
|
+
id: '%3AF_%7C',
|
|
486
|
+
type: 'relation',
|
|
487
|
+
relation: [{ id: '2dea79a9-39bc-81ee-9871-da4f2ffc8ae8' }],
|
|
488
|
+
},
|
|
489
|
+
担当者: {
|
|
490
|
+
id: '%3Bgic',
|
|
491
|
+
type: 'people',
|
|
492
|
+
people: [],
|
|
493
|
+
},
|
|
494
|
+
対象パッケージ: {
|
|
495
|
+
id: '%3ByBh',
|
|
496
|
+
type: 'multi_select',
|
|
497
|
+
multi_select: [
|
|
498
|
+
{ id: '5b008554-068a-47df-9220-a619b5767128', name: 'slide-video-core', color: 'yellow' },
|
|
499
|
+
{ id: 'd1f58db1-9651-4632-83c7-fb92c451837b', name: 'その他', color: 'gray' },
|
|
500
|
+
],
|
|
501
|
+
},
|
|
502
|
+
優先度: {
|
|
503
|
+
id: 'FwQz',
|
|
504
|
+
type: 'select',
|
|
505
|
+
select: { id: '368514f6-b7ca-4a02-999f-c281b921a14a', name: 'Low', color: 'blue' },
|
|
506
|
+
},
|
|
507
|
+
ステータス: {
|
|
508
|
+
id: 'Vegg',
|
|
509
|
+
type: 'select',
|
|
510
|
+
select: { id: 'f601cd45-cfe3-43fd-b7ba-59d46b9cc564', name: '完了', color: 'green' },
|
|
511
|
+
},
|
|
512
|
+
説明: {
|
|
513
|
+
id: 'dTNj',
|
|
514
|
+
type: 'rich_text',
|
|
515
|
+
rich_text: [
|
|
516
|
+
{
|
|
517
|
+
type: 'text',
|
|
518
|
+
text: { content: 'Monorepoルール違反。', link: null },
|
|
519
|
+
annotations: {
|
|
520
|
+
bold: false,
|
|
521
|
+
italic: false,
|
|
522
|
+
strikethrough: false,
|
|
523
|
+
underline: false,
|
|
524
|
+
code: false,
|
|
525
|
+
color: 'default',
|
|
526
|
+
},
|
|
527
|
+
plain_text: 'Monorepoルール違反。',
|
|
528
|
+
href: null,
|
|
529
|
+
},
|
|
530
|
+
],
|
|
531
|
+
},
|
|
532
|
+
期限: {
|
|
533
|
+
id: 'iBLk',
|
|
534
|
+
type: 'date',
|
|
535
|
+
date: null,
|
|
536
|
+
},
|
|
537
|
+
起票日時: {
|
|
538
|
+
id: '%7DmV%3A',
|
|
539
|
+
type: 'created_time',
|
|
540
|
+
created_time: '2026-01-04T21:55:00.000Z',
|
|
541
|
+
},
|
|
542
|
+
名前: {
|
|
543
|
+
id: 'title',
|
|
544
|
+
type: 'title',
|
|
545
|
+
title: [
|
|
546
|
+
{
|
|
547
|
+
type: 'text',
|
|
548
|
+
text: { content: '冗長な main/types フィールドを削除', link: null },
|
|
549
|
+
plain_text: '冗長な main/types フィールドを削除',
|
|
550
|
+
},
|
|
551
|
+
],
|
|
552
|
+
},
|
|
553
|
+
};
|
|
554
|
+
const result = pagePropertiesToObject(properties);
|
|
555
|
+
expect(result).toEqual({
|
|
556
|
+
依存チケット: ['2dea79a9-39bc-81ee-9871-da4f2ffc8ae8'],
|
|
557
|
+
担当者: [],
|
|
558
|
+
対象パッケージ: ['slide-video-core', 'その他'],
|
|
559
|
+
優先度: 'Low',
|
|
560
|
+
ステータス: '完了',
|
|
561
|
+
説明: 'Monorepoルール違反。',
|
|
562
|
+
期限: null,
|
|
563
|
+
起票日時: '2026-01-04T21:55:00.000Z',
|
|
564
|
+
名前: '冗長な main/types フィールドを削除',
|
|
565
|
+
});
|
|
566
|
+
});
|
|
567
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text-to-markdown.test.d.ts","sourceRoot":"","sources":["../../../../src/converters/__tests__/rich-text-to-markdown.test.ts"],"names":[],"mappings":""}
|