notionary 0.2.19__py3-none-any.whl → 0.2.21__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 +263 -0
- notionary/blocks/audio/__init__.py +8 -2
- notionary/blocks/audio/audio_element.py +42 -104
- notionary/blocks/audio/audio_markdown_node.py +3 -1
- notionary/blocks/audio/audio_models.py +6 -55
- notionary/blocks/base_block_element.py +30 -0
- notionary/blocks/bookmark/__init__.py +9 -2
- notionary/blocks/bookmark/bookmark_element.py +46 -139
- notionary/blocks/bookmark/bookmark_markdown_node.py +3 -1
- 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 +40 -55
- 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 +40 -89
- notionary/blocks/callout/callout_markdown_node.py +3 -1
- notionary/blocks/callout/callout_models.py +33 -0
- notionary/blocks/child_database/__init__.py +7 -0
- notionary/blocks/child_database/child_database_models.py +19 -0
- notionary/blocks/child_page/__init__.py +9 -0
- notionary/blocks/child_page/child_page_models.py +12 -0
- notionary/blocks/{shared/block_client.py → client.py} +55 -54
- notionary/blocks/code/__init__.py +6 -2
- notionary/blocks/code/code_element.py +53 -187
- notionary/blocks/code/code_markdown_node.py +13 -13
- notionary/blocks/code/code_models.py +94 -0
- notionary/blocks/column/__init__.py +25 -1
- notionary/blocks/column/column_element.py +40 -314
- notionary/blocks/column/column_list_element.py +37 -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 +26 -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 +47 -114
- 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 +80 -0
- notionary/blocks/equation/equation_element_markdown_node.py +36 -0
- notionary/blocks/equation/equation_models.py +11 -0
- notionary/blocks/file/__init__.py +25 -0
- notionary/blocks/file/file_element.py +93 -0
- notionary/blocks/file/file_element_markdown_node.py +35 -0
- notionary/blocks/file/file_element_models.py +39 -0
- notionary/blocks/heading/__init__.py +16 -2
- notionary/blocks/heading/heading_element.py +67 -72
- 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 +84 -0
- notionary/blocks/{image → image_block}/image_markdown_node.py +3 -1
- notionary/blocks/image_block/image_models.py +10 -0
- notionary/blocks/models.py +172 -0
- notionary/blocks/numbered_list/__init__.py +12 -2
- notionary/blocks/numbered_list/numbered_list_element.py +33 -58
- 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 +27 -69
- 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 +91 -0
- notionary/blocks/pdf/pdf_markdown_node.py +35 -0
- notionary/blocks/pdf/pdf_models.py +11 -0
- notionary/blocks/quote/__init__.py +11 -2
- notionary/blocks/quote/quote_element.py +31 -65
- notionary/blocks/quote/quote_markdown_node.py +4 -1
- notionary/blocks/quote/quote_models.py +18 -0
- notionary/blocks/registry/__init__.py +4 -0
- notionary/blocks/registry/block_registry.py +75 -91
- notionary/blocks/registry/block_registry_builder.py +107 -59
- notionary/blocks/rich_text/__init__.py +33 -0
- notionary/blocks/rich_text/rich_text_models.py +188 -0
- notionary/blocks/rich_text/text_inline_formatter.py +125 -0
- notionary/blocks/table/__init__.py +16 -2
- notionary/blocks/table/table_element.py +48 -241
- 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 +51 -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 +38 -95
- 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 +57 -264
- notionary/blocks/toggle/toggle_markdown_node.py +24 -14
- notionary/blocks/toggle/toggle_models.py +17 -0
- notionary/blocks/toggleable_heading/__init__.py +6 -2
- notionary/blocks/toggleable_heading/toggleable_heading_element.py +74 -244
- notionary/blocks/toggleable_heading/toggleable_heading_markdown_node.py +26 -18
- notionary/blocks/types.py +61 -0
- notionary/blocks/video/__init__.py +8 -2
- notionary/blocks/video/video_element.py +67 -143
- notionary/blocks/video/video_element_models.py +10 -0
- notionary/blocks/video/video_markdown_node.py +3 -1
- notionary/database/client.py +3 -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 +2 -1
- notionary/file_upload/notion_file_upload.py +2 -3
- notionary/markdown/markdown_builder.py +722 -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 +9 -10
- notionary/page/models.py +327 -0
- notionary/page/notion_page.py +99 -52
- notionary/page/notion_text_length_utils.py +119 -0
- notionary/page/{content/page_content_writer.py → page_content_writer.py} +88 -38
- notionary/page/reader/handler/__init__.py +17 -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 +43 -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 +60 -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 +69 -0
- notionary/page/search_filter_builder.py +2 -1
- notionary/page/writer/handler/__init__.py +22 -0
- notionary/page/writer/handler/code_handler.py +100 -0
- notionary/page/writer/handler/column_handler.py +141 -0
- notionary/page/writer/handler/column_list_handler.py +139 -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 +92 -0
- notionary/page/writer/handler/table_handler.py +130 -0
- notionary/page/writer/handler/toggle_handler.py +153 -0
- notionary/page/writer/handler/toggleable_heading_handler.py +167 -0
- notionary/page/writer/markdown_to_notion_converter.py +76 -0
- notionary/telemetry/__init__.py +2 -2
- notionary/telemetry/service.py +4 -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 +3 -2
- notionary/user/notion_user_provider.py +1 -1
- 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 +3 -2
- {notionary-0.2.19.dist-info → notionary-0.2.21.dist-info}/METADATA +12 -8
- notionary-0.2.21.dist-info/RECORD +185 -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/__init__.py +0 -0
- 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/blocks/toggleable_heading/toggleable_heading_models.py +0 -0
- notionary/database/models/page_result.py +0 -10
- notionary/elements/__init__.py +0 -0
- 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/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-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/page/{content/markdown_whitespace_processor.py → markdown_whitespace_processor.py} +0 -0
- /notionary/{blocks/mention/mention_models.py → page/reader/handler/context.py} +0 -0
- {notionary-0.2.19.dist-info → notionary-0.2.21.dist-info}/LICENSE +0 -0
- {notionary-0.2.19.dist-info → notionary-0.2.21.dist-info}/WHEEL +0 -0
@@ -0,0 +1,337 @@
|
|
1
|
+
from dataclasses import dataclass
|
2
|
+
from typing import Any, Dict, List, Literal, Optional, Union
|
3
|
+
|
4
|
+
from pydantic import BaseModel, ConfigDict
|
5
|
+
|
6
|
+
from notionary.page.models import Cover, Icon
|
7
|
+
|
8
|
+
|
9
|
+
@dataclass
|
10
|
+
class TextContent:
|
11
|
+
content: str
|
12
|
+
link: Optional[str] = None
|
13
|
+
|
14
|
+
|
15
|
+
@dataclass
|
16
|
+
class RichText:
|
17
|
+
type: str
|
18
|
+
text: TextContent
|
19
|
+
plain_text: str
|
20
|
+
href: Optional[str]
|
21
|
+
|
22
|
+
|
23
|
+
@dataclass
|
24
|
+
class User:
|
25
|
+
object: str
|
26
|
+
id: str
|
27
|
+
|
28
|
+
|
29
|
+
@dataclass
|
30
|
+
class Parent:
|
31
|
+
type: Literal["page_id", "workspace", "block_id", "database_id"]
|
32
|
+
page_id: Optional[str] = None
|
33
|
+
block_id: Optional[str] = None
|
34
|
+
database_id: Optional[str] = None
|
35
|
+
|
36
|
+
|
37
|
+
# Rich text types for Pydantic models
|
38
|
+
class TextContentPydantic(BaseModel):
|
39
|
+
content: str
|
40
|
+
link: Optional[Dict[str, str]] = None
|
41
|
+
|
42
|
+
|
43
|
+
class Annotations(BaseModel):
|
44
|
+
bold: bool
|
45
|
+
italic: bool
|
46
|
+
strikethrough: bool
|
47
|
+
underline: bool
|
48
|
+
code: bool
|
49
|
+
color: str
|
50
|
+
|
51
|
+
|
52
|
+
class RichTextItemPydantic(BaseModel):
|
53
|
+
type: str # 'text', 'mention', 'equation'
|
54
|
+
text: Optional[TextContentPydantic] = None
|
55
|
+
annotations: Annotations
|
56
|
+
plain_text: str
|
57
|
+
href: Optional[str] = None
|
58
|
+
|
59
|
+
|
60
|
+
# Database property schema types (these are schema definitions, not values)
|
61
|
+
class StatusOption(BaseModel):
|
62
|
+
id: str
|
63
|
+
name: str
|
64
|
+
color: str
|
65
|
+
description: Optional[str] = None
|
66
|
+
|
67
|
+
|
68
|
+
class StatusGroup(BaseModel):
|
69
|
+
id: str
|
70
|
+
name: str
|
71
|
+
color: str
|
72
|
+
option_ids: List[str]
|
73
|
+
|
74
|
+
|
75
|
+
class StatusPropertySchema(BaseModel):
|
76
|
+
options: List[StatusOption]
|
77
|
+
groups: List[StatusGroup]
|
78
|
+
|
79
|
+
|
80
|
+
class DatabaseStatusProperty(BaseModel):
|
81
|
+
id: str
|
82
|
+
name: str
|
83
|
+
type: Literal["status"]
|
84
|
+
status: StatusPropertySchema
|
85
|
+
|
86
|
+
|
87
|
+
class RelationPropertySchema(BaseModel):
|
88
|
+
database_id: str
|
89
|
+
type: str # "single_property"
|
90
|
+
single_property: Dict[str, Any]
|
91
|
+
|
92
|
+
|
93
|
+
class DatabaseRelationProperty(BaseModel):
|
94
|
+
id: str
|
95
|
+
name: str
|
96
|
+
type: Literal["relation"]
|
97
|
+
relation: RelationPropertySchema
|
98
|
+
|
99
|
+
|
100
|
+
class DatabaseUrlProperty(BaseModel):
|
101
|
+
id: str
|
102
|
+
name: str
|
103
|
+
type: Literal["url"]
|
104
|
+
url: Dict[str, Any] # Usually empty dict
|
105
|
+
|
106
|
+
|
107
|
+
class DatabaseRichTextProperty(BaseModel):
|
108
|
+
id: str
|
109
|
+
name: str
|
110
|
+
type: Literal["rich_text"]
|
111
|
+
rich_text: Dict[str, Any] # Usually empty dict
|
112
|
+
|
113
|
+
|
114
|
+
class MultiSelectOption(BaseModel):
|
115
|
+
id: str
|
116
|
+
name: str
|
117
|
+
color: str
|
118
|
+
description: Optional[str] = None
|
119
|
+
|
120
|
+
|
121
|
+
class MultiSelectPropertySchema(BaseModel):
|
122
|
+
options: List[MultiSelectOption]
|
123
|
+
|
124
|
+
|
125
|
+
class DatabaseMultiSelectProperty(BaseModel):
|
126
|
+
id: str
|
127
|
+
name: str
|
128
|
+
type: Literal["multi_select"]
|
129
|
+
multi_select: MultiSelectPropertySchema
|
130
|
+
|
131
|
+
|
132
|
+
class DatabaseTitleProperty(BaseModel):
|
133
|
+
id: str
|
134
|
+
name: str
|
135
|
+
type: Literal["title"]
|
136
|
+
title: Dict[str, Any] # Usually empty dict
|
137
|
+
|
138
|
+
|
139
|
+
# Generic database property for unknown types
|
140
|
+
class GenericDatabaseProperty(BaseModel):
|
141
|
+
id: str
|
142
|
+
name: str
|
143
|
+
type: str
|
144
|
+
|
145
|
+
model_config = ConfigDict(extra="allow")
|
146
|
+
|
147
|
+
|
148
|
+
# Union of all database property types
|
149
|
+
DatabaseProperty = Union[
|
150
|
+
DatabaseStatusProperty,
|
151
|
+
DatabaseRelationProperty,
|
152
|
+
DatabaseUrlProperty,
|
153
|
+
DatabaseRichTextProperty,
|
154
|
+
DatabaseMultiSelectProperty,
|
155
|
+
DatabaseTitleProperty,
|
156
|
+
GenericDatabaseProperty,
|
157
|
+
]
|
158
|
+
|
159
|
+
|
160
|
+
# Page property value types (these are actual values, not schemas)
|
161
|
+
class StatusValue(BaseModel):
|
162
|
+
id: str
|
163
|
+
name: str
|
164
|
+
color: str
|
165
|
+
|
166
|
+
|
167
|
+
class StatusProperty(BaseModel):
|
168
|
+
id: str
|
169
|
+
type: str # 'status'
|
170
|
+
status: Optional[StatusValue] = None
|
171
|
+
|
172
|
+
|
173
|
+
class RelationItem(BaseModel):
|
174
|
+
id: str
|
175
|
+
|
176
|
+
|
177
|
+
class RelationProperty(BaseModel):
|
178
|
+
id: str
|
179
|
+
type: str # 'relation'
|
180
|
+
relation: List[RelationItem]
|
181
|
+
has_more: bool
|
182
|
+
|
183
|
+
|
184
|
+
class UrlProperty(BaseModel):
|
185
|
+
id: str
|
186
|
+
type: str # 'url'
|
187
|
+
url: Optional[str] = None
|
188
|
+
|
189
|
+
|
190
|
+
class RichTextProperty(BaseModel):
|
191
|
+
id: str
|
192
|
+
type: str # 'rich_text'
|
193
|
+
rich_text: List[RichTextItemPydantic]
|
194
|
+
|
195
|
+
|
196
|
+
class MultiSelectItem(BaseModel):
|
197
|
+
id: str
|
198
|
+
name: str
|
199
|
+
color: str
|
200
|
+
|
201
|
+
|
202
|
+
class MultiSelectProperty(BaseModel):
|
203
|
+
id: str
|
204
|
+
type: str # 'multi_select'
|
205
|
+
multi_select: List[MultiSelectItem]
|
206
|
+
|
207
|
+
|
208
|
+
class TitleProperty(BaseModel):
|
209
|
+
id: str
|
210
|
+
type: str # 'title'
|
211
|
+
title: List[RichTextItemPydantic]
|
212
|
+
|
213
|
+
|
214
|
+
# Cover types
|
215
|
+
class ExternalCover(BaseModel):
|
216
|
+
url: str
|
217
|
+
|
218
|
+
|
219
|
+
class NotionCover(BaseModel):
|
220
|
+
type: str # 'external', 'file'
|
221
|
+
external: Optional[ExternalCover] = None
|
222
|
+
|
223
|
+
|
224
|
+
# Parent types for Pydantic
|
225
|
+
class NotionParent(BaseModel):
|
226
|
+
type: str # 'database_id', 'page_id', 'workspace'
|
227
|
+
database_id: Optional[str] = None
|
228
|
+
page_id: Optional[str] = None
|
229
|
+
|
230
|
+
|
231
|
+
# User type for Pydantic
|
232
|
+
class NotionUser(BaseModel):
|
233
|
+
object: str # 'user'
|
234
|
+
id: str
|
235
|
+
|
236
|
+
|
237
|
+
# Database object
|
238
|
+
class NotionDatabaseResponse(BaseModel):
|
239
|
+
"""
|
240
|
+
Represents the response from the Notion API when retrieving a database.
|
241
|
+
"""
|
242
|
+
|
243
|
+
object: Literal["database"]
|
244
|
+
id: str
|
245
|
+
cover: Optional[Any] = None
|
246
|
+
icon: Optional[Icon] = None
|
247
|
+
cover: Optional[Cover]
|
248
|
+
created_time: str
|
249
|
+
last_edited_time: str
|
250
|
+
created_by: NotionUser
|
251
|
+
last_edited_by: NotionUser
|
252
|
+
title: List[RichTextItemPydantic]
|
253
|
+
description: List[Any]
|
254
|
+
is_inline: bool
|
255
|
+
properties: Dict[
|
256
|
+
str, Any
|
257
|
+
] # Using Any for flexibility with different property schemas
|
258
|
+
parent: NotionParent
|
259
|
+
url: str
|
260
|
+
public_url: Optional[str] = None
|
261
|
+
archived: bool
|
262
|
+
in_trash: bool
|
263
|
+
|
264
|
+
|
265
|
+
class NotionPageResponse(BaseModel):
|
266
|
+
object: Literal["page"]
|
267
|
+
id: str
|
268
|
+
created_time: str
|
269
|
+
last_edited_time: str
|
270
|
+
created_by: NotionUser
|
271
|
+
last_edited_by: NotionUser
|
272
|
+
cover: Optional[NotionCover] = None
|
273
|
+
icon: Optional[Icon] = None
|
274
|
+
parent: NotionParent
|
275
|
+
archived: bool
|
276
|
+
in_trash: bool
|
277
|
+
properties: Dict[str, Any]
|
278
|
+
url: str
|
279
|
+
public_url: Optional[str] = None
|
280
|
+
|
281
|
+
|
282
|
+
class NotionQueryResponse(BaseModel):
|
283
|
+
"""
|
284
|
+
Complete Notion search/query response model that can contain both pages and databases.
|
285
|
+
"""
|
286
|
+
|
287
|
+
object: Literal["list"]
|
288
|
+
results: List[Union[NotionPageResponse, NotionDatabaseResponse]]
|
289
|
+
next_cursor: Optional[str] = None
|
290
|
+
has_more: bool
|
291
|
+
type: Literal["page_or_database"]
|
292
|
+
page_or_database: Dict[str, Any]
|
293
|
+
request_id: str
|
294
|
+
|
295
|
+
|
296
|
+
# Specific response type for database queries (pages only)
|
297
|
+
class NotionQueryDatabaseResponse(BaseModel):
|
298
|
+
"""
|
299
|
+
Notion database query response model for querying pages within a database.
|
300
|
+
"""
|
301
|
+
|
302
|
+
object: Literal["list"]
|
303
|
+
results: List[NotionPageResponse]
|
304
|
+
next_cursor: Optional[str] = None
|
305
|
+
has_more: bool
|
306
|
+
type: Literal["page_or_database"]
|
307
|
+
page_or_database: Dict[str, Any]
|
308
|
+
request_id: str
|
309
|
+
|
310
|
+
|
311
|
+
# Specific response type for search results (can be mixed)
|
312
|
+
class NotionSearchResponse(BaseModel):
|
313
|
+
"""
|
314
|
+
Notion search response model that can return both pages and databases.
|
315
|
+
"""
|
316
|
+
|
317
|
+
object: Literal["list"]
|
318
|
+
results: List[Union[NotionPageResponse, NotionDatabaseResponse]]
|
319
|
+
next_cursor: Optional[str] = None
|
320
|
+
has_more: bool
|
321
|
+
type: Literal["page_or_database"]
|
322
|
+
page_or_database: Dict[str, Any]
|
323
|
+
request_id: str
|
324
|
+
|
325
|
+
|
326
|
+
class NotionDatabaseSearchResponse(BaseModel):
|
327
|
+
"""
|
328
|
+
Notion search response model for database-only searches.
|
329
|
+
"""
|
330
|
+
|
331
|
+
object: Literal["list"]
|
332
|
+
results: List[NotionDatabaseResponse]
|
333
|
+
next_cursor: Optional[str] = None
|
334
|
+
has_more: bool
|
335
|
+
type: Literal["page_or_database"]
|
336
|
+
page_or_database: Dict[str, Any]
|
337
|
+
request_id: str
|
@@ -1,25 +1,24 @@
|
|
1
1
|
from __future__ import annotations
|
2
|
+
|
2
3
|
import asyncio
|
3
4
|
import random
|
4
5
|
from typing import Any, AsyncGenerator, Dict, Optional
|
5
6
|
|
7
|
+
from notionary import NotionPage
|
6
8
|
from notionary.database.client import NotionDatabaseClient
|
9
|
+
from notionary.database.database_filter_builder import DatabaseFilterBuilder
|
10
|
+
from notionary.database.database_provider import NotionDatabaseProvider
|
7
11
|
from notionary.models.notion_database_response import (
|
8
12
|
NotionDatabaseResponse,
|
9
13
|
NotionPageResponse,
|
10
14
|
NotionQueryDatabaseResponse,
|
11
15
|
)
|
12
|
-
from notionary import NotionPage
|
13
|
-
|
14
|
-
from notionary.database.database_provider import NotionDatabaseProvider
|
15
|
-
|
16
|
-
from notionary.database.database_filter_builder import DatabaseFilterBuilder
|
17
16
|
from notionary.telemetry import (
|
18
|
-
ProductTelemetry,
|
19
17
|
DatabaseFactoryUsedEvent,
|
18
|
+
ProductTelemetry,
|
20
19
|
QueryOperationEvent,
|
21
20
|
)
|
22
|
-
from notionary.util import
|
21
|
+
from notionary.util import LoggingMixin, factory_only
|
23
22
|
|
24
23
|
|
25
24
|
class NotionDatabase(LoggingMixin):
|
notionary/file_upload/client.py
CHANGED
@@ -1,21 +1,19 @@
|
|
1
|
-
from typing import Optional, BinaryIO
|
2
1
|
from io import BytesIO
|
3
2
|
from pathlib import Path
|
4
|
-
import
|
3
|
+
from typing import BinaryIO, Optional
|
5
4
|
|
6
5
|
import aiofiles
|
6
|
+
import httpx
|
7
7
|
|
8
8
|
from notionary.base_notion_client import BaseNotionClient
|
9
9
|
from notionary.file_upload.models import (
|
10
|
-
FileUploadResponse,
|
11
|
-
FileUploadListResponse,
|
12
|
-
FileUploadCreateRequest,
|
13
10
|
FileUploadCompleteRequest,
|
11
|
+
FileUploadCreateRequest,
|
12
|
+
FileUploadListResponse,
|
13
|
+
FileUploadResponse,
|
14
14
|
)
|
15
|
-
from notionary.util import singleton
|
16
15
|
|
17
16
|
|
18
|
-
@singleton
|
19
17
|
class NotionFileUploadClient(BaseNotionClient):
|
20
18
|
"""
|
21
19
|
Client for Notion file upload operations.
|
notionary/file_upload/models.py
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
import asyncio
|
2
2
|
import mimetypes
|
3
|
-
from typing import Optional
|
4
|
-
from pathlib import Path
|
5
3
|
from datetime import datetime, timedelta
|
6
4
|
from io import BytesIO
|
7
|
-
|
5
|
+
from pathlib import Path
|
6
|
+
from typing import Optional
|
8
7
|
|
9
8
|
from notionary.file_upload.models import FileUploadResponse
|
10
9
|
from notionary.util import LoggingMixin
|