notionary 0.1.12__py3-none-any.whl → 0.1.13__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.
Files changed (54) hide show
  1. notionary/__init__.py +14 -10
  2. notionary/{core/converters → converters}/elements/audio_element.py +1 -1
  3. notionary/{core/converters → converters}/elements/bookmark_element.py +1 -1
  4. notionary/{core/converters → converters}/elements/callout_element.py +2 -2
  5. notionary/{core/converters → converters}/elements/code_block_element.py +1 -1
  6. notionary/{core/converters → converters}/elements/column_element.py +1 -1
  7. notionary/{core/converters → converters}/elements/divider_element.py +1 -1
  8. notionary/{core/converters → converters}/elements/embed_element.py +1 -1
  9. notionary/{core/converters → converters}/elements/heading_element.py +2 -2
  10. notionary/{core/converters → converters}/elements/image_element.py +1 -1
  11. notionary/{core/converters → converters}/elements/list_element.py +2 -2
  12. notionary/{core/converters → converters}/elements/paragraph_element.py +2 -2
  13. notionary/{core/converters → converters}/elements/qoute_element.py +1 -1
  14. notionary/{core/converters → converters}/elements/table_element.py +2 -2
  15. notionary/{core/converters → converters}/elements/todo_lists.py +2 -2
  16. notionary/{core/converters → converters}/elements/toggle_element.py +1 -6
  17. notionary/{core/converters → converters}/elements/video_element.py +1 -1
  18. notionary/{core/converters → converters}/markdown_to_notion_converter.py +2 -2
  19. notionary/{core/converters → converters}/notion_to_markdown_converter.py +2 -2
  20. notionary/{core/converters → converters}/registry/block_element_registry.py +2 -2
  21. notionary/{core/converters → converters}/registry/block_element_registry_builder.py +18 -18
  22. notionary/{core/database → database}/database_discovery.py +19 -17
  23. notionary/{core/database → database}/database_info_service.py +1 -1
  24. notionary/{core/database/notion_database_manager.py → database/notion_database.py} +13 -14
  25. notionary/{core/database/notion_database_manager_factory.py → database/notion_database_factory.py} +8 -12
  26. notionary/{core/page → page}/content/page_content_manager.py +6 -8
  27. notionary/{core/page → page}/metadata/metadata_editor.py +2 -2
  28. notionary/{core/page → page}/metadata/notion_icon_manager.py +1 -1
  29. notionary/{core/page → page}/metadata/notion_page_cover_manager.py +1 -1
  30. notionary/page/notion_page.py +504 -0
  31. notionary/page/notion_page_factory.py +256 -0
  32. notionary/{core/page → page}/properites/database_property_service.py +1 -1
  33. notionary/{core/page → page}/properites/page_property_manager.py +7 -7
  34. notionary/{core/page → page}/relations/notion_page_relation_manager.py +3 -3
  35. notionary/{core/page → page}/relations/notion_page_title_resolver.py +1 -1
  36. notionary/{core/page → page}/relations/page_database_relation.py +1 -1
  37. notionary/util/page_id_utils.py +3 -1
  38. {notionary-0.1.12.dist-info → notionary-0.1.13.dist-info}/METADATA +1 -1
  39. notionary-0.1.13.dist-info/RECORD +56 -0
  40. notionary/core/page/notion_page_manager.py +0 -312
  41. notionary-0.1.12.dist-info/RECORD +0 -55
  42. /notionary/{core/converters → converters}/__init__.py +0 -0
  43. /notionary/{core/converters → converters}/elements/notion_block_element.py +0 -0
  44. /notionary/{core/converters → converters}/elements/text_inline_formatter.py +0 -0
  45. /notionary/{core/database → database}/models/page_result.py +0 -0
  46. /notionary/{core/notion_client.py → notion_client.py} +0 -0
  47. /notionary/{core/page → page}/content/notion_page_content_chunker.py +0 -0
  48. /notionary/{core/page → page}/properites/property_formatter.py +0 -0
  49. /notionary/{core/page → page}/properites/property_operation_result.py +0 -0
  50. /notionary/{core/page → page}/properites/property_value_extractor.py +0 -0
  51. /notionary/{core/page → page}/relations/relation_operation_result.py +0 -0
  52. {notionary-0.1.12.dist-info → notionary-0.1.13.dist-info}/WHEEL +0 -0
  53. {notionary-0.1.12.dist-info → notionary-0.1.13.dist-info}/licenses/LICENSE +0 -0
  54. {notionary-0.1.12.dist-info → notionary-0.1.13.dist-info}/top_level.txt +0 -0
notionary/__init__.py CHANGED
@@ -1,20 +1,24 @@
1
- from .core.notion_client import NotionClient
1
+ from .notion_client import NotionClient
2
2
 
3
- from .core.database.notion_database_manager import NotionDatabaseManager
4
- from .core.database.notion_database_manager_factory import NotionDatabaseFactory
5
- from .core.database.database_discovery import DatabaseDiscovery
3
+ from .database.notion_database import NotionDatabase
4
+ from .database.notion_database_factory import NotionDatabaseFactory
5
+ from .database.database_discovery import DatabaseDiscovery
6
6
 
7
- from .core.page.notion_page_manager import NotionPageManager
7
+ from .page.notion_page import NotionPage
8
+ from .page.notion_page_factory import NotionPageFactory
8
9
 
9
- from .core.converters.registry.block_element_registry import BlockElementRegistry
10
- from .core.converters.registry.block_element_registry_builder import BlockElementRegistryBuilder
10
+ from .converters.registry.block_element_registry import BlockElementRegistry
11
+ from .converters.registry.block_element_registry_builder import (
12
+ BlockElementRegistryBuilder,
13
+ )
11
14
 
12
15
  __all__ = [
13
16
  "NotionClient",
14
- "NotionDatabaseManager",
17
+ "NotionDatabase",
15
18
  "NotionDatabaseFactory",
16
19
  "DatabaseDiscovery",
17
- "NotionPageManager",
20
+ "NotionPage",
21
+ "NotionPageFactory",
18
22
  "BlockElementRegistry",
19
23
  "BlockElementRegistryBuilder",
20
- ]
24
+ ]
@@ -1,6 +1,6 @@
1
1
  import re
2
2
  from typing import Dict, Any, Optional, List
3
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
3
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
4
4
 
5
5
 
6
6
  class AudioElement(NotionBlockElement):
@@ -2,7 +2,7 @@ import re
2
2
  from typing import Dict, Any, Optional, List, Tuple
3
3
  from typing_extensions import override
4
4
 
5
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
5
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
6
6
 
7
7
 
8
8
  class BookmarkElement(NotionBlockElement):
@@ -2,8 +2,8 @@ from typing import Dict, Any, Optional
2
2
  from typing_extensions import override
3
3
  import re
4
4
 
5
- from notionary.core.converters.elements.text_inline_formatter import TextInlineFormatter
6
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
5
+ from notionary.converters.elements.text_inline_formatter import TextInlineFormatter
6
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
7
7
 
8
8
 
9
9
  class CalloutElement(NotionBlockElement):
@@ -1,7 +1,7 @@
1
1
  from typing import Dict, Any, Optional, List, Tuple
2
2
  from typing_extensions import override
3
3
  import re
4
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
4
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
5
5
 
6
6
 
7
7
  class CodeBlockElement(NotionBlockElement):
@@ -2,7 +2,7 @@ import re
2
2
  from typing import Dict, Any, Optional, List, Tuple, Callable
3
3
  from typing_extensions import override
4
4
 
5
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
5
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
6
6
 
7
7
 
8
8
  class ColumnElement(NotionBlockElement):
@@ -4,7 +4,7 @@ from typing import Dict, Any, Optional
4
4
  from typing_extensions import override
5
5
  import re
6
6
 
7
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
7
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
8
8
 
9
9
 
10
10
  class DividerElement(NotionBlockElement):
@@ -1,6 +1,6 @@
1
1
  import re
2
2
  from typing import Dict, Any, Optional, List
3
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
3
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
4
4
 
5
5
 
6
6
  class EmbedElement(NotionBlockElement):
@@ -2,8 +2,8 @@ from typing import Dict, Any, Optional
2
2
  from typing_extensions import override
3
3
  import re
4
4
 
5
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
6
- from notionary.core.converters.elements.text_inline_formatter import TextInlineFormatter
5
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
6
+ from notionary.converters.elements.text_inline_formatter import TextInlineFormatter
7
7
 
8
8
 
9
9
  class HeadingElement(NotionBlockElement):
@@ -1,7 +1,7 @@
1
1
  import re
2
2
  from typing import Dict, Any, Optional, List
3
3
  from typing_extensions import override
4
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
4
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
5
5
 
6
6
 
7
7
  class ImageElement(NotionBlockElement):
@@ -1,8 +1,8 @@
1
1
  import re
2
2
  from typing import Dict, Any, Optional
3
3
  from typing_extensions import override
4
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
5
- from notionary.core.converters.elements.text_inline_formatter import TextInlineFormatter
4
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
5
+ from notionary.converters.elements.text_inline_formatter import TextInlineFormatter
6
6
 
7
7
 
8
8
  class BulletedListElement(NotionBlockElement):
@@ -1,8 +1,8 @@
1
1
  from typing import Dict, Any, Optional
2
2
  from typing_extensions import override
3
3
 
4
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
5
- from notionary.core.converters.elements.text_inline_formatter import TextInlineFormatter
4
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
5
+ from notionary.converters.elements.text_inline_formatter import TextInlineFormatter
6
6
 
7
7
 
8
8
  class ParagraphElement(NotionBlockElement):
@@ -2,7 +2,7 @@ import re
2
2
  from typing import Dict, Any, Optional, List, Tuple
3
3
  from typing_extensions import override
4
4
 
5
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
5
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
6
6
 
7
7
 
8
8
  class QuoteElement(NotionBlockElement):
@@ -3,8 +3,8 @@
3
3
  from typing import Dict, Any, Optional, List, Tuple
4
4
  from typing_extensions import override
5
5
  import re
6
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
7
- from notionary.core.converters.elements.text_inline_formatter import TextInlineFormatter
6
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
7
+ from notionary.converters.elements.text_inline_formatter import TextInlineFormatter
8
8
 
9
9
 
10
10
  class TableElement(NotionBlockElement):
@@ -1,8 +1,8 @@
1
1
  import re
2
2
  from typing import Dict, Any, Optional
3
3
  from typing_extensions import override
4
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
5
- from notionary.core.converters.elements.text_inline_formatter import TextInlineFormatter
4
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
5
+ from notionary.converters.elements.text_inline_formatter import TextInlineFormatter
6
6
 
7
7
 
8
8
  class TodoElement(NotionBlockElement):
@@ -1,7 +1,7 @@
1
1
  import re
2
2
  from typing import Dict, Any, Optional, List, Tuple, Callable
3
3
 
4
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
4
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
5
5
 
6
6
 
7
7
  class ToggleElement(NotionBlockElement):
@@ -171,17 +171,12 @@ class ToggleElement(NotionBlockElement):
171
171
  i += 1
172
172
  continue
173
173
 
174
- # Wenn context_aware aktiviert ist, prüfen wir für "Transcript"-Toggles
175
- # ob sie direkt nach einem Bullet Point kommen
176
174
  is_transcript_toggle = cls.TRANSCRIPT_TOGGLE_PATTERN.match(line.strip())
177
175
 
178
176
  if context_aware and is_transcript_toggle:
179
- # Prüfen, ob der Toggle in einem gültigen Kontext ist (nach Bullet Point)
180
177
  if i > 0 and lines[i - 1].strip().startswith("- "):
181
- # Gültiger Kontext, fahre fort
182
178
  pass
183
179
  else:
184
- # Ungültiger Kontext für Transcript-Toggle, überspringe ihn
185
180
  i += 1
186
181
  continue
187
182
 
@@ -1,6 +1,6 @@
1
1
  import re
2
2
  from typing import Dict, Any, Optional, List
3
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
3
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
4
4
 
5
5
 
6
6
  class VideoElement(NotionBlockElement):
@@ -1,9 +1,9 @@
1
1
  from typing import Dict, Any, List, Optional, Tuple
2
2
 
3
- from notionary.core.converters.registry.block_element_registry import (
3
+ from notionary.converters.registry.block_element_registry import (
4
4
  BlockElementRegistry,
5
5
  )
6
- from notionary.core.converters.registry.block_element_registry_builder import (
6
+ from notionary.converters.registry.block_element_registry_builder import (
7
7
  BlockElementRegistryBuilder,
8
8
  )
9
9
 
@@ -1,9 +1,9 @@
1
1
  from typing import Dict, Any, List, Optional
2
2
 
3
- from notionary.core.converters.registry.block_element_registry import (
3
+ from notionary.converters.registry.block_element_registry import (
4
4
  BlockElementRegistry,
5
5
  )
6
- from notionary.core.converters.registry.block_element_registry_builder import (
6
+ from notionary.converters.registry.block_element_registry_builder import (
7
7
  BlockElementRegistryBuilder,
8
8
  )
9
9
 
@@ -1,7 +1,7 @@
1
1
  from typing import Dict, Any, Optional, List, Type
2
2
 
3
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
4
- from notionary.core.converters.elements.text_inline_formatter import TextInlineFormatter
3
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
4
+ from notionary.converters.elements.text_inline_formatter import TextInlineFormatter
5
5
 
6
6
 
7
7
  class BlockElementRegistry:
@@ -1,30 +1,30 @@
1
1
  from typing import List, Type
2
2
  from collections import OrderedDict
3
3
 
4
- from notionary.core.converters.elements.audio_element import AudioElement
5
- from notionary.core.converters.elements.embed_element import EmbedElement
6
- from notionary.core.converters.elements.notion_block_element import NotionBlockElement
7
- from notionary.core.converters.registry.block_element_registry import (
4
+ from notionary.converters.elements.audio_element import AudioElement
5
+ from notionary.converters.elements.embed_element import EmbedElement
6
+ from notionary.converters.elements.notion_block_element import NotionBlockElement
7
+ from notionary.converters.registry.block_element_registry import (
8
8
  BlockElementRegistry,
9
9
  )
10
10
 
11
- from notionary.core.converters.elements.paragraph_element import ParagraphElement
12
- from notionary.core.converters.elements.heading_element import HeadingElement
13
- from notionary.core.converters.elements.callout_element import CalloutElement
14
- from notionary.core.converters.elements.code_block_element import CodeBlockElement
15
- from notionary.core.converters.elements.divider_element import DividerElement
16
- from notionary.core.converters.elements.table_element import TableElement
17
- from notionary.core.converters.elements.todo_lists import TodoElement
18
- from notionary.core.converters.elements.list_element import (
11
+ from notionary.converters.elements.paragraph_element import ParagraphElement
12
+ from notionary.converters.elements.heading_element import HeadingElement
13
+ from notionary.converters.elements.callout_element import CalloutElement
14
+ from notionary.converters.elements.code_block_element import CodeBlockElement
15
+ from notionary.converters.elements.divider_element import DividerElement
16
+ from notionary.converters.elements.table_element import TableElement
17
+ from notionary.converters.elements.todo_lists import TodoElement
18
+ from notionary.converters.elements.list_element import (
19
19
  BulletedListElement,
20
20
  NumberedListElement,
21
21
  )
22
- from notionary.core.converters.elements.qoute_element import QuoteElement
23
- from notionary.core.converters.elements.image_element import ImageElement
24
- from notionary.core.converters.elements.video_element import VideoElement
25
- from notionary.core.converters.elements.toggle_element import ToggleElement
26
- from notionary.core.converters.elements.bookmark_element import BookmarkElement
27
- from notionary.core.converters.elements.column_element import ColumnElement
22
+ from notionary.converters.elements.qoute_element import QuoteElement
23
+ from notionary.converters.elements.image_element import ImageElement
24
+ from notionary.converters.elements.video_element import VideoElement
25
+ from notionary.converters.elements.toggle_element import ToggleElement
26
+ from notionary.converters.elements.bookmark_element import BookmarkElement
27
+ from notionary.converters.elements.column_element import ColumnElement
28
28
 
29
29
 
30
30
  class BlockElementRegistryBuilder:
@@ -6,7 +6,7 @@ from typing import (
6
6
  Any,
7
7
  Tuple,
8
8
  )
9
- from notionary.core.notion_client import NotionClient
9
+ from notionary.notion_client import NotionClient
10
10
  from notionary.util.logging_mixin import LoggingMixin
11
11
 
12
12
 
@@ -37,43 +37,45 @@ class DatabaseDiscovery(LoggingMixin):
37
37
  List of tuples containing (database_title, database_id)
38
38
  """
39
39
  databases = []
40
-
40
+
41
41
  async for database in self._iter_databases(page_size):
42
42
  db_id = database.get("id")
43
43
  if not db_id:
44
44
  continue
45
-
45
+
46
46
  title = self._extract_database_title(database)
47
47
  databases.append((title, db_id))
48
-
48
+
49
49
  return databases
50
-
50
+
51
51
  async def discover_and_print(self, page_size: int = 100) -> List[Tuple[str, str]]:
52
52
  """
53
53
  Discover databases and print the results in a nicely formatted way.
54
-
54
+
55
55
  This is a convenience method that discovers databases and handles
56
56
  the formatting and printing of results.
57
-
57
+
58
58
  Args:
59
59
  page_size: The number of databases to fetch per request
60
-
60
+
61
61
  Returns:
62
62
  The same list of databases as discover() for further processing
63
63
  """
64
64
  databases = await self.discover(page_size)
65
-
65
+
66
66
  if not databases:
67
67
  print("\n⚠️ No databases found!")
68
68
  print("Please ensure your Notion integration has access to databases.")
69
- print("You need to share the databases with your integration in Notion settings.")
69
+ print(
70
+ "You need to share the databases with your integration in Notion settings."
71
+ )
70
72
  return databases
71
-
73
+
72
74
  print(f"✅ Found {len(databases)} databases:")
73
-
75
+
74
76
  for i, (title, db_id) in enumerate(databases, 1):
75
77
  print(f"{i}. {title} (ID: {db_id})")
76
-
78
+
77
79
  return databases
78
80
 
79
81
  async def _iter_databases(
@@ -113,7 +115,7 @@ class DatabaseDiscovery(LoggingMixin):
113
115
 
114
116
  if not result.get("has_more") or not result.get("next_cursor"):
115
117
  return
116
-
118
+
117
119
  start_cursor = result["next_cursor"]
118
120
 
119
121
  def _extract_database_title(self, database: Dict[str, Any]) -> str:
@@ -128,7 +130,7 @@ class DatabaseDiscovery(LoggingMixin):
128
130
  """
129
131
  if "title" not in database:
130
132
  return "Untitled"
131
-
133
+
132
134
  title_parts = []
133
135
  for text_obj in database["title"]:
134
136
  if "plain_text" in text_obj:
@@ -136,5 +138,5 @@ class DatabaseDiscovery(LoggingMixin):
136
138
 
137
139
  if not title_parts:
138
140
  return "Untitled"
139
-
140
- return "".join(title_parts)
141
+
142
+ return "".join(title_parts)
@@ -1,5 +1,5 @@
1
1
  from typing import Optional
2
- from notionary.core.notion_client import NotionClient
2
+ from notionary.notion_client import NotionClient
3
3
 
4
4
 
5
5
  class DatabaseInfoService:
@@ -1,12 +1,12 @@
1
1
  from typing import Any, AsyncGenerator, Dict, List, Optional
2
2
 
3
- from notionary.core.notion_client import NotionClient
4
- from notionary.core.page.notion_page_manager import NotionPageManager
3
+ from notionary.notion_client import NotionClient
4
+ from notionary.page.notion_page import NotionPage
5
5
  from notionary.util.logging_mixin import LoggingMixin
6
6
  from notionary.util.page_id_utils import format_uuid
7
7
 
8
8
 
9
- class NotionDatabaseManager(LoggingMixin):
9
+ class NotionDatabase(LoggingMixin):
10
10
  """
11
11
  Minimal manager for Notion databases.
12
12
  Focused exclusively on creating basic pages and retrieving page managers
@@ -24,12 +24,12 @@ class NotionDatabaseManager(LoggingMixin):
24
24
  self.database_id = format_uuid(database_id) or database_id
25
25
  self._client = NotionClient(token=token)
26
26
 
27
- async def create_blank_page(self) -> Optional[NotionPageManager]:
27
+ async def create_blank_page(self) -> Optional[NotionPage]:
28
28
  """
29
29
  Create a new blank page in the database with minimal properties.
30
30
 
31
31
  Returns:
32
- NotionPageManager for the created page, or None if creation failed
32
+ NotionPage for the created page, or None if creation failed
33
33
  """
34
34
  try:
35
35
  response = await self._client.post(
@@ -42,7 +42,7 @@ class NotionDatabaseManager(LoggingMixin):
42
42
  "Created blank page %s in database %s", page_id, self.database_id
43
43
  )
44
44
 
45
- return NotionPageManager(page_id=page_id)
45
+ return NotionPage(page_id=page_id)
46
46
 
47
47
  self.logger.warning("Page creation failed: invalid response")
48
48
  return None
@@ -50,13 +50,13 @@ class NotionDatabaseManager(LoggingMixin):
50
50
  except Exception as e:
51
51
  self.logger.error("Error creating blank page: %s", str(e))
52
52
  return None
53
-
53
+
54
54
  async def get_pages(
55
55
  self,
56
56
  limit: int = 100,
57
57
  filter_conditions: Optional[Dict[str, Any]] = None,
58
58
  sorts: Optional[List[Dict[str, Any]]] = None,
59
- ) -> List[NotionPageManager]:
59
+ ) -> List[NotionPage]:
60
60
  """
61
61
  Get all pages from the database.
62
62
 
@@ -66,7 +66,7 @@ class NotionDatabaseManager(LoggingMixin):
66
66
  sorts: Optional sort instructions for the database query
67
67
 
68
68
  Returns:
69
- List of NotionPageManager instances for each page
69
+ List of NotionPage instances for each page
70
70
  """
71
71
  self.logger.debug(
72
72
  "Getting up to %d pages with filter: %s, sorts: %s",
@@ -75,7 +75,7 @@ class NotionDatabaseManager(LoggingMixin):
75
75
  sorts,
76
76
  )
77
77
 
78
- pages: List[NotionPageManager] = []
78
+ pages: List[NotionPage] = []
79
79
  count = 0
80
80
 
81
81
  async for page in self.iter_pages(
@@ -99,7 +99,7 @@ class NotionDatabaseManager(LoggingMixin):
99
99
  page_size: int = 100,
100
100
  filter_conditions: Optional[Dict[str, Any]] = None,
101
101
  sorts: Optional[List[Dict[str, Any]]] = None,
102
- ) -> AsyncGenerator[NotionPageManager, None]:
102
+ ) -> AsyncGenerator[NotionPage, None]:
103
103
  """
104
104
  Asynchronous generator that yields pages from the database.
105
105
  Directly queries the Notion API without using the schema.
@@ -110,7 +110,7 @@ class NotionDatabaseManager(LoggingMixin):
110
110
  sorts: Optional sort instructions for the database query
111
111
 
112
112
  Yields:
113
- NotionPageManager instances for each page
113
+ NotionPage instances for each page
114
114
  """
115
115
  self.logger.debug(
116
116
  "Iterating pages with page_size: %d, filter: %s, sorts: %s",
@@ -149,7 +149,7 @@ class NotionDatabaseManager(LoggingMixin):
149
149
 
150
150
  page_url = f"https://notion.so/{page_id.replace('-', '')}"
151
151
 
152
- notion_page_manager = NotionPageManager(
152
+ notion_page_manager = NotionPage(
153
153
  page_id=page_id, title=title, url=page_url
154
154
  )
155
155
  yield notion_page_manager
@@ -220,4 +220,3 @@ class NotionDatabaseManager(LoggingMixin):
220
220
  async def close(self) -> None:
221
221
  """Close the client connection."""
222
222
  await self._client.close()
223
-
@@ -2,8 +2,8 @@ import logging
2
2
  from typing import List, Optional, Dict, Any
3
3
  from difflib import SequenceMatcher
4
4
 
5
- from notionary.core.notion_client import NotionClient
6
- from notionary.core.database.notion_database_manager import NotionDatabaseManager
5
+ from notionary.database.notion_database import NotionDatabase
6
+ from notionary.notion_client import NotionClient
7
7
  from notionary.exceptions.database_exceptions import (
8
8
  DatabaseConnectionError,
9
9
  DatabaseInitializationError,
@@ -29,7 +29,7 @@ class NotionDatabaseFactory(LoggingMixin):
29
29
  @classmethod
30
30
  async def from_database_id(
31
31
  cls, database_id: str, token: Optional[str] = None
32
- ) -> NotionDatabaseManager:
32
+ ) -> NotionDatabase:
33
33
  """
34
34
  Create a NotionDatabaseManager from a database ID.
35
35
 
@@ -45,7 +45,7 @@ class NotionDatabaseFactory(LoggingMixin):
45
45
  try:
46
46
  formatted_id = format_uuid(database_id) or database_id
47
47
 
48
- manager = NotionDatabaseManager(formatted_id, token)
48
+ manager = NotionDatabase(formatted_id, token)
49
49
 
50
50
  logger.info(
51
51
  "Successfully created database manager for ID: %s", formatted_id
@@ -53,10 +53,8 @@ class NotionDatabaseFactory(LoggingMixin):
53
53
  return manager
54
54
 
55
55
  except DatabaseInitializationError:
56
- # Re-raise the already typed exception
57
56
  raise
58
57
  except NotionDatabaseException:
59
- # Re-raise other custom exceptions
60
58
  raise
61
59
  except Exception as e:
62
60
  error_msg = f"Error connecting to database {database_id}: {str(e)}"
@@ -66,7 +64,7 @@ class NotionDatabaseFactory(LoggingMixin):
66
64
  @classmethod
67
65
  async def from_database_name(
68
66
  cls, database_name: str, token: Optional[str] = None
69
- ) -> NotionDatabaseManager:
67
+ ) -> NotionDatabase:
70
68
  """
71
69
  Create a NotionDatabaseManager by finding a database with a matching name.
72
70
  Uses fuzzy matching to find the closest match to the given name.
@@ -86,13 +84,11 @@ class NotionDatabaseFactory(LoggingMixin):
86
84
  try:
87
85
  logger.debug("Using search endpoint to find databases")
88
86
 
89
- # Create search query for databases
90
87
  search_payload = {
91
88
  "filter": {"property": "object", "value": "database"},
92
89
  "page_size": 100,
93
90
  }
94
91
 
95
- # Perform search
96
92
  response = await client.post("search", search_payload)
97
93
 
98
94
  if not response or "results" not in response:
@@ -144,9 +140,9 @@ class NotionDatabaseFactory(LoggingMixin):
144
140
  best_score,
145
141
  )
146
142
 
147
- manager = NotionDatabaseManager(database_id, token)
143
+ manager = NotionDatabase(database_id, token)
148
144
 
149
- logger.info(f"Successfully created database manager for '{matched_name}'")
145
+ logger.info("Successfully created database manager for '%s'", matched_name)
150
146
  await client.close()
151
147
  return manager
152
148
 
@@ -193,4 +189,4 @@ class NotionDatabaseFactory(LoggingMixin):
193
189
  if "plain_text" in text_obj:
194
190
  text_parts.append(text_obj["plain_text"])
195
191
 
196
- return "".join(text_parts)
192
+ return "".join(text_parts)
@@ -1,17 +1,15 @@
1
- import re
2
1
  from typing import Any, Dict, List, Optional
3
2
 
4
- from notionary.core.converters.markdown_to_notion_converter import (
3
+ from notionary.notion_client import NotionClient
4
+ from notionary.converters.registry.block_element_registry import BlockElementRegistry
5
+
6
+ from notionary.converters.markdown_to_notion_converter import (
5
7
  MarkdownToNotionConverter,
6
8
  )
7
- from notionary.core.converters.notion_to_markdown_converter import (
9
+ from notionary.converters.notion_to_markdown_converter import (
8
10
  NotionToMarkdownConverter,
9
11
  )
10
- from notionary.core.converters.registry.block_element_registry import (
11
- BlockElementRegistry,
12
- )
13
- from notionary.core.notion_client import NotionClient
14
- from notionary.core.page.content.notion_page_content_chunker import (
12
+ from notionary.page.content.notion_page_content_chunker import (
15
13
  NotionPageContentChunker,
16
14
  )
17
15
  from notionary.util.logging_mixin import LoggingMixin
@@ -1,6 +1,6 @@
1
1
  from typing import Any, Dict, Optional
2
- from notionary.core.notion_client import NotionClient
3
- from notionary.core.page.properites.property_formatter import NotionPropertyFormatter
2
+ from notionary.notion_client import NotionClient
3
+ from notionary.page.properites.property_formatter import NotionPropertyFormatter
4
4
  from notionary.util.logging_mixin import LoggingMixin
5
5
 
6
6
 
@@ -1,6 +1,6 @@
1
1
  from typing import Any, Dict, Optional
2
2
 
3
- from notionary.core.notion_client import NotionClient
3
+ from notionary.notion_client import NotionClient
4
4
  from notionary.util.logging_mixin import LoggingMixin
5
5
 
6
6
 
@@ -1,6 +1,6 @@
1
1
  import random
2
2
  from typing import Any, Dict, Optional
3
- from notionary.core.notion_client import NotionClient
3
+ from notionary.notion_client import NotionClient
4
4
  from notionary.util.logging_mixin import LoggingMixin
5
5
 
6
6