notionary 0.1.29__py3-none-any.whl → 0.2.0__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 +5 -5
- notionary/database/notion_database.py +50 -59
- notionary/database/notion_database_factory.py +16 -20
- notionary/elements/audio_element.py +1 -1
- notionary/elements/bookmark_element.py +1 -1
- notionary/elements/bulleted_list_element.py +2 -8
- notionary/elements/callout_element.py +1 -1
- notionary/elements/code_block_element.py +1 -1
- notionary/elements/divider_element.py +1 -1
- notionary/elements/embed_element.py +1 -1
- notionary/elements/heading_element.py +2 -8
- notionary/elements/image_element.py +1 -1
- notionary/elements/mention_element.py +1 -1
- notionary/elements/notion_block_element.py +1 -1
- notionary/elements/numbered_list_element.py +2 -7
- notionary/elements/paragraph_element.py +1 -1
- notionary/elements/qoute_element.py +1 -1
- notionary/elements/registry/{block_element_registry.py → block_registry.py} +70 -26
- notionary/elements/registry/{block_element_registry_builder.py → block_registry_builder.py} +48 -32
- notionary/elements/table_element.py +1 -1
- notionary/elements/text_inline_formatter.py +13 -9
- notionary/elements/todo_element.py +1 -1
- notionary/elements/toggle_element.py +1 -1
- notionary/elements/toggleable_heading_element.py +1 -1
- notionary/elements/video_element.py +1 -1
- notionary/models/notion_block_response.py +264 -0
- notionary/models/notion_database_response.py +63 -0
- notionary/models/notion_page_response.py +100 -0
- notionary/notion_client.py +38 -5
- notionary/page/content/page_content_retriever.py +68 -0
- notionary/page/content/page_content_writer.py +103 -0
- notionary/page/markdown_to_notion_converter.py +5 -5
- notionary/page/metadata/metadata_editor.py +91 -63
- notionary/page/metadata/notion_icon_manager.py +55 -28
- notionary/page/metadata/notion_page_cover_manager.py +23 -20
- notionary/page/notion_page.py +223 -218
- notionary/page/notion_page_factory.py +102 -151
- notionary/page/notion_to_markdown_converter.py +5 -5
- notionary/page/properites/database_property_service.py +11 -55
- notionary/page/properites/page_property_manager.py +44 -67
- notionary/page/properites/property_value_extractor.py +3 -3
- notionary/page/relations/notion_page_relation_manager.py +165 -213
- notionary/page/relations/notion_page_title_resolver.py +59 -41
- notionary/page/relations/page_database_relation.py +7 -9
- notionary/{elements/prompts → prompting}/element_prompt_content.py +19 -4
- notionary/prompting/markdown_syntax_prompt_generator.py +92 -0
- notionary/util/logging_mixin.py +17 -8
- notionary/util/warn_direct_constructor_usage.py +54 -0
- {notionary-0.1.29.dist-info → notionary-0.2.0.dist-info}/METADATA +2 -1
- notionary-0.2.0.dist-info/RECORD +60 -0
- {notionary-0.1.29.dist-info → notionary-0.2.0.dist-info}/WHEEL +1 -1
- notionary/database/database_info_service.py +0 -43
- notionary/elements/prompts/synthax_prompt_builder.py +0 -150
- notionary/page/content/page_content_manager.py +0 -211
- notionary/page/properites/property_operation_result.py +0 -116
- notionary/page/relations/relation_operation_result.py +0 -144
- notionary-0.1.29.dist-info/RECORD +0 -58
- {notionary-0.1.29.dist-info → notionary-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {notionary-0.1.29.dist-info → notionary-0.2.0.dist-info}/top_level.txt +0 -0
@@ -2,14 +2,16 @@ from __future__ import annotations
|
|
2
2
|
from typing import List, Type
|
3
3
|
from collections import OrderedDict
|
4
4
|
|
5
|
+
from notionary.elements.notion_block_element import NotionBlockElement
|
6
|
+
|
5
7
|
from notionary.elements.audio_element import AudioElement
|
6
8
|
from notionary.elements.bulleted_list_element import BulletedListElement
|
7
9
|
from notionary.elements.embed_element import EmbedElement
|
8
10
|
from notionary.elements.mention_element import MentionElement
|
9
11
|
from notionary.elements.notion_block_element import NotionBlockElement
|
10
12
|
from notionary.elements.numbered_list_element import NumberedListElement
|
11
|
-
from notionary.elements.registry.
|
12
|
-
|
13
|
+
from notionary.elements.registry.block_registry import (
|
14
|
+
BlockRegistry,
|
13
15
|
)
|
14
16
|
|
15
17
|
from notionary.elements.paragraph_element import ParagraphElement
|
@@ -27,9 +29,9 @@ from notionary.elements.toggle_element import ToggleElement
|
|
27
29
|
from notionary.elements.bookmark_element import BookmarkElement
|
28
30
|
|
29
31
|
|
30
|
-
class
|
32
|
+
class BlockRegistryBuilder:
|
31
33
|
"""
|
32
|
-
True builder for constructing
|
34
|
+
True builder for constructing BlockRegistry instances.
|
33
35
|
|
34
36
|
This builder allows for incremental construction of registry instances
|
35
37
|
with specific configurations of block elements.
|
@@ -40,7 +42,7 @@ class BlockElementRegistryBuilder:
|
|
40
42
|
self._elements = OrderedDict()
|
41
43
|
|
42
44
|
@classmethod
|
43
|
-
def create_full_registry(cls) ->
|
45
|
+
def create_full_registry(cls) -> BlockRegistry:
|
44
46
|
"""
|
45
47
|
Start with all standard elements in recommended order.
|
46
48
|
"""
|
@@ -65,10 +67,24 @@ class BlockElementRegistryBuilder:
|
|
65
67
|
.with_paragraphs()
|
66
68
|
.with_toggleable_heading_element()
|
67
69
|
).build()
|
70
|
+
|
71
|
+
@classmethod
|
72
|
+
def create_minimal_registry(cls) -> BlockRegistry:
|
73
|
+
"""
|
74
|
+
Create a minimal registry with just essential text elements.
|
75
|
+
Suitable for basic note-taking.
|
76
|
+
"""
|
77
|
+
builder = cls()
|
78
|
+
return (
|
79
|
+
builder.with_paragraphs()
|
80
|
+
.with_headings()
|
81
|
+
.with_bulleted_list()
|
82
|
+
.with_numbered_list()
|
83
|
+
).build()
|
68
84
|
|
69
85
|
def add_element(
|
70
86
|
self, element_class: Type[NotionBlockElement]
|
71
|
-
) ->
|
87
|
+
) -> BlockRegistryBuilder:
|
72
88
|
"""
|
73
89
|
Add an element class to the registry configuration.
|
74
90
|
If the element already exists, it's moved to the end.
|
@@ -86,7 +102,7 @@ class BlockElementRegistryBuilder:
|
|
86
102
|
|
87
103
|
def add_elements(
|
88
104
|
self, element_classes: List[Type[NotionBlockElement]]
|
89
|
-
) ->
|
105
|
+
) -> BlockRegistryBuilder:
|
90
106
|
"""
|
91
107
|
Add multiple element classes to the registry configuration.
|
92
108
|
|
@@ -102,7 +118,7 @@ class BlockElementRegistryBuilder:
|
|
102
118
|
|
103
119
|
def remove_element(
|
104
120
|
self, element_class: Type[NotionBlockElement]
|
105
|
-
) ->
|
121
|
+
) -> BlockRegistryBuilder:
|
106
122
|
"""
|
107
123
|
Remove an element class from the registry configuration.
|
108
124
|
|
@@ -117,7 +133,7 @@ class BlockElementRegistryBuilder:
|
|
117
133
|
|
118
134
|
def move_element_to_end(
|
119
135
|
self, element_class: Type[NotionBlockElement]
|
120
|
-
) ->
|
136
|
+
) -> BlockRegistryBuilder:
|
121
137
|
"""
|
122
138
|
Move an existing element to the end of the registry.
|
123
139
|
If the element doesn't exist, it will be added.
|
@@ -138,131 +154,131 @@ class BlockElementRegistryBuilder:
|
|
138
154
|
paragraph_class = self._elements.pop(ParagraphElement.__name__)
|
139
155
|
self._elements[ParagraphElement.__name__] = paragraph_class
|
140
156
|
|
141
|
-
def with_paragraphs(self) ->
|
157
|
+
def with_paragraphs(self) -> BlockRegistryBuilder:
|
142
158
|
"""
|
143
159
|
Add support for paragraph elements.
|
144
160
|
"""
|
145
161
|
return self.add_element(ParagraphElement)
|
146
162
|
|
147
|
-
def with_headings(self) ->
|
163
|
+
def with_headings(self) -> BlockRegistryBuilder:
|
148
164
|
"""
|
149
165
|
Add support for heading elements.
|
150
166
|
"""
|
151
167
|
return self.add_element(HeadingElement)
|
152
168
|
|
153
|
-
def with_callouts(self) ->
|
169
|
+
def with_callouts(self) -> BlockRegistryBuilder:
|
154
170
|
"""
|
155
171
|
Add support for callout elements.
|
156
172
|
"""
|
157
173
|
return self.add_element(CalloutElement)
|
158
174
|
|
159
|
-
def with_code(self) ->
|
175
|
+
def with_code(self) -> BlockRegistryBuilder:
|
160
176
|
"""
|
161
177
|
Add support for code blocks.
|
162
178
|
"""
|
163
179
|
return self.add_element(CodeBlockElement)
|
164
180
|
|
165
|
-
def with_dividers(self) ->
|
181
|
+
def with_dividers(self) -> BlockRegistryBuilder:
|
166
182
|
"""
|
167
183
|
Add support for divider elements.
|
168
184
|
"""
|
169
185
|
return self.add_element(DividerElement)
|
170
186
|
|
171
|
-
def with_tables(self) ->
|
187
|
+
def with_tables(self) -> BlockRegistryBuilder:
|
172
188
|
"""
|
173
189
|
Add support for tables.
|
174
190
|
"""
|
175
191
|
return self.add_element(TableElement)
|
176
192
|
|
177
|
-
def with_bulleted_list(self) ->
|
193
|
+
def with_bulleted_list(self) -> BlockRegistryBuilder:
|
178
194
|
"""
|
179
195
|
Add support for bulleted list elements (unordered lists).
|
180
196
|
"""
|
181
197
|
return self.add_element(BulletedListElement)
|
182
198
|
|
183
|
-
def with_numbered_list(self) ->
|
199
|
+
def with_numbered_list(self) -> BlockRegistryBuilder:
|
184
200
|
"""
|
185
201
|
Add support for numbered list elements (ordered lists).
|
186
202
|
"""
|
187
203
|
return self.add_element(NumberedListElement)
|
188
204
|
|
189
|
-
def with_toggles(self) ->
|
205
|
+
def with_toggles(self) -> BlockRegistryBuilder:
|
190
206
|
"""
|
191
207
|
Add support for toggle elements.
|
192
208
|
"""
|
193
209
|
return self.add_element(ToggleElement)
|
194
210
|
|
195
|
-
def with_quotes(self) ->
|
211
|
+
def with_quotes(self) -> BlockRegistryBuilder:
|
196
212
|
"""
|
197
213
|
Add support for quote elements.
|
198
214
|
"""
|
199
215
|
return self.add_element(QuoteElement)
|
200
216
|
|
201
|
-
def with_todos(self) ->
|
217
|
+
def with_todos(self) -> BlockRegistryBuilder:
|
202
218
|
"""
|
203
219
|
Add support for todo elements.
|
204
220
|
"""
|
205
221
|
return self.add_element(TodoElement)
|
206
222
|
|
207
|
-
def with_bookmarks(self) ->
|
223
|
+
def with_bookmarks(self) -> BlockRegistryBuilder:
|
208
224
|
"""
|
209
225
|
Add support for bookmark elements.
|
210
226
|
"""
|
211
227
|
return self.add_element(BookmarkElement)
|
212
228
|
|
213
|
-
def with_images(self) ->
|
229
|
+
def with_images(self) -> BlockRegistryBuilder:
|
214
230
|
"""
|
215
231
|
Add support for image elements.
|
216
232
|
"""
|
217
233
|
return self.add_element(ImageElement)
|
218
234
|
|
219
|
-
def with_videos(self) ->
|
235
|
+
def with_videos(self) -> BlockRegistryBuilder:
|
220
236
|
"""
|
221
237
|
Add support for video elements.
|
222
238
|
"""
|
223
239
|
return self.add_element(VideoElement)
|
224
240
|
|
225
|
-
def with_embeds(self) ->
|
241
|
+
def with_embeds(self) -> BlockRegistryBuilder:
|
226
242
|
"""
|
227
243
|
Add support for embed elements.
|
228
244
|
"""
|
229
245
|
return self.add_element(EmbedElement)
|
230
246
|
|
231
|
-
def with_audio(self) ->
|
247
|
+
def with_audio(self) -> BlockRegistryBuilder:
|
232
248
|
"""
|
233
249
|
Add support for audio elements.
|
234
250
|
"""
|
235
251
|
return self.add_element(AudioElement)
|
236
252
|
|
237
|
-
def with_media_support(self) ->
|
253
|
+
def with_media_support(self) -> BlockRegistryBuilder:
|
238
254
|
"""
|
239
255
|
Add support for media elements (images, videos, audio).
|
240
256
|
"""
|
241
257
|
return self.with_images().with_videos().with_audio()
|
242
258
|
|
243
|
-
def with_mention(self) ->
|
259
|
+
def with_mention(self) -> BlockRegistryBuilder:
|
244
260
|
return self.add_element(MentionElement)
|
245
261
|
|
246
|
-
def with_toggleable_heading_element(self) ->
|
262
|
+
def with_toggleable_heading_element(self) -> BlockRegistryBuilder:
|
247
263
|
return self.add_element(ToggleableHeadingElement)
|
248
264
|
|
249
|
-
def build(self) ->
|
265
|
+
def build(self) -> BlockRegistry:
|
250
266
|
"""
|
251
|
-
Build and return the configured
|
267
|
+
Build and return the configured BlockRegistry instance.
|
252
268
|
|
253
269
|
This automatically ensures that ParagraphElement is at the end
|
254
270
|
of the registry (if present) as a fallback element, unless
|
255
271
|
this behavior was explicitly disabled.
|
256
272
|
|
257
273
|
Returns:
|
258
|
-
A configured
|
274
|
+
A configured BlockRegistry instance
|
259
275
|
"""
|
260
276
|
if ParagraphElement.__name__ not in self._elements:
|
261
277
|
self.add_element(ParagraphElement)
|
262
278
|
else:
|
263
279
|
self._ensure_paragraph_at_end()
|
264
280
|
|
265
|
-
registry =
|
281
|
+
registry = BlockRegistry()
|
266
282
|
|
267
283
|
# Add elements in the recorded order
|
268
284
|
for element_class in self._elements.values():
|
@@ -2,7 +2,7 @@ import re
|
|
2
2
|
from typing import Dict, Any, Optional, List, Tuple
|
3
3
|
from notionary.elements.notion_block_element import NotionBlockElement
|
4
4
|
from notionary.elements.text_inline_formatter import TextInlineFormatter
|
5
|
-
from notionary.
|
5
|
+
from notionary.prompting.element_prompt_content import (
|
6
6
|
ElementPromptBuilder,
|
7
7
|
ElementPromptContent,
|
8
8
|
)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
from typing import Dict, Any, List, Tuple
|
2
2
|
import re
|
3
3
|
|
4
|
-
from notionary.
|
4
|
+
from notionary.prompting.element_prompt_content import (
|
5
5
|
ElementPromptBuilder,
|
6
6
|
ElementPromptContent,
|
7
7
|
)
|
@@ -219,20 +219,24 @@ class TextInlineFormatter:
|
|
219
219
|
return (
|
220
220
|
ElementPromptBuilder()
|
221
221
|
.with_description(
|
222
|
-
"
|
222
|
+
"Inline formatting can be used within most block types to style your text. You can combine multiple formatting options."
|
223
223
|
)
|
224
224
|
.with_usage_guidelines(
|
225
225
|
"Use inline formatting to highlight important words, provide emphasis, show code or paths, or add hyperlinks. "
|
226
|
-
"
|
226
|
+
"This helps create visual hierarchy and improves readability."
|
227
|
+
)
|
228
|
+
.with_syntax(
|
229
|
+
"**bold**, *italic*, `code`, ~~strikethrough~~, __underline__, [text](url)"
|
227
230
|
)
|
228
|
-
.with_syntax("**bold**, *italic*, `code`, [text](url)")
|
229
231
|
.with_examples(
|
230
232
|
[
|
231
|
-
"This
|
232
|
-
"
|
233
|
-
"
|
234
|
-
"
|
235
|
-
"
|
233
|
+
"This text has a **bold** word.",
|
234
|
+
"This text has an *italic* word.",
|
235
|
+
"This text has `code` formatting.",
|
236
|
+
"This text has ~~strikethrough~~ formatting.",
|
237
|
+
"This text has __underlined__ formatting.",
|
238
|
+
"This has a [hyperlink](https://example.com).",
|
239
|
+
"You can **combine *different* formatting** styles.",
|
236
240
|
]
|
237
241
|
)
|
238
242
|
.build()
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import re
|
2
2
|
from typing import Dict, Any, Optional
|
3
3
|
from notionary.elements.notion_block_element import NotionBlockElement
|
4
|
-
from notionary.
|
4
|
+
from notionary.prompting.element_prompt_content import (
|
5
5
|
ElementPromptBuilder,
|
6
6
|
ElementPromptContent,
|
7
7
|
)
|
@@ -2,7 +2,7 @@ import re
|
|
2
2
|
from typing import Dict, Any, Optional, List, Tuple, Callable
|
3
3
|
|
4
4
|
from notionary.elements.notion_block_element import NotionBlockElement
|
5
|
-
from notionary.
|
5
|
+
from notionary.prompting.element_prompt_content import (
|
6
6
|
ElementPromptBuilder,
|
7
7
|
ElementPromptContent,
|
8
8
|
)
|
@@ -2,7 +2,7 @@ import re
|
|
2
2
|
from typing import Dict, Any, Optional, List, Tuple, Callable
|
3
3
|
|
4
4
|
from notionary.elements.notion_block_element import NotionBlockElement
|
5
|
-
from notionary.
|
5
|
+
from notionary.prompting.element_prompt_content import (
|
6
6
|
ElementPromptBuilder,
|
7
7
|
ElementPromptContent,
|
8
8
|
)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import re
|
2
2
|
from typing import Dict, Any, Optional, List
|
3
3
|
from notionary.elements.notion_block_element import NotionBlockElement
|
4
|
-
from notionary.
|
4
|
+
from notionary.prompting.element_prompt_content import (
|
5
5
|
ElementPromptBuilder,
|
6
6
|
ElementPromptContent,
|
7
7
|
)
|
@@ -0,0 +1,264 @@
|
|
1
|
+
from typing import List, Optional, Union, Literal
|
2
|
+
from pydantic import BaseModel
|
3
|
+
|
4
|
+
|
5
|
+
# Rich Text Komponenten
|
6
|
+
class TextContent(BaseModel):
|
7
|
+
content: str
|
8
|
+
link: Optional[dict] = None
|
9
|
+
|
10
|
+
|
11
|
+
class Annotations(BaseModel):
|
12
|
+
bold: bool
|
13
|
+
italic: bool
|
14
|
+
strikethrough: bool
|
15
|
+
underline: bool
|
16
|
+
code: bool
|
17
|
+
color: str
|
18
|
+
|
19
|
+
|
20
|
+
class RichText(BaseModel):
|
21
|
+
type: Literal["text"]
|
22
|
+
text: TextContent
|
23
|
+
annotations: Annotations
|
24
|
+
plain_text: str
|
25
|
+
href: Optional[str]
|
26
|
+
|
27
|
+
|
28
|
+
# Benutzerobjekt
|
29
|
+
class User(BaseModel):
|
30
|
+
object: str
|
31
|
+
id: str
|
32
|
+
|
33
|
+
|
34
|
+
# Elternobjekte
|
35
|
+
class PageParent(BaseModel):
|
36
|
+
type: Literal["page_id"]
|
37
|
+
page_id: str
|
38
|
+
|
39
|
+
|
40
|
+
class DatabaseParent(BaseModel):
|
41
|
+
type: Literal["database_id"]
|
42
|
+
database_id: str
|
43
|
+
|
44
|
+
|
45
|
+
class WorkspaceParent(BaseModel):
|
46
|
+
type: Literal["workspace"]
|
47
|
+
workspace: bool = True
|
48
|
+
|
49
|
+
|
50
|
+
Parent = Union[PageParent, DatabaseParent, WorkspaceParent]
|
51
|
+
|
52
|
+
|
53
|
+
# Block-spezifische Inhalte
|
54
|
+
class ParagraphBlock(BaseModel):
|
55
|
+
rich_text: List[RichText]
|
56
|
+
color: Optional[str] = "default"
|
57
|
+
|
58
|
+
|
59
|
+
class Heading1Block(BaseModel):
|
60
|
+
rich_text: List[RichText]
|
61
|
+
color: Optional[str] = "default"
|
62
|
+
is_toggleable: Optional[bool] = False
|
63
|
+
|
64
|
+
|
65
|
+
class Heading2Block(BaseModel):
|
66
|
+
rich_text: List[RichText]
|
67
|
+
color: Optional[str] = "default"
|
68
|
+
is_toggleable: Optional[bool] = False
|
69
|
+
|
70
|
+
|
71
|
+
class Heading3Block(BaseModel):
|
72
|
+
rich_text: List[RichText]
|
73
|
+
color: Optional[str] = "default"
|
74
|
+
is_toggleable: Optional[bool] = False
|
75
|
+
|
76
|
+
|
77
|
+
class BulletedListItemBlock(BaseModel):
|
78
|
+
rich_text: List[RichText]
|
79
|
+
color: Optional[str] = "default"
|
80
|
+
|
81
|
+
|
82
|
+
class NumberedListItemBlock(BaseModel):
|
83
|
+
rich_text: List[RichText]
|
84
|
+
color: Optional[str] = "default"
|
85
|
+
|
86
|
+
|
87
|
+
class ToDoBlock(BaseModel):
|
88
|
+
rich_text: List[RichText]
|
89
|
+
checked: Optional[bool] = False
|
90
|
+
color: Optional[str] = "default"
|
91
|
+
|
92
|
+
|
93
|
+
class ToggleBlock(BaseModel):
|
94
|
+
rich_text: List[RichText]
|
95
|
+
color: Optional[str] = "default"
|
96
|
+
|
97
|
+
|
98
|
+
class QuoteBlock(BaseModel):
|
99
|
+
rich_text: List[RichText]
|
100
|
+
color: Optional[str] = "default"
|
101
|
+
|
102
|
+
|
103
|
+
class CalloutBlock(BaseModel):
|
104
|
+
rich_text: List[RichText]
|
105
|
+
icon: Optional[dict] = None
|
106
|
+
color: Optional[str] = "default"
|
107
|
+
|
108
|
+
|
109
|
+
class CodeBlock(BaseModel):
|
110
|
+
rich_text: List[RichText]
|
111
|
+
language: Optional[str] = "plain text"
|
112
|
+
|
113
|
+
|
114
|
+
class EquationBlock(BaseModel):
|
115
|
+
expression: str
|
116
|
+
|
117
|
+
|
118
|
+
class DividerBlock(BaseModel):
|
119
|
+
pass
|
120
|
+
|
121
|
+
|
122
|
+
class TableOfContentsBlock(BaseModel):
|
123
|
+
color: Optional[str] = "default"
|
124
|
+
|
125
|
+
|
126
|
+
class BreadcrumbBlock(BaseModel):
|
127
|
+
pass
|
128
|
+
|
129
|
+
|
130
|
+
class ColumnListBlock(BaseModel):
|
131
|
+
pass
|
132
|
+
|
133
|
+
|
134
|
+
class ColumnBlock(BaseModel):
|
135
|
+
pass
|
136
|
+
|
137
|
+
|
138
|
+
class LinkToPageBlock(BaseModel):
|
139
|
+
type: str
|
140
|
+
page_id: Optional[str] = None
|
141
|
+
database_id: Optional[str] = None
|
142
|
+
|
143
|
+
|
144
|
+
class SyncedBlock(BaseModel):
|
145
|
+
synced_from: Optional[dict] = None
|
146
|
+
|
147
|
+
|
148
|
+
class TemplateBlock(BaseModel):
|
149
|
+
rich_text: List[RichText]
|
150
|
+
|
151
|
+
|
152
|
+
class TableBlock(BaseModel):
|
153
|
+
table_width: int
|
154
|
+
has_column_header: bool
|
155
|
+
has_row_header: bool
|
156
|
+
|
157
|
+
|
158
|
+
class TableRowBlock(BaseModel):
|
159
|
+
cells: List[List[RichText]]
|
160
|
+
|
161
|
+
|
162
|
+
class BookmarkBlock(BaseModel):
|
163
|
+
caption: List[RichText]
|
164
|
+
url: str
|
165
|
+
|
166
|
+
|
167
|
+
class EmbedBlock(BaseModel):
|
168
|
+
url: str
|
169
|
+
|
170
|
+
|
171
|
+
class ImageBlock(BaseModel):
|
172
|
+
type: str
|
173
|
+
external: Optional[dict] = None
|
174
|
+
file: Optional[dict] = None
|
175
|
+
caption: List[RichText]
|
176
|
+
|
177
|
+
|
178
|
+
class VideoBlock(BaseModel):
|
179
|
+
type: str
|
180
|
+
external: Optional[dict] = None
|
181
|
+
file: Optional[dict] = None
|
182
|
+
caption: List[RichText]
|
183
|
+
|
184
|
+
|
185
|
+
class PDFBlock(BaseModel):
|
186
|
+
type: str
|
187
|
+
external: Optional[dict] = None
|
188
|
+
file: Optional[dict] = None
|
189
|
+
caption: List[RichText]
|
190
|
+
|
191
|
+
|
192
|
+
class FileBlock(BaseModel):
|
193
|
+
type: str
|
194
|
+
external: Optional[dict] = None
|
195
|
+
file: Optional[dict] = None
|
196
|
+
caption: List[RichText]
|
197
|
+
|
198
|
+
|
199
|
+
class AudioBlock(BaseModel):
|
200
|
+
type: str
|
201
|
+
external: Optional[dict] = None
|
202
|
+
file: Optional[dict] = None
|
203
|
+
caption: List[RichText]
|
204
|
+
|
205
|
+
|
206
|
+
class LinkPreviewBlock(BaseModel):
|
207
|
+
url: str
|
208
|
+
|
209
|
+
|
210
|
+
class ChildPageBlock(BaseModel):
|
211
|
+
title: str
|
212
|
+
|
213
|
+
|
214
|
+
class ChildDatabaseBlock(BaseModel):
|
215
|
+
title: str
|
216
|
+
|
217
|
+
|
218
|
+
# TODO: Use the block typing here:
|
219
|
+
# Test the code base.
|
220
|
+
class Block(BaseModel):
|
221
|
+
object: Literal["block"]
|
222
|
+
id: str
|
223
|
+
parent: Parent
|
224
|
+
created_time: str
|
225
|
+
last_edited_time: str
|
226
|
+
created_by: User
|
227
|
+
last_edited_by: User
|
228
|
+
has_children: bool
|
229
|
+
archived: bool
|
230
|
+
in_trash: bool
|
231
|
+
type: str
|
232
|
+
paragraph: Optional[ParagraphBlock] = None
|
233
|
+
heading_1: Optional[Heading1Block] = None
|
234
|
+
heading_2: Optional[Heading2Block] = None
|
235
|
+
heading_3: Optional[Heading3Block] = None
|
236
|
+
bulleted_list_item: Optional[BulletedListItemBlock] = None
|
237
|
+
numbered_list_item: Optional[NumberedListItemBlock] = None
|
238
|
+
to_do: Optional[ToDoBlock] = None
|
239
|
+
toggle: Optional[ToggleBlock] = None
|
240
|
+
quote: Optional[QuoteBlock] = None
|
241
|
+
callout: Optional[CalloutBlock] = None
|
242
|
+
code: Optional[CodeBlock] = None
|
243
|
+
equation: Optional[EquationBlock] = None
|
244
|
+
divider: Optional[DividerBlock] = None
|
245
|
+
table_of_contents: Optional[TableOfContentsBlock] = None
|
246
|
+
breadcrumb: Optional[BreadcrumbBlock] = None
|
247
|
+
column_list: Optional[ColumnListBlock] = None
|
248
|
+
column: Optional[ColumnBlock] = None
|
249
|
+
link_to_page: Optional[LinkToPageBlock] = None
|
250
|
+
synced_block: Optional[SyncedBlock] = None
|
251
|
+
template: Optional[TemplateBlock] = None
|
252
|
+
table: Optional[TableBlock] = None
|
253
|
+
table_row: Optional[TableRowBlock] = None
|
254
|
+
bookmark: Optional[BookmarkBlock] = None
|
255
|
+
embed: Optional[EmbedBlock] = None
|
256
|
+
image: Optional[ImageBlock] = None
|
257
|
+
video: Optional[VideoBlock] = None
|
258
|
+
pdf: Optional[PDFBlock] = None
|
259
|
+
file: Optional[FileBlock] = None
|
260
|
+
audio: Optional[AudioBlock] = None
|
261
|
+
link_preview: Optional[LinkPreviewBlock] = None
|
262
|
+
child_page: Optional[ChildPageBlock] = None
|
263
|
+
child_database: Optional[ChildDatabaseBlock] = None
|
264
|
+
unsupported: Optional[dict] = None
|
@@ -0,0 +1,63 @@
|
|
1
|
+
from pydantic import BaseModel
|
2
|
+
from dataclasses import dataclass
|
3
|
+
from typing import Optional, List, Dict, Any, Literal
|
4
|
+
|
5
|
+
from notionary.models.notion_page_response import Icon
|
6
|
+
|
7
|
+
|
8
|
+
@dataclass
|
9
|
+
class TextContent:
|
10
|
+
content: str
|
11
|
+
link: Optional[str] = None
|
12
|
+
|
13
|
+
|
14
|
+
@dataclass
|
15
|
+
class TextContent:
|
16
|
+
content: str
|
17
|
+
link: Optional[str] = None
|
18
|
+
|
19
|
+
|
20
|
+
@dataclass
|
21
|
+
class RichText:
|
22
|
+
type: str
|
23
|
+
text: TextContent
|
24
|
+
plain_text: str
|
25
|
+
href: Optional[str]
|
26
|
+
|
27
|
+
|
28
|
+
@dataclass
|
29
|
+
class User:
|
30
|
+
object: str
|
31
|
+
id: str
|
32
|
+
|
33
|
+
|
34
|
+
@dataclass
|
35
|
+
class Parent:
|
36
|
+
type: Literal["page_id", "workspace"]
|
37
|
+
page_id: Optional[str] = None
|
38
|
+
|
39
|
+
|
40
|
+
@dataclass
|
41
|
+
class NotionDatabaserResponse(BaseModel):
|
42
|
+
"""
|
43
|
+
Represents the response from the Notion API when retrieving a database.
|
44
|
+
"""
|
45
|
+
|
46
|
+
object: Literal["database"]
|
47
|
+
id: str
|
48
|
+
cover: Optional[Any]
|
49
|
+
icon: Optional[Icon]
|
50
|
+
created_time: str
|
51
|
+
last_edited_time: str
|
52
|
+
created_by: User
|
53
|
+
last_edited_by: User
|
54
|
+
title: List[RichText]
|
55
|
+
description: List[Any]
|
56
|
+
is_inline: bool
|
57
|
+
properties: Dict[str, Any]
|
58
|
+
parent: Parent
|
59
|
+
url: str
|
60
|
+
public_url: Optional[str]
|
61
|
+
archived: bool
|
62
|
+
in_trash: bool
|
63
|
+
request_id: Optional[str] = None
|