notionary 0.2.19__py3-none-any.whl → 0.2.22__py3-none-any.whl
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.
- notionary/__init__.py +8 -4
- notionary/base_notion_client.py +3 -1
- notionary/blocks/__init__.py +2 -91
- notionary/blocks/_bootstrap.py +271 -0
- notionary/blocks/audio/__init__.py +8 -2
- notionary/blocks/audio/audio_element.py +69 -106
- notionary/blocks/audio/audio_markdown_node.py +13 -5
- notionary/blocks/audio/audio_models.py +6 -55
- notionary/blocks/base_block_element.py +42 -0
- notionary/blocks/bookmark/__init__.py +9 -2
- notionary/blocks/bookmark/bookmark_element.py +49 -139
- notionary/blocks/bookmark/bookmark_markdown_node.py +19 -18
- notionary/blocks/bookmark/bookmark_models.py +15 -0
- notionary/blocks/breadcrumbs/__init__.py +17 -0
- notionary/blocks/breadcrumbs/breadcrumb_element.py +39 -0
- notionary/blocks/breadcrumbs/breadcrumb_markdown_node.py +32 -0
- notionary/blocks/breadcrumbs/breadcrumb_models.py +12 -0
- notionary/blocks/bulleted_list/__init__.py +12 -2
- notionary/blocks/bulleted_list/bulleted_list_element.py +55 -53
- notionary/blocks/bulleted_list/bulleted_list_markdown_node.py +2 -1
- notionary/blocks/bulleted_list/bulleted_list_models.py +18 -0
- notionary/blocks/callout/__init__.py +9 -2
- notionary/blocks/callout/callout_element.py +53 -86
- notionary/blocks/callout/callout_markdown_node.py +3 -1
- notionary/blocks/callout/callout_models.py +33 -0
- notionary/blocks/child_database/__init__.py +14 -0
- notionary/blocks/child_database/child_database_element.py +61 -0
- notionary/blocks/child_database/child_database_models.py +12 -0
- notionary/blocks/child_page/__init__.py +9 -0
- notionary/blocks/child_page/child_page_element.py +94 -0
- notionary/blocks/child_page/child_page_models.py +12 -0
- notionary/blocks/{shared/block_client.py → client.py} +54 -54
- notionary/blocks/code/__init__.py +6 -2
- notionary/blocks/code/code_element.py +96 -181
- notionary/blocks/code/code_markdown_node.py +64 -13
- notionary/blocks/code/code_models.py +94 -0
- notionary/blocks/column/__init__.py +25 -1
- notionary/blocks/column/column_element.py +44 -312
- notionary/blocks/column/column_list_element.py +52 -0
- notionary/blocks/column/column_list_markdown_node.py +50 -0
- notionary/blocks/column/column_markdown_node.py +59 -0
- notionary/blocks/column/column_models.py +26 -0
- notionary/blocks/divider/__init__.py +9 -2
- notionary/blocks/divider/divider_element.py +18 -49
- notionary/blocks/divider/divider_markdown_node.py +2 -1
- notionary/blocks/divider/divider_models.py +12 -0
- notionary/blocks/embed/__init__.py +9 -2
- notionary/blocks/embed/embed_element.py +65 -111
- notionary/blocks/embed/embed_markdown_node.py +3 -1
- notionary/blocks/embed/embed_models.py +14 -0
- notionary/blocks/equation/__init__.py +14 -0
- notionary/blocks/equation/equation_element.py +133 -0
- notionary/blocks/equation/equation_element_markdown_node.py +35 -0
- notionary/blocks/equation/equation_models.py +11 -0
- notionary/blocks/file/__init__.py +25 -0
- notionary/blocks/file/file_element.py +112 -0
- notionary/blocks/file/file_element_markdown_node.py +37 -0
- notionary/blocks/file/file_element_models.py +39 -0
- notionary/blocks/guards.py +22 -0
- notionary/blocks/heading/__init__.py +16 -2
- notionary/blocks/heading/heading_element.py +83 -69
- notionary/blocks/heading/heading_markdown_node.py +2 -1
- notionary/blocks/heading/heading_models.py +29 -0
- notionary/blocks/image_block/__init__.py +13 -0
- notionary/blocks/image_block/image_element.py +89 -0
- notionary/blocks/{image → image_block}/image_markdown_node.py +13 -6
- notionary/blocks/image_block/image_models.py +10 -0
- notionary/blocks/mixins/captions/__init__.py +4 -0
- notionary/blocks/mixins/captions/caption_markdown_node_mixin.py +31 -0
- notionary/blocks/mixins/captions/caption_mixin.py +92 -0
- notionary/blocks/models.py +174 -0
- notionary/blocks/numbered_list/__init__.py +12 -2
- notionary/blocks/numbered_list/numbered_list_element.py +48 -56
- notionary/blocks/numbered_list/numbered_list_markdown_node.py +3 -1
- notionary/blocks/numbered_list/numbered_list_models.py +17 -0
- notionary/blocks/paragraph/__init__.py +12 -2
- notionary/blocks/paragraph/paragraph_element.py +40 -66
- notionary/blocks/paragraph/paragraph_markdown_node.py +2 -1
- notionary/blocks/paragraph/paragraph_models.py +16 -0
- notionary/blocks/pdf/__init__.py +13 -0
- notionary/blocks/pdf/pdf_element.py +97 -0
- notionary/blocks/pdf/pdf_markdown_node.py +37 -0
- notionary/blocks/pdf/pdf_models.py +11 -0
- notionary/blocks/quote/__init__.py +11 -2
- notionary/blocks/quote/quote_element.py +45 -62
- notionary/blocks/quote/quote_markdown_node.py +6 -3
- notionary/blocks/quote/quote_models.py +18 -0
- notionary/blocks/registry/__init__.py +4 -0
- notionary/blocks/registry/block_registry.py +60 -121
- notionary/blocks/registry/block_registry_builder.py +115 -59
- notionary/blocks/rich_text/__init__.py +33 -0
- notionary/blocks/rich_text/name_to_id_resolver.py +205 -0
- notionary/blocks/rich_text/rich_text_models.py +221 -0
- notionary/blocks/rich_text/text_inline_formatter.py +456 -0
- notionary/blocks/syntax_prompt_builder.py +137 -0
- notionary/blocks/table/__init__.py +16 -2
- notionary/blocks/table/table_element.py +136 -228
- notionary/blocks/table/table_markdown_node.py +2 -1
- notionary/blocks/table/table_models.py +28 -0
- notionary/blocks/table_of_contents/__init__.py +19 -0
- notionary/blocks/table_of_contents/table_of_contents_element.py +68 -0
- notionary/blocks/table_of_contents/table_of_contents_markdown_node.py +35 -0
- notionary/blocks/table_of_contents/table_of_contents_models.py +18 -0
- notionary/blocks/todo/__init__.py +9 -2
- notionary/blocks/todo/todo_element.py +52 -92
- notionary/blocks/todo/todo_markdown_node.py +2 -1
- notionary/blocks/todo/todo_models.py +19 -0
- notionary/blocks/toggle/__init__.py +13 -3
- notionary/blocks/toggle/toggle_element.py +69 -260
- notionary/blocks/toggle/toggle_markdown_node.py +25 -15
- notionary/blocks/toggle/toggle_models.py +17 -0
- notionary/blocks/toggleable_heading/__init__.py +6 -2
- notionary/blocks/toggleable_heading/toggleable_heading_element.py +86 -241
- notionary/blocks/toggleable_heading/toggleable_heading_markdown_node.py +26 -18
- notionary/blocks/types.py +130 -0
- notionary/blocks/video/__init__.py +8 -2
- notionary/blocks/video/video_element.py +70 -141
- notionary/blocks/video/video_element_models.py +10 -0
- notionary/blocks/video/video_markdown_node.py +13 -6
- notionary/database/client.py +26 -8
- notionary/database/database.py +13 -14
- notionary/database/database_filter_builder.py +2 -2
- notionary/database/database_provider.py +5 -4
- notionary/database/models.py +337 -0
- notionary/database/notion_database.py +6 -7
- notionary/file_upload/client.py +5 -7
- notionary/file_upload/models.py +3 -2
- notionary/file_upload/notion_file_upload.py +2 -3
- notionary/markdown/markdown_builder.py +729 -0
- notionary/markdown/markdown_document_model.py +228 -0
- notionary/{blocks → markdown}/markdown_node.py +1 -0
- notionary/models/notion_database_response.py +0 -338
- notionary/page/client.py +34 -15
- notionary/page/models.py +327 -0
- notionary/page/notion_page.py +136 -58
- notionary/page/{content/page_content_writer.py → page_content_deleting_service.py} +25 -59
- notionary/page/page_content_writer.py +177 -0
- notionary/page/page_context.py +65 -0
- notionary/page/reader/handler/__init__.py +19 -0
- notionary/page/reader/handler/base_block_renderer.py +44 -0
- notionary/page/reader/handler/block_processing_context.py +35 -0
- notionary/page/reader/handler/block_rendering_context.py +48 -0
- notionary/page/reader/handler/column_list_renderer.py +51 -0
- notionary/page/reader/handler/column_renderer.py +60 -0
- notionary/page/reader/handler/line_renderer.py +73 -0
- notionary/page/reader/handler/numbered_list_renderer.py +85 -0
- notionary/page/reader/handler/toggle_renderer.py +69 -0
- notionary/page/reader/handler/toggleable_heading_renderer.py +89 -0
- notionary/page/reader/page_content_retriever.py +81 -0
- notionary/page/search_filter_builder.py +2 -1
- notionary/page/writer/handler/__init__.py +24 -0
- notionary/page/writer/handler/code_handler.py +72 -0
- notionary/page/writer/handler/column_handler.py +141 -0
- notionary/page/writer/handler/column_list_handler.py +139 -0
- notionary/page/writer/handler/equation_handler.py +74 -0
- notionary/page/writer/handler/line_handler.py +35 -0
- notionary/page/writer/handler/line_processing_context.py +54 -0
- notionary/page/writer/handler/regular_line_handler.py +86 -0
- notionary/page/writer/handler/table_handler.py +66 -0
- notionary/page/writer/handler/toggle_handler.py +155 -0
- notionary/page/writer/handler/toggleable_heading_handler.py +173 -0
- notionary/page/writer/markdown_to_notion_converter.py +95 -0
- notionary/page/writer/markdown_to_notion_converter_context.py +30 -0
- notionary/page/writer/markdown_to_notion_formatting_post_processor.py +73 -0
- notionary/page/writer/notion_text_length_processor.py +150 -0
- notionary/telemetry/__init__.py +2 -2
- notionary/telemetry/service.py +3 -3
- notionary/user/__init__.py +2 -2
- notionary/user/base_notion_user.py +2 -1
- notionary/user/client.py +2 -3
- notionary/user/models.py +1 -0
- notionary/user/notion_bot_user.py +4 -5
- notionary/user/notion_user.py +3 -4
- notionary/user/notion_user_manager.py +23 -95
- notionary/util/__init__.py +3 -2
- notionary/util/fuzzy.py +2 -1
- notionary/util/logging_mixin.py +2 -2
- notionary/util/singleton_metaclass.py +1 -1
- notionary/workspace.py +6 -5
- notionary-0.2.22.dist-info/METADATA +237 -0
- notionary-0.2.22.dist-info/RECORD +200 -0
- notionary/blocks/document/__init__.py +0 -7
- notionary/blocks/document/document_element.py +0 -102
- notionary/blocks/document/document_markdown_node.py +0 -31
- notionary/blocks/image/__init__.py +0 -7
- notionary/blocks/image/image_element.py +0 -151
- notionary/blocks/markdown_builder.py +0 -356
- notionary/blocks/mention/__init__.py +0 -7
- notionary/blocks/mention/mention_element.py +0 -229
- notionary/blocks/mention/mention_markdown_node.py +0 -38
- notionary/blocks/prompts/element_prompt_builder.py +0 -83
- notionary/blocks/prompts/element_prompt_content.py +0 -41
- notionary/blocks/shared/models.py +0 -713
- notionary/blocks/shared/notion_block_element.py +0 -37
- notionary/blocks/shared/text_inline_formatter.py +0 -262
- notionary/blocks/shared/text_inline_formatter_new.py +0 -139
- notionary/database/models/page_result.py +0 -10
- notionary/models/notion_block_response.py +0 -264
- notionary/models/notion_page_response.py +0 -78
- notionary/models/search_response.py +0 -0
- notionary/page/__init__.py +0 -0
- notionary/page/content/markdown_whitespace_processor.py +0 -80
- notionary/page/content/notion_text_length_utils.py +0 -87
- notionary/page/content/page_content_retriever.py +0 -60
- notionary/page/formatting/line_processor.py +0 -153
- notionary/page/formatting/markdown_to_notion_converter.py +0 -153
- notionary/page/markdown_syntax_prompt_generator.py +0 -114
- notionary/page/notion_to_markdown_converter.py +0 -179
- notionary/page/properites/property_value_extractor.py +0 -0
- notionary/user/notion_user_provider.py +0 -1
- notionary-0.2.19.dist-info/METADATA +0 -225
- notionary-0.2.19.dist-info/RECORD +0 -150
- /notionary/{blocks/document/document_models.py → markdown/___init__.py} +0 -0
- /notionary/{blocks/image/image_models.py → markdown/makdown_document_model.py} +0 -0
- /notionary/{blocks/mention/mention_models.py → page/reader/handler/equation_renderer.py} +0 -0
- /notionary/{blocks/shared/__init__.py → page/writer/markdown_to_notion_post_processor.py} +0 -0
- /notionary/{blocks/toggleable_heading/toggleable_heading_models.py → page/writer/markdown_to_notion_text_length_post_processor.py} +0 -0
- /notionary/{elements/__init__.py → util/concurrency_limiter.py} +0 -0
- {notionary-0.2.19.dist-info → notionary-0.2.22.dist-info}/LICENSE +0 -0
- {notionary-0.2.19.dist-info → notionary-0.2.22.dist-info}/WHEEL +0 -0
@@ -1,713 +0,0 @@
|
|
1
|
-
from __future__ import annotations
|
2
|
-
|
3
|
-
from dataclasses import dataclass
|
4
|
-
from typing import Literal, Optional, Union, Any, Dict
|
5
|
-
from pydantic import BaseModel
|
6
|
-
|
7
|
-
|
8
|
-
# ============================================================================
|
9
|
-
# ENUMS AND COMMON TYPES
|
10
|
-
# ============================================================================
|
11
|
-
|
12
|
-
BlockColor = Literal[
|
13
|
-
"blue",
|
14
|
-
"blue_background",
|
15
|
-
"brown",
|
16
|
-
"brown_background",
|
17
|
-
"default",
|
18
|
-
"gray",
|
19
|
-
"gray_background",
|
20
|
-
"green",
|
21
|
-
"green_background",
|
22
|
-
"orange",
|
23
|
-
"orange_background",
|
24
|
-
"yellow",
|
25
|
-
"yellow_background",
|
26
|
-
"pink",
|
27
|
-
"pink_background",
|
28
|
-
"purple",
|
29
|
-
"purple_background",
|
30
|
-
"red",
|
31
|
-
"red_background",
|
32
|
-
"default_background"
|
33
|
-
]
|
34
|
-
|
35
|
-
BlockType = Literal[
|
36
|
-
"bookmark",
|
37
|
-
"breadcrumb",
|
38
|
-
"bulleted_list_item",
|
39
|
-
"callout",
|
40
|
-
"child_database",
|
41
|
-
"child_page",
|
42
|
-
"column",
|
43
|
-
"column_list",
|
44
|
-
"code",
|
45
|
-
"divider",
|
46
|
-
"embed",
|
47
|
-
"equation",
|
48
|
-
"file",
|
49
|
-
"heading_1",
|
50
|
-
"heading_2",
|
51
|
-
"heading_3",
|
52
|
-
"image",
|
53
|
-
"link_preview",
|
54
|
-
"link_to_page",
|
55
|
-
"numbered_list_item",
|
56
|
-
"paragraph",
|
57
|
-
"pdf",
|
58
|
-
"quote",
|
59
|
-
"synced_block",
|
60
|
-
"table",
|
61
|
-
"table_of_contents",
|
62
|
-
"table_row",
|
63
|
-
"template",
|
64
|
-
"to_do",
|
65
|
-
"toggle",
|
66
|
-
"unsupported",
|
67
|
-
"video",
|
68
|
-
"audio",
|
69
|
-
]
|
70
|
-
|
71
|
-
CodeLanguage = Literal[
|
72
|
-
"abap",
|
73
|
-
"arduino",
|
74
|
-
"bash",
|
75
|
-
"basic",
|
76
|
-
"c",
|
77
|
-
"clojure",
|
78
|
-
"coffeescript",
|
79
|
-
"c++",
|
80
|
-
"c#",
|
81
|
-
"css",
|
82
|
-
"dart",
|
83
|
-
"diff",
|
84
|
-
"docker",
|
85
|
-
"elixir",
|
86
|
-
"elm",
|
87
|
-
"erlang",
|
88
|
-
"flow",
|
89
|
-
"fortran",
|
90
|
-
"f#",
|
91
|
-
"gherkin",
|
92
|
-
"glsl",
|
93
|
-
"go",
|
94
|
-
"graphql",
|
95
|
-
"groovy",
|
96
|
-
"haskell",
|
97
|
-
"html",
|
98
|
-
"java",
|
99
|
-
"javascript",
|
100
|
-
"json",
|
101
|
-
"julia",
|
102
|
-
"kotlin",
|
103
|
-
"latex",
|
104
|
-
"less",
|
105
|
-
"lisp",
|
106
|
-
"livescript",
|
107
|
-
"lua",
|
108
|
-
"makefile",
|
109
|
-
"markdown",
|
110
|
-
"markup",
|
111
|
-
"matlab",
|
112
|
-
"mermaid",
|
113
|
-
"nix",
|
114
|
-
"objective-c",
|
115
|
-
"ocaml",
|
116
|
-
"pascal",
|
117
|
-
"perl",
|
118
|
-
"php",
|
119
|
-
"plain text",
|
120
|
-
"powershell",
|
121
|
-
"prolog",
|
122
|
-
"protobuf",
|
123
|
-
"python",
|
124
|
-
"r",
|
125
|
-
"reason",
|
126
|
-
"ruby",
|
127
|
-
"rust",
|
128
|
-
"sass",
|
129
|
-
"scala",
|
130
|
-
"scheme",
|
131
|
-
"scss",
|
132
|
-
"shell",
|
133
|
-
"sql",
|
134
|
-
"swift",
|
135
|
-
"typescript",
|
136
|
-
"vb.net",
|
137
|
-
"verilog",
|
138
|
-
"vhdl",
|
139
|
-
"visual basic",
|
140
|
-
"webassembly",
|
141
|
-
"xml",
|
142
|
-
"yaml",
|
143
|
-
"java/c/c++/c#",
|
144
|
-
]
|
145
|
-
|
146
|
-
|
147
|
-
# ============================================================================
|
148
|
-
# RICH TEXT AND COMMON OBJECTS
|
149
|
-
# ============================================================================
|
150
|
-
|
151
|
-
|
152
|
-
class TextAnnotations(BaseModel):
|
153
|
-
bold: bool = False
|
154
|
-
italic: bool = False
|
155
|
-
strikethrough: bool = False
|
156
|
-
underline: bool = False
|
157
|
-
code: bool = False
|
158
|
-
color: BlockColor = "default"
|
159
|
-
|
160
|
-
|
161
|
-
class TextContent(BaseModel):
|
162
|
-
content: str
|
163
|
-
link: Optional[Dict[str, str]] = None
|
164
|
-
|
165
|
-
|
166
|
-
class TextObject(BaseModel):
|
167
|
-
type: Literal["text"]
|
168
|
-
text: TextContent
|
169
|
-
annotations: TextAnnotations = TextAnnotations()
|
170
|
-
plain_text: str
|
171
|
-
href: Optional[str] = None
|
172
|
-
|
173
|
-
|
174
|
-
class MentionDate(BaseModel):
|
175
|
-
start: str
|
176
|
-
end: Optional[str] = None
|
177
|
-
time_zone: Optional[str] = None
|
178
|
-
|
179
|
-
|
180
|
-
class MentionUser(BaseModel):
|
181
|
-
id: str
|
182
|
-
object: Literal["user"] = "user"
|
183
|
-
|
184
|
-
|
185
|
-
class MentionPage(BaseModel):
|
186
|
-
id: str
|
187
|
-
|
188
|
-
|
189
|
-
class MentionDatabase(BaseModel):
|
190
|
-
id: str
|
191
|
-
|
192
|
-
|
193
|
-
class MentionObject(BaseModel):
|
194
|
-
type: Literal[
|
195
|
-
"user", "page", "database", "date", "link_preview", "template_mention"
|
196
|
-
]
|
197
|
-
user: Optional[MentionUser] = None
|
198
|
-
page: Optional[MentionPage] = None
|
199
|
-
database: Optional[MentionDatabase] = None
|
200
|
-
date: Optional[MentionDate] = None
|
201
|
-
# Add other mention types as needed
|
202
|
-
|
203
|
-
|
204
|
-
class TextAnnotations(BaseModel):
|
205
|
-
"""Text formatting annotations"""
|
206
|
-
|
207
|
-
bold: bool = False
|
208
|
-
italic: bool = False
|
209
|
-
strikethrough: bool = False
|
210
|
-
underline: bool = False
|
211
|
-
code: bool = False
|
212
|
-
color: str = "default"
|
213
|
-
|
214
|
-
|
215
|
-
class TextContent(BaseModel):
|
216
|
-
"""Text content with optional link"""
|
217
|
-
|
218
|
-
content: str
|
219
|
-
link: Optional[str] = None
|
220
|
-
|
221
|
-
|
222
|
-
class TextAnnotations(BaseModel):
|
223
|
-
bold: bool = False
|
224
|
-
italic: bool = False
|
225
|
-
strikethrough: bool = False
|
226
|
-
underline: bool = False
|
227
|
-
code: bool = False
|
228
|
-
color: str = "default"
|
229
|
-
|
230
|
-
|
231
|
-
class TextContent(BaseModel):
|
232
|
-
content: str
|
233
|
-
link: Optional[str] = None
|
234
|
-
|
235
|
-
|
236
|
-
class RichTextObject(BaseModel):
|
237
|
-
type: str = "text"
|
238
|
-
text: TextContent
|
239
|
-
annotations: TextAnnotations
|
240
|
-
plain_text: str
|
241
|
-
href: Optional[str] = None
|
242
|
-
|
243
|
-
@classmethod
|
244
|
-
def from_plain_text(cls, content: str, **kwargs) -> RichTextObject:
|
245
|
-
"""Create rich text object from plain text with optional formatting."""
|
246
|
-
annotations = TextAnnotations(**kwargs)
|
247
|
-
text_content = TextContent(content=content, link=None)
|
248
|
-
|
249
|
-
return cls(
|
250
|
-
text=text_content, annotations=annotations, plain_text=content, href=None
|
251
|
-
)
|
252
|
-
|
253
|
-
|
254
|
-
class PageMention(BaseModel):
|
255
|
-
id: str
|
256
|
-
|
257
|
-
|
258
|
-
class MentionContent(BaseModel):
|
259
|
-
type: Literal["page"] = "page"
|
260
|
-
page: PageMention
|
261
|
-
|
262
|
-
|
263
|
-
class MentionRichText(BaseModel):
|
264
|
-
type: Literal["mention"] = "mention"
|
265
|
-
mention: MentionContent
|
266
|
-
annotations: TextAnnotations
|
267
|
-
plain_text: str
|
268
|
-
href: Optional[str] = None
|
269
|
-
|
270
|
-
@classmethod
|
271
|
-
def from_page_id(cls, page_id: str) -> MentionRichText:
|
272
|
-
page_mention = PageMention(id=page_id)
|
273
|
-
mention_content = MentionContent(page=page_mention)
|
274
|
-
return cls(
|
275
|
-
mention=mention_content,
|
276
|
-
annotations=TextAnnotations(),
|
277
|
-
plain_text=f"@{page_id}",
|
278
|
-
href=None,
|
279
|
-
)
|
280
|
-
|
281
|
-
|
282
|
-
# ============================================================================
|
283
|
-
# FILE OBJECTS
|
284
|
-
# ============================================================================
|
285
|
-
|
286
|
-
|
287
|
-
class ExternalFile(BaseModel):
|
288
|
-
url: str
|
289
|
-
|
290
|
-
|
291
|
-
class NotionHostedFile(BaseModel):
|
292
|
-
url: str
|
293
|
-
expiry_time: str
|
294
|
-
|
295
|
-
|
296
|
-
class FileUploadFile(BaseModel):
|
297
|
-
id: str
|
298
|
-
|
299
|
-
|
300
|
-
class FileObject(BaseModel):
|
301
|
-
type: Literal["external", "file", "file_upload"]
|
302
|
-
external: Optional[ExternalFile] = None
|
303
|
-
file: Optional[NotionHostedFile] = None
|
304
|
-
file_upload: Optional[FileUploadFile] = None
|
305
|
-
caption: Optional[list[RichTextObject]] = None
|
306
|
-
name: Optional[str] = None
|
307
|
-
|
308
|
-
|
309
|
-
# ============================================================================
|
310
|
-
# EMOJI AND ICON OBJECTS
|
311
|
-
# ============================================================================
|
312
|
-
|
313
|
-
|
314
|
-
class EmojiIcon(BaseModel):
|
315
|
-
type: Literal["emoji"] = "emoji"
|
316
|
-
emoji: str
|
317
|
-
|
318
|
-
|
319
|
-
class FileIcon(BaseModel):
|
320
|
-
type: Literal["file"] = "file"
|
321
|
-
file: FileObject
|
322
|
-
|
323
|
-
|
324
|
-
IconObject = Union[EmojiIcon, FileIcon]
|
325
|
-
|
326
|
-
|
327
|
-
# ============================================================================
|
328
|
-
# PARENT OBJECTS
|
329
|
-
# ============================================================================
|
330
|
-
|
331
|
-
|
332
|
-
class PageParent(BaseModel):
|
333
|
-
type: Literal["page_id"]
|
334
|
-
page_id: str
|
335
|
-
|
336
|
-
|
337
|
-
class DatabaseParent(BaseModel):
|
338
|
-
type: Literal["database_id"]
|
339
|
-
database_id: str
|
340
|
-
|
341
|
-
|
342
|
-
class BlockParent(BaseModel):
|
343
|
-
type: Literal["block_id"]
|
344
|
-
block_id: str
|
345
|
-
|
346
|
-
|
347
|
-
class WorkspaceParent(BaseModel):
|
348
|
-
type: Literal["workspace"]
|
349
|
-
workspace: bool = True
|
350
|
-
|
351
|
-
|
352
|
-
ParentObject = Union[PageParent, DatabaseParent, BlockParent, WorkspaceParent]
|
353
|
-
|
354
|
-
|
355
|
-
# ============================================================================
|
356
|
-
# USER OBJECTS
|
357
|
-
# ============================================================================
|
358
|
-
|
359
|
-
|
360
|
-
class PartialUser(BaseModel):
|
361
|
-
object: Literal["user"]
|
362
|
-
id: str
|
363
|
-
|
364
|
-
|
365
|
-
# ============================================================================
|
366
|
-
# BLOCK TYPE OBJECTS
|
367
|
-
# ============================================================================
|
368
|
-
|
369
|
-
|
370
|
-
class ExternalUrl(BaseModel):
|
371
|
-
url: str
|
372
|
-
|
373
|
-
|
374
|
-
class AudioContent(BaseModel):
|
375
|
-
type: Literal["external"]
|
376
|
-
external: ExternalUrl
|
377
|
-
caption: Optional[list[RichTextObject]] = None
|
378
|
-
|
379
|
-
|
380
|
-
class AudioBlockCreate(BaseModel):
|
381
|
-
type: Literal["audio"]
|
382
|
-
audio: AudioContent
|
383
|
-
|
384
|
-
|
385
|
-
class AudioBlock(BaseModel):
|
386
|
-
type: Literal["external", "file", "file_upload"]
|
387
|
-
external: Optional[ExternalFile] = None
|
388
|
-
file: Optional[NotionHostedFile] = None
|
389
|
-
file_upload: Optional[FileUploadFile] = None
|
390
|
-
|
391
|
-
|
392
|
-
class BookmarkBlock(BaseModel):
|
393
|
-
caption: list[RichTextObject] = []
|
394
|
-
url: str
|
395
|
-
|
396
|
-
|
397
|
-
class BreadcrumbBlock(BaseModel):
|
398
|
-
pass
|
399
|
-
|
400
|
-
|
401
|
-
class BulletedListItemBlock(BaseModel):
|
402
|
-
rich_text: list[RichTextObject]
|
403
|
-
color: BlockColor = "default"
|
404
|
-
children: Optional[list["Block"]] = None
|
405
|
-
|
406
|
-
|
407
|
-
class CalloutBlock(BaseModel):
|
408
|
-
rich_text: list[RichTextObject]
|
409
|
-
icon: Optional[IconObject] = None
|
410
|
-
color: BlockColor = "default"
|
411
|
-
children: Optional[list["Block"]] = None
|
412
|
-
|
413
|
-
|
414
|
-
class ChildDatabaseBlock(BaseModel):
|
415
|
-
title: str
|
416
|
-
|
417
|
-
|
418
|
-
class ChildPageBlock(BaseModel):
|
419
|
-
title: str
|
420
|
-
|
421
|
-
|
422
|
-
class CodeBlock(BaseModel):
|
423
|
-
caption: list[RichTextObject] = []
|
424
|
-
rich_text: list[RichTextObject]
|
425
|
-
language: CodeLanguage = "plain text"
|
426
|
-
|
427
|
-
|
428
|
-
class ColumnListBlock(BaseModel):
|
429
|
-
pass
|
430
|
-
|
431
|
-
|
432
|
-
class ColumnBlock(BaseModel):
|
433
|
-
width_ratio: Optional[float] = None
|
434
|
-
|
435
|
-
|
436
|
-
class DividerBlock(BaseModel):
|
437
|
-
pass
|
438
|
-
|
439
|
-
|
440
|
-
class EmbedBlock(BaseModel):
|
441
|
-
url: str
|
442
|
-
|
443
|
-
|
444
|
-
class EquationBlock(BaseModel):
|
445
|
-
expression: str
|
446
|
-
|
447
|
-
|
448
|
-
class FileBlock(BaseModel):
|
449
|
-
caption: list[RichTextObject] = []
|
450
|
-
type: Literal["external", "file", "file_upload"]
|
451
|
-
external: Optional[ExternalFile] = None
|
452
|
-
file: Optional[NotionHostedFile] = None
|
453
|
-
file_upload: Optional[FileUploadFile] = None
|
454
|
-
name: Optional[str] = None
|
455
|
-
|
456
|
-
|
457
|
-
class HeadingBlock(BaseModel):
|
458
|
-
rich_text: list[RichTextObject]
|
459
|
-
color: BlockColor = "default"
|
460
|
-
is_toggleable: bool = False
|
461
|
-
children: Optional[list["Block"]] = None
|
462
|
-
|
463
|
-
|
464
|
-
class ImageBlock(BaseModel):
|
465
|
-
type: Literal["external", "file", "file_upload"]
|
466
|
-
external: Optional[ExternalFile] = None
|
467
|
-
file: Optional[NotionHostedFile] = None
|
468
|
-
file_upload: Optional[FileUploadFile] = None
|
469
|
-
caption: Optional[list[RichTextObject]] = None
|
470
|
-
|
471
|
-
|
472
|
-
class LinkPreviewBlock(BaseModel):
|
473
|
-
url: str
|
474
|
-
|
475
|
-
|
476
|
-
class LinkToPageBlock(BaseModel):
|
477
|
-
type: Literal["page_id", "database_id"]
|
478
|
-
page_id: Optional[str] = None
|
479
|
-
database_id: Optional[str] = None
|
480
|
-
|
481
|
-
|
482
|
-
class NumberedListItemBlock(BaseModel):
|
483
|
-
rich_text: list[RichTextObject]
|
484
|
-
color: BlockColor = "default"
|
485
|
-
children: Optional[list["Block"]] = None
|
486
|
-
|
487
|
-
|
488
|
-
class ParagraphBlock(BaseModel):
|
489
|
-
rich_text: list[RichTextObject]
|
490
|
-
color: BlockColor = "default"
|
491
|
-
children: Optional[list["Block"]] = None
|
492
|
-
|
493
|
-
|
494
|
-
class PdfBlock(BaseModel):
|
495
|
-
caption: list[RichTextObject] = []
|
496
|
-
type: Literal["external", "file", "file_upload"]
|
497
|
-
external: Optional[ExternalFile] = None
|
498
|
-
file: Optional[NotionHostedFile] = None
|
499
|
-
file_upload: Optional[FileUploadFile] = None
|
500
|
-
|
501
|
-
|
502
|
-
class QuoteBlock(BaseModel):
|
503
|
-
rich_text: list[RichTextObject]
|
504
|
-
color: BlockColor = "default"
|
505
|
-
children: Optional[list["Block"]] = None
|
506
|
-
|
507
|
-
|
508
|
-
class SyncedFromObject(BaseModel):
|
509
|
-
type: Literal["block_id"]
|
510
|
-
block_id: str
|
511
|
-
|
512
|
-
|
513
|
-
class SyncedBlock(BaseModel):
|
514
|
-
synced_from: Optional[SyncedFromObject] = (
|
515
|
-
None # None for original, object for duplicate
|
516
|
-
)
|
517
|
-
children: Optional[list["Block"]] = None
|
518
|
-
|
519
|
-
|
520
|
-
class TableBlock(BaseModel):
|
521
|
-
table_width: int
|
522
|
-
has_column_header: bool = False
|
523
|
-
has_row_header: bool = False
|
524
|
-
|
525
|
-
|
526
|
-
class TableRowBlock(BaseModel):
|
527
|
-
cells: list[list[RichTextObject]]
|
528
|
-
|
529
|
-
|
530
|
-
class TableOfContentsBlock(BaseModel):
|
531
|
-
color: BlockColor = "default"
|
532
|
-
|
533
|
-
|
534
|
-
class TemplateBlock(BaseModel):
|
535
|
-
rich_text: list[RichTextObject]
|
536
|
-
children: Optional[list["Block"]] = None
|
537
|
-
|
538
|
-
|
539
|
-
class ToDoBlock(BaseModel):
|
540
|
-
rich_text: list[RichTextObject]
|
541
|
-
checked: bool = False
|
542
|
-
color: BlockColor = "default"
|
543
|
-
children: Optional[list["Block"]] = None
|
544
|
-
|
545
|
-
|
546
|
-
class ToggleBlock(BaseModel):
|
547
|
-
rich_text: list[RichTextObject]
|
548
|
-
color: BlockColor = "default"
|
549
|
-
children: Optional[list["Block"]] = None
|
550
|
-
|
551
|
-
|
552
|
-
class VideoBlock(BaseModel):
|
553
|
-
type: Literal["external", "file", "file_upload"]
|
554
|
-
external: Optional[ExternalFile] = None
|
555
|
-
file: Optional[NotionHostedFile] = None
|
556
|
-
file_upload: Optional[FileUploadFile] = None
|
557
|
-
caption: Optional[list[RichTextObject]] = None
|
558
|
-
|
559
|
-
|
560
|
-
class UnsupportedBlock(BaseModel):
|
561
|
-
pass
|
562
|
-
|
563
|
-
|
564
|
-
# ============================================================================
|
565
|
-
# MAIN BLOCK MODEL
|
566
|
-
# ============================================================================
|
567
|
-
|
568
|
-
|
569
|
-
class Block(BaseModel):
|
570
|
-
object: Literal["block"]
|
571
|
-
id: str
|
572
|
-
parent: Optional[ParentObject] = None
|
573
|
-
type: BlockType
|
574
|
-
created_time: str
|
575
|
-
last_edited_time: str
|
576
|
-
created_by: PartialUser
|
577
|
-
last_edited_by: PartialUser
|
578
|
-
archived: bool = False
|
579
|
-
in_trash: bool = False
|
580
|
-
has_children: bool = False
|
581
|
-
|
582
|
-
children: Optional[list[Block]] = None # for recursive structure
|
583
|
-
|
584
|
-
# Block type-specific content (only one will be populated based on type)
|
585
|
-
audio: Optional[AudioBlock] = None
|
586
|
-
bookmark: Optional[BookmarkBlock] = None
|
587
|
-
breadcrumb: Optional[BreadcrumbBlock] = None
|
588
|
-
bulleted_list_item: Optional[BulletedListItemBlock] = None
|
589
|
-
callout: Optional[CalloutBlock] = None
|
590
|
-
child_database: Optional[ChildDatabaseBlock] = None
|
591
|
-
child_page: Optional[ChildPageBlock] = None
|
592
|
-
code: Optional[CodeBlock] = None
|
593
|
-
column_list: Optional[ColumnListBlock] = None
|
594
|
-
column: Optional[ColumnBlock] = None
|
595
|
-
divider: Optional[DividerBlock] = None
|
596
|
-
embed: Optional[EmbedBlock] = None
|
597
|
-
equation: Optional[EquationBlock] = None
|
598
|
-
file: Optional[FileBlock] = None
|
599
|
-
heading_1: Optional[HeadingBlock] = None
|
600
|
-
heading_2: Optional[HeadingBlock] = None
|
601
|
-
heading_3: Optional[HeadingBlock] = None
|
602
|
-
image: Optional[ImageBlock] = None
|
603
|
-
link_preview: Optional[LinkPreviewBlock] = None
|
604
|
-
link_to_page: Optional[LinkToPageBlock] = None
|
605
|
-
numbered_list_item: Optional[NumberedListItemBlock] = None
|
606
|
-
paragraph: Optional[ParagraphBlock] = None
|
607
|
-
pdf: Optional[PdfBlock] = None
|
608
|
-
quote: Optional[QuoteBlock] = None
|
609
|
-
synced_block: Optional[SyncedBlock] = None
|
610
|
-
table: Optional[TableBlock] = None
|
611
|
-
table_row: Optional[TableRowBlock] = None
|
612
|
-
table_of_contents: Optional[TableOfContentsBlock] = None
|
613
|
-
template: Optional[TemplateBlock] = None
|
614
|
-
to_do: Optional[ToDoBlock] = None
|
615
|
-
toggle: Optional[ToggleBlock] = None
|
616
|
-
video: Optional[VideoBlock] = None
|
617
|
-
unsupported: Optional[UnsupportedBlock] = None
|
618
|
-
|
619
|
-
def get_block_content(self) -> Optional[Any]:
|
620
|
-
"""Get the content object for this block based on its type."""
|
621
|
-
return getattr(self, self.type, None)
|
622
|
-
|
623
|
-
|
624
|
-
# Forward reference resolution
|
625
|
-
Block.model_rebuild()
|
626
|
-
BulletedListItemBlock.model_rebuild()
|
627
|
-
CalloutBlock.model_rebuild()
|
628
|
-
HeadingBlock.model_rebuild()
|
629
|
-
NumberedListItemBlock.model_rebuild()
|
630
|
-
ParagraphBlock.model_rebuild()
|
631
|
-
QuoteBlock.model_rebuild()
|
632
|
-
SyncedBlock.model_rebuild()
|
633
|
-
TemplateBlock.model_rebuild()
|
634
|
-
ToDoBlock.model_rebuild()
|
635
|
-
ToggleBlock.model_rebuild()
|
636
|
-
|
637
|
-
|
638
|
-
# ============================================================================
|
639
|
-
# API REQUEST/RESPONSE MODELS
|
640
|
-
# ============================================================================
|
641
|
-
|
642
|
-
|
643
|
-
class BlockChildrenResponse(BaseModel):
|
644
|
-
object: Literal["list"]
|
645
|
-
results: list[Block]
|
646
|
-
next_cursor: Optional[str] = None
|
647
|
-
has_more: bool
|
648
|
-
type: Literal["block"]
|
649
|
-
block: Dict = {}
|
650
|
-
request_id: str
|
651
|
-
|
652
|
-
|
653
|
-
class AppendBlockChildrenRequest(BaseModel):
|
654
|
-
children: list[Dict[str, Any]] # Block creation objects
|
655
|
-
after: Optional[str] = None
|
656
|
-
|
657
|
-
|
658
|
-
class UpdateBlockRequest(BaseModel):
|
659
|
-
# Type-specific updates based on block type
|
660
|
-
# This would contain the block-specific content to update
|
661
|
-
pass
|
662
|
-
|
663
|
-
|
664
|
-
class BlockResponse(BaseModel):
|
665
|
-
"""Single block response from the API"""
|
666
|
-
|
667
|
-
object: Literal["block"]
|
668
|
-
id: str
|
669
|
-
parent: Optional[ParentObject] = None
|
670
|
-
type: BlockType
|
671
|
-
created_time: str
|
672
|
-
last_edited_time: str
|
673
|
-
created_by: PartialUser
|
674
|
-
last_edited_by: PartialUser
|
675
|
-
archived: bool = False
|
676
|
-
in_trash: bool = False
|
677
|
-
has_children: bool = False
|
678
|
-
request_id: str
|
679
|
-
|
680
|
-
# Block type-specific content
|
681
|
-
audio: Optional[AudioBlock] = None
|
682
|
-
bookmark: Optional[BookmarkBlock] = None
|
683
|
-
breadcrumb: Optional[BreadcrumbBlock] = None
|
684
|
-
bulleted_list_item: Optional[BulletedListItemBlock] = None
|
685
|
-
callout: Optional[CalloutBlock] = None
|
686
|
-
child_database: Optional[ChildDatabaseBlock] = None
|
687
|
-
child_page: Optional[ChildPageBlock] = None
|
688
|
-
code: Optional[CodeBlock] = None
|
689
|
-
column_list: Optional[ColumnListBlock] = None
|
690
|
-
column: Optional[ColumnBlock] = None
|
691
|
-
divider: Optional[DividerBlock] = None
|
692
|
-
embed: Optional[EmbedBlock] = None
|
693
|
-
equation: Optional[EquationBlock] = None
|
694
|
-
file: Optional[FileBlock] = None
|
695
|
-
heading_1: Optional[HeadingBlock] = None
|
696
|
-
heading_2: Optional[HeadingBlock] = None
|
697
|
-
heading_3: Optional[HeadingBlock] = None
|
698
|
-
image: Optional[ImageBlock] = None
|
699
|
-
link_preview: Optional[LinkPreviewBlock] = None
|
700
|
-
link_to_page: Optional[LinkToPageBlock] = None
|
701
|
-
numbered_list_item: Optional[NumberedListItemBlock] = None
|
702
|
-
paragraph: Optional[ParagraphBlock] = None
|
703
|
-
pdf: Optional[PdfBlock] = None
|
704
|
-
quote: Optional[QuoteBlock] = None
|
705
|
-
synced_block: Optional[SyncedBlock] = None
|
706
|
-
table: Optional[TableBlock] = None
|
707
|
-
table_row: Optional[TableRowBlock] = None
|
708
|
-
table_of_contents: Optional[TableOfContentsBlock] = None
|
709
|
-
template: Optional[TemplateBlock] = None
|
710
|
-
to_do: Optional[ToDoBlock] = None
|
711
|
-
toggle: Optional[ToggleBlock] = None
|
712
|
-
video: Optional[VideoBlock] = None
|
713
|
-
unsupported: Optional[UnsupportedBlock] = None
|