notion-mcp-server 1.0.1 → 2.4.2
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.md +383 -192
- package/build/config/index.js +3 -1
- package/build/dispatch/concurrency.js +15 -0
- package/build/dispatch/idempotency.js +38 -0
- package/build/dispatch/index.js +175 -0
- package/build/dispatch/rate-limit.js +56 -0
- package/build/dispatch/retry.js +97 -0
- package/build/index.js +1 -1
- package/build/markdown/parse.js +265 -0
- package/build/operations/blocks.js +331 -0
- package/build/operations/comments.js +191 -0
- package/build/operations/data-sources.js +85 -0
- package/build/operations/databases.js +345 -0
- package/build/operations/files.js +239 -0
- package/build/operations/index.js +19 -0
- package/build/operations/pages.js +486 -0
- package/build/operations/registry.js +16 -0
- package/build/operations/users.js +101 -0
- package/build/prompts/index.js +105 -0
- package/build/schema/blocks.js +19 -138
- package/build/schema/database.js +27 -111
- package/build/schema/emit.js +68 -0
- package/build/schema/file.js +1 -1
- package/build/schema/filter-dsl.js +333 -0
- package/build/schema/icon.js +1 -1
- package/build/schema/page-properties.js +17 -3
- package/build/schema/page.js +12 -125
- package/build/schema/refs.js +16 -0
- package/build/schema/rich-text.js +1 -1
- package/build/server/index.js +16 -3
- package/build/services/auth.js +19 -0
- package/build/services/notion.js +14 -17
- package/build/tools/index.js +119 -21
- package/build/utils/error.js +125 -86
- package/build/utils/handler.js +11 -0
- package/build/utils/learning-error.js +40 -0
- package/build/utils/notion-types.js +16 -0
- package/build/utils/paginate.js +35 -0
- package/build/utils/schema-slice.js +156 -0
- package/build/utils/slim.js +269 -0
- package/package.json +13 -7
- package/build/resources/imageList.js +0 -62
- package/build/resources/index.js +0 -1
- package/build/resources/predictionList.js +0 -43
- package/build/resources/svgList.js +0 -69
- package/build/schema/comments.js +0 -60
- package/build/schema/notion.js +0 -57
- package/build/schema/richText.js +0 -757
- package/build/schema/tools.js +0 -17
- package/build/schema/users.js +0 -39
- package/build/services/loggs.js +0 -13
- package/build/services/replicate.js +0 -23
- package/build/tools/appendBlockChildren.js +0 -25
- package/build/tools/batchAppendBlockChildren.js +0 -33
- package/build/tools/batchDeleteBlocks.js +0 -32
- package/build/tools/batchMixedOperations.js +0 -58
- package/build/tools/batchUpdateBlocks.js +0 -33
- package/build/tools/blocks.js +0 -34
- package/build/tools/comments.js +0 -81
- package/build/tools/createDatabase.js +0 -18
- package/build/tools/createPage.js +0 -18
- package/build/tools/createPrediction.js +0 -28
- package/build/tools/database.js +0 -16
- package/build/tools/deleteBlock.js +0 -24
- package/build/tools/formatRichText.js +0 -83
- package/build/tools/generateImage.js +0 -48
- package/build/tools/generateImageVariants.js +0 -105
- package/build/tools/generateMultipleImages.js +0 -60
- package/build/tools/generateSVG.js +0 -43
- package/build/tools/getPrediction.js +0 -22
- package/build/tools/pages.js +0 -22
- package/build/tools/predictionList.js +0 -30
- package/build/tools/queryDatabase.js +0 -22
- package/build/tools/retrieveBlock.js +0 -24
- package/build/tools/retrieveBlockChildren.js +0 -32
- package/build/tools/searchPage.js +0 -24
- package/build/tools/updateBlock.js +0 -25
- package/build/tools/updateDatabase.js +0 -18
- package/build/tools/updatePage.js +0 -40
- package/build/tools/updatePageProperties.js +0 -21
- package/build/tools/users.js +0 -75
- package/build/types/blocks.js +0 -12
- package/build/types/comments.js +0 -7
- package/build/types/database.js +0 -6
- package/build/types/notion.js +0 -1
- package/build/types/page.js +0 -8
- package/build/types/richText.js +0 -1
- package/build/types/tools.js +0 -1
- package/build/types/users.js +0 -6
- package/build/utils/blob.js +0 -5
- package/build/utils/image.js +0 -34
- package/build/utils/index.js +0 -1
- package/build/utils/richText.js +0 -174
- package/build/validation/blocks.js +0 -568
- package/build/validation/notion.js +0 -51
- package/build/validation/page.js +0 -262
- package/build/validation/richText.js +0 -744
- package/build/validation/tools.js +0 -16
- /package/build/{types/index.js → operations/types.js} +0 -0
package/build/utils/image.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export async function outputToBase64(output) {
|
|
2
|
-
const blob = await output.blob();
|
|
3
|
-
const buffer = Buffer.from(await blob.arrayBuffer());
|
|
4
|
-
return buffer.toString("base64");
|
|
5
|
-
}
|
|
6
|
-
export async function urlToSvg(url) {
|
|
7
|
-
try {
|
|
8
|
-
const data = await fetch(url, {
|
|
9
|
-
headers: {
|
|
10
|
-
Authorization: `Bearer ${process.env.REPLICATE_API_TOKEN}`,
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
const text = await data.text();
|
|
14
|
-
return text;
|
|
15
|
-
}
|
|
16
|
-
catch (error) {
|
|
17
|
-
throw new Error("Error fetching svg");
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export async function urlToBase64(url) {
|
|
21
|
-
try {
|
|
22
|
-
const data = await fetch(url, {
|
|
23
|
-
headers: {
|
|
24
|
-
Authorization: `Bearer ${process.env.REPLICATE_API_TOKEN}`,
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
const blob = await data.blob();
|
|
28
|
-
let buffer = Buffer.from(await blob.arrayBuffer());
|
|
29
|
-
return buffer.toString("base64");
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
throw new Error("Error fetching image");
|
|
33
|
-
}
|
|
34
|
-
}
|
package/build/utils/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./error.js";
|
package/build/utils/richText.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Default annotations for rich text
|
|
3
|
-
*/
|
|
4
|
-
const DEFAULT_ANNOTATIONS = {
|
|
5
|
-
bold: false,
|
|
6
|
-
italic: false,
|
|
7
|
-
strikethrough: false,
|
|
8
|
-
underline: false,
|
|
9
|
-
code: false,
|
|
10
|
-
color: "default",
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Creates a simple text rich text item
|
|
14
|
-
* @param content The text content
|
|
15
|
-
* @param annotations Optional annotations for styling
|
|
16
|
-
* @param link Optional URL to link the text to
|
|
17
|
-
* @returns A properly formatted text rich text item
|
|
18
|
-
*/
|
|
19
|
-
export function createTextRichText(content, annotations = DEFAULT_ANNOTATIONS, link) {
|
|
20
|
-
return {
|
|
21
|
-
type: "text",
|
|
22
|
-
text: {
|
|
23
|
-
content,
|
|
24
|
-
link: link ? { url: link } : null,
|
|
25
|
-
},
|
|
26
|
-
annotations,
|
|
27
|
-
plain_text: content,
|
|
28
|
-
href: link || null,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Creates a rich text array from a simple string
|
|
33
|
-
* @param text The text content
|
|
34
|
-
* @returns An array with a single text rich text item
|
|
35
|
-
*/
|
|
36
|
-
export function simpleRichText(text) {
|
|
37
|
-
return [createTextRichText(text)];
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Creates a user mention rich text item
|
|
41
|
-
* @param userId The ID of the user to mention
|
|
42
|
-
* @param plainText The plain text representation (usually "@User Name")
|
|
43
|
-
* @param annotations Optional annotations for styling
|
|
44
|
-
* @returns A properly formatted user mention rich text item
|
|
45
|
-
*/
|
|
46
|
-
export function createUserMention(userId, plainText, annotations = DEFAULT_ANNOTATIONS) {
|
|
47
|
-
return {
|
|
48
|
-
type: "mention",
|
|
49
|
-
mention: {
|
|
50
|
-
type: "user",
|
|
51
|
-
user: {
|
|
52
|
-
id: userId,
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
annotations,
|
|
56
|
-
plain_text: plainText,
|
|
57
|
-
href: null,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Creates a page mention rich text item
|
|
62
|
-
* @param pageId The ID of the page to mention
|
|
63
|
-
* @param plainText The plain text representation
|
|
64
|
-
* @param annotations Optional annotations for styling
|
|
65
|
-
* @returns A properly formatted page mention rich text item
|
|
66
|
-
*/
|
|
67
|
-
export function createPageMention(pageId, plainText, annotations = DEFAULT_ANNOTATIONS) {
|
|
68
|
-
return {
|
|
69
|
-
type: "mention",
|
|
70
|
-
mention: {
|
|
71
|
-
type: "page",
|
|
72
|
-
page: {
|
|
73
|
-
id: pageId,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
annotations,
|
|
77
|
-
plain_text: plainText,
|
|
78
|
-
href: null,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Creates a date mention rich text item
|
|
83
|
-
* @param start Start date as ISO string
|
|
84
|
-
* @param end Optional end date as ISO string
|
|
85
|
-
* @param plainText The plain text representation
|
|
86
|
-
* @param annotations Optional annotations for styling
|
|
87
|
-
* @returns A properly formatted date mention rich text item
|
|
88
|
-
*/
|
|
89
|
-
export function createDateMention(start, end = null, plainText, annotations = DEFAULT_ANNOTATIONS) {
|
|
90
|
-
return {
|
|
91
|
-
type: "mention",
|
|
92
|
-
mention: {
|
|
93
|
-
type: "date",
|
|
94
|
-
date: {
|
|
95
|
-
start,
|
|
96
|
-
end,
|
|
97
|
-
time_zone: null,
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
annotations,
|
|
101
|
-
plain_text: plainText,
|
|
102
|
-
href: null,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Creates an equation rich text item
|
|
107
|
-
* @param expression The LaTeX expression
|
|
108
|
-
* @param plainText The plain text representation
|
|
109
|
-
* @param annotations Optional annotations for styling
|
|
110
|
-
* @returns A properly formatted equation rich text item
|
|
111
|
-
*/
|
|
112
|
-
export function createEquation(expression, plainText, annotations = DEFAULT_ANNOTATIONS) {
|
|
113
|
-
return {
|
|
114
|
-
type: "equation",
|
|
115
|
-
equation: {
|
|
116
|
-
expression,
|
|
117
|
-
},
|
|
118
|
-
annotations,
|
|
119
|
-
plain_text: plainText,
|
|
120
|
-
href: null,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Combines multiple rich text items into a single rich text array
|
|
125
|
-
* @param items The rich text items to combine
|
|
126
|
-
* @returns A combined rich text array
|
|
127
|
-
*/
|
|
128
|
-
export function combineRichText(...items) {
|
|
129
|
-
return items;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Creates styled text with bold formatting
|
|
133
|
-
* @param content The text content
|
|
134
|
-
* @param additionalAnnotations Additional annotations to apply
|
|
135
|
-
* @param link Optional URL to link the text to
|
|
136
|
-
* @returns A text rich text item with bold formatting
|
|
137
|
-
*/
|
|
138
|
-
export function boldText(content, additionalAnnotations = {}, link) {
|
|
139
|
-
return createTextRichText(content, { ...DEFAULT_ANNOTATIONS, ...additionalAnnotations, bold: true }, link);
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Creates styled text with italic formatting
|
|
143
|
-
* @param content The text content
|
|
144
|
-
* @param additionalAnnotations Additional annotations to apply
|
|
145
|
-
* @param link Optional URL to link the text to
|
|
146
|
-
* @returns A text rich text item with italic formatting
|
|
147
|
-
*/
|
|
148
|
-
export function italicText(content, additionalAnnotations = {}, link) {
|
|
149
|
-
return createTextRichText(content, { ...DEFAULT_ANNOTATIONS, ...additionalAnnotations, italic: true }, link);
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Creates styled text with code formatting
|
|
153
|
-
* @param content The text content
|
|
154
|
-
* @param additionalAnnotations Additional annotations to apply
|
|
155
|
-
* @returns A text rich text item with code formatting
|
|
156
|
-
*/
|
|
157
|
-
export function codeText(content, additionalAnnotations = {}) {
|
|
158
|
-
return createTextRichText(content, {
|
|
159
|
-
...DEFAULT_ANNOTATIONS,
|
|
160
|
-
...additionalAnnotations,
|
|
161
|
-
code: true,
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Creates styled text with a specific color
|
|
166
|
-
* @param content The text content
|
|
167
|
-
* @param color The color to apply
|
|
168
|
-
* @param additionalAnnotations Additional annotations to apply
|
|
169
|
-
* @param link Optional URL to link the text to
|
|
170
|
-
* @returns A text rich text item with the specified color
|
|
171
|
-
*/
|
|
172
|
-
export function colorText(content, color, additionalAnnotations = {}, link) {
|
|
173
|
-
return createTextRichText(content, { ...DEFAULT_ANNOTATIONS, ...additionalAnnotations, color }, link);
|
|
174
|
-
}
|